UNPKG

@wordpress/block-library

Version:
1 lines • 1.72 kB
{"version":3,"file":"index.mjs","names":["blockEditorStore"],"sources":["../../../src/query/edit/index.jsx"],"sourcesContent":["import { useSelect } from '@wordpress/data';\nimport { useState } from '@wordpress/element';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport QueryContent from './query-content';\nimport QueryPlaceholder from './query-placeholder';\nimport { PatternSelectionModal } from './pattern-selection';\n\nconst QueryEdit = ( props ) => {\n\tconst { clientId, attributes } = props;\n\tconst [ isPatternSelectionModalOpen, setIsPatternSelectionModalOpen ] =\n\t\tuseState( false );\n\tconst hasInnerBlocks = useSelect(\n\t\t( select ) =>\n\t\t\t!! select( blockEditorStore ).getBlocks( clientId ).length,\n\t\t[ clientId ]\n\t);\n\tconst Component = hasInnerBlocks ? QueryContent : QueryPlaceholder;\n\n\treturn (\n\t\t<>\n\t\t\t<Component\n\t\t\t\t{ ...props }\n\t\t\t\topenPatternSelectionModal={ () =>\n\t\t\t\t\tsetIsPatternSelectionModalOpen( true )\n\t\t\t\t}\n\t\t\t/>\n\t\t\t{ isPatternSelectionModalOpen && (\n\t\t\t\t<PatternSelectionModal\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\tsetIsPatternSelectionModalOpen={\n\t\t\t\t\t\tsetIsPatternSelectionModalOpen\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n};\n\nexport default QueryEdit;\n"],"mappings":";;;;;;;;AAOA,MAAM,aAAc,UAAW;CAC9B,MAAM,EAAE,UAAU,eAAe;CACjC,MAAM,CAAE,6BAA6B,kCACpC,SAAU,KAAM;CAMjB,MAAM,YALiB,WACpB,WACD,CAAC,CAAE,OAAQA,KAAiB,CAAC,CAAC,UAAW,QAAS,CAAC,CAAC,QACrD,CAAE,QAAS,CAEmB,IAAI,eAAe;CAElD,OACC,qBAAA,UAAA,EAAA,UAAA,CACC,oBAAC,WAAD;EACC,GAAK;EACL,iCACC,+BAAgC,IAAK;CAEtC,CAAA,GACC,+BACD,oBAAC,uBAAD;EACY;EACE;EAEZ;CAED,CAAA,CAED,EAAA,CAAA;AAEJ"}