import { Fragment } from '@wordpress/element'; import { Listbox, Transition } from '@headlessui/react'; import './Select.scss'; import PremiumBadge from '../partials/premium-badge'; /** * A reusable styled Select component supporting flat options and option groups. * @param {object} props - Props: options (array), selected (object), setSelected (function) */ const Select = ({ options, selected, setSelected, placeholder = 'Select an option', variantClass = '', className = '', disabled = false, ariaLabel = '' }) => { const renderOption = (option) => { const disabled = option.disabled ?? false; return ( `adpresso-select-option ${active ? 'is-active' : ''} ${variantClass}`} value={option} > {({ selected: isSelected }) => ( <> {option.label} {isSelected ? ( {/**/} ) : null} > )} ); } return ( {selected ? selected.label : placeholder} {/**/} {options.map((item, index) => { if (item.options && Array.isArray(item.options)) { return ( {item.label === 'Pro' ? : item.label} {item.options.map(renderOption)} ); } return renderOption(item); })} ); }; export default Select;