| 1 |
/** |
| 2 |
* Reusable ToolsPanelItem Wrapper Component |
| 3 |
* Can be used for any control that needs a ToolsPanelItem |
| 4 |
*/ |
| 5 |
|
| 6 |
import React from "react"; |
| 7 |
import { __experimentalToolsPanelItem as ToolsPanelItem } from "@wordpress/components"; |
| 8 |
|
| 9 |
interface ToolsPanelItemWrapperProps { |
| 10 |
label: string; |
| 11 |
hasValue: () => boolean; |
| 12 |
onDeselect?: () => void; |
| 13 |
isShownByDefault?: boolean; |
| 14 |
children: React.ReactNode; |
| 15 |
className?: string; |
| 16 |
panelId?: string; |
| 17 |
style?: React.CSSProperties; |
| 18 |
} |
| 19 |
|
| 20 |
export const ToolsPanelItemWrapper: React.FC<ToolsPanelItemWrapperProps> = ({ |
| 21 |
label, |
| 22 |
hasValue, |
| 23 |
onDeselect, |
| 24 |
isShownByDefault = false, |
| 25 |
children, |
| 26 |
className, |
| 27 |
panelId, |
| 28 |
style, |
| 29 |
}) => { |
| 30 |
return ( |
| 31 |
<ToolsPanelItem |
| 32 |
style={style} |
| 33 |
hasValue={hasValue} |
| 34 |
label={label} |
| 35 |
onDeselect={onDeselect} |
| 36 |
isShownByDefault={isShownByDefault} |
| 37 |
className={className} |
| 38 |
panelId={panelId} |
| 39 |
> |
| 40 |
{children} |
| 41 |
</ToolsPanelItem> |
| 42 |
); |
| 43 |
}; |
| 44 |
|
| 45 |
export default ToolsPanelItemWrapper; |
| 46 |
|