UNPKG

@gechiui/components

Version:
39 lines (33 loc) 1.11 kB
import _extends from "@babel/runtime/helpers/esm/extends"; import { createElement } from "@gechiui/element"; /** * External dependencies */ // eslint-disable-next-line no-restricted-imports /** * Internal dependencies */ import { useToolsPanelItem } from './hook'; import { View } from '../../view'; import { contextConnect } from '../../ui/context'; // This wraps controls to be conditionally displayed within a tools panel. It // prevents props being applied to HTML elements that would make them invalid. const ToolsPanelItem = (props, forwardedRef) => { const { children, isShown, shouldRenderPlaceholder, ...toolsPanelItemProps } = useToolsPanelItem(props); if (!isShown) { return shouldRenderPlaceholder ? createElement(View, _extends({}, toolsPanelItemProps, { ref: forwardedRef })) : null; } return createElement(View, _extends({}, toolsPanelItemProps, { ref: forwardedRef }), children); }; const ConnectedToolsPanelItem = contextConnect(ToolsPanelItem, 'ToolsPanelItem'); export default ConnectedToolsPanelItem; //# sourceMappingURL=component.js.map