import { useState } from '@wordpress/element'; import { Button, } from '@wordpress/components'; import { useControlSettingSet } from '../_hooks'; type Props = { controlSetting: any, // wp.customize.setting or wp.customize.settings[key] choices: { [key: string]: string }, value: string, title: string, description?: string, } export default function ApuraButtonGroup({ controlSetting, choices, value, title, description }: Props) { const buttons = Object.entries(choices).map(([key, label]) => ({ label, value: key })); const [selected, setSelected] = useState(value); useControlSettingSet({ controlSetting, value: selected }); const handleOnClick = (value: string) => { setSelected(value); } return (
{title && {title}} {description &&

{description}

}
{buttons.length > 0 && buttons.map(item => { return ( ) })}
) }