@wordpress/components
Version:
UI components for WordPress.
38 lines (32 loc) • 1.08 kB
JavaScript
import _extends from "@babel/runtime/helpers/esm/extends";
import { createElement } from "@wordpress/element";
/**
* External dependencies
*/
/**
* 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 UnconnectedToolsPanelItem = (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);
};
export const ToolsPanelItem = contextConnect(UnconnectedToolsPanelItem, 'ToolsPanelItem');
export default ToolsPanelItem;
//# sourceMappingURL=component.js.map