@wordpress/block-library
Version:
Block library for the WordPress editor.
38 lines (37 loc) • 1.76 kB
JavaScript
;
Object.defineProperties(exports, {
__esModule: { value: true },
[Symbol.toStringTag]: { value: "Module" }
});
let _wordpress_data = require("@wordpress/data");
let _wordpress_blocks = require("@wordpress/blocks");
let _wordpress_block_editor = require("@wordpress/block-editor");
let react_jsx_runtime = require("react/jsx-runtime");
// packages/block-library/src/terms-query/edit/terms-query-placeholder.jsx
function TermsQueryPlaceholder({ attributes, clientId, name }) {
const { blockType, activeBlockVariation, scopeVariations } = (0, _wordpress_data.useSelect)((select) => {
const { getActiveBlockVariation, getBlockType, getBlockVariations } = select(_wordpress_blocks.store);
return {
blockType: getBlockType(name),
activeBlockVariation: getActiveBlockVariation(name, attributes),
scopeVariations: getBlockVariations(name, "block")
};
}, [name, attributes]);
const icon = activeBlockVariation?.icon?.src || activeBlockVariation?.icon || blockType?.icon?.src;
const label = activeBlockVariation?.title || blockType?.title;
const { replaceInnerBlocks } = (0, _wordpress_data.useDispatch)(_wordpress_block_editor.store);
const blockProps = (0, _wordpress_block_editor.useBlockProps)();
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
...blockProps,
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_block_editor.__experimentalBlockVariationPicker, {
icon,
label,
variations: scopeVariations,
onSelect: (variation) => {
if (variation.innerBlocks) replaceInnerBlocks(clientId, (0, _wordpress_blocks.createBlocksFromInnerBlocksTemplate)(variation.innerBlocks), false);
}
})
});
}
exports.default = TermsQueryPlaceholder;
//# sourceMappingURL=terms-query-placeholder.cjs.map