// Copyright 2017-2025 @pezkuwi/app-js authors & contributors // SPDX-License-Identifier: Apache-2.0 import React, { useCallback, useState } from 'react'; import { Button, Input, Popup } from '@pezkuwi/react-components'; import { useTranslation } from './translate.js'; interface Props { className?: string; isCustomExample: boolean; isRunning: boolean; removeSnippet: () => void; runJs: () => void; saveSnippet: (snippetName: string) => void; snippetName?: string; stopJs: () => void; } function ActionButtons ({ className = '', isCustomExample, isRunning, removeSnippet, runJs, saveSnippet, stopJs }: Props): React.ReactElement { const { t } = useTranslation(); const [snippetName, setSnippetName] = useState(''); const _onChangeName = useCallback( (snippetName: string) => setSnippetName(snippetName), [] ); const _onPopupClose = useCallback( (): void => { setSnippetName(''); }, [] ); const _saveSnippet = useCallback( (): void => { saveSnippet(snippetName); _onPopupClose(); }, [_onPopupClose, saveSnippet, snippetName] ); return ( {isCustomExample ? (