UNPKG

@wordpress/block-library

Version:
35 lines (34 loc) • 1.38 kB
"use strict"; Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } }); let _wordpress_block_editor = require("@wordpress/block-editor"); let _wordpress_data = require("@wordpress/data"); let react_jsx_runtime = require("react/jsx-runtime"); // packages/block-library/src/accordion-panel/edit.jsx function Edit({ attributes, context, clientId, isSelected }) { const { allowedBlocks, templateLock } = attributes; const openByDefault = context["core/accordion-open-by-default"]; const { hasSelection } = (0, _wordpress_data.useSelect)((select) => { if (isSelected || openByDefault) return { hasSelection: true }; const { getBlockRootClientId, isBlockSelected, hasSelectedInnerBlock } = select(_wordpress_block_editor.store); const rootClientId = getBlockRootClientId(clientId); return { hasSelection: isBlockSelected(rootClientId) || hasSelectedInnerBlock(rootClientId, true) }; }, [ clientId, isSelected, openByDefault ]); const blockProps = (0, _wordpress_block_editor.useBlockProps)({ hidden: !hasSelection, role: "region" }); const innerBlocksProps = (0, _wordpress_block_editor.useInnerBlocksProps)(blockProps, { allowedBlocks, templateLock }); return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { ...innerBlocksProps }); } exports.default = Edit; //# sourceMappingURL=edit.cjs.map