@wordpress/block-library 9.12.1-next.082ed6819.0 → 9.13.1-next.a9f418477.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/build/block/edit.js +2 -29
- package/build/block/edit.js.map +1 -1
- package/build/cover/edit/index.js +4 -2
- package/build/cover/edit/index.js.map +1 -1
- package/build/cover/edit/inspector-controls.js +6 -4
- package/build/cover/edit/inspector-controls.js.map +1 -1
- package/build/form/index.js +1 -2
- package/build/form/index.js.map +1 -1
- package/build/form/view.js +10 -5
- package/build/form/view.js.map +1 -1
- package/build/list-item/hooks/use-merge.js +2 -2
- package/build/list-item/hooks/use-merge.js.map +1 -1
- package/build/navigation/edit/deleted-navigation-warning.js +9 -2
- package/build/navigation/edit/deleted-navigation-warning.js.map +1 -1
- package/build/navigation-link/edit.js +1 -2
- package/build/navigation-link/edit.js.map +1 -1
- package/build/navigation-submenu/edit.js +3 -1
- package/build/navigation-submenu/edit.js.map +1 -1
- package/build/pattern/recursion-detector.js +0 -1
- package/build/pattern/recursion-detector.js.map +1 -1
- package/build/query/edit/index.js +2 -2
- package/build/query/edit/index.js.map +1 -1
- package/build/query/edit/inspector-controls/author-control.js +0 -1
- package/build/query/edit/inspector-controls/author-control.js.map +1 -1
- package/build/query/edit/inspector-controls/parent-control.js +0 -1
- package/build/query/edit/inspector-controls/parent-control.js.map +1 -1
- package/build/query/edit/inspector-controls/taxonomy-controls.js +0 -1
- package/build/query/edit/inspector-controls/taxonomy-controls.js.map +1 -1
- package/build/query/edit/{pattern-selection-modal.js → pattern-selection.js} +55 -36
- package/build/query/edit/pattern-selection.js.map +1 -0
- package/build/query/edit/query-content.js +5 -8
- package/build/query/edit/query-content.js.map +1 -1
- package/build/query/edit/query-placeholder.js +5 -11
- package/build/query/edit/query-placeholder.js.map +1 -1
- package/build/query/edit/query-toolbar.js +31 -11
- package/build/query/edit/query-toolbar.js.map +1 -1
- package/build/separator/deprecated.js +2 -1
- package/build/separator/deprecated.js.map +1 -1
- package/build/separator/edit.js +29 -4
- package/build/separator/edit.js.map +1 -1
- package/build/separator/index.js +5 -0
- package/build/separator/index.js.map +1 -1
- package/build/separator/save.js +3 -2
- package/build/separator/save.js.map +1 -1
- package/build/social-link/edit.js +35 -1
- package/build/social-link/edit.js.map +1 -1
- package/build/social-link/index.js +4 -2
- package/build/social-link/index.js.map +1 -1
- package/build/template-part/edit/import-controls.js +0 -1
- package/build/template-part/edit/import-controls.js.map +1 -1
- package/build-module/block/edit.js +3 -30
- package/build-module/block/edit.js.map +1 -1
- package/build-module/cover/edit/index.js +4 -2
- package/build-module/cover/edit/index.js.map +1 -1
- package/build-module/cover/edit/inspector-controls.js +6 -4
- package/build-module/cover/edit/inspector-controls.js.map +1 -1
- package/build-module/form/index.js +1 -2
- package/build-module/form/index.js.map +1 -1
- package/build-module/form/view.js +10 -5
- package/build-module/form/view.js.map +1 -1
- package/build-module/list-item/hooks/use-merge.js +2 -2
- package/build-module/list-item/hooks/use-merge.js.map +1 -1
- package/build-module/navigation/edit/deleted-navigation-warning.js +10 -3
- package/build-module/navigation/edit/deleted-navigation-warning.js.map +1 -1
- package/build-module/navigation-link/edit.js +1 -2
- package/build-module/navigation-link/edit.js.map +1 -1
- package/build-module/navigation-submenu/edit.js +3 -1
- package/build-module/navigation-submenu/edit.js.map +1 -1
- package/build-module/pattern/recursion-detector.js +0 -1
- package/build-module/pattern/recursion-detector.js.map +1 -1
- package/build-module/query/edit/index.js +1 -1
- package/build-module/query/edit/index.js.map +1 -1
- package/build-module/query/edit/inspector-controls/author-control.js +0 -1
- package/build-module/query/edit/inspector-controls/author-control.js.map +1 -1
- package/build-module/query/edit/inspector-controls/parent-control.js +0 -1
- package/build-module/query/edit/inspector-controls/parent-control.js.map +1 -1
- package/build-module/query/edit/inspector-controls/taxonomy-controls.js +0 -1
- package/build-module/query/edit/inspector-controls/taxonomy-controls.js.map +1 -1
- package/build-module/query/edit/{pattern-selection-modal.js → pattern-selection.js} +53 -36
- package/build-module/query/edit/pattern-selection.js.map +1 -0
- package/build-module/query/edit/query-content.js +5 -8
- package/build-module/query/edit/query-content.js.map +1 -1
- package/build-module/query/edit/query-placeholder.js +6 -12
- package/build-module/query/edit/query-placeholder.js.map +1 -1
- package/build-module/query/edit/query-toolbar.js +31 -13
- package/build-module/query/edit/query-toolbar.js.map +1 -1
- package/build-module/separator/deprecated.js +2 -1
- package/build-module/separator/deprecated.js.map +1 -1
- package/build-module/separator/edit.js +32 -7
- package/build-module/separator/edit.js.map +1 -1
- package/build-module/separator/index.js +5 -0
- package/build-module/separator/index.js.map +1 -1
- package/build-module/separator/save.js +3 -2
- package/build-module/separator/save.js.map +1 -1
- package/build-module/social-link/edit.js +37 -3
- package/build-module/social-link/edit.js.map +1 -1
- package/build-module/social-link/index.js +4 -2
- package/build-module/social-link/index.js.map +1 -1
- package/build-module/template-part/edit/import-controls.js +0 -1
- package/build-module/template-part/edit/import-controls.js.map +1 -1
- package/build-style/button/style-rtl.css +3 -3
- package/build-style/button/style.css +3 -3
- package/build-style/comments/editor-rtl.css +1 -1
- package/build-style/comments/editor.css +1 -1
- package/build-style/comments/style-rtl.css +1 -1
- package/build-style/comments/style.css +1 -1
- package/build-style/comments-pagination/editor-rtl.css +1 -0
- package/build-style/comments-pagination/editor.css +1 -0
- package/build-style/comments-pagination/style-rtl.css +1 -0
- package/build-style/comments-pagination/style.css +1 -0
- package/build-style/common-rtl.css +17 -17
- package/build-style/common.css +17 -17
- package/build-style/editor-rtl.css +76 -41
- package/build-style/editor.css +76 -41
- package/build-style/gallery/style-rtl.css +2 -2
- package/build-style/gallery/style.css +2 -2
- package/build-style/heading/style-rtl.css +11 -11
- package/build-style/heading/style.css +11 -11
- package/build-style/image/style-rtl.css +4 -3
- package/build-style/image/style.css +4 -3
- package/build-style/latest-comments/style-rtl.css +4 -4
- package/build-style/latest-comments/style.css +4 -4
- package/build-style/latest-posts/style-rtl.css +2 -1
- package/build-style/latest-posts/style.css +2 -1
- package/build-style/more/editor-rtl.css +1 -1
- package/build-style/more/editor.css +1 -1
- package/build-style/nextpage/editor-rtl.css +1 -1
- package/build-style/nextpage/editor.css +1 -1
- package/build-style/post-comments-form/style-rtl.css +2 -2
- package/build-style/post-comments-form/style.css +2 -2
- package/build-style/post-featured-image/editor-rtl.css +27 -27
- package/build-style/post-featured-image/editor.css +27 -27
- package/build-style/pullquote/style-rtl.css +1 -0
- package/build-style/pullquote/style.css +1 -0
- package/build-style/query/editor-rtl.css +30 -0
- package/build-style/query/editor.css +30 -0
- package/build-style/read-more/style-rtl.css +2 -2
- package/build-style/read-more/style.css +2 -2
- package/build-style/social-link/editor-rtl.css +6 -2
- package/build-style/social-link/editor.css +6 -2
- package/build-style/social-links/editor-rtl.css +2 -2
- package/build-style/social-links/editor.css +2 -2
- package/build-style/social-links/style-rtl.css +2 -2
- package/build-style/social-links/style.css +2 -2
- package/build-style/style-rtl.css +55 -51
- package/build-style/style.css +55 -51
- package/build-style/text-columns/style-rtl.css +3 -3
- package/build-style/text-columns/style.css +3 -3
- package/build-types/lock-unlock.d.ts +1 -1
- package/build-types/lock-unlock.d.ts.map +1 -1
- package/package.json +35 -34
- package/src/block/edit.js +6 -51
- package/src/comments-pagination/editor.scss +1 -0
- package/src/comments-pagination/style.scss +1 -0
- package/src/cover/edit/index.js +4 -1
- package/src/cover/edit/inspector-controls.js +10 -3
- package/src/cover/index.php +2 -2
- package/src/form/block.json +1 -2
- package/src/form/index.php +1 -20
- package/src/form/view.js +18 -5
- package/src/image/style.scss +4 -3
- package/src/latest-posts/style.scss +2 -1
- package/src/list-item/hooks/use-merge.js +2 -2
- package/src/missing/test/edit.native.js +0 -1
- package/src/navigation/README.md +1 -0
- package/src/navigation/edit/deleted-navigation-warning.js +11 -2
- package/src/navigation/index.php +9 -35
- package/src/navigation-link/edit.js +0 -6
- package/src/navigation-submenu/edit.js +5 -6
- package/src/navigation-submenu/index.php +17 -1
- package/src/pullquote/style.scss +1 -0
- package/src/query/edit/index.js +1 -1
- package/src/query/edit/{pattern-selection-modal.js → pattern-selection.js} +53 -33
- package/src/query/edit/query-content.js +4 -10
- package/src/query/edit/query-placeholder.js +5 -14
- package/src/query/edit/query-toolbar.js +38 -17
- package/src/query/editor.scss +30 -0
- package/src/search/index.php +3 -3
- package/src/separator/block.json +5 -0
- package/src/separator/deprecated.js +1 -0
- package/src/separator/edit.js +28 -3
- package/src/separator/save.js +2 -2
- package/src/separator/test/edit.js +1 -0
- package/src/social-link/block.json +4 -2
- package/src/social-link/edit.js +40 -0
- package/src/social-link/editor.scss +5 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/build/query/edit/pattern-selection-modal.js.map +0 -1
- package/build-module/query/edit/pattern-selection-modal.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["FormTokenField","__experimentalVStack","VStack","useSelect","store","coreStore","useState","useEffect","useDebounce","decodeEntities","useTaxonomies","jsx","_jsx","EMPTY_ARRAY","BASE_QUERY","order","_fields","context","getTermIdByTermValue","terms","termValue","termId","id","find","term","name","termValueLower","toLocaleLowerCase","TaxonomyControls","onChange","query","postType","taxQuery","taxonomies","length","spacing","children","map","taxonomy","termIds","slug","handleChange","newTermIds","TaxonomyItem","search","setSearch","value","setValue","suggestions","setSuggestions","debouncedSearch","searchResults","searchHasResolved","select","getEntityRecords","hasFinishedResolution","selectorArgs","orderby","exclude","per_page","existingTerms","include","sanitizedValue","reduce","accumulator","entity","push","result","onTermsChange","newTermValues","Set","add","Array","from","className","label","onInputChange","displayTransform","__experimentalShowHowTo","__nextHasNoMarginBottom","__next40pxDefaultSize"],"sources":["@wordpress/block-library/src/query/edit/inspector-controls/taxonomy-controls.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tFormTokenField,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useState, useEffect } from '@wordpress/element';\nimport { useDebounce } from '@wordpress/compose';\nimport { decodeEntities } from '@wordpress/html-entities';\n\n/**\n * Internal dependencies\n */\nimport { useTaxonomies } from '../../utils';\n\nconst EMPTY_ARRAY = [];\nconst BASE_QUERY = {\n\torder: 'asc',\n\t_fields: 'id,name',\n\tcontext: 'view',\n};\n\n// Helper function to get the term id based on user input in terms `FormTokenField`.\nconst getTermIdByTermValue = ( terms, termValue ) => {\n\t// First we check for exact match by `term.id` or case sensitive `term.name` match.\n\tconst termId =\n\t\ttermValue?.id || terms?.find( ( term ) => term.name === termValue )?.id;\n\tif ( termId ) {\n\t\treturn termId;\n\t}\n\n\t/**\n\t * Here we make an extra check for entered terms in a non case sensitive way,\n\t * to match user expectations, due to `FormTokenField` behaviour that shows\n\t * suggestions which are case insensitive.\n\t *\n\t * Although WP tries to discourage users to add terms with the same name (case insensitive),\n\t * it's still possible if you manually change the name, as long as the terms have different slugs.\n\t * In this edge case we always apply the first match from the terms list.\n\t */\n\tconst termValueLower = termValue.toLocaleLowerCase();\n\treturn terms?.find(\n\t\t( term ) => term.name.toLocaleLowerCase() === termValueLower\n\t)?.id;\n};\n\nexport function TaxonomyControls( { onChange, query } ) {\n\tconst { postType, taxQuery } = query;\n\n\tconst taxonomies = useTaxonomies( postType );\n\tif ( ! taxonomies || taxonomies.length === 0 ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<VStack spacing={ 4 }>\n\t\t\t{ taxonomies.map( ( taxonomy ) => {\n\t\t\t\tconst termIds = taxQuery?.[ taxonomy.slug ] || [];\n\t\t\t\tconst handleChange = ( newTermIds ) =>\n\t\t\t\t\tonChange( {\n\t\t\t\t\t\ttaxQuery: {\n\t\t\t\t\t\t\t...taxQuery,\n\t\t\t\t\t\t\t[ taxonomy.slug ]: newTermIds,\n\t\t\t\t\t\t},\n\t\t\t\t\t} );\n\n\t\t\t\treturn (\n\t\t\t\t\t<TaxonomyItem\n\t\t\t\t\t\tkey={ taxonomy.slug }\n\t\t\t\t\t\ttaxonomy={ taxonomy }\n\t\t\t\t\t\ttermIds={ termIds }\n\t\t\t\t\t\tonChange={ handleChange }\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</VStack>\n\t);\n}\n\n/**\n * Renders a `FormTokenField` for a given taxonomy.\n *\n * @param {Object} props The props for the component.\n * @param {Object} props.taxonomy The taxonomy object.\n * @param {number[]} props.termIds An array with the block's term ids for the given taxonomy.\n * @param {Function} props.onChange Callback `onChange` function.\n * @return {JSX.Element} The rendered component.\n */\nfunction TaxonomyItem( { taxonomy, termIds, onChange } ) {\n\tconst [ search, setSearch ] = useState( '' );\n\tconst [ value, setValue ] = useState( EMPTY_ARRAY );\n\tconst [ suggestions, setSuggestions ] = useState( EMPTY_ARRAY );\n\tconst debouncedSearch = useDebounce( setSearch, 250 );\n\tconst { searchResults, searchHasResolved } = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! search ) {\n\t\t\t\treturn { searchResults: EMPTY_ARRAY, searchHasResolved: true };\n\t\t\t}\n\t\t\tconst { getEntityRecords, hasFinishedResolution } =\n\t\t\t\tselect( coreStore );\n\t\t\tconst selectorArgs = [\n\t\t\t\t'taxonomy',\n\t\t\t\ttaxonomy.slug,\n\t\t\t\t{\n\t\t\t\t\t...BASE_QUERY,\n\t\t\t\t\tsearch,\n\t\t\t\t\torderby: 'name',\n\t\t\t\t\texclude: termIds,\n\t\t\t\t\tper_page: 20,\n\t\t\t\t},\n\t\t\t];\n\t\t\treturn {\n\t\t\t\tsearchResults: getEntityRecords( ...selectorArgs ),\n\t\t\t\tsearchHasResolved: hasFinishedResolution(\n\t\t\t\t\t'getEntityRecords',\n\t\t\t\t\tselectorArgs\n\t\t\t\t),\n\t\t\t};\n\t\t},\n\t\t[ search, termIds ]\n\t);\n\t// `existingTerms` are the ones fetched from the API and their type is `{ id: number; name: string }`.\n\t// They are used to extract the terms' names to populate the `FormTokenField` properly\n\t// and to sanitize the provided `termIds`, by setting only the ones that exist.\n\tconst existingTerms = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! termIds?.length ) {\n\t\t\t\treturn EMPTY_ARRAY;\n\t\t\t}\n\t\t\tconst { getEntityRecords } = select( coreStore );\n\t\t\treturn getEntityRecords( 'taxonomy', taxonomy.slug, {\n\t\t\t\t...BASE_QUERY,\n\t\t\t\tinclude: termIds,\n\t\t\t\tper_page: termIds.length,\n\t\t\t} );\n\t\t},\n\t\t[ termIds ]\n\t);\n\t// Update the `value` state only after the selectors are resolved\n\t// to avoid emptying the input when we're changing terms.\n\tuseEffect( () => {\n\t\tif ( ! termIds?.length ) {\n\t\t\tsetValue( EMPTY_ARRAY );\n\t\t}\n\t\tif ( ! existingTerms?.length ) {\n\t\t\treturn;\n\t\t}\n\t\t// Returns only the existing entity ids. This prevents the component\n\t\t// from crashing in the editor, when non existing ids are provided.\n\t\tconst sanitizedValue = termIds.reduce( ( accumulator, id ) => {\n\t\t\tconst entity = existingTerms.find( ( term ) => term.id === id );\n\t\t\tif ( entity ) {\n\t\t\t\taccumulator.push( {\n\t\t\t\t\tid,\n\t\t\t\t\tvalue: entity.name,\n\t\t\t\t} );\n\t\t\t}\n\t\t\treturn accumulator;\n\t\t}, [] );\n\t\tsetValue( sanitizedValue );\n\t}, [ termIds, existingTerms ] );\n\t// Update suggestions only when the query has resolved.\n\tuseEffect( () => {\n\t\tif ( ! searchHasResolved ) {\n\t\t\treturn;\n\t\t}\n\t\tsetSuggestions( searchResults.map( ( result ) => result.name ) );\n\t}, [ searchResults, searchHasResolved ] );\n\tconst onTermsChange = ( newTermValues ) => {\n\t\tconst newTermIds = new Set();\n\t\tfor ( const termValue of newTermValues ) {\n\t\t\tconst termId = getTermIdByTermValue( searchResults, termValue );\n\t\t\tif ( termId ) {\n\t\t\t\tnewTermIds.add( termId );\n\t\t\t}\n\t\t}\n\t\tsetSuggestions( EMPTY_ARRAY );\n\t\tonChange( Array.from( newTermIds ) );\n\t};\n\treturn (\n\t\t<div className=\"block-library-query-inspector__taxonomy-control\">\n\t\t\t<FormTokenField\n\t\t\t\tlabel={ taxonomy.name }\n\t\t\t\tvalue={ value }\n\t\t\t\tonInputChange={ debouncedSearch }\n\t\t\t\tsuggestions={ suggestions }\n\t\t\t\tdisplayTransform={ decodeEntities }\n\t\t\t\tonChange={ onTermsChange }\n\t\t\t\t__experimentalShowHowTo={ false }\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t__next40pxDefaultSize\n\t\t\t/>\n\t\t</div>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SACCA,cAAc,EACdC,oBAAoB,IAAIC,MAAM,QACxB,uBAAuB;AAC9B,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;AACzD,SAASC,QAAQ,EAAEC,SAAS,QAAQ,oBAAoB;AACxD,SAASC,WAAW,QAAQ,oBAAoB;AAChD,SAASC,cAAc,QAAQ,0BAA0B;;AAEzD;AACA;AACA;AACA,SAASC,aAAa,QAAQ,aAAa;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAE5C,MAAMC,WAAW,GAAG,EAAE;AACtB,MAAMC,UAAU,GAAG;EAClBC,KAAK,EAAE,KAAK;EACZC,OAAO,EAAE,SAAS;EAClBC,OAAO,EAAE;AACV,CAAC;;AAED;AACA,MAAMC,oBAAoB,GAAGA,CAAEC,KAAK,EAAEC,SAAS,KAAM;EACpD;EACA,MAAMC,MAAM,GACXD,SAAS,EAAEE,EAAE,IAAIH,KAAK,EAAEI,IAAI,CAAIC,IAAI,IAAMA,IAAI,CAACC,IAAI,KAAKL,SAAU,CAAC,EAAEE,EAAE;EACxE,IAAKD,MAAM,EAAG;IACb,OAAOA,MAAM;EACd;;EAEA;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACC,MAAMK,cAAc,GAAGN,SAAS,CAACO,iBAAiB,CAAC,CAAC;EACpD,OAAOR,KAAK,EAAEI,IAAI,CACfC,IAAI,IAAMA,IAAI,CAACC,IA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ACC9B,IAAA;IAAK8D,SAAS,EAAC,iDAAiD;IAAAtC,QAAA,eAC/DxB,IAAA,CAACZ,cAAc;MACd2E,KAAK,EAAGrC,QAAQ,CAACb,IAAM;MACvBqB,KAAK,EAAGA,KAAO;MACf8B,aAAa,EAAG1B,eAAiB;MACjCF,WAAW,EAAGA,WAAa;MAC3B6B,gBAAgB,EAAGpE,cAAgB;MACnCoB,QAAQ,EAAGuC,aAAe;MAC1BU,uBAAuB,EAAG,KAAO;MACjCC,uBAAuB;MACvBC,qBAAqB;IAAA,CACrB;EAAC,CACE,CAAC;AAER","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["FormTokenField","__experimentalVStack","VStack","useSelect","store","coreStore","useState","useEffect","useDebounce","decodeEntities","useTaxonomies","jsx","_jsx","EMPTY_ARRAY","BASE_QUERY","order","_fields","context","getTermIdByTermValue","terms","termValue","termId","id","find","term","name","termValueLower","toLocaleLowerCase","TaxonomyControls","onChange","query","postType","taxQuery","taxonomies","length","spacing","children","map","taxonomy","termIds","slug","handleChange","newTermIds","TaxonomyItem","search","setSearch","value","setValue","suggestions","setSuggestions","debouncedSearch","searchResults","searchHasResolved","select","getEntityRecords","hasFinishedResolution","selectorArgs","orderby","exclude","per_page","existingTerms","include","sanitizedValue","reduce","accumulator","entity","push","result","onTermsChange","newTermValues","Set","add","Array","from","className","label","onInputChange","displayTransform","__experimentalShowHowTo","__nextHasNoMarginBottom","__next40pxDefaultSize"],"sources":["@wordpress/block-library/src/query/edit/inspector-controls/taxonomy-controls.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tFormTokenField,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useState, useEffect } from '@wordpress/element';\nimport { useDebounce } from '@wordpress/compose';\nimport { decodeEntities } from '@wordpress/html-entities';\n\n/**\n * Internal dependencies\n */\nimport { useTaxonomies } from '../../utils';\n\nconst EMPTY_ARRAY = [];\nconst BASE_QUERY = {\n\torder: 'asc',\n\t_fields: 'id,name',\n\tcontext: 'view',\n};\n\n// Helper function to get the term id based on user input in terms `FormTokenField`.\nconst getTermIdByTermValue = ( terms, termValue ) => {\n\t// First we check for exact match by `term.id` or case sensitive `term.name` match.\n\tconst termId =\n\t\ttermValue?.id || terms?.find( ( term ) => term.name === termValue )?.id;\n\tif ( termId ) {\n\t\treturn termId;\n\t}\n\n\t/**\n\t * Here we make an extra check for entered terms in a non case sensitive way,\n\t * to match user expectations, due to `FormTokenField` behaviour that shows\n\t * suggestions which are case insensitive.\n\t *\n\t * Although WP tries to discourage users to add terms with the same name (case insensitive),\n\t * it's still possible if you manually change the name, as long as the terms have different slugs.\n\t * In this edge case we always apply the first match from the terms list.\n\t */\n\tconst termValueLower = termValue.toLocaleLowerCase();\n\treturn terms?.find(\n\t\t( term ) => term.name.toLocaleLowerCase() === termValueLower\n\t)?.id;\n};\n\nexport function TaxonomyControls( { onChange, query } ) {\n\tconst { postType, taxQuery } = query;\n\n\tconst taxonomies = useTaxonomies( postType );\n\tif ( ! taxonomies || taxonomies.length === 0 ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<VStack spacing={ 4 }>\n\t\t\t{ taxonomies.map( ( taxonomy ) => {\n\t\t\t\tconst termIds = taxQuery?.[ taxonomy.slug ] || [];\n\t\t\t\tconst handleChange = ( newTermIds ) =>\n\t\t\t\t\tonChange( {\n\t\t\t\t\t\ttaxQuery: {\n\t\t\t\t\t\t\t...taxQuery,\n\t\t\t\t\t\t\t[ taxonomy.slug ]: newTermIds,\n\t\t\t\t\t\t},\n\t\t\t\t\t} );\n\n\t\t\t\treturn (\n\t\t\t\t\t<TaxonomyItem\n\t\t\t\t\t\tkey={ taxonomy.slug }\n\t\t\t\t\t\ttaxonomy={ taxonomy }\n\t\t\t\t\t\ttermIds={ termIds }\n\t\t\t\t\t\tonChange={ handleChange }\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</VStack>\n\t);\n}\n\n/**\n * Renders a `FormTokenField` for a given taxonomy.\n *\n * @param {Object} props The props for the component.\n * @param {Object} props.taxonomy The taxonomy object.\n * @param {number[]} props.termIds An array with the block's term ids for the given taxonomy.\n * @param {Function} props.onChange Callback `onChange` function.\n * @return {JSX.Element} The rendered component.\n */\nfunction TaxonomyItem( { taxonomy, termIds, onChange } ) {\n\tconst [ search, setSearch ] = useState( '' );\n\tconst [ value, setValue ] = useState( EMPTY_ARRAY );\n\tconst [ suggestions, setSuggestions ] = useState( EMPTY_ARRAY );\n\tconst debouncedSearch = useDebounce( setSearch, 250 );\n\tconst { searchResults, searchHasResolved } = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! search ) {\n\t\t\t\treturn { searchResults: EMPTY_ARRAY, searchHasResolved: true };\n\t\t\t}\n\t\t\tconst { getEntityRecords, hasFinishedResolution } =\n\t\t\t\tselect( coreStore );\n\t\t\tconst selectorArgs = [\n\t\t\t\t'taxonomy',\n\t\t\t\ttaxonomy.slug,\n\t\t\t\t{\n\t\t\t\t\t...BASE_QUERY,\n\t\t\t\t\tsearch,\n\t\t\t\t\torderby: 'name',\n\t\t\t\t\texclude: termIds,\n\t\t\t\t\tper_page: 20,\n\t\t\t\t},\n\t\t\t];\n\t\t\treturn {\n\t\t\t\tsearchResults: getEntityRecords( ...selectorArgs ),\n\t\t\t\tsearchHasResolved: hasFinishedResolution(\n\t\t\t\t\t'getEntityRecords',\n\t\t\t\t\tselectorArgs\n\t\t\t\t),\n\t\t\t};\n\t\t},\n\t\t[ search, termIds ]\n\t);\n\t// `existingTerms` are the ones fetched from the API and their type is `{ id: number; name: string }`.\n\t// They are used to extract the terms' names to populate the `FormTokenField` properly\n\t// and to sanitize the provided `termIds`, by setting only the ones that exist.\n\tconst existingTerms = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! termIds?.length ) {\n\t\t\t\treturn EMPTY_ARRAY;\n\t\t\t}\n\t\t\tconst { getEntityRecords } = select( coreStore );\n\t\t\treturn getEntityRecords( 'taxonomy', taxonomy.slug, {\n\t\t\t\t...BASE_QUERY,\n\t\t\t\tinclude: termIds,\n\t\t\t\tper_page: termIds.length,\n\t\t\t} );\n\t\t},\n\t\t[ termIds ]\n\t);\n\t// Update the `value` state only after the selectors are resolved\n\t// to avoid emptying the input when we're changing terms.\n\tuseEffect( () => {\n\t\tif ( ! termIds?.length ) {\n\t\t\tsetValue( EMPTY_ARRAY );\n\t\t}\n\t\tif ( ! existingTerms?.length ) {\n\t\t\treturn;\n\t\t}\n\t\t// Returns only the existing entity ids. This prevents the component\n\t\t// from crashing in the editor, when non existing ids are provided.\n\t\tconst sanitizedValue = termIds.reduce( ( accumulator, id ) => {\n\t\t\tconst entity = existingTerms.find( ( term ) => term.id === id );\n\t\t\tif ( entity ) {\n\t\t\t\taccumulator.push( {\n\t\t\t\t\tid,\n\t\t\t\t\tvalue: entity.name,\n\t\t\t\t} );\n\t\t\t}\n\t\t\treturn accumulator;\n\t\t}, [] );\n\t\tsetValue( sanitizedValue );\n\t}, [ termIds, existingTerms ] );\n\t// Update suggestions only when the query has resolved.\n\tuseEffect( () => {\n\t\tif ( ! searchHasResolved ) {\n\t\t\treturn;\n\t\t}\n\t\tsetSuggestions( searchResults.map( ( result ) => result.name ) );\n\t}, [ searchResults, searchHasResolved ] );\n\tconst onTermsChange = ( newTermValues ) => {\n\t\tconst newTermIds = new Set();\n\t\tfor ( const termValue of newTermValues ) {\n\t\t\tconst termId = getTermIdByTermValue( searchResults, termValue );\n\t\t\tif ( termId ) {\n\t\t\t\tnewTermIds.add( termId );\n\t\t\t}\n\t\t}\n\t\tsetSuggestions( EMPTY_ARRAY );\n\t\tonChange( Array.from( newTermIds ) );\n\t};\n\treturn (\n\t\t<div className=\"block-library-query-inspector__taxonomy-control\">\n\t\t\t<FormTokenField\n\t\t\t\tlabel={ taxonomy.name }\n\t\t\t\tvalue={ value }\n\t\t\t\tonInputChange={ debouncedSearch }\n\t\t\t\tsuggestions={ suggestions }\n\t\t\t\tdisplayTransform={ decodeEntities }\n\t\t\t\tonChange={ onTermsChange }\n\t\t\t\t__experimentalShowHowTo={ false }\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t__next40pxDefaultSize\n\t\t\t/>\n\t\t</div>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SACCA,cAAc,EACdC,oBAAoB,IAAIC,MAAM,QACxB,uBAAuB;AAC9B,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;AACzD,SAASC,QAAQ,EAAEC,SAAS,QAAQ,oBAAoB;AACxD,SAASC,WAAW,QAAQ,oBAAoB;AAChD,SAASC,cAAc,QAAQ,0BAA0B;;AAEzD;AACA;AACA;AACA,SAASC,aAAa,QAAQ,aAAa;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAE5C,MAAMC,WAAW,GAAG,EAAE;AACtB,MAAMC,UAAU,GAAG;EAClBC,KAAK,EAAE,KAAK;EACZC,OAAO,EAAE,SAAS;EAClBC,OAAO,EAAE;AACV,CAAC;;AAED;AACA,MAAMC,oBAAoB,GAAGA,CAAEC,KAAK,EAAEC,SAAS,KAAM;EACpD;EACA,MAAMC,MAAM,GACXD,SAAS,EAAEE,EAAE,IAAIH,KAAK,EAAEI,IAAI,CAAIC,IAAI,IAAMA,IAAI,CAACC,IAAI,KAAKL,SAAU,CAAC,EAAEE,EAAE;EACxE,IAAKD,MAAM,EAAG;IACb,OAAOA,MAAM;EACd;;EAEA;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACC,MAAMK,cAAc,GAAGN,SAAS,CAACO,iBAAiB,CAAC,CAAC;EACpD,OAAOR,KAAK,EAAEI,IAAI,CACfC,IAAI,IAAMA,IAAI,CAACC,IAAI,CAACE,iBAAiB,CAAC,CAAC,KAAKD,cAC/C,CAAC,EAAEJ,EAAE;AACN,CAAC;AAED,OAAO,SAASM,gBAAgBA,CAAE;EAAEC,QA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,IAAM;MACvBqB,KAAK,EAAGA,KAAO;MACf8B,aAAa,EAAG1B,eAAiB;MACjCF,WAAW,EAAGA,WAAa;MAC3B6B,gBAAgB,EAAGpE,cAAgB;MACnCoB,QAAQ,EAAGuC,aAAe;MAC1BU,uBAAuB,EAAG,KAAO;MACjCC,uBAAuB;MACvBC,qBAAqB;IAAA,CACrB;EAAC,CACE,CAAC;AAER","ignoreList":[]}
|
|
@@ -13,16 +13,48 @@ import { __ } from '@wordpress/i18n';
|
|
|
13
13
|
import { useBlockNameForPatterns, getTransformedBlocksFromPattern, usePatterns } from '../utils';
|
|
14
14
|
import { searchPatterns } from '../../utils/search-patterns';
|
|
15
15
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
16
|
-
export
|
|
16
|
+
export function PatternSelectionModal({
|
|
17
17
|
clientId,
|
|
18
18
|
attributes,
|
|
19
19
|
setIsPatternSelectionModalOpen
|
|
20
|
+
}) {
|
|
21
|
+
return /*#__PURE__*/_jsx(Modal, {
|
|
22
|
+
overlayClassName: "block-library-query-pattern__selection-modal",
|
|
23
|
+
title: __('Choose a pattern'),
|
|
24
|
+
onRequestClose: () => setIsPatternSelectionModalOpen(false),
|
|
25
|
+
isFullScreen: true,
|
|
26
|
+
children: /*#__PURE__*/_jsx(PatternSelection, {
|
|
27
|
+
clientId: clientId,
|
|
28
|
+
attributes: attributes
|
|
29
|
+
})
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
export function useBlockPatterns(clientId, attributes) {
|
|
33
|
+
const blockNameForPatterns = useBlockNameForPatterns(clientId, attributes);
|
|
34
|
+
return usePatterns(clientId, blockNameForPatterns);
|
|
35
|
+
}
|
|
36
|
+
export default function PatternSelection({
|
|
37
|
+
clientId,
|
|
38
|
+
attributes,
|
|
39
|
+
showTitlesAsTooltip = false,
|
|
40
|
+
showSearch = true
|
|
20
41
|
}) {
|
|
21
42
|
const [searchValue, setSearchValue] = useState('');
|
|
22
43
|
const {
|
|
23
44
|
replaceBlock,
|
|
24
45
|
selectBlock
|
|
25
46
|
} = useDispatch(blockEditorStore);
|
|
47
|
+
const blockPatterns = useBlockPatterns(clientId, attributes);
|
|
48
|
+
/*
|
|
49
|
+
* When we preview Query Loop blocks we should prefer the current
|
|
50
|
+
* block's postType, which is passed through block context.
|
|
51
|
+
*/
|
|
52
|
+
const blockPreviewContext = useMemo(() => ({
|
|
53
|
+
previewPostType: attributes.query.postType
|
|
54
|
+
}), [attributes.query.postType]);
|
|
55
|
+
const filteredBlockPatterns = useMemo(() => {
|
|
56
|
+
return searchPatterns(blockPatterns, searchValue);
|
|
57
|
+
}, [blockPatterns, searchValue]);
|
|
26
58
|
const onBlockPatternSelect = (pattern, blocks) => {
|
|
27
59
|
const {
|
|
28
60
|
newBlocks,
|
|
@@ -33,40 +65,25 @@ export default function PatternSelectionModal({
|
|
|
33
65
|
selectBlock(queryClientIds[0]);
|
|
34
66
|
}
|
|
35
67
|
};
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
children: /*#__PURE__*/_jsx(SearchControl, {
|
|
56
|
-
__nextHasNoMarginBottom: true,
|
|
57
|
-
onChange: setSearchValue,
|
|
58
|
-
value: searchValue,
|
|
59
|
-
label: __('Search'),
|
|
60
|
-
placeholder: __('Search')
|
|
61
|
-
})
|
|
62
|
-
}), /*#__PURE__*/_jsx(BlockContextProvider, {
|
|
63
|
-
value: blockPreviewContext,
|
|
64
|
-
children: /*#__PURE__*/_jsx(BlockPatternsList, {
|
|
65
|
-
blockPatterns: filteredBlockPatterns,
|
|
66
|
-
onClickPattern: onBlockPatternSelect
|
|
67
|
-
})
|
|
68
|
-
})]
|
|
69
|
-
})
|
|
68
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
69
|
+
className: "block-library-query-pattern__selection-content",
|
|
70
|
+
children: [showSearch && /*#__PURE__*/_jsx("div", {
|
|
71
|
+
className: "block-library-query-pattern__selection-search",
|
|
72
|
+
children: /*#__PURE__*/_jsx(SearchControl, {
|
|
73
|
+
__nextHasNoMarginBottom: true,
|
|
74
|
+
onChange: setSearchValue,
|
|
75
|
+
value: searchValue,
|
|
76
|
+
label: __('Search'),
|
|
77
|
+
placeholder: __('Search')
|
|
78
|
+
})
|
|
79
|
+
}), /*#__PURE__*/_jsx(BlockContextProvider, {
|
|
80
|
+
value: blockPreviewContext,
|
|
81
|
+
children: /*#__PURE__*/_jsx(BlockPatternsList, {
|
|
82
|
+
blockPatterns: filteredBlockPatterns,
|
|
83
|
+
onClickPattern: onBlockPatternSelect,
|
|
84
|
+
showTitlesAsTooltip: showTitlesAsTooltip
|
|
85
|
+
})
|
|
86
|
+
})]
|
|
70
87
|
});
|
|
71
88
|
}
|
|
72
|
-
//# sourceMappingURL=pattern-selection
|
|
89
|
+
//# sourceMappingURL=pattern-selection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useState","useMemo","useDispatch","Modal","SearchControl","BlockContextProvider","store","blockEditorStore","__experimentalBlockPatternsList","BlockPatternsList","__","useBlockNameForPatterns","getTransformedBlocksFromPattern","usePatterns","searchPatterns","jsx","_jsx","jsxs","_jsxs","PatternSelectionModal","clientId","attributes","setIsPatternSelectionModalOpen","overlayClassName","title","onRequestClose","isFullScreen","children","PatternSelection","useBlockPatterns","blockNameForPatterns","showTitlesAsTooltip","showSearch","searchValue","setSearchValue","replaceBlock","selectBlock","blockPatterns","blockPreviewContext","previewPostType","query","postType","filteredBlockPatterns","onBlockPatternSelect","pattern","blocks","newBlocks","queryClientIds","className","__nextHasNoMarginBottom","onChange","value","label","placeholder","onClickPattern"],"sources":["@wordpress/block-library/src/query/edit/pattern-selection.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useState, useMemo } from '@wordpress/element';\nimport { useDispatch } from '@wordpress/data';\nimport { Modal, SearchControl } from '@wordpress/components';\nimport {\n\tBlockContextProvider,\n\tstore as blockEditorStore,\n\t__experimentalBlockPatternsList as BlockPatternsList,\n} from '@wordpress/block-editor';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport {\n\tuseBlockNameForPatterns,\n\tgetTransformedBlocksFromPattern,\n\tusePatterns,\n} from '../utils';\nimport { searchPatterns } from '../../utils/search-patterns';\n\nexport function PatternSelectionModal( {\n\tclientId,\n\tattributes,\n\tsetIsPatternSelectionModalOpen,\n} ) {\n\treturn (\n\t\t<Modal\n\t\t\toverlayClassName=\"block-library-query-pattern__selection-modal\"\n\t\t\ttitle={ __( 'Choose a pattern' ) }\n\t\t\tonRequestClose={ () => setIsPatternSelectionModalOpen( false ) }\n\t\t\tisFullScreen\n\t\t>\n\t\t\t<PatternSelection clientId={ clientId } attributes={ attributes } />\n\t\t</Modal>\n\t);\n}\n\nexport function useBlockPatterns( clientId, attributes ) {\n\tconst blockNameForPatterns = useBlockNameForPatterns(\n\t\tclientId,\n\t\tattributes\n\t);\n\treturn usePatterns( clientId, blockNameForPatterns );\n}\n\nexport default function PatternSelection( {\n\tclientId,\n\tattributes,\n\tshowTitlesAsTooltip = false,\n\tshowSearch = true,\n} ) {\n\tconst [ searchValue, setSearchValue ] = useState( '' );\n\tconst { replaceBlock, selectBlock } = useDispatch( blockEditorStore );\n\tconst blockPatterns = useBlockPatterns( clientId, attributes );\n\t/*\n\t * When we preview Query Loop blocks we should prefer the current\n\t * block's postType, which is passed through block context.\n\t */\n\tconst blockPreviewContext = useMemo(\n\t\t() => ( {\n\t\t\tpreviewPostType: attributes.query.postType,\n\t\t} ),\n\t\t[ attributes.query.postType ]\n\t);\n\tconst filteredBlockPatterns = useMemo( () => {\n\t\treturn searchPatterns( blockPatterns, searchValue );\n\t}, [ blockPatterns, searchValue ] );\n\n\tconst onBlockPatternSelect = ( pattern, blocks ) => {\n\t\tconst { newBlocks, queryClientIds } = getTransformedBlocksFromPattern(\n\t\t\tblocks,\n\t\t\tattributes\n\t\t);\n\t\treplaceBlock( clientId, newBlocks );\n\t\tif ( queryClientIds[ 0 ] ) {\n\t\t\tselectBlock( queryClientIds[ 0 ] );\n\t\t}\n\t};\n\treturn (\n\t\t<div className=\"block-library-query-pattern__selection-content\">\n\t\t\t{ showSearch && (\n\t\t\t\t<div className=\"block-library-query-pattern__selection-search\">\n\t\t\t\t\t<SearchControl\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\tonChange={ setSearchValue }\n\t\t\t\t\t\tvalue={ searchValue }\n\t\t\t\t\t\tlabel={ __( 'Search' ) }\n\t\t\t\t\t\tplaceholder={ __( 'Search' ) }\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t<BlockContextProvider value={ blockPreviewContext }>\n\t\t\t\t<BlockPatternsList\n\t\t\t\t\tblockPatterns={ filteredBlockPatterns }\n\t\t\t\t\tonClickPattern={ onBlockPatternSelect }\n\t\t\t\t\tshowTitlesAsTooltip={ showTitlesAsTooltip }\n\t\t\t\t/>\n\t\t\t</BlockContextProvider>\n\t\t</div>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,QAAQ,EAAEC,OAAO,QAAQ,oBAAoB;AACtD,SAASC,WAAW,QAAQ,iBAAiB;AAC7C,SAASC,KAAK,EAAEC,aAAa,QAAQ,uBAAuB;AAC5D,SACCC,oBAAoB,EACpBC,KAAK,IAAIC,gBAAgB,EACzBC,+BAA+B,IAAIC,iBAAiB,QAC9C,yBAAyB;AAChC,SAASC,EAAE,QAAQ,iBAAiB;;AAEpC;AACA;AACA;AACA,SACCC,uBAAuB,EACvBC,+BAA+B,EAC/BC,WAAW,QACL,UAAU;AACjB,SAASC,cAAc,QAAQ,6BAA6B;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IA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,WAAY,CAAC;EACpD,CAAC,EAAE,CAAEI,aAAa,EAAEJ,WAAW,CAAG,CAAC;EAEnC,MAAMU,oBAAoB,GAAGA,CAAEC,OAAO,EAAEC,MAAM,KAAM;IACnD,MAAM;MAAEC,SAAS;MAAEC;IAAe,CAAC,GAAGnC,+BAA+B,CACpEiC,MAAM,EACNxB,UACD,CAAC;IACDc,YAAY,CAAEf,QAAQ,EAAE0B,SAAU,CAAC;IACnC,IAAKC,cAAc,CAAE,CAAC,CAAE,EAAG;MAC1BX,WAAW,CAAEW,cAAc,CAAE,CAAC,CAAG,CAAC;IACnC;EACD,CAAC;EACD,oBACC7B,KAAA;IAAK8B,SAAS,EAAC,gDAAgD;IAAArB,QAAA,GAC5DK,UAAU,iBACXhB,IAAA;MAAKgC,SAAS,EAAC,+CAA+C;MAAArB,QAAA,eAC7DX,IAAA,CAACZ,aAAa;QACb6C,uBAAuB;QACvBC,QAAQ,EAAGhB,cAAgB;QAC3BiB,KAAK,EAAGlB,WAAa;QACrBmB,KAAK,EAAG1C,EAAE,CAAE,QAAS,CAAG;QACxB2C,WAAW,EAAG3C,EAAE,CAAE,QAAS;MAAG,CAC9B;IAAC,CACE,CACL,eACDM,IAAA,CAACX,oBAAoB;MAAC8C,KAAK,EAAGb,mBAAqB;MAAAX,QAAA,eAClDX,IAAA,CAACP,iBAAiB;QACjB4B,aAAa,EAAGK,qBAAuB;QACvCY,cAAc,EAAGX,oBAAsB;QACvCZ,mBAAmB,EAAGA;MAAqB,CAC3C;IAAC,CACmB,CAAC;EAAA,CACnB,CAAC;AAER","ignoreList":[]}
|
|
@@ -13,20 +13,19 @@ import { store as coreStore } from '@wordpress/core-data';
|
|
|
13
13
|
* Internal dependencies
|
|
14
14
|
*/
|
|
15
15
|
import EnhancedPaginationControl from './inspector-controls/enhanced-pagination-control';
|
|
16
|
-
import QueryToolbar from './query-toolbar';
|
|
17
16
|
import QueryInspectorControls from './inspector-controls';
|
|
18
17
|
import EnhancedPaginationModal from './enhanced-pagination-modal';
|
|
19
18
|
import { getQueryContextFromTemplate } from '../utils';
|
|
19
|
+
import QueryToolbar from './query-toolbar';
|
|
20
20
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
21
21
|
const DEFAULTS_POSTS_PER_PAGE = 3;
|
|
22
22
|
const TEMPLATE = [['core/post-template']];
|
|
23
23
|
export default function QueryContent({
|
|
24
24
|
attributes,
|
|
25
25
|
setAttributes,
|
|
26
|
-
openPatternSelectionModal,
|
|
27
|
-
name,
|
|
28
26
|
clientId,
|
|
29
|
-
context
|
|
27
|
+
context,
|
|
28
|
+
name
|
|
30
29
|
}) {
|
|
31
30
|
const {
|
|
32
31
|
queryId,
|
|
@@ -138,6 +137,7 @@ export default function QueryContent({
|
|
|
138
137
|
clientId: clientId
|
|
139
138
|
}), /*#__PURE__*/_jsx(InspectorControls, {
|
|
140
139
|
children: /*#__PURE__*/_jsx(QueryInspectorControls, {
|
|
140
|
+
name: name,
|
|
141
141
|
attributes: attributes,
|
|
142
142
|
setQuery: updateQuery,
|
|
143
143
|
setDisplayLayout: updateDisplayLayout,
|
|
@@ -147,11 +147,8 @@ export default function QueryContent({
|
|
|
147
147
|
})
|
|
148
148
|
}), /*#__PURE__*/_jsx(BlockControls, {
|
|
149
149
|
children: /*#__PURE__*/_jsx(QueryToolbar, {
|
|
150
|
-
name: name,
|
|
151
|
-
clientId: clientId,
|
|
152
150
|
attributes: attributes,
|
|
153
|
-
|
|
154
|
-
openPatternSelectionModal: openPatternSelectionModal
|
|
151
|
+
clientId: clientId
|
|
155
152
|
})
|
|
156
153
|
}), /*#__PURE__*/_jsxs(InspectorControls, {
|
|
157
154
|
group: "advanced",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useSelect","useDispatch","useInstanceId","useEffect","useCallback","BlockControls","InspectorControls","useBlockProps","store","blockEditorStore","useInnerBlocksProps","SelectControl","__","coreStore","EnhancedPaginationControl","QueryToolbar","QueryInspectorControls","EnhancedPaginationModal","getQueryContextFromTemplate","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","DEFAULTS_POSTS_PER_PAGE","TEMPLATE","QueryContent","attributes","setAttributes","openPatternSelectionModal","name","clientId","context","queryId","query","displayLayout","enhancedPagination","tagName","TagName","inherit","templateSlug","isSingular","__unstableMarkNextChangeAsNotPersistent","instanceId","blockProps","innerBlocksProps","template","postsPerPage","select","getSettings","getEntityRecord","getEntityRecordEdits","canUser","settingPerPage","kind","posts_per_page","editedSettingPerPage","updateQuery","newQuery","perPage","Object","keys","length","Number","isFinite","updateDisplayLayout","newDisplayLayout","htmlElementMessages","main","section","aside","children","setQuery","setDisplayLayout","group","__nextHasNoMarginBottom","__next40pxDefaultSize","label","options","value","onChange","help"],"sources":["@wordpress/block-library/src/query/edit/query-content.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useInstanceId } from '@wordpress/compose';\nimport { useEffect, useCallback } from '@wordpress/element';\nimport {\n\tBlockControls,\n\tInspectorControls,\n\tuseBlockProps,\n\tstore as blockEditorStore,\n\tuseInnerBlocksProps,\n} from '@wordpress/block-editor';\nimport { SelectControl } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport EnhancedPaginationControl from './inspector-controls/enhanced-pagination-control';\nimport QueryToolbar from './query-toolbar';\nimport QueryInspectorControls from './inspector-controls';\nimport EnhancedPaginationModal from './enhanced-pagination-modal';\nimport { getQueryContextFromTemplate } from '../utils';\n\nconst DEFAULTS_POSTS_PER_PAGE = 3;\n\nconst TEMPLATE = [ [ 'core/post-template' ] ];\nexport default function QueryContent( {\n\tattributes,\n\tsetAttributes,\n\topenPatternSelectionModal,\n\tname,\n\tclientId,\n\tcontext,\n} ) {\n\tconst {\n\t\tqueryId,\n\t\tquery,\n\t\tdisplayLayout,\n\t\tenhancedPagination,\n\t\ttagName: TagName = 'div',\n\t\tquery: { inherit } = {},\n\t} = attributes;\n\tconst { templateSlug } = context;\n\tconst { isSingular } = getQueryContextFromTemplate( templateSlug );\n\tconst { __unstableMarkNextChangeAsNotPersistent } =\n\t\tuseDispatch( blockEditorStore );\n\tconst instanceId = useInstanceId( QueryContent );\n\tconst blockProps = useBlockProps();\n\tconst innerBlocksProps = useInnerBlocksProps( blockProps, {\n\t\ttemplate: TEMPLATE,\n\t} );\n\tconst { postsPerPage } = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\tconst { getEntityRecord, getEntityRecordEdits, canUser } =\n\t\t\tselect( coreStore );\n\t\tconst settingPerPage = canUser( 'read', {\n\t\t\tkind: 'root',\n\t\t\tname: 'site',\n\t\t} )\n\t\t\t? +getEntityRecord( 'root', 'site' )?.posts_per_page\n\t\t\t: +getSettings().postsPerPage;\n\n\t\t// Gets changes made via the template area posts per page setting. These won't be saved\n\t\t// until the page is saved, but we should reflect this setting within the query loops\n\t\t// that inherit it.\n\t\tconst editedSettingPerPage = +getEntityRecordEdits( 'root', 'site' )\n\t\t\t?.posts_per_page;\n\n\t\treturn {\n\t\t\tpostsPerPage:\n\t\t\t\teditedSettingPerPage ||\n\t\t\t\tsettingPerPage ||\n\t\t\t\tDEFAULTS_POSTS_PER_PAGE,\n\t\t};\n\t}, [] );\n\t// There are some effects running where some initialization logic is\n\t// happening and setting some values to some attributes (ex. queryId).\n\t// These updates can cause an `undo trap` where undoing will result in\n\t// resetting again, so we need to mark these changes as not persistent\n\t// with `__unstableMarkNextChangeAsNotPersistent`.\n\n\t// Changes in query property (which is an object) need to be in the same callback,\n\t// because updates are batched after the render and changes in different query properties\n\t// would cause to override previous wanted changes.\n\tconst updateQuery = useCallback(\n\t\t( newQuery ) => setAttributes( { query: { ...query, ...newQuery } } ),\n\t\t[ query, setAttributes ]\n\t);\n\tuseEffect( () => {\n\t\tconst newQuery = {};\n\t\t// When we inherit from global query always need to set the `perPage`\n\t\t// based on the reading settings.\n\t\tif ( inherit && query.perPage !== postsPerPage ) {\n\t\t\tnewQuery.perPage = postsPerPage;\n\t\t} else if ( ! query.perPage && postsPerPage ) {\n\t\t\tnewQuery.perPage = postsPerPage;\n\t\t}\n\t\t// We need to reset the `inherit` value if in a singular template, as queries\n\t\t// are not inherited when in singular content (e.g. post, page, 404, blank).\n\t\tif ( isSingular && query.inherit ) {\n\t\t\tnewQuery.inherit = false;\n\t\t}\n\t\tif ( !! Object.keys( newQuery ).length ) {\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\tupdateQuery( newQuery );\n\t\t}\n\t}, [\n\t\tquery.perPage,\n\t\tquery.inherit,\n\t\tpostsPerPage,\n\t\tinherit,\n\t\tisSingular,\n\t\t__unstableMarkNextChangeAsNotPersistent,\n\t\tupdateQuery,\n\t] );\n\t// We need this for multi-query block pagination.\n\t// Query parameters for each block are scoped to their ID.\n\tuseEffect( () => {\n\t\tif ( ! Number.isFinite( queryId ) ) {\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\tsetAttributes( { queryId: instanceId } );\n\t\t}\n\t}, [\n\t\tqueryId,\n\t\tinstanceId,\n\t\t__unstableMarkNextChangeAsNotPersistent,\n\t\tsetAttributes,\n\t] );\n\tconst updateDisplayLayout = ( newDisplayLayout ) =>\n\t\tsetAttributes( {\n\t\t\tdisplayLayout: { ...displayLayout, ...newDisplayLayout },\n\t\t} );\n\tconst htmlElementMessages = {\n\t\tmain: __(\n\t\t\t'The <main> element should be used for the primary content of your document only.'\n\t\t),\n\t\tsection: __(\n\t\t\t\"The <section> element should represent a standalone portion of the document that can't be better represented by another element.\"\n\t\t),\n\t\taside: __(\n\t\t\t\"The <aside> element should represent a portion of a document whose content is only indirectly related to the document's main content.\"\n\t\t),\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t<EnhancedPaginationModal\n\t\t\t\tattributes={ attributes }\n\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\tclientId={ clientId }\n\t\t\t/>\n\t\t\t<InspectorControls>\n\t\t\t\t<QueryInspectorControls\n\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\tsetQuery={ updateQuery }\n\t\t\t\t\tsetDisplayLayout={ updateDisplayLayout }\n\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\tisSingular={ isSingular }\n\t\t\t\t/>\n\t\t\t</InspectorControls>\n\t\t\t<BlockControls>\n\t\t\t\t<QueryToolbar\n\t\t\t\t\tname={ name }\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\tsetQuery={ updateQuery }\n\t\t\t\t\topenPatternSelectionModal={ openPatternSelectionModal }\n\t\t\t\t/>\n\t\t\t</BlockControls>\n\t\t\t<InspectorControls group=\"advanced\">\n\t\t\t\t<SelectControl\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\tlabel={ __( 'HTML element' ) }\n\t\t\t\t\toptions={ [\n\t\t\t\t\t\t{ label: __( 'Default (<div>)' ), value: 'div' },\n\t\t\t\t\t\t{ label: '<main>', value: 'main' },\n\t\t\t\t\t\t{ label: '<section>', value: 'section' },\n\t\t\t\t\t\t{ label: '<aside>', value: 'aside' },\n\t\t\t\t\t] }\n\t\t\t\t\tvalue={ TagName }\n\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\tsetAttributes( { tagName: value } )\n\t\t\t\t\t}\n\t\t\t\t\thelp={ htmlElementMessages[ TagName ] }\n\t\t\t\t/>\n\t\t\t\t<EnhancedPaginationControl\n\t\t\t\t\tenhancedPagination={ enhancedPagination }\n\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t/>\n\t\t\t</InspectorControls>\n\t\t\t<TagName { ...innerBlocksProps } />\n\t\t</>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,EAAEC,WAAW,QAAQ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C/BG,QAAQ,EAAGA;MAAU,CACrB,CAAC;IAAA,CACgB,CAAC,eACpBZ,IAAA,CAACmB,OAAO;MAAA,GAAMO;IAAgB,CAAI,CAAC;EAAA,CAClC,CAAC;AAEL","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["useSelect","useDispatch","useInstanceId","useEffect","useCallback","BlockControls","InspectorControls","useBlockProps","store","blockEditorStore","useInnerBlocksProps","SelectControl","__","coreStore","EnhancedPaginationControl","QueryInspectorControls","EnhancedPaginationModal","getQueryContextFromTemplate","QueryToolbar","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","DEFAULTS_POSTS_PER_PAGE","TEMPLATE","QueryContent","attributes","setAttributes","clientId","context","name","queryId","query","displayLayout","enhancedPagination","tagName","TagName","inherit","templateSlug","isSingular","__unstableMarkNextChangeAsNotPersistent","instanceId","blockProps","innerBlocksProps","template","postsPerPage","select","getSettings","getEntityRecord","getEntityRecordEdits","canUser","settingPerPage","kind","posts_per_page","editedSettingPerPage","updateQuery","newQuery","perPage","Object","keys","length","Number","isFinite","updateDisplayLayout","newDisplayLayout","htmlElementMessages","main","section","aside","children","setQuery","setDisplayLayout","group","__nextHasNoMarginBottom","__next40pxDefaultSize","label","options","value","onChange","help"],"sources":["@wordpress/block-library/src/query/edit/query-content.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useInstanceId } from '@wordpress/compose';\nimport { useEffect, useCallback } from '@wordpress/element';\nimport {\n\tBlockControls,\n\tInspectorControls,\n\tuseBlockProps,\n\tstore as blockEditorStore,\n\tuseInnerBlocksProps,\n} from '@wordpress/block-editor';\nimport { SelectControl } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport EnhancedPaginationControl from './inspector-controls/enhanced-pagination-control';\nimport QueryInspectorControls from './inspector-controls';\nimport EnhancedPaginationModal from './enhanced-pagination-modal';\nimport { getQueryContextFromTemplate } from '../utils';\nimport QueryToolbar from './query-toolbar';\n\nconst DEFAULTS_POSTS_PER_PAGE = 3;\n\nconst TEMPLATE = [ [ 'core/post-template' ] ];\nexport default function QueryContent( {\n\tattributes,\n\tsetAttributes,\n\tclientId,\n\tcontext,\n\tname,\n} ) {\n\tconst {\n\t\tqueryId,\n\t\tquery,\n\t\tdisplayLayout,\n\t\tenhancedPagination,\n\t\ttagName: TagName = 'div',\n\t\tquery: { inherit } = {},\n\t} = attributes;\n\tconst { templateSlug } = context;\n\tconst { isSingular } = getQueryContextFromTemplate( templateSlug );\n\tconst { __unstableMarkNextChangeAsNotPersistent } =\n\t\tuseDispatch( blockEditorStore );\n\tconst instanceId = useInstanceId( QueryContent );\n\tconst blockProps = useBlockProps();\n\tconst innerBlocksProps = useInnerBlocksProps( blockProps, {\n\t\ttemplate: TEMPLATE,\n\t} );\n\tconst { postsPerPage } = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\tconst { getEntityRecord, getEntityRecordEdits, canUser } =\n\t\t\tselect( coreStore );\n\t\tconst settingPerPage = canUser( 'read', {\n\t\t\tkind: 'root',\n\t\t\tname: 'site',\n\t\t} )\n\t\t\t? +getEntityRecord( 'root', 'site' )?.posts_per_page\n\t\t\t: +getSettings().postsPerPage;\n\n\t\t// Gets changes made via the template area posts per page setting. These won't be saved\n\t\t// until the page is saved, but we should reflect this setting within the query loops\n\t\t// that inherit it.\n\t\tconst editedSettingPerPage = +getEntityRecordEdits( 'root', 'site' )\n\t\t\t?.posts_per_page;\n\n\t\treturn {\n\t\t\tpostsPerPage:\n\t\t\t\teditedSettingPerPage ||\n\t\t\t\tsettingPerPage ||\n\t\t\t\tDEFAULTS_POSTS_PER_PAGE,\n\t\t};\n\t}, [] );\n\t// There are some effects running where some initialization logic is\n\t// happening and setting some values to some attributes (ex. queryId).\n\t// These updates can cause an `undo trap` where undoing will result in\n\t// resetting again, so we need to mark these changes as not persistent\n\t// with `__unstableMarkNextChangeAsNotPersistent`.\n\n\t// Changes in query property (which is an object) need to be in the same callback,\n\t// because updates are batched after the render and changes in different query properties\n\t// would cause to override previous wanted changes.\n\tconst updateQuery = useCallback(\n\t\t( newQuery ) => setAttributes( { query: { ...query, ...newQuery } } ),\n\t\t[ query, setAttributes ]\n\t);\n\tuseEffect( () => {\n\t\tconst newQuery = {};\n\t\t// When we inherit from global query always need to set the `perPage`\n\t\t// based on the reading settings.\n\t\tif ( inherit && query.perPage !== postsPerPage ) {\n\t\t\tnewQuery.perPage = postsPerPage;\n\t\t} else if ( ! query.perPage && postsPerPage ) {\n\t\t\tnewQuery.perPage = postsPerPage;\n\t\t}\n\t\t// We need to reset the `inherit` value if in a singular template, as queries\n\t\t// are not inherited when in singular content (e.g. post, page, 404, blank).\n\t\tif ( isSingular && query.inherit ) {\n\t\t\tnewQuery.inherit = false;\n\t\t}\n\t\tif ( !! Object.keys( newQuery ).length ) {\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\tupdateQuery( newQuery );\n\t\t}\n\t}, [\n\t\tquery.perPage,\n\t\tquery.inherit,\n\t\tpostsPerPage,\n\t\tinherit,\n\t\tisSingular,\n\t\t__unstableMarkNextChangeAsNotPersistent,\n\t\tupdateQuery,\n\t] );\n\t// We need this for multi-query block pagination.\n\t// Query parameters for each block are scoped to their ID.\n\tuseEffect( () => {\n\t\tif ( ! Number.isFinite( queryId ) ) {\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\tsetAttributes( { queryId: instanceId } );\n\t\t}\n\t}, [\n\t\tqueryId,\n\t\tinstanceId,\n\t\t__unstableMarkNextChangeAsNotPersistent,\n\t\tsetAttributes,\n\t] );\n\tconst updateDisplayLayout = ( newDisplayLayout ) =>\n\t\tsetAttributes( {\n\t\t\tdisplayLayout: { ...displayLayout, ...newDisplayLayout },\n\t\t} );\n\tconst htmlElementMessages = {\n\t\tmain: __(\n\t\t\t'The <main> element should be used for the primary content of your document only.'\n\t\t),\n\t\tsection: __(\n\t\t\t\"The <section> element should represent a standalone portion of the document that can't be better represented by another element.\"\n\t\t),\n\t\taside: __(\n\t\t\t\"The <aside> element should represent a portion of a document whose content is only indirectly related to the document's main content.\"\n\t\t),\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t<EnhancedPaginationModal\n\t\t\t\tattributes={ attributes }\n\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\tclientId={ clientId }\n\t\t\t/>\n\t\t\t<InspectorControls>\n\t\t\t\t<QueryInspectorControls\n\t\t\t\t\tname={ name }\n\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\tsetQuery={ updateQuery }\n\t\t\t\t\tsetDisplayLayout={ updateDisplayLayout }\n\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\tisSingular={ isSingular }\n\t\t\t\t/>\n\t\t\t</InspectorControls>\n\t\t\t<BlockControls>\n\t\t\t\t<QueryToolbar attributes={ attributes } clientId={ clientId } />\n\t\t\t</BlockControls>\n\t\t\t<InspectorControls group=\"advanced\">\n\t\t\t\t<SelectControl\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\tlabel={ __( 'HTML element' ) }\n\t\t\t\t\toptions={ [\n\t\t\t\t\t\t{ label: __( 'Default (<div>)' ), value: 'div' },\n\t\t\t\t\t\t{ label: '<main>', value: 'main' },\n\t\t\t\t\t\t{ label: '<section>', value: 'section' },\n\t\t\t\t\t\t{ label: '<aside>', value: 'aside' },\n\t\t\t\t\t] }\n\t\t\t\t\tvalue={ TagName }\n\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\tsetAttributes( { tagName: value } )\n\t\t\t\t\t}\n\t\t\t\t\thelp={ htmlElementMessages[ TagName ] }\n\t\t\t\t/>\n\t\t\t\t<EnhancedPaginationControl\n\t\t\t\t\tenhancedPagination={ enhancedPagination }\n\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\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FlB,IAAA,CAACN,yBAAyB;QACzBsB,kBAAkB,EAAGA,kBAAoB;QACzCP,aAAa,EAAGA,aAAe;QAC/BC,QAAQ,EAAGA;MAAU,CACrB,CAAC;IAAA,CACgB,CAAC,eACpBV,IAAA,CAACkB,OAAO;MAAA,GAAMO;IAAgB,CAAI,CAAC;EAAA,CAClC,CAAC;AAEL","ignoreList":[]}
|
|
@@ -11,7 +11,8 @@ import { __ } from '@wordpress/i18n';
|
|
|
11
11
|
/**
|
|
12
12
|
* Internal dependencies
|
|
13
13
|
*/
|
|
14
|
-
import { useScopedBlockVariations
|
|
14
|
+
import { useScopedBlockVariations } from '../utils';
|
|
15
|
+
import { useBlockPatterns } from './pattern-selection';
|
|
15
16
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
16
17
|
export default function QueryPlaceholder({
|
|
17
18
|
attributes,
|
|
@@ -21,27 +22,20 @@ export default function QueryPlaceholder({
|
|
|
21
22
|
}) {
|
|
22
23
|
const [isStartingBlank, setIsStartingBlank] = useState(false);
|
|
23
24
|
const blockProps = useBlockProps();
|
|
24
|
-
const blockNameForPatterns = useBlockNameForPatterns(clientId, attributes);
|
|
25
25
|
const {
|
|
26
26
|
blockType,
|
|
27
|
-
activeBlockVariation
|
|
28
|
-
hasPatterns
|
|
27
|
+
activeBlockVariation
|
|
29
28
|
} = useSelect(select => {
|
|
30
29
|
const {
|
|
31
30
|
getActiveBlockVariation,
|
|
32
31
|
getBlockType
|
|
33
32
|
} = select(blocksStore);
|
|
34
|
-
const {
|
|
35
|
-
getBlockRootClientId,
|
|
36
|
-
getPatternsByBlockTypes
|
|
37
|
-
} = select(blockEditorStore);
|
|
38
|
-
const rootClientId = getBlockRootClientId(clientId);
|
|
39
33
|
return {
|
|
40
34
|
blockType: getBlockType(name),
|
|
41
|
-
activeBlockVariation: getActiveBlockVariation(name, attributes)
|
|
42
|
-
hasPatterns: !!getPatternsByBlockTypes(blockNameForPatterns, rootClientId).length
|
|
35
|
+
activeBlockVariation: getActiveBlockVariation(name, attributes)
|
|
43
36
|
};
|
|
44
|
-
}, [name,
|
|
37
|
+
}, [name, attributes]);
|
|
38
|
+
const hasPatterns = !!useBlockPatterns(clientId, attributes).length;
|
|
45
39
|
const icon = activeBlockVariation?.icon?.src || activeBlockVariation?.icon || blockType?.icon?.src;
|
|
46
40
|
const label = activeBlockVariation?.title || blockType?.title;
|
|
47
41
|
if (isStartingBlank) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useSelect","useDispatch","createBlocksFromInnerBlocksTemplate","store","blocksStore","useState","useBlockProps","blockEditorStore","__experimentalBlockVariationPicker","Button","Placeholder","__","useScopedBlockVariations","
|
|
1
|
+
{"version":3,"names":["useSelect","useDispatch","createBlocksFromInnerBlocksTemplate","store","blocksStore","useState","useBlockProps","blockEditorStore","__experimentalBlockVariationPicker","Button","Placeholder","__","useScopedBlockVariations","useBlockPatterns","jsx","_jsx","jsxs","_jsxs","QueryPlaceholder","attributes","clientId","name","openPatternSelectionModal","isStartingBlank","setIsStartingBlank","blockProps","blockType","activeBlockVariation","select","getActiveBlockVariation","getBlockType","hasPatterns","length","icon","src","label","title","QueryVariationPicker","children","instructions","__next40pxDefaultSize","variant","onClick","scopeVariations","replaceInnerBlocks","variations","onSelect","variation","innerBlocks"],"sources":["@wordpress/block-library/src/query/edit/query-placeholder.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tcreateBlocksFromInnerBlocksTemplate,\n\tstore as blocksStore,\n} from '@wordpress/blocks';\nimport { useState } from '@wordpress/element';\nimport {\n\tuseBlockProps,\n\tstore as blockEditorStore,\n\t__experimentalBlockVariationPicker,\n} from '@wordpress/block-editor';\nimport { Button, Placeholder } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { useScopedBlockVariations } from '../utils';\nimport { useBlockPatterns } from './pattern-selection';\n\nexport default function QueryPlaceholder( {\n\tattributes,\n\tclientId,\n\tname,\n\topenPatternSelectionModal,\n} ) {\n\tconst [ isStartingBlank, setIsStartingBlank ] = useState( false );\n\tconst blockProps = useBlockProps();\n\tconst { blockType, activeBlockVariation } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getActiveBlockVariation, getBlockType } =\n\t\t\t\tselect( blocksStore );\n\t\t\treturn {\n\t\t\t\tblockType: getBlockType( name ),\n\t\t\t\tactiveBlockVariation: getActiveBlockVariation(\n\t\t\t\t\tname,\n\t\t\t\t\tattributes\n\t\t\t\t),\n\t\t\t};\n\t\t},\n\t\t[ name, attributes ]\n\t);\n\tconst hasPatterns = !! useBlockPatterns( clientId, attributes ).length;\n\tconst icon =\n\t\tactiveBlockVariation?.icon?.src ||\n\t\tactiveBlockVariation?.icon ||\n\t\tblockType?.icon?.src;\n\tconst label = activeBlockVariation?.title || blockType?.title;\n\tif ( isStartingBlank ) {\n\t\treturn (\n\t\t\t<QueryVariationPicker\n\t\t\t\tclientId={ clientId }\n\t\t\t\tattributes={ attributes }\n\t\t\t\ticon={ icon }\n\t\t\t\tlabel={ label }\n\t\t\t/>\n\t\t);\n\t}\n\treturn (\n\t\t<div { ...blockProps }>\n\t\t\t<Placeholder\n\t\t\t\ticon={ icon }\n\t\t\t\tlabel={ label }\n\t\t\t\tinstructions={ __(\n\t\t\t\t\t'Choose a pattern for the query loop or start blank.'\n\t\t\t\t) }\n\t\t\t>\n\t\t\t\t{ !! hasPatterns && (\n\t\t\t\t\t<Button\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\tonClick={ openPatternSelectionModal }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Choose' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t) }\n\n\t\t\t\t<Button\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\tsetIsStartingBlank( true );\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Start blank' ) }\n\t\t\t\t</Button>\n\t\t\t</Placeholder>\n\t\t</div>\n\t);\n}\n\nfunction QueryVariationPicker( { clientId, attributes, icon, label } ) {\n\tconst scopeVariations = useScopedBlockVariations( attributes );\n\tconst { replaceInnerBlocks } = useDispatch( blockEditorStore );\n\tconst blockProps = useBlockProps();\n\treturn (\n\t\t<div { ...blockProps }>\n\t\t\t<__experimentalBlockVariationPicker\n\t\t\t\ticon={ icon }\n\t\t\t\tlabel={ label }\n\t\t\t\tvariations={ scopeVariations }\n\t\t\t\tonSelect={ ( variation ) => {\n\t\t\t\t\tif ( variation.innerBlocks ) {\n\t\t\t\t\t\treplaceInnerBlocks(\n\t\t\t\t\t\t\tclientId,\n\t\t\t\t\t\t\tcreateBlocksFromInnerBlocksTemplate(\n\t\t\t\t\t\t\t\tvariation.innerBlocks\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tfalse\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t} }\n\t\t\t/>\n\t\t</div>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SACCC,mCAAmC,EACnCC,KAAK,IAAIC,WAAW,QACd,mBAAmB;AAC1B,SAASC,QAAQ,QAAQ,oBAAoB;AAC7C,SACCC,aAAa,EACbH,KAAK,IAAII,gBAAgB,EACzBC,kCAAkC,QAC5B,yBAAyB;AAChC,SAASC,MAAM,EAAEC,WAAW,QAAQ,uBAAuB;AAC3D,SAASC,EAAE,QAAQ,iBAAiB;;AAEpC;AACA;AACA;AACA,SAASC,wBAAwB,QAAQ,UAAU;AACnD,SAASC,gBAAgB,QAAQ,qBAAqB;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAEvD,eAAe,SAASC,gBAAgBA,CAAE;EACzCC,UAAU;EACVC,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N+B,qBAAqB;QACrBC,OAAO,EAAC,SAAS;QACjBC,OAAO,EAAGpB,yBAA2B;QAAAgB,QAAA,EAEnC3B,EAAE,CAAE,QAAS;MAAC,CACT,CACR,eAEDI,IAAA,CAACN,MAAM;QACN+B,qBAAqB;QACrBC,OAAO,EAAC,WAAW;QACnBC,OAAO,EAAGA,CAAA,KAAM;UACflB,kBAAkB,CAAE,IAAK,CAAC;QAC3B,CAAG;QAAAc,QAAA,EAED3B,EAAE,CAAE,aAAc;MAAC,CACd,CAAC;IAAA,CACG;EAAC,CACV,CAAC;AAER;AAEA,SAAS0B,oBAAoBA,CAAE;EAAEjB,QAAQ;EAAED,UAAU;EAAEc,IAAI;EAAEE;AAAM,CAAC,EAAG;EACtE,MAAMQ,eAAe,GAAG/B,wBAAwB,CAAEO,UAAW,CAAC;EAC9D,MAAM;IAAEyB;EAAmB,CAAC,GAAG3C,WAAW,CAAEM,gBAAiB,CAAC;EAC9D,MAAMkB,UAAU,GAAGnB,aAAa,CAAC,CAAC;EAClC,oBACCS,IAAA;IAAA,GAAUU,UAAU;IAAAa,QAAA,eACnBvB,IAAA,CAACP,kCAAkC;MAClCyB,IAAI,EAAGA,IAAM;MACbE,KAAK,EAAGA,KAAO;MACfU,UAAU,EAAGF,eAAiB;MAC9BG,QAAQ,EAAKC,SAAS,IAAM;QAC3B,IAAKA,SAAS,CAACC,WAAW,EAAG;UAC5BJ,kBAAkB,CACjBxB,QAAQ,EACRlB,mCAAmC,CAClC6C,SAAS,CAACC,WACX,CAAC,EACD,KACD,CAAC;QACF;MACD;IAAG,CACH;EAAC,CACE,CAAC;AAER","ignoreList":[]}
|
|
@@ -1,26 +1,44 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { ToolbarGroup, ToolbarButton } from '@wordpress/components';
|
|
4
|
+
import { ToolbarGroup, ToolbarButton, Dropdown, __experimentalDropdownContentWrapper as DropdownContentWrapper } from '@wordpress/components';
|
|
5
5
|
import { __ } from '@wordpress/i18n';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Internal dependencies
|
|
9
9
|
*/
|
|
10
|
-
import {
|
|
11
|
-
import { jsx as _jsx
|
|
10
|
+
import PatternSelection, { useBlockPatterns } from './pattern-selection';
|
|
11
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
12
|
export default function QueryToolbar({
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
clientId
|
|
13
|
+
clientId,
|
|
14
|
+
attributes
|
|
16
15
|
}) {
|
|
17
|
-
const hasPatterns =
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
16
|
+
const hasPatterns = useBlockPatterns(clientId, attributes).length;
|
|
17
|
+
if (!hasPatterns) {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
return /*#__PURE__*/_jsx(ToolbarGroup, {
|
|
21
|
+
className: "wp-block-template-part__block-control-group",
|
|
22
|
+
children: /*#__PURE__*/_jsx(DropdownContentWrapper, {
|
|
23
|
+
children: /*#__PURE__*/_jsx(Dropdown, {
|
|
24
|
+
contentClassName: "block-editor-block-settings-menu__popover",
|
|
25
|
+
focusOnMount: "firstElement",
|
|
26
|
+
expandOnMobile: true,
|
|
27
|
+
renderToggle: ({
|
|
28
|
+
isOpen,
|
|
29
|
+
onToggle
|
|
30
|
+
}) => /*#__PURE__*/_jsx(ToolbarButton, {
|
|
31
|
+
"aria-haspopup": "true",
|
|
32
|
+
"aria-expanded": isOpen,
|
|
33
|
+
onClick: onToggle,
|
|
34
|
+
children: __('Change design')
|
|
35
|
+
}),
|
|
36
|
+
renderContent: () => /*#__PURE__*/_jsx(PatternSelection, {
|
|
37
|
+
clientId: clientId,
|
|
38
|
+
attributes: attributes,
|
|
39
|
+
showSearch: false,
|
|
40
|
+
showTitlesAsTooltip: true
|
|
41
|
+
})
|
|
24
42
|
})
|
|
25
43
|
})
|
|
26
44
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ToolbarGroup","ToolbarButton","
|
|
1
|
+
{"version":3,"names":["ToolbarGroup","ToolbarButton","Dropdown","__experimentalDropdownContentWrapper","DropdownContentWrapper","__","PatternSelection","useBlockPatterns","jsx","_jsx","QueryToolbar","clientId","attributes","hasPatterns","length","className","children","contentClassName","focusOnMount","expandOnMobile","renderToggle","isOpen","onToggle","onClick","renderContent","showSearch","showTitlesAsTooltip"],"sources":["@wordpress/block-library/src/query/edit/query-toolbar.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tToolbarGroup,\n\tToolbarButton,\n\tDropdown,\n\t__experimentalDropdownContentWrapper as DropdownContentWrapper,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport PatternSelection, { useBlockPatterns } from './pattern-selection';\n\nexport default function QueryToolbar( { clientId, attributes } ) {\n\tconst hasPatterns = useBlockPatterns( clientId, attributes ).length;\n\tif ( ! hasPatterns ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<ToolbarGroup className=\"wp-block-template-part__block-control-group\">\n\t\t\t<DropdownContentWrapper>\n\t\t\t\t<Dropdown\n\t\t\t\t\tcontentClassName=\"block-editor-block-settings-menu__popover\"\n\t\t\t\t\tfocusOnMount=\"firstElement\"\n\t\t\t\t\texpandOnMobile\n\t\t\t\t\trenderToggle={ ( { isOpen, onToggle } ) => (\n\t\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\t\taria-haspopup=\"true\"\n\t\t\t\t\t\t\taria-expanded={ isOpen }\n\t\t\t\t\t\t\tonClick={ onToggle }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Change design' ) }\n\t\t\t\t\t\t</ToolbarButton>\n\t\t\t\t\t) }\n\t\t\t\t\trenderContent={ () => (\n\t\t\t\t\t\t<PatternSelection\n\t\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\t\tattributes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EAAC,CACZ,CAAC;AAEjB","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["clsx","getColorClassName","useBlockProps","jsx","_jsx","v1","attributes","color","type","customColor","save","backgroundClass","colorClass","className","style","backgroundColor","undefined","migrate","restAttributes","opacity","background"],"sources":["@wordpress/block-library/src/separator/deprecated.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { getColorClassName, useBlockProps } from '@wordpress/block-editor';\n\nconst v1 = {\n\tattributes: {\n\t\tcolor: {\n\t\t\ttype: 'string',\n\t\t},\n\t\tcustomColor: {\n\t\t\ttype: 'string',\n\t\t},\n\t},\n\tsave( { attributes } ) {\n\t\tconst { color, customColor } = attributes;\n\n\t\t// the hr support changing color using border-color, since border-color\n\t\t// is not yet supported in the color palette, we use background-color\n\t\tconst backgroundClass = getColorClassName( 'background-color', color );\n\t\t// the dots styles uses text for the dots, to change those dots color is\n\t\t// using color, not backgroundColor\n\t\tconst colorClass = getColorClassName( 'color', color );\n\n\t\tconst className = clsx( {\n\t\t\t'has-text-color has-background': color || customColor,\n\t\t\t[ backgroundClass ]: backgroundClass,\n\t\t\t[ colorClass ]: colorClass,\n\t\t} );\n\n\t\tconst style = {\n\t\t\tbackgroundColor: backgroundClass ? undefined : customColor,\n\t\t\tcolor: colorClass ? undefined : customColor,\n\t\t};\n\n\t\treturn <hr { ...useBlockProps.save( { className, style } ) } />;\n\t},\n\tmigrate( attributes ) {\n\t\tconst { color, customColor, ...restAttributes } = attributes;\n\t\treturn {\n\t\t\t...restAttributes,\n\t\t\tbackgroundColor: color ? color : undefined,\n\t\t\topacity: 'css',\n\t\t\tstyle: customColor\n\t\t\t\t? { color: { background: customColor } }\n\t\t\t\t: undefined,\n\t\t};\n\t},\n};\n\nexport default [ v1 ];\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,IAAI,MAAM,MAAM;;AAEvB;AACA;AACA;AACA,SAASC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","getColorClassName","useBlockProps","jsx","_jsx","v1","attributes","color","type","customColor","save","backgroundClass","colorClass","className","style","backgroundColor","undefined","migrate","restAttributes","opacity","background","tagName"],"sources":["@wordpress/block-library/src/separator/deprecated.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { getColorClassName, useBlockProps } from '@wordpress/block-editor';\n\nconst v1 = {\n\tattributes: {\n\t\tcolor: {\n\t\t\ttype: 'string',\n\t\t},\n\t\tcustomColor: {\n\t\t\ttype: 'string',\n\t\t},\n\t},\n\tsave( { attributes } ) {\n\t\tconst { color, customColor } = attributes;\n\n\t\t// the hr support changing color using border-color, since border-color\n\t\t// is not yet supported in the color palette, we use background-color\n\t\tconst backgroundClass = getColorClassName( 'background-color', color );\n\t\t// the dots styles uses text for the dots, to change those dots color is\n\t\t// using color, not backgroundColor\n\t\tconst colorClass = getColorClassName( 'color', color );\n\n\t\tconst className = clsx( {\n\t\t\t'has-text-color has-background': color || customColor,\n\t\t\t[ backgroundClass ]: backgroundClass,\n\t\t\t[ colorClass ]: colorClass,\n\t\t} );\n\n\t\tconst style = {\n\t\t\tbackgroundColor: backgroundClass ? undefined : customColor,\n\t\t\tcolor: colorClass ? undefined : customColor,\n\t\t};\n\n\t\treturn <hr { ...useBlockProps.save( { className, style } ) } />;\n\t},\n\tmigrate( attributes ) {\n\t\tconst { color, customColor, ...restAttributes } = attributes;\n\t\treturn {\n\t\t\t...restAttributes,\n\t\t\tbackgroundColor: color ? color : undefined,\n\t\t\topacity: 'css',\n\t\t\tstyle: customColor\n\t\t\t\t? { color: { background: customColor } }\n\t\t\t\t: undefined,\n\t\t\ttagName: 'hr',\n\t\t};\n\t},\n};\n\nexport default [ v1 ];\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,IAAI,MAAM,MAAM;;AAEvB;AACA;AACA;AACA,SAASC,iBAAiB,EAAEC,aAAa,QAAQ,yBAAyB;AAAC,SAAAC,GAAA,IAA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]}
|
|
@@ -6,14 +6,18 @@ import clsx from 'clsx';
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
|
-
import { HorizontalRule } from '@wordpress/components';
|
|
10
|
-
import { useBlockProps, getColorClassName, __experimentalUseColorProps as useColorProps } from '@wordpress/block-editor';
|
|
9
|
+
import { HorizontalRule, SelectControl } from '@wordpress/components';
|
|
10
|
+
import { useBlockProps, getColorClassName, __experimentalUseColorProps as useColorProps, InspectorControls } from '@wordpress/block-editor';
|
|
11
|
+
import { __ } from '@wordpress/i18n';
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
14
|
* Internal dependencies
|
|
14
15
|
*/
|
|
15
16
|
import useDeprecatedOpacity from './use-deprecated-opacity';
|
|
16
|
-
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
17
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
18
|
+
const htmlElementMessages = {
|
|
19
|
+
div: __('The <div> element should only be used if the separator is a design element that should not be announced.')
|
|
20
|
+
};
|
|
17
21
|
export default function SeparatorEdit({
|
|
18
22
|
attributes,
|
|
19
23
|
setAttributes
|
|
@@ -21,7 +25,8 @@ export default function SeparatorEdit({
|
|
|
21
25
|
const {
|
|
22
26
|
backgroundColor,
|
|
23
27
|
opacity,
|
|
24
|
-
style
|
|
28
|
+
style,
|
|
29
|
+
tagName
|
|
25
30
|
} = attributes;
|
|
26
31
|
const colorProps = useColorProps(attributes);
|
|
27
32
|
const currentColor = colorProps?.style?.backgroundColor;
|
|
@@ -41,13 +46,33 @@ export default function SeparatorEdit({
|
|
|
41
46
|
color: currentColor,
|
|
42
47
|
backgroundColor: currentColor
|
|
43
48
|
};
|
|
44
|
-
|
|
45
|
-
|
|
49
|
+
const Wrapper = tagName === 'hr' ? HorizontalRule : tagName;
|
|
50
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
51
|
+
children: [/*#__PURE__*/_jsx(InspectorControls, {
|
|
52
|
+
group: "advanced",
|
|
53
|
+
children: /*#__PURE__*/_jsx(SelectControl, {
|
|
54
|
+
__nextHasNoMarginBottom: true,
|
|
55
|
+
__next40pxDefaultSize: true,
|
|
56
|
+
label: __('HTML element'),
|
|
57
|
+
options: [{
|
|
58
|
+
label: __('Default (<hr>)'),
|
|
59
|
+
value: 'hr'
|
|
60
|
+
}, {
|
|
61
|
+
label: '<div>',
|
|
62
|
+
value: 'div'
|
|
63
|
+
}],
|
|
64
|
+
value: tagName,
|
|
65
|
+
onChange: value => setAttributes({
|
|
66
|
+
tagName: value
|
|
67
|
+
}),
|
|
68
|
+
help: htmlElementMessages[tagName]
|
|
69
|
+
})
|
|
70
|
+
}), /*#__PURE__*/_jsx(Wrapper, {
|
|
46
71
|
...useBlockProps({
|
|
47
72
|
className,
|
|
48
73
|
style: hasCustomColor ? styles : undefined
|
|
49
74
|
})
|
|
50
|
-
})
|
|
75
|
+
})]
|
|
51
76
|
});
|
|
52
77
|
}
|
|
53
78
|
//# sourceMappingURL=edit.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["clsx","HorizontalRule","useBlockProps","getColorClassName","__experimentalUseColorProps","useColorProps","useDeprecatedOpacity","jsx","_jsx","Fragment","_Fragment","SeparatorEdit","attributes","setAttributes","backgroundColor","opacity","style","colorProps","currentColor","hasCustomColor","color","background","colorClass","className","styles","children","undefined"],"sources":["@wordpress/block-library/src/separator/edit.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { HorizontalRule } from '@wordpress/components';\nimport {\n\tuseBlockProps,\n\tgetColorClassName,\n\t__experimentalUseColorProps as useColorProps,\n} from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport useDeprecatedOpacity from './use-deprecated-opacity';\n\nexport default function SeparatorEdit( { attributes, setAttributes } ) {\n\tconst { backgroundColor, opacity, style } = attributes;\n\tconst colorProps = useColorProps( attributes );\n\tconst currentColor = colorProps?.style?.backgroundColor;\n\tconst hasCustomColor = !! style?.color?.background;\n\n\tuseDeprecatedOpacity( opacity, currentColor, setAttributes );\n\n\t// The dots styles uses text for the dots, to change those dots color is\n\t// using color, not backgroundColor.\n\tconst colorClass = getColorClassName( 'color', backgroundColor );\n\n\tconst className = clsx(\n\t\t{\n\t\t\t'has-text-color': backgroundColor || currentColor,\n\t\t\t[ colorClass ]: colorClass,\n\t\t\t'has-css-opacity': opacity === 'css',\n\t\t\t'has-alpha-channel-opacity': opacity === 'alpha-channel',\n\t\t},\n\t\tcolorProps.className\n\t);\n\n\tconst styles = {\n\t\tcolor: currentColor,\n\t\tbackgroundColor: currentColor,\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t<
|
|
1
|
+
{"version":3,"names":["clsx","HorizontalRule","SelectControl","useBlockProps","getColorClassName","__experimentalUseColorProps","useColorProps","InspectorControls","__","useDeprecatedOpacity","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","htmlElementMessages","div","SeparatorEdit","attributes","setAttributes","backgroundColor","opacity","style","tagName","colorProps","currentColor","hasCustomColor","color","background","colorClass","className","styles","Wrapper","children","group","__nextHasNoMarginBottom","__next40pxDefaultSize","label","options","value","onChange","help","undefined"],"sources":["@wordpress/block-library/src/separator/edit.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { HorizontalRule, SelectControl } from '@wordpress/components';\nimport {\n\tuseBlockProps,\n\tgetColorClassName,\n\t__experimentalUseColorProps as useColorProps,\n\tInspectorControls,\n} from '@wordpress/block-editor';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport useDeprecatedOpacity from './use-deprecated-opacity';\n\nconst htmlElementMessages = {\n\tdiv: __(\n\t\t'The <div> element should only be used if the separator is a design element that should not be announced.'\n\t),\n};\n\nexport default function SeparatorEdit( { attributes, setAttributes } ) {\n\tconst { backgroundColor, opacity, style, tagName } = attributes;\n\tconst colorProps = useColorProps( attributes );\n\tconst currentColor = colorProps?.style?.backgroundColor;\n\tconst hasCustomColor = !! style?.color?.background;\n\n\tuseDeprecatedOpacity( opacity, currentColor, setAttributes );\n\n\t// The dots styles uses text for the dots, to change those dots color is\n\t// using color, not backgroundColor.\n\tconst colorClass = getColorClassName( 'color', backgroundColor );\n\n\tconst className = clsx(\n\t\t{\n\t\t\t'has-text-color': backgroundColor || currentColor,\n\t\t\t[ colorClass ]: colorClass,\n\t\t\t'has-css-opacity': opacity === 'css',\n\t\t\t'has-alpha-channel-opacity': opacity === 'alpha-channel',\n\t\t},\n\t\tcolorProps.className\n\t);\n\n\tconst styles = {\n\t\tcolor: currentColor,\n\t\tbackgroundColor: currentColor,\n\t};\n\tconst Wrapper = tagName === 'hr' ? HorizontalRule : tagName;\n\n\treturn (\n\t\t<>\n\t\t\t<InspectorControls group=\"advanced\">\n\t\t\t\t<SelectControl\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\tlabel={ __( 'HTML element' ) }\n\t\t\t\t\toptions={ [\n\t\t\t\t\t\t{ label: __( 'Default (<hr>)' ), value: 'hr' },\n\t\t\t\t\t\t{ label: '<div>', value: 'div' },\n\t\t\t\t\t] }\n\t\t\t\t\tvalue={ tagName }\n\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\tsetAttributes( { tagName: value } )\n\t\t\t\t\t}\n\t\t\t\t\thelp={ htmlElementMessages[ tagName ] }\n\t\t\t\t/>\n\t\t\t</InspectorControls>\n\t\t\t<Wrapper\n\t\t\t\t{ ...useBlockProps( {\n\t\t\t\t\tclassName,\n\t\t\t\t\tstyle: hasCustomColor ? styles : undefined,\n\t\t\t\t} ) }\n\t\t\t/>\n\t\t</>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,IAAI,MAAM,MAAM;;AAEvB;AACA;AACA;AACA,SAASC,cAAc,EAAEC,aAAa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