UNPKG

@wordpress/edit-post

Version:
94 lines (85 loc) 2.7 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _element = require("@wordpress/element"); var _compose = require("@wordpress/compose"); var _plugins = require("@wordpress/plugins"); var _components = require("@wordpress/components"); /** * WordPress dependencies */ const { Fill, Slot } = (0, _components.createSlotFill)('PluginPostPublishPanel'); const PluginPostPublishPanelFill = ({ children, className, title, initialOpen = false, icon }) => (0, _element.createElement)(Fill, null, (0, _element.createElement)(_components.PanelBody, { className: className, initialOpen: initialOpen || !title, title: title, icon: icon }, children)); /** * 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. * @param {WPBlockTypeIconRender} [props.icon=inherits from the plugin] The [Dashicon](https://developer.wordpress.org/resource/dashicons/) icon slug string, or an SVG WP element, to be rendered when the sidebar is pinned to toolbar. * * @example * ```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 * ```jsx * // Using ESNext syntax * import { __ } from '@wordpress/i18n'; * import { PluginPostPublishPanel } from '@wordpress/edit-post'; * * const MyPluginPostPublishPanel = () => ( * <PluginPostPublishPanel * className="my-plugin-post-publish-panel" * title={ __( 'My panel title' ) } * initialOpen={ true } * > * { __( 'My panel content' ) } * </PluginPostPublishPanel> * ); * ``` * * @return {WPComponent} The component to be rendered. */ const PluginPostPublishPanel = (0, _compose.compose)((0, _plugins.withPluginContext)((context, ownProps) => { return { icon: ownProps.icon || context.icon }; }))(PluginPostPublishPanelFill); PluginPostPublishPanel.Slot = Slot; var _default = PluginPostPublishPanel; exports.default = _default; //# sourceMappingURL=index.js.map