/** * WordPress dependencies */ import { Button, CheckboxControl } from '@safe-wordpress/components'; import { _x } from '@safe-wordpress/i18n'; /** * External dependencies */ import clsx from 'clsx'; import { OptionLabel } from '@nelio/forms/components'; import type { KeyboardEventHandler } from 'react'; /** * Internal dependencies */ import type { OptionItem } from '../types'; type EditableOptionItemProps = { readonly option: OptionItem; readonly isLabelOnFocus: boolean; readonly isValueOnFocus: boolean; readonly isDisabled?: boolean; readonly isRemoveDisabled: boolean; readonly onFocusLabel: () => void; readonly onFocusValue: () => void; readonly onSelectedChange: ( selected: boolean ) => void; readonly onChange: ( o: OptionItem ) => void; readonly onRemove: () => void; readonly onKeyDown?: KeyboardEventHandler< HTMLInputElement >; }; export const EditableOptionItem = ( props: EditableOptionItemProps ): JSX.Element => { const { option, isLabelOnFocus, isValueOnFocus, isDisabled, isRemoveDisabled, onFocusLabel, onFocusValue, onSelectedChange, onChange, onRemove, onKeyDown, } = props; const { label, selected, disabled, value } = option; return (
onChange( { ...option, label: newValue } ) } onKeyDown={ onKeyDown } /> onChange( { ...option, value: newValue } ) } onKeyDown={ onKeyDown } />
); };