UNPKG

@wordpress/edit-post

Version:
83 lines (76 loc) 2.43 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _element = require("@wordpress/element"); var _components = require("@wordpress/components"); /** * WordPress dependencies */ var _createSlotFill = (0, _components.createSlotFill)('PluginPostPublishPanel'), Fill = _createSlotFill.Fill, Slot = _createSlotFill.Slot; /** * Renders provided content to the post-publish panel in the publish flow * (side panel that opens after a user publishes the post). * * @param {Object} props Component properties. * @param {string} [props.className] An optional class name added to the panel. * @param {string} [props.title] Title displayed at the top of the panel. * @param {boolean} [props.initialOpen=false] Whether to have the panel initially opened. When no title is provided it is always opened. * * @example <caption>ES5</caption> * ```js * // Using ES5 syntax * var __ = wp.i18n.__; * var PluginPostPublishPanel = wp.editPost.PluginPostPublishPanel; * * function MyPluginPostPublishPanel() { * return wp.element.createElement( * PluginPostPublishPanel, * { * className: 'my-plugin-post-publish-panel', * title: __( 'My panel title' ), * initialOpen: true, * }, * __( 'My panel content' ) * ); * } * ``` * * @example <caption>ESNext</caption> * ```jsx * // Using ESNext syntax * const { __ } = wp.i18n; * const { PluginPostPublishPanel } = wp.editPost; * * const MyPluginPostPublishPanel = () => ( * <PluginPostPublishPanel * className="my-plugin-post-publish-panel" * title={ __( 'My panel title' ) } * initialOpen={ true } * > * { __( 'My panel content' ) } * </PluginPostPublishPanel> * ); * ``` * * @return {WPElement} The WPElement to be rendered. */ var PluginPostPublishPanel = function PluginPostPublishPanel(_ref) { var children = _ref.children, className = _ref.className, title = _ref.title, _ref$initialOpen = _ref.initialOpen, initialOpen = _ref$initialOpen === void 0 ? false : _ref$initialOpen; return (0, _element.createElement)(Fill, null, (0, _element.createElement)(_components.PanelBody, { className: className, initialOpen: initialOpen || !title, title: title }, children)); }; PluginPostPublishPanel.Slot = Slot; var _default = PluginPostPublishPanel; exports.default = _default; //# sourceMappingURL=index.js.map