import { TextControl } from '@wordpress/components'; import SettingsBlock from './SettingsBlock'; import { Title, Action, Description, SupplementaryLabel, } from './SettingsBlockElements'; const DEFAULT_ELEMENT_ORDER = [ 'title', 'action', 'description' ]; const ELEMENT_RENDERERS = { title: ( { title, supplementaryLabel } ) => ( { title } { supplementaryLabel && ( <SupplementaryLabel>{ supplementaryLabel }</SupplementaryLabel> ) } ), action: ( { actionProps } ) => ( actionProps?.callback( actionProps?.key, newValue ) } /> ), description: ( { description } ) => ( { description } ), }; const InputSettingsBlock = ( { title, description, supplementaryLabel, order = DEFAULT_ELEMENT_ORDER, ...props } ) => ( { order.map( ( elementKey ) => { const RenderElement = ELEMENT_RENDERERS[ elementKey ]; return RenderElement ? ( ) : null; } ) } ); export default InputSettingsBlock;