@wordpress/edit-site 3.0.18-next.33ec3857e2.0 → 3.0.21
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 -8
- package/build/components/block-editor/resizable-editor.js.map +1 -1
- package/build/components/global-styles/border-panel.js +22 -81
- package/build/components/global-styles/border-panel.js.map +1 -1
- package/build/components/global-styles/gradients-palette-panel.js +7 -3
- package/build/components/global-styles/gradients-palette-panel.js.map +1 -1
- package/build/components/global-styles/screen-background-color.js +10 -9
- package/build/components/global-styles/screen-background-color.js.map +1 -1
- package/build/components/global-styles/screen-colors.js +1 -1
- package/build/components/global-styles/screen-colors.js.map +1 -1
- package/build/components/global-styles/screen-link-color.js +10 -6
- package/build/components/global-styles/screen-link-color.js.map +1 -1
- package/build/components/global-styles/screen-text-color.js +10 -6
- package/build/components/global-styles/screen-text-color.js.map +1 -1
- package/build/components/global-styles/ui.js +14 -27
- package/build/components/global-styles/ui.js.map +1 -1
- package/build/components/list/actions/index.js +0 -1
- package/build/components/list/actions/index.js.map +1 -1
- package/build/components/list/added-by.js +9 -3
- package/build/components/list/added-by.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/components/navigation-sidebar/navigation-toggle/index.js +10 -1
- package/build/components/navigation-sidebar/navigation-toggle/index.js.map +1 -1
- package/build/components/sidebar/default-sidebar.js +2 -4
- package/build/components/sidebar/default-sidebar.js.map +1 -1
- package/build/components/sidebar/global-styles-sidebar.js +0 -1
- package/build/components/sidebar/global-styles-sidebar.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 -8
- package/build-module/components/block-editor/resizable-editor.js.map +1 -1
- package/build-module/components/global-styles/border-panel.js +23 -82
- package/build-module/components/global-styles/border-panel.js.map +1 -1
- package/build-module/components/global-styles/gradients-palette-panel.js +5 -4
- package/build-module/components/global-styles/gradients-palette-panel.js.map +1 -1
- package/build-module/components/global-styles/screen-background-color.js +11 -9
- package/build-module/components/global-styles/screen-background-color.js.map +1 -1
- package/build-module/components/global-styles/screen-colors.js +1 -1
- package/build-module/components/global-styles/screen-colors.js.map +1 -1
- package/build-module/components/global-styles/screen-link-color.js +11 -7
- package/build-module/components/global-styles/screen-link-color.js.map +1 -1
- package/build-module/components/global-styles/screen-text-color.js +11 -7
- package/build-module/components/global-styles/screen-text-color.js.map +1 -1
- package/build-module/components/global-styles/ui.js +14 -26
- package/build-module/components/global-styles/ui.js.map +1 -1
- package/build-module/components/list/actions/index.js +0 -1
- package/build-module/components/list/actions/index.js.map +1 -1
- package/build-module/components/list/added-by.js +10 -4
- package/build-module/components/list/added-by.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/components/navigation-sidebar/navigation-toggle/index.js +11 -1
- package/build-module/components/navigation-sidebar/navigation-toggle/index.js.map +1 -1
- package/build-module/components/sidebar/default-sidebar.js +2 -4
- package/build-module/components/sidebar/default-sidebar.js.map +1 -1
- package/build-module/components/sidebar/global-styles-sidebar.js +0 -1
- package/build-module/components/sidebar/global-styles-sidebar.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 +62 -32
- package/build-style/style.css +62 -32
- package/package.json +28 -28
- package/src/components/block-editor/index.js +2 -2
- package/src/components/block-editor/resizable-editor.js +52 -13
- package/src/components/block-editor/style.scss +18 -10
- package/src/components/global-styles/border-panel.js +42 -106
- package/src/components/global-styles/gradients-palette-panel.js +4 -4
- package/src/components/global-styles/screen-background-color.js +10 -7
- package/src/components/global-styles/screen-colors.js +1 -1
- package/src/components/global-styles/screen-link-color.js +14 -6
- package/src/components/global-styles/screen-text-color.js +14 -6
- package/src/components/global-styles/style.scss +19 -1
- package/src/components/global-styles/ui.js +25 -50
- package/src/components/header/document-actions/style.scss +9 -1
- package/src/components/header/style.scss +1 -2
- package/src/components/list/actions/index.js +0 -1
- package/src/components/list/added-by.js +25 -9
- package/src/components/navigation-sidebar/navigation-panel/constants.js +0 -15
- package/src/components/navigation-sidebar/navigation-toggle/index.js +12 -0
- package/src/components/navigation-sidebar/navigation-toggle/style.scss +8 -4
- package/src/components/sidebar/default-sidebar.js +0 -2
- package/src/components/sidebar/global-styles-sidebar.js +0 -1
- package/src/components/sidebar/style.scss +14 -21
- 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,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":";;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AASC,MAAAA;AAAT,KAAF;AAAA,WAC7B,4BAAC,wCAAD;AACC,MAAA,GAAG,EAAI,8BAA8BA,IAAM,EAD5C;AAEC,MAAA,SAAS,EAAC,gDAFX;AAGC,MAAA,cAAc,EAAGA,IAHlB;AAIC,MAAA,KAAK,EAAGD,KAJT;AAKC,MAAA,qBAAqB;AALtB,MAD6B;AAAA,GAA9B,CAbF,EAuBG,CAAEjB,MAAF,IAAYI,SAAZ,IACD,4BAAC,wCAAD;AAAgB,IAAA,KAAK,EAAG,cAAI,UAAJ,CAAxB;AAA2C,IAAA,MAAM;AAAjD,IAxBF,CADD,EA6BGW,oCAAyBC,GAAzB,CAA8B;AAAA,QAAE;AAAEG,MAAAA,IAAF;AAAQD,MAAAA,IAAR;AAAcD,MAAAA;AAAd,KAAF;AAAA,WAC/B,4BAAC,yBAAD;AACC,MAAA,GAAG,EAAI,uBAAuBC,IAAM,EADrC;AAEC,MAAA,IAAI,EAAGA,IAFR;AAGC,MAAA,KAAK,EAAGD,KAHT;AAIC,MAAA,aAAa,EAAGX,mBAAmB,CAAEa,IAAF;AAJpC,MAD+B;AAAA,GAA9B,CA7BH,CADD;AAwCA","sourcesContent":["/**\n * External dependencies\n */\nimport { groupBy } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/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;;AAXA;;AAKA;;AAIA;;AACA;;AAEA;;AAKA;;AAQA;;AACA;;AACA;;AACA;;AACA;;AAhCA;AACA;AACA;;AAGA;AACA;AACA;;AAUA;AACA;AACA;AAkBe,SAASA,aAAT,GAAyB;AACvC,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,MAA6B,qBAAaC,MAAF,IAAc;AAC3D,UAAM;AAA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AG,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
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/navigation-sidebar/navigation-panel/navigation-entity-items.js"],"names":["getEntityTitle","kind","entity","name","title","rendered","NavigationEntityItems","query","entities","select","coreStore","getEntityRecords","setPage","editSiteStore","onActivateItem","type","slug","link","id","path","context","postType","postId","map","key"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AAKA;;AAXA;AACA;AACA;;AAMA;AACA;AACA;AAGA,MAAMA,cAAc,GAAG,CAAEC,IAAF,EAAQC,MAAR;AAAA;;AAAA,SACtB,eAAeD,IAAf,GAAsBC,MAAM,CAACC,IAA7B,GAAoCD,MAApC,aAAoCA,MAApC,wCAAoCA,MAAM,CAAEE,KAA5C,kDAAoC,cAAeC,QAD7B;AAAA,CAAvB;;AAGe,SAASC,qBAAT,OAA6D;AAAA,MAA7B;AAAEL,IAAAA,IAAF;AAAQE,IAAAA,IAAR;AAAcI,IAAAA,KAAK,GAAG;AAAtB,GAA6B;AAC3E,QAAMC,QAAQ,GAAG,qBACdC,MAAF,IAAcA,MAAM,CAAEC,eAAF,CAAN,CAAoBC,gBAApB,CAAsCV,IAAtC,EAA4CE,IAA5C,EAAkDI,KAAlD,CADE,EAEhB,CAAEN,IAAF,EAAQE,IAAR,EAAcI,KAAd,CAFgB,CAAjB;AAKA,QAAM;AAAEK,IAAAA;AAAF,MAAc,uBAAaC,YAAb,CAApB;;AAEA,MAAK,CAAEL,QAAP,EAAkB;AACjB,WAAO,IAAP;AACA;;AAED,QAAMM,cAAc,GAAG,SAAgC;AAAA,QAA9B;AAAEC,MAAAA,IAAF;AAAQC,MAAAA,IAAR;AAAcC,MAAAA,IAAd;AAAoBC,MAAAA;AAApB,KAA8B;AACtDN,IAAAA,OAAO,CAAE;AACRG,MAAAA,IADQ;AAERC,MAAAA,IAFQ;AAGRG,MAAAA,IAAI,EAAE,gCAAuBF,IAAvB,CAHE;AAIRG,MAAAA,OAAO,EAAE;AACRC,QAAAA,QAAQ,EAAEN,IADF;AAERO,QAAAA,MAAM,EAAEJ;AAFA;AAJD,KAAF,CAAP;AASA,GAVD;;AAYA,SAAOV,QAAQ,CAACe,GAAT,CAAgBrB,MAAF,IAAc;AAClC,UAAMsB,GAAG,GAAI,WAAW,gCAAuBtB,MAAM,CAACe,IAA9B,CAAsC,EAA9D;AAEA,WACC,4BAAC,wCAAD;AACC,MAAA,GAAG,EAAGO,GADP;AAEC,MAAA,IAAI,EAAGA,GAFR;AAGC,MAAA,KAAK,EAAGxB,cAAc,CAAEC,IAAF,EAAQC,MAAR,CAHvB;AAIC,MAAA,OAAO,EAAG,MAAMY,cAAc,CAAEZ,MAAF;AAJ/B,MADD;AAQA,GAXM,CAAP;AAYA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { __experimentalNavigationItem as NavigationItem } from '@wordpress/components';\nimport { getPathAndQueryString } from '@wordpress/url';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../../store';\n\nconst getEntityTitle = ( kind, entity ) =>\n\t'taxonomy' === kind ? entity.name : entity?.title?.rendered;\n\nexport default function NavigationEntityItems( { kind, name, query = {} } ) {\n\tconst entities = useSelect(\n\t\t( select ) => select( coreStore ).getEntityRecords( kind, name, query ),\n\t\t[ kind, name, query ]\n\t);\n\n\tconst { setPage } = useDispatch( editSiteStore );\n\n\tif ( ! entities ) {\n\t\treturn null;\n\t}\n\n\tconst onActivateItem = ( { type, slug, link, id } ) => {\n\t\tsetPage( {\n\t\t\ttype,\n\t\t\tslug,\n\t\t\tpath: getPathAndQueryString( link ),\n\t\t\tcontext: {\n\t\t\t\tpostType: type,\n\t\t\t\tpostId: id,\n\t\t\t},\n\t\t} );\n\t};\n\n\treturn entities.map( ( entity ) => {\n\t\tconst key = `content-${ getPathAndQueryString( entity.link ) }`;\n\n\t\treturn (\n\t\t\t<NavigationItem\n\t\t\t\tkey={ key }\n\t\t\t\titem={ key }\n\t\t\t\ttitle={ getEntityTitle( kind, entity ) }\n\t\t\t\tonClick={ () => onActivateItem( entity ) }\n\t\t\t/>\n\t\t);\n\t} );\n}\n"]}
|
|
@@ -1,125 +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 = NewTemplateDropdown;
|
|
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 _icons = require("@wordpress/icons");
|
|
21
|
-
|
|
22
|
-
var _editor = require("@wordpress/editor");
|
|
23
|
-
|
|
24
|
-
var _coreData = require("@wordpress/core-data");
|
|
25
|
-
|
|
26
|
-
var _getClosestAvailableTemplate = _interopRequireDefault(require("../../../utils/get-closest-available-template"));
|
|
27
|
-
|
|
28
|
-
var _constants = require("./constants");
|
|
29
|
-
|
|
30
|
-
var _store = require("../../../store");
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* External dependencies
|
|
34
|
-
*/
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* WordPress dependencies
|
|
38
|
-
*/
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Internal dependencies
|
|
42
|
-
*/
|
|
43
|
-
function NewTemplateDropdown() {
|
|
44
|
-
const {
|
|
45
|
-
defaultTemplateTypes,
|
|
46
|
-
templates
|
|
47
|
-
} = (0, _data.useSelect)(select => {
|
|
48
|
-
const {
|
|
49
|
-
__experimentalGetDefaultTemplateTypes: getDefaultTemplateTypes
|
|
50
|
-
} = select(_editor.store);
|
|
51
|
-
const templateEntities = select(_coreData.store).getEntityRecords('postType', 'wp_template');
|
|
52
|
-
return {
|
|
53
|
-
defaultTemplateTypes: getDefaultTemplateTypes(),
|
|
54
|
-
templates: templateEntities
|
|
55
|
-
};
|
|
56
|
-
}, []);
|
|
57
|
-
const {
|
|
58
|
-
addTemplate
|
|
59
|
-
} = (0, _data.useDispatch)(_store.store);
|
|
60
|
-
|
|
61
|
-
const createTemplate = slug => {
|
|
62
|
-
const closestAvailableTemplate = (0, _getClosestAvailableTemplate.default)(slug, templates);
|
|
63
|
-
const {
|
|
64
|
-
title,
|
|
65
|
-
description
|
|
66
|
-
} = (0, _lodash.find)(defaultTemplateTypes, {
|
|
67
|
-
slug
|
|
68
|
-
});
|
|
69
|
-
addTemplate({
|
|
70
|
-
content: closestAvailableTemplate.content.raw,
|
|
71
|
-
excerpt: description,
|
|
72
|
-
// Slugs need to be strings, so this is for template `404`
|
|
73
|
-
slug: slug.toString(),
|
|
74
|
-
status: 'publish',
|
|
75
|
-
title
|
|
76
|
-
});
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
const existingTemplateSlugs = (0, _lodash.map)(templates, 'slug');
|
|
80
|
-
const missingTemplates = (0, _lodash.filter)(defaultTemplateTypes, template => (0, _lodash.includes)(_constants.TEMPLATES_NEW_OPTIONS, template.slug) && !(0, _lodash.includes)(existingTemplateSlugs, template.slug));
|
|
81
|
-
|
|
82
|
-
if (!missingTemplates.length) {
|
|
83
|
-
return null;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
return (0, _element.createElement)(_components.DropdownMenu, {
|
|
87
|
-
className: "edit-site-navigation-panel__new-template-dropdown",
|
|
88
|
-
icon: null,
|
|
89
|
-
label: (0, _i18n.__)('Add Template'),
|
|
90
|
-
popoverProps: {
|
|
91
|
-
noArrow: false
|
|
92
|
-
},
|
|
93
|
-
toggleProps: {
|
|
94
|
-
children: (0, _element.createElement)(_icons.Icon, {
|
|
95
|
-
icon: _icons.plus
|
|
96
|
-
}),
|
|
97
|
-
isSmall: true,
|
|
98
|
-
variant: 'tertiary'
|
|
99
|
-
}
|
|
100
|
-
}, _ref => {
|
|
101
|
-
let {
|
|
102
|
-
onClose
|
|
103
|
-
} = _ref;
|
|
104
|
-
return (0, _element.createElement)(_components.NavigableMenu, {
|
|
105
|
-
className: "edit-site-navigation-panel__new-template-popover"
|
|
106
|
-
}, (0, _element.createElement)(_components.MenuGroup, {
|
|
107
|
-
label: (0, _i18n.__)('Add Template')
|
|
108
|
-
}, (0, _lodash.map)(missingTemplates, _ref2 => {
|
|
109
|
-
let {
|
|
110
|
-
title,
|
|
111
|
-
description,
|
|
112
|
-
slug
|
|
113
|
-
} = _ref2;
|
|
114
|
-
return (0, _element.createElement)(_components.MenuItem, {
|
|
115
|
-
info: description,
|
|
116
|
-
key: slug,
|
|
117
|
-
onClick: () => {
|
|
118
|
-
createTemplate(slug);
|
|
119
|
-
onClose();
|
|
120
|
-
}
|
|
121
|
-
}, title);
|
|
122
|
-
})));
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
//# sourceMappingURL=new-template-dropdown.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/navigation-sidebar/navigation-panel/new-template-dropdown.js"],"names":["NewTemplateDropdown","defaultTemplateTypes","templates","select","__experimentalGetDefaultTemplateTypes","getDefaultTemplateTypes","editorStore","templateEntities","coreStore","getEntityRecords","addTemplate","editSiteStore","createTemplate","slug","closestAvailableTemplate","title","description","content","raw","excerpt","toString","status","existingTemplateSlugs","missingTemplates","template","TEMPLATES_NEW_OPTIONS","length","noArrow","children","plus","isSmall","variant","onClose"],"mappings":";;;;;;;;;;;AAGA;;AAKA;;AAMA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AAzBA;AACA;AACA;;AAGA;AACA;AACA;;AAaA;AACA;AACA;AAKe,SAASA,mBAAT,GAA+B;AAC7C,QAAM;AAAEC,IAAAA,oBAAF;AAAwBC,IAAAA;AAAxB,MAAsC,qBAAaC,MAAF,IAAc;AACpE,UAAM;AACLC,MAAAA,qCAAqC,EAAEC;AADlC,QAEFF,MAAM,CAAEG,aAAF,CAFV;AAGA,UAAMC,gBAAgB,GAAGJ,MAAM,CAAEK,eAAF,CAAN,CAAoBC,gBAApB,CACxB,UADwB,EAExB,aAFwB,CAAzB;AAIA,WAAO;AACNR,MAAAA,oBAAoB,EAAEI,uBAAuB,EADvC;AAENH,MAAAA,SAAS,EAAEK;AAFL,KAAP;AAIA,GAZ2C,EAYzC,EAZyC,CAA5C;AAaA,QAAM;AAAEG,IAAAA;AAAF,MAAkB,uBAAaC,YAAb,CAAxB;;AAEA,QAAMC,cAAc,GAAKC,IAAF,IAAY;AAClC,UAAMC,wBAAwB,GAAG,0CAChCD,IADgC,EAEhCX,SAFgC,CAAjC;AAIA,UAAM;AAAEa,MAAAA,KAAF;AAASC,MAAAA;AAAT,QAAyB,kBAAMf,oBAAN,EAA4B;AAAEY,MAAAA;AAAF,KAA5B,CAA/B;AACAH,IAAAA,WAAW,CAAE;AACZO,MAAAA,OAAO,EAAEH,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FP;AAGC,QAAA,OAAO,EAAG,MAAM;AACfD,UAAAA,cAAc,CAAEC,IAAF,CAAd;AACAmB,UAAAA,OAAO;AACP;AANF,SAQGjB,KARH,CADD;AAAA,KAFC,CADH,CADD,CADC;AAAA,GAbH,CADD;AAqCA","sourcesContent":["/**\n * External dependencies\n */\nimport { filter, find, includes, map } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tDropdownMenu,\n\tMenuGroup,\n\tMenuItem,\n\tNavigableMenu,\n} from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { Icon, plus } from '@wordpress/icons';\nimport { store as editorStore } from '@wordpress/editor';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport getClosestAvailableTemplate from '../../../utils/get-closest-available-template';\nimport { TEMPLATES_NEW_OPTIONS } from './constants';\nimport { store as editSiteStore } from '../../../store';\n\nexport default function NewTemplateDropdown() {\n\tconst { defaultTemplateTypes, templates } = useSelect( ( select ) => {\n\t\tconst {\n\t\t\t__experimentalGetDefaultTemplateTypes: getDefaultTemplateTypes,\n\t\t} = select( editorStore );\n\t\tconst templateEntities = select( coreStore ).getEntityRecords(\n\t\t\t'postType',\n\t\t\t'wp_template'\n\t\t);\n\t\treturn {\n\t\t\tdefaultTemplateTypes: getDefaultTemplateTypes(),\n\t\t\ttemplates: templateEntities,\n\t\t};\n\t}, [] );\n\tconst { addTemplate } = useDispatch( editSiteStore );\n\n\tconst createTemplate = ( slug ) => {\n\t\tconst closestAvailableTemplate = getClosestAvailableTemplate(\n\t\t\tslug,\n\t\t\ttemplates\n\t\t);\n\t\tconst { title, description } = find( defaultTemplateTypes, { slug } );\n\t\taddTemplate( {\n\t\t\tcontent: closestAvailableTemplate.content.raw,\n\t\t\texcerpt: description,\n\t\t\t// Slugs need to be strings, so this is for template `404`\n\t\t\tslug: slug.toString(),\n\t\t\tstatus: 'publish',\n\t\t\ttitle,\n\t\t} );\n\t};\n\n\tconst existingTemplateSlugs = map( templates, 'slug' );\n\n\tconst missingTemplates = filter(\n\t\tdefaultTemplateTypes,\n\t\t( template ) =>\n\t\t\tincludes( TEMPLATES_NEW_OPTIONS, template.slug ) &&\n\t\t\t! includes( existingTemplateSlugs, template.slug )\n\t);\n\n\tif ( ! missingTemplates.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<DropdownMenu\n\t\t\tclassName=\"edit-site-navigation-panel__new-template-dropdown\"\n\t\t\ticon={ null }\n\t\t\tlabel={ __( 'Add Template' ) }\n\t\t\tpopoverProps={ {\n\t\t\t\tnoArrow: false,\n\t\t\t} }\n\t\t\ttoggleProps={ {\n\t\t\t\tchildren: <Icon icon={ plus } />,\n\t\t\t\tisSmall: true,\n\t\t\t\tvariant: 'tertiary',\n\t\t\t} }\n\t\t>\n\t\t\t{ ( { onClose } ) => (\n\t\t\t\t<NavigableMenu className=\"edit-site-navigation-panel__new-template-popover\">\n\t\t\t\t\t<MenuGroup label={ __( 'Add Template' ) }>\n\t\t\t\t\t\t{ map(\n\t\t\t\t\t\t\tmissingTemplates,\n\t\t\t\t\t\t\t( { title, description, slug } ) => (\n\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\tinfo={ description }\n\t\t\t\t\t\t\t\t\tkey={ slug }\n\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\tcreateTemplate( slug );\n\t\t\t\t\t\t\t\t\t\tonClose();\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{ title }\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) }\n\t\t\t\t\t</MenuGroup>\n\t\t\t\t</NavigableMenu>\n\t\t\t) }\n\t\t</DropdownMenu>\n\t);\n}\n"]}
|