UNPKG

@wordpress/block-library

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