@wordpress/block-library
Version:
Block library for the WordPress editor.
46 lines (45 loc) • 1.44 kB
JavaScript
/**
* WordPress dependencies
*/
import { ToolbarGroup, ToolbarButton, Dropdown, __experimentalDropdownContentWrapper as DropdownContentWrapper } from '@wordpress/components';
import { __ } from '@wordpress/i18n';
/**
* Internal dependencies
*/
import PatternSelection, { useBlockPatterns } from './pattern-selection';
import { jsx as _jsx } from "react/jsx-runtime";
export default function QueryToolbar({
clientId,
attributes
}) {
const hasPatterns = useBlockPatterns(clientId, attributes).length;
if (!hasPatterns) {
return null;
}
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: __('Change design')
}),
renderContent: () => /*#__PURE__*/_jsx(PatternSelection, {
clientId: clientId,
attributes: attributes,
showSearch: false,
showTitlesAsTooltip: true
})
})
})
});
}
//# sourceMappingURL=query-toolbar.js.map