import { useState } from '@wordpress/element'; import { useHotkeys } from 'react-hotkeys-hook'; import { Button, TextControl, Dropdown, MenuItem, MenuGroup, } from '@wordpress/components'; import { PanelEditorWrapperProps, PanelEditorProps, } from '@components/DesignPanel/types'; import { isMac } from '@utils/devices'; import CheckIcon from 'blockbite-icons/dist/Check'; export default function PanelEditorDropdown({ panels, panelId = null, setPanelId = null, }: PanelEditorWrapperProps) { const [open, setOpen] = useState(false); const [activeKeyword, setActiveKeyword] = useState(''); const filteredOptions = panels.filter((p) => { const controlLabels = p.controls.map((control: any) => control.label); return ( p.label.toLowerCase().includes(activeKeyword.toLowerCase()) || controlLabels.some((label: string) => label.toLowerCase().includes(activeKeyword.toLowerCase()) ) ); }); const currentCategory = panels.find((p) => p.id === panelId); useHotkeys('alt+k', () => setOpen((prev) => !prev)); return ( ( )} renderContent={({ onClose }) => (
setActiveKeyword(value)} autoComplete="off" />
{filteredOptions.length === 0 && (
No options found.
)} {filteredOptions.map((option: PanelEditorProps) => ( : null } isSelected={currentCategory?.id === option.id} onClick={() => { setPanelId(option.id); setActiveKeyword(''); onClose(); }} > {option.label} ))}
)} /> ); }