| 1 |
import { InspectorControls } from "@wordpress/block-editor"; |
| 2 |
import { TextControl } from "@wordpress/components"; |
| 3 |
import { __ } from "@wordpress/i18n"; |
| 4 |
|
| 5 |
export function AdvancedCustomClassControl({ |
| 6 |
label, |
| 7 |
value, |
| 8 |
onChange, |
| 9 |
}: { |
| 10 |
label?: string; |
| 11 |
value?: string; |
| 12 |
onChange: (value: string | undefined) => void; |
| 13 |
}) { |
| 14 |
return ( |
| 15 |
<InspectorControls group="advanced"> |
| 16 |
<TextControl |
| 17 |
__next40pxDefaultSize |
| 18 |
autoComplete="off" |
| 19 |
label={label || __("Additional CSS class(es)", "tableberg")} |
| 20 |
value={value || ""} |
| 21 |
onChange={nextValue => { |
| 22 |
const trimmedValue = nextValue.trim(); |
| 23 |
|
| 24 |
onChange(trimmedValue !== "" ? trimmedValue : undefined); |
| 25 |
}} |
| 26 |
help={__("Separate multiple classes with spaces.", "tableberg")} |
| 27 |
/> |
| 28 |
</InspectorControls> |
| 29 |
); |
| 30 |
} |
| 31 |
|