@wordpress/edit-site 6.31.0 → 6.31.1-next.f56bd8138.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/build/components/add-new-template/add-custom-template-modal-content.js +2 -1
- package/build/components/add-new-template/add-custom-template-modal-content.js.map +1 -1
- package/build/components/add-new-template/utils.js +18 -3
- package/build/components/add-new-template/utils.js.map +1 -1
- package/build/components/global-styles/screen-css.js +2 -3
- package/build/components/global-styles/screen-css.js.map +1 -1
- package/build/components/global-styles/screen-root.js +3 -35
- package/build/components/global-styles/screen-root.js.map +1 -1
- package/build/components/sidebar-global-styles-wrapper/index.js +45 -13
- package/build/components/sidebar-global-styles-wrapper/index.js.map +1 -1
- package/build-module/components/add-new-template/add-custom-template-modal-content.js +2 -1
- package/build-module/components/add-new-template/add-custom-template-modal-content.js.map +1 -1
- package/build-module/components/add-new-template/utils.js +18 -3
- package/build-module/components/add-new-template/utils.js.map +1 -1
- package/build-module/components/global-styles/screen-css.js +2 -3
- package/build-module/components/global-styles/screen-css.js.map +1 -1
- package/build-module/components/global-styles/screen-root.js +4 -36
- package/build-module/components/global-styles/screen-root.js.map +1 -1
- package/build-module/components/sidebar-global-styles-wrapper/index.js +48 -16
- package/build-module/components/sidebar-global-styles-wrapper/index.js.map +1 -1
- package/package.json +41 -41
- package/src/components/add-new-template/add-custom-template-modal-content.js +2 -1
- package/src/components/add-new-template/utils.js +27 -3
- package/src/components/global-styles/screen-css.js +4 -5
- package/src/components/global-styles/screen-root.js +5 -51
- package/src/components/sidebar-global-styles-wrapper/index.js +62 -16
|
@@ -11,6 +11,7 @@ var _coreData = require("@wordpress/core-data");
|
|
|
11
11
|
var _htmlEntities = require("@wordpress/html-entities");
|
|
12
12
|
var _compose = require("@wordpress/compose");
|
|
13
13
|
var _dom = require("@wordpress/dom");
|
|
14
|
+
var _url = require("@wordpress/url");
|
|
14
15
|
var _utils = require("./utils");
|
|
15
16
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
16
17
|
/**
|
|
@@ -51,7 +52,7 @@ function SuggestionListItem({
|
|
|
51
52
|
lineHeight: 1.53846153846 // 20px
|
|
52
53
|
,
|
|
53
54
|
className: `${baseCssClass}__info`,
|
|
54
|
-
children: suggestion.link
|
|
55
|
+
children: (0, _url.safeDecodeURI)(suggestion.link)
|
|
55
56
|
})]
|
|
56
57
|
});
|
|
57
58
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_element","require","_i18n","_components","_coreData","_htmlEntities","_compose","_dom","_utils","_jsxRuntime","EMPTY_ARRAY","SuggestionListItem","suggestion","search","onSelect","entityForSuggestions","baseCssClass","jsxs","Composite","Item","render","jsx","Button","__next40pxDefaultSize","role","className","onClick","config","getSpecificTemplate","children","__experimentalText","size","lineHeight","weight","TextHighlight","text","decodeEntities","name","highlight","link","useSearchSuggestions","query","useMemo","order","context","per_page","queryArgs","records","searchResults","hasResolved","searchHasResolved","useEntityRecords","type","slug","suggestions","setSuggestions","useState","useEffect","newSuggestions","length","recordNamePath","mapToIHasNameAndId","SuggestionList","setSearch","debouncedSearch","useDebouncedInput","labels","showSearchControl","setShowSearchControl","Fragment","SearchControl","__nextHasNoMarginBottom","onChange","value","label","search_items","placeholder","orientation","__","map","as","not_found","AddCustomTemplateModalContent","onBack","containerRef","showSearchEntities","setShowSearchEntities","current","firstFocusable","focus","focusable","find","__experimentalVStack","spacing","alignment","Flex","gap","align","FlexItem","isBlock","title","description","templatePrefix","template","all_items","singular_name","justify","variant","hasGeneralTemplate","_default","exports","default"],"sources":["@wordpress/edit-site/src/components/add-new-template/add-custom-template-modal-content.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useState, useMemo, useEffect } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tButton,\n\tFlex,\n\tFlexItem,\n\tSearchControl,\n\tTextHighlight,\n\tComposite,\n\t__experimentalText as Text,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { useEntityRecords } from '@wordpress/core-data';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { useDebouncedInput } from '@wordpress/compose';\nimport { focus } from '@wordpress/dom';\n\n/**\n * Internal dependencies\n */\nimport { mapToIHasNameAndId } from './utils';\n\nconst EMPTY_ARRAY = [];\n\nfunction SuggestionListItem( {\n\tsuggestion,\n\tsearch,\n\tonSelect,\n\tentityForSuggestions,\n} ) {\n\tconst baseCssClass =\n\t\t'edit-site-custom-template-modal__suggestions_list__list-item';\n\treturn (\n\t\t<Composite.Item\n\t\t\trender={\n\t\t\t\t<Button\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\trole=\"option\"\n\t\t\t\t\tclassName={ baseCssClass }\n\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\tonSelect(\n\t\t\t\t\t\t\tentityForSuggestions.config.getSpecificTemplate(\n\t\t\t\t\t\t\t\tsuggestion\n\t\t\t\t\t\t\t)\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>\n\t\t\t<Text\n\t\t\t\tsize=\"body\"\n\t\t\t\tlineHeight={ 1.53846153846 } // 20px\n\t\t\t\tweight={ 500 }\n\t\t\t\tclassName={ `${ baseCssClass }__title` }\n\t\t\t>\n\t\t\t\t<TextHighlight\n\t\t\t\t\ttext={ decodeEntities( suggestion.name ) }\n\t\t\t\t\thighlight={ search }\n\t\t\t\t/>\n\t\t\t</Text>\n\t\t\t{ suggestion.link && (\n\t\t\t\t<Text\n\t\t\t\t\tsize=\"body\"\n\t\t\t\t\tlineHeight={ 1.53846153846 } // 20px\n\t\t\t\t\tclassName={ `${ baseCssClass }__info` }\n\t\t\t\t>\n\t\t\t\t\t{ suggestion.link }\n\t\t\t\t</Text>\n\t\t\t) }\n\t\t</Composite.Item>\n\t);\n}\n\nfunction useSearchSuggestions( entityForSuggestions, search ) {\n\tconst { config } = entityForSuggestions;\n\tconst query = useMemo(\n\t\t() => ( {\n\t\t\torder: 'asc',\n\t\t\tcontext: 'view',\n\t\t\tsearch,\n\t\t\tper_page: search ? 20 : 10,\n\t\t\t...config.queryArgs( search ),\n\t\t} ),\n\t\t[ search, config ]\n\t);\n\tconst { records: searchResults, hasResolved: searchHasResolved } =\n\t\tuseEntityRecords(\n\t\t\tentityForSuggestions.type,\n\t\t\tentityForSuggestions.slug,\n\t\t\tquery\n\t\t);\n\tconst [ suggestions, setSuggestions ] = useState( EMPTY_ARRAY );\n\tuseEffect( () => {\n\t\tif ( ! searchHasResolved ) {\n\t\t\treturn;\n\t\t}\n\t\tlet newSuggestions = EMPTY_ARRAY;\n\t\tif ( searchResults?.length ) {\n\t\t\tnewSuggestions = searchResults;\n\t\t\tif ( config.recordNamePath ) {\n\t\t\t\tnewSuggestions = mapToIHasNameAndId(\n\t\t\t\t\tnewSuggestions,\n\t\t\t\t\tconfig.recordNamePath\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\t// Update suggestions only when the query has resolved, so as to keep\n\t\t// the previous results in the UI.\n\t\tsetSuggestions( newSuggestions );\n\t}, [ searchResults, searchHasResolved ] );\n\treturn suggestions;\n}\n\nfunction SuggestionList( { entityForSuggestions, onSelect } ) {\n\tconst [ search, setSearch, debouncedSearch ] = useDebouncedInput();\n\tconst suggestions = useSearchSuggestions(\n\t\tentityForSuggestions,\n\t\tdebouncedSearch\n\t);\n\tconst { labels } = entityForSuggestions;\n\tconst [ showSearchControl, setShowSearchControl ] = useState( false );\n\tif ( ! showSearchControl && suggestions?.length > 9 ) {\n\t\tsetShowSearchControl( true );\n\t}\n\treturn (\n\t\t<>\n\t\t\t{ showSearchControl && (\n\t\t\t\t<SearchControl\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\tonChange={ setSearch }\n\t\t\t\t\tvalue={ search }\n\t\t\t\t\tlabel={ labels.search_items }\n\t\t\t\t\tplaceholder={ labels.search_items }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ !! suggestions?.length && (\n\t\t\t\t<Composite\n\t\t\t\t\torientation=\"vertical\"\n\t\t\t\t\trole=\"listbox\"\n\t\t\t\t\tclassName=\"edit-site-custom-template-modal__suggestions_list\"\n\t\t\t\t\taria-label={ __( 'Suggestions list' ) }\n\t\t\t\t>\n\t\t\t\t\t{ suggestions.map( ( suggestion ) => (\n\t\t\t\t\t\t<SuggestionListItem\n\t\t\t\t\t\t\tkey={ suggestion.slug }\n\t\t\t\t\t\t\tsuggestion={ suggestion }\n\t\t\t\t\t\t\tsearch={ debouncedSearch }\n\t\t\t\t\t\t\tonSelect={ onSelect }\n\t\t\t\t\t\t\tentityForSuggestions={ entityForSuggestions }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) ) }\n\t\t\t\t</Composite>\n\t\t\t) }\n\t\t\t{ debouncedSearch && ! suggestions?.length && (\n\t\t\t\t<Text\n\t\t\t\t\tas=\"p\"\n\t\t\t\t\tclassName=\"edit-site-custom-template-modal__no-results\"\n\t\t\t\t>\n\t\t\t\t\t{ labels.not_found }\n\t\t\t\t</Text>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nfunction AddCustomTemplateModalContent( {\n\tonSelect,\n\tentityForSuggestions,\n\tonBack,\n\tcontainerRef,\n} ) {\n\tconst [ showSearchEntities, setShowSearchEntities ] = useState();\n\n\t// Focus on the first focusable element when the modal opens.\n\t// We handle focus management in the parent modal, just need to focus on the first focusable element.\n\tuseEffect( () => {\n\t\tif ( containerRef.current ) {\n\t\t\tconst [ firstFocusable ] = focus.focusable.find(\n\t\t\t\tcontainerRef.current\n\t\t\t);\n\t\t\tfirstFocusable?.focus();\n\t\t}\n\t}, [ showSearchEntities ] );\n\n\treturn (\n\t\t<VStack\n\t\t\tspacing={ 4 }\n\t\t\tclassName=\"edit-site-custom-template-modal__contents-wrapper\"\n\t\t\talignment=\"left\"\n\t\t>\n\t\t\t{ ! showSearchEntities && (\n\t\t\t\t<>\n\t\t\t\t\t<Text as=\"p\">\n\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t'Select whether to create a single template for all items or a specific one.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t</Text>\n\t\t\t\t\t<Flex\n\t\t\t\t\t\tclassName=\"edit-site-custom-template-modal__contents\"\n\t\t\t\t\t\tgap=\"4\"\n\t\t\t\t\t\talign=\"initial\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<FlexItem\n\t\t\t\t\t\t\tisBlock\n\t\t\t\t\t\t\tas={ Button }\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\tconst {\n\t\t\t\t\t\t\t\t\tslug,\n\t\t\t\t\t\t\t\t\ttitle,\n\t\t\t\t\t\t\t\t\tdescription,\n\t\t\t\t\t\t\t\t\ttemplatePrefix,\n\t\t\t\t\t\t\t\t} = entityForSuggestions.template;\n\t\t\t\t\t\t\t\tonSelect( {\n\t\t\t\t\t\t\t\t\tslug,\n\t\t\t\t\t\t\t\t\ttitle,\n\t\t\t\t\t\t\t\t\tdescription,\n\t\t\t\t\t\t\t\t\ttemplatePrefix,\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<Text\n\t\t\t\t\t\t\t\tas=\"span\"\n\t\t\t\t\t\t\t\tweight={ 500 }\n\t\t\t\t\t\t\t\tlineHeight={ 1.53846153846 } // 20px\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ entityForSuggestions.labels.all_items }\n\t\t\t\t\t\t\t</Text>\n\t\t\t\t\t\t\t<Text\n\t\t\t\t\t\t\t\tas=\"span\"\n\t\t\t\t\t\t\t\tlineHeight={ 1.53846153846 } // 20px\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t// translators: The user is given the choice to set up a template for all items of a post type or taxonomy, or just a specific one.\n\t\t\t\t\t\t\t\t\t__( 'For all items' )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t</Text>\n\t\t\t\t\t\t</FlexItem>\n\t\t\t\t\t\t<FlexItem\n\t\t\t\t\t\t\tisBlock\n\t\t\t\t\t\t\tas={ Button }\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\tsetShowSearchEntities( true );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<Text\n\t\t\t\t\t\t\t\tas=\"span\"\n\t\t\t\t\t\t\t\tweight={ 500 }\n\t\t\t\t\t\t\t\tlineHeight={ 1.53846153846 } // 20px\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ entityForSuggestions.labels.singular_name }\n\t\t\t\t\t\t\t</Text>\n\t\t\t\t\t\t\t<Text\n\t\t\t\t\t\t\t\tas=\"span\"\n\t\t\t\t\t\t\t\tlineHeight={ 1.53846153846 } // 20px\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t// translators: The user is given the choice to set up a template for all items of a post type or taxonomy, or just a specific one.\n\t\t\t\t\t\t\t\t\t__( 'For a specific item' )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t</Text>\n\t\t\t\t\t\t</FlexItem>\n\t\t\t\t\t</Flex>\n\t\t\t\t\t<Flex justify=\"right\">\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\tonClick={ onBack }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Back' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</Flex>\n\t\t\t\t</>\n\t\t\t) }\n\t\t\t{ showSearchEntities && (\n\t\t\t\t<>\n\t\t\t\t\t<Text as=\"p\">\n\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t'This template will be used only for the specific item chosen.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t</Text>\n\t\t\t\t\t<SuggestionList\n\t\t\t\t\t\tentityForSuggestions={ entityForSuggestions }\n\t\t\t\t\t\tonSelect={ onSelect }\n\t\t\t\t\t/>\n\t\t\t\t\t<Flex justify=\"right\">\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t// If general template exists, go directly back to main screen\n\t\t\t\t\t\t\t\t// instead of showing the choice screen\n\t\t\t\t\t\t\t\tif ( entityForSuggestions.hasGeneralTemplate ) {\n\t\t\t\t\t\t\t\t\tonBack();\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tsetShowSearchEntities( false );\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Back' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</Flex>\n\t\t\t\t</>\n\t\t\t) }\n\t\t</VStack>\n\t);\n}\n\nexport default AddCustomTemplateModalContent;\n"],"mappings":";;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AAUA,IAAAG,SAAA,GAAAH,OAAA;AACA,IAAAI,aAAA,GAAAJ,OAAA;AACA,IAAAK,QAAA,GAAAL,OAAA;AACA,IAAAM,IAAA,GAAAN,OAAA;AAKA,IAAAO,MAAA,GAAAP,OAAA;AAA6C,IAAAQ,WAAA,GAAAR,OAAA;AAvB7C;AACA;AACA;;AAkBA;AACA;AACA;;AAGA,MAAMS,WAAW,GAAG,EAAE;AAEtB,SAASC,kBAAkBA,CAAE;EAC5BC,UAAU;EACVC,MAAM;EACNC,QAAQ;EACRC;AACD,CAAC,EAAG;EACH,MAAMC,YAAY,GACjB,8DAA8D;EAC/D,oBACC,IAAAP,WAAA,CAAAQ,IAAA,EAACd,WAAA,CAAAe,SAAS,CAACC,IAAI;IACdC,MAAM,eACL,IAAAX,WAAA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UAAAtD,QAAA,EAEhB,IAAAiD,QAAE,EAAE,MAAO;QAAC,CACP;MAAC,CACJ,CAAC;IAAA,CACN,CACF,EACCO,kBAAkB,iBACnB,IAAA5E,WAAA,CAAAQ,IAAA,EAAAR,WAAA,CAAA4D,QAAA;MAAAxC,QAAA,gBACC,IAAApB,WAAA,CAAAY,GAAA,EAAClB,WAAA,CAAA2B,kBAAI;QAACkD,EAAE,EAAC,GAAG;QAAAnD,QAAA,EACT,IAAAiD,QAAE,EACH,+DACD;MAAC,CACI,CAAC,eACP,IAAArE,WAAA,CAAAY,GAAA,EAACyC,cAAc;QACd/C,oBAAoB,EAAGA,oBAAsB;QAC7CD,QAAQ,EAAGA;MAAU,CACrB,CAAC,eACF,IAAAL,WAAA,CAAAY,GAAA,EAAClB,WAAA,CAAA4F,IAAI;QAACW,OAAO,EAAC,OAAO;QAAA7E,QAAA,eACpB,IAAApB,WAAA,CAAAY,GAAA,EAAClB,WAAA,CAAAmB,MAAM;UACNC,qBAAqB;UACrBoF,OAAO,EAAC,UAAU;UAClBjF,OAAO,EAAGA,CAAA,KAAM;YACf;YACA;YACA,IAAKX,oBAAoB,CAAC6F,kBAAkB,EAAG;cAC9CzB,MAAM,CAAC,CAAC;YACT,CAAC,MAAM;cACNG,qBAAqB,CAAE,KAAM,CAAC;YAC/B;UACD,CAAG;UAAAzD,QAAA,EAED,IAAAiD,QAAE,EAAE,MAAO;QAAC,CACP;MAAC,CACJ,CAAC;IAAA,CACN,CACF;EAAA,CACM,CAAC;AAEX;AAAC,IAAA+B,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEc7B,6BAA6B","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_element","require","_i18n","_components","_coreData","_htmlEntities","_compose","_dom","_url","_utils","_jsxRuntime","EMPTY_ARRAY","SuggestionListItem","suggestion","search","onSelect","entityForSuggestions","baseCssClass","jsxs","Composite","Item","render","jsx","Button","__next40pxDefaultSize","role","className","onClick","config","getSpecificTemplate","children","__experimentalText","size","lineHeight","weight","TextHighlight","text","decodeEntities","name","highlight","link","safeDecodeURI","useSearchSuggestions","query","useMemo","order","context","per_page","queryArgs","records","searchResults","hasResolved","searchHasResolved","useEntityRecords","type","slug","suggestions","setSuggestions","useState","useEffect","newSuggestions","length","recordNamePath","mapToIHasNameAndId","SuggestionList","setSearch","debouncedSearch","useDebouncedInput","labels","showSearchControl","setShowSearchControl","Fragment","SearchControl","__nextHasNoMarginBottom","onChange","value","label","search_items","placeholder","orientation","__","map","as","not_found","AddCustomTemplateModalContent","onBack","containerRef","showSearchEntities","setShowSearchEntities","current","firstFocusable","focus","focusable","find","__experimentalVStack","spacing","alignment","Flex","gap","align","FlexItem","isBlock","title","description","templatePrefix","template","all_items","singular_name","justify","variant","hasGeneralTemplate","_default","exports","default"],"sources":["@wordpress/edit-site/src/components/add-new-template/add-custom-template-modal-content.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useState, useMemo, useEffect } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tButton,\n\tFlex,\n\tFlexItem,\n\tSearchControl,\n\tTextHighlight,\n\tComposite,\n\t__experimentalText as Text,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { useEntityRecords } from '@wordpress/core-data';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { useDebouncedInput } from '@wordpress/compose';\nimport { focus } from '@wordpress/dom';\nimport { safeDecodeURI } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport { mapToIHasNameAndId } from './utils';\n\nconst EMPTY_ARRAY = [];\n\nfunction SuggestionListItem( {\n\tsuggestion,\n\tsearch,\n\tonSelect,\n\tentityForSuggestions,\n} ) {\n\tconst baseCssClass =\n\t\t'edit-site-custom-template-modal__suggestions_list__list-item';\n\treturn (\n\t\t<Composite.Item\n\t\t\trender={\n\t\t\t\t<Button\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\trole=\"option\"\n\t\t\t\t\tclassName={ baseCssClass }\n\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\tonSelect(\n\t\t\t\t\t\t\tentityForSuggestions.config.getSpecificTemplate(\n\t\t\t\t\t\t\t\tsuggestion\n\t\t\t\t\t\t\t)\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>\n\t\t\t<Text\n\t\t\t\tsize=\"body\"\n\t\t\t\tlineHeight={ 1.53846153846 } // 20px\n\t\t\t\tweight={ 500 }\n\t\t\t\tclassName={ `${ baseCssClass }__title` }\n\t\t\t>\n\t\t\t\t<TextHighlight\n\t\t\t\t\ttext={ decodeEntities( suggestion.name ) }\n\t\t\t\t\thighlight={ search }\n\t\t\t\t/>\n\t\t\t</Text>\n\t\t\t{ suggestion.link && (\n\t\t\t\t<Text\n\t\t\t\t\tsize=\"body\"\n\t\t\t\t\tlineHeight={ 1.53846153846 } // 20px\n\t\t\t\t\tclassName={ `${ baseCssClass }__info` }\n\t\t\t\t>\n\t\t\t\t\t{ safeDecodeURI( suggestion.link ) }\n\t\t\t\t</Text>\n\t\t\t) }\n\t\t</Composite.Item>\n\t);\n}\n\nfunction useSearchSuggestions( entityForSuggestions, search ) {\n\tconst { config } = entityForSuggestions;\n\tconst query = useMemo(\n\t\t() => ( {\n\t\t\torder: 'asc',\n\t\t\tcontext: 'view',\n\t\t\tsearch,\n\t\t\tper_page: search ? 20 : 10,\n\t\t\t...config.queryArgs( search ),\n\t\t} ),\n\t\t[ search, config ]\n\t);\n\tconst { records: searchResults, hasResolved: searchHasResolved } =\n\t\tuseEntityRecords(\n\t\t\tentityForSuggestions.type,\n\t\t\tentityForSuggestions.slug,\n\t\t\tquery\n\t\t);\n\tconst [ suggestions, setSuggestions ] = useState( EMPTY_ARRAY );\n\tuseEffect( () => {\n\t\tif ( ! searchHasResolved ) {\n\t\t\treturn;\n\t\t}\n\t\tlet newSuggestions = EMPTY_ARRAY;\n\t\tif ( searchResults?.length ) {\n\t\t\tnewSuggestions = searchResults;\n\t\t\tif ( config.recordNamePath ) {\n\t\t\t\tnewSuggestions = mapToIHasNameAndId(\n\t\t\t\t\tnewSuggestions,\n\t\t\t\t\tconfig.recordNamePath\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\t// Update suggestions only when the query has resolved, so as to keep\n\t\t// the previous results in the UI.\n\t\tsetSuggestions( newSuggestions );\n\t}, [ searchResults, searchHasResolved ] );\n\treturn suggestions;\n}\n\nfunction SuggestionList( { entityForSuggestions, onSelect } ) {\n\tconst [ search, setSearch, debouncedSearch ] = useDebouncedInput();\n\tconst suggestions = useSearchSuggestions(\n\t\tentityForSuggestions,\n\t\tdebouncedSearch\n\t);\n\tconst { labels } = entityForSuggestions;\n\tconst [ showSearchControl, setShowSearchControl ] = useState( false );\n\tif ( ! showSearchControl && suggestions?.length > 9 ) {\n\t\tsetShowSearchControl( true );\n\t}\n\treturn (\n\t\t<>\n\t\t\t{ showSearchControl && (\n\t\t\t\t<SearchControl\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\tonChange={ setSearch }\n\t\t\t\t\tvalue={ search }\n\t\t\t\t\tlabel={ labels.search_items }\n\t\t\t\t\tplaceholder={ labels.search_items }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ !! suggestions?.length && (\n\t\t\t\t<Composite\n\t\t\t\t\torientation=\"vertical\"\n\t\t\t\t\trole=\"listbox\"\n\t\t\t\t\tclassName=\"edit-site-custom-template-modal__suggestions_list\"\n\t\t\t\t\taria-label={ __( 'Suggestions list' ) }\n\t\t\t\t>\n\t\t\t\t\t{ suggestions.map( ( suggestion ) => (\n\t\t\t\t\t\t<SuggestionListItem\n\t\t\t\t\t\t\tkey={ suggestion.slug }\n\t\t\t\t\t\t\tsuggestion={ suggestion }\n\t\t\t\t\t\t\tsearch={ debouncedSearch }\n\t\t\t\t\t\t\tonSelect={ onSelect }\n\t\t\t\t\t\t\tentityForSuggestions={ entityForSuggestions }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) ) }\n\t\t\t\t</Composite>\n\t\t\t) }\n\t\t\t{ debouncedSearch && ! suggestions?.length && (\n\t\t\t\t<Text\n\t\t\t\t\tas=\"p\"\n\t\t\t\t\tclassName=\"edit-site-custom-template-modal__no-results\"\n\t\t\t\t>\n\t\t\t\t\t{ labels.not_found }\n\t\t\t\t</Text>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nfunction AddCustomTemplateModalContent( {\n\tonSelect,\n\tentityForSuggestions,\n\tonBack,\n\tcontainerRef,\n} ) {\n\tconst [ showSearchEntities, setShowSearchEntities ] = useState();\n\n\t// Focus on the first focusable element when the modal opens.\n\t// We handle focus management in the parent modal, just need to focus on the first focusable element.\n\tuseEffect( () => {\n\t\tif ( containerRef.current ) {\n\t\t\tconst [ firstFocusable ] = focus.focusable.find(\n\t\t\t\tcontainerRef.current\n\t\t\t);\n\t\t\tfirstFocusable?.focus();\n\t\t}\n\t}, [ showSearchEntities ] );\n\n\treturn (\n\t\t<VStack\n\t\t\tspacing={ 4 }\n\t\t\tclassName=\"edit-site-custom-template-modal__contents-wrapper\"\n\t\t\talignment=\"left\"\n\t\t>\n\t\t\t{ ! showSearchEntities && (\n\t\t\t\t<>\n\t\t\t\t\t<Text as=\"p\">\n\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t'Select whether to create a single template for all items or a specific one.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t</Text>\n\t\t\t\t\t<Flex\n\t\t\t\t\t\tclassName=\"edit-site-custom-template-modal__contents\"\n\t\t\t\t\t\tgap=\"4\"\n\t\t\t\t\t\talign=\"initial\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<FlexItem\n\t\t\t\t\t\t\tisBlock\n\t\t\t\t\t\t\tas={ Button }\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\tconst {\n\t\t\t\t\t\t\t\t\tslug,\n\t\t\t\t\t\t\t\t\ttitle,\n\t\t\t\t\t\t\t\t\tdescription,\n\t\t\t\t\t\t\t\t\ttemplatePrefix,\n\t\t\t\t\t\t\t\t} = entityForSuggestions.template;\n\t\t\t\t\t\t\t\tonSelect( {\n\t\t\t\t\t\t\t\t\tslug,\n\t\t\t\t\t\t\t\t\ttitle,\n\t\t\t\t\t\t\t\t\tdescription,\n\t\t\t\t\t\t\t\t\ttemplatePrefix,\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<Text\n\t\t\t\t\t\t\t\tas=\"span\"\n\t\t\t\t\t\t\t\tweight={ 500 }\n\t\t\t\t\t\t\t\tlineHeight={ 1.53846153846 } // 20px\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ entityForSuggestions.labels.all_items }\n\t\t\t\t\t\t\t</Text>\n\t\t\t\t\t\t\t<Text\n\t\t\t\t\t\t\t\tas=\"span\"\n\t\t\t\t\t\t\t\tlineHeight={ 1.53846153846 } // 20px\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t// translators: The user is given the choice to set up a template for all items of a post type or taxonomy, or just a specific one.\n\t\t\t\t\t\t\t\t\t__( 'For all items' )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t</Text>\n\t\t\t\t\t\t</FlexItem>\n\t\t\t\t\t\t<FlexItem\n\t\t\t\t\t\t\tisBlock\n\t\t\t\t\t\t\tas={ Button }\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\tsetShowSearchEntities( true );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<Text\n\t\t\t\t\t\t\t\tas=\"span\"\n\t\t\t\t\t\t\t\tweight={ 500 }\n\t\t\t\t\t\t\t\tlineHeight={ 1.53846153846 } // 20px\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ entityForSuggestions.labels.singular_name }\n\t\t\t\t\t\t\t</Text>\n\t\t\t\t\t\t\t<Text\n\t\t\t\t\t\t\t\tas=\"span\"\n\t\t\t\t\t\t\t\tlineHeight={ 1.53846153846 } // 20px\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t// translators: The user is given the choice to set up a template for all items of a post type or taxonomy, or just a specific one.\n\t\t\t\t\t\t\t\t\t__( 'For a specific item' )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t</Text>\n\t\t\t\t\t\t</FlexItem>\n\t\t\t\t\t</Flex>\n\t\t\t\t\t<Flex justify=\"right\">\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\tonClick={ onBack }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Back' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</Flex>\n\t\t\t\t</>\n\t\t\t) }\n\t\t\t{ showSearchEntities && (\n\t\t\t\t<>\n\t\t\t\t\t<Text as=\"p\">\n\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t'This template will be used only for the specific item chosen.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t</Text>\n\t\t\t\t\t<SuggestionList\n\t\t\t\t\t\tentityForSuggestions={ entityForSuggestions }\n\t\t\t\t\t\tonSelect={ onSelect }\n\t\t\t\t\t/>\n\t\t\t\t\t<Flex justify=\"right\">\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t// If general template exists, go directly back to main screen\n\t\t\t\t\t\t\t\t// instead of showing the choice screen\n\t\t\t\t\t\t\t\tif ( entityForSuggestions.hasGeneralTemplate ) {\n\t\t\t\t\t\t\t\t\tonBack();\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tsetShowSearchEntities( false );\n\t\t\t\t\t\t\t\t}\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C,cAAc;QACdhD,oBAAoB,EAAGA,oBAAsB;QAC7CD,QAAQ,EAAGA;MAAU,CACrB,CAAC,eACF,IAAAL,WAAA,CAAAY,GAAA,EAACnB,WAAA,CAAA8F,IAAI;QAACW,OAAO,EAAC,OAAO;QAAA9E,QAAA,eACpB,IAAApB,WAAA,CAAAY,GAAA,EAACnB,WAAA,CAAAoB,MAAM;UACNC,qBAAqB;UACrBqF,OAAO,EAAC,UAAU;UAClBlF,OAAO,EAAGA,CAAA,KAAM;YACf;YACA;YACA,IAAKX,oBAAoB,CAAC8F,kBAAkB,EAAG;cAC9CzB,MAAM,CAAC,CAAC;YACT,CAAC,MAAM;cACNG,qBAAqB,CAAE,KAAM,CAAC;YAC/B;UACD,CAAG;UAAA1D,QAAA,EAED,IAAAkD,QAAE,EAAE,MAAO;QAAC,CACP;MAAC,CACJ,CAAC;IAAA,CACN,CACF;EAAA,CACM,CAAC;AAEX;AAAC,IAAA+B,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEc7B,6BAA6B","ignoreList":[]}
|
|
@@ -14,6 +14,7 @@ var _htmlEntities = require("@wordpress/html-entities");
|
|
|
14
14
|
var _element = require("@wordpress/element");
|
|
15
15
|
var _i18n = require("@wordpress/i18n");
|
|
16
16
|
var _icons = require("@wordpress/icons");
|
|
17
|
+
var _url = require("@wordpress/url");
|
|
17
18
|
var _constants = require("../../utils/constants");
|
|
18
19
|
/**
|
|
19
20
|
* WordPress dependencies
|
|
@@ -39,6 +40,20 @@ const getValueFromObjectPath = (object, path) => {
|
|
|
39
40
|
return value;
|
|
40
41
|
};
|
|
41
42
|
|
|
43
|
+
/**
|
|
44
|
+
* Helper that adds a prefix to a post slug. The slug needs to be URL-decoded first,
|
|
45
|
+
* so that we have raw Unicode characters there. The server will truncate the slug to
|
|
46
|
+
* 200 characters, respecing Unicode char boundary. On the other hand, the server
|
|
47
|
+
* doesn't detect urlencoded octet boundary and can possibly construct slugs that
|
|
48
|
+
* are not valid urlencoded strings.
|
|
49
|
+
* @param {string} prefix The prefix to add to the slug.
|
|
50
|
+
* @param {string} slug The slug to add the prefix to.
|
|
51
|
+
* @return {string} The slug with the prefix.
|
|
52
|
+
*/
|
|
53
|
+
function prefixSlug(prefix, slug) {
|
|
54
|
+
return `${prefix}-${(0, _url.safeDecodeURI)(slug)}`;
|
|
55
|
+
}
|
|
56
|
+
|
|
42
57
|
/**
|
|
43
58
|
* Helper util to map records to add a `name` prop from a
|
|
44
59
|
* provided path, in order to handle all entities in the same
|
|
@@ -235,7 +250,7 @@ const usePostTypeMenuItems = onClickMenuItem => {
|
|
|
235
250
|
};
|
|
236
251
|
},
|
|
237
252
|
getSpecificTemplate: suggestion => {
|
|
238
|
-
const templateSlug =
|
|
253
|
+
const templateSlug = prefixSlug(templatePrefixes[slug], suggestion.slug);
|
|
239
254
|
return {
|
|
240
255
|
title: templateSlug,
|
|
241
256
|
slug: templateSlug,
|
|
@@ -363,7 +378,7 @@ const useTaxonomiesMenuItems = onClickMenuItem => {
|
|
|
363
378
|
};
|
|
364
379
|
},
|
|
365
380
|
getSpecificTemplate: suggestion => {
|
|
366
|
-
const templateSlug =
|
|
381
|
+
const templateSlug = prefixSlug(templatePrefixes[slug], suggestion.slug);
|
|
367
382
|
return {
|
|
368
383
|
title: templateSlug,
|
|
369
384
|
slug: templateSlug,
|
|
@@ -449,7 +464,7 @@ function useAuthorMenuItem(onClickMenuItem) {
|
|
|
449
464
|
};
|
|
450
465
|
},
|
|
451
466
|
getSpecificTemplate: suggestion => {
|
|
452
|
-
const templateSlug =
|
|
467
|
+
const templateSlug = prefixSlug('author', suggestion.slug);
|
|
453
468
|
return {
|
|
454
469
|
title: (0, _i18n.sprintf)(
|
|
455
470
|
// translators: %s: Name of the author e.g: "Admin".
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_data","require","_coreData","_htmlEntities","_element","_i18n","_icons","_constants","EMPTY_OBJECT","getValueFromObjectPath","object","path","value","split","forEach","fieldName","mapToIHasNameAndId","entities","map","entity","name","decodeEntities","exports","useExistingTemplates","useSelect","select","coreStore","getEntityRecords","TEMPLATE_POST_TYPE","per_page","useDefaultTemplateTypes","getCurrentTheme","default_template_types","usePublicPostTypes","postTypes","getPostTypes","useMemo","excludedPostTypes","filter","viewable","slug","includes","sort","a","b","localeCompare","usePublicTaxonomies","taxonomies","getTaxonomies","visibility","publicly_queryable","usePostTypeArchiveMenuItems","publicPostTypes","postTypesWithArchives","postType","has_archive","existingTemplates","postTypeLabels","reduce","accumulator","labels","singularName","singular_name","toLowerCase","needsUniqueIdentifier","useCallback","some","existingTemplate","title","sprintf","__","description","icon","startsWith","slice","archive","templatePrefix","usePostTypeMenuItems","onClickMenuItem","defaultTemplateTypes","templateLabels","templateName","template_name","templatePrefixes","suffix","postTypesInfo","useEntitiesInfo","menuItems","generalTemplateSlug","defaultTemplateType","find","_slug","_needsUniqueIdentifier","menuItemTitle","_x","menuItem","post","hasEntities","onClick","template","type","config","recordNamePath","queryArgs","search","_fields","orderBy","exclude","existingEntitiesIds","getSpecificTemplate","suggestion","templateSlug","push","postTypesMenuItems","key","defaultPostTypesMenuItems","useTaxonomiesMenuItems","publicTaxonomies","taxonomyLabels","taxonomiesInfo","existingTemplateSlugs","taxonomy","hasGeneralTemplate","blockMeta","taxonomiesMenuItems","defaultTaxonomiesMenuItems","USE_AUTHOR_MENU_ITEM_TEMPLATE_PREFIX","user","USE_AUTHOR_MENU_ITEM_QUERY_PARAMETERS","who","useAuthorMenuItem","authorInfo","authorMenuItem","search_items","not_found","all_items","entityName","additionalQueryParameters","entitiesHasRecords","Object","keys","context","length","entitiesInfo"],"sources":["@wordpress/edit-site/src/components/add-new-template/utils.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { useMemo, useCallback } from '@wordpress/element';\nimport { __, _x, sprintf } from '@wordpress/i18n';\nimport { blockMeta, post, archive } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { TEMPLATE_POST_TYPE } from '../../utils/constants';\n\nconst EMPTY_OBJECT = {};\n\n/**\n * @typedef IHasNameAndId\n * @property {string|number} id The entity's id.\n * @property {string} name The entity's name.\n */\n\nconst getValueFromObjectPath = ( object, path ) => {\n\tlet value = object;\n\tpath.split( '.' ).forEach( ( fieldName ) => {\n\t\tvalue = value?.[ fieldName ];\n\t} );\n\treturn value;\n};\n\n/**\n * Helper util to map records to add a `name` prop from a\n * provided path, in order to handle all entities in the same\n * fashion(implementing`IHasNameAndId` interface).\n *\n * @param {Object[]} entities The array of entities.\n * @param {string} path The path to map a `name` property from the entity.\n * @return {IHasNameAndId[]} An array of entities that now implement the `IHasNameAndId` interface.\n */\nexport const mapToIHasNameAndId = ( entities, path ) => {\n\treturn ( entities || [] ).map( ( entity ) => ( {\n\t\t...entity,\n\t\tname: decodeEntities( getValueFromObjectPath( entity, path ) ),\n\t} ) );\n};\n\n/**\n * @typedef {Object} EntitiesInfo\n * @property {boolean} hasEntities If an entity has available records(posts, terms, etc..).\n * @property {number[]} existingEntitiesIds An array of the existing entities ids.\n */\n\nexport const useExistingTemplates = () => {\n\treturn useSelect(\n\t\t( select ) =>\n\t\t\tselect( coreStore ).getEntityRecords(\n\t\t\t\t'postType',\n\t\t\t\tTEMPLATE_POST_TYPE,\n\t\t\t\t{\n\t\t\t\t\tper_page: -1,\n\t\t\t\t}\n\t\t\t),\n\t\t[]\n\t);\n};\n\nexport const useDefaultTemplateTypes = () => {\n\treturn useSelect(\n\t\t( select ) =>\n\t\t\tselect( coreStore ).getCurrentTheme()?.default_template_types || [],\n\t\t[]\n\t);\n};\n\nconst usePublicPostTypes = () => {\n\tconst postTypes = useSelect(\n\t\t( select ) => select( coreStore ).getPostTypes( { per_page: -1 } ),\n\t\t[]\n\t);\n\treturn useMemo( () => {\n\t\tconst excludedPostTypes = [ 'attachment' ];\n\t\treturn postTypes\n\t\t\t?.filter(\n\t\t\t\t( { viewable, slug } ) =>\n\t\t\t\t\tviewable && ! excludedPostTypes.includes( slug )\n\t\t\t)\n\t\t\t.sort( ( a, b ) => {\n\t\t\t\t// Sort post types alphabetically by name,\n\t\t\t\t// but exclude the built-in 'post' type from sorting.\n\t\t\t\tif ( a.slug === 'post' || b.slug === 'post' ) {\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\n\t\t\t\treturn a.name.localeCompare( b.name );\n\t\t\t} );\n\t}, [ postTypes ] );\n};\n\nconst usePublicTaxonomies = () => {\n\tconst taxonomies = useSelect(\n\t\t( select ) => select( coreStore ).getTaxonomies( { per_page: -1 } ),\n\t\t[]\n\t);\n\treturn useMemo( () => {\n\t\treturn taxonomies?.filter(\n\t\t\t( { visibility } ) => visibility?.publicly_queryable\n\t\t);\n\t}, [ taxonomies ] );\n};\n\nexport function usePostTypeArchiveMenuItems() {\n\tconst publicPostTypes = usePublicPostTypes();\n\tconst postTypesWithArchives = useMemo(\n\t\t() => publicPostTypes?.filter( ( postType ) => postType.has_archive ),\n\t\t[ publicPostTypes ]\n\t);\n\tconst existingTemplates = useExistingTemplates();\n\t// We need to keep track of naming conflicts. If a conflict\n\t// occurs, we need to add slug.\n\tconst postTypeLabels = useMemo(\n\t\t() =>\n\t\t\tpublicPostTypes?.reduce( ( accumulator, { labels } ) => {\n\t\t\t\tconst singularName = labels.singular_name.toLowerCase();\n\t\t\t\taccumulator[ singularName ] =\n\t\t\t\t\t( accumulator[ singularName ] || 0 ) + 1;\n\t\t\t\treturn accumulator;\n\t\t\t}, {} ),\n\t\t[ publicPostTypes ]\n\t);\n\tconst needsUniqueIdentifier = useCallback(\n\t\t( { labels, slug } ) => {\n\t\t\tconst singularName = labels.singular_name.toLowerCase();\n\t\t\treturn postTypeLabels[ singularName ] > 1 && singularName !== slug;\n\t\t},\n\t\t[ postTypeLabels ]\n\t);\n\treturn useMemo(\n\t\t() =>\n\t\t\tpostTypesWithArchives\n\t\t\t\t?.filter(\n\t\t\t\t\t( postType ) =>\n\t\t\t\t\t\t! ( existingTemplates || [] ).some(\n\t\t\t\t\t\t\t( existingTemplate ) =>\n\t\t\t\t\t\t\t\texistingTemplate.slug ===\n\t\t\t\t\t\t\t\t'archive-' + postType.slug\n\t\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t\t.map( ( postType ) => {\n\t\t\t\t\tlet title;\n\t\t\t\t\tif ( needsUniqueIdentifier( postType ) ) {\n\t\t\t\t\t\ttitle = sprintf(\n\t\t\t\t\t\t\t// translators: %1s: Name of the post type e.g: \"Post\"; %2s: Slug of the post type e.g: \"book\".\n\t\t\t\t\t\t\t__( 'Archive: %1$s (%2$s)' ),\n\t\t\t\t\t\t\tpostType.labels.singular_name,\n\t\t\t\t\t\t\tpostType.slug\n\t\t\t\t\t\t);\n\t\t\t\t\t} else {\n\t\t\t\t\t\ttitle = sprintf(\n\t\t\t\t\t\t\t// translators: %s: Name of the post type e.g: \"Post\".\n\t\t\t\t\t\t\t__( 'Archive: %s' ),\n\t\t\t\t\t\t\tpostType.labels.singular_name\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\treturn {\n\t\t\t\t\t\tslug: 'archive-' + postType.slug,\n\t\t\t\t\t\tdescription: sprintf(\n\t\t\t\t\t\t\t// translators: %s: Name of the post type e.g: \"Post\".\n\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t'Displays an archive with the latest posts of type: %s.'\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tpostType.labels.singular_name\n\t\t\t\t\t\t),\n\t\t\t\t\t\ttitle,\n\t\t\t\t\t\t// `icon` is the `menu_icon` property of a post type. We\n\t\t\t\t\t\t// only handle `dashicons` for now, even if the `menu_icon`\n\t\t\t\t\t\t// also supports urls and svg as values.\n\t\t\t\t\t\ticon:\n\t\t\t\t\t\t\ttypeof postType.icon === 'string' &&\n\t\t\t\t\t\t\tpostType.icon.startsWith( 'dashicons-' )\n\t\t\t\t\t\t\t\t? postType.icon.slice( 10 )\n\t\t\t\t\t\t\t\t: archive,\n\t\t\t\t\t\ttemplatePrefix: 'archive',\n\t\t\t\t\t};\n\t\t\t\t} ) || [],\n\t\t[ postTypesWithArchives, existingTemplates, needsUniqueIdentifier ]\n\t);\n}\n\nexport const usePostTypeMenuItems = ( onClickMenuItem ) => {\n\tconst publicPostTypes = usePublicPostTypes();\n\tconst defaultTemplateTypes = useDefaultTemplateTypes();\n\t// We need to keep track of naming conflicts. If a conflict\n\t// occurs, we need to add slug.\n\tconst templateLabels = useMemo(\n\t\t() =>\n\t\t\tpublicPostTypes?.reduce( ( accumulator, { labels } ) => {\n\t\t\t\tconst templateName = (\n\t\t\t\t\tlabels.template_name || labels.singular_name\n\t\t\t\t).toLowerCase();\n\t\t\t\taccumulator[ templateName ] =\n\t\t\t\t\t( accumulator[ templateName ] || 0 ) + 1;\n\t\t\t\treturn accumulator;\n\t\t\t}, {} ),\n\t\t[ publicPostTypes ]\n\t);\n\tconst needsUniqueIdentifier = useCallback(\n\t\t( { labels, slug } ) => {\n\t\t\tconst templateName = (\n\t\t\t\tlabels.template_name || labels.singular_name\n\t\t\t).toLowerCase();\n\t\t\treturn templateLabels[ templateName ] > 1 && templateName !== slug;\n\t\t},\n\t\t[ templateLabels ]\n\t);\n\n\t// `page`is a special case in template hierarchy.\n\tconst templatePrefixes = useMemo(\n\t\t() =>\n\t\t\tpublicPostTypes?.reduce( ( accumulator, { slug } ) => {\n\t\t\t\tlet suffix = slug;\n\t\t\t\tif ( slug !== 'page' ) {\n\t\t\t\t\tsuffix = `single-${ suffix }`;\n\t\t\t\t}\n\t\t\t\taccumulator[ slug ] = suffix;\n\t\t\t\treturn accumulator;\n\t\t\t}, {} ),\n\t\t[ publicPostTypes ]\n\t);\n\tconst postTypesInfo = useEntitiesInfo( 'postType', templatePrefixes );\n\tconst menuItems = ( publicPostTypes || [] ).reduce(\n\t\t( accumulator, postType ) => {\n\t\t\tconst { slug, labels, icon } = postType;\n\t\t\t// We need to check if the general template is part of the\n\t\t\t// defaultTemplateTypes. If it is, just use that info and\n\t\t\t// augment it with the specific template functionality.\n\t\t\tconst generalTemplateSlug = templatePrefixes[ slug ];\n\t\t\tconst defaultTemplateType = defaultTemplateTypes?.find(\n\t\t\t\t( { slug: _slug } ) => _slug === generalTemplateSlug\n\t\t\t);\n\t\t\tconst _needsUniqueIdentifier = needsUniqueIdentifier( postType );\n\t\t\tlet menuItemTitle =\n\t\t\t\tlabels.template_name ||\n\t\t\t\tsprintf(\n\t\t\t\t\t// translators: %s: Name of the post type e.g: \"Post\".\n\t\t\t\t\t__( 'Single item: %s' ),\n\t\t\t\t\tlabels.singular_name\n\t\t\t\t);\n\t\t\tif ( _needsUniqueIdentifier ) {\n\t\t\t\tmenuItemTitle = labels.template_name\n\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t// translators: 1: Name of the template e.g: \"Single Item: Post\". 2: Slug of the post type e.g: \"book\".\n\t\t\t\t\t\t\t_x( '%1$s (%2$s)', 'post type menu label' ),\n\t\t\t\t\t\t\tlabels.template_name,\n\t\t\t\t\t\t\tslug\n\t\t\t\t\t )\n\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t// translators: 1: Name of the post type e.g: \"Post\". 2: Slug of the post type e.g: \"book\".\n\t\t\t\t\t\t\t_x(\n\t\t\t\t\t\t\t\t'Single item: %1$s (%2$s)',\n\t\t\t\t\t\t\t\t'post type menu label'\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tlabels.singular_name,\n\t\t\t\t\t\t\tslug\n\t\t\t\t\t );\n\t\t\t}\n\t\t\tconst menuItem = defaultTemplateType\n\t\t\t\t? {\n\t\t\t\t\t\t...defaultTemplateType,\n\t\t\t\t\t\ttemplatePrefix: templatePrefixes[ slug ],\n\t\t\t\t }\n\t\t\t\t: {\n\t\t\t\t\t\tslug: generalTemplateSlug,\n\t\t\t\t\t\ttitle: menuItemTitle,\n\t\t\t\t\t\tdescription: sprintf(\n\t\t\t\t\t\t\t// translators: %s: Name of the post type e.g: \"Post\".\n\t\t\t\t\t\t\t__( 'Displays a single item: %s.' ),\n\t\t\t\t\t\t\tlabels.singular_name\n\t\t\t\t\t\t),\n\t\t\t\t\t\t// `icon` is the `menu_icon` property of a post type. We\n\t\t\t\t\t\t// only handle `dashicons` for now, even if the `menu_icon`\n\t\t\t\t\t\t// also supports urls and svg as values.\n\t\t\t\t\t\ticon:\n\t\t\t\t\t\t\ttypeof icon === 'string' &&\n\t\t\t\t\t\t\ticon.startsWith( 'dashicons-' )\n\t\t\t\t\t\t\t\t? icon.slice( 10 )\n\t\t\t\t\t\t\t\t: post,\n\t\t\t\t\t\ttemplatePrefix: templatePrefixes[ slug ],\n\t\t\t\t };\n\t\t\tconst hasEntities = postTypesInfo?.[ slug ]?.hasEntities;\n\t\t\t// We have a different template creation flow only if they have entities.\n\t\t\tif ( hasEntities ) {\n\t\t\t\tmenuItem.onClick = ( template ) => {\n\t\t\t\t\tonClickMenuItem( {\n\t\t\t\t\t\ttype: 'postType',\n\t\t\t\t\t\tslug,\n\t\t\t\t\t\tconfig: {\n\t\t\t\t\t\t\trecordNamePath: 'title.rendered',\n\t\t\t\t\t\t\tqueryArgs: ( { search } ) => {\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t_fields: 'id,title,slug,link',\n\t\t\t\t\t\t\t\t\torderBy: search ? 'relevance' : 'modified',\n\t\t\t\t\t\t\t\t\texclude:\n\t\t\t\t\t\t\t\t\t\tpostTypesInfo[ slug ]\n\t\t\t\t\t\t\t\t\t\t\t.existingEntitiesIds,\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tgetSpecificTemplate: ( suggestion ) => {\n\t\t\t\t\t\t\t\tconst templateSlug = `${ templatePrefixes[ slug ] }-${ suggestion.slug }`;\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\ttitle: templateSlug,\n\t\t\t\t\t\t\t\t\tslug: templateSlug,\n\t\t\t\t\t\t\t\t\ttemplatePrefix: templatePrefixes[ slug ],\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t\tlabels,\n\t\t\t\t\t\ttemplate,\n\t\t\t\t\t} );\n\t\t\t\t};\n\t\t\t}\n\t\t\t// We don't need to add the menu item if there are no entities.\n\t\t\tif ( hasEntities ) {\n\t\t\t\taccumulator.push( menuItem );\n\t\t\t}\n\t\t\treturn accumulator;\n\t\t},\n\t\t[]\n\t);\n\t// Split menu items into two groups: one for the default post types\n\t// and one for the rest.\n\tconst postTypesMenuItems = useMemo(\n\t\t() =>\n\t\t\tmenuItems.reduce(\n\t\t\t\t( accumulator, postType ) => {\n\t\t\t\t\tconst { slug } = postType;\n\t\t\t\t\tlet key = 'postTypesMenuItems';\n\t\t\t\t\tif ( slug === 'page' ) {\n\t\t\t\t\t\tkey = 'defaultPostTypesMenuItems';\n\t\t\t\t\t}\n\t\t\t\t\taccumulator[ key ].push( postType );\n\t\t\t\t\treturn accumulator;\n\t\t\t\t},\n\t\t\t\t{ defaultPostTypesMenuItems: [], postTypesMenuItems: [] }\n\t\t\t),\n\t\t[ menuItems ]\n\t);\n\treturn postTypesMenuItems;\n};\n\nexport const useTaxonomiesMenuItems = ( onClickMenuItem ) => {\n\tconst publicTaxonomies = usePublicTaxonomies();\n\tconst existingTemplates = useExistingTemplates();\n\tconst defaultTemplateTypes = useDefaultTemplateTypes();\n\t// `category` and `post_tag` are special cases in template hierarchy.\n\tconst templatePrefixes = useMemo(\n\t\t() =>\n\t\t\tpublicTaxonomies?.reduce( ( accumulator, { slug } ) => {\n\t\t\t\tlet suffix = slug;\n\t\t\t\tif ( ! [ 'category', 'post_tag' ].includes( slug ) ) {\n\t\t\t\t\tsuffix = `taxonomy-${ suffix }`;\n\t\t\t\t}\n\t\t\t\tif ( slug === 'post_tag' ) {\n\t\t\t\t\tsuffix = `tag`;\n\t\t\t\t}\n\t\t\t\taccumulator[ slug ] = suffix;\n\t\t\t\treturn accumulator;\n\t\t\t}, {} ),\n\t\t[ publicTaxonomies ]\n\t);\n\t// We need to keep track of naming conflicts. If a conflict\n\t// occurs, we need to add slug.\n\tconst taxonomyLabels = publicTaxonomies?.reduce(\n\t\t( accumulator, { labels } ) => {\n\t\t\tconst templateName = (\n\t\t\t\tlabels.template_name || labels.singular_name\n\t\t\t).toLowerCase();\n\t\t\taccumulator[ templateName ] =\n\t\t\t\t( accumulator[ templateName ] || 0 ) + 1;\n\t\t\treturn accumulator;\n\t\t},\n\t\t{}\n\t);\n\tconst needsUniqueIdentifier = ( labels, slug ) => {\n\t\tif ( [ 'category', 'post_tag' ].includes( slug ) ) {\n\t\t\treturn false;\n\t\t}\n\t\tconst templateName = (\n\t\t\tlabels.template_name || labels.singular_name\n\t\t).toLowerCase();\n\t\treturn taxonomyLabels[ templateName ] > 1 && templateName !== slug;\n\t};\n\tconst taxonomiesInfo = useEntitiesInfo( 'taxonomy', templatePrefixes );\n\tconst existingTemplateSlugs = ( existingTemplates || [] ).map(\n\t\t( { slug } ) => slug\n\t);\n\tconst menuItems = ( publicTaxonomies || [] ).reduce(\n\t\t( accumulator, taxonomy ) => {\n\t\t\tconst { slug, labels } = taxonomy;\n\t\t\t// We need to check if the general template is part of the\n\t\t\t// defaultTemplateTypes. If it is, just use that info and\n\t\t\t// augment it with the specific template functionality.\n\t\t\tconst generalTemplateSlug = templatePrefixes[ slug ];\n\t\t\tconst defaultTemplateType = defaultTemplateTypes?.find(\n\t\t\t\t( { slug: _slug } ) => _slug === generalTemplateSlug\n\t\t\t);\n\t\t\tconst hasGeneralTemplate =\n\t\t\t\texistingTemplateSlugs?.includes( generalTemplateSlug );\n\t\t\tconst _needsUniqueIdentifier = needsUniqueIdentifier(\n\t\t\t\tlabels,\n\t\t\t\tslug\n\t\t\t);\n\t\t\tlet menuItemTitle = labels.template_name || labels.singular_name;\n\t\t\tif ( _needsUniqueIdentifier ) {\n\t\t\t\tmenuItemTitle = labels.template_name\n\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t// translators: 1: Name of the template e.g: \"Products by Category\". 2: Slug of the taxonomy e.g: \"product_cat\".\n\t\t\t\t\t\t\t_x( '%1$s (%2$s)', 'taxonomy template menu label' ),\n\t\t\t\t\t\t\tlabels.template_name,\n\t\t\t\t\t\t\tslug\n\t\t\t\t\t )\n\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t// translators: 1: Name of the taxonomy e.g: \"Category\". 2: Slug of the taxonomy e.g: \"product_cat\".\n\t\t\t\t\t\t\t_x( '%1$s (%2$s)', 'taxonomy menu label' ),\n\t\t\t\t\t\t\tlabels.singular_name,\n\t\t\t\t\t\t\tslug\n\t\t\t\t\t );\n\t\t\t}\n\t\t\tconst menuItem = defaultTemplateType\n\t\t\t\t? {\n\t\t\t\t\t\t...defaultTemplateType,\n\t\t\t\t\t\ttemplatePrefix: templatePrefixes[ slug ],\n\t\t\t\t }\n\t\t\t\t: {\n\t\t\t\t\t\tslug: generalTemplateSlug,\n\t\t\t\t\t\ttitle: menuItemTitle,\n\t\t\t\t\t\tdescription: sprintf(\n\t\t\t\t\t\t\t// translators: %s: Name of the taxonomy e.g: \"Product Categories\".\n\t\t\t\t\t\t\t__( 'Displays taxonomy: %s.' ),\n\t\t\t\t\t\t\tlabels.singular_name\n\t\t\t\t\t\t),\n\t\t\t\t\t\ticon: blockMeta,\n\t\t\t\t\t\ttemplatePrefix: templatePrefixes[ slug ],\n\t\t\t\t };\n\t\t\tconst hasEntities = taxonomiesInfo?.[ slug ]?.hasEntities;\n\t\t\t// We have a different template creation flow only if they have entities.\n\t\t\tif ( hasEntities ) {\n\t\t\t\tmenuItem.onClick = ( template ) => {\n\t\t\t\t\tonClickMenuItem( {\n\t\t\t\t\t\ttype: 'taxonomy',\n\t\t\t\t\t\tslug,\n\t\t\t\t\t\tconfig: {\n\t\t\t\t\t\t\tqueryArgs: ( { search } ) => {\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t_fields: 'id,name,slug,link',\n\t\t\t\t\t\t\t\t\torderBy: search ? 'name' : 'count',\n\t\t\t\t\t\t\t\t\texclude:\n\t\t\t\t\t\t\t\t\t\ttaxonomiesInfo[ slug ]\n\t\t\t\t\t\t\t\t\t\t\t.existingEntitiesIds,\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tgetSpecificTemplate: ( suggestion ) => {\n\t\t\t\t\t\t\t\tconst templateSlug = `${ templatePrefixes[ slug ] }-${ suggestion.slug }`;\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\ttitle: templateSlug,\n\t\t\t\t\t\t\t\t\tslug: templateSlug,\n\t\t\t\t\t\t\t\t\ttemplatePrefix: templatePrefixes[ slug ],\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t\tlabels,\n\t\t\t\t\t\thasGeneralTemplate,\n\t\t\t\t\t\ttemplate,\n\t\t\t\t\t} );\n\t\t\t\t};\n\t\t\t}\n\t\t\t// We don't need to add the menu item if there are no\n\t\t\t// entities and the general template exists.\n\t\t\tif ( ! hasGeneralTemplate || hasEntities ) {\n\t\t\t\taccumulator.push( menuItem );\n\t\t\t}\n\t\t\treturn accumulator;\n\t\t},\n\t\t[]\n\t);\n\t// Split menu items into two groups: one for the default taxonomies\n\t// and one for the rest.\n\tconst taxonomiesMenuItems = useMemo(\n\t\t() =>\n\t\t\tmenuItems.reduce(\n\t\t\t\t( accumulator, taxonomy ) => {\n\t\t\t\t\tconst { slug } = taxonomy;\n\t\t\t\t\tlet key = 'taxonomiesMenuItems';\n\t\t\t\t\tif ( [ 'category', 'tag' ].includes( slug ) ) {\n\t\t\t\t\t\tkey = 'defaultTaxonomiesMenuItems';\n\t\t\t\t\t}\n\t\t\t\t\taccumulator[ key ].push( taxonomy );\n\t\t\t\t\treturn accumulator;\n\t\t\t\t},\n\t\t\t\t{ defaultTaxonomiesMenuItems: [], taxonomiesMenuItems: [] }\n\t\t\t),\n\t\t[ menuItems ]\n\t);\n\treturn taxonomiesMenuItems;\n};\n\nconst USE_AUTHOR_MENU_ITEM_TEMPLATE_PREFIX = { user: 'author' };\nconst USE_AUTHOR_MENU_ITEM_QUERY_PARAMETERS = { user: { who: 'authors' } };\nexport function useAuthorMenuItem( onClickMenuItem ) {\n\tconst existingTemplates = useExistingTemplates();\n\tconst defaultTemplateTypes = useDefaultTemplateTypes();\n\tconst authorInfo = useEntitiesInfo(\n\t\t'root',\n\t\tUSE_AUTHOR_MENU_ITEM_TEMPLATE_PREFIX,\n\t\tUSE_AUTHOR_MENU_ITEM_QUERY_PARAMETERS\n\t);\n\tlet authorMenuItem = defaultTemplateTypes?.find(\n\t\t( { slug } ) => slug === 'author'\n\t);\n\tif ( ! authorMenuItem ) {\n\t\tauthorMenuItem = {\n\t\t\tdescription: __(\n\t\t\t\t'Displays latest posts written by a single author.'\n\t\t\t),\n\t\t\tslug: 'author',\n\t\t\ttitle: 'Author',\n\t\t};\n\t}\n\tconst hasGeneralTemplate = !! existingTemplates?.find(\n\t\t( { slug } ) => slug === 'author'\n\t);\n\tif ( authorInfo.user?.hasEntities ) {\n\t\tauthorMenuItem = { ...authorMenuItem, templatePrefix: 'author' };\n\t\tauthorMenuItem.onClick = ( template ) => {\n\t\t\tonClickMenuItem( {\n\t\t\t\ttype: 'root',\n\t\t\t\tslug: 'user',\n\t\t\t\tconfig: {\n\t\t\t\t\tqueryArgs: ( { search } ) => {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t_fields: 'id,name,slug,link',\n\t\t\t\t\t\t\torderBy: search ? 'name' : 'registered_date',\n\t\t\t\t\t\t\texclude: authorInfo.user.existingEntitiesIds,\n\t\t\t\t\t\t\twho: 'authors',\n\t\t\t\t\t\t};\n\t\t\t\t\t},\n\t\t\t\t\tgetSpecificTemplate: ( suggestion ) => {\n\t\t\t\t\t\tconst templateSlug = `author-${ suggestion.slug }`;\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\ttitle: sprintf(\n\t\t\t\t\t\t\t\t// translators: %s: Name of the author e.g: \"Admin\".\n\t\t\t\t\t\t\t\t__( 'Author: %s' ),\n\t\t\t\t\t\t\t\tsuggestion.name\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tslug: templateSlug,\n\t\t\t\t\t\t\ttemplatePrefix: 'author',\n\t\t\t\t\t\t};\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tlabels: {\n\t\t\t\t\tsingular_name: __( 'Author' ),\n\t\t\t\t\tsearch_items: __( 'Search Authors' ),\n\t\t\t\t\tnot_found: __( 'No authors found.' ),\n\t\t\t\t\tall_items: __( 'All Authors' ),\n\t\t\t\t},\n\t\t\t\thasGeneralTemplate,\n\t\t\t\ttemplate,\n\t\t\t} );\n\t\t};\n\t}\n\tif ( ! hasGeneralTemplate || authorInfo.user?.hasEntities ) {\n\t\treturn authorMenuItem;\n\t}\n}\n\n/**\n * Helper hook that returns information about an entity having\n * records that we can create a specific template for.\n *\n * For example we can search for `terms` in `taxonomy` entity or\n * `posts` in `postType` entity.\n *\n * First we need to find the existing records with an associated template,\n * to query afterwards for any remaining record, by excluding them.\n *\n * @param {string} entityName The entity's name.\n * @param {Record<string,string>} templatePrefixes An object with the entity's slug as key and the template prefix as value.\n * @param {Record<string,Object>} additionalQueryParameters An object with the entity's slug as key and additional query parameters as value.\n * @return {Record<string,EntitiesInfo>} An object with the entity's slug as key and the EntitiesInfo as value.\n */\nconst useEntitiesInfo = (\n\tentityName,\n\ttemplatePrefixes,\n\tadditionalQueryParameters = EMPTY_OBJECT\n) => {\n\tconst entitiesHasRecords = useSelect(\n\t\t( select ) => {\n\t\t\treturn Object.keys( templatePrefixes || {} ).reduce(\n\t\t\t\t( accumulator, slug ) => {\n\t\t\t\t\taccumulator[ slug ] = !! select(\n\t\t\t\t\t\tcoreStore\n\t\t\t\t\t).getEntityRecords( entityName, slug, {\n\t\t\t\t\t\tper_page: 1,\n\t\t\t\t\t\t_fields: 'id',\n\t\t\t\t\t\tcontext: 'view',\n\t\t\t\t\t\t...additionalQueryParameters[ slug ],\n\t\t\t\t\t} )?.length;\n\t\t\t\t\treturn accumulator;\n\t\t\t\t},\n\t\t\t\t{}\n\t\t\t);\n\t\t},\n\t\t[ templatePrefixes, entityName, additionalQueryParameters ]\n\t);\n\tconst entitiesInfo = useMemo( () => {\n\t\treturn Object.keys( templatePrefixes || {} ).reduce(\n\t\t\t( accumulator, slug ) => {\n\t\t\t\taccumulator[ slug ] = {\n\t\t\t\t\thasEntities: entitiesHasRecords[ slug ],\n\t\t\t\t};\n\t\t\t\treturn accumulator;\n\t\t\t},\n\t\t\t{}\n\t\t);\n\t}, [ templatePrefixes, entitiesHasRecords ] );\n\treturn entitiesInfo;\n};\n"],"mappings":";;;;;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,aAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AAKA,IAAAM,UAAA,GAAAN,OAAA;AAbA;AACA;AACA;;AAQA;AACA;AACA;;AAGA,MAAMO,YAAY,GAAG,CAAC,CAAC;;AAEvB;AACA;AACA;AACA;AACA;;AAEA,MAAMC,sBAAsB,GAAGA,CAAEC,MAAM,EAAEC,IAAI,KAAM;EAClD,IAAIC,KAAK,GAAGF,MAAM;EAClBC,IAAI,CAACE,KAAK,CAAE,GAAI,CAAC,CAACC,OAAO,CAAIC,SAAS,IAAM;IAC3CH,KAAK,GAAGA,KAAK,GAAIG,SAAS,CAAE;EAC7B,CAAE,CAAC;EACH,OAAOH,KAAK;AACb,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMI,kBAAkB,GAAGA,CAAEC,QAAQ,EAAEN,IAAI,KAAM;EACvD,OAAO,CAAEM,QAAQ,IAAI,EA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ACA;AACA;AACA,MAAM9C,eAAe,GAAGA,CACvBkD,UAAU,EACVrD,gBAAgB,EAChBsD,yBAAyB,GAAGjI,YAAY,KACpC;EACJ,MAAMkI,kBAAkB,GAAG,IAAAlH,eAAS,EACjCC,MAAM,IAAM;IACb,OAAOkH,MAAM,CAACC,IAAI,CAAEzD,gBAAgB,IAAI,CAAC,CAAE,CAAC,CAACzB,MAAM,CAClD,CAAEC,WAAW,EAAEnB,IAAI,KAAM;MACxBmB,WAAW,CAAEnB,IAAI,CAAE,GAAG,CAAC,CAAEf,MAAM,CAC9BC,eACD,CAAC,CAACC,gBAAgB,CAAE6G,UAAU,EAAEhG,IAAI,EAAE;QACrCX,QAAQ,EAAE,CAAC;QACX4E,OAAO,EAAE,IAAI;QACboC,OAAO,EAAE,MAAM;QACf,GAAGJ,yBAAyB,CAAEjG,IAAI;MACnC,CAAE,CAAC,EAAEsG,MAAM;MACX,OAAOnF,WAAW;IACnB,CAAC,EACD,CAAC,CACF,CAAC;EACF,CAAC,EACD,CAAEwB,gBAAgB,EAAEqD,UAAU,EAAEC,yBAAyB,CAC1D,CAAC;EACD,MAAMM,YAAY,GAAG,IAAA3G,gBAAO,EAAE,MAAM;IACnC,OAAOuG,MAAM,CAACC,IAAI,CAAEzD,gBAAgB,IAAI,CAAC,CAAE,CAAC,CAACzB,MAAM,CAClD,CAAEC,WAAW,EAAEnB,IAAI,KAAM;MACxBmB,WAAW,CAAEnB,IAAI,CAAE,GAAG;QACrByD,WAAW,EAAEyC,kBAAkB,CAAElG,IAAI;MACtC,CAAC;MACD,OAAOmB,WAAW;IACnB,CAAC,EACD,CAAC,CACF,CAAC;EACF,CAAC,EAAE,CAAEwB,gBAAgB,EAAEuD,kBAAkB,CAAG,CAAC;EAC7C,OAAOK,YAAY;AACpB,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_data","require","_coreData","_htmlEntities","_element","_i18n","_icons","_url","_constants","EMPTY_OBJECT","getValueFromObjectPath","object","path","value","split","forEach","fieldName","prefixSlug","prefix","slug","safeDecodeURI","mapToIHasNameAndId","entities","map","entity","name","decodeEntities","exports","useExistingTemplates","useSelect","select","coreStore","getEntityRecords","TEMPLATE_POST_TYPE","per_page","useDefaultTemplateTypes","getCurrentTheme","default_template_types","usePublicPostTypes","postTypes","getPostTypes","useMemo","excludedPostTypes","filter","viewable","includes","sort","a","b","localeCompare","usePublicTaxonomies","taxonomies","getTaxonomies","visibility","publicly_queryable","usePostTypeArchiveMenuItems","publicPostTypes","postTypesWithArchives","postType","has_archive","existingTemplates","postTypeLabels","reduce","accumulator","labels","singularName","singular_name","toLowerCase","needsUniqueIdentifier","useCallback","some","existingTemplate","title","sprintf","__","description","icon","startsWith","slice","archive","templatePrefix","usePostTypeMenuItems","onClickMenuItem","defaultTemplateTypes","templateLabels","templateName","template_name","templatePrefixes","suffix","postTypesInfo","useEntitiesInfo","menuItems","generalTemplateSlug","defaultTemplateType","find","_slug","_needsUniqueIdentifier","menuItemTitle","_x","menuItem","post","hasEntities","onClick","template","type","config","recordNamePath","queryArgs","search","_fields","orderBy","exclude","existingEntitiesIds","getSpecificTemplate","suggestion","templateSlug","push","postTypesMenuItems","key","defaultPostTypesMenuItems","useTaxonomiesMenuItems","publicTaxonomies","taxonomyLabels","taxonomiesInfo","existingTemplateSlugs","taxonomy","hasGeneralTemplate","blockMeta","taxonomiesMenuItems","defaultTaxonomiesMenuItems","USE_AUTHOR_MENU_ITEM_TEMPLATE_PREFIX","user","USE_AUTHOR_MENU_ITEM_QUERY_PARAMETERS","who","useAuthorMenuItem","authorInfo","authorMenuItem","search_items","not_found","all_items","entityName","additionalQueryParameters","entitiesHasRecords","Object","keys","context","length","entitiesInfo"],"sources":["@wordpress/edit-site/src/components/add-new-template/utils.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { useMemo, useCallback } from '@wordpress/element';\nimport { __, _x, sprintf } from '@wordpress/i18n';\nimport { blockMeta, post, archive } from '@wordpress/icons';\nimport { safeDecodeURI } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport { TEMPLATE_POST_TYPE } from '../../utils/constants';\n\nconst EMPTY_OBJECT = {};\n\n/**\n * @typedef IHasNameAndId\n * @property {string|number} id The entity's id.\n * @property {string} name The entity's name.\n */\n\nconst getValueFromObjectPath = ( object, path ) => {\n\tlet value = object;\n\tpath.split( '.' ).forEach( ( fieldName ) => {\n\t\tvalue = value?.[ fieldName ];\n\t} );\n\treturn value;\n};\n\n/**\n * Helper that adds a prefix to a post slug. The slug needs to be URL-decoded first,\n * so that we have raw Unicode characters there. The server will truncate the slug to\n * 200 characters, respecing Unicode char boundary. On the other hand, the server\n * doesn't detect urlencoded octet boundary and can possibly construct slugs that\n * are not valid urlencoded strings.\n * @param {string} prefix The prefix to add to the slug.\n * @param {string} slug The slug to add the prefix to.\n * @return {string} The slug with the prefix.\n */\nfunction prefixSlug( prefix, slug ) {\n\treturn `${ prefix }-${ safeDecodeURI( slug ) }`;\n}\n\n/**\n * Helper util to map records to add a `name` prop from a\n * provided path, in order to handle all entities in the same\n * fashion(implementing`IHasNameAndId` interface).\n *\n * @param {Object[]} entities The array of entities.\n * @param {string} path The path to map a `name` property from the entity.\n * @return {IHasNameAndId[]} An array of entities that now implement the `IHasNameAndId` interface.\n */\nexport const mapToIHasNameAndId = ( entities, path ) => {\n\treturn ( entities || [] ).map( ( entity ) => ( {\n\t\t...entity,\n\t\tname: decodeEntities( getValueFromObjectPath( entity, path ) ),\n\t} ) );\n};\n\n/**\n * @typedef {Object} EntitiesInfo\n * @property {boolean} hasEntities If an entity has available records(posts, terms, etc..).\n * @property {number[]} existingEntitiesIds An array of the existing entities ids.\n */\n\nexport const useExistingTemplates = () => {\n\treturn useSelect(\n\t\t( select ) =>\n\t\t\tselect( coreStore ).getEntityRecords(\n\t\t\t\t'postType',\n\t\t\t\tTEMPLATE_POST_TYPE,\n\t\t\t\t{\n\t\t\t\t\tper_page: -1,\n\t\t\t\t}\n\t\t\t),\n\t\t[]\n\t);\n};\n\nexport const useDefaultTemplateTypes = () => {\n\treturn useSelect(\n\t\t( select ) =>\n\t\t\tselect( coreStore ).getCurrentTheme()?.default_template_types || [],\n\t\t[]\n\t);\n};\n\nconst usePublicPostTypes = () => {\n\tconst postTypes = useSelect(\n\t\t( select ) => select( coreStore ).getPostTypes( { per_page: -1 } ),\n\t\t[]\n\t);\n\treturn useMemo( () => {\n\t\tconst excludedPostTypes = [ 'attachment' ];\n\t\treturn postTypes\n\t\t\t?.filter(\n\t\t\t\t( { viewable, slug } ) =>\n\t\t\t\t\tviewable && ! excludedPostTypes.includes( slug )\n\t\t\t)\n\t\t\t.sort( ( a, b ) => {\n\t\t\t\t// Sort post types alphabetically by name,\n\t\t\t\t// but exclude the built-in 'post' type from sorting.\n\t\t\t\tif ( a.slug === 'post' || b.slug === 'post' ) {\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\n\t\t\t\treturn a.name.localeCompare( b.name );\n\t\t\t} );\n\t}, [ postTypes ] );\n};\n\nconst usePublicTaxonomies = () => {\n\tconst taxonomies = useSelect(\n\t\t( select ) => select( coreStore ).getTaxonomies( { per_page: -1 } ),\n\t\t[]\n\t);\n\treturn useMemo( () => {\n\t\treturn taxonomies?.filter(\n\t\t\t( { visibility } ) => visibility?.publicly_queryable\n\t\t);\n\t}, [ taxonomies ] );\n};\n\nexport function usePostTypeArchiveMenuItems() {\n\tconst publicPostTypes = usePublicPostTypes();\n\tconst postTypesWithArchives = useMemo(\n\t\t() => publicPostTypes?.filter( ( postType ) => postType.has_archive ),\n\t\t[ publicPostTypes ]\n\t);\n\tconst existingTemplates = useExistingTemplates();\n\t// We need to keep track of naming conflicts. If a conflict\n\t// occurs, we need to add slug.\n\tconst postTypeLabels = useMemo(\n\t\t() =>\n\t\t\tpublicPostTypes?.reduce( ( accumulator, { labels } ) => {\n\t\t\t\tconst singularName = labels.singular_name.toLowerCase();\n\t\t\t\taccumulator[ singularName ] =\n\t\t\t\t\t( accumulator[ singularName ] || 0 ) + 1;\n\t\t\t\treturn accumulator;\n\t\t\t}, {} ),\n\t\t[ publicPostTypes ]\n\t);\n\tconst needsUniqueIdentifier = useCallback(\n\t\t( { labels, slug } ) => {\n\t\t\tconst singularName = labels.singular_name.toLowerCase();\n\t\t\treturn postTypeLabels[ singularName ] > 1 && singularName !== slug;\n\t\t},\n\t\t[ postTypeLabels ]\n\t);\n\treturn useMemo(\n\t\t() =>\n\t\t\tpostTypesWithArchives\n\t\t\t\t?.filter(\n\t\t\t\t\t( postType ) =>\n\t\t\t\t\t\t! ( existingTemplates || [] ).some(\n\t\t\t\t\t\t\t( existingTemplate ) =>\n\t\t\t\t\t\t\t\texistingTemplate.slug ===\n\t\t\t\t\t\t\t\t'archive-' + postType.slug\n\t\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t\t.map( ( postType ) => {\n\t\t\t\t\tlet title;\n\t\t\t\t\tif ( needsUniqueIdentifier( postType ) ) {\n\t\t\t\t\t\ttitle = sprintf(\n\t\t\t\t\t\t\t// translators: %1s: Name of the post type e.g: \"Post\"; %2s: Slug of the post type e.g: \"book\".\n\t\t\t\t\t\t\t__( 'Archive: %1$s (%2$s)' ),\n\t\t\t\t\t\t\tpostType.labels.singular_name,\n\t\t\t\t\t\t\tpostType.slug\n\t\t\t\t\t\t);\n\t\t\t\t\t} else {\n\t\t\t\t\t\ttitle = sprintf(\n\t\t\t\t\t\t\t// translators: %s: Name of the post type e.g: \"Post\".\n\t\t\t\t\t\t\t__( 'Archive: %s' ),\n\t\t\t\t\t\t\tpostType.labels.singular_name\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\treturn {\n\t\t\t\t\t\tslug: 'archive-' + postType.slug,\n\t\t\t\t\t\tdescription: sprintf(\n\t\t\t\t\t\t\t// translators: %s: Name of the post type e.g: \"Post\".\n\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t'Displays an archive with the latest posts of type: %s.'\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tpostType.labels.singular_name\n\t\t\t\t\t\t),\n\t\t\t\t\t\ttitle,\n\t\t\t\t\t\t// `icon` is the `menu_icon` property of a post type. We\n\t\t\t\t\t\t// only handle `dashicons` for now, even if the `menu_icon`\n\t\t\t\t\t\t// also supports urls and svg as values.\n\t\t\t\t\t\ticon:\n\t\t\t\t\t\t\ttypeof postType.icon === 'string' &&\n\t\t\t\t\t\t\tpostType.icon.startsWith( 'dashicons-' )\n\t\t\t\t\t\t\t\t? postType.icon.slice( 10 )\n\t\t\t\t\t\t\t\t: archive,\n\t\t\t\t\t\ttemplatePrefix: 'archive',\n\t\t\t\t\t};\n\t\t\t\t} ) || [],\n\t\t[ postTypesWithArchives, existingTemplates, needsUniqueIdentifier ]\n\t);\n}\n\nexport const usePostTypeMenuItems = ( onClickMenuItem ) => {\n\tconst publicPostTypes = usePublicPostTypes();\n\tconst defaultTemplateTypes = useDefaultTemplateTypes();\n\t// We need to keep track of naming conflicts. If a conflict\n\t// occurs, we need to add slug.\n\tconst templateLabels = useMemo(\n\t\t() =>\n\t\t\tpublicPostTypes?.reduce( ( accumulator, { labels } ) => {\n\t\t\t\tconst templateName = (\n\t\t\t\t\tlabels.template_name || labels.singular_name\n\t\t\t\t).toLowerCase();\n\t\t\t\taccumulator[ templateName ] =\n\t\t\t\t\t( accumulator[ templateName ] || 0 ) + 1;\n\t\t\t\treturn accumulator;\n\t\t\t}, {} ),\n\t\t[ publicPostTypes ]\n\t);\n\tconst needsUniqueIdentifier = useCallback(\n\t\t( { labels, slug } ) => {\n\t\t\tconst templateName = (\n\t\t\t\tlabels.template_name || labels.singular_name\n\t\t\t).toLowerCase();\n\t\t\treturn templateLabels[ templateName ] > 1 && templateName !== slug;\n\t\t},\n\t\t[ templateLabels ]\n\t);\n\n\t// `page`is a special case in template hierarchy.\n\tconst templatePrefixes = useMemo(\n\t\t() =>\n\t\t\tpublicPostTypes?.reduce( ( accumulator, { slug } ) => {\n\t\t\t\tlet suffix = slug;\n\t\t\t\tif ( slug !== 'page' ) {\n\t\t\t\t\tsuffix = `single-${ suffix }`;\n\t\t\t\t}\n\t\t\t\taccumulator[ slug ] = suffix;\n\t\t\t\treturn accumulator;\n\t\t\t}, {} ),\n\t\t[ publicPostTypes ]\n\t);\n\tconst postTypesInfo = useEntitiesInfo( 'postType', templatePrefixes );\n\tconst menuItems = ( publicPostTypes || [] ).reduce(\n\t\t( accumulator, postType ) => {\n\t\t\tconst { slug, labels, icon } = postType;\n\t\t\t// We need to check if the general template is part of the\n\t\t\t// defaultTemplateTypes. If it is, just use that info and\n\t\t\t// augment it with the specific template functionality.\n\t\t\tconst generalTemplateSlug = templatePrefixes[ slug ];\n\t\t\tconst defaultTemplateType = defaultTemplateTypes?.find(\n\t\t\t\t( { slug: _slug } ) => _slug === generalTemplateSlug\n\t\t\t);\n\t\t\tconst _needsUniqueIdentifier = needsUniqueIdentifier( postType );\n\t\t\tlet menuItemTitle =\n\t\t\t\tlabels.template_name ||\n\t\t\t\tsprintf(\n\t\t\t\t\t// translators: %s: Name of the post type e.g: \"Post\".\n\t\t\t\t\t__( 'Single item: %s' ),\n\t\t\t\t\tlabels.singular_name\n\t\t\t\t);\n\t\t\tif ( _needsUniqueIdentifier ) {\n\t\t\t\tmenuItemTitle = labels.template_name\n\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t// translators: 1: Name of the template e.g: \"Single Item: Post\". 2: Slug of the post type e.g: \"book\".\n\t\t\t\t\t\t\t_x( '%1$s (%2$s)', 'post type menu label' ),\n\t\t\t\t\t\t\tlabels.template_name,\n\t\t\t\t\t\t\tslug\n\t\t\t\t\t )\n\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t// translators: 1: Name of the post type e.g: \"Post\". 2: Slug of the post type e.g: \"book\".\n\t\t\t\t\t\t\t_x(\n\t\t\t\t\t\t\t\t'Single item: %1$s (%2$s)',\n\t\t\t\t\t\t\t\t'post type menu label'\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tlabels.singular_name,\n\t\t\t\t\t\t\tslug\n\t\t\t\t\t );\n\t\t\t}\n\t\t\tconst menuItem = defaultTemplateType\n\t\t\t\t? {\n\t\t\t\t\t\t...defaultTemplateType,\n\t\t\t\t\t\ttemplatePrefix: templatePrefixes[ slug ],\n\t\t\t\t }\n\t\t\t\t: {\n\t\t\t\t\t\tslug: generalTemplateSlug,\n\t\t\t\t\t\ttitle: menuItemTitle,\n\t\t\t\t\t\tdescription: sprintf(\n\t\t\t\t\t\t\t// translators: %s: Name of the post type e.g: \"Post\".\n\t\t\t\t\t\t\t__( 'Displays a single item: %s.' ),\n\t\t\t\t\t\t\tlabels.singular_name\n\t\t\t\t\t\t),\n\t\t\t\t\t\t// `icon` is the `menu_icon` property of a post type. We\n\t\t\t\t\t\t// only handle `dashicons` for now, even if the `menu_icon`\n\t\t\t\t\t\t// also supports urls and svg as values.\n\t\t\t\t\t\ticon:\n\t\t\t\t\t\t\ttypeof icon === 'string' &&\n\t\t\t\t\t\t\ticon.startsWith( 'dashicons-' )\n\t\t\t\t\t\t\t\t? icon.slice( 10 )\n\t\t\t\t\t\t\t\t: post,\n\t\t\t\t\t\ttemplatePrefix: templatePrefixes[ slug ],\n\t\t\t\t };\n\t\t\tconst hasEntities = postTypesInfo?.[ slug ]?.hasEntities;\n\t\t\t// We have a different template creation flow only if they have entities.\n\t\t\tif ( hasEntities ) {\n\t\t\t\tmenuItem.onClick = ( template ) => {\n\t\t\t\t\tonClickMenuItem( {\n\t\t\t\t\t\ttype: 'postType',\n\t\t\t\t\t\tslug,\n\t\t\t\t\t\tconfig: {\n\t\t\t\t\t\t\trecordNamePath: 'title.rendered',\n\t\t\t\t\t\t\tqueryArgs: ( { search } ) => {\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t_fields: 'id,title,slug,link',\n\t\t\t\t\t\t\t\t\torderBy: search ? 'relevance' : 'modified',\n\t\t\t\t\t\t\t\t\texclude:\n\t\t\t\t\t\t\t\t\t\tpostTypesInfo[ slug ]\n\t\t\t\t\t\t\t\t\t\t\t.existingEntitiesIds,\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tgetSpecificTemplate: ( suggestion ) => {\n\t\t\t\t\t\t\t\tconst templateSlug = prefixSlug(\n\t\t\t\t\t\t\t\t\ttemplatePrefixes[ slug ],\n\t\t\t\t\t\t\t\t\tsuggestion.slug\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\ttitle: templateSlug,\n\t\t\t\t\t\t\t\t\tslug: templateSlug,\n\t\t\t\t\t\t\t\t\ttemplatePrefix: templatePrefixes[ slug ],\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t\tlabels,\n\t\t\t\t\t\ttemplate,\n\t\t\t\t\t} );\n\t\t\t\t};\n\t\t\t}\n\t\t\t// We don't need to add the menu item if there are no entities.\n\t\t\tif ( hasEntities ) {\n\t\t\t\taccumulator.push( menuItem );\n\t\t\t}\n\t\t\treturn accumulator;\n\t\t},\n\t\t[]\n\t);\n\t// Split menu items into two groups: one for the default post types\n\t// and one for the rest.\n\tconst postTypesMenuItems = useMemo(\n\t\t() =>\n\t\t\tmenuItems.reduce(\n\t\t\t\t( accumulator, postType ) => {\n\t\t\t\t\tconst { slug } = postType;\n\t\t\t\t\tlet key = 'postTypesMenuItems';\n\t\t\t\t\tif ( slug === 'page' ) {\n\t\t\t\t\t\tkey = 'defaultPostTypesMenuItems';\n\t\t\t\t\t}\n\t\t\t\t\taccumulator[ key ].push( postType );\n\t\t\t\t\treturn accumulator;\n\t\t\t\t},\n\t\t\t\t{ defaultPostTypesMenuItems: [], postTypesMenuItems: [] }\n\t\t\t),\n\t\t[ menuItems ]\n\t);\n\treturn postTypesMenuItems;\n};\n\nexport const useTaxonomiesMenuItems = ( onClickMenuItem ) => {\n\tconst publicTaxonomies = usePublicTaxonomies();\n\tconst existingTemplates = useExistingTemplates();\n\tconst defaultTemplateTypes = useDefaultTemplateTypes();\n\t// `category` and `post_tag` are special cases in template hierarchy.\n\tconst templatePrefixes = useMemo(\n\t\t() =>\n\t\t\tpublicTaxonomies?.reduce( ( accumulator, { slug } ) => {\n\t\t\t\tlet suffix = slug;\n\t\t\t\tif ( ! [ 'category', 'post_tag' ].includes( slug ) ) {\n\t\t\t\t\tsuffix = `taxonomy-${ suffix }`;\n\t\t\t\t}\n\t\t\t\tif ( slug === 'post_tag' ) {\n\t\t\t\t\tsuffix = `tag`;\n\t\t\t\t}\n\t\t\t\taccumulator[ slug ] = suffix;\n\t\t\t\treturn accumulator;\n\t\t\t}, {} ),\n\t\t[ publicTaxonomies ]\n\t);\n\t// We need to keep track of naming conflicts. If a conflict\n\t// occurs, we need to add slug.\n\tconst taxonomyLabels = publicTaxonomies?.reduce(\n\t\t( accumulator, { labels } ) => {\n\t\t\tconst templateName = (\n\t\t\t\tlabels.template_name || labels.singular_name\n\t\t\t).toLowerCase();\n\t\t\taccumulator[ templateName ] =\n\t\t\t\t( accumulator[ templateName ] || 0 ) + 1;\n\t\t\treturn accumulator;\n\t\t},\n\t\t{}\n\t);\n\tconst needsUniqueIdentifier = ( labels, slug ) => {\n\t\tif ( [ 'category', 'post_tag' ].includes( slug ) ) {\n\t\t\treturn false;\n\t\t}\n\t\tconst templateName = (\n\t\t\tlabels.template_name || labels.singular_name\n\t\t).toLowerCase();\n\t\treturn taxonomyLabels[ templateName ] > 1 && templateName !== slug;\n\t};\n\tconst taxonomiesInfo = useEntitiesInfo( 'taxonomy', templatePrefixes );\n\tconst existingTemplateSlugs = ( existingTemplates || [] ).map(\n\t\t( { slug } ) => slug\n\t);\n\tconst menuItems = ( publicTaxonomies || [] ).reduce(\n\t\t( accumulator, taxonomy ) => {\n\t\t\tconst { slug, labels } = taxonomy;\n\t\t\t// We need to check if the general template is part of the\n\t\t\t// defaultTemplateTypes. If it is, just use that info and\n\t\t\t// augment it with the specific template functionality.\n\t\t\tconst generalTemplateSlug = templatePrefixes[ slug ];\n\t\t\tconst defaultTemplateType = defaultTemplateTypes?.find(\n\t\t\t\t( { slug: _slug } ) => _slug === generalTemplateSlug\n\t\t\t);\n\t\t\tconst hasGeneralTemplate =\n\t\t\t\texistingTemplateSlugs?.includes( generalTemplateSlug );\n\t\t\tconst _needsUniqueIdentifier = needsUniqueIdentifier(\n\t\t\t\tlabels,\n\t\t\t\tslug\n\t\t\t);\n\t\t\tlet menuItemTitle = labels.template_name || labels.singular_name;\n\t\t\tif ( _needsUniqueIdentifier ) {\n\t\t\t\tmenuItemTitle = labels.template_name\n\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t// translators: 1: Name of the template e.g: \"Products by Category\". 2: Slug of the taxonomy e.g: \"product_cat\".\n\t\t\t\t\t\t\t_x( '%1$s (%2$s)', 'taxonomy template menu label' ),\n\t\t\t\t\t\t\tlabels.template_name,\n\t\t\t\t\t\t\tslug\n\t\t\t\t\t )\n\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t// translators: 1: Name of the taxonomy e.g: \"Category\". 2: Slug of the taxonomy e.g: \"product_cat\".\n\t\t\t\t\t\t\t_x( '%1$s (%2$s)', 'taxonomy menu label' ),\n\t\t\t\t\t\t\tlabels.singular_name,\n\t\t\t\t\t\t\tslug\n\t\t\t\t\t );\n\t\t\t}\n\t\t\tconst menuItem = defaultTemplateType\n\t\t\t\t? {\n\t\t\t\t\t\t...defaultTemplateType,\n\t\t\t\t\t\ttemplatePrefix: templatePrefixes[ slug ],\n\t\t\t\t }\n\t\t\t\t: {\n\t\t\t\t\t\tslug: generalTemplateSlug,\n\t\t\t\t\t\ttitle: menuItemTitle,\n\t\t\t\t\t\tdescription: sprintf(\n\t\t\t\t\t\t\t// translators: %s: Name of the taxonomy e.g: \"Product Categories\".\n\t\t\t\t\t\t\t__( 'Displays taxonomy: %s.' ),\n\t\t\t\t\t\t\tlabels.singular_name\n\t\t\t\t\t\t),\n\t\t\t\t\t\ticon: blockMeta,\n\t\t\t\t\t\ttemplatePrefix: templatePrefixes[ slug ],\n\t\t\t\t };\n\t\t\tconst hasEntities = taxonomiesInfo?.[ slug ]?.hasEntities;\n\t\t\t// We have a different template creation flow only if they have entities.\n\t\t\tif ( hasEntities ) {\n\t\t\t\tmenuItem.onClick = ( template ) => {\n\t\t\t\t\tonClickMenuItem( {\n\t\t\t\t\t\ttype: 'taxonomy',\n\t\t\t\t\t\tslug,\n\t\t\t\t\t\tconfig: {\n\t\t\t\t\t\t\tqueryArgs: ( { search } ) => {\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t_fields: 'id,name,slug,link',\n\t\t\t\t\t\t\t\t\torderBy: search ? 'name' : 'count',\n\t\t\t\t\t\t\t\t\texclude:\n\t\t\t\t\t\t\t\t\t\ttaxonomiesInfo[ slug ]\n\t\t\t\t\t\t\t\t\t\t\t.existingEntitiesIds,\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tgetSpecificTemplate: ( suggestion ) => {\n\t\t\t\t\t\t\t\tconst templateSlug = prefixSlug(\n\t\t\t\t\t\t\t\t\ttemplatePrefixes[ slug ],\n\t\t\t\t\t\t\t\t\tsuggestion.slug\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\ttitle: templateSlug,\n\t\t\t\t\t\t\t\t\tslug: templateSlug,\n\t\t\t\t\t\t\t\t\ttemplatePrefix: templatePrefixes[ slug ],\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t\tlabels,\n\t\t\t\t\t\thasGeneralTemplate,\n\t\t\t\t\t\ttemplate,\n\t\t\t\t\t} );\n\t\t\t\t};\n\t\t\t}\n\t\t\t// We don't need to add the menu item if there are no\n\t\t\t// entities and the general template exists.\n\t\t\tif ( ! hasGeneralTemplate || hasEntities ) {\n\t\t\t\taccumulator.push( menuItem );\n\t\t\t}\n\t\t\treturn accumulator;\n\t\t},\n\t\t[]\n\t);\n\t// Split menu items into two groups: one for the default taxonomies\n\t// and one for the rest.\n\tconst taxonomiesMenuItems = useMemo(\n\t\t() =>\n\t\t\tmenuItems.reduce(\n\t\t\t\t( accumulator, taxonomy ) => {\n\t\t\t\t\tconst { slug } = taxonomy;\n\t\t\t\t\tlet key = 'taxonomiesMenuItems';\n\t\t\t\t\tif ( [ 'category', 'tag' ].includes( slug ) ) {\n\t\t\t\t\t\tkey = 'defaultTaxonomiesMenuItems';\n\t\t\t\t\t}\n\t\t\t\t\taccumulator[ key ].push( taxonomy );\n\t\t\t\t\treturn accumulator;\n\t\t\t\t},\n\t\t\t\t{ defaultTaxonomiesMenuItems: [], taxonomiesMenuItems: [] }\n\t\t\t),\n\t\t[ menuItems ]\n\t);\n\treturn taxonomiesMenuItems;\n};\n\nconst USE_AUTHOR_MENU_ITEM_TEMPLATE_PREFIX = { user: 'author' };\nconst USE_AUTHOR_MENU_ITEM_QUERY_PARAMETERS = { user: { who: 'authors' } };\nexport function useAuthorMenuItem( onClickMenuItem ) {\n\tconst existingTemplates = useExistingTemplates();\n\tconst defaultTemplateTypes = useDefaultTemplateTypes();\n\tconst authorInfo = useEntitiesInfo(\n\t\t'root',\n\t\tUSE_AUTHOR_MENU_ITEM_TEMPLATE_PREFIX,\n\t\tUSE_AUTHOR_MENU_ITEM_QUERY_PARAMETERS\n\t);\n\tlet authorMenuItem = defaultTemplateTypes?.find(\n\t\t( { slug } ) => slug === 'author'\n\t);\n\tif ( ! authorMenuItem ) {\n\t\tauthorMenuItem = {\n\t\t\tdescription: __(\n\t\t\t\t'Displays latest posts written by a single author.'\n\t\t\t),\n\t\t\tslug: 'author',\n\t\t\ttitle: 'Author',\n\t\t};\n\t}\n\tconst hasGeneralTemplate = !! existingTemplates?.find(\n\t\t( { slug } ) => slug === 'author'\n\t);\n\tif ( authorInfo.user?.hasEntities ) {\n\t\tauthorMenuItem = { ...authorMenuItem, templatePrefix: 'author' };\n\t\tauthorMenuItem.onClick = ( template ) => {\n\t\t\tonClickMenuItem( {\n\t\t\t\ttype: 'root',\n\t\t\t\tslug: 'user',\n\t\t\t\tconfig: {\n\t\t\t\t\tqueryArgs: ( { search } ) => {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t_fields: 'id,name,slug,link',\n\t\t\t\t\t\t\torderBy: search ? 'name' : 'registered_date',\n\t\t\t\t\t\t\texclude: authorInfo.user.existingEntitiesIds,\n\t\t\t\t\t\t\twho: 'authors',\n\t\t\t\t\t\t};\n\t\t\t\t\t},\n\t\t\t\t\tgetSpecificTemplate: ( suggestion ) => {\n\t\t\t\t\t\tconst templateSlug = prefixSlug(\n\t\t\t\t\t\t\t'author',\n\t\t\t\t\t\t\tsuggestion.slug\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\ttitle: sprintf(\n\t\t\t\t\t\t\t\t// translators: %s: Name of the author e.g: \"Admin\".\n\t\t\t\t\t\t\t\t__( 'Author: %s' ),\n\t\t\t\t\t\t\t\tsuggestion.name\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tslug: templateSlug,\n\t\t\t\t\t\t\ttemplatePrefix: 'author',\n\t\t\t\t\t\t};\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tlabels: {\n\t\t\t\t\tsingular_name: __( 'Author' ),\n\t\t\t\t\tsearch_items: __( 'Search Authors' ),\n\t\t\t\t\tnot_found: __( 'No authors found.' ),\n\t\t\t\t\tall_items: __( 'All Authors' ),\n\t\t\t\t},\n\t\t\t\thasGeneralTemplate,\n\t\t\t\ttemplate,\n\t\t\t} );\n\t\t};\n\t}\n\tif ( ! hasGeneralTemplate || authorInfo.user?.hasEntities ) {\n\t\treturn authorMenuItem;\n\t}\n}\n\n/**\n * Helper hook that returns information about an entity having\n * records that we can create a specific template for.\n *\n * For example we can search for `terms` in `taxonomy` entity or\n * `posts` in `postType` entity.\n *\n * First we need to find the existing records with an associated template,\n * to query afterwards for any remaining record, by excluding them.\n *\n * @param {string} entityName The entity's name.\n * @param {Record<string,string>} templatePrefixes An object with the entity's slug as key and the template prefix as value.\n * @param {Record<string,Object>} additionalQueryParameters An object with the entity's slug as key and additional query parameters as value.\n * @return {Record<string,EntitiesInfo>} An object with the entity's slug as key and the EntitiesInfo as value.\n */\nconst useEntitiesInfo = (\n\tentityName,\n\ttemplatePrefixes,\n\tadditionalQueryParameters = EMPTY_OBJECT\n) => {\n\tconst entitiesHasRecords = useSelect(\n\t\t( select ) => {\n\t\t\treturn Object.keys( templatePrefixes || {} ).reduce(\n\t\t\t\t( accumulator, slug ) => {\n\t\t\t\t\taccumulator[ slug ] = !! select(\n\t\t\t\t\t\tcoreStore\n\t\t\t\t\t).getEntityRecords( entityName, slug, {\n\t\t\t\t\t\tper_page: 1,\n\t\t\t\t\t\t_fields: 'id',\n\t\t\t\t\t\tcontext: 'view',\n\t\t\t\t\t\t...additionalQueryParameters[ slug ],\n\t\t\t\t\t} )?.length;\n\t\t\t\t\treturn accumulator;\n\t\t\t\t},\n\t\t\t\t{}\n\t\t\t);\n\t\t},\n\t\t[ templatePrefixes, entityName, additionalQueryParameters ]\n\t);\n\tconst entitiesInfo = useMemo( () => {\n\t\treturn Object.keys( templatePrefixes || {} ).reduce(\n\t\t\t( accumulator, slug ) => {\n\t\t\t\taccumulator[ slug ] = {\n\t\t\t\t\thasEntities: entitiesHasRecords[ slug ],\n\t\t\t\t};\n\t\t\t\treturn accumulator;\n\t\t\t},\n\t\t\t{}\n\t\t);\n\t}, [ templatePrefixes, entitiesHasRecords ] );\n\treturn entitiesInfo;\n};\n"],"mappings":";;;;;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,aAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAA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,gBAAgB,CAAE4G,UAAU,EAAEzH,IAAI,EAAE;QACrCe,QAAQ,EAAE,CAAC;QACX2E,OAAO,EAAE,IAAI;QACboC,OAAO,EAAE,MAAM;QACf,GAAGJ,yBAAyB,CAAE1H,IAAI;MACnC,CAAE,CAAC,EAAE+H,MAAM;MACX,OAAOnF,WAAW;IACnB,CAAC,EACD,CAAC,CACF,CAAC;EACF,CAAC,EACD,CAAEwB,gBAAgB,EAAEqD,UAAU,EAAEC,yBAAyB,CAC1D,CAAC;EACD,MAAMM,YAAY,GAAG,IAAA1G,gBAAO,EAAE,MAAM;IACnC,OAAOsG,MAAM,CAACC,IAAI,CAAEzD,gBAAgB,IAAI,CAAC,CAAE,CAAC,CAACzB,MAAM,CAClD,CAAEC,WAAW,EAAE5C,IAAI,KAAM;MACxB4C,WAAW,CAAE5C,IAAI,CAAE,GAAG;QACrBkF,WAAW,EAAEyC,kBAAkB,CAAE3H,IAAI;MACtC,CAAC;MACD,OAAO4C,WAAW;IACnB,CAAC,EACD,CAAC,CACF,CAAC;EACF,CAAC,EAAE,CAAEwB,gBAAgB,EAAEuD,kBAAkB,CAAG,CAAC;EAC7C,OAAOK,YAAY;AACpB,CAAC","ignoreList":[]}
|
|
@@ -26,7 +26,6 @@ const {
|
|
|
26
26
|
AdvancedPanel: StylesAdvancedPanel
|
|
27
27
|
} = (0, _lockUnlock.unlock)(_blockEditor.privateApis);
|
|
28
28
|
function ScreenCSS() {
|
|
29
|
-
const description = (0, _i18n.__)('Add your own CSS to customize the appearance and layout of your site.');
|
|
30
29
|
const [style] = useGlobalStyle('', undefined, 'user', {
|
|
31
30
|
shouldDecodeEncode: false
|
|
32
31
|
});
|
|
@@ -38,9 +37,9 @@ function ScreenCSS() {
|
|
|
38
37
|
} = (0, _lockUnlock.unlock)((0, _data.useDispatch)(_store.store));
|
|
39
38
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
40
39
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_header.default, {
|
|
41
|
-
title: (0, _i18n.__)('CSS'),
|
|
40
|
+
title: (0, _i18n.__)('Additional CSS'),
|
|
42
41
|
description: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
43
|
-
children: [
|
|
42
|
+
children: [(0, _i18n.__)('You can add custom CSS to further customize the appearance and layout of your site.'), /*#__PURE__*/(0, _jsxRuntime.jsx)("br", {}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.ExternalLink, {
|
|
44
43
|
href: (0, _i18n.__)('https://developer.wordpress.org/advanced-administration/wordpress/css/'),
|
|
45
44
|
className: "edit-site-global-styles-screen-css-help-link",
|
|
46
45
|
children: (0, _i18n.__)('Learn more about CSS')
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_i18n","require","_components","_blockEditor","_data","_lockUnlock","_store","_header","_interopRequireDefault","_jsxRuntime","useGlobalStyle","AdvancedPanel","StylesAdvancedPanel","unlock","blockEditorPrivateApis","ScreenCSS","
|
|
1
|
+
{"version":3,"names":["_i18n","require","_components","_blockEditor","_data","_lockUnlock","_store","_header","_interopRequireDefault","_jsxRuntime","useGlobalStyle","AdvancedPanel","StylesAdvancedPanel","unlock","blockEditorPrivateApis","ScreenCSS","style","undefined","shouldDecodeEncode","inheritedStyle","setStyle","setEditorCanvasContainerView","useDispatch","editSiteStore","jsxs","Fragment","children","jsx","default","title","__","description","ExternalLink","href","className","onBack","value","onChange","inheritedValue","_default","exports"],"sources":["@wordpress/edit-site/src/components/global-styles/screen-css.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { ExternalLink } from '@wordpress/components';\nimport { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';\nimport { useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\nimport { store as editSiteStore } from '../../store';\nimport ScreenHeader from './header';\n\nconst { useGlobalStyle, AdvancedPanel: StylesAdvancedPanel } = unlock(\n\tblockEditorPrivateApis\n);\n\nfunction ScreenCSS() {\n\tconst [ style ] = useGlobalStyle( '', undefined, 'user', {\n\t\tshouldDecodeEncode: false,\n\t} );\n\tconst [ inheritedStyle, setStyle ] = useGlobalStyle( '', undefined, 'all', {\n\t\tshouldDecodeEncode: false,\n\t} );\n\n\tconst { setEditorCanvasContainerView } = unlock(\n\t\tuseDispatch( editSiteStore )\n\t);\n\n\treturn (\n\t\t<>\n\t\t\t<ScreenHeader\n\t\t\t\ttitle={ __( 'Additional CSS' ) }\n\t\t\t\tdescription={\n\t\t\t\t\t<>\n\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t'You can add custom CSS to further customize the appearance and layout of your site.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t<br />\n\t\t\t\t\t\t<ExternalLink\n\t\t\t\t\t\t\thref={ __(\n\t\t\t\t\t\t\t\t'https://developer.wordpress.org/advanced-administration/wordpress/css/'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\tclassName=\"edit-site-global-styles-screen-css-help-link\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Learn more about CSS' ) }\n\t\t\t\t\t\t</ExternalLink>\n\t\t\t\t\t</>\n\t\t\t\t}\n\t\t\t\tonBack={ () => {\n\t\t\t\t\tsetEditorCanvasContainerView( undefined );\n\t\t\t\t} }\n\t\t\t/>\n\t\t\t<div className=\"edit-site-global-styles-screen-css\">\n\t\t\t\t<StylesAdvancedPanel\n\t\t\t\t\tvalue={ style }\n\t\t\t\t\tonChange={ setStyle }\n\t\t\t\t\tinheritedValue={ inheritedStyle }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t</>\n\t);\n}\n\nexport default ScreenCSS;\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,YAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OA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jB,CAAC;MAAA,CACd,CACF;MACDK,MAAM,EAAGA,CAAA,KAAM;QACdd,4BAA4B,CAAEJ,SAAU,CAAC;MAC1C;IAAG,CACH,CAAC,eACF,IAAAR,WAAA,CAAAkB,GAAA;MAAKO,SAAS,EAAC,oCAAoC;MAAAR,QAAA,eAClD,IAAAjB,WAAA,CAAAkB,GAAA,EAACf,mBAAmB;QACnBwB,KAAK,EAAGpB,KAAO;QACfqB,QAAQ,EAAGjB,QAAU;QACrBkB,cAAc,EAAGnB;MAAgB,CACjC;IAAC,CACE,CAAC;EAAA,CACL,CAAC;AAEL;AAAC,IAAAoB,QAAA,GAAAC,OAAA,CAAAZ,OAAA,GAEcb,SAAS","ignoreList":[]}
|
|
@@ -24,21 +24,11 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
26
|
function ScreenRoot() {
|
|
27
|
-
const {
|
|
28
|
-
hasVariations,
|
|
29
|
-
canEditCSS
|
|
30
|
-
} = (0, _data.useSelect)(select => {
|
|
27
|
+
const hasVariations = (0, _data.useSelect)(select => {
|
|
31
28
|
const {
|
|
32
|
-
getEntityRecord,
|
|
33
|
-
__experimentalGetCurrentGlobalStylesId,
|
|
34
29
|
__experimentalGetCurrentThemeGlobalStylesVariations
|
|
35
30
|
} = select(_coreData.store);
|
|
36
|
-
|
|
37
|
-
const globalStyles = globalStylesId ? getEntityRecord('root', 'globalStyles', globalStylesId) : undefined;
|
|
38
|
-
return {
|
|
39
|
-
hasVariations: !!__experimentalGetCurrentThemeGlobalStylesVariations()?.length,
|
|
40
|
-
canEditCSS: !!globalStyles?._links?.['wp:action-edit-css']
|
|
41
|
-
};
|
|
31
|
+
return !!__experimentalGetCurrentThemeGlobalStylesVariations()?.length;
|
|
42
32
|
}, []);
|
|
43
33
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.Card, {
|
|
44
34
|
size: "small",
|
|
@@ -78,7 +68,7 @@ function ScreenRoot() {
|
|
|
78
68
|
* the nav button inset should be looked at before reusing further.
|
|
79
69
|
*/,
|
|
80
70
|
paddingX: "13px",
|
|
81
|
-
marginBottom:
|
|
71
|
+
marginBottom: 2,
|
|
82
72
|
children: (0, _i18n.__)('Customize the appearance of specific blocks for the whole site.')
|
|
83
73
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.__experimentalItemGroup, {
|
|
84
74
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_navigationButton.NavigationButtonAsItem, {
|
|
@@ -93,28 +83,6 @@ function ScreenRoot() {
|
|
|
93
83
|
})
|
|
94
84
|
})
|
|
95
85
|
})]
|
|
96
|
-
}), canEditCSS && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
97
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.CardDivider, {}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.CardBody, {
|
|
98
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.__experimentalSpacer, {
|
|
99
|
-
as: "p",
|
|
100
|
-
paddingTop: 2,
|
|
101
|
-
paddingX: "13px",
|
|
102
|
-
marginBottom: 4,
|
|
103
|
-
children: (0, _i18n.__)('Add your own CSS to customize the appearance and layout of your site.')
|
|
104
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.__experimentalItemGroup, {
|
|
105
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_navigationButton.NavigationButtonAsItem, {
|
|
106
|
-
path: "/css",
|
|
107
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.__experimentalHStack, {
|
|
108
|
-
justify: "space-between",
|
|
109
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.FlexItem, {
|
|
110
|
-
children: (0, _i18n.__)('Additional CSS')
|
|
111
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_iconWithCurrentColor.IconWithCurrentColor, {
|
|
112
|
-
icon: (0, _i18n.isRTL)() ? _icons.chevronLeft : _icons.chevronRight
|
|
113
|
-
})]
|
|
114
|
-
})
|
|
115
|
-
})
|
|
116
|
-
})]
|
|
117
|
-
})]
|
|
118
86
|
})]
|
|
119
87
|
});
|
|
120
88
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_components","require","_i18n","_icons","_data","_coreData","_iconWithCurrentColor","_navigationButton","_rootMenu","_interopRequireDefault","_previewStyles","_jsxRuntime","ScreenRoot","hasVariations","
|
|
1
|
+
{"version":3,"names":["_components","require","_i18n","_icons","_data","_coreData","_iconWithCurrentColor","_navigationButton","_rootMenu","_interopRequireDefault","_previewStyles","_jsxRuntime","ScreenRoot","hasVariations","useSelect","select","__experimentalGetCurrentThemeGlobalStylesVariations","coreStore","length","jsxs","Card","size","isBorderless","className","isRounded","children","jsx","CardBody","__experimentalVStack","spacing","CardMedia","default","__experimentalItemGroup","NavigationButtonAsItem","path","__experimentalHStack","justify","FlexItem","__","IconWithCurrentColor","icon","isRTL","chevronLeft","chevronRight","CardDivider","__experimentalSpacer","as","paddingTop","paddingX","marginBottom","_default","exports"],"sources":["@wordpress/edit-site/src/components/global-styles/screen-root.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalItemGroup as ItemGroup,\n\t__experimentalHStack as HStack,\n\t__experimentalSpacer as Spacer,\n\t__experimentalVStack as VStack,\n\tFlexItem,\n\tCardBody,\n\tCard,\n\tCardDivider,\n\tCardMedia,\n} from '@wordpress/components';\nimport { isRTL, __ } from '@wordpress/i18n';\nimport { chevronLeft, chevronRight } from '@wordpress/icons';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { IconWithCurrentColor } from './icon-with-current-color';\nimport { NavigationButtonAsItem } from './navigation-button';\nimport RootMenu from './root-menu';\nimport PreviewStyles from './preview-styles';\n\nfunction ScreenRoot() {\n\tconst hasVariations = useSelect( ( select ) => {\n\t\tconst { __experimentalGetCurrentThemeGlobalStylesVariations } =\n\t\t\tselect( coreStore );\n\t\treturn !! __experimentalGetCurrentThemeGlobalStylesVariations()?.length;\n\t}, [] );\n\n\treturn (\n\t\t<Card\n\t\t\tsize=\"small\"\n\t\t\tisBorderless\n\t\t\tclassName=\"edit-site-global-styles-screen-root\"\n\t\t\tisRounded={ false }\n\t\t>\n\t\t\t<CardBody>\n\t\t\t\t<VStack spacing={ 4 }>\n\t\t\t\t\t<Card className=\"edit-site-global-styles-screen-root__active-style-tile\">\n\t\t\t\t\t\t<CardMedia className=\"edit-site-global-styles-screen-root__active-style-tile-preview\">\n\t\t\t\t\t\t\t<PreviewStyles />\n\t\t\t\t\t\t</CardMedia>\n\t\t\t\t\t</Card>\n\t\t\t\t\t{ hasVariations && (\n\t\t\t\t\t\t<ItemGroup>\n\t\t\t\t\t\t\t<NavigationButtonAsItem path=\"/variations\">\n\t\t\t\t\t\t\t\t<HStack justify=\"space-between\">\n\t\t\t\t\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t\t\t\t\t{ __( 'Browse styles' ) }\n\t\t\t\t\t\t\t\t\t</FlexItem>\n\t\t\t\t\t\t\t\t\t<IconWithCurrentColor\n\t\t\t\t\t\t\t\t\t\ticon={\n\t\t\t\t\t\t\t\t\t\t\tisRTL() ? chevronLeft : chevronRight\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t</HStack>\n\t\t\t\t\t\t\t</NavigationButtonAsItem>\n\t\t\t\t\t\t</ItemGroup>\n\t\t\t\t\t) }\n\t\t\t\t\t<RootMenu />\n\t\t\t\t</VStack>\n\t\t\t</CardBody>\n\n\t\t\t<CardDivider />\n\n\t\t\t<CardBody>\n\t\t\t\t<Spacer\n\t\t\t\t\tas=\"p\"\n\t\t\t\t\tpaddingTop={ 2 }\n\t\t\t\t\t/*\n\t\t\t\t\t * 13px matches the text inset of the NavigationButton (12px padding, plus the width of the button's border).\n\t\t\t\t\t * This is an ad hoc override for this instance and the Additional CSS option below. Other options for matching the\n\t\t\t\t\t * the nav button inset should be looked at before reusing further.\n\t\t\t\t\t */\n\t\t\t\t\tpaddingX=\"13px\"\n\t\t\t\t\tmarginBottom={ 2 }\n\t\t\t\t>\n\t\t\t\t\t{ __(\n\t\t\t\t\t\t'Customize the appearance of specific blocks for the whole site.'\n\t\t\t\t\t) }\n\t\t\t\t</Spacer>\n\t\t\t\t<ItemGroup>\n\t\t\t\t\t<NavigationButtonAsItem path=\"/blocks\">\n\t\t\t\t\t\t<HStack justify=\"space-between\">\n\t\t\t\t\t\t\t<FlexItem>{ __( 'Blocks' ) }</FlexItem>\n\t\t\t\t\t\t\t<IconWithCurrentColor\n\t\t\t\t\t\t\t\ticon={ isRTL() ? chevronLeft : chevronRight }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</HStack>\n\t\t\t\t\t</NavigationButtonAsItem>\n\t\t\t\t</ItemGroup>\n\t\t\t</CardBody>\n\t\t</Card>\n\t);\n}\n\nexport default ScreenRoot;\n"],"mappings":";;;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AAWA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,SAAA,GAAAJ,OAAA;AAKA,IAAAK,qBAAA,GAAAL,OAAA;AACA,IAAAM,iBAAA,GAAAN,OAAA;AACA,IAAAO,SAAA,GAAAC,sBAAA,CAAAR,OAAA;AACA,IAAAS,cAAA,GAAAD,sBAAA,CAAAR,OAAA;AAA6C,IAAAU,WAAA,GAAAV,OAAA;AAzB7C;AACA;AACA;;AAiBA;AACA;AACA;;AAMA,SAASW,UAAUA,CAAA,EAAG;EACrB,MAAMC,aAAa,GAAG,IAAAC,eAAS,EAAIC,MAAM,IAAM;IAC9C,MAAM;MAAEC;IAAoD,CAAC,GAC5DD,MAAM,CAAEE,eAAU,CAAC;IACpB,OAAO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AO,QAAA,GAAAC,OAAA,CAAApB,OAAA,GAEcnB,UAAU","ignoreList":[]}
|
|
@@ -7,6 +7,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.default = GlobalStylesUIWrapper;
|
|
8
8
|
exports.useSection = void 0;
|
|
9
9
|
var _i18n = require("@wordpress/i18n");
|
|
10
|
+
var _data = require("@wordpress/data");
|
|
11
|
+
var _coreData = require("@wordpress/core-data");
|
|
10
12
|
var _element = require("@wordpress/element");
|
|
11
13
|
var _router = require("@wordpress/router");
|
|
12
14
|
var _compose = require("@wordpress/compose");
|
|
@@ -35,19 +37,49 @@ const GlobalStylesPageActions = ({
|
|
|
35
37
|
path
|
|
36
38
|
}) => {
|
|
37
39
|
const history = useHistory();
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
40
|
+
const canEditCSS = (0, _data.useSelect)(select => {
|
|
41
|
+
const {
|
|
42
|
+
getEntityRecord,
|
|
43
|
+
__experimentalGetCurrentGlobalStylesId
|
|
44
|
+
} = select(_coreData.store);
|
|
45
|
+
const globalStylesId = __experimentalGetCurrentGlobalStylesId();
|
|
46
|
+
const globalStyles = globalStylesId ? getEntityRecord('root', 'globalStyles', globalStylesId) : undefined;
|
|
47
|
+
return !!globalStyles?._links?.['wp:action-edit-css'];
|
|
48
|
+
}, []);
|
|
49
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.__experimentalHStack, {
|
|
50
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button, {
|
|
51
|
+
isPressed: isStyleBookOpened,
|
|
52
|
+
icon: _icons.seen,
|
|
53
|
+
label: (0, _i18n.__)('Style Book'),
|
|
54
|
+
onClick: () => {
|
|
55
|
+
setIsStyleBookOpened(!isStyleBookOpened);
|
|
56
|
+
const updatedPath = !isStyleBookOpened ? (0, _url.addQueryArgs)(path, {
|
|
57
|
+
preview: 'stylebook'
|
|
58
|
+
}) : (0, _url.removeQueryArgs)(path, 'preview');
|
|
59
|
+
// Navigate to the updated path.
|
|
60
|
+
history.navigate(updatedPath);
|
|
61
|
+
},
|
|
62
|
+
size: "compact"
|
|
63
|
+
}), canEditCSS && /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.DropdownMenu, {
|
|
64
|
+
icon: _icons.moreVertical,
|
|
65
|
+
label: (0, _i18n.__)('More'),
|
|
66
|
+
toggleProps: {
|
|
67
|
+
size: 'compact'
|
|
68
|
+
},
|
|
69
|
+
children: ({
|
|
70
|
+
onClose
|
|
71
|
+
}) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.MenuGroup, {
|
|
72
|
+
children: canEditCSS && /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.MenuItem, {
|
|
73
|
+
onClick: () => {
|
|
74
|
+
onClose();
|
|
75
|
+
history.navigate((0, _url.addQueryArgs)(path, {
|
|
76
|
+
section: '/css'
|
|
77
|
+
}));
|
|
78
|
+
},
|
|
79
|
+
children: (0, _i18n.__)('Additional CSS')
|
|
80
|
+
})
|
|
81
|
+
})
|
|
82
|
+
})]
|
|
51
83
|
});
|
|
52
84
|
};
|
|
53
85
|
|