2023-03-17 12:26:34 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
import Button, { ButtonProps } from '@woocommerce/base-components/button';
|
|
|
|
import { RichText } from '@wordpress/block-editor';
|
|
|
|
|
|
|
|
export interface EditableButtonProps
|
|
|
|
extends Omit< ButtonProps, 'onChange' | 'placeholder' | 'value' > {
|
|
|
|
/**
|
|
|
|
* On change callback.
|
|
|
|
*/
|
|
|
|
onChange: ( value: string ) => void;
|
|
|
|
/**
|
|
|
|
* The placeholder of the editable button.
|
|
|
|
*/
|
|
|
|
placeholder?: string;
|
|
|
|
/**
|
|
|
|
* The current value of the editable button.
|
|
|
|
*/
|
|
|
|
value: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
const EditableButton = ( {
|
|
|
|
onChange,
|
|
|
|
placeholder,
|
|
|
|
value,
|
|
|
|
...props
|
|
|
|
}: EditableButtonProps ) => {
|
|
|
|
return (
|
|
|
|
<Button { ...props }>
|
2023-07-18 16:04:50 +00:00
|
|
|
<RichText
|
|
|
|
multiline={ false }
|
|
|
|
allowedFormats={ [] }
|
|
|
|
value={ value }
|
|
|
|
placeholder={ placeholder }
|
|
|
|
onChange={ onChange }
|
|
|
|
/>
|
2023-03-17 12:26:34 +00:00
|
|
|
</Button>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default EditableButton;
|