{"version":3,"file":"edit.cjs","names":["useSelect","blockEditorStore","useDispatch","useToolsPanelDropdownMenuProps","useBlockProps","useInnerBlocksProps","InspectorControls","ToolsPanel","__","ToolsPanelItem","QueryPaginationArrowControls","QueryPaginationLabelControl"],"sources":["../../src/query-pagination/edit.jsx"],"sourcesContent":["import { __ } from '@wordpress/i18n';\nimport {\n\tInspectorControls,\n\tuseBlockProps,\n\tuseInnerBlocksProps,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport {\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\nimport { useEffect } from '@wordpress/element';\nimport { QueryPaginationArrowControls } from './query-pagination-arrow-controls';\nimport { QueryPaginationLabelControl } from './query-pagination-label-control';\nimport { useToolsPanelDropdownMenuProps } from '../utils/hooks';\n\nexport default function QueryPaginationEdit( {\n\tattributes: { paginationArrow, showLabel },\n\tsetAttributes,\n\tclientId,\n} ) {\n\tconst hasNextPreviousBlocks = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlocks } = select( blockEditorStore );\n\t\t\tconst innerBlocks = getBlocks( clientId );\n\t\t\t/**\n\t\t\t * Show the `paginationArrow` and `showLabel` controls only if a\n\t\t\t * `QueryPaginationNext/Previous` block exists.\n\t\t\t */\n\t\t\treturn innerBlocks?.find( ( innerBlock ) => {\n\t\t\t\treturn [\n\t\t\t\t\t'core/query-pagination-next',\n\t\t\t\t\t'core/query-pagination-previous',\n\t\t\t\t].includes( innerBlock.name );\n\t\t\t} );\n\t\t},\n\t\t[ clientId ]\n\t);\n\tconst { __unstableMarkNextChangeAsNotPersistent } =\n\t\tuseDispatch( blockEditorStore );\n\tconst dropdownMenuProps = useToolsPanelDropdownMenuProps();\n\tconst blockProps = useBlockProps();\n\tconst innerBlocksProps = useInnerBlocksProps( blockProps );\n\n\t// Always show label text if paginationArrow is set to 'none'.\n\tuseEffect( () => {\n\t\tif ( paginationArrow === 'none' && ! showLabel ) {\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\tsetAttributes( { showLabel: true } );\n\t\t}\n\t}, [\n\t\tpaginationArrow,\n\t\tsetAttributes,\n\t\tshowLabel,\n\t\t__unstableMarkNextChangeAsNotPersistent,\n\t] );\n\n\treturn (\n\t\t<>\n\t\t\t{ hasNextPreviousBlocks && (\n\t\t\t\t<InspectorControls>\n\t\t\t\t\t<ToolsPanel\n\t\t\t\t\t\tlabel={ __( 'Settings' ) }\n\t\t\t\t\t\tresetAll={ () => {\n\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\tpaginationArrow: 'none',\n\t\t\t\t\t\t\t\tshowLabel: true,\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tdropdownMenuProps={ dropdownMenuProps }\n\t\t\t\t\t>\n\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\thasValue={ () => paginationArrow !== 'none' }\n\t\t\t\t\t\t\tlabel={ __( 'Pagination arrow' ) }\n\t\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\t\tsetAttributes( { paginationArrow: 'none' } )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<QueryPaginationArrowControls\n\t\t\t\t\t\t\t\tvalue={ paginationArrow }\n\t\t\t\t\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\t\t\t\t\tsetAttributes( { paginationArrow: value } );\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t\t{ paginationArrow !== 'none' && (\n\t\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\t\thasValue={ () => ! showLabel }\n\t\t\t\t\t\t\t\tlabel={ __( 'Show text' ) }\n\t\t\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\t\t\tsetAttributes( { showLabel: true } )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<QueryPaginationLabelControl\n\t\t\t\t\t\t\t\t\tvalue={ showLabel }\n\t\t\t\t\t\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\t\t\t\t\t\tsetAttributes( { showLabel: value } );\n\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</ToolsPanel>\n\t\t\t\t</InspectorControls>\n\t\t\t) }\n\t\t\t<nav { ...innerBlocksProps } />\n\t\t</>\n\t);\n}\n"],"mappings":";;;;;;;;;;;;;;;AAiBA,SAAwB,oBAAqB,EAC5C,YAAY,EAAE,iBAAiB,aAC/B,eACA,YACG;CACH,MAAM,yBAAA,GAAwBA,gBAAAA,UAAAA,EAC3B,WAAY;EACb,MAAM,EAAE,cAAc,OAAQC,wBAAAA,KAAiB;;;;;EAM/C,OALoB,UAAW,QAKd,CAAC,EAAE,MAAQ,eAAgB;GAC3C,OAAO,CACN,8BACA,gCACD,CAAC,CAAC,SAAU,WAAW,IAAK;EAC7B,CAAE;CACH,GACA,CAAE,QAAS,CACZ;CACA,MAAM,EAAE,6CAAA,GACPC,gBAAAA,YAAAA,CAAaD,wBAAAA,KAAiB;CAC/B,MAAM,qBAAA,GAAoBE,kBAAAA,+BAAAA,CAA+B;CACzD,MAAM,cAAA,GAAaC,wBAAAA,cAAAA,CAAc;CACjC,MAAM,oBAAA,GAAmBC,wBAAAA,oBAAAA,CAAqB,UAAW;CAGzD,CAAA,GAAA,mBAAA,UAAA,OAAiB;EAChB,IAAK,oBAAoB,UAAU,CAAE,WAAY;GAChD,wCAAwC;GACxC,cAAe,EAAE,WAAW,KAAK,CAAE;EACpC;CACD,GAAG;EACF;EACA;EACA;EACA;CACD,CAAE;CAE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