import './style.scss'; import { __experimentalToggleGroupControl, __experimentalToggleGroupControlOption, ToggleGroupControl as __stableToggleGroupControl, ToggleGroupControlOption as __stableToggleGroupControlOption, } from '@wordpress/components'; import { Fragment, useState } from '@wordpress/element'; const ToggleGroupControl = __stableToggleGroupControl || __experimentalToggleGroupControl; const ToggleGroupControlOption = __stableToggleGroupControlOption || __experimentalToggleGroupControlOption; /** * Component Class * * @param props */ export default function ToggleGroupCustomControl(props) { const { children, options } = props; const [collapsed, setCollapsed] = useState(options[0].category); return (
{ setCollapsed(val); }} isBlock > {options.map((option) => { return ( ); })} {options.map((option) => { if (collapsed === option.category) { return ( {children(option)} ); } return null; })}
); }