UNPKG

@wordpress/block-library

Version:
51 lines (50 loc) 1.47 kB
import { jsx } from "react/jsx-runtime"; import { ToolbarGroup, ToolbarButton, Dropdown, __experimentalDropdownContentWrapper as DropdownContentWrapper } from "@wordpress/components"; import { __ } from "@wordpress/i18n"; import PatternSelection, { useBlockPatterns } from "./pattern-selection"; function QueryToolbar({ clientId, attributes, hasInnerBlocks }) { const hasPatterns = useBlockPatterns(clientId, attributes).length; if (!hasPatterns) { return null; } const buttonLabel = hasInnerBlocks ? __("Change design") : __("Choose pattern"); return /* @__PURE__ */ jsx(ToolbarGroup, { className: "wp-block-template-part__block-control-group", children: /* @__PURE__ */ jsx(DropdownContentWrapper, { children: /* @__PURE__ */ jsx( Dropdown, { contentClassName: "block-editor-block-settings-menu__popover", focusOnMount: "firstElement", expandOnMobile: true, renderToggle: ({ isOpen, onToggle }) => /* @__PURE__ */ jsx( ToolbarButton, { "aria-haspopup": "true", "aria-expanded": isOpen, onClick: onToggle, children: buttonLabel } ), renderContent: () => /* @__PURE__ */ jsx( PatternSelection, { clientId, attributes, showSearch: false, showTitlesAsTooltip: true } ) } ) }) }); } export { QueryToolbar as default }; //# sourceMappingURL=query-toolbar.js.map