@wordpress/edit-site 6.30.1-next.a730c9c8c.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/CHANGELOG.md +2 -0
- package/build/components/add-new-template/add-custom-template-modal-content.js +3 -2
- package/build/components/add-new-template/add-custom-template-modal-content.js.map +1 -1
- package/build/components/add-new-template/index.js +1 -5
- package/build/components/add-new-template/index.js.map +1 -1
- package/build/components/add-new-template/utils.js +26 -87
- package/build/components/add-new-template/utils.js.map +1 -1
- package/build/components/dataviews-actions/index.js +51 -1
- package/build/components/dataviews-actions/index.js.map +1 -1
- package/build/components/editor/index.js +1 -1
- package/build/components/editor/index.js.map +1 -1
- package/build/components/editor/use-resolve-edited-entity.js +42 -14
- package/build/components/editor/use-resolve-edited-entity.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/page-templates/fields.js +65 -5
- package/build/components/page-templates/fields.js.map +1 -1
- package/build/components/page-templates/hooks.js +1 -1
- package/build/components/page-templates/hooks.js.map +1 -1
- package/build/components/page-templates/index.js +103 -29
- package/build/components/page-templates/index.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/components/sidebar-navigation-screen-templates-browse/content.js +11 -5
- package/build/components/sidebar-navigation-screen-templates-browse/content.js.map +1 -1
- package/build/components/site-editor-routes/index.js +1 -1
- package/build/components/site-editor-routes/index.js.map +1 -1
- package/build/components/site-editor-routes/template-item.js +29 -23
- package/build/components/site-editor-routes/template-item.js.map +1 -1
- package/build-module/components/add-new-template/add-custom-template-modal-content.js +3 -2
- package/build-module/components/add-new-template/add-custom-template-modal-content.js.map +1 -1
- package/build-module/components/add-new-template/index.js +2 -6
- package/build-module/components/add-new-template/index.js.map +1 -1
- package/build-module/components/add-new-template/utils.js +26 -87
- package/build-module/components/add-new-template/utils.js.map +1 -1
- package/build-module/components/dataviews-actions/index.js +49 -0
- package/build-module/components/dataviews-actions/index.js.map +1 -1
- package/build-module/components/editor/index.js +1 -1
- package/build-module/components/editor/index.js.map +1 -1
- package/build-module/components/editor/use-resolve-edited-entity.js +42 -14
- package/build-module/components/editor/use-resolve-edited-entity.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/page-templates/fields.js +65 -5
- package/build-module/components/page-templates/fields.js.map +1 -1
- package/build-module/components/page-templates/hooks.js +1 -1
- package/build-module/components/page-templates/hooks.js.map +1 -1
- package/build-module/components/page-templates/index.js +105 -31
- package/build-module/components/page-templates/index.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/build-module/components/sidebar-navigation-screen-templates-browse/content.js +11 -5
- package/build-module/components/sidebar-navigation-screen-templates-browse/content.js.map +1 -1
- package/build-module/components/site-editor-routes/index.js +2 -2
- package/build-module/components/site-editor-routes/index.js.map +1 -1
- package/build-module/components/site-editor-routes/template-item.js +28 -22
- package/build-module/components/site-editor-routes/template-item.js.map +1 -1
- package/package.json +41 -41
- package/src/components/add-new-template/add-custom-template-modal-content.js +3 -4
- package/src/components/add-new-template/index.js +1 -8
- package/src/components/add-new-template/utils.js +36 -121
- package/src/components/dataviews-actions/index.js +51 -0
- package/src/components/editor/index.js +1 -0
- package/src/components/editor/use-resolve-edited-entity.js +54 -7
- package/src/components/global-styles/screen-css.js +4 -5
- package/src/components/global-styles/screen-root.js +5 -51
- package/src/components/page-templates/fields.js +70 -4
- package/src/components/page-templates/hooks.js +1 -1
- package/src/components/page-templates/index.js +160 -57
- package/src/components/sidebar-global-styles-wrapper/index.js +62 -16
- package/src/components/sidebar-navigation-screen-templates-browse/content.js +17 -7
- package/src/components/site-editor-routes/index.js +2 -1
- package/src/components/site-editor-routes/template-item.js +34 -26
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_i18n","require","_element","_coreData","_dataviews","_router","_editor","_url","_page","_interopRequireDefault","_addNewTemplate","_constants","_lockUnlock","_dataviewsActions","_fields","_compose","_jsxRuntime","usePostActions","templateTitleField","unlock","editorPrivateApis","useHistory","useLocation","routerPrivateApis","useEntityRecordsWithPermissions","corePrivateApis","EMPTY_ARRAY","defaultLayouts","LAYOUT_TABLE","showMedia","LAYOUT_GRID","LAYOUT_LIST","DEFAULT_VIEW","type","search","page","perPage","sort","field","direction","titleField","descriptionField","mediaField","fields","filters","PageTemplates","path","query","activeView","layout","postId","selection","setSelection","useState","defaultView","useMemo","usedType","operator","value","view","setView","useEffect","currentView","OPERATOR_IS_ANY","records","isResolving","isLoadingData","TEMPLATE_POST_TYPE","per_page","history","onChangeSelection","useCallback","items","navigate","addQueryArgs","length","undefined","authors","authorsSet","Set","forEach","template","add","author_text","Array","from","map","author","label","previewField","authorField","elements","data","paginationInfo","filterSortAndPaginate","postTypeActions","postType","context","editAction","useEditPostAction","actions","onChangeView","useEvent","newView","jsx","default","className","title","__","children","DataViews","isLoading","isItemClickable","onClickItem","id"],"sources":["@wordpress/edit-site/src/components/page-templates/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useState, useMemo, useCallback, useEffect } from '@wordpress/element';\nimport { privateApis as corePrivateApis } from '@wordpress/core-data';\nimport { DataViews, filterSortAndPaginate } from '@wordpress/dataviews';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\nimport { privateApis as editorPrivateApis } from '@wordpress/editor';\nimport { addQueryArgs } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport Page from '../page';\nimport AddNewTemplate from '../add-new-template';\nimport {\n\tTEMPLATE_POST_TYPE,\n\tOPERATOR_IS_ANY,\n\tLAYOUT_GRID,\n\tLAYOUT_TABLE,\n\tLAYOUT_LIST,\n} from '../../utils/constants';\nimport { unlock } from '../../lock-unlock';\nimport { useEditPostAction } from '../dataviews-actions';\nimport { authorField, descriptionField, previewField } from './fields';\nimport { useEvent } from '@wordpress/compose';\n\nconst { usePostActions, templateTitleField } = unlock( editorPrivateApis );\nconst { useHistory, useLocation } = unlock( routerPrivateApis );\nconst { useEntityRecordsWithPermissions } = unlock( corePrivateApis );\n\nconst EMPTY_ARRAY = [];\n\nconst defaultLayouts = {\n\t[ LAYOUT_TABLE ]: {\n\t\tshowMedia: false,\n\t},\n\t[ LAYOUT_GRID ]: {\n\t\tshowMedia: true,\n\t},\n\t[ LAYOUT_LIST ]: {\n\t\tshowMedia: false,\n\t},\n};\n\nconst DEFAULT_VIEW = {\n\ttype: LAYOUT_GRID,\n\tsearch: '',\n\tpage: 1,\n\tperPage: 20,\n\tsort: {\n\t\tfield: 'title',\n\t\tdirection: 'asc',\n\t},\n\ttitleField: 'title',\n\tdescriptionField: 'description',\n\tmediaField: 'preview',\n\tfields: [ 'author' ],\n\tfilters: [],\n\t...defaultLayouts[ LAYOUT_GRID ],\n};\n\nexport default function PageTemplates() {\n\tconst { path, query } = useLocation();\n\tconst { activeView = 'all', layout, postId } = query;\n\tconst [ selection, setSelection ] = useState( [ postId ] );\n\n\tconst defaultView = useMemo( () => {\n\t\tconst usedType = layout ?? DEFAULT_VIEW.type;\n\t\treturn {\n\t\t\t...DEFAULT_VIEW,\n\t\t\ttype: usedType,\n\t\t\tfilters:\n\t\t\t\tactiveView !== 'all'\n\t\t\t\t\t? [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tfield: 'author',\n\t\t\t\t\t\t\t\toperator: 'isAny',\n\t\t\t\t\t\t\t\tvalue: [ activeView ],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t ]\n\t\t\t\t\t: [],\n\t\t\t...defaultLayouts[ usedType ],\n\t\t};\n\t}, [ layout, activeView ] );\n\tconst [ view, setView ] = useState( defaultView );\n\n\t// Sync the layout from the URL to the view state.\n\tuseEffect( () => {\n\t\tsetView( ( currentView ) => ( {\n\t\t\t...currentView,\n\t\t\ttype: layout ?? DEFAULT_VIEW.type,\n\t\t} ) );\n\t}, [ setView, layout ] );\n\n\t// Sync the active view from the URL to the view state.\n\tuseEffect( () => {\n\t\tsetView( ( currentView ) => ( {\n\t\t\t...currentView,\n\t\t\tfilters:\n\t\t\t\tactiveView !== 'all'\n\t\t\t\t\t? [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tfield: 'author',\n\t\t\t\t\t\t\t\toperator: OPERATOR_IS_ANY,\n\t\t\t\t\t\t\t\tvalue: [ activeView ],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t ]\n\t\t\t\t\t: [],\n\t\t} ) );\n\t}, [ setView, activeView ] );\n\n\tconst { records, isResolving: isLoadingData } =\n\t\tuseEntityRecordsWithPermissions( 'postType', TEMPLATE_POST_TYPE, {\n\t\t\tper_page: -1,\n\t\t} );\n\tconst history = useHistory();\n\tconst onChangeSelection = useCallback(\n\t\t( items ) => {\n\t\t\tsetSelection( items );\n\t\t\tif ( view?.type === LAYOUT_LIST ) {\n\t\t\t\thistory.navigate(\n\t\t\t\t\taddQueryArgs( path, {\n\t\t\t\t\t\tpostId: items.length === 1 ? items[ 0 ] : undefined,\n\t\t\t\t\t} )\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t\t[ history, path, view?.type ]\n\t);\n\n\tconst authors = useMemo( () => {\n\t\tif ( ! records ) {\n\t\t\treturn EMPTY_ARRAY;\n\t\t}\n\t\tconst authorsSet = new Set();\n\t\trecords.forEach( ( template ) => {\n\t\t\tauthorsSet.add( template.author_text );\n\t\t} );\n\t\treturn Array.from( authorsSet ).map( ( author ) => ( {\n\t\t\tvalue: author,\n\t\t\tlabel: author,\n\t\t} ) );\n\t}, [ records ] );\n\n\tconst fields = useMemo(\n\t\t() => [\n\t\t\tpreviewField,\n\t\t\ttemplateTitleField,\n\t\t\tdescriptionField,\n\t\t\t{\n\t\t\t\t...authorField,\n\t\t\t\telements: authors,\n\t\t\t},\n\t\t],\n\t\t[ authors ]\n\t);\n\n\tconst { data, paginationInfo } = useMemo( () => {\n\t\treturn filterSortAndPaginate( records, view, fields );\n\t}, [ records, view, fields ] );\n\n\tconst postTypeActions = usePostActions( {\n\t\tpostType: TEMPLATE_POST_TYPE,\n\t\tcontext: 'list',\n\t} );\n\tconst editAction = useEditPostAction();\n\tconst actions = useMemo(\n\t\t() => [ editAction, ...postTypeActions ],\n\t\t[ postTypeActions, editAction ]\n\t);\n\n\tconst onChangeView = useEvent( ( newView ) => {\n\t\tsetView( newView );\n\t\tif ( newView.type !== layout ) {\n\t\t\thistory.navigate(\n\t\t\t\taddQueryArgs( path, {\n\t\t\t\t\tlayout: newView.type,\n\t\t\t\t} )\n\t\t\t);\n\t\t}\n\t} );\n\n\treturn (\n\t\t<Page\n\t\t\tclassName=\"edit-site-page-templates\"\n\t\t\ttitle={ __( 'Templates' ) }\n\t\t\tactions={ <AddNewTemplate /> }\n\t\t>\n\t\t\t<DataViews\n\t\t\t\tkey={ activeView }\n\t\t\t\tpaginationInfo={ paginationInfo }\n\t\t\t\tfields={ fields }\n\t\t\t\tactions={ actions }\n\t\t\t\tdata={ data }\n\t\t\t\tisLoading={ isLoadingData }\n\t\t\t\tview={ view }\n\t\t\t\tonChangeView={ onChangeView }\n\t\t\t\tonChangeSelection={ onChangeSelection }\n\t\t\t\tisItemClickable={ () => true }\n\t\t\t\tonClickItem={ ( { id } ) => {\n\t\t\t\t\thistory.navigate( `/wp_template/${ id }?canvas=edit` );\n\t\t\t\t} }\n\t\t\t\tselection={ selection }\n\t\t\t\tdefaultLayouts={ defaultLayouts }\n\t\t\t/>\n\t\t</Page>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,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wF,GAAA,EAAChG,KAAA,CAAAiG,OAAI;IACJC,SAAS,EAAC,0BAA0B;IACpCC,KAAK,EAAG,IAAAC,QAAE,EAAE,WAAY,CAAG;IAC3BR,OAAO,eAAG,IAAApF,WAAA,CAAAwF,GAAA,EAAC9F,eAAA,CAAA+F,OAAc,IAAE,CAAG;IAAAI,QAAA,eAE9B,IAAA7F,WAAA,CAAAwF,GAAA,EAACpG,UAAA,CAAA0G,SAAS;MAETjB,cAAc,EAAGA,cAAgB;MACjClD,MAAM,EAAGA,MAAQ;MACjByD,OAAO,EAAGA,OAAS;MACnBR,IAAI,EAAGA,IAAM;MACbmB,SAAS,EAAG7C,aAAe;MAC3BP,IAAI,EAAGA,IAAM;MACb0C,YAAY,EAAGA,YAAc;MAC7B/B,iBAAiB,EAAGA,iBAAmB;MACvC0C,eAAe,EAAGA,CAAA,KAAM,IAAM;MAC9BC,WAAW,EAAGA,CAAE;QAAEC;MAAG,CAAC,KAAM;QAC3B7C,OAAO,CAACI,QAAQ,CAAE,gBAAiByC,EAAE,cAAgB,CAAC;MACvD,CAAG;MACH/D,SAAS,EAAGA,SAAW;MACvBxB,cAAc,EAAGA;IAAgB,GAd3BqB,UAeN;EAAC,CACG,CAAC;AAET","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_i18n","require","_element","_coreData","_dataviews","_router","_editor","_url","_data","_compose","_page","_interopRequireDefault","_addNewTemplate","_constants","_lockUnlock","_dataviewsActions","_fields2","_jsxRuntime","usePostActions","templateTitleField","unlock","editorPrivateApis","useHistory","useLocation","routerPrivateApis","useEntityRecordsWithPermissions","corePrivateApis","defaultLayouts","LAYOUT_TABLE","showMedia","LAYOUT_GRID","LAYOUT_LIST","DEFAULT_VIEW","type","search","page","perPage","sort","field","direction","titleField","descriptionField","mediaField","fields","filters","PageTemplates","path","query","activeView","layout","postId","selection","setSelection","useState","defaultView","useMemo","usedType","includes","operator","value","view","setView","useEffect","currentView","OPERATOR_IS_ANY","activeTemplatesOption","useSelect","select","coreStore","getEntityRecord","active_templates","records","userRecords","isResolving","isLoadingUserRecords","TEMPLATE_POST_TYPE","per_page","staticRecords","isLoadingStaticData","activeTemplates","_active","filter","record","is_custom","activeSlug","activeId","index","findIndex","template","slug","splice","find","id","push","_records","isLoadingData","map","_isActive","undefined","Object","values","users","getUser","reduce","acc","author_text","author","history","onChangeSelection","useCallback","items","navigate","addQueryArgs","length","_fields","previewField","activeField","slugField","elements","_users$author$id","_users$author$name","label","name","authorField","data","paginationInfo","filterSortAndPaginate","postTypeActions","postType","context","editAction","useEditPostAction","setActiveTemplateAction","useSetActiveTemplateAction","actions","onChangeView","useEvent","newView","jsx","default","className","title","__","children","DataViews","isLoading","isItemClickable","onClickItem","item"],"sources":["@wordpress/edit-site/src/components/page-templates/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useState, useMemo, useCallback, useEffect } from '@wordpress/element';\nimport {\n\tprivateApis as corePrivateApis,\n\tstore as coreStore,\n} from '@wordpress/core-data';\nimport { DataViews, filterSortAndPaginate } from '@wordpress/dataviews';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\nimport { privateApis as editorPrivateApis } from '@wordpress/editor';\nimport { addQueryArgs } from '@wordpress/url';\nimport { useSelect } from '@wordpress/data';\nimport { useEvent } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport Page from '../page';\nimport AddNewTemplate from '../add-new-template';\nimport {\n\tTEMPLATE_POST_TYPE,\n\tOPERATOR_IS_ANY,\n\tLAYOUT_GRID,\n\tLAYOUT_TABLE,\n\tLAYOUT_LIST,\n} from '../../utils/constants';\nimport { unlock } from '../../lock-unlock';\nimport {\n\tuseEditPostAction,\n\tuseSetActiveTemplateAction,\n} from '../dataviews-actions';\nimport {\n\tauthorField,\n\tdescriptionField,\n\tpreviewField,\n\tactiveField,\n\tslugField,\n} from './fields';\n\nconst { usePostActions, templateTitleField } = unlock( editorPrivateApis );\nconst { useHistory, useLocation } = unlock( routerPrivateApis );\nconst { useEntityRecordsWithPermissions } = unlock( corePrivateApis );\n\nconst defaultLayouts = {\n\t[ LAYOUT_TABLE ]: {\n\t\tshowMedia: false,\n\t},\n\t[ LAYOUT_GRID ]: {\n\t\tshowMedia: true,\n\t},\n\t[ LAYOUT_LIST ]: {\n\t\tshowMedia: false,\n\t},\n};\n\nconst DEFAULT_VIEW = {\n\ttype: LAYOUT_GRID,\n\tsearch: '',\n\tpage: 1,\n\tperPage: 20,\n\tsort: {\n\t\tfield: 'title',\n\t\tdirection: 'asc',\n\t},\n\ttitleField: 'title',\n\tdescriptionField: 'description',\n\tmediaField: 'preview',\n\tfields: [ 'author', 'active', 'slug' ],\n\tfilters: [],\n\t...defaultLayouts[ LAYOUT_GRID ],\n};\n\nexport default function PageTemplates() {\n\tconst { path, query } = useLocation();\n\tconst { activeView = 'active', layout, postId } = query;\n\tconst [ selection, setSelection ] = useState( [ postId ] );\n\tconst defaultView = useMemo( () => {\n\t\tconst usedType = layout ?? DEFAULT_VIEW.type;\n\t\treturn {\n\t\t\t...DEFAULT_VIEW,\n\t\t\ttype: usedType,\n\t\t\tfilters: ! [ 'active', 'user' ].includes( activeView )\n\t\t\t\t? [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tfield: 'author',\n\t\t\t\t\t\t\toperator: 'isAny',\n\t\t\t\t\t\t\tvalue: [ activeView ],\n\t\t\t\t\t\t},\n\t\t\t\t ]\n\t\t\t\t: [],\n\t\t\t...defaultLayouts[ usedType ],\n\t\t};\n\t}, [ layout, activeView ] );\n\tconst [ view, setView ] = useState( defaultView );\n\n\t// Sync the layout from the URL to the view state.\n\tuseEffect( () => {\n\t\tsetView( ( currentView ) => ( {\n\t\t\t...currentView,\n\t\t\ttype: layout ?? DEFAULT_VIEW.type,\n\t\t} ) );\n\t}, [ setView, layout ] );\n\n\t// Sync the active view from the URL to the view state.\n\tuseEffect( () => {\n\t\tsetView( ( currentView ) => ( {\n\t\t\t...currentView,\n\t\t\tfilters: ! [ 'active', 'user' ].includes( activeView )\n\t\t\t\t? [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tfield: 'author',\n\t\t\t\t\t\t\toperator: OPERATOR_IS_ANY,\n\t\t\t\t\t\t\tvalue: [ activeView ],\n\t\t\t\t\t\t},\n\t\t\t\t ]\n\t\t\t\t: [],\n\t\t} ) );\n\t}, [ setView, activeView ] );\n\n\tconst activeTemplatesOption = useSelect(\n\t\t( select ) =>\n\t\t\tselect( coreStore ).getEntityRecord( 'root', 'site' )\n\t\t\t\t?.active_templates\n\t);\n\t// Todo: this will have to be better so that we're not fetching all the\n\t// records all the time. Active templates query will need to move server\n\t// side.\n\tconst { records: userRecords, isResolving: isLoadingUserRecords } =\n\t\tuseEntityRecordsWithPermissions( 'postType', TEMPLATE_POST_TYPE, {\n\t\t\tper_page: -1,\n\t\t} );\n\tconst { records: staticRecords, isResolving: isLoadingStaticData } =\n\t\tuseEntityRecordsWithPermissions( 'postType', 'wp_registered_template', {\n\t\t\tper_page: -1,\n\t\t} );\n\n\tconst activeTemplates = useMemo( () => {\n\t\tconst _active = [ ...staticRecords ].filter(\n\t\t\t( record ) => ! record.is_custom\n\t\t);\n\t\tif ( activeTemplatesOption ) {\n\t\t\tfor ( const activeSlug in activeTemplatesOption ) {\n\t\t\t\tconst activeId = activeTemplatesOption[ activeSlug ];\n\t\t\t\tif ( activeId === false ) {\n\t\t\t\t\t// Remove the template from the array.\n\t\t\t\t\tconst index = _active.findIndex(\n\t\t\t\t\t\t( template ) => template.slug === activeSlug\n\t\t\t\t\t);\n\t\t\t\t\tif ( index !== -1 ) {\n\t\t\t\t\t\t_active.splice( index, 1 );\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t// Replace the template in the array.\n\t\t\t\t\tconst template = userRecords.find(\n\t\t\t\t\t\t( { id } ) => id === activeId\n\t\t\t\t\t);\n\t\t\t\t\tif ( template ) {\n\t\t\t\t\t\tconst index = _active.findIndex(\n\t\t\t\t\t\t\t( { slug } ) => slug === template.slug\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif ( index !== -1 ) {\n\t\t\t\t\t\t\t_active[ index ] = template;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t_active.push( template );\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\treturn _active;\n\t}, [ userRecords, staticRecords, activeTemplatesOption ] );\n\n\tlet _records;\n\tlet isLoadingData;\n\tif ( activeView === 'active' ) {\n\t\t_records = activeTemplates;\n\t\tisLoadingData = isLoadingUserRecords || isLoadingStaticData;\n\t} else if ( activeView === 'user' ) {\n\t\t_records = userRecords;\n\t\tisLoadingData = isLoadingUserRecords;\n\t} else {\n\t\t_records = staticRecords;\n\t\tisLoadingData = isLoadingStaticData;\n\t}\n\n\tconst records = useMemo( () => {\n\t\treturn _records.map( ( record ) => ( {\n\t\t\t...record,\n\t\t\t_isActive:\n\t\t\t\ttypeof record.id === 'string'\n\t\t\t\t\t? activeTemplatesOption[ record.slug ] === record.id ||\n\t\t\t\t\t activeTemplatesOption[ record.slug ] === undefined\n\t\t\t\t\t: Object.values( activeTemplatesOption ).includes(\n\t\t\t\t\t\t\trecord.id\n\t\t\t\t\t ),\n\t\t} ) );\n\t}, [ _records, activeTemplatesOption ] );\n\n\tconst users = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getUser } = select( coreStore );\n\t\t\treturn records.reduce( ( acc, record ) => {\n\t\t\t\tif ( record.author_text ) {\n\t\t\t\t\tif ( ! acc[ record.author_text ] ) {\n\t\t\t\t\t\tacc[ record.author_text ] = record.author_text;\n\t\t\t\t\t}\n\t\t\t\t} else if ( record.author ) {\n\t\t\t\t\tif ( ! acc[ record.author ] ) {\n\t\t\t\t\t\tacc[ record.author ] = getUser( record.author );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn acc;\n\t\t\t}, {} );\n\t\t},\n\t\t[ records ]\n\t);\n\n\tconst history = useHistory();\n\tconst onChangeSelection = useCallback(\n\t\t( items ) => {\n\t\t\tsetSelection( items );\n\t\t\tif ( view?.type === LAYOUT_LIST ) {\n\t\t\t\thistory.navigate(\n\t\t\t\t\taddQueryArgs( path, {\n\t\t\t\t\t\tpostId: items.length === 1 ? items[ 0 ] : undefined,\n\t\t\t\t\t} )\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t\t[ history, path, view?.type ]\n\t);\n\n\tconst fields = useMemo( () => {\n\t\tconst _fields = [\n\t\t\tpreviewField,\n\t\t\ttemplateTitleField,\n\t\t\tdescriptionField,\n\t\t\tactiveField,\n\t\t\tslugField,\n\t\t];\n\t\tconst elements = [];\n\t\tfor ( const author in users ) {\n\t\t\telements.push( {\n\t\t\t\tvalue: users[ author ]?.id ?? author,\n\t\t\t\tlabel: users[ author ]?.name ?? author,\n\t\t\t} );\n\t\t}\n\t\t_fields.push( {\n\t\t\t...authorField,\n\t\t\telements,\n\t\t} );\n\t\treturn _fields;\n\t}, [ users ] );\n\n\tconst { data, paginationInfo } = useMemo( () => {\n\t\treturn filterSortAndPaginate( records, view, fields );\n\t}, [ records, view, fields ] );\n\n\tconst postTypeActions = usePostActions( {\n\t\tpostType: TEMPLATE_POST_TYPE,\n\t\tcontext: 'list',\n\t} );\n\tconst editAction = useEditPostAction();\n\tconst setActiveTemplateAction = useSetActiveTemplateAction();\n\tconst actions = useMemo(\n\t\t() =>\n\t\t\tactiveView === 'user'\n\t\t\t\t? [ setActiveTemplateAction, editAction, ...postTypeActions ]\n\t\t\t\t: [ setActiveTemplateAction, ...postTypeActions ],\n\t\t[ postTypeActions, setActiveTemplateAction, editAction, activeView ]\n\t);\n\n\tconst onChangeView = useEvent( ( newView ) => {\n\t\tsetView( newView );\n\t\tif ( newView.type !== layout ) {\n\t\t\thistory.navigate(\n\t\t\t\taddQueryArgs( path, {\n\t\t\t\t\tlayout: newView.type,\n\t\t\t\t} )\n\t\t\t);\n\t\t}\n\t} );\n\n\treturn (\n\t\t<Page\n\t\t\tclassName=\"edit-site-page-templates\"\n\t\t\ttitle={ __( 'Templates' ) }\n\t\t\tactions={ <AddNewTemplate /> }\n\t\t>\n\t\t\t<DataViews\n\t\t\t\tkey={ activeView }\n\t\t\t\tpaginationInfo={ paginationInfo }\n\t\t\t\tfields={ fields }\n\t\t\t\tactions={ actions }\n\t\t\t\tdata={ data }\n\t\t\t\tisLoading={ isLoadingData }\n\t\t\t\tview={ view }\n\t\t\t\tonChangeView={ onChangeView }\n\t\t\t\tonChangeSelection={ onChangeSelection }\n\t\t\t\tisItemClickable={ () => true }\n\t\t\t\tonClickItem={ ( item ) => {\n\t\t\t\t\thistory.navigate(\n\t\t\t\t\t\t`/${ item.type }/${ item.id }?canvas=edit`\n\t\t\t\t\t);\n\t\t\t\t} }\n\t\t\t\tselection={ selection }\n\t\t\t\tdefaultLayouts={ defaultLayouts }\n\t\t\t/>\n\t\t</Page>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AAIA,IAAAG,UAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AACA,IAAAK,OAAA,GAAAL,OAAA;AACA,IAAAM,IAAA,GAAAN,OAAA;AACA,IAAAO,KAAA,GAAAP,OAAA;AACA,IAAAQ,QAAA,GAAAR,OAAA;AAKA,IAAAS,KAAA,GAAAC,sBAAA,CAAAV,OAAA;AACA,IAAAW,eAAA,GAAAD,sBAAA,CAAAV,OAAA;AACA,IAAAY,UAAA,GAAAZ,OAAA;AAOA,IAAAa,WAAA,GAAAb,OAAA;AACA,IAAAc,iBAAA,GAAAd,OAAA;AAIA,IAAAe,QAAA,GAAAf,OAAA;AAMkB,IAAAgB,WAAA,GAAAhB,OAAA;AAvClB;AACA;AACA;;AAcA;AACA;AACA;;AAuBA,MAAM;EAAEiB,cAAc;EAAEC;AAAmB,CAAC,GAAG,IAAAC,kBAAM,EAAEC,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O,CAAE4E,OAAQ,CAAC;IAClB,IAAKA,OAAO,CAACxG,IAAI,KAAKgB,MAAM,EAAG;MAC9B0D,OAAO,CAACI,QAAQ,CACf,IAAAC,iBAAY,EAAElE,IAAI,EAAE;QACnBG,MAAM,EAAEwF,OAAO,CAACxG;MACjB,CAAE,CACH,CAAC;IACF;EACD,CAAE,CAAC;EAEH,oBACC,IAAAhB,WAAA,CAAAyH,GAAA,EAAChI,KAAA,CAAAiI,OAAI;IACJC,SAAS,EAAC,0BAA0B;IACpCC,KAAK,EAAG,IAAAC,QAAE,EAAE,WAAY,CAAG;IAC3BR,OAAO,eAAG,IAAArH,WAAA,CAAAyH,GAAA,EAAC9H,eAAA,CAAA+H,OAAc,IAAE,CAAG;IAAAI,QAAA,eAE9B,IAAA9H,WAAA,CAAAyH,GAAA,EAACtI,UAAA,CAAA4I,SAAS;MAETnB,cAAc,EAAGA,cAAgB;MACjClF,MAAM,EAAGA,MAAQ;MACjB2F,OAAO,EAAGA,OAAS;MACnBV,IAAI,EAAGA,IAAM;MACbqB,SAAS,EAAGlD,aAAe;MAC3BnC,IAAI,EAAGA,IAAM;MACb2E,YAAY,EAAGA,YAAc;MAC7B3B,iBAAiB,EAAGA,iBAAmB;MACvCsC,eAAe,EAAGA,CAAA,KAAM,IAAM;MAC9BC,WAAW,EAAKC,IAAI,IAAM;QACzBzC,OAAO,CAACI,QAAQ,CACf,IAAKqC,IAAI,CAACnH,IAAI,IAAMmH,IAAI,CAACxD,EAAE,cAC5B,CAAC;MACF,CAAG;MACHzC,SAAS,EAAGA,SAAW;MACvBxB,cAAc,EAAGA;IAAgB,GAhB3BqB,UAiBN;EAAC,CACG,CAAC;AAET","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
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_i18n","require","_element","_router","_compose","_components","_url","_icons","_ui","_interopRequireDefault","_page","_lockUnlock","_jsxRuntime","useLocation","useHistory","unlock","routerPrivateApis","GlobalStylesPageActions","isStyleBookOpened","setIsStyleBookOpened","path","history","jsx","Button","isPressed","icon","seen","label","__","onClick","updatedPath","addQueryArgs","preview","removeQueryArgs","navigate","size","useSection","query","useMemo","_query$section","
|
|
1
|
+
{"version":3,"names":["_i18n","require","_data","_coreData","_element","_router","_compose","_components","_url","_icons","_ui","_interopRequireDefault","_page","_lockUnlock","_jsxRuntime","useLocation","useHistory","unlock","routerPrivateApis","GlobalStylesPageActions","isStyleBookOpened","setIsStyleBookOpened","path","history","canEditCSS","useSelect","select","getEntityRecord","__experimentalGetCurrentGlobalStylesId","coreStore","globalStylesId","globalStyles","undefined","_links","jsxs","__experimentalHStack","children","jsx","Button","isPressed","icon","seen","label","__","onClick","updatedPath","addQueryArgs","preview","removeQueryArgs","navigate","size","DropdownMenu","moreVertical","toggleProps","onClose","MenuGroup","MenuItem","section","useSection","query","useMemo","_query$section","updatedSection","exports","GlobalStylesUIWrapper","useState","includes","isMobileViewport","useViewportMatch","onChangeSection","Fragment","default","actions","className","title","onPathChange"],"sources":["@wordpress/edit-site/src/components/sidebar-global-styles-wrapper/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useMemo, useState } from '@wordpress/element';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\nimport { useViewportMatch } from '@wordpress/compose';\nimport {\n\tButton,\n\t__experimentalHStack as HStack,\n\tDropdownMenu,\n\tMenuGroup,\n\tMenuItem,\n} from '@wordpress/components';\nimport { addQueryArgs, removeQueryArgs } from '@wordpress/url';\nimport { seen, moreVertical } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport GlobalStylesUI from '../global-styles/ui';\nimport Page from '../page';\nimport { unlock } from '../../lock-unlock';\n\nconst { useLocation, useHistory } = unlock( routerPrivateApis );\n\nconst GlobalStylesPageActions = ( {\n\tisStyleBookOpened,\n\tsetIsStyleBookOpened,\n\tpath,\n} ) => {\n\tconst history = useHistory();\n\tconst canEditCSS = useSelect( ( select ) => {\n\t\tconst { getEntityRecord, __experimentalGetCurrentGlobalStylesId } =\n\t\t\tselect( coreStore );\n\t\tconst globalStylesId = __experimentalGetCurrentGlobalStylesId();\n\t\tconst globalStyles = globalStylesId\n\t\t\t? getEntityRecord( 'root', 'globalStyles', globalStylesId )\n\t\t\t: undefined;\n\t\treturn !! globalStyles?._links?.[ 'wp:action-edit-css' ];\n\t}, [] );\n\n\treturn (\n\t\t<HStack>\n\t\t\t<Button\n\t\t\t\tisPressed={ isStyleBookOpened }\n\t\t\t\ticon={ seen }\n\t\t\t\tlabel={ __( 'Style Book' ) }\n\t\t\t\tonClick={ () => {\n\t\t\t\t\tsetIsStyleBookOpened( ! isStyleBookOpened );\n\t\t\t\t\tconst updatedPath = ! isStyleBookOpened\n\t\t\t\t\t\t? addQueryArgs( path, { preview: 'stylebook' } )\n\t\t\t\t\t\t: removeQueryArgs( path, 'preview' );\n\t\t\t\t\t// Navigate to the updated path.\n\t\t\t\t\thistory.navigate( updatedPath );\n\t\t\t\t} }\n\t\t\t\tsize=\"compact\"\n\t\t\t/>\n\t\t\t{ canEditCSS && (\n\t\t\t\t<DropdownMenu\n\t\t\t\t\ticon={ moreVertical }\n\t\t\t\t\tlabel={ __( 'More' ) }\n\t\t\t\t\ttoggleProps={ { size: 'compact' } }\n\t\t\t\t>\n\t\t\t\t\t{ ( { onClose } ) => (\n\t\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t\t{ canEditCSS && (\n\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\t\t\t\thistory.navigate(\n\t\t\t\t\t\t\t\t\t\t\taddQueryArgs( path, {\n\t\t\t\t\t\t\t\t\t\t\t\tsection: '/css',\n\t\t\t\t\t\t\t\t\t\t\t} )\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>\n\t\t\t\t\t\t\t\t\t{ __( 'Additional CSS' ) }\n\t\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t) }\n\t\t\t\t</DropdownMenu>\n\t\t\t) }\n\t\t</HStack>\n\t);\n};\n\n/**\n * Hook to deal with navigation and location state.\n *\n * @return {Array} The current section and a function to update it.\n */\nexport const useSection = () => {\n\tconst { path, query } = useLocation();\n\tconst history = useHistory();\n\treturn useMemo( () => {\n\t\treturn [\n\t\t\tquery.section ?? '/',\n\t\t\t( updatedSection ) => {\n\t\t\t\thistory.navigate(\n\t\t\t\t\taddQueryArgs( path, {\n\t\t\t\t\t\tsection: updatedSection,\n\t\t\t\t\t} )\n\t\t\t\t);\n\t\t\t},\n\t\t];\n\t}, [ path, query.section, history ] );\n};\n\nexport default function GlobalStylesUIWrapper() {\n\tconst { path } = useLocation();\n\n\tconst [ isStyleBookOpened, setIsStyleBookOpened ] = useState(\n\t\tpath.includes( 'preview=stylebook' )\n\t);\n\tconst isMobileViewport = useViewportMatch( 'medium', '<' );\n\tconst [ section, onChangeSection ] = useSection();\n\n\treturn (\n\t\t<>\n\t\t\t<Page\n\t\t\t\tactions={\n\t\t\t\t\t! isMobileViewport ? (\n\t\t\t\t\t\t<GlobalStylesPageActions\n\t\t\t\t\t\t\tisStyleBookOpened={ isStyleBookOpened }\n\t\t\t\t\t\t\tsetIsStyleBookOpened={ setIsStyleBookOpened }\n\t\t\t\t\t\t\tpath={ path }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) : null\n\t\t\t\t}\n\t\t\t\tclassName=\"edit-site-styles\"\n\t\t\t\ttitle={ __( 'Styles' ) }\n\t\t\t>\n\t\t\t\t<GlobalStylesUI\n\t\t\t\t\tpath={ section }\n\t\t\t\t\tonPathChange={ onChangeSection }\n\t\t\t\t/>\n\t\t\t</Page>\n\t\t</>\n\t);\n}\n"],"mappings":";;;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AACA,IAAAK,QAAA,GAAAL,OAAA;AACA,IAAAM,WAAA,GAAAN,OAAA;AAOA,IAAAO,IAAA,GAAAP,OAAA;AACA,IAAAQ,MAAA,GAAAR,OAAA;AAKA,IAAAS,GAAA,GAAAC,sBAAA,CAAAV,OAAA;AACA,IAAAW,KAAA,GAAAD,sBAAA,CAAAV,OAAA;AACA,IAAAY,WAAA,GAAAZ,OAAA;AAA2C,IAAAa,WAAA,GAAAb,OAAA;AAxB3C;AACA;AACA;;AAiBA;AACA;AACA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,CAAC;AACtC,CAAC;AAACwC,OAAA,CAAAL,UAAA,GAAAA,UAAA;AAEa,SAASM,qBAAqBA,CAAA,EAAG;EAC/C,MAAM;IAAE1C;EAAK,CAAC,GAAGP,WAAW,CAAC,CAAC;EAE9B,MAAM,CAAEK,iBAAiB,EAAEC,oBAAoB,CAAE,GAAG,IAAA4C,iBAAQ,EAC3D3C,IAAI,CAAC4C,QAAQ,CAAE,mBAAoB,CACpC,CAAC;EACD,MAAMC,gBAAgB,GAAG,IAAAC,yBAAgB,EAAE,QAAQ,EAAE,GAAI,CAAC;EAC1D,MAAM,CAAEX,OAAO,EAAEY,eAAe,CAAE,GAAGX,UAAU,CAAC,CAAC;EAEjD,oBACC,IAAA5C,WAAA,CAAAuB,GAAA,EAAAvB,WAAA,CAAAwD,QAAA;IAAAlC,QAAA,eACC,IAAAtB,WAAA,CAAAuB,GAAA,EAACzB,KAAA,CAAA2D,OAAI;MACJC,OAAO,EACN,CAAEL,gBAAgB,gBACjB,IAAArD,WAAA,CAAAuB,GAAA,EAAClB,uBAAuB;QACvBC,iBAAiB,EAAGA,iBAAmB;QACvCC,oBAAoB,EAAGA,oBAAsB;QAC7CC,IAAI,EAAGA;MAAM,CACb,CAAC,GACC,IACJ;MACDmD,SAAS,EAAC,kBAAkB;MAC5BC,KAAK,EAAG,IAAA/B,QAAE,EAAE,QAAS,CAAG;MAAAP,QAAA,eAExB,IAAAtB,WAAA,CAAAuB,GAAA,EAAC3B,GAAA,CAAA6D,OAAc;QACdjD,IAAI,EAAGmC,OAAS;QAChBkB,YAAY,EAAGN;MAAiB,CAChC;IAAC,CACG;EAAC,CACN,CAAC;AAEL","ignoreList":[]}
|
|
@@ -14,7 +14,6 @@ var _url = require("@wordpress/url");
|
|
|
14
14
|
var _sidebarNavigationItem = _interopRequireDefault(require("../sidebar-navigation-item"));
|
|
15
15
|
var _hooks = require("../page-templates/hooks");
|
|
16
16
|
var _icons = require("@wordpress/icons");
|
|
17
|
-
var _constants = require("../../utils/constants");
|
|
18
17
|
var _lockUnlock = require("../../lock-unlock");
|
|
19
18
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
20
19
|
/**
|
|
@@ -49,12 +48,12 @@ function TemplateDataviewItem({
|
|
|
49
48
|
function DataviewsTemplatesSidebarContent() {
|
|
50
49
|
const {
|
|
51
50
|
query: {
|
|
52
|
-
activeView = '
|
|
51
|
+
activeView = 'active'
|
|
53
52
|
}
|
|
54
53
|
} = useLocation();
|
|
55
54
|
const {
|
|
56
55
|
records
|
|
57
|
-
} = (0, _coreData.useEntityRecords)('postType',
|
|
56
|
+
} = (0, _coreData.useEntityRecords)('postType', 'wp_registered_template', {
|
|
58
57
|
per_page: -1
|
|
59
58
|
});
|
|
60
59
|
const firstItemPerAuthorText = (0, _element.useMemo)(() => {
|
|
@@ -73,8 +72,15 @@ function DataviewsTemplatesSidebarContent() {
|
|
|
73
72
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_sidebarNavigationItem.default, {
|
|
74
73
|
to: "/template",
|
|
75
74
|
icon: _icons.layout,
|
|
76
|
-
"aria-current": activeView === '
|
|
77
|
-
children: (0, _i18n.__)('
|
|
75
|
+
"aria-current": activeView === 'active',
|
|
76
|
+
children: (0, _i18n.__)('Active templates')
|
|
77
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_sidebarNavigationItem.default, {
|
|
78
|
+
to: (0, _url.addQueryArgs)('/template', {
|
|
79
|
+
activeView: 'user'
|
|
80
|
+
}),
|
|
81
|
+
icon: _icons.layout,
|
|
82
|
+
"aria-current": activeView === 'user',
|
|
83
|
+
children: (0, _i18n.__)('Custom templates')
|
|
78
84
|
}), firstItemPerAuthorText.map(template => {
|
|
79
85
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(TemplateDataviewItem, {
|
|
80
86
|
template: template,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_coreData","require","_element","_components","_i18n","_router","_url","_sidebarNavigationItem","_interopRequireDefault","_hooks","_icons","
|
|
1
|
+
{"version":3,"names":["_coreData","require","_element","_components","_i18n","_router","_url","_sidebarNavigationItem","_interopRequireDefault","_hooks","_icons","_lockUnlock","_jsxRuntime","useLocation","unlock","routerPrivateApis","EMPTY_ARRAY","TemplateDataviewItem","template","isActive","text","icon","useAddedBy","type","id","jsx","default","to","addQueryArgs","activeView","children","DataviewsTemplatesSidebarContent","query","records","useEntityRecords","per_page","firstItemPerAuthorText","useMemo","_ref","firstItemPerAuthor","reduce","acc","author","author_text","Object","values","jsxs","__experimentalItemGroup","className","layout","__","map"],"sources":["@wordpress/edit-site/src/components/sidebar-navigation-screen-templates-browse/content.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEntityRecords } from '@wordpress/core-data';\nimport { useMemo } from '@wordpress/element';\nimport { __experimentalItemGroup as ItemGroup } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\nimport { addQueryArgs } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport SidebarNavigationItem from '../sidebar-navigation-item';\nimport { useAddedBy } from '../page-templates/hooks';\nimport { layout } from '@wordpress/icons';\nimport { unlock } from '../../lock-unlock';\n\nconst { useLocation } = unlock( routerPrivateApis );\n\nconst EMPTY_ARRAY = [];\n\nfunction TemplateDataviewItem( { template, isActive } ) {\n\tconst { text, icon } = useAddedBy( template.type, template.id );\n\n\treturn (\n\t\t<SidebarNavigationItem\n\t\t\tto={ addQueryArgs( '/template', { activeView: text } ) }\n\t\t\ticon={ icon }\n\t\t\taria-current={ isActive }\n\t\t>\n\t\t\t{ text }\n\t\t</SidebarNavigationItem>\n\t);\n}\n\nexport default function DataviewsTemplatesSidebarContent() {\n\tconst {\n\t\tquery: { activeView = 'active' },\n\t} = useLocation();\n\tconst { records } = useEntityRecords(\n\t\t'postType',\n\t\t'wp_registered_template',\n\t\t{\n\t\t\tper_page: -1,\n\t\t}\n\t);\n\tconst firstItemPerAuthorText = useMemo( () => {\n\t\tconst firstItemPerAuthor = records?.reduce( ( acc, template ) => {\n\t\t\tconst author = template.author_text;\n\t\t\tif ( author && ! acc[ author ] ) {\n\t\t\t\tacc[ author ] = template;\n\t\t\t}\n\t\t\treturn acc;\n\t\t}, {} );\n\t\treturn (\n\t\t\t( firstItemPerAuthor && Object.values( firstItemPerAuthor ) ) ??\n\t\t\tEMPTY_ARRAY\n\t\t);\n\t}, [ records ] );\n\n\treturn (\n\t\t<ItemGroup className=\"edit-site-sidebar-navigation-screen-templates-browse\">\n\t\t\t<SidebarNavigationItem\n\t\t\t\tto=\"/template\"\n\t\t\t\ticon={ layout }\n\t\t\t\taria-current={ activeView === 'active' }\n\t\t\t>\n\t\t\t\t{ __( 'Active templates' ) }\n\t\t\t</SidebarNavigationItem>\n\t\t\t<SidebarNavigationItem\n\t\t\t\tto={ addQueryArgs( '/template', { activeView: 'user' } ) }\n\t\t\t\ticon={ layout }\n\t\t\t\taria-current={ activeView === 'user' }\n\t\t\t>\n\t\t\t\t{ __( 'Custom templates' ) }\n\t\t\t</SidebarNavigationItem>\n\t\t\t{ firstItemPerAuthorText.map( ( template ) => {\n\t\t\t\treturn (\n\t\t\t\t\t<TemplateDataviewItem\n\t\t\t\t\t\tkey={ template.author_text }\n\t\t\t\t\t\ttemplate={ template }\n\t\t\t\t\t\tisActive={ activeView === template.author_text }\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</ItemGroup>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AACA,IAAAK,IAAA,GAAAL,OAAA;AAKA,IAAAM,sBAAA,GAAAC,sBAAA,CAAAP,OAAA;AACA,IAAAQ,MAAA,GAAAR,OAAA;AACA,IAAAS,MAAA,GAAAT,OAAA;AACA,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pageItemRoute, _pages.pagesRoute, _templateItem.templateItemRoute, _templates.templatesRoute, _templatePartItem.templatePartItemRoute, _patternItem.patternItemRoute, _patterns.patternsRoute, _navigationItem.navigationItemRoute, _navigation.navigationRoute, _styles.stylesRoute, _home.homeRoute, _stylebook.stylebookRoute, _notfound.notFoundRoute];
|
|
32
|
+
const routes = [_pageItem.pageItemRoute, _pages.pagesRoute, _templateItem.templateItemRoute, _templateItem.staticTemplateItemRoute, _templates.templatesRoute, _templatePartItem.templatePartItemRoute, _patternItem.patternItemRoute, _patterns.patternsRoute, _navigationItem.navigationItemRoute, _navigation.navigationRoute, _styles.stylesRoute, _home.homeRoute, _stylebook.stylebookRoute, _notfound.notFoundRoute];
|
|
33
33
|
function useRegisterSiteEditorRoutes() {
|
|
34
34
|
const registry = (0, _data.useRegistry)();
|
|
35
35
|
const {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_data","require","_element","_lockUnlock","_store","_home","_styles","_navigation","_navigationItem","_patterns","_patternItem","_templatePartItem","_templates","_templateItem","_pages","_pageItem","_stylebook","_notfound","routes","pageItemRoute","pagesRoute","templateItemRoute","templatesRoute","templatePartItemRoute","patternItemRoute","patternsRoute","navigationItemRoute","navigationRoute","stylesRoute","homeRoute","stylebookRoute","notFoundRoute","useRegisterSiteEditorRoutes","registry","useRegistry","registerRoute","unlock","useDispatch","siteEditorStore","useEffect","batch","forEach"],"sources":["@wordpress/edit-site/src/components/site-editor-routes/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRegistry, useDispatch } from '@wordpress/data';\nimport { useEffect } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\nimport { store as siteEditorStore } from '../../store';\nimport { homeRoute } from './home';\nimport { stylesRoute } from './styles';\nimport { navigationRoute } from './navigation';\nimport { navigationItemRoute } from './navigation-item';\nimport { patternsRoute } from './patterns';\nimport { patternItemRoute } from './pattern-item';\nimport { templatePartItemRoute } from './template-part-item';\nimport { templatesRoute } from './templates';\nimport { templateItemRoute } from './template-item';\nimport { pagesRoute } from './pages';\nimport { pageItemRoute } from './page-item';\nimport { stylebookRoute } from './stylebook';\nimport { notFoundRoute } from './notfound';\n\nconst routes = [\n\tpageItemRoute,\n\tpagesRoute,\n\ttemplateItemRoute,\n\ttemplatesRoute,\n\ttemplatePartItemRoute,\n\tpatternItemRoute,\n\tpatternsRoute,\n\tnavigationItemRoute,\n\tnavigationRoute,\n\tstylesRoute,\n\thomeRoute,\n\tstylebookRoute,\n\tnotFoundRoute,\n];\n\nexport function useRegisterSiteEditorRoutes() {\n\tconst registry = useRegistry();\n\tconst { registerRoute } = unlock( useDispatch( siteEditorStore ) );\n\tuseEffect( () => {\n\t\tregistry.batch( () => {\n\t\t\troutes.forEach( registerRoute );\n\t\t} );\n\t}, [ registry, registerRoute ] );\n}\n"],"mappings":";;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAKA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AACA,IAAAK,OAAA,GAAAL,OAAA;AACA,IAAAM,WAAA,GAAAN,OAAA;AACA,IAAAO,eAAA,GAAAP,OAAA;AACA,IAAAQ,SAAA,GAAAR,OAAA;AACA,IAAAS,YAAA,GAAAT,OAAA;AACA,IAAAU,iBAAA,GAAAV,OAAA;AACA,IAAAW,UAAA,GAAAX,OAAA;AACA,IAAAY,aAAA,GAAAZ,OAAA;AACA,IAAAa,MAAA,GAAAb,OAAA;AACA,IAAAc,SAAA,GAAAd,OAAA;AACA,IAAAe,UAAA,GAAAf,OAAA;AACA,IAAAgB,SAAA,GAAAhB,OAAA;AAvBA;AACA;AACA;;AAIA;AACA;AACA;;AAiBA,MAAMiB,MAAM,GAAG,CACdC,uBAAa,EACbC,iBAAU,EACVC,+BAAiB,EACjBC,yBAAc,EACdC,uCAAqB,EACrBC,6BAAgB,EAChBC,uBAAa,EACbC,mCAAmB,EACnBC,2BAAe,EACfC,mBAAW,EACXC,eAAS,EACTC,yBAAc,EACdC,uBAAa,CACb;AAEM,SAASC,2BAA2BA,CAAA,EAAG;EAC7C,MAAMC,QAAQ,GAAG,IAAAC,iBAAW,EAAC,CAAC;EAC9B,MAAM;IAAEC;EAAc,CAAC,GAAG,IAAAC,kBAAM,EAAE,IAAAC,iBAAW,EAAEC,YAAgB,CAAE,CAAC;EAClE,IAAAC,kBAAS,EAAE,MAAM;IAChBN,QAAQ,CAACO,KAAK,CAAE,MAAM;
|
|
1
|
+
{"version":3,"names":["_data","require","_element","_lockUnlock","_store","_home","_styles","_navigation","_navigationItem","_patterns","_patternItem","_templatePartItem","_templates","_templateItem","_pages","_pageItem","_stylebook","_notfound","routes","pageItemRoute","pagesRoute","templateItemRoute","staticTemplateItemRoute","templatesRoute","templatePartItemRoute","patternItemRoute","patternsRoute","navigationItemRoute","navigationRoute","stylesRoute","homeRoute","stylebookRoute","notFoundRoute","useRegisterSiteEditorRoutes","registry","useRegistry","registerRoute","unlock","useDispatch","siteEditorStore","useEffect","batch","forEach"],"sources":["@wordpress/edit-site/src/components/site-editor-routes/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRegistry, useDispatch } from '@wordpress/data';\nimport { useEffect } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\nimport { store as siteEditorStore } from '../../store';\nimport { homeRoute } from './home';\nimport { stylesRoute } from './styles';\nimport { navigationRoute } from './navigation';\nimport { navigationItemRoute } from './navigation-item';\nimport { patternsRoute } from './patterns';\nimport { patternItemRoute } from './pattern-item';\nimport { templatePartItemRoute } from './template-part-item';\nimport { templatesRoute } from './templates';\nimport { templateItemRoute, staticTemplateItemRoute } from './template-item';\nimport { pagesRoute } from './pages';\nimport { pageItemRoute } from './page-item';\nimport { stylebookRoute } from './stylebook';\nimport { notFoundRoute } from './notfound';\n\nconst routes = [\n\tpageItemRoute,\n\tpagesRoute,\n\ttemplateItemRoute,\n\tstaticTemplateItemRoute,\n\ttemplatesRoute,\n\ttemplatePartItemRoute,\n\tpatternItemRoute,\n\tpatternsRoute,\n\tnavigationItemRoute,\n\tnavigationRoute,\n\tstylesRoute,\n\thomeRoute,\n\tstylebookRoute,\n\tnotFoundRoute,\n];\n\nexport function useRegisterSiteEditorRoutes() {\n\tconst registry = useRegistry();\n\tconst { registerRoute } = unlock( useDispatch( siteEditorStore ) );\n\tuseEffect( () => {\n\t\tregistry.batch( () => {\n\t\t\troutes.forEach( registerRoute );\n\t\t} );\n\t}, [ registry, registerRoute ] );\n}\n"],"mappings":";;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAKA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AACA,IAAAK,OAAA,GAAAL,OAAA;AACA,IAAAM,WAAA,GAAAN,OAAA;AACA,IAAAO,eAAA,GAAAP,OAAA;AACA,IAAAQ,SAAA,GAAAR,OAAA;AACA,IAAAS,YAAA,GAAAT,OAAA;AACA,IAAAU,iBAAA,GAAAV,OAAA;AACA,IAAAW,UAAA,GAAAX,OAAA;AACA,IAAAY,aAAA,GAAAZ,OAAA;AACA,IAAAa,MAAA,GAAAb,OAAA;AACA,IAAAc,SAAA,GAAAd,OAAA;AACA,IAAAe,UAAA,GAAAf,OAAA;AACA,IAAAgB,SAAA,GAAAhB,OAAA;AAvBA;AACA;AACA;;AAIA;AACA;AACA;;AAiBA,MAAMiB,MAAM,GAAG,CACdC,uBAAa,EACbC,iBAAU,EACVC,+BAAiB,EACjBC,qCAAuB,EACvBC,yBAAc,EACdC,uCAAqB,EACrBC,6BAAgB,EAChBC,uBAAa,EACbC,mCAAmB,EACnBC,2BAAe,EACfC,mBAAW,EACXC,eAAS,EACTC,yBAAc,EACdC,uBAAa,CACb;AAEM,SAASC,2BAA2BA,CAAA,EAAG;EAC7C,MAAMC,QAAQ,GAAG,IAAAC,iBAAW,EAAC,CAAC;EAC9B,MAAM;IAAEC;EAAc,CAAC,GAAG,IAAAC,kBAAM,EAAE,IAAAC,iBAAW,EAAEC,YAAgB,CAAE,CAAC;EAClE,IAAAC,kBAAS,EAAE,MAAM;IAChBN,QAAQ,CAACO,KAAK,CAAE,MAAM;MACrBvB,MAAM,CAACwB,OAAO,CAAEN,aAAc,CAAC;IAChC,CAAE,CAAC;EACJ,CAAC,EAAE,CAAEF,QAAQ,EAAEE,aAAa,CAAG,CAAC;AACjC","ignoreList":[]}
|
|
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.templateItemRoute = void 0;
|
|
7
|
+
exports.templateItemRoute = exports.staticTemplateItemRoute = void 0;
|
|
8
8
|
var _editor = _interopRequireDefault(require("../editor"));
|
|
9
9
|
var _sidebarNavigationScreenTemplatesBrowse = _interopRequireDefault(require("../sidebar-navigation-screen-templates-browse"));
|
|
10
10
|
var _sidebarNavigationScreenUnsupported = _interopRequireDefault(require("../sidebar-navigation-screen-unsupported"));
|
|
@@ -13,30 +13,36 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
13
13
|
* Internal dependencies
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
|
+
const areas = {
|
|
17
|
+
sidebar({
|
|
18
|
+
siteData
|
|
19
|
+
}) {
|
|
20
|
+
const isBlockTheme = siteData.currentTheme?.is_block_theme;
|
|
21
|
+
return isBlockTheme ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_sidebarNavigationScreenTemplatesBrowse.default, {
|
|
22
|
+
backPath: "/"
|
|
23
|
+
}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_sidebarNavigationScreenUnsupported.default, {});
|
|
24
|
+
},
|
|
25
|
+
mobile({
|
|
26
|
+
siteData
|
|
27
|
+
}) {
|
|
28
|
+
const isBlockTheme = siteData.currentTheme?.is_block_theme;
|
|
29
|
+
return isBlockTheme ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_editor.default, {}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_sidebarNavigationScreenUnsupported.default, {});
|
|
30
|
+
},
|
|
31
|
+
preview({
|
|
32
|
+
siteData
|
|
33
|
+
}) {
|
|
34
|
+
const isBlockTheme = siteData.currentTheme?.is_block_theme;
|
|
35
|
+
return isBlockTheme ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_editor.default, {}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_sidebarNavigationScreenUnsupported.default, {});
|
|
36
|
+
}
|
|
37
|
+
};
|
|
16
38
|
const templateItemRoute = exports.templateItemRoute = {
|
|
17
39
|
name: 'template-item',
|
|
18
40
|
path: '/wp_template/*postId',
|
|
19
|
-
areas
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
backPath: "/"
|
|
26
|
-
}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_sidebarNavigationScreenUnsupported.default, {});
|
|
27
|
-
},
|
|
28
|
-
mobile({
|
|
29
|
-
siteData
|
|
30
|
-
}) {
|
|
31
|
-
const isBlockTheme = siteData.currentTheme?.is_block_theme;
|
|
32
|
-
return isBlockTheme ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_editor.default, {}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_sidebarNavigationScreenUnsupported.default, {});
|
|
33
|
-
},
|
|
34
|
-
preview({
|
|
35
|
-
siteData
|
|
36
|
-
}) {
|
|
37
|
-
const isBlockTheme = siteData.currentTheme?.is_block_theme;
|
|
38
|
-
return isBlockTheme ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_editor.default, {}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_sidebarNavigationScreenUnsupported.default, {});
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
+
areas
|
|
42
|
+
};
|
|
43
|
+
const staticTemplateItemRoute = exports.staticTemplateItemRoute = {
|
|
44
|
+
name: 'static-template-item',
|
|
45
|
+
path: '/wp_registered_template/*postId',
|
|
46
|
+
areas
|
|
41
47
|
};
|
|
42
48
|
//# sourceMappingURL=template-item.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_editor","_interopRequireDefault","require","_sidebarNavigationScreenTemplatesBrowse","_sidebarNavigationScreenUnsupported","_jsxRuntime","
|
|
1
|
+
{"version":3,"names":["_editor","_interopRequireDefault","require","_sidebarNavigationScreenTemplatesBrowse","_sidebarNavigationScreenUnsupported","_jsxRuntime","areas","sidebar","siteData","isBlockTheme","currentTheme","is_block_theme","jsx","default","backPath","mobile","preview","templateItemRoute","exports","name","path","staticTemplateItemRoute"],"sources":["@wordpress/edit-site/src/components/site-editor-routes/template-item.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport Editor from '../editor';\nimport SidebarNavigationScreenTemplatesBrowse from '../sidebar-navigation-screen-templates-browse';\nimport SidebarNavigationScreenUnsupported from '../sidebar-navigation-screen-unsupported';\n\nconst areas = {\n\tsidebar( { siteData } ) {\n\t\tconst isBlockTheme = siteData.currentTheme?.is_block_theme;\n\t\treturn isBlockTheme ? (\n\t\t\t<SidebarNavigationScreenTemplatesBrowse backPath=\"/\" />\n\t\t) : (\n\t\t\t<SidebarNavigationScreenUnsupported />\n\t\t);\n\t},\n\tmobile( { siteData } ) {\n\t\tconst isBlockTheme = siteData.currentTheme?.is_block_theme;\n\t\treturn isBlockTheme ? (\n\t\t\t<Editor />\n\t\t) : (\n\t\t\t<SidebarNavigationScreenUnsupported />\n\t\t);\n\t},\n\tpreview( { siteData } ) {\n\t\tconst isBlockTheme = siteData.currentTheme?.is_block_theme;\n\t\treturn isBlockTheme ? (\n\t\t\t<Editor />\n\t\t) : (\n\t\t\t<SidebarNavigationScreenUnsupported />\n\t\t);\n\t},\n};\n\nexport const templateItemRoute = {\n\tname: 'template-item',\n\tpath: '/wp_template/*postId',\n\tareas,\n};\n\nexport const staticTemplateItemRoute = {\n\tname: 'static-template-item',\n\tpath: '/wp_registered_template/*postId',\n\tareas,\n};\n"],"mappings":";;;;;;;AAGA,IAAAA,OAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,uCAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,mCAAA,GAAAH,sBAAA,CAAAC,OAAA;AAA0F,IAAAG,WAAA,GAAAH,OAAA;AAL1F;AACA;AACA;;AAKA,MAAMI,KAAK,GAAG;EACbC,OAAOA,CAAE;IAAEC;EAAS,CAAC,EAAG;IACvB,MAAMC,YAAY,GAAGD,QAAQ,CAACE,YAAY,EAAEC,cAAc;IAC1D,OAAOF,YAAY,gBAClB,IAAAJ,WAAA,CAAAO,GAAA,EAACT,uCAAA,CAAAU,OAAsC;MAACC,QAAQ,EAAC;IAAG,CAAE,CAAC,gBAEvD,IAAAT,WAAA,CAAAO,GAAA,EAACR,mCAAA,CAAAS,OAAkC,IAAE,CACrC;EACF,CAAC;EACDE,MAAMA,CAAE;IAAEP;EAAS,CAAC,EAAG;IACtB,MAAMC,YAAY,GAAGD,QAAQ,CAACE,YAAY,EAAEC,cAAc;IAC1D,OAAOF,YAAY,gBAClB,IAAAJ,WAAA,CAAAO,GAAA,EAACZ,OAAA,CAAAa,OAAM,IAAE,CAAC,gBAEV,IAAAR,WAAA,CAAAO,GAAA,EAACR,mCAAA,CAAAS,OAAkC,IAAE,CACrC;EACF,CAAC;EACDG,OAAOA,CAAE;IAAER;EAAS,CAAC,EAAG;IACvB,MAAMC,YAAY,GAAGD,QAAQ,CAACE,YAAY,EAAEC,cAAc;IAC1D,OAAOF,YAAY,gBAClB,IAAAJ,WAAA,CAAAO,GAAA,EAACZ,OAAA,CAAAa,OAAM,IAAE,CAAC,gBAEV,IAAAR,WAAA,CAAAO,GAAA,EAACR,mCAAA,CAAAS,OAAkC,IAAE,CACrC;EACF;AACD,CAAC;AAEM,MAAMI,iBAAiB,GAAAC,OAAA,CAAAD,iBAAA,GAAG;EAChCE,IAAI,EAAE,eAAe;EACrBC,IAAI,EAAE,sBAAsB;EAC5Bd;AACD,CAAC;AAEM,MAAMe,uBAAuB,GAAAH,OAAA,CAAAG,uBAAA,GAAG;EACtCF,IAAI,EAAE,sBAAsB;EAC5BC,IAAI,EAAE,iCAAiC;EACvCd;AACD,CAAC","ignoreList":[]}
|
|
@@ -8,6 +8,7 @@ import { useEntityRecords } from '@wordpress/core-data';
|
|
|
8
8
|
import { decodeEntities } from '@wordpress/html-entities';
|
|
9
9
|
import { useDebouncedInput } from '@wordpress/compose';
|
|
10
10
|
import { focus } from '@wordpress/dom';
|
|
11
|
+
import { safeDecodeURI } from '@wordpress/url';
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
14
|
* Internal dependencies
|
|
@@ -44,7 +45,7 @@ function SuggestionListItem({
|
|
|
44
45
|
lineHeight: 1.53846153846 // 20px
|
|
45
46
|
,
|
|
46
47
|
className: `${baseCssClass}__info`,
|
|
47
|
-
children: suggestion.link
|
|
48
|
+
children: safeDecodeURI(suggestion.link)
|
|
48
49
|
})]
|
|
49
50
|
});
|
|
50
51
|
}
|
|
@@ -125,7 +126,7 @@ function AddCustomTemplateModalContent({
|
|
|
125
126
|
onBack,
|
|
126
127
|
containerRef
|
|
127
128
|
}) {
|
|
128
|
-
const [showSearchEntities, setShowSearchEntities] = useState(
|
|
129
|
+
const [showSearchEntities, setShowSearchEntities] = useState();
|
|
129
130
|
|
|
130
131
|
// Focus on the first focusable element when the modal opens.
|
|
131
132
|
// We handle focus management in the parent modal, just need to focus on the first focusable element.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useState","useMemo","useEffect","__","Button","Flex","FlexItem","SearchControl","TextHighlight","Composite","__experimentalText","Text","__experimentalVStack","VStack","useEntityRecords","decodeEntities","useDebouncedInput","focus","mapToIHasNameAndId","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","EMPTY_ARRAY","SuggestionListItem","suggestion","search","onSelect","entityForSuggestions","baseCssClass","Item","render","__next40pxDefaultSize","role","className","onClick","config","getSpecificTemplate","children","size","lineHeight","weight","text","name","highlight","link","useSearchSuggestions","query","order","context","per_page","queryArgs","records","searchResults","hasResolved","searchHasResolved","type","slug","suggestions","setSuggestions","newSuggestions","length","recordNamePath","SuggestionList","setSearch","debouncedSearch","labels","showSearchControl","setShowSearchControl","__nextHasNoMarginBottom","onChange","value","label","search_items","placeholder","orientation","map","as","not_found","AddCustomTemplateModalContent","onBack","containerRef","showSearchEntities","setShowSearchEntities","hasGeneralTemplate","current","firstFocusable","focusable","find","spacing","alignment","gap","align","isBlock","title","description","templatePrefix","template","all_items","singular_name","justify","variant"],"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\t\tentityForSuggestions.hasGeneralTemplate\n\t);\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\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sB;UAAC,CAEvB,CAAC;QAAA,CACE,CAAC;MAAA,CACN,CAAC,eACPiB,IAAA,CAACf,IAAI;QAACiG,OAAO,EAAC,OAAO;QAAA9D,QAAA,eACpBpB,IAAA,CAAChB,MAAM;UACN8B,qBAAqB;UACrBqE,OAAO,EAAC,UAAU;UAClBlE,OAAO,EAAG6C,MAAQ;UAAA1C,QAAA,EAEhBrC,EAAE,CAAE,MAAO;QAAC,CACP;MAAC,CACJ,CAAC;IAAA,CACN,CACF,EACCiF,kBAAkB,iBACnB9D,KAAA,CAAAE,SAAA;MAAAgB,QAAA,gBACCpB,IAAA,CAACT,IAAI;QAACoE,EAAE,EAAC,GAAG;QAAAvC,QAAA,EACTrC,EAAE,CACH,+DACD;MAAC,CACI,CAAC,eACPiB,IAAA,CAAC6C,cAAc;QACdnC,oBAAoB,EAAGA,oBAAsB;QAC7CD,QAAQ,EAAGA;MAAU,CACrB,CAAC,eACFT,IAAA,CAACf,IAAI;QAACiG,OAAO,EAAC,OAAO;QAAA9D,QAAA,eACpBpB,IAAA,CAAChB,MAAM;UACN8B,qBAAqB;UACrBqE,OAAO,EAAC,UAAU;UAClBlE,OAAO,EAAGA,CAAA,KAAM;YACf;YACA;YACA,IAAKP,oBAAoB,CAACwD,kBAAkB,EAAG;cAC9CJ,MAAM,CAAC,CAAC;YACT,CAAC,MAAM;cACNG,qBAAqB,CAAE,KAAM,CAAC;YAC/B;UACD,CAAG;UAAA7C,QAAA,EAEDrC,EAAE,CAAE,MAAO;QAAC,CACP;MAAC,CACJ,CAAC;IAAA,CACN,CACF;EAAA,CACM,CAAC;AAEX;AAEA,eAAe8E,6BAA6B","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["useState","useMemo","useEffect","__","Button","Flex","FlexItem","SearchControl","TextHighlight","Composite","__experimentalText","Text","__experimentalVStack","VStack","useEntityRecords","decodeEntities","useDebouncedInput","focus","safeDecodeURI","mapToIHasNameAndId","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","EMPTY_ARRAY","SuggestionListItem","suggestion","search","onSelect","entityForSuggestions","baseCssClass","Item","render","__next40pxDefaultSize","role","className","onClick","config","getSpecificTemplate","children","size","lineHeight","weight","text","name","highlight","link","useSearchSuggestions","query","order","context","per_page","queryArgs","records","searchResults","hasResolved","searchHasResolved","type","slug","suggestions","setSuggestions","newSuggestions","length","recordNamePath","SuggestionList","setSearch","debouncedSearch","labels","showSearchControl","setShowSearchControl","__nextHasNoMarginBottom","onChange","value","label","search_items","placeholder","orientation","map","as","not_found","AddCustomTemplateModalContent","onBack","containerRef","showSearchEntities","setShowSearchEntities","current","firstFocusable","focusable","find","spacing","alignment","gap","align","isBlock","title","description","templatePrefix","template","all_items","singular_name","justify","variant","hasGeneralTemplate"],"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}\n\t\t\t\t\t\t\t} }\n\t\t\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AC,CAEvB,CAAC;QAAA,CACE,CAAC;MAAA,CACN,CAAC,eACPkB,IAAA,CAAChB,IAAI;QAACiG,OAAO,EAAC,OAAO;QAAA7D,QAAA,eACpBpB,IAAA,CAACjB,MAAM;UACN+B,qBAAqB;UACrBoE,OAAO,EAAC,UAAU;UAClBjE,OAAO,EAAG6C,MAAQ;UAAA1C,QAAA,EAEhBtC,EAAE,CAAE,MAAO;QAAC,CACP;MAAC,CACJ,CAAC;IAAA,CACN,CACF,EACCkF,kBAAkB,iBACnB9D,KAAA,CAAAE,SAAA;MAAAgB,QAAA,gBACCpB,IAAA,CAACV,IAAI;QAACqE,EAAE,EAAC,GAAG;QAAAvC,QAAA,EACTtC,EAAE,CACH,+DACD;MAAC,CACI,CAAC,eACPkB,IAAA,CAAC6C,cAAc;QACdnC,oBAAoB,EAAGA,oBAAsB;QAC7CD,QAAQ,EAAGA;MAAU,CACrB,CAAC,eACFT,IAAA,CAAChB,IAAI;QAACiG,OAAO,EAAC,OAAO;QAAA7D,QAAA,eACpBpB,IAAA,CAACjB,MAAM;UACN+B,qBAAqB;UACrBoE,OAAO,EAAC,UAAU;UAClBjE,OAAO,EAAGA,CAAA,KAAM;YACf;YACA;YACA,IAAKP,oBAAoB,CAACyE,kBAAkB,EAAG;cAC9CrB,MAAM,CAAC,CAAC;YACT,CAAC,MAAM;cACNG,qBAAqB,CAAE,KAAM,CAAC;YAC/B;UACD,CAAG;UAAA7C,QAAA,EAEDtC,EAAE,CAAE,MAAO;QAAC,CACP;MAAC,CACJ,CAAC;IAAA,CACN,CACF;EAAA,CACM,CAAC;AAEX;AAEA,eAAe+E,6BAA6B","ignoreList":[]}
|
|
@@ -27,7 +27,7 @@ import { TEMPLATE_POST_TYPE } from '../../utils/constants';
|
|
|
27
27
|
* Internal dependencies
|
|
28
28
|
*/
|
|
29
29
|
import AddCustomTemplateModalContent from './add-custom-template-modal-content';
|
|
30
|
-
import {
|
|
30
|
+
import { useDefaultTemplateTypes, useTaxonomiesMenuItems, usePostTypeMenuItems, useAuthorMenuItem, usePostTypeArchiveMenuItems } from './utils';
|
|
31
31
|
import AddCustomGenericTemplateModalContent from './add-custom-generic-template-modal-content';
|
|
32
32
|
import { unlock } from '../../lock-unlock';
|
|
33
33
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
@@ -269,12 +269,8 @@ function NewTemplate() {
|
|
|
269
269
|
});
|
|
270
270
|
}
|
|
271
271
|
function useMissingTemplates(setEntityForSuggestions, onClick) {
|
|
272
|
-
const existingTemplates = useExistingTemplates();
|
|
273
272
|
const defaultTemplateTypes = useDefaultTemplateTypes();
|
|
274
|
-
const
|
|
275
|
-
slug
|
|
276
|
-
}) => slug);
|
|
277
|
-
const missingDefaultTemplates = (defaultTemplateTypes || []).filter(template => DEFAULT_TEMPLATE_SLUGS.includes(template.slug) && !existingTemplateSlugs.includes(template.slug));
|
|
273
|
+
const missingDefaultTemplates = (defaultTemplateTypes || []).filter(template => DEFAULT_TEMPLATE_SLUGS.includes(template.slug));
|
|
278
274
|
const onClickMenuItem = _entityForSuggestions => {
|
|
279
275
|
onClick?.();
|
|
280
276
|
setEntityForSuggestions(_entityForSuggestions);
|