@wordpress/edit-site 3.0.19 → 3.0.24
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/block-editor/index.js +1 -1
- package/build/components/block-editor/index.js.map +1 -1
- package/build/components/block-editor/resizable-editor.js +37 -7
- package/build/components/block-editor/resizable-editor.js.map +1 -1
- package/build/components/navigation-sidebar/navigation-panel/constants.js +1 -11
- package/build/components/navigation-sidebar/navigation-panel/constants.js.map +1 -1
- package/build/plugins/site-export.js +1 -1
- package/build/plugins/site-export.js.map +1 -1
- package/build-module/components/block-editor/index.js +2 -2
- package/build-module/components/block-editor/index.js.map +1 -1
- package/build-module/components/block-editor/resizable-editor.js +37 -7
- package/build-module/components/block-editor/resizable-editor.js.map +1 -1
- package/build-module/components/navigation-sidebar/navigation-panel/constants.js +0 -5
- package/build-module/components/navigation-sidebar/navigation-panel/constants.js.map +1 -1
- package/build-module/plugins/site-export.js +2 -2
- package/build-module/plugins/site-export.js.map +1 -1
- package/build-style/style-rtl.css +11 -4
- package/build-style/style.css +11 -4
- package/package.json +8 -8
- package/src/components/block-editor/index.js +2 -2
- package/src/components/block-editor/resizable-editor.js +52 -12
- package/src/components/block-editor/style.scss +8 -0
- package/src/components/editor/style.scss +0 -1
- package/src/components/global-styles/style.scss +2 -1
- package/src/components/navigation-sidebar/navigation-panel/constants.js +0 -15
- package/src/components/navigation-sidebar/navigation-toggle/style.scss +8 -4
- package/src/plugins/site-export.js +2 -2
- package/build/components/navigation-sidebar/navigation-panel/content-navigation-item.js +0 -101
- package/build/components/navigation-sidebar/navigation-panel/content-navigation-item.js.map +0 -1
- package/build/components/navigation-sidebar/navigation-panel/menus/content-categories.js +0 -82
- package/build/components/navigation-sidebar/navigation-panel/menus/content-categories.js.map +0 -1
- package/build/components/navigation-sidebar/navigation-panel/menus/content-pages.js +0 -82
- package/build/components/navigation-sidebar/navigation-panel/menus/content-pages.js.map +0 -1
- package/build/components/navigation-sidebar/navigation-panel/menus/content-posts.js +0 -107
- package/build/components/navigation-sidebar/navigation-panel/menus/content-posts.js.map +0 -1
- package/build/components/navigation-sidebar/navigation-panel/menus/index.js +0 -57
- package/build/components/navigation-sidebar/navigation-panel/menus/index.js.map +0 -1
- package/build/components/navigation-sidebar/navigation-panel/menus/template-parts-sub.js +0 -48
- package/build/components/navigation-sidebar/navigation-panel/menus/template-parts-sub.js.map +0 -1
- package/build/components/navigation-sidebar/navigation-panel/menus/template-parts.js +0 -100
- package/build/components/navigation-sidebar/navigation-panel/menus/template-parts.js.map +0 -1
- package/build/components/navigation-sidebar/navigation-panel/menus/templates-sub.js +0 -62
- package/build/components/navigation-sidebar/navigation-panel/menus/templates-sub.js.map +0 -1
- package/build/components/navigation-sidebar/navigation-panel/menus/templates.js +0 -143
- package/build/components/navigation-sidebar/navigation-panel/menus/templates.js.map +0 -1
- package/build/components/navigation-sidebar/navigation-panel/navigation-entity-items.js +0 -76
- package/build/components/navigation-sidebar/navigation-panel/navigation-entity-items.js.map +0 -1
- package/build/components/navigation-sidebar/navigation-panel/new-template-dropdown.js +0 -125
- package/build/components/navigation-sidebar/navigation-panel/new-template-dropdown.js.map +0 -1
- package/build/components/navigation-sidebar/navigation-panel/search-results.js +0 -132
- package/build/components/navigation-sidebar/navigation-panel/search-results.js.map +0 -1
- package/build/components/navigation-sidebar/navigation-panel/template-navigation-item.js +0 -86
- package/build/components/navigation-sidebar/navigation-panel/template-navigation-item.js.map +0 -1
- package/build/components/navigation-sidebar/navigation-panel/template-preview.js +0 -46
- package/build/components/navigation-sidebar/navigation-panel/template-preview.js.map +0 -1
- package/build/components/navigation-sidebar/navigation-panel/use-debounced-search.js +0 -47
- package/build/components/navigation-sidebar/navigation-panel/use-debounced-search.js.map +0 -1
- package/build/components/navigation-sidebar/navigation-panel/utils.js +0 -21
- package/build/components/navigation-sidebar/navigation-panel/utils.js.map +0 -1
- package/build/utils/get-closest-available-template.js +0 -48
- package/build/utils/get-closest-available-template.js.map +0 -1
- package/build-module/components/navigation-sidebar/navigation-panel/content-navigation-item.js +0 -86
- package/build-module/components/navigation-sidebar/navigation-panel/content-navigation-item.js.map +0 -1
- package/build-module/components/navigation-sidebar/navigation-panel/menus/content-categories.js +0 -65
- package/build-module/components/navigation-sidebar/navigation-panel/menus/content-categories.js.map +0 -1
- package/build-module/components/navigation-sidebar/navigation-panel/menus/content-pages.js +0 -65
- package/build-module/components/navigation-sidebar/navigation-panel/menus/content-pages.js.map +0 -1
- package/build-module/components/navigation-sidebar/navigation-panel/menus/content-posts.js +0 -90
- package/build-module/components/navigation-sidebar/navigation-panel/menus/content-posts.js.map +0 -1
- package/build-module/components/navigation-sidebar/navigation-panel/menus/index.js +0 -40
- package/build-module/components/navigation-sidebar/navigation-panel/menus/index.js.map +0 -1
- package/build-module/components/navigation-sidebar/navigation-panel/menus/template-parts-sub.js +0 -35
- package/build-module/components/navigation-sidebar/navigation-panel/menus/template-parts-sub.js.map +0 -1
- package/build-module/components/navigation-sidebar/navigation-panel/menus/template-parts.js +0 -84
- package/build-module/components/navigation-sidebar/navigation-panel/menus/template-parts.js.map +0 -1
- package/build-module/components/navigation-sidebar/navigation-panel/menus/templates-sub.js +0 -50
- package/build-module/components/navigation-sidebar/navigation-panel/menus/templates-sub.js.map +0 -1
- package/build-module/components/navigation-sidebar/navigation-panel/menus/templates.js +0 -124
- package/build-module/components/navigation-sidebar/navigation-panel/menus/templates.js.map +0 -1
- package/build-module/components/navigation-sidebar/navigation-panel/navigation-entity-items.js +0 -65
- package/build-module/components/navigation-sidebar/navigation-panel/navigation-entity-items.js.map +0 -1
- package/build-module/components/navigation-sidebar/navigation-panel/new-template-dropdown.js +0 -106
- package/build-module/components/navigation-sidebar/navigation-panel/new-template-dropdown.js.map +0 -1
- package/build-module/components/navigation-sidebar/navigation-panel/search-results.js +0 -116
- package/build-module/components/navigation-sidebar/navigation-panel/search-results.js.map +0 -1
- package/build-module/components/navigation-sidebar/navigation-panel/template-navigation-item.js +0 -71
- package/build-module/components/navigation-sidebar/navigation-panel/template-navigation-item.js.map +0 -1
- package/build-module/components/navigation-sidebar/navigation-panel/template-preview.js +0 -38
- package/build-module/components/navigation-sidebar/navigation-panel/template-preview.js.map +0 -1
- package/build-module/components/navigation-sidebar/navigation-panel/use-debounced-search.js +0 -37
- package/build-module/components/navigation-sidebar/navigation-panel/use-debounced-search.js.map +0 -1
- package/build-module/components/navigation-sidebar/navigation-panel/utils.js +0 -8
- package/build-module/components/navigation-sidebar/navigation-panel/utils.js.map +0 -1
- package/build-module/utils/get-closest-available-template.js +0 -40
- package/build-module/utils/get-closest-available-template.js.map +0 -1
- package/src/components/navigation-sidebar/navigation-panel/content-navigation-item.js +0 -89
- package/src/components/navigation-sidebar/navigation-panel/menus/content-categories.js +0 -85
- package/src/components/navigation-sidebar/navigation-panel/menus/content-pages.js +0 -85
- package/src/components/navigation-sidebar/navigation-panel/menus/content-posts.js +0 -117
- package/src/components/navigation-sidebar/navigation-panel/menus/index.js +0 -61
- package/src/components/navigation-sidebar/navigation-panel/menus/template-parts-sub.js +0 -34
- package/src/components/navigation-sidebar/navigation-panel/menus/template-parts.js +0 -94
- package/src/components/navigation-sidebar/navigation-panel/menus/templates-sub.js +0 -42
- package/src/components/navigation-sidebar/navigation-panel/menus/templates.js +0 -147
- package/src/components/navigation-sidebar/navigation-panel/navigation-entity-items.js +0 -53
- package/src/components/navigation-sidebar/navigation-panel/new-template-dropdown.js +0 -110
- package/src/components/navigation-sidebar/navigation-panel/search-results.js +0 -117
- package/src/components/navigation-sidebar/navigation-panel/template-navigation-item.js +0 -83
- package/src/components/navigation-sidebar/navigation-panel/template-preview.js +0 -32
- package/src/components/navigation-sidebar/navigation-panel/use-debounced-search.js +0 -47
- package/src/components/navigation-sidebar/navigation-panel/utils.js +0 -11
- package/src/utils/get-closest-available-template.js +0 -31
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.default = ContentPostsMenu;
|
|
9
|
-
|
|
10
|
-
var _element = require("@wordpress/element");
|
|
11
|
-
|
|
12
|
-
var _components = require("@wordpress/components");
|
|
13
|
-
|
|
14
|
-
var _i18n = require("@wordpress/i18n");
|
|
15
|
-
|
|
16
|
-
var _data = require("@wordpress/data");
|
|
17
|
-
|
|
18
|
-
var _coreData = require("@wordpress/core-data");
|
|
19
|
-
|
|
20
|
-
var _constants = require("../constants");
|
|
21
|
-
|
|
22
|
-
var _contentNavigationItem = _interopRequireDefault(require("../content-navigation-item"));
|
|
23
|
-
|
|
24
|
-
var _searchResults = _interopRequireDefault(require("../search-results"));
|
|
25
|
-
|
|
26
|
-
var _useDebouncedSearch = _interopRequireDefault(require("../use-debounced-search"));
|
|
27
|
-
|
|
28
|
-
var _store = require("../../../../store");
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* WordPress dependencies
|
|
32
|
-
*/
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Internal dependencies
|
|
36
|
-
*/
|
|
37
|
-
function ContentPostsMenu() {
|
|
38
|
-
const {
|
|
39
|
-
search,
|
|
40
|
-
searchQuery,
|
|
41
|
-
onSearch,
|
|
42
|
-
isDebouncing
|
|
43
|
-
} = (0, _useDebouncedSearch.default)();
|
|
44
|
-
const {
|
|
45
|
-
posts,
|
|
46
|
-
showOnFront,
|
|
47
|
-
isResolved
|
|
48
|
-
} = (0, _data.useSelect)(select => {
|
|
49
|
-
const {
|
|
50
|
-
getEntityRecords,
|
|
51
|
-
getEditedEntityRecord,
|
|
52
|
-
hasFinishedResolution
|
|
53
|
-
} = select(_coreData.store);
|
|
54
|
-
const query = searchQuery ? {
|
|
55
|
-
search: searchQuery
|
|
56
|
-
} : undefined;
|
|
57
|
-
const getEntityRecodsArgs = ['postType', 'post', query];
|
|
58
|
-
const hasResolvedPosts = hasFinishedResolution('getEntityRecords', getEntityRecodsArgs);
|
|
59
|
-
return {
|
|
60
|
-
posts: getEntityRecords(...getEntityRecodsArgs),
|
|
61
|
-
isResolved: hasResolvedPosts,
|
|
62
|
-
showOnFront: getEditedEntityRecord('root', 'site').show_on_front
|
|
63
|
-
};
|
|
64
|
-
}, [searchQuery]);
|
|
65
|
-
const {
|
|
66
|
-
setPage,
|
|
67
|
-
setIsNavigationPanelOpened
|
|
68
|
-
} = (0, _data.useDispatch)(_store.store);
|
|
69
|
-
const onActivateFrontItem = (0, _element.useCallback)(() => {
|
|
70
|
-
setPage({
|
|
71
|
-
type: 'page',
|
|
72
|
-
path: '/',
|
|
73
|
-
context: {
|
|
74
|
-
queryContext: {
|
|
75
|
-
page: 1
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
setIsNavigationPanelOpened(false);
|
|
80
|
-
}, [setPage, setIsNavigationPanelOpened]);
|
|
81
|
-
const shouldShowLoadingForDebouncing = search && isDebouncing;
|
|
82
|
-
const showLoading = !isResolved || shouldShowLoadingForDebouncing;
|
|
83
|
-
return (0, _element.createElement)(_components.__experimentalNavigationMenu, {
|
|
84
|
-
menu: _constants.MENU_CONTENT_POSTS,
|
|
85
|
-
title: (0, _i18n.__)('Posts'),
|
|
86
|
-
parentMenu: _constants.MENU_ROOT,
|
|
87
|
-
hasSearch: true,
|
|
88
|
-
onSearch: onSearch,
|
|
89
|
-
search: search,
|
|
90
|
-
isSearchDebouncing: isDebouncing || !isResolved
|
|
91
|
-
}, search && !isDebouncing && (0, _element.createElement)(_searchResults.default, {
|
|
92
|
-
items: posts,
|
|
93
|
-
search: search,
|
|
94
|
-
disableFilter: true
|
|
95
|
-
}), !search && (0, _element.createElement)(_element.Fragment, null, showOnFront === 'posts' && (0, _element.createElement)(_components.__experimentalNavigationItem, {
|
|
96
|
-
item: 'post-/',
|
|
97
|
-
title: (0, _i18n.__)('All Posts'),
|
|
98
|
-
onClick: onActivateFrontItem
|
|
99
|
-
}), posts === null || posts === void 0 ? void 0 : posts.map(post => (0, _element.createElement)(_contentNavigationItem.default, {
|
|
100
|
-
item: post,
|
|
101
|
-
key: `${post.type}-${post.id}`
|
|
102
|
-
}))), showLoading && (0, _element.createElement)(_components.__experimentalNavigationItem, {
|
|
103
|
-
title: (0, _i18n.__)('Loading…'),
|
|
104
|
-
isText: true
|
|
105
|
-
}));
|
|
106
|
-
}
|
|
107
|
-
//# sourceMappingURL=content-posts.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/navigation-sidebar/navigation-panel/menus/content-posts.js"],"names":["ContentPostsMenu","search","searchQuery","onSearch","isDebouncing","posts","showOnFront","isResolved","select","getEntityRecords","getEditedEntityRecord","hasFinishedResolution","coreStore","query","undefined","getEntityRecodsArgs","hasResolvedPosts","show_on_front","setPage","setIsNavigationPanelOpened","editSiteStore","onActivateFrontItem","type","path","context","queryContext","page","shouldShowLoadingForDebouncing","showLoading","MENU_CONTENT_POSTS","MENU_ROOT","map","post","id"],"mappings":";;;;;;;;;AAQA;;AALA;;AAIA;;AAEA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AAnBA;AACA;AACA;;AAUA;AACA;AACA;AAOe,SAASA,gBAAT,GAA4B;AAC1C,QAAM;AACLC,IAAAA,MADK;AAELC,IAAAA,WAFK;AAGLC,IAAAA,QAHK;AAILC,IAAAA;AAJK,MAKF,kCALJ;AAOA,QAAM;AAAEC,IAAAA,KAAF;AAASC,IAAAA,WAAT;AAAsBC,IAAAA;AAAtB,MAAqC,qBACxCC,MAAF,IAAc;AACb,UAAM;AACLC,MAAAA,gBADK;AAELC,MAAAA,qBAFK;AAGLC,MAAAA;AAHK,QAIFH,MAAM,CAAEI,eAAF,CAJV;AAKA,UAAMC,KAAK,GAAGX,WAAW,GACtB;AACAD,MAAAA,MAAM,EAAEC;AADR,KADsB,GAItBY,SAJH;AAKA,UAAM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C,sBAAD;AACC,IAAA,KAAK,EAAGC,KADT;AAEC,IAAA,MAAM,EAAGJ,MAFV;AAGC,IAAA,aAAa;AAHd,IAVF,EAiBG,CAAEA,MAAF,IACD,qDACGK,WAAW,KAAK,OAAhB,IACD,4BAAC,wCAAD;AACC,IAAA,IAAI,EAAG,QADR;AAEC,IAAA,KAAK,EAAG,cAAI,WAAJ,CAFT;AAGC,IAAA,OAAO,EAAGe;AAHX,IAFF,EASGhB,KATH,aASGA,KATH,uBASGA,KAAK,CAAE0B,GAAP,CAAcC,IAAF,IACb,4BAAC,8BAAD;AACC,IAAA,IAAI,EAAGA,IADR;AAEC,IAAA,GAAG,EAAI,GAAGA,IAAI,CAACV,IAAM,IAAIU,IAAI,CAACC,EAAI;AAFnC,IADC,CATH,CAlBF,EAoCGL,WAAW,IACZ,4BAAC,wCAAD;AAAgB,IAAA,KAAK,EAAG,cAAI,UAAJ,CAAxB;AAA2C,IAAA,MAAM;AAAjD,IArCF,CADD;AA0CA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalNavigationMenu as NavigationMenu,\n\t__experimentalNavigationItem as NavigationItem,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useCallback } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { MENU_CONTENT_POSTS, MENU_ROOT } from '../constants';\nimport ContentNavigationItem from '../content-navigation-item';\nimport SearchResults from '../search-results';\nimport useDebouncedSearch from '../use-debounced-search';\nimport { store as editSiteStore } from '../../../../store';\n\nexport default function ContentPostsMenu() {\n\tconst {\n\t\tsearch,\n\t\tsearchQuery,\n\t\tonSearch,\n\t\tisDebouncing,\n\t} = useDebouncedSearch();\n\n\tconst { posts, showOnFront, isResolved } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetEntityRecords,\n\t\t\t\tgetEditedEntityRecord,\n\t\t\t\thasFinishedResolution,\n\t\t\t} = select( coreStore );\n\t\t\tconst query = searchQuery\n\t\t\t\t? {\n\t\t\t\t\t\tsearch: searchQuery,\n\t\t\t\t }\n\t\t\t\t: undefined;\n\t\t\tconst getEntityRecodsArgs = [ 'postType', 'post', query ];\n\t\t\tconst hasResolvedPosts = hasFinishedResolution(\n\t\t\t\t'getEntityRecords',\n\t\t\t\tgetEntityRecodsArgs\n\t\t\t);\n\t\t\treturn {\n\t\t\t\tposts: getEntityRecords( ...getEntityRecodsArgs ),\n\t\t\t\tisResolved: hasResolvedPosts,\n\t\t\t\tshowOnFront: getEditedEntityRecord( 'root', 'site' )\n\t\t\t\t\t.show_on_front,\n\t\t\t};\n\t\t},\n\t\t[ searchQuery ]\n\t);\n\n\tconst { setPage, setIsNavigationPanelOpened } = useDispatch(\n\t\teditSiteStore\n\t);\n\n\tconst onActivateFrontItem = useCallback( () => {\n\t\tsetPage( {\n\t\t\ttype: 'page',\n\t\t\tpath: '/',\n\t\t\tcontext: {\n\t\t\t\tqueryContext: { page: 1 },\n\t\t\t},\n\t\t} );\n\t\tsetIsNavigationPanelOpened( false );\n\t}, [ setPage, setIsNavigationPanelOpened ] );\n\n\tconst shouldShowLoadingForDebouncing = search && isDebouncing;\n\tconst showLoading = ! isResolved || shouldShowLoadingForDebouncing;\n\n\treturn (\n\t\t<NavigationMenu\n\t\t\tmenu={ MENU_CONTENT_POSTS }\n\t\t\ttitle={ __( 'Posts' ) }\n\t\t\tparentMenu={ MENU_ROOT }\n\t\t\thasSearch={ true }\n\t\t\tonSearch={ onSearch }\n\t\t\tsearch={ search }\n\t\t\tisSearchDebouncing={ isDebouncing || ! isResolved }\n\t\t>\n\t\t\t{ search && ! isDebouncing && (\n\t\t\t\t<SearchResults\n\t\t\t\t\titems={ posts }\n\t\t\t\t\tsearch={ search }\n\t\t\t\t\tdisableFilter\n\t\t\t\t/>\n\t\t\t) }\n\n\t\t\t{ ! search && (\n\t\t\t\t<>\n\t\t\t\t\t{ showOnFront === 'posts' && (\n\t\t\t\t\t\t<NavigationItem\n\t\t\t\t\t\t\titem={ 'post-/' }\n\t\t\t\t\t\t\ttitle={ __( 'All Posts' ) }\n\t\t\t\t\t\t\tonClick={ onActivateFrontItem }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\n\t\t\t\t\t{ posts?.map( ( post ) => (\n\t\t\t\t\t\t<ContentNavigationItem\n\t\t\t\t\t\t\titem={ post }\n\t\t\t\t\t\t\tkey={ `${ post.type }-${ post.id }` }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) ) }\n\t\t\t\t</>\n\t\t\t) }\n\n\t\t\t{ showLoading && (\n\t\t\t\t<NavigationItem title={ __( 'Loading…' ) } isText />\n\t\t\t) }\n\t\t</NavigationMenu>\n\t);\n}\n"]}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.default = SiteMenu;
|
|
9
|
-
|
|
10
|
-
var _element = require("@wordpress/element");
|
|
11
|
-
|
|
12
|
-
var _components = require("@wordpress/components");
|
|
13
|
-
|
|
14
|
-
var _i18n = require("@wordpress/i18n");
|
|
15
|
-
|
|
16
|
-
var _constants = require("../constants");
|
|
17
|
-
|
|
18
|
-
var _contentPages = _interopRequireDefault(require("./content-pages"));
|
|
19
|
-
|
|
20
|
-
var _contentCategories = _interopRequireDefault(require("./content-categories"));
|
|
21
|
-
|
|
22
|
-
var _contentPosts = _interopRequireDefault(require("./content-posts"));
|
|
23
|
-
|
|
24
|
-
var _templates = _interopRequireDefault(require("./templates"));
|
|
25
|
-
|
|
26
|
-
var _templateParts = _interopRequireDefault(require("./template-parts"));
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* WordPress dependencies
|
|
30
|
-
*/
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Internal dependencies
|
|
34
|
-
*/
|
|
35
|
-
function SiteMenu() {
|
|
36
|
-
return (0, _element.createElement)(_components.__experimentalNavigationMenu, null, (0, _element.createElement)(_components.__experimentalNavigationGroup, {
|
|
37
|
-
title: (0, _i18n.__)('Theme')
|
|
38
|
-
}, (0, _element.createElement)(_components.__experimentalNavigationItem, {
|
|
39
|
-
title: (0, _i18n.__)('Templates'),
|
|
40
|
-
navigateToMenu: _constants.MENU_TEMPLATES
|
|
41
|
-
}), (0, _element.createElement)(_components.__experimentalNavigationItem, {
|
|
42
|
-
title: (0, _i18n.__)('Template Parts'),
|
|
43
|
-
navigateToMenu: _constants.MENU_TEMPLATE_PARTS
|
|
44
|
-
})), (0, _element.createElement)(_components.__experimentalNavigationGroup, {
|
|
45
|
-
title: (0, _i18n.__)('Content')
|
|
46
|
-
}, (0, _element.createElement)(_components.__experimentalNavigationItem, {
|
|
47
|
-
title: (0, _i18n.__)('Pages'),
|
|
48
|
-
navigateToMenu: _constants.MENU_CONTENT_PAGES
|
|
49
|
-
}), (0, _element.createElement)(_components.__experimentalNavigationItem, {
|
|
50
|
-
title: (0, _i18n.__)('Categories'),
|
|
51
|
-
navigateToMenu: _constants.MENU_CONTENT_CATEGORIES
|
|
52
|
-
}), (0, _element.createElement)(_components.__experimentalNavigationItem, {
|
|
53
|
-
title: (0, _i18n.__)('Posts'),
|
|
54
|
-
navigateToMenu: _constants.MENU_CONTENT_POSTS
|
|
55
|
-
})), (0, _element.createElement)(_templates.default, null), (0, _element.createElement)(_templateParts.default, null), (0, _element.createElement)(_contentPages.default, null), (0, _element.createElement)(_contentCategories.default, null), (0, _element.createElement)(_contentPosts.default, null));
|
|
56
|
-
}
|
|
57
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/navigation-sidebar/navigation-panel/menus/index.js"],"names":["SiteMenu","MENU_TEMPLATES","MENU_TEMPLATE_PARTS","MENU_CONTENT_PAGES","MENU_CONTENT_CATEGORIES","MENU_CONTENT_POSTS"],"mappings":";;;;;;;;;;;AAGA;;AAKA;;AAKA;;AAOA;;AACA;;AACA;;AACA;;AACA;;AAxBA;AACA;AACA;;AAQA;AACA;AACA;AAce,SAASA,QAAT,GAAoB;AAClC,SACC,4BAAC,wCAAD,QACC,4BAAC,yCAAD;AAAiB,IAAA,KAAK,EAAG,cAAI,OAAJ;AAAzB,KACC,4BAAC,wCAAD;AACC,IAAA,KAAK,EAAG,cAAI,WAAJ,CADT;AAEC,IAAA,cAAc,EAAGC;AAFlB,IADD,EAKC,4BAAC,wCAAD;AACC,IAAA,KAAK,EAAG,cAAI,gBAAJ,CADT;AAEC,IAAA,cAAc,EAAGC;AAFlB,IALD,CADD,EAWC,4BAAC,yCAAD;AAAiB,IAAA,KAAK,EAAG,cAAI,SAAJ;AAAzB,KACC,4BAAC,wCAAD;AACC,IAAA,KAAK,EAAG,cAAI,OAAJ,CADT;AAEC,IAAA,cAAc,EAAGC;AAFlB,IADD,EAKC,4BAAC,wCAAD;AACC,IAAA,KAAK,EAAG,cAAI,YAAJ,CADT;AAEC,IAAA,cAAc,EAAGC;AAFlB,IALD,EASC,4BAAC,wCAAD;AACC,IAAA,KAAK,EAAG,cAAI,OAAJ,CADT;AAEC,IAAA,cAAc,EAAGC;AAFlB,IATD,CAXD,EAyBC,4BAAC,kBAAD,OAzBD,EA0BC,4BAAC,sBAAD,OA1BD,EA2BC,4BAAC,qBAAD,OA3BD,EA4BC,4BAAC,0BAAD,OA5BD,EA6BC,4BAAC,qBAAD,OA7BD,CADD;AAiCA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalNavigationGroup as NavigationGroup,\n\t__experimentalNavigationItem as NavigationItem,\n\t__experimentalNavigationMenu as NavigationMenu,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport {\n\tMENU_TEMPLATES,\n\tMENU_TEMPLATE_PARTS,\n\tMENU_CONTENT_CATEGORIES,\n\tMENU_CONTENT_PAGES,\n\tMENU_CONTENT_POSTS,\n} from '../constants';\nimport ContentPagesMenu from './content-pages';\nimport ContentCategoriesMenu from './content-categories';\nimport ContentPostsMenu from './content-posts';\nimport TemplatesMenu from './templates';\nimport TemplatePartsMenu from './template-parts';\n\nexport default function SiteMenu() {\n\treturn (\n\t\t<NavigationMenu>\n\t\t\t<NavigationGroup title={ __( 'Theme' ) }>\n\t\t\t\t<NavigationItem\n\t\t\t\t\ttitle={ __( 'Templates' ) }\n\t\t\t\t\tnavigateToMenu={ MENU_TEMPLATES }\n\t\t\t\t/>\n\t\t\t\t<NavigationItem\n\t\t\t\t\ttitle={ __( 'Template Parts' ) }\n\t\t\t\t\tnavigateToMenu={ MENU_TEMPLATE_PARTS }\n\t\t\t\t/>\n\t\t\t</NavigationGroup>\n\t\t\t<NavigationGroup title={ __( 'Content' ) }>\n\t\t\t\t<NavigationItem\n\t\t\t\t\ttitle={ __( 'Pages' ) }\n\t\t\t\t\tnavigateToMenu={ MENU_CONTENT_PAGES }\n\t\t\t\t/>\n\t\t\t\t<NavigationItem\n\t\t\t\t\ttitle={ __( 'Categories' ) }\n\t\t\t\t\tnavigateToMenu={ MENU_CONTENT_CATEGORIES }\n\t\t\t\t/>\n\t\t\t\t<NavigationItem\n\t\t\t\t\ttitle={ __( 'Posts' ) }\n\t\t\t\t\tnavigateToMenu={ MENU_CONTENT_POSTS }\n\t\t\t\t/>\n\t\t\t</NavigationGroup>\n\t\t\t<TemplatesMenu />\n\t\t\t<TemplatePartsMenu />\n\t\t\t<ContentPagesMenu />\n\t\t\t<ContentCategoriesMenu />\n\t\t\t<ContentPostsMenu />\n\t\t</NavigationMenu>\n\t);\n}\n"]}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.default = TemplatePartsSubMenu;
|
|
9
|
-
|
|
10
|
-
var _element = require("@wordpress/element");
|
|
11
|
-
|
|
12
|
-
var _lodash = require("lodash");
|
|
13
|
-
|
|
14
|
-
var _components = require("@wordpress/components");
|
|
15
|
-
|
|
16
|
-
var _templateNavigationItem = _interopRequireDefault(require("../template-navigation-item"));
|
|
17
|
-
|
|
18
|
-
var _constants = require("../constants");
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* External dependencies
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* WordPress dependencies
|
|
26
|
-
*/
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Internal dependencies
|
|
30
|
-
*/
|
|
31
|
-
function TemplatePartsSubMenu(_ref) {
|
|
32
|
-
let {
|
|
33
|
-
menu,
|
|
34
|
-
title,
|
|
35
|
-
templateParts
|
|
36
|
-
} = _ref;
|
|
37
|
-
return (0, _element.createElement)(_components.__experimentalNavigationMenu, {
|
|
38
|
-
className: "edit-site-navigation-panel__template-parts",
|
|
39
|
-
menu: menu,
|
|
40
|
-
title: title,
|
|
41
|
-
parentMenu: _constants.MENU_TEMPLATE_PARTS,
|
|
42
|
-
isEmpty: !templateParts || templateParts.length === 0
|
|
43
|
-
}, (0, _lodash.map)(templateParts, templatePart => (0, _element.createElement)(_templateNavigationItem.default, {
|
|
44
|
-
item: templatePart,
|
|
45
|
-
key: `wp_template_part-${templatePart.id}`
|
|
46
|
-
})));
|
|
47
|
-
}
|
|
48
|
-
//# sourceMappingURL=template-parts-sub.js.map
|
package/build/components/navigation-sidebar/navigation-panel/menus/template-parts-sub.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/navigation-sidebar/navigation-panel/menus/template-parts-sub.js"],"names":["TemplatePartsSubMenu","menu","title","templateParts","MENU_TEMPLATE_PARTS","length","templatePart","id"],"mappings":";;;;;;;;;;;AAGA;;AAKA;;AAKA;;AACA;;AAdA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;AAIe,SAASA,oBAAT,OAAgE;AAAA,MAAjC;AAAEC,IAAAA,IAAF;AAAQC,IAAAA,KAAR;AAAeC,IAAAA;AAAf,GAAiC;AAC9E,SACC,4BAAC,wCAAD;AACC,IAAA,SAAS,EAAC,4CADX;AAEC,IAAA,IAAI,EAAGF,IAFR;AAGC,IAAA,KAAK,EAAGC,KAHT;AAIC,IAAA,UAAU,EAAGE,8BAJd;AAKC,IAAA,OAAO,EAAG,CAAED,aAAF,IAAmBA,aAAa,CAACE,MAAd,KAAyB;AALvD,KAOG,iBAAKF,aAAL,EAAsBG,YAAF,IACrB,4BAAC,+BAAD;AACC,IAAA,IAAI,EAAGA,YADR;AAEC,IAAA,GAAG,EAAI,oBAAoBA,YAAY,CAACC,EAAI;AAF7C,IADC,CAPH,CADD;AAgBA","sourcesContent":["/**\n * External dependencies\n */\nimport { map } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { __experimentalNavigationMenu as NavigationMenu } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport TemplateNavigationItem from '../template-navigation-item';\nimport { MENU_TEMPLATE_PARTS } from '../constants';\n\nexport default function TemplatePartsSubMenu( { menu, title, templateParts } ) {\n\treturn (\n\t\t<NavigationMenu\n\t\t\tclassName=\"edit-site-navigation-panel__template-parts\"\n\t\t\tmenu={ menu }\n\t\t\ttitle={ title }\n\t\t\tparentMenu={ MENU_TEMPLATE_PARTS }\n\t\t\tisEmpty={ ! templateParts || templateParts.length === 0 }\n\t\t>\n\t\t\t{ map( templateParts, ( templatePart ) => (\n\t\t\t\t<TemplateNavigationItem\n\t\t\t\t\titem={ templatePart }\n\t\t\t\t\tkey={ `wp_template_part-${ templatePart.id }` }\n\t\t\t\t/>\n\t\t\t) ) }\n\t\t</NavigationMenu>\n\t);\n}\n"]}
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.default = TemplatePartsMenu;
|
|
9
|
-
|
|
10
|
-
var _element = require("@wordpress/element");
|
|
11
|
-
|
|
12
|
-
var _lodash = require("lodash");
|
|
13
|
-
|
|
14
|
-
var _i18n = require("@wordpress/i18n");
|
|
15
|
-
|
|
16
|
-
var _data = require("@wordpress/data");
|
|
17
|
-
|
|
18
|
-
var _components = require("@wordpress/components");
|
|
19
|
-
|
|
20
|
-
var _coreData = require("@wordpress/core-data");
|
|
21
|
-
|
|
22
|
-
var _constants = require("../constants");
|
|
23
|
-
|
|
24
|
-
var _searchResults = _interopRequireDefault(require("../search-results"));
|
|
25
|
-
|
|
26
|
-
var _templatePartsSub = _interopRequireDefault(require("./template-parts-sub"));
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* External dependencies
|
|
30
|
-
*/
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* WordPress dependencies
|
|
34
|
-
*/
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Internal dependencies
|
|
38
|
-
*/
|
|
39
|
-
function TemplatePartsMenu() {
|
|
40
|
-
const [search, setSearch] = (0, _element.useState)('');
|
|
41
|
-
const onSearch = (0, _element.useCallback)(value => {
|
|
42
|
-
setSearch(value);
|
|
43
|
-
});
|
|
44
|
-
const {
|
|
45
|
-
isLoading,
|
|
46
|
-
templateParts,
|
|
47
|
-
templatePartsByArea
|
|
48
|
-
} = (0, _data.useSelect)(select => {
|
|
49
|
-
const templatePartRecords = select(_coreData.store).getEntityRecords('postType', 'wp_template_part');
|
|
50
|
-
|
|
51
|
-
const _templateParts = templatePartRecords || [];
|
|
52
|
-
|
|
53
|
-
const _templatePartsByArea = (0, _lodash.groupBy)(_templateParts, 'area');
|
|
54
|
-
|
|
55
|
-
return {
|
|
56
|
-
isLoading: templatePartRecords === null,
|
|
57
|
-
templateParts: _templateParts,
|
|
58
|
-
templatePartsByArea: _templatePartsByArea
|
|
59
|
-
};
|
|
60
|
-
}, []);
|
|
61
|
-
return (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)(_components.__experimentalNavigationMenu, {
|
|
62
|
-
menu: _constants.MENU_TEMPLATE_PARTS,
|
|
63
|
-
title: (0, _i18n.__)('Template Parts'),
|
|
64
|
-
parentMenu: _constants.MENU_ROOT,
|
|
65
|
-
hasSearch: true,
|
|
66
|
-
onSearch: onSearch,
|
|
67
|
-
search: search
|
|
68
|
-
}, search && (0, _element.createElement)(_searchResults.default, {
|
|
69
|
-
items: templateParts,
|
|
70
|
-
search: search
|
|
71
|
-
}), !search && _constants.TEMPLATE_PARTS_SUB_MENUS.map(_ref => {
|
|
72
|
-
let {
|
|
73
|
-
title,
|
|
74
|
-
menu
|
|
75
|
-
} = _ref;
|
|
76
|
-
return (0, _element.createElement)(_components.__experimentalNavigationItem, {
|
|
77
|
-
key: `template-parts-navigate-to-${menu}`,
|
|
78
|
-
className: "edit-site-navigation-panel__template-part-item",
|
|
79
|
-
navigateToMenu: menu,
|
|
80
|
-
title: title,
|
|
81
|
-
hideIfTargetMenuEmpty: true
|
|
82
|
-
});
|
|
83
|
-
}), !search && isLoading && (0, _element.createElement)(_components.__experimentalNavigationItem, {
|
|
84
|
-
title: (0, _i18n.__)('Loading…'),
|
|
85
|
-
isText: true
|
|
86
|
-
})), _constants.TEMPLATE_PARTS_SUB_MENUS.map(_ref2 => {
|
|
87
|
-
let {
|
|
88
|
-
area,
|
|
89
|
-
menu,
|
|
90
|
-
title
|
|
91
|
-
} = _ref2;
|
|
92
|
-
return (0, _element.createElement)(_templatePartsSub.default, {
|
|
93
|
-
key: `template-parts-menu-${menu}`,
|
|
94
|
-
menu: menu,
|
|
95
|
-
title: title,
|
|
96
|
-
templateParts: templatePartsByArea[area]
|
|
97
|
-
});
|
|
98
|
-
}));
|
|
99
|
-
}
|
|
100
|
-
//# sourceMappingURL=template-parts.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/navigation-sidebar/navigation-panel/menus/template-parts.js"],"names":["TemplatePartsMenu","search","setSearch","onSearch","value","isLoading","templateParts","templatePartsByArea","select","templatePartRecords","coreStore","getEntityRecords","_templateParts","_templatePartsByArea","MENU_TEMPLATE_PARTS","MENU_ROOT","TEMPLATE_PARTS_SUB_MENUS","map","title","menu","area"],"mappings":";;;;;;;;;AAcA;;AAXA;;AAKA;;AACA;;AACA;;AAKA;;AAKA;;AAKA;;AACA;;AA1BA;AACA;AACA;;AAGA;AACA;AACA;;AAUA;AACA;AACA;AASe,SAASA,iBAAT,GAA6B;AAC3C,QAAM,CAAEC,MAAF,EAAUC,SAAV,IAAwB,uBAAU,EAAV,CAA9B;AACA,QAAMC,QAAQ,GAAG,0BAAeC,KAAF,IAAa;AAC1CF,IAAAA,SAAS,CAAEE,KAAF,CAAT;AACA,GAFgB,CAAjB;AAIA,QAAM;AAAEC,IAAAA,SAAF;AAAaC,IAAAA,aAAb;AAA4BC,IAAAA;AAA5B,MAAoD,qBACvDC,MAAF,IAAc;AACb,UAAMC,mBAAmB,GAAGD,MAAM,CAAEE,eAAF,CAAN,CAAoBC,gBAApB,CAC3B,UAD2B,EAE3B,kBAF2B,CAA5B;;AAKA,UAAMC,cAAc,GAAGH,mBAAmB,IAAI,EAA9C;;AACA,UAAMI,oBAAoB,GAAG,qBAASD,cAAT,EAAyB,MAAzB,CAA7B;;AAEA,WAAO;AACNP,MAAAA,SAAS,EAAEI,mBAAmB,KAAK,IAD7B;AAENH,MAAAA,aAAa,EAAEM,cAFT;AAGNL,MAAAA,mBAAmB,EAAEM;AAHf,KAAP;AAKA,GAfwD,EAgBzD,EAhByD,CAA1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ordpress/i18n';\nimport { useSelect } from '@wordpress/data';\nimport {\n\t__experimentalNavigationMenu as NavigationMenu,\n\t__experimentalNavigationItem as NavigationItem,\n} from '@wordpress/components';\nimport { useState, useCallback } from '@wordpress/element';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport {\n\tMENU_ROOT,\n\tMENU_TEMPLATE_PARTS,\n\tTEMPLATE_PARTS_SUB_MENUS,\n} from '../constants';\nimport SearchResults from '../search-results';\nimport TemplatePartsSubMenu from './template-parts-sub';\n\nexport default function TemplatePartsMenu() {\n\tconst [ search, setSearch ] = useState( '' );\n\tconst onSearch = useCallback( ( value ) => {\n\t\tsetSearch( value );\n\t} );\n\n\tconst { isLoading, templateParts, templatePartsByArea } = useSelect(\n\t\t( select ) => {\n\t\t\tconst templatePartRecords = select( coreStore ).getEntityRecords(\n\t\t\t\t'postType',\n\t\t\t\t'wp_template_part'\n\t\t\t);\n\n\t\t\tconst _templateParts = templatePartRecords || [];\n\t\t\tconst _templatePartsByArea = groupBy( _templateParts, 'area' );\n\n\t\t\treturn {\n\t\t\t\tisLoading: templatePartRecords === null,\n\t\t\t\ttemplateParts: _templateParts,\n\t\t\t\ttemplatePartsByArea: _templatePartsByArea,\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\n\treturn (\n\t\t<>\n\t\t\t<NavigationMenu\n\t\t\t\tmenu={ MENU_TEMPLATE_PARTS }\n\t\t\t\ttitle={ __( 'Template Parts' ) }\n\t\t\t\tparentMenu={ MENU_ROOT }\n\t\t\t\thasSearch={ true }\n\t\t\t\tonSearch={ onSearch }\n\t\t\t\tsearch={ search }\n\t\t\t>\n\t\t\t\t{ search && (\n\t\t\t\t\t<SearchResults items={ templateParts } search={ search } />\n\t\t\t\t) }\n\n\t\t\t\t{ ! search &&\n\t\t\t\t\tTEMPLATE_PARTS_SUB_MENUS.map( ( { title, menu } ) => (\n\t\t\t\t\t\t<NavigationItem\n\t\t\t\t\t\t\tkey={ `template-parts-navigate-to-${ menu }` }\n\t\t\t\t\t\t\tclassName=\"edit-site-navigation-panel__template-part-item\"\n\t\t\t\t\t\t\tnavigateToMenu={ menu }\n\t\t\t\t\t\t\ttitle={ title }\n\t\t\t\t\t\t\thideIfTargetMenuEmpty\n\t\t\t\t\t\t/>\n\t\t\t\t\t) ) }\n\n\t\t\t\t{ ! search && isLoading && (\n\t\t\t\t\t<NavigationItem title={ __( 'Loading…' ) } isText />\n\t\t\t\t) }\n\t\t\t</NavigationMenu>\n\n\t\t\t{ TEMPLATE_PARTS_SUB_MENUS.map( ( { area, menu, title } ) => (\n\t\t\t\t<TemplatePartsSubMenu\n\t\t\t\t\tkey={ `template-parts-menu-${ menu }` }\n\t\t\t\t\tmenu={ menu }\n\t\t\t\t\ttitle={ title }\n\t\t\t\t\ttemplateParts={ templatePartsByArea[ area ] }\n\t\t\t\t/>\n\t\t\t) ) }\n\t\t</>\n\t);\n}\n"]}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.default = TemplatesSubMenu;
|
|
9
|
-
|
|
10
|
-
var _element = require("@wordpress/element");
|
|
11
|
-
|
|
12
|
-
var _lodash = require("lodash");
|
|
13
|
-
|
|
14
|
-
var _components = require("@wordpress/components");
|
|
15
|
-
|
|
16
|
-
var _templateNavigationItem = _interopRequireDefault(require("../template-navigation-item"));
|
|
17
|
-
|
|
18
|
-
var _constants = require("../constants");
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* External dependencies
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* WordPress dependencies
|
|
26
|
-
*/
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Internal dependencies
|
|
30
|
-
*/
|
|
31
|
-
function TemplatesSubMenu(_ref) {
|
|
32
|
-
let {
|
|
33
|
-
menu,
|
|
34
|
-
title,
|
|
35
|
-
templates
|
|
36
|
-
} = _ref;
|
|
37
|
-
const templatesFiltered = (0, _element.useMemo)(() => {
|
|
38
|
-
var _templates$filter$map, _templates$filter;
|
|
39
|
-
|
|
40
|
-
return (_templates$filter$map = templates === null || templates === void 0 ? void 0 : (_templates$filter = templates.filter(_ref2 => {
|
|
41
|
-
let {
|
|
42
|
-
location
|
|
43
|
-
} = _ref2;
|
|
44
|
-
return location === menu;
|
|
45
|
-
})) === null || _templates$filter === void 0 ? void 0 : _templates$filter.map(_ref3 => {
|
|
46
|
-
let {
|
|
47
|
-
template
|
|
48
|
-
} = _ref3;
|
|
49
|
-
return template;
|
|
50
|
-
})) !== null && _templates$filter$map !== void 0 ? _templates$filter$map : [];
|
|
51
|
-
}, [menu, templates]);
|
|
52
|
-
return (0, _element.createElement)(_components.__experimentalNavigationMenu, {
|
|
53
|
-
menu: menu,
|
|
54
|
-
title: title,
|
|
55
|
-
parentMenu: _constants.MENU_TEMPLATES,
|
|
56
|
-
isEmpty: templatesFiltered.length === 0
|
|
57
|
-
}, (0, _lodash.map)(templatesFiltered, template => (0, _element.createElement)(_templateNavigationItem.default, {
|
|
58
|
-
item: template,
|
|
59
|
-
key: `wp_template-${template.id}`
|
|
60
|
-
})));
|
|
61
|
-
}
|
|
62
|
-
//# sourceMappingURL=templates-sub.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/navigation-sidebar/navigation-panel/menus/templates-sub.js"],"names":["TemplatesSubMenu","menu","title","templates","templatesFiltered","filter","location","map","template","MENU_TEMPLATES","length","id"],"mappings":";;;;;;;;;AASA;;AANA;;AAKA;;AAMA;;AACA;;AAfA;AACA;AACA;;AAGA;AACA;AACA;;AAIA;AACA;AACA;AAIe,SAASA,gBAAT,OAAwD;AAAA,MAA7B;AAAEC,IAAAA,IAAF;AAAQC,IAAAA,KAAR;AAAeC,IAAAA;AAAf,GAA6B;AACtE,QAAMC,iBAAiB,GAAG,sBACzB;AAAA;;AAAA,oCACCD,SADD,aACCA,SADD,4CACCA,SAAS,CACNE,MADH,CACW;AAAA,UAAE;AAAEC,QAAAA;AAAF,OAAF;AAAA,aAAoBA,QAAQ,KAAKL,IAAjC;AAAA,KADX,CADD,sDACC,kBAEGM,GAFH,CAEQ;AAAA,UAAE;AAAEC,QAAAA;AAAF,OAAF;AAAA,aAAoBA,QAApB;AAAA,KAFR,CADD,yEAG2C,EAH3C;AAAA,GADyB,EAKzB,CAAEP,IAAF,EAAQE,SAAR,CALyB,CAA1B;AAQA,SACC,4BAAC,wCAAD;AACC,IAAA,IAAI,EAAGF,IADR;AAEC,IAAA,KAAK,EAAGC,KAFT;AAGC,IAAA,UAAU,EAAGO,yBAHd;AAIC,IAAA,OAAO,EAAGL,iBAAiB,CAACM,MAAlB,KAA6B;AAJxC,KAMG,iBAAKN,iBAAL,EAA0BI,QAAF,IACzB,4BAAC,+BAAD;AACC,IAAA,IAAI,EAAGA,QADR;AAEC,IAAA,GAAG,EAAI,eAAeA,QAAQ,CAACG,EAAI;AAFpC,IADC,CANH,CADD;AAeA","sourcesContent":["/**\n * External dependencies\n */\nimport { map } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { __experimentalNavigationMenu as NavigationMenu } from '@wordpress/components';\nimport { useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport TemplateNavigationItem from '../template-navigation-item';\nimport { MENU_TEMPLATES } from '../constants';\n\nexport default function TemplatesSubMenu( { menu, title, templates } ) {\n\tconst templatesFiltered = useMemo(\n\t\t() =>\n\t\t\ttemplates\n\t\t\t\t?.filter( ( { location } ) => location === menu )\n\t\t\t\t?.map( ( { template } ) => template ) ?? [],\n\t\t[ menu, templates ]\n\t);\n\n\treturn (\n\t\t<NavigationMenu\n\t\t\tmenu={ menu }\n\t\t\ttitle={ title }\n\t\t\tparentMenu={ MENU_TEMPLATES }\n\t\t\tisEmpty={ templatesFiltered.length === 0 }\n\t\t>\n\t\t\t{ map( templatesFiltered, ( template ) => (\n\t\t\t\t<TemplateNavigationItem\n\t\t\t\t\titem={ template }\n\t\t\t\t\tkey={ `wp_template-${ template.id }` }\n\t\t\t\t/>\n\t\t\t) ) }\n\t\t</NavigationMenu>\n\t);\n}\n"]}
|
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.default = TemplatesMenu;
|
|
9
|
-
|
|
10
|
-
var _element = require("@wordpress/element");
|
|
11
|
-
|
|
12
|
-
var _lodash = require("lodash");
|
|
13
|
-
|
|
14
|
-
var _components = require("@wordpress/components");
|
|
15
|
-
|
|
16
|
-
var _data = require("@wordpress/data");
|
|
17
|
-
|
|
18
|
-
var _i18n = require("@wordpress/i18n");
|
|
19
|
-
|
|
20
|
-
var _coreData = require("@wordpress/core-data");
|
|
21
|
-
|
|
22
|
-
var _constants = require("../constants");
|
|
23
|
-
|
|
24
|
-
var _newTemplateDropdown = _interopRequireDefault(require("../new-template-dropdown"));
|
|
25
|
-
|
|
26
|
-
var _templateNavigationItem = _interopRequireDefault(require("../template-navigation-item"));
|
|
27
|
-
|
|
28
|
-
var _searchResults = _interopRequireDefault(require("../search-results"));
|
|
29
|
-
|
|
30
|
-
var _templatesSub = _interopRequireDefault(require("./templates-sub"));
|
|
31
|
-
|
|
32
|
-
var _templateHierarchy = require("../template-hierarchy");
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* External dependencies
|
|
36
|
-
*/
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* WordPress dependencies
|
|
40
|
-
*/
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Internal dependencies
|
|
44
|
-
*/
|
|
45
|
-
function TemplatesMenu() {
|
|
46
|
-
const [search, setSearch] = (0, _element.useState)('');
|
|
47
|
-
const onSearch = (0, _element.useCallback)(value => {
|
|
48
|
-
setSearch(value);
|
|
49
|
-
});
|
|
50
|
-
const {
|
|
51
|
-
templates,
|
|
52
|
-
showOnFront
|
|
53
|
-
} = (0, _data.useSelect)(select => {
|
|
54
|
-
const {
|
|
55
|
-
getEntityRecords,
|
|
56
|
-
getEditedEntityRecord
|
|
57
|
-
} = select(_coreData.store);
|
|
58
|
-
return {
|
|
59
|
-
templates: getEntityRecords('postType', 'wp_template'),
|
|
60
|
-
showOnFront: getEditedEntityRecord('root', 'site').show_on_front
|
|
61
|
-
};
|
|
62
|
-
}, []);
|
|
63
|
-
const templatesWithLocation = (0, _element.useMemo)(() => {
|
|
64
|
-
if (!templates) {
|
|
65
|
-
return null;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
const unusedTemplates = (0, _templateHierarchy.getUnusedTemplates)(templates, showOnFront);
|
|
69
|
-
const templateLocations = (0, _templateHierarchy.getTemplatesLocationMap)(templates);
|
|
70
|
-
return templates.map(template => ({
|
|
71
|
-
template,
|
|
72
|
-
location: (0, _lodash.find)(unusedTemplates, {
|
|
73
|
-
slug: template.slug
|
|
74
|
-
}) ? _constants.MENU_TEMPLATES_UNUSED : templateLocations[template.slug]
|
|
75
|
-
}));
|
|
76
|
-
}, [templates]);
|
|
77
|
-
const topLevelTemplates = (0, _element.useMemo)(() => {
|
|
78
|
-
var _templatesWithLocatio, _templatesWithLocatio2;
|
|
79
|
-
|
|
80
|
-
return (_templatesWithLocatio = templatesWithLocation === null || templatesWithLocation === void 0 ? void 0 : (_templatesWithLocatio2 = templatesWithLocation.filter(_ref => {
|
|
81
|
-
let {
|
|
82
|
-
location
|
|
83
|
-
} = _ref;
|
|
84
|
-
return location === _constants.MENU_TEMPLATES;
|
|
85
|
-
})) === null || _templatesWithLocatio2 === void 0 ? void 0 : _templatesWithLocatio2.map(_ref2 => {
|
|
86
|
-
let {
|
|
87
|
-
template
|
|
88
|
-
} = _ref2;
|
|
89
|
-
return template;
|
|
90
|
-
})) !== null && _templatesWithLocatio !== void 0 ? _templatesWithLocatio : [];
|
|
91
|
-
}, [templatesWithLocation]);
|
|
92
|
-
return (0, _element.createElement)(_components.__experimentalNavigationMenu, {
|
|
93
|
-
menu: _constants.MENU_TEMPLATES,
|
|
94
|
-
title: (0, _i18n.__)('Templates'),
|
|
95
|
-
titleAction: (0, _element.createElement)(_newTemplateDropdown.default, null),
|
|
96
|
-
parentMenu: _constants.MENU_ROOT,
|
|
97
|
-
hasSearch: true,
|
|
98
|
-
onSearch: onSearch,
|
|
99
|
-
search: search
|
|
100
|
-
}, search && (0, _element.createElement)(_searchResults.default, {
|
|
101
|
-
items: templates,
|
|
102
|
-
search: search
|
|
103
|
-
}), !search && (0, _element.createElement)(_element.Fragment, null, (0, _lodash.map)(topLevelTemplates, template => (0, _element.createElement)(_templateNavigationItem.default, {
|
|
104
|
-
item: template,
|
|
105
|
-
key: `wp_template-${template.id}`
|
|
106
|
-
})), (0, _element.createElement)(_components.__experimentalNavigationItem, {
|
|
107
|
-
navigateToMenu: _constants.MENU_TEMPLATES_POSTS,
|
|
108
|
-
title: (0, _i18n.__)('Post templates'),
|
|
109
|
-
hideIfTargetMenuEmpty: true
|
|
110
|
-
}), (0, _element.createElement)(_components.__experimentalNavigationItem, {
|
|
111
|
-
navigateToMenu: _constants.MENU_TEMPLATES_PAGES,
|
|
112
|
-
title: (0, _i18n.__)('Page templates'),
|
|
113
|
-
hideIfTargetMenuEmpty: true
|
|
114
|
-
}), (0, _element.createElement)(_components.__experimentalNavigationItem, {
|
|
115
|
-
navigateToMenu: _constants.MENU_TEMPLATES_GENERAL,
|
|
116
|
-
title: (0, _i18n.__)('General templates'),
|
|
117
|
-
hideIfTargetMenuEmpty: true
|
|
118
|
-
}), (0, _element.createElement)(_components.__experimentalNavigationItem, {
|
|
119
|
-
navigateToMenu: _constants.MENU_TEMPLATES_UNUSED,
|
|
120
|
-
title: (0, _i18n.__)('Unused templates'),
|
|
121
|
-
hideIfTargetMenuEmpty: true
|
|
122
|
-
})), !search && templates === null && (0, _element.createElement)(_components.__experimentalNavigationItem, {
|
|
123
|
-
title: (0, _i18n.__)('Loading…'),
|
|
124
|
-
isText: true
|
|
125
|
-
}), (0, _element.createElement)(_templatesSub.default, {
|
|
126
|
-
menu: _constants.MENU_TEMPLATES_POSTS,
|
|
127
|
-
title: (0, _i18n.__)('Post templates'),
|
|
128
|
-
templates: templatesWithLocation
|
|
129
|
-
}), (0, _element.createElement)(_templatesSub.default, {
|
|
130
|
-
menu: _constants.MENU_TEMPLATES_PAGES,
|
|
131
|
-
title: (0, _i18n.__)('Page templates'),
|
|
132
|
-
templates: templatesWithLocation
|
|
133
|
-
}), (0, _element.createElement)(_templatesSub.default, {
|
|
134
|
-
menu: _constants.MENU_TEMPLATES_GENERAL,
|
|
135
|
-
title: (0, _i18n.__)('General templates'),
|
|
136
|
-
templates: templatesWithLocation
|
|
137
|
-
}), (0, _element.createElement)(_templatesSub.default, {
|
|
138
|
-
menu: _constants.MENU_TEMPLATES_UNUSED,
|
|
139
|
-
title: (0, _i18n.__)('Unused templates'),
|
|
140
|
-
templates: templatesWithLocation
|
|
141
|
-
}));
|
|
142
|
-
}
|
|
143
|
-
//# sourceMappingURL=templates.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/navigation-sidebar/navigation-panel/menus/templates.js"],"names":["TemplatesMenu","search","setSearch","onSearch","value","templates","showOnFront","select","getEntityRecords","getEditedEntityRecord","coreStore","show_on_front","templatesWithLocation","unusedTemplates","templateLocations","map","template","location","slug","MENU_TEMPLATES_UNUSED","topLevelTemplates","filter","MENU_TEMPLATES","MENU_ROOT","id","MENU_TEMPLATES_POSTS","MENU_TEMPLATES_PAGES","MENU_TEMPLATES_GENERAL"],"mappings":";;;;;;;;;AAcA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AK,EAAG,cAAI,mBAAJ,CAFT;AAGC,IAAA,qBAAqB;AAHtB,IAjBD,EAsBC,4BAAC,wCAAD;AACC,IAAA,cAAc,EAAGR,gCADlB;AAEC,IAAA,KAAK,EAAG,cAAI,kBAAJ,CAFT;AAGC,IAAA,qBAAqB;AAHtB,IAtBD,CAdF,EA4CG,CAAElB,MAAF,IAAYI,SAAS,KAAK,IAA1B,IACD,4BAAC,wCAAD;AAAgB,IAAA,KAAK,EAAG,cAAI,UAAJ,CAAxB;AAA2C,IAAA,MAAM;AAAjD,IA7CF,EAgDC,4BAAC,qBAAD;AACC,IAAA,IAAI,EAAGoB,+BADR;AAEC,IAAA,KAAK,EAAG,cAAI,gBAAJ,CAFT;AAGC,IAAA,SAAS,EAAGb;AAHb,IAhDD,EAqDC,4BAAC,qBAAD;AACC,IAAA,IAAI,EAAGc,+BADR;AAEC,IAAA,KAAK,EAAG,cAAI,gBAAJ,CAFT;AAGC,IAAA,SAAS,EAAGd;AAHb,IArDD,EA0DC,4BAAC,qBAAD;AACC,IAAA,IAAI,EAAGe,iCADR;AAEC,IAAA,KAAK,EAAG,cAAI,mBAAJ,CAFT;AAGC,IAAA,SAAS,EAAGf;AAHb,IA1DD,EA+DC,4BAAC,qBAAD;AACC,IAAA,IAAI,EAAGO,gCADR;AAEC,IAAA,KAAK,EAAG,cAAI,kBAAJ,CAFT;AAGC,IAAA,SAAS,EAAGP;AAHb,IA/DD,CADD;AAuEA","sourcesContent":["/**\n * External dependencies\n */\nimport { map, find } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalNavigationItem as NavigationItem,\n\t__experimentalNavigationMenu as NavigationMenu,\n} from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { useState, useCallback, useMemo } from '@wordpress/element';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport {\n\tMENU_ROOT,\n\tMENU_TEMPLATES,\n\tMENU_TEMPLATES_GENERAL,\n\tMENU_TEMPLATES_PAGES,\n\tMENU_TEMPLATES_POSTS,\n\tMENU_TEMPLATES_UNUSED,\n} from '../constants';\nimport NewTemplateDropdown from '../new-template-dropdown';\nimport TemplateNavigationItem from '../template-navigation-item';\nimport SearchResults from '../search-results';\nimport TemplatesSubMenu from './templates-sub';\nimport {\n\tgetTemplatesLocationMap,\n\tgetUnusedTemplates,\n} from '../template-hierarchy';\n\nexport default function TemplatesMenu() {\n\tconst [ search, setSearch ] = useState( '' );\n\tconst onSearch = useCallback( ( value ) => {\n\t\tsetSearch( value );\n\t} );\n\n\tconst { templates, showOnFront } = useSelect( ( select ) => {\n\t\tconst { getEntityRecords, getEditedEntityRecord } = select( coreStore );\n\t\treturn {\n\t\t\ttemplates: getEntityRecords( 'postType', 'wp_template' ),\n\t\t\tshowOnFront: getEditedEntityRecord( 'root', 'site' ).show_on_front,\n\t\t};\n\t}, [] );\n\n\tconst templatesWithLocation = useMemo( () => {\n\t\tif ( ! templates ) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst unusedTemplates = getUnusedTemplates( templates, showOnFront );\n\t\tconst templateLocations = getTemplatesLocationMap( templates );\n\n\t\treturn templates.map( ( template ) => ( {\n\t\t\ttemplate,\n\t\t\tlocation: find( unusedTemplates, { slug: template.slug } )\n\t\t\t\t? MENU_TEMPLATES_UNUSED\n\t\t\t\t: templateLocations[ template.slug ],\n\t\t} ) );\n\t}, [ templates ] );\n\n\tconst topLevelTemplates = useMemo(\n\t\t() =>\n\t\t\ttemplatesWithLocation\n\t\t\t\t?.filter( ( { location } ) => location === MENU_TEMPLATES )\n\t\t\t\t?.map( ( { template } ) => template ) ?? [],\n\t\t[ templatesWithLocation ]\n\t);\n\n\treturn (\n\t\t<NavigationMenu\n\t\t\tmenu={ MENU_TEMPLATES }\n\t\t\ttitle={ __( 'Templates' ) }\n\t\t\ttitleAction={ <NewTemplateDropdown /> }\n\t\t\tparentMenu={ MENU_ROOT }\n\t\t\thasSearch={ true }\n\t\t\tonSearch={ onSearch }\n\t\t\tsearch={ search }\n\t\t>\n\t\t\t{ search && (\n\t\t\t\t<SearchResults items={ templates } search={ search } />\n\t\t\t) }\n\n\t\t\t{ ! search && (\n\t\t\t\t<>\n\t\t\t\t\t{ map( topLevelTemplates, ( template ) => (\n\t\t\t\t\t\t<TemplateNavigationItem\n\t\t\t\t\t\t\titem={ template }\n\t\t\t\t\t\t\tkey={ `wp_template-${ template.id }` }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) ) }\n\t\t\t\t\t<NavigationItem\n\t\t\t\t\t\tnavigateToMenu={ MENU_TEMPLATES_POSTS }\n\t\t\t\t\t\ttitle={ __( 'Post templates' ) }\n\t\t\t\t\t\thideIfTargetMenuEmpty\n\t\t\t\t\t/>\n\t\t\t\t\t<NavigationItem\n\t\t\t\t\t\tnavigateToMenu={ MENU_TEMPLATES_PAGES }\n\t\t\t\t\t\ttitle={ __( 'Page templates' ) }\n\t\t\t\t\t\thideIfTargetMenuEmpty\n\t\t\t\t\t/>\n\t\t\t\t\t<NavigationItem\n\t\t\t\t\t\tnavigateToMenu={ MENU_TEMPLATES_GENERAL }\n\t\t\t\t\t\ttitle={ __( 'General templates' ) }\n\t\t\t\t\t\thideIfTargetMenuEmpty\n\t\t\t\t\t/>\n\t\t\t\t\t<NavigationItem\n\t\t\t\t\t\tnavigateToMenu={ MENU_TEMPLATES_UNUSED }\n\t\t\t\t\t\ttitle={ __( 'Unused templates' ) }\n\t\t\t\t\t\thideIfTargetMenuEmpty\n\t\t\t\t\t/>\n\t\t\t\t</>\n\t\t\t) }\n\n\t\t\t{ ! search && templates === null && (\n\t\t\t\t<NavigationItem title={ __( 'Loading…' ) } isText />\n\t\t\t) }\n\n\t\t\t<TemplatesSubMenu\n\t\t\t\tmenu={ MENU_TEMPLATES_POSTS }\n\t\t\t\ttitle={ __( 'Post templates' ) }\n\t\t\t\ttemplates={ templatesWithLocation }\n\t\t\t/>\n\t\t\t<TemplatesSubMenu\n\t\t\t\tmenu={ MENU_TEMPLATES_PAGES }\n\t\t\t\ttitle={ __( 'Page templates' ) }\n\t\t\t\ttemplates={ templatesWithLocation }\n\t\t\t/>\n\t\t\t<TemplatesSubMenu\n\t\t\t\tmenu={ MENU_TEMPLATES_GENERAL }\n\t\t\t\ttitle={ __( 'General templates' ) }\n\t\t\t\ttemplates={ templatesWithLocation }\n\t\t\t/>\n\t\t\t<TemplatesSubMenu\n\t\t\t\tmenu={ MENU_TEMPLATES_UNUSED }\n\t\t\t\ttitle={ __( 'Unused templates' ) }\n\t\t\t\ttemplates={ templatesWithLocation }\n\t\t\t/>\n\t\t</NavigationMenu>\n\t);\n}\n"]}
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = NavigationEntityItems;
|
|
7
|
-
|
|
8
|
-
var _element = require("@wordpress/element");
|
|
9
|
-
|
|
10
|
-
var _data = require("@wordpress/data");
|
|
11
|
-
|
|
12
|
-
var _components = require("@wordpress/components");
|
|
13
|
-
|
|
14
|
-
var _url = require("@wordpress/url");
|
|
15
|
-
|
|
16
|
-
var _coreData = require("@wordpress/core-data");
|
|
17
|
-
|
|
18
|
-
var _store = require("../../../store");
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* WordPress dependencies
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Internal dependencies
|
|
26
|
-
*/
|
|
27
|
-
const getEntityTitle = (kind, entity) => {
|
|
28
|
-
var _entity$title;
|
|
29
|
-
|
|
30
|
-
return 'taxonomy' === kind ? entity.name : entity === null || entity === void 0 ? void 0 : (_entity$title = entity.title) === null || _entity$title === void 0 ? void 0 : _entity$title.rendered;
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
function NavigationEntityItems(_ref) {
|
|
34
|
-
let {
|
|
35
|
-
kind,
|
|
36
|
-
name,
|
|
37
|
-
query = {}
|
|
38
|
-
} = _ref;
|
|
39
|
-
const entities = (0, _data.useSelect)(select => select(_coreData.store).getEntityRecords(kind, name, query), [kind, name, query]);
|
|
40
|
-
const {
|
|
41
|
-
setPage
|
|
42
|
-
} = (0, _data.useDispatch)(_store.store);
|
|
43
|
-
|
|
44
|
-
if (!entities) {
|
|
45
|
-
return null;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
const onActivateItem = _ref2 => {
|
|
49
|
-
let {
|
|
50
|
-
type,
|
|
51
|
-
slug,
|
|
52
|
-
link,
|
|
53
|
-
id
|
|
54
|
-
} = _ref2;
|
|
55
|
-
setPage({
|
|
56
|
-
type,
|
|
57
|
-
slug,
|
|
58
|
-
path: (0, _url.getPathAndQueryString)(link),
|
|
59
|
-
context: {
|
|
60
|
-
postType: type,
|
|
61
|
-
postId: id
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
return entities.map(entity => {
|
|
67
|
-
const key = `content-${(0, _url.getPathAndQueryString)(entity.link)}`;
|
|
68
|
-
return (0, _element.createElement)(_components.__experimentalNavigationItem, {
|
|
69
|
-
key: key,
|
|
70
|
-
item: key,
|
|
71
|
-
title: getEntityTitle(kind, entity),
|
|
72
|
-
onClick: () => onActivateItem(entity)
|
|
73
|
-
});
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
//# sourceMappingURL=navigation-entity-items.js.map
|