@wordpress/edit-site 6.4.0 → 6.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/build/components/add-new-pattern/index.js +6 -1
- package/build/components/add-new-pattern/index.js.map +1 -1
- package/build/components/add-new-post/index.js +2 -1
- package/build/components/add-new-post/index.js.map +1 -1
- package/build/components/add-new-template/utils.js +2 -2
- package/build/components/add-new-template/utils.js.map +1 -1
- package/build/components/editor/index.js +71 -20
- package/build/components/editor/index.js.map +1 -1
- package/build/components/global-styles/font-families.js +3 -4
- package/build/components/global-styles/font-families.js.map +1 -1
- package/build/components/global-styles/font-library-modal/context.js +0 -5
- package/build/components/global-styles/font-library-modal/context.js.map +1 -1
- package/build/components/global-styles/font-library-modal/font-collection.js +25 -5
- package/build/components/global-styles/font-library-modal/font-collection.js.map +1 -1
- package/build/components/global-styles/font-library-modal/index.js +1 -8
- package/build/components/global-styles/font-library-modal/index.js.map +1 -1
- package/build/components/global-styles/font-library-modal/installed-fonts.js +21 -6
- package/build/components/global-styles/font-library-modal/installed-fonts.js.map +1 -1
- package/build/components/global-styles/font-library-modal/upload-fonts.js +2 -3
- package/build/components/global-styles/font-library-modal/upload-fonts.js.map +1 -1
- package/build/components/global-styles/screen-typeset.js +40 -0
- package/build/components/global-styles/screen-typeset.js.map +1 -0
- package/build/components/global-styles/screen-typography-element.js +14 -0
- package/build/components/global-styles/screen-typography-element.js.map +1 -1
- package/build/components/global-styles/screen-typography.js +4 -6
- package/build/components/global-styles/screen-typography.js.map +1 -1
- package/build/components/global-styles/shadows-edit-panel.js +50 -59
- package/build/components/global-styles/shadows-edit-panel.js.map +1 -1
- package/build/components/global-styles/typeset-button.js +97 -0
- package/build/components/global-styles/typeset-button.js.map +1 -0
- package/build/components/global-styles/typeset.js +80 -0
- package/build/components/global-styles/typeset.js.map +1 -0
- package/build/components/global-styles/ui.js +4 -0
- package/build/components/global-styles/ui.js.map +1 -1
- package/build/components/global-styles/utils.js +10 -1
- package/build/components/global-styles/utils.js.map +1 -1
- package/build/components/page-patterns/fields.js +230 -0
- package/build/components/page-patterns/fields.js.map +1 -0
- package/build/components/page-patterns/index.js +8 -226
- package/build/components/page-patterns/index.js.map +1 -1
- package/build/components/page-patterns/use-patterns.js +26 -1
- package/build/components/page-patterns/use-patterns.js.map +1 -1
- package/build/components/page-templates/fields.js +169 -0
- package/build/components/page-templates/fields.js.map +1 -0
- package/build/components/page-templates/index.js +10 -177
- package/build/components/page-templates/index.js.map +1 -1
- package/build/components/post-edit/index.js +18 -6
- package/build/components/post-edit/index.js.map +1 -1
- package/build/components/post-fields/index.js +19 -15
- package/build/components/post-fields/index.js.map +1 -1
- package/build/components/post-list/index.js +125 -67
- package/build/components/post-list/index.js.map +1 -1
- package/build/components/sidebar-dataviews/add-new-view.js +2 -2
- package/build/components/sidebar-dataviews/add-new-view.js.map +1 -1
- package/build/components/sidebar-dataviews/dataview-item.js +2 -3
- package/build/components/sidebar-dataviews/dataview-item.js.map +1 -1
- package/build/components/sidebar-dataviews/default-views.js +81 -81
- package/build/components/sidebar-dataviews/default-views.js.map +1 -1
- package/build/components/sidebar-dataviews/index.js +3 -42
- package/build/components/sidebar-dataviews/index.js.map +1 -1
- package/build/components/site-hub/index.js +6 -3
- package/build/components/site-hub/index.js.map +1 -1
- package/build/components/style-book/index.js +22 -25
- package/build/components/style-book/index.js.map +1 -1
- package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js +5 -0
- package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
- package/build/hooks/push-changes-to-global-styles/index.js +2 -3
- package/build/hooks/push-changes-to-global-styles/index.js.map +1 -1
- package/build/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js +2 -4
- package/build/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js.map +1 -1
- package/build/index.js +0 -2
- package/build/index.js.map +1 -1
- package/build-module/components/add-new-pattern/index.js +6 -1
- package/build-module/components/add-new-pattern/index.js.map +1 -1
- package/build-module/components/add-new-post/index.js +2 -1
- package/build-module/components/add-new-post/index.js.map +1 -1
- package/build-module/components/add-new-template/utils.js +2 -2
- package/build-module/components/add-new-template/utils.js.map +1 -1
- package/build-module/components/editor/index.js +73 -22
- package/build-module/components/editor/index.js.map +1 -1
- package/build-module/components/global-styles/font-families.js +3 -4
- package/build-module/components/global-styles/font-families.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/context.js +0 -5
- package/build-module/components/global-styles/font-library-modal/context.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/font-collection.js +26 -6
- package/build-module/components/global-styles/font-library-modal/font-collection.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/index.js +1 -8
- package/build-module/components/global-styles/font-library-modal/index.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/installed-fonts.js +21 -6
- package/build-module/components/global-styles/font-library-modal/installed-fonts.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/upload-fonts.js +2 -3
- package/build-module/components/global-styles/font-library-modal/upload-fonts.js.map +1 -1
- package/build-module/components/global-styles/screen-typeset.js +34 -0
- package/build-module/components/global-styles/screen-typeset.js.map +1 -0
- package/build-module/components/global-styles/screen-typography-element.js +14 -0
- package/build-module/components/global-styles/screen-typography-element.js.map +1 -1
- package/build-module/components/global-styles/screen-typography.js +4 -6
- package/build-module/components/global-styles/screen-typography.js.map +1 -1
- package/build-module/components/global-styles/shadows-edit-panel.js +51 -60
- package/build-module/components/global-styles/shadows-edit-panel.js.map +1 -1
- package/build-module/components/global-styles/typeset-button.js +89 -0
- package/build-module/components/global-styles/typeset-button.js.map +1 -0
- package/build-module/components/global-styles/typeset.js +71 -0
- package/build-module/components/global-styles/typeset.js.map +1 -0
- package/build-module/components/global-styles/ui.js +4 -0
- package/build-module/components/global-styles/ui.js.map +1 -1
- package/build-module/components/global-styles/utils.js +10 -1
- package/build-module/components/global-styles/utils.js.map +1 -1
- package/build-module/components/page-patterns/fields.js +223 -0
- package/build-module/components/page-patterns/fields.js.map +1 -0
- package/build-module/components/page-patterns/index.js +11 -229
- package/build-module/components/page-patterns/index.js.map +1 -1
- package/build-module/components/page-patterns/use-patterns.js +26 -1
- package/build-module/components/page-patterns/use-patterns.js.map +1 -1
- package/build-module/components/page-templates/fields.js +160 -0
- package/build-module/components/page-templates/fields.js.map +1 -0
- package/build-module/components/page-templates/index.js +12 -178
- package/build-module/components/page-templates/index.js.map +1 -1
- package/build-module/components/post-edit/index.js +20 -8
- package/build-module/components/post-edit/index.js.map +1 -1
- package/build-module/components/post-fields/index.js +19 -15
- package/build-module/components/post-fields/index.js.map +1 -1
- package/build-module/components/post-list/index.js +127 -69
- package/build-module/components/post-list/index.js.map +1 -1
- package/build-module/components/sidebar-dataviews/add-new-view.js +2 -2
- package/build-module/components/sidebar-dataviews/add-new-view.js.map +1 -1
- package/build-module/components/sidebar-dataviews/dataview-item.js +2 -3
- package/build-module/components/sidebar-dataviews/dataview-item.js.map +1 -1
- package/build-module/components/sidebar-dataviews/default-views.js +81 -81
- package/build-module/components/sidebar-dataviews/default-views.js.map +1 -1
- package/build-module/components/sidebar-dataviews/index.js +3 -42
- package/build-module/components/sidebar-dataviews/index.js.map +1 -1
- package/build-module/components/site-hub/index.js +7 -4
- package/build-module/components/site-hub/index.js.map +1 -1
- package/build-module/components/style-book/index.js +23 -26
- package/build-module/components/style-book/index.js.map +1 -1
- package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js +5 -0
- package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
- package/build-module/hooks/push-changes-to-global-styles/index.js +2 -3
- package/build-module/hooks/push-changes-to-global-styles/index.js.map +1 -1
- package/build-module/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js +2 -3
- package/build-module/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js.map +1 -1
- package/build-module/index.js +0 -2
- package/build-module/index.js.map +1 -1
- package/build-style/posts-rtl.css +190 -11
- package/build-style/posts.css +190 -11
- package/build-style/style-rtl.css +296 -55
- package/build-style/style.css +296 -55
- package/package.json +41 -41
- package/src/components/add-new-pattern/index.js +8 -3
- package/src/components/add-new-post/index.js +2 -1
- package/src/components/add-new-template/utils.js +10 -6
- package/src/components/editor/index.js +80 -22
- package/src/components/editor/style.scss +59 -1
- package/src/components/global-styles/font-families.js +3 -5
- package/src/components/global-styles/font-library-modal/context.js +0 -5
- package/src/components/global-styles/font-library-modal/font-collection.js +34 -10
- package/src/components/global-styles/font-library-modal/index.js +2 -7
- package/src/components/global-styles/font-library-modal/installed-fonts.js +23 -5
- package/src/components/global-styles/font-library-modal/style.scss +1 -1
- package/src/components/global-styles/font-library-modal/upload-fonts.js +2 -2
- package/src/components/global-styles/screen-typeset.js +42 -0
- package/src/components/global-styles/screen-typography-element.js +14 -0
- package/src/components/global-styles/screen-typography.js +4 -4
- package/src/components/global-styles/shadows-edit-panel.js +66 -73
- package/src/components/global-styles/style.scss +4 -7
- package/src/components/global-styles/typeset-button.js +93 -0
- package/src/components/global-styles/typeset.js +73 -0
- package/src/components/global-styles/ui.js +5 -0
- package/src/components/global-styles/utils.js +13 -1
- package/src/components/layout/style.scss +8 -0
- package/src/components/page-patterns/fields.js +251 -0
- package/src/components/page-patterns/index.js +15 -244
- package/src/components/page-patterns/style.scss +82 -85
- package/src/components/page-patterns/use-patterns.js +31 -1
- package/src/components/page-templates/fields.js +157 -0
- package/src/components/page-templates/index.js +19 -170
- package/src/components/page-templates/style.scss +14 -5
- package/src/components/post-edit/index.js +27 -8
- package/src/components/post-fields/index.js +29 -17
- package/src/components/post-list/index.js +134 -74
- package/src/components/sidebar-dataviews/add-new-view.js +2 -4
- package/src/components/sidebar-dataviews/dataview-item.js +2 -2
- package/src/components/sidebar-dataviews/default-views.js +95 -95
- package/src/components/sidebar-dataviews/index.js +3 -37
- package/src/components/site-hub/index.js +11 -2
- package/src/components/site-icon/style.scss +4 -1
- package/src/components/style-book/index.js +27 -32
- package/src/components/sync-state-with-url/use-init-edited-entity-from-url.js +5 -0
- package/src/hooks/push-changes-to-global-styles/index.js +2 -3
- package/src/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js +2 -3
- package/src/index.js +0 -2
- package/build/utils/clone-deep.js +0 -15
- package/build/utils/clone-deep.js.map +0 -1
- package/build-module/utils/clone-deep.js +0 -9
- package/build-module/utils/clone-deep.js.map +0 -1
- package/src/utils/clone-deep.js +0 -8
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.titleField = exports.previewField = exports.descriptionField = exports.authorField = void 0;
|
|
8
|
+
var _clsx = _interopRequireDefault(require("clsx"));
|
|
9
|
+
var _components = require("@wordpress/components");
|
|
10
|
+
var _i18n = require("@wordpress/i18n");
|
|
11
|
+
var _element = require("@wordpress/element");
|
|
12
|
+
var _htmlEntities = require("@wordpress/html-entities");
|
|
13
|
+
var _blocks = require("@wordpress/blocks");
|
|
14
|
+
var _blockEditor = require("@wordpress/block-editor");
|
|
15
|
+
var _editor = require("@wordpress/editor");
|
|
16
|
+
var _async = require("../async");
|
|
17
|
+
var _link = _interopRequireWildcard(require("../routes/link"));
|
|
18
|
+
var _hooks = require("./hooks");
|
|
19
|
+
var _usePatternSettings = _interopRequireDefault(require("../page-patterns/use-pattern-settings"));
|
|
20
|
+
var _lockUnlock = require("../../lock-unlock");
|
|
21
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
22
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
23
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
24
|
+
/**
|
|
25
|
+
* External dependencies
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* WordPress dependencies
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Internal dependencies
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
const {
|
|
37
|
+
useGlobalStyle
|
|
38
|
+
} = (0, _lockUnlock.unlock)(_blockEditor.privateApis);
|
|
39
|
+
function PreviewField({
|
|
40
|
+
item
|
|
41
|
+
}) {
|
|
42
|
+
const settings = (0, _usePatternSettings.default)();
|
|
43
|
+
const [backgroundColor = 'white'] = useGlobalStyle('color.background');
|
|
44
|
+
const blocks = (0, _element.useMemo)(() => {
|
|
45
|
+
return (0, _blocks.parse)(item.content.raw);
|
|
46
|
+
}, [item.content.raw]);
|
|
47
|
+
const {
|
|
48
|
+
onClick
|
|
49
|
+
} = (0, _link.useLink)({
|
|
50
|
+
postId: item.id,
|
|
51
|
+
postType: item.type,
|
|
52
|
+
canvas: 'edit'
|
|
53
|
+
});
|
|
54
|
+
const isEmpty = !blocks?.length;
|
|
55
|
+
// Wrap everything in a block editor provider to ensure 'styles' that are needed
|
|
56
|
+
// for the previews are synced between the site editor store and the block editor store.
|
|
57
|
+
// Additionally we need to have the `__experimentalBlockPatterns` setting in order to
|
|
58
|
+
// render patterns inside the previews.
|
|
59
|
+
// TODO: Same approach is used in the patterns list and it becomes obvious that some of
|
|
60
|
+
// the block editor settings are needed in context where we don't have the block editor.
|
|
61
|
+
// Explore how we can solve this in a better way.
|
|
62
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_editor.EditorProvider, {
|
|
63
|
+
post: item,
|
|
64
|
+
settings: settings,
|
|
65
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
66
|
+
className: "page-templates-preview-field",
|
|
67
|
+
style: {
|
|
68
|
+
backgroundColor
|
|
69
|
+
},
|
|
70
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("button", {
|
|
71
|
+
className: "page-templates-preview-field__button",
|
|
72
|
+
type: "button",
|
|
73
|
+
onClick: onClick,
|
|
74
|
+
"aria-label": item.title?.rendered || item.title,
|
|
75
|
+
children: [isEmpty && (0, _i18n.__)('Empty template'), !isEmpty && /*#__PURE__*/(0, _jsxRuntime.jsx)(_async.Async, {
|
|
76
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_blockEditor.BlockPreview, {
|
|
77
|
+
blocks: blocks
|
|
78
|
+
})
|
|
79
|
+
})]
|
|
80
|
+
})
|
|
81
|
+
})
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
const previewField = exports.previewField = {
|
|
85
|
+
label: (0, _i18n.__)('Preview'),
|
|
86
|
+
id: 'preview',
|
|
87
|
+
render: PreviewField,
|
|
88
|
+
enableSorting: false
|
|
89
|
+
};
|
|
90
|
+
function TitleField({
|
|
91
|
+
item
|
|
92
|
+
}) {
|
|
93
|
+
const linkProps = {
|
|
94
|
+
params: {
|
|
95
|
+
postId: item.id,
|
|
96
|
+
postType: item.type,
|
|
97
|
+
canvas: 'edit'
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_link.default, {
|
|
101
|
+
...linkProps,
|
|
102
|
+
children: (0, _htmlEntities.decodeEntities)(item.title?.rendered) || (0, _i18n.__)('(no title)')
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
const titleField = exports.titleField = {
|
|
106
|
+
label: (0, _i18n.__)('Template'),
|
|
107
|
+
id: 'title',
|
|
108
|
+
getValue: ({
|
|
109
|
+
item
|
|
110
|
+
}) => item.title?.rendered,
|
|
111
|
+
render: TitleField,
|
|
112
|
+
enableHiding: false,
|
|
113
|
+
enableGlobalSearch: true
|
|
114
|
+
};
|
|
115
|
+
const descriptionField = exports.descriptionField = {
|
|
116
|
+
label: (0, _i18n.__)('Description'),
|
|
117
|
+
id: 'description',
|
|
118
|
+
render: ({
|
|
119
|
+
item
|
|
120
|
+
}) => {
|
|
121
|
+
return item.description && /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
122
|
+
className: "page-templates-description",
|
|
123
|
+
children: (0, _htmlEntities.decodeEntities)(item.description)
|
|
124
|
+
});
|
|
125
|
+
},
|
|
126
|
+
enableSorting: false,
|
|
127
|
+
enableGlobalSearch: true
|
|
128
|
+
};
|
|
129
|
+
function AuthorField({
|
|
130
|
+
item
|
|
131
|
+
}) {
|
|
132
|
+
const [isImageLoaded, setIsImageLoaded] = (0, _element.useState)(false);
|
|
133
|
+
const {
|
|
134
|
+
text,
|
|
135
|
+
icon,
|
|
136
|
+
imageUrl
|
|
137
|
+
} = (0, _hooks.useAddedBy)(item.type, item.id);
|
|
138
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.__experimentalHStack, {
|
|
139
|
+
alignment: "left",
|
|
140
|
+
spacing: 0,
|
|
141
|
+
children: [imageUrl && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
142
|
+
className: (0, _clsx.default)('page-templates-author-field__avatar', {
|
|
143
|
+
'is-loaded': isImageLoaded
|
|
144
|
+
}),
|
|
145
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("img", {
|
|
146
|
+
onLoad: () => setIsImageLoaded(true),
|
|
147
|
+
alt: "",
|
|
148
|
+
src: imageUrl
|
|
149
|
+
})
|
|
150
|
+
}), !imageUrl && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
151
|
+
className: "page-templates-author-field__icon",
|
|
152
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Icon, {
|
|
153
|
+
icon: icon
|
|
154
|
+
})
|
|
155
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
156
|
+
className: "page-templates-author-field__name",
|
|
157
|
+
children: text
|
|
158
|
+
})]
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
const authorField = exports.authorField = {
|
|
162
|
+
label: (0, _i18n.__)('Author'),
|
|
163
|
+
id: 'author',
|
|
164
|
+
getValue: ({
|
|
165
|
+
item
|
|
166
|
+
}) => item.author_text,
|
|
167
|
+
render: AuthorField
|
|
168
|
+
};
|
|
169
|
+
//# sourceMappingURL=fields.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_clsx","_interopRequireDefault","require","_components","_i18n","_element","_htmlEntities","_blocks","_blockEditor","_editor","_async","_link","_interopRequireWildcard","_hooks","_usePatternSettings","_lockUnlock","_jsxRuntime","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","useGlobalStyle","unlock","blockEditorPrivateApis","PreviewField","item","settings","usePatternSettings","backgroundColor","blocks","useMemo","parse","content","raw","onClick","useLink","postId","id","postType","type","canvas","isEmpty","length","jsx","EditorProvider","post","children","className","style","jsxs","title","rendered","__","Async","BlockPreview","previewField","exports","label","render","enableSorting","TitleField","linkProps","params","decodeEntities","titleField","getValue","enableHiding","enableGlobalSearch","descriptionField","description","AuthorField","isImageLoaded","setIsImageLoaded","useState","text","icon","imageUrl","useAddedBy","__experimentalHStack","alignment","spacing","clsx","onLoad","alt","src","Icon","authorField","author_text"],"sources":["@wordpress/edit-site/src/components/page-templates/fields.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { Icon, __experimentalHStack as HStack } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useState, useMemo } from '@wordpress/element';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { parse } from '@wordpress/blocks';\nimport {\n\tBlockPreview,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\nimport { EditorProvider } from '@wordpress/editor';\n\n/**\n * Internal dependencies\n */\nimport { Async } from '../async';\nimport { default as Link, useLink } from '../routes/link';\nimport { useAddedBy } from './hooks';\n\nimport usePatternSettings from '../page-patterns/use-pattern-settings';\nimport { unlock } from '../../lock-unlock';\n\nconst { useGlobalStyle } = unlock( blockEditorPrivateApis );\n\nfunction PreviewField( { item } ) {\n\tconst settings = usePatternSettings();\n\tconst [ backgroundColor = 'white' ] = useGlobalStyle( 'color.background' );\n\tconst blocks = useMemo( () => {\n\t\treturn parse( item.content.raw );\n\t}, [ item.content.raw ] );\n\tconst { onClick } = useLink( {\n\t\tpostId: item.id,\n\t\tpostType: item.type,\n\t\tcanvas: 'edit',\n\t} );\n\n\tconst isEmpty = ! blocks?.length;\n\t// Wrap everything in a block editor provider to ensure 'styles' that are needed\n\t// for the previews are synced between the site editor store and the block editor store.\n\t// Additionally we need to have the `__experimentalBlockPatterns` setting in order to\n\t// render patterns inside the previews.\n\t// TODO: Same approach is used in the patterns list and it becomes obvious that some of\n\t// the block editor settings are needed in context where we don't have the block editor.\n\t// Explore how we can solve this in a better way.\n\treturn (\n\t\t<EditorProvider post={ item } settings={ settings }>\n\t\t\t<div\n\t\t\t\tclassName=\"page-templates-preview-field\"\n\t\t\t\tstyle={ { backgroundColor } }\n\t\t\t>\n\t\t\t\t<button\n\t\t\t\t\tclassName=\"page-templates-preview-field__button\"\n\t\t\t\t\ttype=\"button\"\n\t\t\t\t\tonClick={ onClick }\n\t\t\t\t\taria-label={ item.title?.rendered || item.title }\n\t\t\t\t>\n\t\t\t\t\t{ isEmpty && __( 'Empty template' ) }\n\t\t\t\t\t{ ! isEmpty && (\n\t\t\t\t\t\t<Async>\n\t\t\t\t\t\t\t<BlockPreview blocks={ blocks } />\n\t\t\t\t\t\t</Async>\n\t\t\t\t\t) }\n\t\t\t\t</button>\n\t\t\t</div>\n\t\t</EditorProvider>\n\t);\n}\n\nexport const previewField = {\n\tlabel: __( 'Preview' ),\n\tid: 'preview',\n\trender: PreviewField,\n\tenableSorting: false,\n};\n\nfunction TitleField( { item } ) {\n\tconst linkProps = {\n\t\tparams: {\n\t\t\tpostId: item.id,\n\t\t\tpostType: item.type,\n\t\t\tcanvas: 'edit',\n\t\t},\n\t};\n\treturn (\n\t\t<Link { ...linkProps }>\n\t\t\t{ decodeEntities( item.title?.rendered ) || __( '(no title)' ) }\n\t\t</Link>\n\t);\n}\n\nexport const titleField = {\n\tlabel: __( 'Template' ),\n\tid: 'title',\n\tgetValue: ( { item } ) => item.title?.rendered,\n\trender: TitleField,\n\tenableHiding: false,\n\tenableGlobalSearch: true,\n};\n\nexport const descriptionField = {\n\tlabel: __( 'Description' ),\n\tid: 'description',\n\trender: ( { item } ) => {\n\t\treturn (\n\t\t\titem.description && (\n\t\t\t\t<span className=\"page-templates-description\">\n\t\t\t\t\t{ decodeEntities( item.description ) }\n\t\t\t\t</span>\n\t\t\t)\n\t\t);\n\t},\n\tenableSorting: false,\n\tenableGlobalSearch: true,\n};\n\nfunction AuthorField( { item } ) {\n\tconst [ isImageLoaded, setIsImageLoaded ] = useState( false );\n\tconst { text, icon, imageUrl } = useAddedBy( item.type, item.id );\n\n\treturn (\n\t\t<HStack alignment=\"left\" spacing={ 0 }>\n\t\t\t{ imageUrl && (\n\t\t\t\t<div\n\t\t\t\t\tclassName={ clsx( 'page-templates-author-field__avatar', {\n\t\t\t\t\t\t'is-loaded': isImageLoaded,\n\t\t\t\t\t} ) }\n\t\t\t\t>\n\t\t\t\t\t<img\n\t\t\t\t\t\tonLoad={ () => setIsImageLoaded( true ) }\n\t\t\t\t\t\talt=\"\"\n\t\t\t\t\t\tsrc={ imageUrl }\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t{ ! imageUrl && (\n\t\t\t\t<div className=\"page-templates-author-field__icon\">\n\t\t\t\t\t<Icon icon={ icon } />\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t<span className=\"page-templates-author-field__name\">{ text }</span>\n\t\t</HStack>\n\t);\n}\n\nexport const authorField = {\n\tlabel: __( 'Author' ),\n\tid: 'author',\n\tgetValue: ( { item } ) => item.author_text,\n\trender: AuthorField,\n};\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,aAAA,GAAAJ,OAAA;AACA,IAAAK,OAAA,GAAAL,OAAA;AACA,IAAAM,YAAA,GAAAN,OAAA;AAIA,IAAAO,OAAA,GAAAP,OAAA;AAKA,IAAAQ,MAAA,GAAAR,OAAA;AACA,IAAAS,KAAA,GAAAC,uBAAA,CAAAV,OAAA;AACA,IAAAW,MAAA,GAAAX,OAAA;AAEA,IAAAY,mBAAA,GAAAb,sBAAA,CAAAC,OAAA;AACA,IAAAa,WAAA,GAAAb,OAAA;AAA2C,IAAAc,WAAA,GAAAd,OAAA;AAAA,SAAAe,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAN,wBAAAM,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA,CAAAI,GAAA,CAAA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IAAI,CAACc,IAAI,EAAEd,IAAI,CAACY,EAAG,CAAC;EAEjE,oBACC,IAAArC,WAAA,CAAAiD,IAAA,EAAC9D,WAAA,CAAA2F,oBAAM;IAACC,SAAS,EAAC,MAAM;IAACC,OAAO,EAAG,CAAG;IAAAlC,QAAA,GACnC8B,QAAQ,iBACT,IAAA5E,WAAA,CAAA2C,GAAA;MACCI,SAAS,EAAG,IAAAkC,aAAI,EAAE,qCAAqC,EAAE;QACxD,WAAW,EAAEV;MACd,CAAE,CAAG;MAAAzB,QAAA,eAEL,IAAA9C,WAAA,CAAA2C,GAAA;QACCuC,MAAM,EAAGA,CAAA,KAAMV,gBAAgB,CAAE,IAAK,CAAG;QACzCW,GAAG,EAAC,EAAE;QACNC,GAAG,EAAGR;MAAU,CAChB;IAAC,CACE,CACL,EACC,CAAEA,QAAQ,iBACX,IAAA5E,WAAA,CAAA2C,GAAA;MAAKI,SAAS,EAAC,mCAAmC;MAAAD,QAAA,eACjD,IAAA9C,WAAA,CAAA2C,GAAA,EAACxD,WAAA,CAAAkG,IAAI;QAACV,IAAI,EAAGA;MAAM,CAAE;IAAC,CAClB,CACL,eACD,IAAA3E,WAAA,CAAA2C,GAAA;MAAMI,SAAS,EAAC,mCAAmC;MAAAD,QAAA,EAAG4B;IAAI,CAAQ,CAAC;EAAA,CAC5D,CAAC;AAEX;AAEO,MAAMY,WAAW,GAAA9B,OAAA,CAAA8B,WAAA,GAAG;EAC1B7B,KAAK,EAAE,IAAAL,QAAE,EAAE,QAAS,CAAC;EACrBf,EAAE,EAAE,QAAQ;EACZ4B,QAAQ,EAAEA,CAAE;IAAExC;EAAK,CAAC,KAAMA,IAAI,CAAC8D,WAAW;EAC1C7B,MAAM,EAAEY;AACT,CAAC","ignoreList":[]}
|
|
@@ -5,33 +5,19 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.default = PageTemplates;
|
|
8
|
-
var _clsx = _interopRequireDefault(require("clsx"));
|
|
9
|
-
var _components = require("@wordpress/components");
|
|
10
8
|
var _i18n = require("@wordpress/i18n");
|
|
11
9
|
var _element = require("@wordpress/element");
|
|
12
10
|
var _coreData = require("@wordpress/core-data");
|
|
13
|
-
var _htmlEntities = require("@wordpress/html-entities");
|
|
14
|
-
var _blocks = require("@wordpress/blocks");
|
|
15
|
-
var _blockEditor = require("@wordpress/block-editor");
|
|
16
11
|
var _dataviews = require("@wordpress/dataviews");
|
|
17
12
|
var _router = require("@wordpress/router");
|
|
18
13
|
var _editor = require("@wordpress/editor");
|
|
19
|
-
var _async = require("../async");
|
|
20
14
|
var _page = _interopRequireDefault(require("../page"));
|
|
21
|
-
var _link = _interopRequireWildcard(require("../routes/link"));
|
|
22
15
|
var _addNewTemplate = _interopRequireDefault(require("../add-new-template"));
|
|
23
|
-
var _hooks = require("./hooks");
|
|
24
16
|
var _constants = require("../../utils/constants");
|
|
25
|
-
var _usePatternSettings = _interopRequireDefault(require("../page-patterns/use-pattern-settings"));
|
|
26
17
|
var _lockUnlock = require("../../lock-unlock");
|
|
27
18
|
var _dataviewsActions = require("../dataviews-actions");
|
|
19
|
+
var _fields = require("./fields");
|
|
28
20
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
29
|
-
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
30
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
31
|
-
/**
|
|
32
|
-
* External dependencies
|
|
33
|
-
*/
|
|
34
|
-
|
|
35
21
|
/**
|
|
36
22
|
* WordPress dependencies
|
|
37
23
|
*/
|
|
@@ -43,13 +29,13 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
43
29
|
const {
|
|
44
30
|
usePostActions
|
|
45
31
|
} = (0, _lockUnlock.unlock)(_editor.privateApis);
|
|
46
|
-
const {
|
|
47
|
-
useGlobalStyle
|
|
48
|
-
} = (0, _lockUnlock.unlock)(_blockEditor.privateApis);
|
|
49
32
|
const {
|
|
50
33
|
useHistory,
|
|
51
34
|
useLocation
|
|
52
35
|
} = (0, _lockUnlock.unlock)(_router.privateApis);
|
|
36
|
+
const {
|
|
37
|
+
useEntityRecordsWithPermissions
|
|
38
|
+
} = (0, _lockUnlock.unlock)(_coreData.privateApis);
|
|
53
39
|
const EMPTY_ARRAY = [];
|
|
54
40
|
const defaultLayouts = {
|
|
55
41
|
[_constants.LAYOUT_TABLE]: {
|
|
@@ -68,8 +54,7 @@ const defaultLayouts = {
|
|
|
68
54
|
minWidth: 320
|
|
69
55
|
},
|
|
70
56
|
preview: {
|
|
71
|
-
|
|
72
|
-
maxWidth: 120
|
|
57
|
+
width: '1%'
|
|
73
58
|
},
|
|
74
59
|
author: {
|
|
75
60
|
width: '1%'
|
|
@@ -106,107 +91,6 @@ const DEFAULT_VIEW = {
|
|
|
106
91
|
layout: defaultLayouts[_constants.LAYOUT_GRID].layout,
|
|
107
92
|
filters: []
|
|
108
93
|
};
|
|
109
|
-
function Title({
|
|
110
|
-
item,
|
|
111
|
-
viewType
|
|
112
|
-
}) {
|
|
113
|
-
if (viewType === _constants.LAYOUT_LIST) {
|
|
114
|
-
return (0, _htmlEntities.decodeEntities)(item.title?.rendered) || (0, _i18n.__)('(no title)');
|
|
115
|
-
}
|
|
116
|
-
const linkProps = {
|
|
117
|
-
params: {
|
|
118
|
-
postId: item.id,
|
|
119
|
-
postType: item.type,
|
|
120
|
-
canvas: 'edit'
|
|
121
|
-
}
|
|
122
|
-
};
|
|
123
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_link.default, {
|
|
124
|
-
...linkProps,
|
|
125
|
-
children: (0, _htmlEntities.decodeEntities)(item.title?.rendered) || (0, _i18n.__)('(no title)')
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
function AuthorField({
|
|
129
|
-
item
|
|
130
|
-
}) {
|
|
131
|
-
const [isImageLoaded, setIsImageLoaded] = (0, _element.useState)(false);
|
|
132
|
-
const {
|
|
133
|
-
text,
|
|
134
|
-
icon,
|
|
135
|
-
imageUrl
|
|
136
|
-
} = (0, _hooks.useAddedBy)(item.type, item.id);
|
|
137
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.__experimentalHStack, {
|
|
138
|
-
alignment: "left",
|
|
139
|
-
spacing: 0,
|
|
140
|
-
children: [imageUrl && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
141
|
-
className: (0, _clsx.default)('page-templates-author-field__avatar', {
|
|
142
|
-
'is-loaded': isImageLoaded
|
|
143
|
-
}),
|
|
144
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("img", {
|
|
145
|
-
onLoad: () => setIsImageLoaded(true),
|
|
146
|
-
alt: "",
|
|
147
|
-
src: imageUrl
|
|
148
|
-
})
|
|
149
|
-
}), !imageUrl && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
150
|
-
className: "page-templates-author-field__icon",
|
|
151
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Icon, {
|
|
152
|
-
icon: icon
|
|
153
|
-
})
|
|
154
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
155
|
-
className: "page-templates-author-field__name",
|
|
156
|
-
children: text
|
|
157
|
-
})]
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
function Preview({
|
|
161
|
-
item,
|
|
162
|
-
viewType
|
|
163
|
-
}) {
|
|
164
|
-
const settings = (0, _usePatternSettings.default)();
|
|
165
|
-
const [backgroundColor = 'white'] = useGlobalStyle('color.background');
|
|
166
|
-
const blocks = (0, _element.useMemo)(() => {
|
|
167
|
-
return (0, _blocks.parse)(item.content.raw);
|
|
168
|
-
}, [item.content.raw]);
|
|
169
|
-
const {
|
|
170
|
-
onClick
|
|
171
|
-
} = (0, _link.useLink)({
|
|
172
|
-
postId: item.id,
|
|
173
|
-
postType: item.type,
|
|
174
|
-
canvas: 'edit'
|
|
175
|
-
});
|
|
176
|
-
const isEmpty = !blocks?.length;
|
|
177
|
-
// Wrap everything in a block editor provider to ensure 'styles' that are needed
|
|
178
|
-
// for the previews are synced between the site editor store and the block editor store.
|
|
179
|
-
// Additionally we need to have the `__experimentalBlockPatterns` setting in order to
|
|
180
|
-
// render patterns inside the previews.
|
|
181
|
-
// TODO: Same approach is used in the patterns list and it becomes obvious that some of
|
|
182
|
-
// the block editor settings are needed in context where we don't have the block editor.
|
|
183
|
-
// Explore how we can solve this in a better way.
|
|
184
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_editor.EditorProvider, {
|
|
185
|
-
post: item,
|
|
186
|
-
settings: settings,
|
|
187
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
188
|
-
className: `page-templates-preview-field is-viewtype-${viewType}`,
|
|
189
|
-
style: {
|
|
190
|
-
backgroundColor
|
|
191
|
-
},
|
|
192
|
-
children: [viewType === _constants.LAYOUT_LIST && !isEmpty && /*#__PURE__*/(0, _jsxRuntime.jsx)(_async.Async, {
|
|
193
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_blockEditor.BlockPreview, {
|
|
194
|
-
blocks: blocks
|
|
195
|
-
})
|
|
196
|
-
}), viewType !== _constants.LAYOUT_LIST && /*#__PURE__*/(0, _jsxRuntime.jsxs)("button", {
|
|
197
|
-
className: "page-templates-preview-field__button",
|
|
198
|
-
type: "button",
|
|
199
|
-
onClick: onClick,
|
|
200
|
-
"aria-label": item.title?.rendered || item.title,
|
|
201
|
-
children: [isEmpty && (0, _i18n.__)('Empty template'), !isEmpty && /*#__PURE__*/(0, _jsxRuntime.jsx)(_async.Async, {
|
|
202
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_blockEditor.BlockPreview, {
|
|
203
|
-
blocks: blocks
|
|
204
|
-
})
|
|
205
|
-
})]
|
|
206
|
-
})]
|
|
207
|
-
})
|
|
208
|
-
});
|
|
209
|
-
}
|
|
210
94
|
function PageTemplates() {
|
|
211
95
|
const {
|
|
212
96
|
params
|
|
@@ -245,7 +129,7 @@ function PageTemplates() {
|
|
|
245
129
|
const {
|
|
246
130
|
records,
|
|
247
131
|
isResolving: isLoadingData
|
|
248
|
-
} = (
|
|
132
|
+
} = useEntityRecordsWithPermissions('postType', _constants.TEMPLATE_POST_TYPE, {
|
|
249
133
|
per_page: -1
|
|
250
134
|
});
|
|
251
135
|
const history = useHistory();
|
|
@@ -271,61 +155,10 @@ function PageTemplates() {
|
|
|
271
155
|
label: author
|
|
272
156
|
}));
|
|
273
157
|
}, [records]);
|
|
274
|
-
const fields = (0, _element.useMemo)(() => [{
|
|
275
|
-
|
|
276
|
-
id: 'preview',
|
|
277
|
-
render: ({
|
|
278
|
-
item
|
|
279
|
-
}) => {
|
|
280
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(Preview, {
|
|
281
|
-
item: item,
|
|
282
|
-
viewType: view.type
|
|
283
|
-
});
|
|
284
|
-
},
|
|
285
|
-
enableSorting: false
|
|
286
|
-
}, {
|
|
287
|
-
label: (0, _i18n.__)('Template'),
|
|
288
|
-
id: 'title',
|
|
289
|
-
getValue: ({
|
|
290
|
-
item
|
|
291
|
-
}) => item.title?.rendered,
|
|
292
|
-
render: ({
|
|
293
|
-
item
|
|
294
|
-
}) => /*#__PURE__*/(0, _jsxRuntime.jsx)(Title, {
|
|
295
|
-
item: item,
|
|
296
|
-
viewType: view.type
|
|
297
|
-
}),
|
|
298
|
-
enableHiding: false,
|
|
299
|
-
enableGlobalSearch: true
|
|
300
|
-
}, {
|
|
301
|
-
label: (0, _i18n.__)('Description'),
|
|
302
|
-
id: 'description',
|
|
303
|
-
render: ({
|
|
304
|
-
item
|
|
305
|
-
}) => {
|
|
306
|
-
return item.description && /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
307
|
-
className: "page-templates-description",
|
|
308
|
-
children: (0, _htmlEntities.decodeEntities)(item.description)
|
|
309
|
-
});
|
|
310
|
-
},
|
|
311
|
-
enableSorting: false,
|
|
312
|
-
enableGlobalSearch: true
|
|
313
|
-
}, {
|
|
314
|
-
label: (0, _i18n.__)('Author'),
|
|
315
|
-
id: 'author',
|
|
316
|
-
getValue: ({
|
|
317
|
-
item
|
|
318
|
-
}) => item.author_text,
|
|
319
|
-
render: ({
|
|
320
|
-
item
|
|
321
|
-
}) => {
|
|
322
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(AuthorField, {
|
|
323
|
-
viewType: view.type,
|
|
324
|
-
item: item
|
|
325
|
-
});
|
|
326
|
-
},
|
|
158
|
+
const fields = (0, _element.useMemo)(() => [_fields.previewField, _fields.titleField, _fields.descriptionField, {
|
|
159
|
+
..._fields.authorField,
|
|
327
160
|
elements: authors
|
|
328
|
-
}], [authors
|
|
161
|
+
}], [authors]);
|
|
329
162
|
const {
|
|
330
163
|
data,
|
|
331
164
|
paginationInfo
|
|
@@ -362,7 +195,7 @@ function PageTemplates() {
|
|
|
362
195
|
onChangeSelection: onChangeSelection,
|
|
363
196
|
selection: selection,
|
|
364
197
|
defaultLayouts: defaultLayouts
|
|
365
|
-
})
|
|
198
|
+
}, activeView)
|
|
366
199
|
});
|
|
367
200
|
}
|
|
368
201
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_clsx","_interopRequireDefault","require","_components","_i18n","_element","_coreData","_htmlEntities","_blocks","_blockEditor","_dataviews","_router","_editor","_async","_page","_link","_interopRequireWildcard","_addNewTemplate","_hooks","_constants","_usePatternSettings","_lockUnlock","_dataviewsActions","_jsxRuntime","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","usePostActions","unlock","editorPrivateApis","useGlobalStyle","blockEditorPrivateApis","useHistory","useLocation","routerPrivateApis","EMPTY_ARRAY","defaultLayouts","LAYOUT_TABLE","fields","layout","primaryField","combinedFields","id","label","__","children","direction","styles","template","maxWidth","minWidth","preview","author","width","LAYOUT_GRID","mediaField","columnFields","LAYOUT_LIST","DEFAULT_VIEW","type","search","page","perPage","sort","field","filters","Title","item","viewType","decodeEntities","title","rendered","linkProps","params","postId","postType","canvas","jsx","AuthorField","isImageLoaded","setIsImageLoaded","useState","text","icon","imageUrl","useAddedBy","jsxs","__experimentalHStack","alignment","spacing","className","clsx","onLoad","alt","src","Icon","Preview","settings","usePatternSettings","backgroundColor","blocks","useMemo","parse","content","raw","onClick","useLink","isEmpty","length","EditorProvider","post","style","Async","BlockPreview","PageTemplates","activeView","selection","setSelection","defaultView","usedType","operator","value","view","setView","useEffect","currentView","OPERATOR_IS_ANY","records","isResolving","isLoadingData","useEntityRecords","TEMPLATE_POST_TYPE","per_page","history","onChangeSelection","useCallback","items","push","undefined","authors","authorsSet","Set","forEach","add","author_text","Array","from","map","render","enableSorting","getValue","enableHiding","enableGlobalSearch","description","elements","data","paginationInfo","filterSortAndPaginate","postTypeActions","context","editAction","useEditPostAction","actions","onChangeView","newView","DataViews","isLoading"],"sources":["@wordpress/edit-site/src/components/page-templates/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { Icon, __experimentalHStack as HStack } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useState, useMemo, useCallback, useEffect } from '@wordpress/element';\nimport { useEntityRecords } from '@wordpress/core-data';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { parse } from '@wordpress/blocks';\nimport {\n\tBlockPreview,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\nimport { DataViews, filterSortAndPaginate } from '@wordpress/dataviews';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\nimport {\n\tprivateApis as editorPrivateApis,\n\tEditorProvider,\n} from '@wordpress/editor';\n\n/**\n * Internal dependencies\n */\nimport { Async } from '../async';\nimport Page from '../page';\nimport { default as Link, useLink } from '../routes/link';\nimport AddNewTemplate from '../add-new-template';\nimport { useAddedBy } from './hooks';\nimport {\n\tTEMPLATE_POST_TYPE,\n\tOPERATOR_IS_ANY,\n\tLAYOUT_GRID,\n\tLAYOUT_TABLE,\n\tLAYOUT_LIST,\n} from '../../utils/constants';\n\nimport usePatternSettings from '../page-patterns/use-pattern-settings';\nimport { unlock } from '../../lock-unlock';\nimport { useEditPostAction } from '../dataviews-actions';\n\nconst { usePostActions } = unlock( editorPrivateApis );\n\nconst { useGlobalStyle } = unlock( blockEditorPrivateApis );\nconst { useHistory, useLocation } = unlock( routerPrivateApis );\n\nconst EMPTY_ARRAY = [];\n\nconst defaultLayouts = {\n\t[ LAYOUT_TABLE ]: {\n\t\tfields: [ 'template', 'author' ],\n\t\tlayout: {\n\t\t\tprimaryField: 'title',\n\t\t\tcombinedFields: [\n\t\t\t\t{\n\t\t\t\t\tid: 'template',\n\t\t\t\t\tlabel: __( 'Template' ),\n\t\t\t\t\tchildren: [ 'title', 'description' ],\n\t\t\t\t\tdirection: 'vertical',\n\t\t\t\t},\n\t\t\t],\n\t\t\tstyles: {\n\t\t\t\ttemplate: {\n\t\t\t\t\tmaxWidth: 400,\n\t\t\t\t\tminWidth: 320,\n\t\t\t\t},\n\t\t\t\tpreview: {\n\t\t\t\t\tminWidth: 120,\n\t\t\t\t\tmaxWidth: 120,\n\t\t\t\t},\n\t\t\t\tauthor: {\n\t\t\t\t\twidth: '1%',\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t},\n\t[ LAYOUT_GRID ]: {\n\t\tfields: [ 'title', 'description', 'author' ],\n\t\tlayout: {\n\t\t\tmediaField: 'preview',\n\t\t\tprimaryField: 'title',\n\t\t\tcolumnFields: [ 'description' ],\n\t\t},\n\t},\n\t[ LAYOUT_LIST ]: {\n\t\tfields: [ 'title', 'description', 'author' ],\n\t\tlayout: {\n\t\t\tprimaryField: 'title',\n\t\t\tmediaField: 'preview',\n\t\t},\n\t},\n};\n\nconst DEFAULT_VIEW = {\n\ttype: LAYOUT_GRID,\n\tsearch: '',\n\tpage: 1,\n\tperPage: 20,\n\tsort: {\n\t\tfield: 'title',\n\t\tdirection: 'asc',\n\t},\n\tfields: defaultLayouts[ LAYOUT_GRID ].fields,\n\tlayout: defaultLayouts[ LAYOUT_GRID ].layout,\n\tfilters: [],\n};\n\nfunction Title( { item, viewType } ) {\n\tif ( viewType === LAYOUT_LIST ) {\n\t\treturn decodeEntities( item.title?.rendered ) || __( '(no title)' );\n\t}\n\tconst linkProps = {\n\t\tparams: {\n\t\t\tpostId: item.id,\n\t\t\tpostType: item.type,\n\t\t\tcanvas: 'edit',\n\t\t},\n\t};\n\treturn (\n\t\t<Link { ...linkProps }>\n\t\t\t{ decodeEntities( item.title?.rendered ) || __( '(no title)' ) }\n\t\t</Link>\n\t);\n}\n\nfunction AuthorField( { item } ) {\n\tconst [ isImageLoaded, setIsImageLoaded ] = useState( false );\n\tconst { text, icon, imageUrl } = useAddedBy( item.type, item.id );\n\n\treturn (\n\t\t<HStack alignment=\"left\" spacing={ 0 }>\n\t\t\t{ imageUrl && (\n\t\t\t\t<div\n\t\t\t\t\tclassName={ clsx( 'page-templates-author-field__avatar', {\n\t\t\t\t\t\t'is-loaded': isImageLoaded,\n\t\t\t\t\t} ) }\n\t\t\t\t>\n\t\t\t\t\t<img\n\t\t\t\t\t\tonLoad={ () => setIsImageLoaded( true ) }\n\t\t\t\t\t\talt=\"\"\n\t\t\t\t\t\tsrc={ imageUrl }\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t{ ! imageUrl && (\n\t\t\t\t<div className=\"page-templates-author-field__icon\">\n\t\t\t\t\t<Icon icon={ icon } />\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t<span className=\"page-templates-author-field__name\">{ text }</span>\n\t\t</HStack>\n\t);\n}\n\nfunction Preview( { item, viewType } ) {\n\tconst settings = usePatternSettings();\n\tconst [ backgroundColor = 'white' ] = useGlobalStyle( 'color.background' );\n\tconst blocks = useMemo( () => {\n\t\treturn parse( item.content.raw );\n\t}, [ item.content.raw ] );\n\tconst { onClick } = useLink( {\n\t\tpostId: item.id,\n\t\tpostType: item.type,\n\t\tcanvas: 'edit',\n\t} );\n\n\tconst isEmpty = ! blocks?.length;\n\t// Wrap everything in a block editor provider to ensure 'styles' that are needed\n\t// for the previews are synced between the site editor store and the block editor store.\n\t// Additionally we need to have the `__experimentalBlockPatterns` setting in order to\n\t// render patterns inside the previews.\n\t// TODO: Same approach is used in the patterns list and it becomes obvious that some of\n\t// the block editor settings are needed in context where we don't have the block editor.\n\t// Explore how we can solve this in a better way.\n\treturn (\n\t\t<EditorProvider post={ item } settings={ settings }>\n\t\t\t<div\n\t\t\t\tclassName={ `page-templates-preview-field is-viewtype-${ viewType }` }\n\t\t\t\tstyle={ { backgroundColor } }\n\t\t\t>\n\t\t\t\t{ viewType === LAYOUT_LIST && ! isEmpty && (\n\t\t\t\t\t<Async>\n\t\t\t\t\t\t<BlockPreview blocks={ blocks } />\n\t\t\t\t\t</Async>\n\t\t\t\t) }\n\t\t\t\t{ viewType !== LAYOUT_LIST && (\n\t\t\t\t\t<button\n\t\t\t\t\t\tclassName=\"page-templates-preview-field__button\"\n\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\tonClick={ onClick }\n\t\t\t\t\t\taria-label={ item.title?.rendered || item.title }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ isEmpty && __( 'Empty template' ) }\n\t\t\t\t\t\t{ ! isEmpty && (\n\t\t\t\t\t\t\t<Async>\n\t\t\t\t\t\t\t\t<BlockPreview blocks={ blocks } />\n\t\t\t\t\t\t\t</Async>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</button>\n\t\t\t\t) }\n\t\t\t</div>\n\t\t</EditorProvider>\n\t);\n}\n\nexport default function PageTemplates() {\n\tconst { params } = useLocation();\n\tconst { activeView = 'all', layout, postId } = params;\n\tconst [ selection, setSelection ] = useState( [ postId ] );\n\n\tconst defaultView = useMemo( () => {\n\t\tconst usedType = layout ?? DEFAULT_VIEW.type;\n\t\treturn {\n\t\t\t...DEFAULT_VIEW,\n\t\t\ttype: usedType,\n\t\t\tlayout: defaultLayouts[ usedType ].layout,\n\t\t\tfields: defaultLayouts[ usedType ].fields,\n\t\t\tfilters:\n\t\t\t\tactiveView !== 'all'\n\t\t\t\t\t? [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tfield: 'author',\n\t\t\t\t\t\t\t\toperator: 'isAny',\n\t\t\t\t\t\t\t\tvalue: [ activeView ],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t ]\n\t\t\t\t\t: [],\n\t\t};\n\t}, [ layout, activeView ] );\n\tconst [ view, setView ] = useState( defaultView );\n\tuseEffect( () => {\n\t\tsetView( ( currentView ) => ( {\n\t\t\t...currentView,\n\t\t\tfilters:\n\t\t\t\tactiveView !== 'all'\n\t\t\t\t\t? [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tfield: 'author',\n\t\t\t\t\t\t\t\toperator: OPERATOR_IS_ANY,\n\t\t\t\t\t\t\t\tvalue: [ activeView ],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t ]\n\t\t\t\t\t: [],\n\t\t} ) );\n\t}, [ activeView ] );\n\n\tconst { records, isResolving: isLoadingData } = useEntityRecords(\n\t\t'postType',\n\t\tTEMPLATE_POST_TYPE,\n\t\t{\n\t\t\tper_page: -1,\n\t\t}\n\t);\n\tconst history = useHistory();\n\tconst onChangeSelection = useCallback(\n\t\t( items ) => {\n\t\t\tsetSelection( items );\n\t\t\tif ( view?.type === LAYOUT_LIST ) {\n\t\t\t\thistory.push( {\n\t\t\t\t\t...params,\n\t\t\t\t\tpostId: items.length === 1 ? items[ 0 ] : undefined,\n\t\t\t\t} );\n\t\t\t}\n\t\t},\n\t\t[ history, params, view?.type ]\n\t);\n\n\tconst authors = useMemo( () => {\n\t\tif ( ! records ) {\n\t\t\treturn EMPTY_ARRAY;\n\t\t}\n\t\tconst authorsSet = new Set();\n\t\trecords.forEach( ( template ) => {\n\t\t\tauthorsSet.add( template.author_text );\n\t\t} );\n\t\treturn Array.from( authorsSet ).map( ( author ) => ( {\n\t\t\tvalue: author,\n\t\t\tlabel: author,\n\t\t} ) );\n\t}, [ records ] );\n\n\tconst fields = useMemo(\n\t\t() => [\n\t\t\t{\n\t\t\t\tlabel: __( 'Preview' ),\n\t\t\t\tid: 'preview',\n\t\t\t\trender: ( { item } ) => {\n\t\t\t\t\treturn <Preview item={ item } viewType={ view.type } />;\n\t\t\t\t},\n\t\t\t\tenableSorting: false,\n\t\t\t},\n\t\t\t{\n\t\t\t\tlabel: __( 'Template' ),\n\t\t\t\tid: 'title',\n\t\t\t\tgetValue: ( { item } ) => item.title?.rendered,\n\t\t\t\trender: ( { item } ) => (\n\t\t\t\t\t<Title item={ item } viewType={ view.type } />\n\t\t\t\t),\n\t\t\t\tenableHiding: false,\n\t\t\t\tenableGlobalSearch: true,\n\t\t\t},\n\t\t\t{\n\t\t\t\tlabel: __( 'Description' ),\n\t\t\t\tid: 'description',\n\t\t\t\trender: ( { item } ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\titem.description && (\n\t\t\t\t\t\t\t<span className=\"page-templates-description\">\n\t\t\t\t\t\t\t\t{ decodeEntities( item.description ) }\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t)\n\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t\tenableSorting: false,\n\t\t\t\tenableGlobalSearch: true,\n\t\t\t},\n\t\t\t{\n\t\t\t\tlabel: __( 'Author' ),\n\t\t\t\tid: 'author',\n\t\t\t\tgetValue: ( { item } ) => item.author_text,\n\t\t\t\trender: ( { item } ) => {\n\t\t\t\t\treturn <AuthorField viewType={ view.type } item={ item } />;\n\t\t\t\t},\n\t\t\t\telements: authors,\n\t\t\t},\n\t\t],\n\t\t[ authors, view.type ]\n\t);\n\n\tconst { data, paginationInfo } = useMemo( () => {\n\t\treturn filterSortAndPaginate( records, view, fields );\n\t}, [ records, view, fields ] );\n\n\tconst postTypeActions = usePostActions( {\n\t\tpostType: TEMPLATE_POST_TYPE,\n\t\tcontext: 'list',\n\t} );\n\tconst editAction = useEditPostAction();\n\tconst actions = useMemo(\n\t\t() => [ editAction, ...postTypeActions ],\n\t\t[ postTypeActions, editAction ]\n\t);\n\n\tconst onChangeView = useCallback(\n\t\t( newView ) => {\n\t\t\tif ( newView.type !== view.type ) {\n\t\t\t\thistory.push( {\n\t\t\t\t\t...params,\n\t\t\t\t\tlayout: newView.type,\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\tsetView( newView );\n\t\t},\n\t\t[ view.type, setView, history, params ]\n\t);\n\n\treturn (\n\t\t<Page\n\t\t\tclassName=\"edit-site-page-templates\"\n\t\t\ttitle={ __( 'Templates' ) }\n\t\t\tactions={ <AddNewTemplate /> }\n\t\t>\n\t\t\t<DataViews\n\t\t\t\tpaginationInfo={ paginationInfo }\n\t\t\t\tfields={ fields }\n\t\t\t\tactions={ actions }\n\t\t\t\tdata={ data }\n\t\t\t\tisLoading={ isLoadingData }\n\t\t\t\tview={ view }\n\t\t\t\tonChangeView={ onChangeView }\n\t\t\t\tonChangeSelection={ onChangeSelection }\n\t\t\t\tselection={ selection }\n\t\t\t\tdefaultLayouts={ defaultLayouts }\n\t\t\t/>\n\t\t</Page>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE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GAAG,IAAA7D,gBAAO,EACtB,MAAM,CAAE2D,UAAU,EAAE,GAAGF,eAAe,CAAE,EACxC,CAAEA,eAAe,EAAEE,UAAU,CAC9B,CAAC;EAED,MAAMG,YAAY,GAAG,IAAA5B,oBAAW,EAC7B6B,OAAO,IAAM;IACd,IAAKA,OAAO,CAACzG,IAAI,KAAK+D,IAAI,CAAC/D,IAAI,EAAG;MACjC0E,OAAO,CAACI,IAAI,CAAE;QACb,GAAGhE,MAAM;QACTlC,MAAM,EAAE6H,OAAO,CAACzG;MACjB,CAAE,CAAC;IACJ;IAEAgE,OAAO,CAAEyC,OAAQ,CAAC;EACnB,CAAC,EACD,CAAE1C,IAAI,CAAC/D,IAAI,EAAEgE,OAAO,EAAEU,OAAO,EAAE5D,MAAM,CACtC,CAAC;EAED,oBACC,IAAAnE,WAAA,CAAAuE,GAAA,EAAChF,KAAA,CAAAgB,OAAI;IACJ6E,SAAS,EAAC,0BAA0B;IACpCpB,KAAK,EAAG,IAAA1B,QAAE,EAAE,WAAY,CAAG;IAC3BsH,OAAO,eAAG,IAAA5J,WAAA,CAAAuE,GAAA,EAAC7E,eAAA,CAAAa,OAAc,IAAE,CAAG;IAAAgC,QAAA,eAE9B,IAAAvC,WAAA,CAAAuE,GAAA,EAACpF,UAAA,CAAA4K,SAAS;MACTT,cAAc,EAAGA,cAAgB;MACjCtH,MAAM,EAAGA,MAAQ;MACjB4H,OAAO,EAAGA,OAAS;MACnBP,IAAI,EAAGA,IAAM;MACbW,SAAS,EAAGrC,aAAe;MAC3BP,IAAI,EAAGA,IAAM;MACbyC,YAAY,EAAGA,YAAc;MAC7B7B,iBAAiB,EAAGA,iBAAmB;MACvClB,SAAS,EAAGA,SAAW;MACvBhF,cAAc,EAAGA;IAAgB,CACjC;EAAC,CACG,CAAC;AAET","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_i18n","require","_element","_coreData","_dataviews","_router","_editor","_page","_interopRequireDefault","_addNewTemplate","_constants","_lockUnlock","_dataviewsActions","_fields","_jsxRuntime","usePostActions","unlock","editorPrivateApis","useHistory","useLocation","routerPrivateApis","useEntityRecordsWithPermissions","corePrivateApis","EMPTY_ARRAY","defaultLayouts","LAYOUT_TABLE","fields","layout","primaryField","combinedFields","id","label","__","children","direction","styles","template","maxWidth","minWidth","preview","width","author","LAYOUT_GRID","mediaField","columnFields","LAYOUT_LIST","DEFAULT_VIEW","type","search","page","perPage","sort","field","filters","PageTemplates","params","activeView","postId","selection","setSelection","useState","defaultView","useMemo","usedType","operator","value","view","setView","useEffect","currentView","OPERATOR_IS_ANY","records","isResolving","isLoadingData","TEMPLATE_POST_TYPE","per_page","history","onChangeSelection","useCallback","items","push","length","undefined","authors","authorsSet","Set","forEach","add","author_text","Array","from","map","previewField","titleField","descriptionField","authorField","elements","data","paginationInfo","filterSortAndPaginate","postTypeActions","postType","context","editAction","useEditPostAction","actions","onChangeView","newView","jsx","default","className","title","DataViews","isLoading"],"sources":["@wordpress/edit-site/src/components/page-templates/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useState, useMemo, useCallback, useEffect } from '@wordpress/element';\nimport { privateApis as corePrivateApis } from '@wordpress/core-data';\nimport { DataViews, filterSortAndPaginate } from '@wordpress/dataviews';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\nimport { privateApis as editorPrivateApis } from '@wordpress/editor';\n\n/**\n * Internal dependencies\n */\nimport Page from '../page';\nimport AddNewTemplate from '../add-new-template';\nimport {\n\tTEMPLATE_POST_TYPE,\n\tOPERATOR_IS_ANY,\n\tLAYOUT_GRID,\n\tLAYOUT_TABLE,\n\tLAYOUT_LIST,\n} from '../../utils/constants';\nimport { unlock } from '../../lock-unlock';\nimport { useEditPostAction } from '../dataviews-actions';\nimport {\n\tauthorField,\n\tdescriptionField,\n\tpreviewField,\n\ttitleField,\n} from './fields';\n\nconst { usePostActions } = unlock( editorPrivateApis );\nconst { useHistory, useLocation } = unlock( routerPrivateApis );\nconst { useEntityRecordsWithPermissions } = unlock( corePrivateApis );\n\nconst EMPTY_ARRAY = [];\n\nconst defaultLayouts = {\n\t[ LAYOUT_TABLE ]: {\n\t\tfields: [ 'template', 'author' ],\n\t\tlayout: {\n\t\t\tprimaryField: 'title',\n\t\t\tcombinedFields: [\n\t\t\t\t{\n\t\t\t\t\tid: 'template',\n\t\t\t\t\tlabel: __( 'Template' ),\n\t\t\t\t\tchildren: [ 'title', 'description' ],\n\t\t\t\t\tdirection: 'vertical',\n\t\t\t\t},\n\t\t\t],\n\t\t\tstyles: {\n\t\t\t\ttemplate: {\n\t\t\t\t\tmaxWidth: 400,\n\t\t\t\t\tminWidth: 320,\n\t\t\t\t},\n\t\t\t\tpreview: {\n\t\t\t\t\twidth: '1%',\n\t\t\t\t},\n\t\t\t\tauthor: {\n\t\t\t\t\twidth: '1%',\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t},\n\t[ LAYOUT_GRID ]: {\n\t\tfields: [ 'title', 'description', 'author' ],\n\t\tlayout: {\n\t\t\tmediaField: 'preview',\n\t\t\tprimaryField: 'title',\n\t\t\tcolumnFields: [ 'description' ],\n\t\t},\n\t},\n\t[ LAYOUT_LIST ]: {\n\t\tfields: [ 'title', 'description', 'author' ],\n\t\tlayout: {\n\t\t\tprimaryField: 'title',\n\t\t\tmediaField: 'preview',\n\t\t},\n\t},\n};\n\nconst DEFAULT_VIEW = {\n\ttype: LAYOUT_GRID,\n\tsearch: '',\n\tpage: 1,\n\tperPage: 20,\n\tsort: {\n\t\tfield: 'title',\n\t\tdirection: 'asc',\n\t},\n\tfields: defaultLayouts[ LAYOUT_GRID ].fields,\n\tlayout: defaultLayouts[ LAYOUT_GRID ].layout,\n\tfilters: [],\n};\n\nexport default function PageTemplates() {\n\tconst { params } = useLocation();\n\tconst { activeView = 'all', layout, postId } = params;\n\tconst [ selection, setSelection ] = useState( [ postId ] );\n\n\tconst defaultView = useMemo( () => {\n\t\tconst usedType = layout ?? DEFAULT_VIEW.type;\n\t\treturn {\n\t\t\t...DEFAULT_VIEW,\n\t\t\ttype: usedType,\n\t\t\tlayout: defaultLayouts[ usedType ].layout,\n\t\t\tfields: defaultLayouts[ usedType ].fields,\n\t\t\tfilters:\n\t\t\t\tactiveView !== 'all'\n\t\t\t\t\t? [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tfield: 'author',\n\t\t\t\t\t\t\t\toperator: 'isAny',\n\t\t\t\t\t\t\t\tvalue: [ activeView ],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t ]\n\t\t\t\t\t: [],\n\t\t};\n\t}, [ layout, activeView ] );\n\tconst [ view, setView ] = useState( defaultView );\n\tuseEffect( () => {\n\t\tsetView( ( currentView ) => ( {\n\t\t\t...currentView,\n\t\t\tfilters:\n\t\t\t\tactiveView !== 'all'\n\t\t\t\t\t? [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tfield: 'author',\n\t\t\t\t\t\t\t\toperator: OPERATOR_IS_ANY,\n\t\t\t\t\t\t\t\tvalue: [ activeView ],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t ]\n\t\t\t\t\t: [],\n\t\t} ) );\n\t}, [ activeView ] );\n\n\tconst { records, isResolving: isLoadingData } =\n\t\tuseEntityRecordsWithPermissions( 'postType', TEMPLATE_POST_TYPE, {\n\t\t\tper_page: -1,\n\t\t} );\n\tconst history = useHistory();\n\tconst onChangeSelection = useCallback(\n\t\t( items ) => {\n\t\t\tsetSelection( items );\n\t\t\tif ( view?.type === LAYOUT_LIST ) {\n\t\t\t\thistory.push( {\n\t\t\t\t\t...params,\n\t\t\t\t\tpostId: items.length === 1 ? items[ 0 ] : undefined,\n\t\t\t\t} );\n\t\t\t}\n\t\t},\n\t\t[ history, params, view?.type ]\n\t);\n\n\tconst authors = useMemo( () => {\n\t\tif ( ! records ) {\n\t\t\treturn EMPTY_ARRAY;\n\t\t}\n\t\tconst authorsSet = new Set();\n\t\trecords.forEach( ( template ) => {\n\t\t\tauthorsSet.add( template.author_text );\n\t\t} );\n\t\treturn Array.from( authorsSet ).map( ( author ) => ( {\n\t\t\tvalue: author,\n\t\t\tlabel: author,\n\t\t} ) );\n\t}, [ records ] );\n\n\tconst fields = useMemo(\n\t\t() => [\n\t\t\tpreviewField,\n\t\t\ttitleField,\n\t\t\tdescriptionField,\n\t\t\t{\n\t\t\t\t...authorField,\n\t\t\t\telements: authors,\n\t\t\t},\n\t\t],\n\t\t[ authors ]\n\t);\n\n\tconst { data, paginationInfo } = useMemo( () => {\n\t\treturn filterSortAndPaginate( records, view, fields );\n\t}, [ records, view, fields ] );\n\n\tconst postTypeActions = usePostActions( {\n\t\tpostType: TEMPLATE_POST_TYPE,\n\t\tcontext: 'list',\n\t} );\n\tconst editAction = useEditPostAction();\n\tconst actions = useMemo(\n\t\t() => [ editAction, ...postTypeActions ],\n\t\t[ postTypeActions, editAction ]\n\t);\n\n\tconst onChangeView = useCallback(\n\t\t( newView ) => {\n\t\t\tif ( newView.type !== view.type ) {\n\t\t\t\thistory.push( {\n\t\t\t\t\t...params,\n\t\t\t\t\tlayout: newView.type,\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\tsetView( newView );\n\t\t},\n\t\t[ view.type, setView, history, params ]\n\t);\n\n\treturn (\n\t\t<Page\n\t\t\tclassName=\"edit-site-page-templates\"\n\t\t\ttitle={ __( 'Templates' ) }\n\t\t\tactions={ <AddNewTemplate /> }\n\t\t>\n\t\t\t<DataViews\n\t\t\t\tkey={ activeView }\n\t\t\t\tpaginationInfo={ paginationInfo }\n\t\t\t\tfields={ fields }\n\t\t\t\tactions={ actions }\n\t\t\t\tdata={ data }\n\t\t\t\tisLoading={ isLoadingData }\n\t\t\t\tview={ view }\n\t\t\t\tonChangeView={ onChangeView }\n\t\t\t\tonChangeSelection={ onChangeSelection }\n\t\t\t\tselection={ selection }\n\t\t\t\tdefaultLayouts={ defaultLayouts }\n\t\t\t/>\n\t\t</Page>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,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'panel',
|
|
52
|
+
fields: ['title', 'author']
|
|
52
53
|
};
|
|
53
54
|
const [edits, setEdits] = (0, _element.useState)({});
|
|
54
55
|
const itemWithEdits = (0, _element.useMemo)(() => {
|
|
@@ -59,6 +60,9 @@ function PostEditForm({
|
|
|
59
60
|
}, [initialEdits, edits]);
|
|
60
61
|
const onSubmit = async event => {
|
|
61
62
|
event.preventDefault();
|
|
63
|
+
if (!(0, _dataviews.isItemValid)(itemWithEdits, fields, form)) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
62
66
|
const {
|
|
63
67
|
getEntityRecord
|
|
64
68
|
} = registry.resolveSelect(_coreData.store);
|
|
@@ -71,17 +75,25 @@ function PostEditForm({
|
|
|
71
75
|
}
|
|
72
76
|
setEdits({});
|
|
73
77
|
};
|
|
74
|
-
|
|
78
|
+
const isUpdateDisabled = !(0, _dataviews.isItemValid)(itemWithEdits, fields, form);
|
|
79
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.__experimentalVStack, {
|
|
80
|
+
as: "form",
|
|
75
81
|
onSubmit: onSubmit,
|
|
82
|
+
spacing: 4,
|
|
76
83
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_dataviews.DataForm, {
|
|
77
84
|
data: itemWithEdits,
|
|
78
85
|
fields: fields,
|
|
79
86
|
form: form,
|
|
80
87
|
onChange: setEdits
|
|
81
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
88
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.FlexItem, {
|
|
89
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button, {
|
|
90
|
+
variant: "primary",
|
|
91
|
+
type: "submit",
|
|
92
|
+
accessibleWhenDisabled: true,
|
|
93
|
+
disabled: isUpdateDisabled,
|
|
94
|
+
__next40pxDefaultSize: true,
|
|
95
|
+
children: (0, _i18n.__)('Update')
|
|
96
|
+
})
|
|
85
97
|
})]
|
|
86
98
|
});
|
|
87
99
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_clsx","_interopRequireDefault","require","_i18n","_dataviews","_data","_coreData","_components","_element","_page","_postFields","_jsxRuntime","PostEditForm","postType","postId","ids","useMemo","split","initialEdits","useSelect","select","length","coreDataStore","getEntityRecord","registry","useRegistry","saveEntityRecord","useDispatch","fields","usePostFields","form","
|
|
1
|
+
{"version":3,"names":["_clsx","_interopRequireDefault","require","_i18n","_dataviews","_data","_coreData","_components","_element","_page","_postFields","_jsxRuntime","PostEditForm","postType","postId","ids","useMemo","split","initialEdits","useSelect","select","length","coreDataStore","getEntityRecord","registry","useRegistry","saveEntityRecord","useDispatch","fields","usePostFields","form","type","edits","setEdits","useState","itemWithEdits","onSubmit","event","preventDefault","isItemValid","resolveSelect","id","item","isUpdateDisabled","jsxs","__experimentalVStack","as","spacing","children","jsx","DataForm","data","onChange","FlexItem","Button","variant","accessibleWhenDisabled","disabled","__next40pxDefaultSize","__","PostEdit","default","className","clsx","label"],"sources":["@wordpress/edit-site/src/components/post-edit/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { DataForm, isItemValid } from '@wordpress/dataviews';\nimport { useDispatch, useSelect, useRegistry } from '@wordpress/data';\nimport { store as coreDataStore } from '@wordpress/core-data';\nimport {\n\tButton,\n\tFlexItem,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { useState, useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport Page from '../page';\nimport usePostFields from '../post-fields';\n\nfunction PostEditForm( { postType, postId } ) {\n\tconst ids = useMemo( () => postId.split( ',' ), [ postId ] );\n\tconst { initialEdits } = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ids.length !== 1 ) {\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tinitialEdits:\n\t\t\t\t\tids.length === 1\n\t\t\t\t\t\t? select( coreDataStore ).getEntityRecord(\n\t\t\t\t\t\t\t\t'postType',\n\t\t\t\t\t\t\t\tpostType,\n\t\t\t\t\t\t\t\tids[ 0 ]\n\t\t\t\t\t\t )\n\t\t\t\t\t\t: null,\n\t\t\t};\n\t\t},\n\t\t[ postType, ids ]\n\t);\n\tconst registry = useRegistry();\n\tconst { saveEntityRecord } = useDispatch( coreDataStore );\n\tconst { fields } = usePostFields();\n\tconst form = {\n\t\ttype: 'panel',\n\t\tfields: [ 'title', 'author' ],\n\t};\n\tconst [ edits, setEdits ] = useState( {} );\n\tconst itemWithEdits = useMemo( () => {\n\t\treturn {\n\t\t\t...initialEdits,\n\t\t\t...edits,\n\t\t};\n\t}, [ initialEdits, edits ] );\n\tconst onSubmit = async ( event ) => {\n\t\tevent.preventDefault();\n\n\t\tif ( ! isItemValid( itemWithEdits, fields, form ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { getEntityRecord } = registry.resolveSelect( coreDataStore );\n\t\tfor ( const id of ids ) {\n\t\t\tconst item = await getEntityRecord( 'postType', postType, id );\n\t\t\tsaveEntityRecord( 'postType', postType, {\n\t\t\t\t...item,\n\t\t\t\t...edits,\n\t\t\t} );\n\t\t}\n\t\tsetEdits( {} );\n\t};\n\n\tconst isUpdateDisabled = ! isItemValid( itemWithEdits, fields, form );\n\treturn (\n\t\t<VStack as=\"form\" onSubmit={ onSubmit } spacing={ 4 }>\n\t\t\t<DataForm\n\t\t\t\tdata={ itemWithEdits }\n\t\t\t\tfields={ fields }\n\t\t\t\tform={ form }\n\t\t\t\tonChange={ setEdits }\n\t\t\t/>\n\t\t\t<FlexItem>\n\t\t\t\t<Button\n\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\ttype=\"submit\"\n\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\tdisabled={ isUpdateDisabled }\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Update' ) }\n\t\t\t\t</Button>\n\t\t\t</FlexItem>\n\t\t</VStack>\n\t);\n}\n\nexport function PostEdit( { postType, postId } ) {\n\treturn (\n\t\t<Page\n\t\t\tclassName={ clsx( 'edit-site-post-edit', {\n\t\t\t\t'is-empty': ! postId,\n\t\t\t} ) }\n\t\t\tlabel={ __( 'Post Edit' ) }\n\t\t>\n\t\t\t{ postId && (\n\t\t\t\t<PostEditForm postType={ postType } postId={ postId } />\n\t\t\t) }\n\t\t\t{ ! postId && <p>{ __( 'Select a page to edit' ) }</p> }\n\t\t</Page>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,UAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,SAAA,GAAAJ,OAAA;AACA,IAAAK,WAAA,GAAAL,OAAA;AAKA,IAAAM,QAAA,GAAAN,OAAA;AAKA,IAAAO,KAAA,GAAAR,sBAAA,CAAAC,OAAA;AACA,IAAAQ,WAAA,GAAAT,sBAAA,CAAAC,OAAA;AAA2C,IAAAS,WAAA,GAAAT,OAAA;AAvB3C;AACA;AACA;;AAGA;AACA;AACA;;AAYA;AACA;AACA;;AAIA,SAASU,YAAYA,CAAE;EAAEC,QAAQ;EAAEC;AAAO,CAAC,EAAG;EAC7C,MAAMC,GAAG,GAAG,IAAAC,gBAAO,EAAE,MAAMF,MAAM,CAACG,KAAK,CAAE,GAAI,CAAC,EAAE,CAAEH,MAAM,CAAG,CAAC;EAC5D,MAAM;IAAEI;EAAa,CAAC,GAAG,IAAAC,eAAS,EAC/BC,MAAM,IAAM;IACb,IAAKL,GAAG,CAACM,MAAM,KAAK,CAAC,EAAG,CACxB;IACA,OAAO;MACNH,YAAY,EACXH,GAAG,CAACM,MAAM,KAAK,CAAC,GACbD,MAAM,CAAEE,eAAc,CAAC,CAACC,eAAe,CACvC,UAAU,EACVV,QAAQ,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