@wordpress/block-library 7.0.0 → 7.0.2
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/README.md +16 -0
- package/build/button/edit.native.js +2 -2
- package/build/button/edit.native.js.map +1 -1
- package/build/columns/index.js +12 -0
- package/build/columns/index.js.map +1 -1
- package/build/comment-author-avatar/edit.js +17 -4
- package/build/comment-author-avatar/edit.js.map +1 -1
- package/build/comment-template/edit.js +94 -36
- package/build/comment-template/edit.js.map +1 -1
- package/build/comment-template/hooks.js +175 -0
- package/build/comment-template/hooks.js.map +1 -0
- package/build/comment-template/index.js +1 -1
- package/build/comment-template/util.js.map +1 -1
- package/build/comments-pagination-next/index.js +1 -1
- package/build/comments-pagination-numbers/index.js +1 -1
- package/build/comments-query-loop/edit/comments-inspector-controls.js +20 -9
- package/build/comments-query-loop/edit/comments-inspector-controls.js.map +1 -1
- package/build/comments-query-loop/edit.js +1 -19
- package/build/comments-query-loop/edit.js.map +1 -1
- package/build/comments-query-loop/index.js +5 -0
- package/build/comments-query-loop/index.js.map +1 -1
- package/build/cover/edit.js +21 -22
- package/build/cover/edit.js.map +1 -1
- package/build/cover/edit.native.js +7 -5
- package/build/cover/edit.native.js.map +1 -1
- package/build/cover/overlay-color-settings.native.js +4 -3
- package/build/cover/overlay-color-settings.native.js.map +1 -1
- package/build/cover/transforms.js +4 -2
- package/build/cover/transforms.js.map +1 -1
- package/build/group/index.js +1 -0
- package/build/group/index.js.map +1 -1
- package/build/heading/edit.js +14 -2
- package/build/heading/edit.js.map +1 -1
- package/build/image/deprecated.js +89 -5
- package/build/image/deprecated.js.map +1 -1
- package/build/image/save.js +0 -7
- package/build/image/save.js.map +1 -1
- package/build/latest-posts/edit.js +1 -0
- package/build/latest-posts/edit.js.map +1 -1
- package/build/navigation/edit/index.js +17 -15
- package/build/navigation/edit/index.js.map +1 -1
- package/build/navigation/edit/navigation-menu-selector.js +44 -27
- package/build/navigation/edit/navigation-menu-selector.js.map +1 -1
- package/build/navigation/edit/placeholder/index.js +8 -22
- package/build/navigation/edit/placeholder/index.js.map +1 -1
- package/build/navigation/use-navigation-menu.js +6 -6
- package/build/navigation/use-navigation-menu.js.map +1 -1
- package/build/navigation-submenu/edit.js +41 -9
- package/build/navigation-submenu/edit.js.map +1 -1
- package/build/page-list/edit.js +11 -17
- package/build/page-list/edit.js.map +1 -1
- package/build/social-links/deprecated.js +1 -62
- package/build/social-links/deprecated.js.map +1 -1
- package/build/template-part/edit/index.js +36 -64
- package/build/template-part/edit/index.js.map +1 -1
- package/build/template-part/edit/placeholder.js +64 -0
- package/build/template-part/edit/placeholder.js.map +1 -0
- package/build/template-part/edit/selection-modal.js +103 -0
- package/build/template-part/edit/selection-modal.js.map +1 -0
- package/build/template-part/edit/title-modal.js +54 -0
- package/build/template-part/edit/title-modal.js.map +1 -0
- package/build/template-part/edit/utils/hooks.js +156 -0
- package/build/template-part/edit/utils/hooks.js.map +1 -0
- package/build/template-part/index.js +3 -1
- package/build/template-part/index.js.map +1 -1
- package/build-module/button/edit.native.js +4 -4
- package/build-module/button/edit.native.js.map +1 -1
- package/build-module/columns/index.js +12 -0
- package/build-module/columns/index.js.map +1 -1
- package/build-module/comment-author-avatar/edit.js +18 -6
- package/build-module/comment-author-avatar/edit.js.map +1 -1
- package/build-module/comment-template/edit.js +95 -37
- package/build-module/comment-template/edit.js.map +1 -1
- package/build-module/comment-template/hooks.js +156 -0
- package/build-module/comment-template/hooks.js.map +1 -0
- package/build-module/comment-template/index.js +1 -1
- package/build-module/comment-template/util.js.map +1 -1
- package/build-module/comments-pagination-next/index.js +1 -1
- package/build-module/comments-pagination-numbers/index.js +1 -1
- package/build-module/comments-query-loop/edit/comments-inspector-controls.js +20 -9
- package/build-module/comments-query-loop/edit/comments-inspector-controls.js.map +1 -1
- package/build-module/comments-query-loop/edit.js +2 -19
- package/build-module/comments-query-loop/edit.js.map +1 -1
- package/build-module/comments-query-loop/index.js +5 -0
- package/build-module/comments-query-loop/index.js.map +1 -1
- package/build-module/cover/edit.js +23 -24
- package/build-module/cover/edit.js.map +1 -1
- package/build-module/cover/edit.native.js +10 -8
- package/build-module/cover/edit.native.js.map +1 -1
- package/build-module/cover/overlay-color-settings.native.js +4 -4
- package/build-module/cover/overlay-color-settings.native.js.map +1 -1
- package/build-module/cover/transforms.js +4 -2
- package/build-module/cover/transforms.js.map +1 -1
- package/build-module/group/index.js +1 -0
- package/build-module/group/index.js.map +1 -1
- package/build-module/heading/edit.js +15 -3
- package/build-module/heading/edit.js.map +1 -1
- package/build-module/image/deprecated.js +90 -7
- package/build-module/image/deprecated.js.map +1 -1
- package/build-module/image/save.js +0 -7
- package/build-module/image/save.js.map +1 -1
- package/build-module/latest-posts/edit.js +1 -0
- package/build-module/latest-posts/edit.js.map +1 -1
- package/build-module/navigation/edit/index.js +17 -15
- package/build-module/navigation/edit/index.js.map +1 -1
- package/build-module/navigation/edit/navigation-menu-selector.js +45 -27
- package/build-module/navigation/edit/navigation-menu-selector.js.map +1 -1
- package/build-module/navigation/edit/placeholder/index.js +8 -21
- package/build-module/navigation/edit/placeholder/index.js.map +1 -1
- package/build-module/navigation/use-navigation-menu.js +6 -6
- package/build-module/navigation/use-navigation-menu.js.map +1 -1
- package/build-module/navigation-submenu/edit.js +41 -10
- package/build-module/navigation-submenu/edit.js.map +1 -1
- package/build-module/page-list/edit.js +12 -18
- package/build-module/page-list/edit.js.map +1 -1
- package/build-module/social-links/deprecated.js +1 -62
- package/build-module/social-links/deprecated.js.map +1 -1
- package/build-module/template-part/edit/index.js +37 -65
- package/build-module/template-part/edit/index.js.map +1 -1
- package/build-module/template-part/edit/placeholder.js +52 -0
- package/build-module/template-part/edit/placeholder.js.map +1 -0
- package/build-module/template-part/edit/selection-modal.js +89 -0
- package/build-module/template-part/edit/selection-modal.js.map +1 -0
- package/build-module/template-part/edit/title-modal.js +46 -0
- package/build-module/template-part/edit/title-modal.js.map +1 -0
- package/build-module/template-part/edit/utils/hooks.js +135 -0
- package/build-module/template-part/edit/utils/hooks.js.map +1 -0
- package/build-module/template-part/index.js +2 -1
- package/build-module/template-part/index.js.map +1 -1
- package/build-style/comment-author-avatar/editor-rtl.css +83 -0
- package/build-style/comment-author-avatar/editor.css +83 -0
- package/build-style/cover/style-rtl.css +4 -0
- package/build-style/cover/style.css +4 -0
- package/build-style/editor-rtl.css +27 -81
- package/build-style/editor.css +27 -81
- package/build-style/image/editor-rtl.css +0 -16
- package/build-style/image/editor.css +0 -16
- package/build-style/image/style-rtl.css +2 -0
- package/build-style/image/style.css +2 -0
- package/build-style/navigation/style-rtl.css +14 -3
- package/build-style/navigation/style.css +14 -3
- package/build-style/page-list/editor-rtl.css +0 -9
- package/build-style/page-list/editor.css +0 -9
- package/build-style/style-rtl.css +20 -3
- package/build-style/style.css +20 -3
- package/build-style/template-part/editor-rtl.css +19 -56
- package/build-style/template-part/editor.css +19 -56
- package/package.json +15 -15
- package/src/archives/index.php +1 -1
- package/src/button/edit.native.js +3 -3
- package/src/columns/block.json +12 -0
- package/src/comment-author-avatar/edit.js +13 -8
- package/src/comment-author-avatar/editor.scss +7 -0
- package/src/comment-template/block.json +7 -1
- package/src/comment-template/edit.js +102 -40
- package/src/comment-template/hooks.js +151 -0
- package/src/comment-template/index.php +8 -0
- package/src/comment-template/util.js +1 -0
- package/src/comments-pagination-next/block.json +8 -1
- package/src/comments-pagination-next/index.php +6 -8
- package/src/comments-pagination-numbers/block.json +7 -1
- package/src/comments-pagination-numbers/index.php +3 -10
- package/src/comments-query-loop/block.json +5 -0
- package/src/comments-query-loop/edit/comments-inspector-controls.js +22 -4
- package/src/comments-query-loop/edit.js +1 -16
- package/src/cover/edit.js +15 -28
- package/src/cover/edit.native.js +15 -7
- package/src/cover/overlay-color-settings.native.js +3 -4
- package/src/cover/style.scss +4 -0
- package/src/cover/transforms.js +2 -0
- package/src/editor.scss +1 -0
- package/src/gallery/index.php +1 -8
- package/src/group/block.json +1 -0
- package/src/heading/edit.js +18 -5
- package/src/home-link/index.php +1 -19
- package/src/image/deprecated.js +105 -1
- package/src/image/editor.scss +0 -18
- package/src/image/save.js +0 -8
- package/src/image/style.scss +3 -0
- package/src/image/test/edit.native.js +0 -10
- package/src/latest-posts/edit.js +1 -0
- package/src/latest-posts/index.php +1 -1
- package/src/navigation/edit/index.js +25 -26
- package/src/navigation/edit/navigation-menu-selector.js +73 -28
- package/src/navigation/edit/placeholder/index.js +8 -32
- package/src/navigation/index.php +4 -4
- package/src/navigation/style.scss +22 -3
- package/src/navigation/use-navigation-menu.js +6 -6
- package/src/navigation-link/index.php +3 -22
- package/src/navigation-submenu/edit.js +50 -12
- package/src/navigation-submenu/index.php +3 -21
- package/src/page-list/edit.js +21 -25
- package/src/page-list/editor.scss +0 -10
- package/src/page-list/index.php +4 -4
- package/src/post-navigation-link/index.php +3 -3
- package/src/search/index.php +6 -3
- package/src/site-logo/index.php +1 -1
- package/src/social-links/deprecated.js +0 -59
- package/src/template-part/edit/index.js +61 -71
- package/src/template-part/edit/placeholder.js +78 -0
- package/src/template-part/edit/selection-modal.js +115 -0
- package/src/template-part/edit/title-modal.js +59 -0
- package/src/template-part/edit/utils/hooks.js +158 -0
- package/src/template-part/editor.scss +16 -74
- package/src/template-part/index.js +4 -1
- package/build/navigation/edit/existing-menus-options.js +0 -62
- package/build/navigation/edit/existing-menus-options.js.map +0 -1
- package/build/template-part/edit/placeholder/index.js +0 -141
- package/build/template-part/edit/placeholder/index.js.map +0 -1
- package/build/template-part/edit/placeholder/patterns-setup.js +0 -100
- package/build/template-part/edit/placeholder/patterns-setup.js.map +0 -1
- package/build/template-part/edit/selection/index.js +0 -45
- package/build/template-part/edit/selection/index.js.map +0 -1
- package/build/template-part/edit/selection/template-part-previews.js +0 -317
- package/build/template-part/edit/selection/template-part-previews.js.map +0 -1
- package/build-module/navigation/edit/existing-menus-options.js +0 -53
- package/build-module/navigation/edit/existing-menus-options.js.map +0 -1
- package/build-module/template-part/edit/placeholder/index.js +0 -124
- package/build-module/template-part/edit/placeholder/index.js.map +0 -1
- package/build-module/template-part/edit/placeholder/patterns-setup.js +0 -91
- package/build-module/template-part/edit/placeholder/patterns-setup.js.map +0 -1
- package/build-module/template-part/edit/selection/index.js +0 -35
- package/build-module/template-part/edit/selection/index.js.map +0 -1
- package/build-module/template-part/edit/selection/template-part-previews.js +0 -298
- package/build-module/template-part/edit/selection/template-part-previews.js.map +0 -1
- package/src/navigation/edit/existing-menus-options.js +0 -70
- package/src/template-part/edit/placeholder/index.js +0 -172
- package/src/template-part/edit/placeholder/patterns-setup.js +0 -124
- package/src/template-part/edit/selection/index.js +0 -37
- package/src/template-part/edit/selection/template-part-previews.js +0 -372
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/template-part/edit/selection/index.js"],"names":["TemplatePartSelection","setAttributes","onClose","area","templatePartId","filterValue","setFilterValue"],"mappings":";;;;;;;;;AAIA;;AADA;;AAMA;;AATA;AACA;AACA;;AAIA;AACA;AACA;AAGe,SAASA,qBAAT,OAKX;AAAA,MAL2C;AAC9CC,IAAAA,aAD8C;AAE9CC,IAAAA,OAF8C;AAG9CC,IAAAA,IAH8C;AAI9CC,IAAAA,cAAc,GAAG;AAJ6B,GAK3C;AACH,QAAM,CAAEC,WAAF,EAAeC,cAAf,IAAkC,uBAAU,EAAV,CAAxC;AACA,SACC,yCACC,4BAAC,yBAAD;AACC,IAAA,KAAK,EAAGD,WADT;AAEC,IAAA,QAAQ,EAAGC,cAFZ;AAGC,IAAA,SAAS,EAAC;AAHX,IADD,EAMC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,4BAAC,6BAAD;AACC,IAAA,aAAa,EAAGL,aADjB;AAEC,IAAA,WAAW,EAAGI,WAFf;AAGC,IAAA,OAAO,EAAGH,OAHX;AAIC,IAAA,IAAI,EAAGC,IAJR;AAKC,IAAA,cAAc,EAAGC;AALlB,IADD,CAND,CADD;AAkBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { SearchControl } from '@wordpress/components';\nimport { useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport TemplatePartPreviews from './template-part-previews';\n\nexport default function TemplatePartSelection( {\n\tsetAttributes,\n\tonClose,\n\tarea,\n\ttemplatePartId = null,\n} ) {\n\tconst [ filterValue, setFilterValue ] = useState( '' );\n\treturn (\n\t\t<div>\n\t\t\t<SearchControl\n\t\t\t\tvalue={ filterValue }\n\t\t\t\tonChange={ setFilterValue }\n\t\t\t\tclassName=\"wp-block-template-part__selection-preview-search-form\"\n\t\t\t/>\n\t\t\t<div className=\"wp-block-template-part__selection-preview-container\">\n\t\t\t\t<TemplatePartPreviews\n\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\tfilterValue={ filterValue }\n\t\t\t\t\tonClose={ onClose }\n\t\t\t\t\tarea={ area }\n\t\t\t\t\ttemplatePartId={ templatePartId }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n"]}
|
|
@@ -1,317 +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 = TemplatePartPreviews;
|
|
9
|
-
|
|
10
|
-
var _element = require("@wordpress/element");
|
|
11
|
-
|
|
12
|
-
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
13
|
-
|
|
14
|
-
var _lodash = require("lodash");
|
|
15
|
-
|
|
16
|
-
var _data = require("@wordpress/data");
|
|
17
|
-
|
|
18
|
-
var _blocks = require("@wordpress/blocks");
|
|
19
|
-
|
|
20
|
-
var _keycodes = require("@wordpress/keycodes");
|
|
21
|
-
|
|
22
|
-
var _i18n = require("@wordpress/i18n");
|
|
23
|
-
|
|
24
|
-
var _blockEditor = require("@wordpress/block-editor");
|
|
25
|
-
|
|
26
|
-
var _components = require("@wordpress/components");
|
|
27
|
-
|
|
28
|
-
var _compose = require("@wordpress/compose");
|
|
29
|
-
|
|
30
|
-
var _notices = require("@wordpress/notices");
|
|
31
|
-
|
|
32
|
-
var _coreData = require("@wordpress/core-data");
|
|
33
|
-
|
|
34
|
-
var _createTemplatePartId = require("../utils/create-template-part-id");
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* External dependencies
|
|
38
|
-
*/
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* WordPress dependencies
|
|
42
|
-
*/
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Internal dependencies
|
|
46
|
-
*/
|
|
47
|
-
function getAreaGroupTitle(areaLabel) {
|
|
48
|
-
return (0, _i18n.sprintf)( // Translators: %s for the area the template part is assigned to (Header, Footer, General, etc.)
|
|
49
|
-
(0, _i18n.__)('Area: %s'), areaLabel);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
function PreviewPlaceholder() {
|
|
53
|
-
return (0, _element.createElement)("div", {
|
|
54
|
-
className: "wp-block-template-part__selection-preview-item is-placeholder",
|
|
55
|
-
tabIndex: 0
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
function TemplatePartItem(_ref) {
|
|
60
|
-
let {
|
|
61
|
-
templatePart,
|
|
62
|
-
setAttributes,
|
|
63
|
-
onClose,
|
|
64
|
-
composite
|
|
65
|
-
} = _ref;
|
|
66
|
-
const {
|
|
67
|
-
slug,
|
|
68
|
-
theme,
|
|
69
|
-
title: {
|
|
70
|
-
rendered: title
|
|
71
|
-
}
|
|
72
|
-
} = templatePart; // The 'raw' property is not defined for a brief period in the save cycle.
|
|
73
|
-
// The fallback prevents an error in the parse function while saving.
|
|
74
|
-
|
|
75
|
-
const content = templatePart.content.raw || '';
|
|
76
|
-
const blocks = (0, _element.useMemo)(() => (0, _blocks.parse)(content), [content]);
|
|
77
|
-
const {
|
|
78
|
-
createSuccessNotice
|
|
79
|
-
} = (0, _data.useDispatch)(_notices.store);
|
|
80
|
-
const onClick = (0, _element.useCallback)(() => {
|
|
81
|
-
setAttributes({
|
|
82
|
-
slug,
|
|
83
|
-
theme,
|
|
84
|
-
area: undefined
|
|
85
|
-
});
|
|
86
|
-
createSuccessNotice((0, _i18n.sprintf)(
|
|
87
|
-
/* translators: %s: template part title. */
|
|
88
|
-
(0, _i18n.__)('Template Part "%s" inserted.'), title || slug), {
|
|
89
|
-
type: 'snackbar'
|
|
90
|
-
});
|
|
91
|
-
onClose();
|
|
92
|
-
}, [slug, theme]);
|
|
93
|
-
return (0, _element.createElement)(_components.__unstableCompositeItem, (0, _extends2.default)({
|
|
94
|
-
as: "div",
|
|
95
|
-
className: "wp-block-template-part__selection-preview-item",
|
|
96
|
-
role: "option",
|
|
97
|
-
onClick: onClick,
|
|
98
|
-
onKeyDown: event => {
|
|
99
|
-
if (_keycodes.ENTER === event.keyCode || _keycodes.SPACE === event.keyCode) {
|
|
100
|
-
onClick();
|
|
101
|
-
}
|
|
102
|
-
},
|
|
103
|
-
tabIndex: 0,
|
|
104
|
-
"aria-label": title || slug
|
|
105
|
-
}, composite), (0, _element.createElement)(_blockEditor.BlockPreview, {
|
|
106
|
-
blocks: blocks
|
|
107
|
-
}), (0, _element.createElement)("div", {
|
|
108
|
-
className: "wp-block-template-part__selection-preview-item-title"
|
|
109
|
-
}, title || slug));
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
function PanelGroup(_ref2) {
|
|
113
|
-
let {
|
|
114
|
-
title,
|
|
115
|
-
icon,
|
|
116
|
-
children
|
|
117
|
-
} = _ref2;
|
|
118
|
-
return (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)("div", {
|
|
119
|
-
className: "wp-block-template-part__selection-panel-group-header"
|
|
120
|
-
}, (0, _element.createElement)("span", {
|
|
121
|
-
className: "wp-block-template-part__selection-panel-group-title"
|
|
122
|
-
}, title), (0, _element.createElement)(_components.Icon, {
|
|
123
|
-
icon: icon
|
|
124
|
-
})), (0, _element.createElement)("div", {
|
|
125
|
-
className: "wp-block-template-part__selection-panel-group-content"
|
|
126
|
-
}, children));
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
function TemplatePartsByArea(_ref3) {
|
|
130
|
-
let {
|
|
131
|
-
templateParts,
|
|
132
|
-
setAttributes,
|
|
133
|
-
onClose,
|
|
134
|
-
composite,
|
|
135
|
-
area = 'uncategorized',
|
|
136
|
-
labelsByArea
|
|
137
|
-
} = _ref3;
|
|
138
|
-
const {
|
|
139
|
-
templatePartsByArea,
|
|
140
|
-
templatePartsToShow
|
|
141
|
-
} = (0, _element.useMemo)(() => {
|
|
142
|
-
const _templatePartsToShow = templateParts.filter(templatePart => 'uncategorized' === area || templatePart.area === area) || [];
|
|
143
|
-
|
|
144
|
-
const _templatePartsByArea = Object.values((0, _lodash.groupBy)(_templatePartsToShow, 'area'));
|
|
145
|
-
|
|
146
|
-
const orderedTemplatePartsToShow = (0, _lodash.flatten)(_templatePartsToShow);
|
|
147
|
-
return {
|
|
148
|
-
templatePartsByArea: _templatePartsByArea,
|
|
149
|
-
templatePartsToShow: orderedTemplatePartsToShow
|
|
150
|
-
};
|
|
151
|
-
}, [templateParts, area]);
|
|
152
|
-
const currentShownTPs = (0, _compose.useAsyncList)(templatePartsToShow);
|
|
153
|
-
|
|
154
|
-
if (!templatePartsToShow.length) {
|
|
155
|
-
return (0, _element.createElement)(PanelGroup, {
|
|
156
|
-
title: getAreaGroupTitle(labelsByArea[area] || labelsByArea.uncategorized)
|
|
157
|
-
}, (0, _i18n.sprintf)( // Translators: %s for the template part variation ("Header", "Footer", "Template Part").
|
|
158
|
-
(0, _i18n.__)('There is no other %s available. If you are looking for another type of template part, try searching for it using the input above.'), area && area !== 'uncategorized' ? labelsByArea[area] || area : (0, _i18n.__)('Template Part')));
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
return templatePartsByArea.map(templatePartList => {
|
|
162
|
-
return (0, _element.createElement)(PanelGroup, {
|
|
163
|
-
key: templatePartList[0].area,
|
|
164
|
-
title: getAreaGroupTitle(labelsByArea[templatePartList[0].area] || labelsByArea.uncategorized)
|
|
165
|
-
}, templatePartList.map(templatePart => {
|
|
166
|
-
return currentShownTPs.includes(templatePart) ? (0, _element.createElement)(TemplatePartItem, {
|
|
167
|
-
key: templatePart.id,
|
|
168
|
-
templatePart: templatePart,
|
|
169
|
-
setAttributes: setAttributes,
|
|
170
|
-
onClose: onClose,
|
|
171
|
-
composite: composite
|
|
172
|
-
}) : (0, _element.createElement)(PreviewPlaceholder, {
|
|
173
|
-
key: templatePart.id
|
|
174
|
-
});
|
|
175
|
-
}));
|
|
176
|
-
});
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
function TemplatePartSearchResults(_ref4) {
|
|
180
|
-
let {
|
|
181
|
-
templateParts,
|
|
182
|
-
setAttributes,
|
|
183
|
-
filterValue,
|
|
184
|
-
onClose,
|
|
185
|
-
composite,
|
|
186
|
-
labelsByArea
|
|
187
|
-
} = _ref4;
|
|
188
|
-
const {
|
|
189
|
-
filteredTPs,
|
|
190
|
-
groupedResults
|
|
191
|
-
} = (0, _element.useMemo)(() => {
|
|
192
|
-
// Filter based on value.
|
|
193
|
-
// Remove diacritics and convert to lowercase to normalize.
|
|
194
|
-
const normalizedFilterValue = (0, _lodash.deburr)(filterValue).toLowerCase();
|
|
195
|
-
const searchResults = templateParts.filter(_ref5 => {
|
|
196
|
-
let {
|
|
197
|
-
title: {
|
|
198
|
-
rendered: title
|
|
199
|
-
},
|
|
200
|
-
area
|
|
201
|
-
} = _ref5;
|
|
202
|
-
return (0, _lodash.deburr)(title).toLowerCase().includes(normalizedFilterValue) || // Since diacritics can be used in theme names, remove them for the comparison.
|
|
203
|
-
(0, _lodash.deburr)(labelsByArea[area]).toLowerCase().includes(normalizedFilterValue);
|
|
204
|
-
}); // Order based on value location.
|
|
205
|
-
|
|
206
|
-
searchResults.sort((a, b) => {
|
|
207
|
-
// First prioritize index found in title.
|
|
208
|
-
// Deburr for diacritics.
|
|
209
|
-
const indexInTitleA = (0, _lodash.deburr)(a.title.rendered).toLowerCase().indexOf(normalizedFilterValue);
|
|
210
|
-
const indexInTitleB = (0, _lodash.deburr)(b.title.rendered).toLowerCase().indexOf(normalizedFilterValue);
|
|
211
|
-
|
|
212
|
-
if (indexInTitleA !== -1 && indexInTitleB !== -1) {
|
|
213
|
-
return indexInTitleA - indexInTitleB;
|
|
214
|
-
} else if (indexInTitleA !== -1) {
|
|
215
|
-
return -1;
|
|
216
|
-
} else if (indexInTitleB !== -1) {
|
|
217
|
-
return 1;
|
|
218
|
-
} // Second prioritize index found in area.
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
return (0, _lodash.deburr)(labelsByArea[a.area]).toLowerCase().indexOf(normalizedFilterValue) - (0, _lodash.deburr)(labelsByArea[b.area]).toLowerCase().indexOf(normalizedFilterValue);
|
|
222
|
-
}); // Group filtered results together if their neighbors share the same area.
|
|
223
|
-
// This helps not show redundant panel groups side by side in the results.
|
|
224
|
-
|
|
225
|
-
const _groupedResults = [];
|
|
226
|
-
|
|
227
|
-
for (let i = 0; i < searchResults.length; i++) {
|
|
228
|
-
if (i !== 0 && searchResults[i].area === searchResults[i - 1].area) {
|
|
229
|
-
_groupedResults[_groupedResults.length - 1].push(searchResults[i]);
|
|
230
|
-
} else {
|
|
231
|
-
_groupedResults.push([searchResults[i]]);
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
return {
|
|
236
|
-
filteredTPs: searchResults,
|
|
237
|
-
groupedResults: _groupedResults
|
|
238
|
-
};
|
|
239
|
-
}, [filterValue, templateParts]);
|
|
240
|
-
const currentShownTPs = (0, _compose.useAsyncList)(filteredTPs);
|
|
241
|
-
return groupedResults.map(group => (0, _element.createElement)(PanelGroup, {
|
|
242
|
-
key: group[0].id,
|
|
243
|
-
title: getAreaGroupTitle(labelsByArea[group[0].area] || labelsByArea.uncategorized)
|
|
244
|
-
}, group.map(templatePart => currentShownTPs.includes(templatePart) ? (0, _element.createElement)(TemplatePartItem, {
|
|
245
|
-
key: templatePart.id,
|
|
246
|
-
templatePart: templatePart,
|
|
247
|
-
setAttributes: setAttributes,
|
|
248
|
-
onClose: onClose,
|
|
249
|
-
composite: composite
|
|
250
|
-
}) : (0, _element.createElement)(PreviewPlaceholder, {
|
|
251
|
-
key: templatePart.id
|
|
252
|
-
}))));
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
function TemplatePartPreviews(_ref6) {
|
|
256
|
-
let {
|
|
257
|
-
setAttributes,
|
|
258
|
-
filterValue,
|
|
259
|
-
onClose,
|
|
260
|
-
area,
|
|
261
|
-
templatePartId
|
|
262
|
-
} = _ref6;
|
|
263
|
-
const composite = (0, _components.__unstableUseCompositeState)();
|
|
264
|
-
const {
|
|
265
|
-
templateParts,
|
|
266
|
-
labelsByArea
|
|
267
|
-
} = (0, _data.useSelect)(select => {
|
|
268
|
-
const _templateParts = (select(_coreData.store).getEntityRecords('postType', 'wp_template_part', {
|
|
269
|
-
per_page: -1
|
|
270
|
-
}) || []).filter(templatePart => (0, _createTemplatePartId.createTemplatePartId)(templatePart.theme, templatePart.slug) !== templatePartId); // FIXME: @wordpress/block-library should not depend on @wordpress/editor.
|
|
271
|
-
// Blocks can be loaded into a *non-post* block editor.
|
|
272
|
-
// eslint-disable-next-line @wordpress/data-no-store-string-literals
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
const definedAreas = select('core/editor').__experimentalGetDefaultTemplatePartAreas();
|
|
276
|
-
|
|
277
|
-
const _labelsByArea = {};
|
|
278
|
-
definedAreas.forEach(item => {
|
|
279
|
-
_labelsByArea[item.area] = item.label;
|
|
280
|
-
});
|
|
281
|
-
return {
|
|
282
|
-
templateParts: _templateParts,
|
|
283
|
-
labelsByArea: _labelsByArea
|
|
284
|
-
};
|
|
285
|
-
}, []);
|
|
286
|
-
|
|
287
|
-
if (!templateParts || !templateParts.length) {
|
|
288
|
-
return (0, _element.createElement)(PanelGroup, null, (0, _i18n.__)('There are no existing template parts to select.'));
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
if (filterValue) {
|
|
292
|
-
return (0, _element.createElement)(_components.__unstableComposite, (0, _extends2.default)({}, composite, {
|
|
293
|
-
role: "listbox",
|
|
294
|
-
"aria-label": (0, _i18n.__)('List of template parts')
|
|
295
|
-
}), (0, _element.createElement)(TemplatePartSearchResults, {
|
|
296
|
-
templateParts: templateParts,
|
|
297
|
-
setAttributes: setAttributes,
|
|
298
|
-
filterValue: filterValue,
|
|
299
|
-
onClose: onClose,
|
|
300
|
-
composite: composite,
|
|
301
|
-
labelsByArea: labelsByArea
|
|
302
|
-
}));
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
return (0, _element.createElement)(_components.__unstableComposite, (0, _extends2.default)({}, composite, {
|
|
306
|
-
role: "listbox",
|
|
307
|
-
"aria-label": (0, _i18n.__)('List of template parts')
|
|
308
|
-
}), (0, _element.createElement)(TemplatePartsByArea, {
|
|
309
|
-
templateParts: templateParts,
|
|
310
|
-
setAttributes: setAttributes,
|
|
311
|
-
onClose: onClose,
|
|
312
|
-
composite: composite,
|
|
313
|
-
area: area,
|
|
314
|
-
labelsByArea: labelsByArea
|
|
315
|
-
}));
|
|
316
|
-
}
|
|
317
|
-
//# sourceMappingURL=template-part-previews.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/template-part/edit/selection/template-part-previews.js"],"names":["getAreaGroupTitle","areaLabel","PreviewPlaceholder","TemplatePartItem","templatePart","setAttributes","onClose","composite","slug","theme","title","rendered","content","raw","blocks","createSuccessNotice","noticesStore","onClick","area","undefined","type","event","ENTER","keyCode","SPACE","PanelGroup","icon","children","TemplatePartsByArea","templateParts","labelsByArea","templatePartsByArea","templatePartsToShow","_templatePartsToShow","filter","_templatePartsByArea","Object","values","orderedTemplatePartsToShow","currentShownTPs","length","uncategorized","map","templatePartList","includes","id","TemplatePartSearchResults","filterValue","filteredTPs","groupedResults","normalizedFilterValue","toLowerCase","searchResults","sort","a","b","indexInTitleA","indexOf","indexInTitleB","_groupedResults","i","push","group","TemplatePartPreviews","templatePartId","select","_templateParts","coreStore","getEntityRecords","per_page","definedAreas","__experimentalGetDefaultTemplatePartAreas","_labelsByArea","forEach","item","label"],"mappings":";;;;;;;;;AAUA;;;;AAPA;;AAKA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AAMA;;AACA;;AACA;;AAKA;;AA3BA;AACA;AACA;;AAGA;AACA;AACA;;AAiBA;AACA;AACA;AAGA,SAASA,iBAAT,CAA4BC,SAA5B,EAAwC;AACvC,SAAO,oBACN;AACA,gBAAI,UAAJ,CAFM,EAGNA,SAHM,CAAP;AAKA;;AACD,SAASC,kBAAT,GAA8B;AAC7B,SACC;AACC,IAAA,SAAS,EAAC,+DADX;AAEC,IAAA,QAAQ,EAAG;AAFZ,IADD;AAMA;;AAED,SAASC,gBAAT,OAKI;AAAA,MALuB;AAC1BC,IAAAA,YAD0B;AAE1BC,IAAAA,aAF0B;AAG1BC,IAAAA,OAH0B;AAI1BC,IAAAA;AAJ0B,GAKvB;AACH,QAAM;AACLC,IAAAA,IADK;AAELC,IAAAA,KAFK;AAGLC,IAAAA,KAAK,EAAE;AAAEC,MAAAA,QAAQ,EAAED;AAAZ;AAHF,MAIFN,YAJJ,CADG,CAMH;AACA;;AACA,QAAMQ,OAAO,GAAGR,YAAY,CAACQ,OAAb,CAAqBC,GAArB,IAA4B,EAA5C;AACA,QAAMC,MAAM,GAAG,sBAAS,MAAM,mBAAOF,OAAP,CAAf,EAAiC,CAAEA,OAAF,CAAjC,CAAf;AACA,QAAM;AAAEG,IAAAA;AAAF,MAA0B,uBAAaC,cAAb,CAAhC;AAEA,QAAMC,OAAO,GAAG,0BAAa,MAAM;AAClCZ,IAAAA,aAAa,CAAE;AAAEG,MAAAA,IAAF;AAAQC,MAAAA,KAAR;AAAeS,MAAAA,IAAI,EAAEC;AAArB,KAAF,CAAb;AACAJ,IAAAA,mB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AGC,IAAA,OAAO,EAAGC,OAHX;AAIC,IAAA,SAAS,EAAGC,SAJb;AAKC,IAAA,IAAI,EAAGW,IALR;AAMC,IAAA,YAAY,EAAGY;AANhB,IALD,CADD;AAgBA","sourcesContent":["/**\n * External dependencies\n */\nimport { groupBy, deburr, flatten } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { parse } from '@wordpress/blocks';\nimport { useMemo, useCallback } from '@wordpress/element';\nimport { ENTER, SPACE } from '@wordpress/keycodes';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { BlockPreview } from '@wordpress/block-editor';\nimport {\n\t__unstableComposite as Composite,\n\t__unstableCompositeItem as CompositeItem,\n\tIcon,\n\t__unstableUseCompositeState as useCompositeState,\n} from '@wordpress/components';\nimport { useAsyncList } from '@wordpress/compose';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { createTemplatePartId } from '../utils/create-template-part-id';\n\nfunction getAreaGroupTitle( areaLabel ) {\n\treturn sprintf(\n\t\t// Translators: %s for the area the template part is assigned to (Header, Footer, General, etc.)\n\t\t__( 'Area: %s' ),\n\t\tareaLabel\n\t);\n}\nfunction PreviewPlaceholder() {\n\treturn (\n\t\t<div\n\t\t\tclassName=\"wp-block-template-part__selection-preview-item is-placeholder\"\n\t\t\ttabIndex={ 0 }\n\t\t/>\n\t);\n}\n\nfunction TemplatePartItem( {\n\ttemplatePart,\n\tsetAttributes,\n\tonClose,\n\tcomposite,\n} ) {\n\tconst {\n\t\tslug,\n\t\ttheme,\n\t\ttitle: { rendered: title },\n\t} = templatePart;\n\t// The 'raw' property is not defined for a brief period in the save cycle.\n\t// The fallback prevents an error in the parse function while saving.\n\tconst content = templatePart.content.raw || '';\n\tconst blocks = useMemo( () => parse( content ), [ content ] );\n\tconst { createSuccessNotice } = useDispatch( noticesStore );\n\n\tconst onClick = useCallback( () => {\n\t\tsetAttributes( { slug, theme, area: undefined } );\n\t\tcreateSuccessNotice(\n\t\t\tsprintf(\n\t\t\t\t/* translators: %s: template part title. */\n\t\t\t\t__( 'Template Part \"%s\" inserted.' ),\n\t\t\t\ttitle || slug\n\t\t\t),\n\t\t\t{\n\t\t\t\ttype: 'snackbar',\n\t\t\t}\n\t\t);\n\t\tonClose();\n\t}, [ slug, theme ] );\n\n\treturn (\n\t\t<CompositeItem\n\t\t\tas=\"div\"\n\t\t\tclassName=\"wp-block-template-part__selection-preview-item\"\n\t\t\trole=\"option\"\n\t\t\tonClick={ onClick }\n\t\t\tonKeyDown={ ( event ) => {\n\t\t\t\tif ( ENTER === event.keyCode || SPACE === event.keyCode ) {\n\t\t\t\t\tonClick();\n\t\t\t\t}\n\t\t\t} }\n\t\t\ttabIndex={ 0 }\n\t\t\taria-label={ title || slug }\n\t\t\t{ ...composite }\n\t\t>\n\t\t\t<BlockPreview blocks={ blocks } />\n\t\t\t<div className=\"wp-block-template-part__selection-preview-item-title\">\n\t\t\t\t{ title || slug }\n\t\t\t</div>\n\t\t</CompositeItem>\n\t);\n}\n\nfunction PanelGroup( { title, icon, children } ) {\n\treturn (\n\t\t<>\n\t\t\t<div className=\"wp-block-template-part__selection-panel-group-header\">\n\t\t\t\t<span className=\"wp-block-template-part__selection-panel-group-title\">\n\t\t\t\t\t{ title }\n\t\t\t\t</span>\n\t\t\t\t<Icon icon={ icon } />\n\t\t\t</div>\n\t\t\t<div className=\"wp-block-template-part__selection-panel-group-content\">\n\t\t\t\t{ children }\n\t\t\t</div>\n\t\t</>\n\t);\n}\n\nfunction TemplatePartsByArea( {\n\ttemplateParts,\n\tsetAttributes,\n\tonClose,\n\tcomposite,\n\tarea = 'uncategorized',\n\tlabelsByArea,\n} ) {\n\tconst { templatePartsByArea, templatePartsToShow } = useMemo( () => {\n\t\tconst _templatePartsToShow =\n\t\t\ttemplateParts.filter(\n\t\t\t\t( templatePart ) =>\n\t\t\t\t\t'uncategorized' === area || templatePart.area === area\n\t\t\t) || [];\n\t\tconst _templatePartsByArea = Object.values(\n\t\t\tgroupBy( _templatePartsToShow, 'area' )\n\t\t);\n\t\tconst orderedTemplatePartsToShow = flatten( _templatePartsToShow );\n\t\treturn {\n\t\t\ttemplatePartsByArea: _templatePartsByArea,\n\t\t\ttemplatePartsToShow: orderedTemplatePartsToShow,\n\t\t};\n\t}, [ templateParts, area ] );\n\n\tconst currentShownTPs = useAsyncList( templatePartsToShow );\n\n\tif ( ! templatePartsToShow.length ) {\n\t\treturn (\n\t\t\t<PanelGroup\n\t\t\t\ttitle={ getAreaGroupTitle(\n\t\t\t\t\tlabelsByArea[ area ] || labelsByArea.uncategorized\n\t\t\t\t) }\n\t\t\t>\n\t\t\t\t{ sprintf(\n\t\t\t\t\t// Translators: %s for the template part variation (\"Header\", \"Footer\", \"Template Part\").\n\t\t\t\t\t__(\n\t\t\t\t\t\t'There is no other %s available. If you are looking for another type of template part, try searching for it using the input above.'\n\t\t\t\t\t),\n\t\t\t\t\tarea && area !== 'uncategorized'\n\t\t\t\t\t\t? labelsByArea[ area ] || area\n\t\t\t\t\t\t: __( 'Template Part' )\n\t\t\t\t) }\n\t\t\t</PanelGroup>\n\t\t);\n\t}\n\n\treturn templatePartsByArea.map( ( templatePartList ) => {\n\t\treturn (\n\t\t\t<PanelGroup\n\t\t\t\tkey={ templatePartList[ 0 ].area }\n\t\t\t\ttitle={ getAreaGroupTitle(\n\t\t\t\t\tlabelsByArea[ templatePartList[ 0 ].area ] ||\n\t\t\t\t\t\tlabelsByArea.uncategorized\n\t\t\t\t) }\n\t\t\t>\n\t\t\t\t{ templatePartList.map( ( templatePart ) => {\n\t\t\t\t\treturn currentShownTPs.includes( templatePart ) ? (\n\t\t\t\t\t\t<TemplatePartItem\n\t\t\t\t\t\t\tkey={ templatePart.id }\n\t\t\t\t\t\t\ttemplatePart={ templatePart }\n\t\t\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\t\t\tonClose={ onClose }\n\t\t\t\t\t\t\tcomposite={ composite }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) : (\n\t\t\t\t\t\t<PreviewPlaceholder key={ templatePart.id } />\n\t\t\t\t\t);\n\t\t\t\t} ) }\n\t\t\t</PanelGroup>\n\t\t);\n\t} );\n}\n\nfunction TemplatePartSearchResults( {\n\ttemplateParts,\n\tsetAttributes,\n\tfilterValue,\n\tonClose,\n\tcomposite,\n\tlabelsByArea,\n} ) {\n\tconst { filteredTPs, groupedResults } = useMemo( () => {\n\t\t// Filter based on value.\n\t\t// Remove diacritics and convert to lowercase to normalize.\n\t\tconst normalizedFilterValue = deburr( filterValue ).toLowerCase();\n\t\tconst searchResults = templateParts.filter(\n\t\t\t( { title: { rendered: title }, area } ) =>\n\t\t\t\tdeburr( title )\n\t\t\t\t\t.toLowerCase()\n\t\t\t\t\t.includes( normalizedFilterValue ) ||\n\t\t\t\t// Since diacritics can be used in theme names, remove them for the comparison.\n\t\t\t\tdeburr( labelsByArea[ area ] )\n\t\t\t\t\t.toLowerCase()\n\t\t\t\t\t.includes( normalizedFilterValue )\n\t\t);\n\t\t// Order based on value location.\n\t\tsearchResults.sort( ( a, b ) => {\n\t\t\t// First prioritize index found in title.\n\t\t\t// Deburr for diacritics.\n\t\t\tconst indexInTitleA = deburr( a.title.rendered )\n\t\t\t\t.toLowerCase()\n\t\t\t\t.indexOf( normalizedFilterValue );\n\t\t\tconst indexInTitleB = deburr( b.title.rendered )\n\t\t\t\t.toLowerCase()\n\t\t\t\t.indexOf( normalizedFilterValue );\n\t\t\tif ( indexInTitleA !== -1 && indexInTitleB !== -1 ) {\n\t\t\t\treturn indexInTitleA - indexInTitleB;\n\t\t\t} else if ( indexInTitleA !== -1 ) {\n\t\t\t\treturn -1;\n\t\t\t} else if ( indexInTitleB !== -1 ) {\n\t\t\t\treturn 1;\n\t\t\t}\n\t\t\t// Second prioritize index found in area.\n\t\t\treturn (\n\t\t\t\tdeburr( labelsByArea[ a.area ] )\n\t\t\t\t\t.toLowerCase()\n\t\t\t\t\t.indexOf( normalizedFilterValue ) -\n\t\t\t\tdeburr( labelsByArea[ b.area ] )\n\t\t\t\t\t.toLowerCase()\n\t\t\t\t\t.indexOf( normalizedFilterValue )\n\t\t\t);\n\t\t} );\n\t\t// Group filtered results together if their neighbors share the same area.\n\t\t// This helps not show redundant panel groups side by side in the results.\n\t\tconst _groupedResults = [];\n\t\tfor ( let i = 0; i < searchResults.length; i++ ) {\n\t\t\tif (\n\t\t\t\ti !== 0 &&\n\t\t\t\tsearchResults[ i ].area === searchResults[ i - 1 ].area\n\t\t\t) {\n\t\t\t\t_groupedResults[ _groupedResults.length - 1 ].push(\n\t\t\t\t\tsearchResults[ i ]\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\t_groupedResults.push( [ searchResults[ i ] ] );\n\t\t\t}\n\t\t}\n\t\treturn {\n\t\t\tfilteredTPs: searchResults,\n\t\t\tgroupedResults: _groupedResults,\n\t\t};\n\t}, [ filterValue, templateParts ] );\n\n\tconst currentShownTPs = useAsyncList( filteredTPs );\n\n\treturn groupedResults.map( ( group ) => (\n\t\t<PanelGroup\n\t\t\tkey={ group[ 0 ].id }\n\t\t\ttitle={ getAreaGroupTitle(\n\t\t\t\tlabelsByArea[ group[ 0 ].area ] || labelsByArea.uncategorized\n\t\t\t) }\n\t\t>\n\t\t\t{ group.map( ( templatePart ) =>\n\t\t\t\tcurrentShownTPs.includes( templatePart ) ? (\n\t\t\t\t\t<TemplatePartItem\n\t\t\t\t\t\tkey={ templatePart.id }\n\t\t\t\t\t\ttemplatePart={ templatePart }\n\t\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\t\tonClose={ onClose }\n\t\t\t\t\t\tcomposite={ composite }\n\t\t\t\t\t/>\n\t\t\t\t) : (\n\t\t\t\t\t<PreviewPlaceholder key={ templatePart.id } />\n\t\t\t\t)\n\t\t\t) }\n\t\t</PanelGroup>\n\t) );\n}\n\nexport default function TemplatePartPreviews( {\n\tsetAttributes,\n\tfilterValue,\n\tonClose,\n\tarea,\n\ttemplatePartId,\n} ) {\n\tconst composite = useCompositeState();\n\n\tconst { templateParts, labelsByArea } = useSelect( ( select ) => {\n\t\tconst _templateParts = (\n\t\t\tselect( coreStore ).getEntityRecords(\n\t\t\t\t'postType',\n\t\t\t\t'wp_template_part',\n\t\t\t\t{\n\t\t\t\t\tper_page: -1,\n\t\t\t\t}\n\t\t\t) || []\n\t\t).filter(\n\t\t\t( templatePart ) =>\n\t\t\t\tcreateTemplatePartId(\n\t\t\t\t\ttemplatePart.theme,\n\t\t\t\t\ttemplatePart.slug\n\t\t\t\t) !== templatePartId\n\t\t);\n\n\t\t// FIXME: @wordpress/block-library should not depend on @wordpress/editor.\n\t\t// Blocks can be loaded into a *non-post* block editor.\n\t\t// eslint-disable-next-line @wordpress/data-no-store-string-literals\n\t\tconst definedAreas = select(\n\t\t\t'core/editor'\n\t\t).__experimentalGetDefaultTemplatePartAreas();\n\t\tconst _labelsByArea = {};\n\t\tdefinedAreas.forEach( ( item ) => {\n\t\t\t_labelsByArea[ item.area ] = item.label;\n\t\t} );\n\n\t\treturn {\n\t\t\ttemplateParts: _templateParts,\n\t\t\tlabelsByArea: _labelsByArea,\n\t\t};\n\t}, [] );\n\n\tif ( ! templateParts || ! templateParts.length ) {\n\t\treturn (\n\t\t\t<PanelGroup>\n\t\t\t\t{ __( 'There are no existing template parts to select.' ) }\n\t\t\t</PanelGroup>\n\t\t);\n\t}\n\n\tif ( filterValue ) {\n\t\treturn (\n\t\t\t<Composite\n\t\t\t\t{ ...composite }\n\t\t\t\trole=\"listbox\"\n\t\t\t\taria-label={ __( 'List of template parts' ) }\n\t\t\t>\n\t\t\t\t<TemplatePartSearchResults\n\t\t\t\t\ttemplateParts={ templateParts }\n\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\tfilterValue={ filterValue }\n\t\t\t\t\tonClose={ onClose }\n\t\t\t\t\tcomposite={ composite }\n\t\t\t\t\tlabelsByArea={ labelsByArea }\n\t\t\t\t/>\n\t\t\t</Composite>\n\t\t);\n\t}\n\n\treturn (\n\t\t<Composite\n\t\t\t{ ...composite }\n\t\t\trole=\"listbox\"\n\t\t\taria-label={ __( 'List of template parts' ) }\n\t\t>\n\t\t\t<TemplatePartsByArea\n\t\t\t\ttemplateParts={ templateParts }\n\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\tonClose={ onClose }\n\t\t\t\tcomposite={ composite }\n\t\t\t\tarea={ area }\n\t\t\t\tlabelsByArea={ labelsByArea }\n\t\t\t/>\n\t\t</Composite>\n\t);\n}\n"]}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { createElement, Fragment } from "@wordpress/element";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* WordPress dependencies
|
|
5
|
-
*/
|
|
6
|
-
import { MenuGroup, MenuItem } from '@wordpress/components';
|
|
7
|
-
import { __, sprintf } from '@wordpress/i18n';
|
|
8
|
-
import { decodeEntities } from '@wordpress/html-entities';
|
|
9
|
-
|
|
10
|
-
const ExistingMenusOptions = _ref => {
|
|
11
|
-
let {
|
|
12
|
-
showNavigationMenus,
|
|
13
|
-
showClassicMenus = false,
|
|
14
|
-
navigationMenus,
|
|
15
|
-
classicMenus,
|
|
16
|
-
onSelectNavigationMenu,
|
|
17
|
-
onSelectClassicMenu,
|
|
18
|
-
actionLabel
|
|
19
|
-
} = _ref;
|
|
20
|
-
const hasNavigationMenus = !!(navigationMenus !== null && navigationMenus !== void 0 && navigationMenus.length);
|
|
21
|
-
const hasClassicMenus = !!(classicMenus !== null && classicMenus !== void 0 && classicMenus.length);
|
|
22
|
-
/* translators: %s: The name of a menu. */
|
|
23
|
-
|
|
24
|
-
const createActionLabel = __("Create from '%s'");
|
|
25
|
-
|
|
26
|
-
actionLabel = actionLabel || createActionLabel;
|
|
27
|
-
return createElement(Fragment, null, showNavigationMenus && hasNavigationMenus && createElement(MenuGroup, {
|
|
28
|
-
label: __('Menus')
|
|
29
|
-
}, navigationMenus.map(menu => {
|
|
30
|
-
const label = decodeEntities(menu.title.rendered);
|
|
31
|
-
return createElement(MenuItem, {
|
|
32
|
-
onClick: () => {
|
|
33
|
-
onSelectNavigationMenu(menu);
|
|
34
|
-
},
|
|
35
|
-
key: menu.id,
|
|
36
|
-
"aria-label": sprintf(actionLabel, label)
|
|
37
|
-
}, label);
|
|
38
|
-
})), showClassicMenus && hasClassicMenus && createElement(MenuGroup, {
|
|
39
|
-
label: __('Classic Menus')
|
|
40
|
-
}, classicMenus.map(menu => {
|
|
41
|
-
const label = decodeEntities(menu.name);
|
|
42
|
-
return createElement(MenuItem, {
|
|
43
|
-
onClick: () => {
|
|
44
|
-
onSelectClassicMenu(menu);
|
|
45
|
-
},
|
|
46
|
-
key: menu.id,
|
|
47
|
-
"aria-label": sprintf(createActionLabel, label)
|
|
48
|
-
}, label);
|
|
49
|
-
})));
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
export default ExistingMenusOptions;
|
|
53
|
-
//# sourceMappingURL=existing-menus-options.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/navigation/edit/existing-menus-options.js"],"names":["MenuGroup","MenuItem","__","sprintf","decodeEntities","ExistingMenusOptions","showNavigationMenus","showClassicMenus","navigationMenus","classicMenus","onSelectNavigationMenu","onSelectClassicMenu","actionLabel","hasNavigationMenus","length","hasClassicMenus","createActionLabel","map","menu","label","title","rendered","id","name"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,SAAT,EAAoBC,QAApB,QAAoC,uBAApC;AACA,SAASC,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SAASC,cAAT,QAA+B,0BAA/B;;AAEA,MAAMC,oBAAoB,GAAG,QAQtB;AAAA,MARwB;AAC9BC,IAAAA,mBAD8B;AAE9BC,IAAAA,gBAAgB,GAAG,KAFW;AAG9BC,IAAAA,eAH8B;AAI9BC,IAAAA,YAJ8B;AAK9BC,IAAAA,sBAL8B;AAM9BC,IA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GA,KAVH,CADD;AAcA,GAhBC,CADH,CApBF,CADD;AA2CA,CA5DD;;AA8DA,eAAed,oBAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { MenuGroup, MenuItem } from '@wordpress/components';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { decodeEntities } from '@wordpress/html-entities';\n\nconst ExistingMenusOptions = ( {\n\tshowNavigationMenus,\n\tshowClassicMenus = false,\n\tnavigationMenus,\n\tclassicMenus,\n\tonSelectNavigationMenu,\n\tonSelectClassicMenu,\n\tactionLabel,\n} ) => {\n\tconst hasNavigationMenus = !! navigationMenus?.length;\n\tconst hasClassicMenus = !! classicMenus?.length;\n\n\t/* translators: %s: The name of a menu. */\n\tconst createActionLabel = __( \"Create from '%s'\" );\n\n\tactionLabel = actionLabel || createActionLabel;\n\n\treturn (\n\t\t<>\n\t\t\t{ showNavigationMenus && hasNavigationMenus && (\n\t\t\t\t<MenuGroup label={ __( 'Menus' ) }>\n\t\t\t\t\t{ navigationMenus.map( ( menu ) => {\n\t\t\t\t\t\tconst label = decodeEntities( menu.title.rendered );\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\tonSelectNavigationMenu( menu );\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\tkey={ menu.id }\n\t\t\t\t\t\t\t\taria-label={ sprintf( actionLabel, label ) }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ label }\n\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t);\n\t\t\t\t\t} ) }\n\t\t\t\t</MenuGroup>\n\t\t\t) }\n\t\t\t{ showClassicMenus && hasClassicMenus && (\n\t\t\t\t<MenuGroup label={ __( 'Classic Menus' ) }>\n\t\t\t\t\t{ classicMenus.map( ( menu ) => {\n\t\t\t\t\t\tconst label = decodeEntities( menu.name );\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\tonSelectClassicMenu( menu );\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\tkey={ menu.id }\n\t\t\t\t\t\t\t\taria-label={ sprintf(\n\t\t\t\t\t\t\t\t\tcreateActionLabel,\n\t\t\t\t\t\t\t\t\tlabel\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ label }\n\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t);\n\t\t\t\t\t} ) }\n\t\t\t\t</MenuGroup>\n\t\t\t) }\n\t\t</>\n\t);\n};\n\nexport default ExistingMenusOptions;\n"]}
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
import { createElement, Fragment } from "@wordpress/element";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* External dependencies
|
|
5
|
-
*/
|
|
6
|
-
import { find, kebabCase } from 'lodash';
|
|
7
|
-
/**
|
|
8
|
-
* WordPress dependencies
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import { __, sprintf } from '@wordpress/i18n';
|
|
12
|
-
import { useCallback, useState } from '@wordpress/element';
|
|
13
|
-
import { useDispatch, useSelect } from '@wordpress/data';
|
|
14
|
-
import { Placeholder, Dropdown, Button, Spinner } from '@wordpress/components';
|
|
15
|
-
import { serialize } from '@wordpress/blocks';
|
|
16
|
-
import { store as coreStore } from '@wordpress/core-data';
|
|
17
|
-
/**
|
|
18
|
-
* Internal dependencies
|
|
19
|
-
*/
|
|
20
|
-
|
|
21
|
-
import TemplatePartSelection from '../selection';
|
|
22
|
-
import PatternsSetup from './patterns-setup';
|
|
23
|
-
const PLACEHOLDER_STEPS = {
|
|
24
|
-
initial: 1,
|
|
25
|
-
patterns: 2
|
|
26
|
-
};
|
|
27
|
-
export default function TemplatePartPlaceholder(_ref) {
|
|
28
|
-
let {
|
|
29
|
-
area,
|
|
30
|
-
clientId,
|
|
31
|
-
setAttributes,
|
|
32
|
-
enableSelection,
|
|
33
|
-
hasResolvedReplacements
|
|
34
|
-
} = _ref;
|
|
35
|
-
const {
|
|
36
|
-
saveEntityRecord
|
|
37
|
-
} = useDispatch(coreStore);
|
|
38
|
-
const [step, setStep] = useState(PLACEHOLDER_STEPS.initial);
|
|
39
|
-
const {
|
|
40
|
-
areaIcon,
|
|
41
|
-
areaLabel
|
|
42
|
-
} = useSelect(select => {
|
|
43
|
-
// FIXME: @wordpress/block-library should not depend on @wordpress/editor.
|
|
44
|
-
// Blocks can be loaded into a *non-post* block editor.
|
|
45
|
-
// eslint-disable-next-line @wordpress/data-no-store-string-literals
|
|
46
|
-
const definedAreas = select('core/editor').__experimentalGetDefaultTemplatePartAreas();
|
|
47
|
-
|
|
48
|
-
const selectedArea = find(definedAreas, {
|
|
49
|
-
area
|
|
50
|
-
});
|
|
51
|
-
const defaultArea = find(definedAreas, {
|
|
52
|
-
area: 'uncategorized'
|
|
53
|
-
});
|
|
54
|
-
return {
|
|
55
|
-
areaIcon: (selectedArea === null || selectedArea === void 0 ? void 0 : selectedArea.icon) || (defaultArea === null || defaultArea === void 0 ? void 0 : defaultArea.icon),
|
|
56
|
-
areaLabel: (selectedArea === null || selectedArea === void 0 ? void 0 : selectedArea.label) || __('Template Part')
|
|
57
|
-
};
|
|
58
|
-
}, [area]);
|
|
59
|
-
const onCreate = useCallback(async function () {
|
|
60
|
-
let startingBlocks = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
61
|
-
let title = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : __('Untitled Template Part');
|
|
62
|
-
// If we have `area` set from block attributes, means an exposed
|
|
63
|
-
// block variation was inserted. So add this prop to the template
|
|
64
|
-
// part entity on creation. Afterwards remove `area` value from
|
|
65
|
-
// block attributes.
|
|
66
|
-
const record = {
|
|
67
|
-
title,
|
|
68
|
-
slug: kebabCase(title),
|
|
69
|
-
content: serialize(startingBlocks),
|
|
70
|
-
// `area` is filterable on the server and defaults to `UNCATEGORIZED`
|
|
71
|
-
// if provided value is not allowed.
|
|
72
|
-
area
|
|
73
|
-
};
|
|
74
|
-
const templatePart = await saveEntityRecord('postType', 'wp_template_part', record);
|
|
75
|
-
setAttributes({
|
|
76
|
-
slug: templatePart.slug,
|
|
77
|
-
theme: templatePart.theme,
|
|
78
|
-
area: undefined
|
|
79
|
-
});
|
|
80
|
-
}, [setAttributes, area]);
|
|
81
|
-
return createElement(Fragment, null, step === PLACEHOLDER_STEPS.initial && createElement(Placeholder, {
|
|
82
|
-
icon: areaIcon,
|
|
83
|
-
label: areaLabel,
|
|
84
|
-
instructions: enableSelection ? sprintf( // Translators: %s as template part area title ("Header", "Footer", etc.).
|
|
85
|
-
__('Choose an existing %s or create a new one.'), areaLabel.toLowerCase()) : sprintf( // Translators: %s as template part area title ("Header", "Footer", etc.).
|
|
86
|
-
__('Create a new %s.'), areaLabel.toLowerCase())
|
|
87
|
-
}, !hasResolvedReplacements ? createElement(Spinner, null) : createElement(Dropdown, {
|
|
88
|
-
contentClassName: "wp-block-template-part__placeholder-preview-dropdown-content",
|
|
89
|
-
position: "bottom right left",
|
|
90
|
-
renderToggle: _ref2 => {
|
|
91
|
-
let {
|
|
92
|
-
isOpen,
|
|
93
|
-
onToggle
|
|
94
|
-
} = _ref2;
|
|
95
|
-
return createElement(Fragment, null, enableSelection && createElement(Button, {
|
|
96
|
-
variant: "primary",
|
|
97
|
-
onClick: onToggle,
|
|
98
|
-
"aria-expanded": isOpen
|
|
99
|
-
}, __('Choose existing')), createElement(Button, {
|
|
100
|
-
variant: enableSelection ? 'tertiary' : 'primary',
|
|
101
|
-
onClick: () => setStep(PLACEHOLDER_STEPS.patterns)
|
|
102
|
-
}, sprintf( // Translators: %s as template part area title ("Header", "Footer", etc.).
|
|
103
|
-
__('New %s'), areaLabel.toLowerCase())));
|
|
104
|
-
},
|
|
105
|
-
renderContent: _ref3 => {
|
|
106
|
-
let {
|
|
107
|
-
onClose
|
|
108
|
-
} = _ref3;
|
|
109
|
-
return createElement(TemplatePartSelection, {
|
|
110
|
-
setAttributes: setAttributes,
|
|
111
|
-
onClose: onClose,
|
|
112
|
-
area: area
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
})), step === PLACEHOLDER_STEPS.patterns && createElement(PatternsSetup, {
|
|
116
|
-
area: area,
|
|
117
|
-
areaLabel: areaLabel,
|
|
118
|
-
areaIcon: areaIcon,
|
|
119
|
-
onCreate: onCreate,
|
|
120
|
-
clientId: clientId,
|
|
121
|
-
resetPlaceholder: () => setStep(PLACEHOLDER_STEPS.initial)
|
|
122
|
-
}));
|
|
123
|
-
}
|
|
124
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/template-part/edit/placeholder/index.js"],"names":["find","kebabCase","__","sprintf","useCallback","useState","useDispatch","useSelect","Placeholder","Dropdown","Button","Spinner","serialize","store","coreStore","TemplatePartSelection","PatternsSetup","PLACEHOLDER_STEPS","initial","patterns","TemplatePartPlaceholder","area","clientId","setAttributes","enableSelection","hasResolvedReplacements","saveEntityRecord","step","setStep","areaIcon","areaLabel","select","definedAreas","__experimentalGetDefaultTemplatePartAreas","selectedArea","defaultArea","icon","label","onCreate","startingBlocks","title","record","slug","content","templatePart","theme","undefined","toLowerCase","isOpen","onToggle","onClose"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,IAAT,EAAeC,SAAf,QAAgC,QAAhC;AAEA;AACA;AACA;;AACA,SAASC,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SAASC,WAAT,EAAsBC,QAAtB,QAAsC,oBAAtC;AACA,SAASC,WAAT,EAAsBC,SAAtB,QAAuC,iBAAvC;AACA,SAASC,WAAT,EAAsBC,QAAtB,EAAgCC,MAAhC,EAAwCC,OAAxC,QAAuD,uBAAvD;AACA,SAASC,SAAT,QAA0B,mBAA1B;AACA,SAASC,KAAK,IAAIC,SAAlB,QAAmC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AAUC,QAAAA;AAAV,OAAF;AAAA,aACd,8BACGzB,eAAe,IAChB,cAAC,MAAD;AACC,QAAA,OAAO,EAAC,SADT;AAEC,QAAA,OAAO,EAAGyB,QAFX;AAGC,yBAAgBD;AAHjB,SAKG9C,EAAE,CAAE,iBAAF,CALL,CAFF,EAUC,cAAC,MAAD;AACC,QAAA,OAAO,EACNsB,eAAe,GACZ,UADY,GAEZ,SAJL;AAMC,QAAA,OAAO,EAAG,MACTI,OAAO,CACNX,iBAAiB,CAACE,QADZ;AAPT,SAYGhB,OAAO,EACR;AACAD,MAAAA,EAAE,CAAE,QAAF,CAFM,EAGR4B,SAAS,CAACiB,WAAV,EAHQ,CAZV,CAVD,CADc;AAAA,KAHhB;AAkCC,IAAA,aAAa,EAAG;AAAA,UAAE;AAAEG,QAAAA;AAAF,OAAF;AAAA,aACf,cAAC,qBAAD;AACC,QAAA,aAAa,EAAG3B,aADjB;AAEC,QAAA,OAAO,EAAG2B,OAFX;AAGC,QAAA,IAAI,EAAG7B;AAHR,QADe;AAAA;AAlCjB,IAtBF,CAFF,EAqEGM,IAAI,KAAKV,iBAAiB,CAACE,QAA3B,IACD,cAAC,aAAD;AACC,IAAA,IAAI,EAAGE,IADR;AAEC,IAAA,SAAS,EAAGS,SAFb;AAGC,IAAA,QAAQ,EAAGD,QAHZ;AAIC,IAAA,QAAQ,EAAGS,QAJZ;AAKC,IAAA,QAAQ,EAAGhB,QALZ;AAMC,IAAA,gBAAgB,EAAG,MAClBM,OAAO,CAAEX,iBAAiB,CAACC,OAApB;AAPT,IAtEF,CADD;AAoFA","sourcesContent":["/**\n * External dependencies\n */\nimport { find, kebabCase } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useCallback, useState } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { Placeholder, Dropdown, Button, Spinner } from '@wordpress/components';\nimport { serialize } from '@wordpress/blocks';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport TemplatePartSelection from '../selection';\nimport PatternsSetup from './patterns-setup';\n\nconst PLACEHOLDER_STEPS = {\n\tinitial: 1,\n\tpatterns: 2,\n};\n\nexport default function TemplatePartPlaceholder( {\n\tarea,\n\tclientId,\n\tsetAttributes,\n\tenableSelection,\n\thasResolvedReplacements,\n} ) {\n\tconst { saveEntityRecord } = useDispatch( coreStore );\n\tconst [ step, setStep ] = useState( PLACEHOLDER_STEPS.initial );\n\n\tconst { areaIcon, areaLabel } = useSelect(\n\t\t( select ) => {\n\t\t\t// FIXME: @wordpress/block-library should not depend on @wordpress/editor.\n\t\t\t// Blocks can be loaded into a *non-post* block editor.\n\t\t\t// eslint-disable-next-line @wordpress/data-no-store-string-literals\n\t\t\tconst definedAreas = select(\n\t\t\t\t'core/editor'\n\t\t\t).__experimentalGetDefaultTemplatePartAreas();\n\n\t\t\tconst selectedArea = find( definedAreas, { area } );\n\t\t\tconst defaultArea = find( definedAreas, { area: 'uncategorized' } );\n\n\t\t\treturn {\n\t\t\t\tareaIcon: selectedArea?.icon || defaultArea?.icon,\n\t\t\t\tareaLabel: selectedArea?.label || __( 'Template Part' ),\n\t\t\t};\n\t\t},\n\t\t[ area ]\n\t);\n\n\tconst onCreate = useCallback(\n\t\tasync (\n\t\t\tstartingBlocks = [],\n\t\t\ttitle = __( 'Untitled Template Part' )\n\t\t) => {\n\t\t\t// If we have `area` set from block attributes, means an exposed\n\t\t\t// block variation was inserted. So add this prop to the template\n\t\t\t// part entity on creation. Afterwards remove `area` value from\n\t\t\t// block attributes.\n\t\t\tconst record = {\n\t\t\t\ttitle,\n\t\t\t\tslug: kebabCase( title ),\n\t\t\t\tcontent: serialize( startingBlocks ),\n\t\t\t\t// `area` is filterable on the server and defaults to `UNCATEGORIZED`\n\t\t\t\t// if provided value is not allowed.\n\t\t\t\tarea,\n\t\t\t};\n\t\t\tconst templatePart = await saveEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\t'wp_template_part',\n\t\t\t\trecord\n\t\t\t);\n\t\t\tsetAttributes( {\n\t\t\t\tslug: templatePart.slug,\n\t\t\t\ttheme: templatePart.theme,\n\t\t\t\tarea: undefined,\n\t\t\t} );\n\t\t},\n\t\t[ setAttributes, area ]\n\t);\n\n\treturn (\n\t\t<>\n\t\t\t{ step === PLACEHOLDER_STEPS.initial && (\n\t\t\t\t<Placeholder\n\t\t\t\t\ticon={ areaIcon }\n\t\t\t\t\tlabel={ areaLabel }\n\t\t\t\t\tinstructions={\n\t\t\t\t\t\tenableSelection\n\t\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t\t// Translators: %s as template part area title (\"Header\", \"Footer\", etc.).\n\t\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t\t'Choose an existing %s or create a new one.'\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\tareaLabel.toLowerCase()\n\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t\t\t// Translators: %s as template part area title (\"Header\", \"Footer\", etc.).\n\t\t\t\t\t\t\t\t\t__( 'Create a new %s.' ),\n\t\t\t\t\t\t\t\t\tareaLabel.toLowerCase()\n\t\t\t\t\t\t\t )\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t\t\t{ ! hasResolvedReplacements ? (\n\t\t\t\t\t\t<Spinner />\n\t\t\t\t\t) : (\n\t\t\t\t\t\t<Dropdown\n\t\t\t\t\t\t\tcontentClassName=\"wp-block-template-part__placeholder-preview-dropdown-content\"\n\t\t\t\t\t\t\tposition=\"bottom right left\"\n\t\t\t\t\t\t\trenderToggle={ ( { isOpen, onToggle } ) => (\n\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t{ enableSelection && (\n\t\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\t\t\t\t\tonClick={ onToggle }\n\t\t\t\t\t\t\t\t\t\t\taria-expanded={ isOpen }\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t{ __( 'Choose existing' ) }\n\t\t\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\tvariant={\n\t\t\t\t\t\t\t\t\t\t\tenableSelection\n\t\t\t\t\t\t\t\t\t\t\t\t? 'tertiary'\n\t\t\t\t\t\t\t\t\t\t\t\t: 'primary'\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\t\t\t\t\t\tsetStep(\n\t\t\t\t\t\t\t\t\t\t\t\tPLACEHOLDER_STEPS.patterns\n\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ sprintf(\n\t\t\t\t\t\t\t\t\t\t\t// Translators: %s as template part area title (\"Header\", \"Footer\", etc.).\n\t\t\t\t\t\t\t\t\t\t\t__( 'New %s' ),\n\t\t\t\t\t\t\t\t\t\t\tareaLabel.toLowerCase()\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\trenderContent={ ( { onClose } ) => (\n\t\t\t\t\t\t\t\t<TemplatePartSelection\n\t\t\t\t\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\t\t\t\t\tonClose={ onClose }\n\t\t\t\t\t\t\t\t\tarea={ area }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</Placeholder>\n\t\t\t) }\n\t\t\t{ step === PLACEHOLDER_STEPS.patterns && (\n\t\t\t\t<PatternsSetup\n\t\t\t\t\tarea={ area }\n\t\t\t\t\tareaLabel={ areaLabel }\n\t\t\t\t\tareaIcon={ areaIcon }\n\t\t\t\t\tonCreate={ onCreate }\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\tresetPlaceholder={ () =>\n\t\t\t\t\t\tsetStep( PLACEHOLDER_STEPS.initial )\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n"]}
|