UNPKG

@wordpress/block-library

Version:
39 lines (38 loc) 1.25 kB
import { Fragment, jsx, jsxs } from "react/jsx-runtime"; import { useSelect } from "@wordpress/data"; import { useState } from "@wordpress/element"; import { store as blockEditorStore } from "@wordpress/block-editor"; import QueryContent from "./query-content"; import QueryPlaceholder from "./query-placeholder"; import { PatternSelectionModal } from "./pattern-selection"; const QueryEdit = (props) => { const { clientId, attributes } = props; const [isPatternSelectionModalOpen, setIsPatternSelectionModalOpen] = useState(false); const hasInnerBlocks = useSelect( (select) => !!select(blockEditorStore).getBlocks(clientId).length, [clientId] ); const Component = hasInnerBlocks ? QueryContent : QueryPlaceholder; return /* @__PURE__ */ jsxs(Fragment, { children: [ /* @__PURE__ */ jsx( Component, { ...props, openPatternSelectionModal: () => setIsPatternSelectionModalOpen(true) } ), isPatternSelectionModalOpen && /* @__PURE__ */ jsx( PatternSelectionModal, { clientId, attributes, setIsPatternSelectionModalOpen } ) ] }); }; var edit_default = QueryEdit; export { edit_default as default }; //# sourceMappingURL=index.js.map