@wordpress/edit-site 3.0.10 → 3.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/components/add-new-template/new-template-part.js +34 -18
- package/build/components/add-new-template/new-template-part.js.map +1 -1
- package/build/components/add-new-template/new-template.js +41 -23
- package/build/components/add-new-template/new-template.js.map +1 -1
- package/build/components/block-editor/index.js +3 -1
- package/build/components/block-editor/index.js.map +1 -1
- package/build/components/editor/index.js +12 -6
- package/build/components/editor/index.js.map +1 -1
- package/build/components/global-styles/color-palette-panel.js +29 -6
- package/build/components/global-styles/color-palette-panel.js.map +1 -1
- package/build/components/global-styles/global-styles-provider.js +5 -43
- package/build/components/global-styles/global-styles-provider.js.map +1 -1
- package/build/components/global-styles/gradients-palette-panel.js +71 -0
- package/build/components/global-styles/gradients-palette-panel.js.map +1 -0
- package/build/components/global-styles/hooks.js +5 -5
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/palette.js +11 -5
- package/build/components/global-styles/palette.js.map +1 -1
- package/build/components/global-styles/screen-background-color.js +3 -1
- package/build/components/global-styles/screen-background-color.js.map +1 -1
- package/build/components/global-styles/screen-color-palette.js +23 -3
- package/build/components/global-styles/screen-color-palette.js.map +1 -1
- package/build/components/global-styles/screen-link-color.js +3 -1
- package/build/components/global-styles/screen-link-color.js.map +1 -1
- package/build/components/global-styles/screen-text-color.js +3 -1
- package/build/components/global-styles/screen-text-color.js.map +1 -1
- package/build/components/global-styles/screen-typography-element.js +54 -0
- package/build/components/global-styles/screen-typography-element.js.map +1 -0
- package/build/components/global-styles/screen-typography.js +74 -6
- package/build/components/global-styles/screen-typography.js.map +1 -1
- package/build/components/global-styles/typography-panel.js +28 -8
- package/build/components/global-styles/typography-panel.js.map +1 -1
- package/build/components/global-styles/ui.js +12 -0
- package/build/components/global-styles/ui.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js +2 -2
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/global-styles/utils.js +1 -1
- package/build/components/global-styles/utils.js.map +1 -1
- package/build/components/keyboard-shortcuts/index.js +26 -0
- package/build/components/keyboard-shortcuts/index.js.map +1 -1
- package/build/components/list/actions/index.js +104 -0
- package/build/components/list/actions/index.js.map +1 -0
- package/build/components/list/actions/rename-menu-item.js +112 -0
- package/build/components/list/actions/rename-menu-item.js.map +1 -0
- package/build/components/list/added-by.js +180 -0
- package/build/components/list/added-by.js.map +1 -0
- package/build/components/list/index.js +54 -7
- package/build/components/list/index.js.map +1 -1
- package/build/components/list/table.js +58 -68
- package/build/components/list/table.js.map +1 -1
- package/build/components/list/use-register-shortcuts.js +52 -0
- package/build/components/list/use-register-shortcuts.js.map +1 -0
- package/build/components/navigation-sidebar/index.js +24 -9
- package/build/components/navigation-sidebar/index.js.map +1 -1
- package/build/components/navigation-sidebar/navigation-panel/index.js +35 -17
- package/build/components/navigation-sidebar/navigation-panel/index.js.map +1 -1
- package/build/components/navigation-sidebar/navigation-toggle/index.js +14 -5
- package/build/components/navigation-sidebar/navigation-toggle/index.js.map +1 -1
- package/build/components/template-details/edit-template-title.js +33 -0
- package/build/components/template-details/edit-template-title.js.map +1 -0
- package/build/components/template-details/index.js +8 -4
- package/build/components/template-details/index.js.map +1 -1
- package/build/components/template-details/template-areas.js +1 -1
- package/build/components/template-details/template-areas.js.map +1 -1
- package/build/index.js +8 -2
- package/build/index.js.map +1 -1
- package/build/store/actions.js +47 -18
- package/build/store/actions.js.map +1 -1
- package/build/store/selectors.js +25 -5
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/add-new-template/new-template-part.js +30 -17
- package/build-module/components/add-new-template/new-template-part.js.map +1 -1
- package/build-module/components/add-new-template/new-template.js +40 -24
- package/build-module/components/add-new-template/new-template.js.map +1 -1
- package/build-module/components/block-editor/index.js +2 -1
- package/build-module/components/block-editor/index.js.map +1 -1
- package/build-module/components/editor/index.js +13 -7
- package/build-module/components/editor/index.js.map +1 -1
- package/build-module/components/global-styles/color-palette-panel.js +29 -7
- package/build-module/components/global-styles/color-palette-panel.js.map +1 -1
- package/build-module/components/global-styles/global-styles-provider.js +6 -39
- package/build-module/components/global-styles/global-styles-provider.js.map +1 -1
- package/build-module/components/global-styles/gradients-palette-panel.js +60 -0
- package/build-module/components/global-styles/gradients-palette-panel.js.map +1 -0
- package/build-module/components/global-styles/hooks.js +5 -5
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/global-styles/palette.js +12 -5
- package/build-module/components/global-styles/palette.js.map +1 -1
- package/build-module/components/global-styles/screen-background-color.js +3 -1
- package/build-module/components/global-styles/screen-background-color.js.map +1 -1
- package/build-module/components/global-styles/screen-color-palette.js +22 -3
- package/build-module/components/global-styles/screen-color-palette.js.map +1 -1
- package/build-module/components/global-styles/screen-link-color.js +3 -1
- package/build-module/components/global-styles/screen-link-color.js.map +1 -1
- package/build-module/components/global-styles/screen-text-color.js +3 -1
- package/build-module/components/global-styles/screen-text-color.js.map +1 -1
- package/build-module/components/global-styles/screen-typography-element.js +41 -0
- package/build-module/components/global-styles/screen-typography-element.js.map +1 -0
- package/build-module/components/global-styles/screen-typography.js +70 -6
- package/build-module/components/global-styles/screen-typography.js.map +1 -1
- package/build-module/components/global-styles/typography-panel.js +28 -8
- package/build-module/components/global-styles/typography-panel.js.map +1 -1
- package/build-module/components/global-styles/ui.js +11 -0
- package/build-module/components/global-styles/ui.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js +2 -2
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/global-styles/utils.js +1 -1
- package/build-module/components/global-styles/utils.js.map +1 -1
- package/build-module/components/keyboard-shortcuts/index.js +26 -0
- package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
- package/build-module/components/list/actions/index.js +85 -0
- package/build-module/components/list/actions/index.js.map +1 -0
- package/build-module/components/list/actions/rename-menu-item.js +101 -0
- package/build-module/components/list/actions/rename-menu-item.js.map +1 -0
- package/build-module/components/list/added-by.js +166 -0
- package/build-module/components/list/added-by.js.map +1 -0
- package/build-module/components/list/index.js +49 -8
- package/build-module/components/list/index.js.map +1 -1
- package/build-module/components/list/table.js +60 -70
- package/build-module/components/list/table.js.map +1 -1
- package/build-module/components/list/use-register-shortcuts.js +41 -0
- package/build-module/components/list/use-register-shortcuts.js.map +1 -0
- package/build-module/components/navigation-sidebar/index.js +22 -10
- package/build-module/components/navigation-sidebar/index.js.map +1 -1
- package/build-module/components/navigation-sidebar/navigation-panel/index.js +33 -18
- package/build-module/components/navigation-sidebar/navigation-panel/index.js.map +1 -1
- package/build-module/components/navigation-sidebar/navigation-toggle/index.js +14 -6
- package/build-module/components/navigation-sidebar/navigation-toggle/index.js.map +1 -1
- package/build-module/components/template-details/edit-template-title.js +23 -0
- package/build-module/components/template-details/edit-template-title.js.map +1 -0
- package/build-module/components/template-details/index.js +7 -4
- package/build-module/components/template-details/index.js.map +1 -1
- package/build-module/components/template-details/template-areas.js +1 -1
- package/build-module/components/template-details/template-areas.js.map +1 -1
- package/build-module/index.js +8 -3
- package/build-module/index.js.map +1 -1
- package/build-module/store/actions.js +48 -19
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/selectors.js +21 -3
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +146 -21
- package/build-style/style.css +146 -21
- package/package.json +10 -8
- package/src/components/add-new-template/new-template-part.js +32 -18
- package/src/components/add-new-template/new-template.js +39 -20
- package/src/components/block-editor/index.js +2 -0
- package/src/components/editor/index.js +17 -6
- package/src/components/global-styles/color-palette-panel.js +64 -7
- package/src/components/global-styles/global-styles-provider.js +3 -33
- package/src/components/global-styles/gradients-palette-panel.js +99 -0
- package/src/components/global-styles/hooks.js +4 -4
- package/src/components/global-styles/palette.js +30 -10
- package/src/components/global-styles/screen-background-color.js +2 -0
- package/src/components/global-styles/screen-color-palette.js +30 -3
- package/src/components/global-styles/screen-link-color.js +2 -0
- package/src/components/global-styles/screen-text-color.js +2 -0
- package/src/components/global-styles/screen-typography-element.js +39 -0
- package/src/components/global-styles/screen-typography.js +84 -3
- package/src/components/global-styles/style.scss +45 -6
- package/src/components/global-styles/test/use-global-styles-output.js +1 -1
- package/src/components/global-styles/test/utils.js +1 -1
- package/src/components/global-styles/typography-panel.js +37 -7
- package/src/components/global-styles/ui.js +9 -0
- package/src/components/global-styles/use-global-styles-output.js +2 -2
- package/src/components/global-styles/utils.js +1 -1
- package/src/components/keyboard-shortcuts/index.js +32 -0
- package/src/components/list/actions/index.js +95 -0
- package/src/components/list/actions/rename-menu-item.js +134 -0
- package/src/components/list/added-by.js +179 -0
- package/src/components/list/index.js +63 -5
- package/src/components/list/style.scss +106 -11
- package/src/components/list/table.js +65 -76
- package/src/components/list/use-register-shortcuts.js +45 -0
- package/src/components/navigation-sidebar/index.js +21 -12
- package/src/components/navigation-sidebar/navigation-panel/index.js +32 -15
- package/src/components/navigation-sidebar/navigation-toggle/index.js +29 -17
- package/src/components/navigation-sidebar/navigation-toggle/test/index.js +2 -0
- package/src/components/sidebar/style.scss +2 -1
- package/src/components/template-details/edit-template-title.js +28 -0
- package/src/components/template-details/index.js +15 -10
- package/src/components/template-details/template-areas.js +1 -1
- package/src/index.js +10 -2
- package/src/store/actions.js +82 -34
- package/src/store/selectors.js +22 -4
- package/src/store/test/actions.js +0 -24
- package/src/store/test/selectors.js +24 -0
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { createElement } from "@wordpress/element";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* External dependencies
|
|
5
|
+
*/
|
|
6
|
+
import classnames from 'classnames';
|
|
7
|
+
/**
|
|
8
|
+
* WordPress dependencies
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { __experimentalHStack as HStack, Icon, Tooltip } from '@wordpress/components';
|
|
12
|
+
import { store as coreStore } from '@wordpress/core-data';
|
|
13
|
+
import { useSelect } from '@wordpress/data';
|
|
14
|
+
import { useState } from '@wordpress/element';
|
|
15
|
+
import { layout as themeIcon, plugins as pluginIcon } from '@wordpress/icons';
|
|
16
|
+
import { __ } from '@wordpress/i18n';
|
|
17
|
+
const TEMPLATE_POST_TYPE_NAMES = ['wp_template', 'wp_template_part'];
|
|
18
|
+
|
|
19
|
+
function CustomizedTooltip(_ref) {
|
|
20
|
+
let {
|
|
21
|
+
isCustomized,
|
|
22
|
+
children
|
|
23
|
+
} = _ref;
|
|
24
|
+
|
|
25
|
+
if (!isCustomized) {
|
|
26
|
+
return children;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return createElement(Tooltip, {
|
|
30
|
+
text: __('This template has been customized')
|
|
31
|
+
}, children);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function AddedByTheme(_ref2) {
|
|
35
|
+
var _theme$name;
|
|
36
|
+
|
|
37
|
+
let {
|
|
38
|
+
slug,
|
|
39
|
+
isCustomized
|
|
40
|
+
} = _ref2;
|
|
41
|
+
const theme = useSelect(select => select(coreStore).getTheme(slug), [slug]);
|
|
42
|
+
return createElement(HStack, {
|
|
43
|
+
alignment: "left"
|
|
44
|
+
}, createElement(CustomizedTooltip, {
|
|
45
|
+
isCustomized: isCustomized
|
|
46
|
+
}, createElement("div", {
|
|
47
|
+
className: classnames('edit-site-list-added-by__icon', {
|
|
48
|
+
'is-customized': isCustomized
|
|
49
|
+
})
|
|
50
|
+
}, createElement(Icon, {
|
|
51
|
+
icon: themeIcon
|
|
52
|
+
}))), createElement("span", null, (theme === null || theme === void 0 ? void 0 : (_theme$name = theme.name) === null || _theme$name === void 0 ? void 0 : _theme$name.rendered) || slug));
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function AddedByPlugin(_ref3) {
|
|
56
|
+
let {
|
|
57
|
+
slug,
|
|
58
|
+
isCustomized
|
|
59
|
+
} = _ref3;
|
|
60
|
+
const plugin = useSelect(select => select(coreStore).getPlugin(slug), [slug]);
|
|
61
|
+
return createElement(HStack, {
|
|
62
|
+
alignment: "left"
|
|
63
|
+
}, createElement(CustomizedTooltip, {
|
|
64
|
+
isCustomized: isCustomized
|
|
65
|
+
}, createElement("div", {
|
|
66
|
+
className: "edit-site-list-added-by__icon"
|
|
67
|
+
}, createElement(Icon, {
|
|
68
|
+
icon: pluginIcon
|
|
69
|
+
}))), createElement("span", null, (plugin === null || plugin === void 0 ? void 0 : plugin.name) || slug));
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function AddedByAuthor(_ref4) {
|
|
73
|
+
let {
|
|
74
|
+
id
|
|
75
|
+
} = _ref4;
|
|
76
|
+
const user = useSelect(select => select(coreStore).getUser(id), [id]);
|
|
77
|
+
const [isImageLoaded, setIsImageLoaded] = useState(false);
|
|
78
|
+
return createElement(HStack, {
|
|
79
|
+
alignment: "left"
|
|
80
|
+
}, createElement("div", {
|
|
81
|
+
className: classnames('edit-site-list-added-by__avatar', {
|
|
82
|
+
'is-loaded': isImageLoaded
|
|
83
|
+
})
|
|
84
|
+
}, createElement("img", {
|
|
85
|
+
onLoad: () => setIsImageLoaded(true),
|
|
86
|
+
alt: "",
|
|
87
|
+
src: user === null || user === void 0 ? void 0 : user.avatar_urls[48]
|
|
88
|
+
})), createElement("span", null, user === null || user === void 0 ? void 0 : user.nickname));
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function AddedBySite() {
|
|
92
|
+
const {
|
|
93
|
+
name,
|
|
94
|
+
logoURL
|
|
95
|
+
} = useSelect(select => {
|
|
96
|
+
var _getMedia;
|
|
97
|
+
|
|
98
|
+
const {
|
|
99
|
+
getEntityRecord,
|
|
100
|
+
getMedia
|
|
101
|
+
} = select(coreStore);
|
|
102
|
+
const siteData = getEntityRecord('root', '__unstableBase');
|
|
103
|
+
return {
|
|
104
|
+
name: siteData.name,
|
|
105
|
+
logoURL: siteData !== null && siteData !== void 0 && siteData.site_logo ? (_getMedia = getMedia(siteData.site_logo)) === null || _getMedia === void 0 ? void 0 : _getMedia.source_url : undefined
|
|
106
|
+
};
|
|
107
|
+
}, []);
|
|
108
|
+
const [isImageLoaded, setIsImageLoaded] = useState(false);
|
|
109
|
+
return createElement(HStack, {
|
|
110
|
+
alignment: "left"
|
|
111
|
+
}, createElement("div", {
|
|
112
|
+
className: classnames('edit-site-list-added-by__avatar', {
|
|
113
|
+
'is-loaded': isImageLoaded
|
|
114
|
+
})
|
|
115
|
+
}, createElement("img", {
|
|
116
|
+
onLoad: () => setIsImageLoaded(true),
|
|
117
|
+
alt: "",
|
|
118
|
+
src: logoURL
|
|
119
|
+
})), createElement("span", null, name));
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export default function AddedBy(_ref5) {
|
|
123
|
+
let {
|
|
124
|
+
templateType,
|
|
125
|
+
template
|
|
126
|
+
} = _ref5;
|
|
127
|
+
|
|
128
|
+
if (!template) {
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
if (TEMPLATE_POST_TYPE_NAMES.includes(templateType)) {
|
|
133
|
+
// Template originally provided by a theme, but customized by a user.
|
|
134
|
+
// Templates originally didn't have the 'origin' field so identify
|
|
135
|
+
// older customized templates by checking for no origin and a 'theme'
|
|
136
|
+
// or 'custom' source.
|
|
137
|
+
if (template.has_theme_file && (template.origin === 'theme' || !template.origin && ['theme', 'custom'].includes(template.source))) {
|
|
138
|
+
return createElement(AddedByTheme, {
|
|
139
|
+
slug: template.theme,
|
|
140
|
+
isCustomized: template.source === 'custom'
|
|
141
|
+
});
|
|
142
|
+
} // Template originally provided by a plugin, but customized by a user.
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
if (template.has_theme_file && template.origin === 'plugin') {
|
|
146
|
+
return createElement(AddedByPlugin, {
|
|
147
|
+
slug: template.theme,
|
|
148
|
+
isCustomized: template.source === 'custom'
|
|
149
|
+
});
|
|
150
|
+
} // Template was created from scratch, but has no author. Author support
|
|
151
|
+
// was only added to templates in WordPress 5.9. Fallback to showing the
|
|
152
|
+
// site logo and title.
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
if (!template.has_theme_file && template.source === 'custom' && !template.author) {
|
|
156
|
+
return createElement(AddedBySite, null);
|
|
157
|
+
}
|
|
158
|
+
} // Simply show the author for templates created from scratch that have an
|
|
159
|
+
// author or for any other post type.
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
return createElement(AddedByAuthor, {
|
|
163
|
+
id: template.author
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
//# sourceMappingURL=added-by.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/list/added-by.js"],"names":["classnames","__experimentalHStack","HStack","Icon","Tooltip","store","coreStore","useSelect","useState","layout","themeIcon","plugins","pluginIcon","__","TEMPLATE_POST_TYPE_NAMES","CustomizedTooltip","isCustomized","children","AddedByTheme","slug","theme","select","getTheme","name","rendered","AddedByPlugin","plugin","getPlugin","AddedByAuthor","id","user","getUser","isImageLoaded","setIsImageLoaded","avatar_urls","nickname","AddedBySite","logoURL","getEntityRecord","getMedia","siteData","site_logo","source_url","undefined","AddedBy","templateType","template","includes","has_theme_file","origin","source","author"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SACCC,oBAAoB,IAAIC,MADzB,EAECC,IAFD,EAGCC,OAHD,QAIO,uBAJP;AAKA,SAASC,KAAK,IAAIC,SAAlB,QAAmC,sBAAnC;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SAASC,QAAT,QAAyB,oBAAzB;AACA,SAASC,MAAM,IAAIC,SAAnB,EAA8BC,OAAO,IAAIC,UAAzC,QAA2D,kBAA3D;AACA,SAASC,EAAT,QAAmB,iBAAnB;AAEA,MAAMC,wBAAwB,GAAG,CAAE,aAAF,EAAiB,kBAAjB,CAAjC;;AAEA,SAASC,iBAAT,OAAyD;AAAA,MAA7B;AAAEC,IAAAA,YAAF;AAAgBC,IAAAA;AAAhB,GAA6B;;AACxD,MAAK,CAAED,YAAP,EAAsB;AACrB,WAAOC,QAAP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AG0B,QAAQ,CAACI,MAAT,KAAoB;AAFpC,QADD;AAMA,KA3BuD,CA6BxD;AACA;AACA;;;AACA,QACC,CAAEJ,QAAQ,CAACE,cAAX,IACAF,QAAQ,CAACI,MAAT,KAAoB,QADpB,IAEA,CAAEJ,QAAQ,CAACK,MAHZ,EAIE;AACD,aAAO,cAAC,WAAD,OAAP;AACA;AACD,GA5C4D,CA8C7D;AACA;;;AACA,SAAO,cAAC,aAAD;AAAe,IAAA,EAAE,EAAGL,QAAQ,CAACK;AAA7B,IAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalHStack as HStack,\n\tIcon,\n\tTooltip,\n} from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useSelect } from '@wordpress/data';\nimport { useState } from '@wordpress/element';\nimport { layout as themeIcon, plugins as pluginIcon } from '@wordpress/icons';\nimport { __ } from '@wordpress/i18n';\n\nconst TEMPLATE_POST_TYPE_NAMES = [ 'wp_template', 'wp_template_part' ];\n\nfunction CustomizedTooltip( { isCustomized, children } ) {\n\tif ( ! isCustomized ) {\n\t\treturn children;\n\t}\n\n\treturn (\n\t\t<Tooltip text={ __( 'This template has been customized' ) }>\n\t\t\t{ children }\n\t\t</Tooltip>\n\t);\n}\n\nfunction AddedByTheme( { slug, isCustomized } ) {\n\tconst theme = useSelect(\n\t\t( select ) => select( coreStore ).getTheme( slug ),\n\t\t[ slug ]\n\t);\n\n\treturn (\n\t\t<HStack alignment=\"left\">\n\t\t\t<CustomizedTooltip isCustomized={ isCustomized }>\n\t\t\t\t<div\n\t\t\t\t\tclassName={ classnames( 'edit-site-list-added-by__icon', {\n\t\t\t\t\t\t'is-customized': isCustomized,\n\t\t\t\t\t} ) }\n\t\t\t\t>\n\t\t\t\t\t<Icon icon={ themeIcon } />\n\t\t\t\t</div>\n\t\t\t</CustomizedTooltip>\n\t\t\t<span>{ theme?.name?.rendered || slug }</span>\n\t\t</HStack>\n\t);\n}\n\nfunction AddedByPlugin( { slug, isCustomized } ) {\n\tconst plugin = useSelect(\n\t\t( select ) => select( coreStore ).getPlugin( slug ),\n\t\t[ slug ]\n\t);\n\n\treturn (\n\t\t<HStack alignment=\"left\">\n\t\t\t<CustomizedTooltip isCustomized={ isCustomized }>\n\t\t\t\t<div className=\"edit-site-list-added-by__icon\">\n\t\t\t\t\t<Icon icon={ pluginIcon } />\n\t\t\t\t</div>\n\t\t\t</CustomizedTooltip>\n\t\t\t<span>{ plugin?.name || slug }</span>\n\t\t</HStack>\n\t);\n}\n\nfunction AddedByAuthor( { id } ) {\n\tconst user = useSelect( ( select ) => select( coreStore ).getUser( id ), [\n\t\tid,\n\t] );\n\tconst [ isImageLoaded, setIsImageLoaded ] = useState( false );\n\n\treturn (\n\t\t<HStack alignment=\"left\">\n\t\t\t<div\n\t\t\t\tclassName={ classnames( 'edit-site-list-added-by__avatar', {\n\t\t\t\t\t'is-loaded': isImageLoaded,\n\t\t\t\t} ) }\n\t\t\t>\n\t\t\t\t<img\n\t\t\t\t\tonLoad={ () => setIsImageLoaded( true ) }\n\t\t\t\t\talt=\"\"\n\t\t\t\t\tsrc={ user?.avatar_urls[ 48 ] }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t\t<span>{ user?.nickname }</span>\n\t\t</HStack>\n\t);\n}\n\nfunction AddedBySite() {\n\tconst { name, logoURL } = useSelect( ( select ) => {\n\t\tconst { getEntityRecord, getMedia } = select( coreStore );\n\t\tconst siteData = getEntityRecord( 'root', '__unstableBase' );\n\n\t\treturn {\n\t\t\tname: siteData.name,\n\t\t\tlogoURL: siteData?.site_logo\n\t\t\t\t? getMedia( siteData.site_logo )?.source_url\n\t\t\t\t: undefined,\n\t\t};\n\t}, [] );\n\tconst [ isImageLoaded, setIsImageLoaded ] = useState( false );\n\n\treturn (\n\t\t<HStack alignment=\"left\">\n\t\t\t<div\n\t\t\t\tclassName={ classnames( 'edit-site-list-added-by__avatar', {\n\t\t\t\t\t'is-loaded': isImageLoaded,\n\t\t\t\t} ) }\n\t\t\t>\n\t\t\t\t<img\n\t\t\t\t\tonLoad={ () => setIsImageLoaded( true ) }\n\t\t\t\t\talt=\"\"\n\t\t\t\t\tsrc={ logoURL }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t\t<span>{ name }</span>\n\t\t</HStack>\n\t);\n}\n\nexport default function AddedBy( { templateType, template } ) {\n\tif ( ! template ) {\n\t\treturn;\n\t}\n\n\tif ( TEMPLATE_POST_TYPE_NAMES.includes( templateType ) ) {\n\t\t// Template originally provided by a theme, but customized by a user.\n\t\t// Templates originally didn't have the 'origin' field so identify\n\t\t// older customized templates by checking for no origin and a 'theme'\n\t\t// or 'custom' source.\n\t\tif (\n\t\t\ttemplate.has_theme_file &&\n\t\t\t( template.origin === 'theme' ||\n\t\t\t\t( ! template.origin &&\n\t\t\t\t\t[ 'theme', 'custom' ].includes( template.source ) ) )\n\t\t) {\n\t\t\treturn (\n\t\t\t\t<AddedByTheme\n\t\t\t\t\tslug={ template.theme }\n\t\t\t\t\tisCustomized={ template.source === 'custom' }\n\t\t\t\t/>\n\t\t\t);\n\t\t}\n\n\t\t// Template originally provided by a plugin, but customized by a user.\n\t\tif ( template.has_theme_file && template.origin === 'plugin' ) {\n\t\t\treturn (\n\t\t\t\t<AddedByPlugin\n\t\t\t\t\tslug={ template.theme }\n\t\t\t\t\tisCustomized={ template.source === 'custom' }\n\t\t\t\t/>\n\t\t\t);\n\t\t}\n\n\t\t// Template was created from scratch, but has no author. Author support\n\t\t// was only added to templates in WordPress 5.9. Fallback to showing the\n\t\t// site logo and title.\n\t\tif (\n\t\t\t! template.has_theme_file &&\n\t\t\ttemplate.source === 'custom' &&\n\t\t\t! template.author\n\t\t) {\n\t\t\treturn <AddedBySite />;\n\t\t}\n\t}\n\n\t// Simply show the author for templates created from scratch that have an\n\t// author or for any other post type.\n\treturn <AddedByAuthor id={ template.author } />;\n}\n"]}
|
|
@@ -1,40 +1,81 @@
|
|
|
1
1
|
import { createElement } from "@wordpress/element";
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* External dependencies
|
|
5
|
+
*/
|
|
6
|
+
import classnames from 'classnames';
|
|
3
7
|
/**
|
|
4
8
|
* WordPress dependencies
|
|
5
9
|
*/
|
|
10
|
+
|
|
11
|
+
import { store as coreStore } from '@wordpress/core-data';
|
|
12
|
+
import { useSelect } from '@wordpress/data';
|
|
6
13
|
import { InterfaceSkeleton } from '@wordpress/interface';
|
|
7
|
-
import { __ } from '@wordpress/i18n';
|
|
8
|
-
import {
|
|
14
|
+
import { __, sprintf } from '@wordpress/i18n';
|
|
15
|
+
import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';
|
|
16
|
+
import { EditorSnackbars } from '@wordpress/editor';
|
|
9
17
|
/**
|
|
10
18
|
* Internal dependencies
|
|
11
19
|
*/
|
|
12
20
|
|
|
21
|
+
import useRegisterShortcuts from './use-register-shortcuts';
|
|
13
22
|
import Header from './header';
|
|
14
23
|
import NavigationSidebar from '../navigation-sidebar';
|
|
15
24
|
import Table from './table';
|
|
25
|
+
import { store as editSiteStore } from '../../store';
|
|
16
26
|
export default function List(_ref) {
|
|
27
|
+
var _postType$labels;
|
|
28
|
+
|
|
17
29
|
let {
|
|
18
30
|
templateType
|
|
19
31
|
} = _ref;
|
|
20
|
-
|
|
32
|
+
useRegisterShortcuts();
|
|
33
|
+
const {
|
|
34
|
+
previousShortcut,
|
|
35
|
+
nextShortcut,
|
|
36
|
+
isNavigationOpen
|
|
37
|
+
} = useSelect(select => {
|
|
38
|
+
return {
|
|
39
|
+
previousShortcut: select(keyboardShortcutsStore).getAllShortcutKeyCombinations('core/edit-site/previous-region'),
|
|
40
|
+
nextShortcut: select(keyboardShortcutsStore).getAllShortcutKeyCombinations('core/edit-site/next-region'),
|
|
41
|
+
isNavigationOpen: select(editSiteStore).isNavigationOpened()
|
|
42
|
+
};
|
|
43
|
+
}, []);
|
|
44
|
+
const postType = useSelect(select => select(coreStore).getPostType(templateType), [templateType]); // `postType` could load in asynchronously. Only provide the detailed region labels if
|
|
45
|
+
// the postType has loaded, otherwise `InterfaceSkeleton` will fallback to the defaults.
|
|
46
|
+
|
|
47
|
+
const itemsListLabel = postType === null || postType === void 0 ? void 0 : (_postType$labels = postType.labels) === null || _postType$labels === void 0 ? void 0 : _postType$labels.items_list;
|
|
48
|
+
const detailedRegionLabels = postType ? {
|
|
49
|
+
header: sprintf( // translators: %s - the name of the page, 'Header' as in the header area of that page.
|
|
50
|
+
__('%s - Header'), itemsListLabel),
|
|
51
|
+
body: sprintf( // translators: %s - the name of the page, 'Content' as in the content area of that page.
|
|
52
|
+
__('%s - Content'), itemsListLabel)
|
|
53
|
+
} : undefined;
|
|
21
54
|
return createElement(InterfaceSkeleton, {
|
|
22
|
-
className:
|
|
55
|
+
className: classnames('edit-site-list', {
|
|
56
|
+
'is-navigation-open': isNavigationOpen
|
|
57
|
+
}),
|
|
23
58
|
labels: {
|
|
24
|
-
drawer: __('Navigation Sidebar')
|
|
59
|
+
drawer: __('Navigation Sidebar'),
|
|
60
|
+
...detailedRegionLabels
|
|
25
61
|
},
|
|
26
62
|
header: createElement(Header, {
|
|
27
63
|
templateType: templateType
|
|
28
64
|
}),
|
|
29
65
|
drawer: createElement(NavigationSidebar, {
|
|
30
|
-
|
|
31
|
-
|
|
66
|
+
activeTemplateType: templateType,
|
|
67
|
+
isDefaultOpen: true
|
|
32
68
|
}),
|
|
69
|
+
notices: createElement(EditorSnackbars, null),
|
|
33
70
|
content: createElement("main", {
|
|
34
71
|
className: "edit-site-list-main"
|
|
35
72
|
}, createElement(Table, {
|
|
36
73
|
templateType: templateType
|
|
37
|
-
}))
|
|
74
|
+
})),
|
|
75
|
+
shortcuts: {
|
|
76
|
+
previous: previousShortcut,
|
|
77
|
+
next: nextShortcut
|
|
78
|
+
}
|
|
38
79
|
});
|
|
39
80
|
}
|
|
40
81
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/list/index.js"],"names":["InterfaceSkeleton","__","
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/list/index.js"],"names":["classnames","store","coreStore","useSelect","InterfaceSkeleton","__","sprintf","keyboardShortcutsStore","EditorSnackbars","useRegisterShortcuts","Header","NavigationSidebar","Table","editSiteStore","List","templateType","previousShortcut","nextShortcut","isNavigationOpen","select","getAllShortcutKeyCombinations","isNavigationOpened","postType","getPostType","itemsListLabel","labels","items_list","detailedRegionLabels","header","body","undefined","drawer","previous","next"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,SAAlB,QAAmC,sBAAnC;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SAASC,iBAAT,QAAkC,sBAAlC;AACA,SAASC,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SAASL,KAAK,IAAIM,sBAAlB,QAAgD,+BAAhD;AACA,SAASC,eAAT,QAAgC,mBAAhC;AAEA;AACA;AACA;;AACA,OAAOC,oBAAP,MAAiC,0BAAjC;AACA,OAAOC,MAAP,MAAmB,UAAnB;AACA,OAAOC,iBAAP,MAA8B,uBAA9B;AACA,OAAOC,KAAP,MAAkB,SAAlB;AACA,SAASX,KAAK,IAAIY,aAAlB,QAAuC,aAAvC;AAEA,eAAe,SAASC,IAAT,OAAkC;AAAA;;AAAA,MAAnB;AAAEC,IAAAA;AAAF,GAAmB;AAChDN,EAAAA,oBAAoB;AAEpB,QAAM;AAAEO,IAAAA,gBAAF;AAAoBC,IAAAA,YAApB;AAAkCC,IAAAA;AAAlC,MAAuDf,SAAS,CACnEgB,MAAF,IAAc;AACb,WAAO;AACNH,MAAAA,gBAAgB,EAAEG,MAAM,CACvBZ,sBADuB,CAAN,CAEhBa,6BAFgB,CAGjB,gCAHiB,CADZ;AAMNH,MAAAA,YAAY,EAAEE,MAA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tB,MADD,CAjBF;AAqBC,IAAA,SAAS,EAAG;AACXiB,MAAAA,QAAQ,EAAEhB,gBADC;AAEXiB,MAAAA,IAAI,EAAEhB;AAFK;AArBb,IADD;AA4BA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useSelect } from '@wordpress/data';\nimport { InterfaceSkeleton } from '@wordpress/interface';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\nimport { EditorSnackbars } from '@wordpress/editor';\n\n/**\n * Internal dependencies\n */\nimport useRegisterShortcuts from './use-register-shortcuts';\nimport Header from './header';\nimport NavigationSidebar from '../navigation-sidebar';\nimport Table from './table';\nimport { store as editSiteStore } from '../../store';\n\nexport default function List( { templateType } ) {\n\tuseRegisterShortcuts();\n\n\tconst { previousShortcut, nextShortcut, isNavigationOpen } = useSelect(\n\t\t( select ) => {\n\t\t\treturn {\n\t\t\t\tpreviousShortcut: select(\n\t\t\t\t\tkeyboardShortcutsStore\n\t\t\t\t).getAllShortcutKeyCombinations(\n\t\t\t\t\t'core/edit-site/previous-region'\n\t\t\t\t),\n\t\t\t\tnextShortcut: select(\n\t\t\t\t\tkeyboardShortcutsStore\n\t\t\t\t).getAllShortcutKeyCombinations( 'core/edit-site/next-region' ),\n\t\t\t\tisNavigationOpen: select( editSiteStore ).isNavigationOpened(),\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\n\tconst postType = useSelect(\n\t\t( select ) => select( coreStore ).getPostType( templateType ),\n\t\t[ templateType ]\n\t);\n\n\t// `postType` could load in asynchronously. Only provide the detailed region labels if\n\t// the postType has loaded, otherwise `InterfaceSkeleton` will fallback to the defaults.\n\tconst itemsListLabel = postType?.labels?.items_list;\n\tconst detailedRegionLabels = postType\n\t\t? {\n\t\t\t\theader: sprintf(\n\t\t\t\t\t// translators: %s - the name of the page, 'Header' as in the header area of that page.\n\t\t\t\t\t__( '%s - Header' ),\n\t\t\t\t\titemsListLabel\n\t\t\t\t),\n\t\t\t\tbody: sprintf(\n\t\t\t\t\t// translators: %s - the name of the page, 'Content' as in the content area of that page.\n\t\t\t\t\t__( '%s - Content' ),\n\t\t\t\t\titemsListLabel\n\t\t\t\t),\n\t\t }\n\t\t: undefined;\n\n\treturn (\n\t\t<InterfaceSkeleton\n\t\t\tclassName={ classnames( 'edit-site-list', {\n\t\t\t\t'is-navigation-open': isNavigationOpen,\n\t\t\t} ) }\n\t\t\tlabels={ {\n\t\t\t\tdrawer: __( 'Navigation Sidebar' ),\n\t\t\t\t...detailedRegionLabels,\n\t\t\t} }\n\t\t\theader={ <Header templateType={ templateType } /> }\n\t\t\tdrawer={\n\t\t\t\t<NavigationSidebar\n\t\t\t\t\tactiveTemplateType={ templateType }\n\t\t\t\t\tisDefaultOpen\n\t\t\t\t/>\n\t\t\t}\n\t\t\tnotices={ <EditorSnackbars /> }\n\t\t\tcontent={\n\t\t\t\t<main className=\"edit-site-list-main\">\n\t\t\t\t\t<Table templateType={ templateType } />\n\t\t\t\t</main>\n\t\t\t}\n\t\t\tshortcuts={ {\n\t\t\t\tprevious: previousShortcut,\n\t\t\t\tnext: nextShortcut,\n\t\t\t} }\n\t\t/>\n\t);\n}\n"]}
|
|
@@ -3,39 +3,21 @@ import { createElement } from "@wordpress/element";
|
|
|
3
3
|
/**
|
|
4
4
|
* WordPress dependencies
|
|
5
5
|
*/
|
|
6
|
-
import { useSelect
|
|
6
|
+
import { useSelect } from '@wordpress/data';
|
|
7
7
|
import { store as coreStore } from '@wordpress/core-data';
|
|
8
8
|
import { __, sprintf } from '@wordpress/i18n';
|
|
9
|
-
import { VisuallyHidden,
|
|
10
|
-
import { moreVertical } from '@wordpress/icons';
|
|
9
|
+
import { VisuallyHidden, __experimentalHeading as Heading } from '@wordpress/components';
|
|
11
10
|
import { addQueryArgs } from '@wordpress/url';
|
|
12
11
|
/**
|
|
13
12
|
* Internal dependencies
|
|
14
13
|
*/
|
|
15
14
|
|
|
16
|
-
import
|
|
17
|
-
import
|
|
18
|
-
|
|
19
|
-
function Actions(_ref) {
|
|
20
|
-
let {
|
|
21
|
-
template,
|
|
22
|
-
onClose
|
|
23
|
-
} = _ref;
|
|
24
|
-
const {
|
|
25
|
-
removeTemplate
|
|
26
|
-
} = useDispatch(editSiteStore);
|
|
27
|
-
return createElement(MenuGroup, null, createElement(MenuItem, {
|
|
28
|
-
onClick: () => {
|
|
29
|
-
removeTemplate(template);
|
|
30
|
-
onClose();
|
|
31
|
-
}
|
|
32
|
-
}, __('Remove template')));
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export default function Table(_ref2) {
|
|
15
|
+
import Actions from './actions';
|
|
16
|
+
import AddedBy from './added-by';
|
|
17
|
+
export default function Table(_ref) {
|
|
36
18
|
let {
|
|
37
19
|
templateType
|
|
38
|
-
} =
|
|
20
|
+
} = _ref;
|
|
39
21
|
const {
|
|
40
22
|
templates,
|
|
41
23
|
isLoading,
|
|
@@ -47,8 +29,12 @@ export default function Table(_ref2) {
|
|
|
47
29
|
getPostType
|
|
48
30
|
} = select(coreStore);
|
|
49
31
|
return {
|
|
50
|
-
templates: getEntityRecords('postType', templateType
|
|
51
|
-
|
|
32
|
+
templates: getEntityRecords('postType', templateType, {
|
|
33
|
+
per_page: -1
|
|
34
|
+
}),
|
|
35
|
+
isLoading: !hasFinishedResolution('getEntityRecords', ['postType', templateType, {
|
|
36
|
+
per_page: -1
|
|
37
|
+
}]),
|
|
52
38
|
postType: getPostType(templateType)
|
|
53
39
|
};
|
|
54
40
|
}, [templateType]);
|
|
@@ -64,49 +50,53 @@ export default function Table(_ref2) {
|
|
|
64
50
|
__('No %s found.'), postType === null || postType === void 0 ? void 0 : (_postType$labels = postType.labels) === null || _postType$labels === void 0 ? void 0 : (_postType$labels$name = _postType$labels.name) === null || _postType$labels$name === void 0 ? void 0 : _postType$labels$name.toLowerCase()));
|
|
65
51
|
}
|
|
66
52
|
|
|
67
|
-
return
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
53
|
+
return (// These explicit aria roles are needed for Safari.
|
|
54
|
+
// See https://developer.mozilla.org/en-US/docs/Web/CSS/display#tables
|
|
55
|
+
createElement("table", {
|
|
56
|
+
className: "edit-site-list-table",
|
|
57
|
+
role: "table"
|
|
58
|
+
}, createElement("thead", null, createElement("tr", {
|
|
59
|
+
className: "edit-site-list-table-head",
|
|
60
|
+
role: "row"
|
|
61
|
+
}, createElement("th", {
|
|
62
|
+
className: "edit-site-list-table-column",
|
|
63
|
+
role: "columnheader"
|
|
64
|
+
}, __('Template')), createElement("th", {
|
|
65
|
+
className: "edit-site-list-table-column",
|
|
66
|
+
role: "columnheader"
|
|
67
|
+
}, __('Added by')), createElement("th", {
|
|
68
|
+
className: "edit-site-list-table-column",
|
|
69
|
+
role: "columnheader"
|
|
70
|
+
}, createElement(VisuallyHidden, null, __('Actions'))))), createElement("tbody", null, templates.map(template => {
|
|
71
|
+
var _template$title;
|
|
72
|
+
|
|
73
|
+
return createElement("tr", {
|
|
74
|
+
key: template.id,
|
|
75
|
+
className: "edit-site-list-table-row",
|
|
76
|
+
role: "row"
|
|
77
|
+
}, createElement("td", {
|
|
78
|
+
className: "edit-site-list-table-column",
|
|
79
|
+
role: "cell"
|
|
80
|
+
}, createElement(Heading, {
|
|
81
|
+
level: 4
|
|
82
|
+
}, createElement("a", {
|
|
83
|
+
href: addQueryArgs(window.location.href, {
|
|
84
|
+
postId: template.id,
|
|
85
|
+
postType: template.type
|
|
86
|
+
})
|
|
87
|
+
}, ((_template$title = template.title) === null || _template$title === void 0 ? void 0 : _template$title.rendered) || template.slug)), template.description), createElement("td", {
|
|
88
|
+
className: "edit-site-list-table-column",
|
|
89
|
+
role: "cell"
|
|
90
|
+
}, createElement(AddedBy, {
|
|
91
|
+
templateType: templateType,
|
|
92
|
+
template: template
|
|
93
|
+
})), createElement("td", {
|
|
94
|
+
className: "edit-site-list-table-column",
|
|
95
|
+
role: "cell"
|
|
96
|
+
}, createElement(Actions, {
|
|
97
|
+
template: template
|
|
98
|
+
})));
|
|
99
|
+
})))
|
|
100
|
+
);
|
|
111
101
|
}
|
|
112
102
|
//# sourceMappingURL=table.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/list/table.js"],"names":["useSelect","
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/list/table.js"],"names":["useSelect","store","coreStore","__","sprintf","VisuallyHidden","__experimentalHeading","Heading","addQueryArgs","Actions","AddedBy","Table","templateType","templates","isLoading","postType","select","getEntityRecords","hasFinishedResolution","getPostType","per_page","length","labels","name","toLowerCase","map","template","id","window","location","href","postId","type","title","rendered","slug","description"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,iBAA1B;AACA,SAASC,KAAK,IAAIC,SAAlB,QAAmC,sBAAnC;AACA,SAASC,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SACCC,cADD,EAECC,qBAAqB,IAAIC,OAF1B,QAGO,uBAHP;AAIA,SAASC,YAAT,QAA6B,gBAA7B;AAEA;AACA;AACA;;AACA,OAAOC,OAAP,M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KAAf,CADH,CAxBD;AAHD;AA+DA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\tVisuallyHidden,\n\t__experimentalHeading as Heading,\n} from '@wordpress/components';\nimport { addQueryArgs } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport Actions from './actions';\nimport AddedBy from './added-by';\n\nexport default function Table( { templateType } ) {\n\tconst { templates, isLoading, postType } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetEntityRecords,\n\t\t\t\thasFinishedResolution,\n\t\t\t\tgetPostType,\n\t\t\t} = select( coreStore );\n\n\t\t\treturn {\n\t\t\t\ttemplates: getEntityRecords( 'postType', templateType, {\n\t\t\t\t\tper_page: -1,\n\t\t\t\t} ),\n\t\t\t\tisLoading: ! hasFinishedResolution( 'getEntityRecords', [\n\t\t\t\t\t'postType',\n\t\t\t\t\ttemplateType,\n\t\t\t\t\t{ per_page: -1 },\n\t\t\t\t] ),\n\t\t\t\tpostType: getPostType( templateType ),\n\t\t\t};\n\t\t},\n\t\t[ templateType ]\n\t);\n\n\tif ( ! templates || isLoading ) {\n\t\treturn null;\n\t}\n\n\tif ( ! templates.length ) {\n\t\treturn (\n\t\t\t<div>\n\t\t\t\t{ sprintf(\n\t\t\t\t\t// translators: The template type name, should be either \"templates\" or \"template parts\".\n\t\t\t\t\t__( 'No %s found.' ),\n\t\t\t\t\tpostType?.labels?.name?.toLowerCase()\n\t\t\t\t) }\n\t\t\t</div>\n\t\t);\n\t}\n\n\treturn (\n\t\t// These explicit aria roles are needed for Safari.\n\t\t// See https://developer.mozilla.org/en-US/docs/Web/CSS/display#tables\n\t\t<table className=\"edit-site-list-table\" role=\"table\">\n\t\t\t<thead>\n\t\t\t\t<tr className=\"edit-site-list-table-head\" role=\"row\">\n\t\t\t\t\t<th\n\t\t\t\t\t\tclassName=\"edit-site-list-table-column\"\n\t\t\t\t\t\trole=\"columnheader\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Template' ) }\n\t\t\t\t\t</th>\n\t\t\t\t\t<th\n\t\t\t\t\t\tclassName=\"edit-site-list-table-column\"\n\t\t\t\t\t\trole=\"columnheader\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Added by' ) }\n\t\t\t\t\t</th>\n\t\t\t\t\t<th\n\t\t\t\t\t\tclassName=\"edit-site-list-table-column\"\n\t\t\t\t\t\trole=\"columnheader\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<VisuallyHidden>{ __( 'Actions' ) }</VisuallyHidden>\n\t\t\t\t\t</th>\n\t\t\t\t</tr>\n\t\t\t</thead>\n\n\t\t\t<tbody>\n\t\t\t\t{ templates.map( ( template ) => (\n\t\t\t\t\t<tr\n\t\t\t\t\t\tkey={ template.id }\n\t\t\t\t\t\tclassName=\"edit-site-list-table-row\"\n\t\t\t\t\t\trole=\"row\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<td className=\"edit-site-list-table-column\" role=\"cell\">\n\t\t\t\t\t\t\t<Heading level={ 4 }>\n\t\t\t\t\t\t\t\t<a\n\t\t\t\t\t\t\t\t\thref={ addQueryArgs( window.location.href, {\n\t\t\t\t\t\t\t\t\t\tpostId: template.id,\n\t\t\t\t\t\t\t\t\t\tpostType: template.type,\n\t\t\t\t\t\t\t\t\t} ) }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ template.title?.rendered ||\n\t\t\t\t\t\t\t\t\t\ttemplate.slug }\n\t\t\t\t\t\t\t\t</a>\n\t\t\t\t\t\t\t</Heading>\n\t\t\t\t\t\t\t{ template.description }\n\t\t\t\t\t\t</td>\n\n\t\t\t\t\t\t<td className=\"edit-site-list-table-column\" role=\"cell\">\n\t\t\t\t\t\t\t<AddedBy\n\t\t\t\t\t\t\t\ttemplateType={ templateType }\n\t\t\t\t\t\t\t\ttemplate={ template }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</td>\n\t\t\t\t\t\t<td className=\"edit-site-list-table-column\" role=\"cell\">\n\t\t\t\t\t\t\t<Actions template={ template } />\n\t\t\t\t\t\t</td>\n\t\t\t\t\t</tr>\n\t\t\t\t) ) }\n\t\t\t</tbody>\n\t\t</table>\n\t);\n}\n"]}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useDispatch } from '@wordpress/data';
|
|
5
|
+
import { useEffect } from '@wordpress/element';
|
|
6
|
+
import { __ } from '@wordpress/i18n';
|
|
7
|
+
import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';
|
|
8
|
+
export default function useRegisterShortcuts() {
|
|
9
|
+
const {
|
|
10
|
+
registerShortcut
|
|
11
|
+
} = useDispatch(keyboardShortcutsStore);
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
registerShortcut({
|
|
14
|
+
name: 'core/edit-site/next-region',
|
|
15
|
+
category: 'global',
|
|
16
|
+
description: __('Navigate to the next part of the editor.'),
|
|
17
|
+
keyCombination: {
|
|
18
|
+
modifier: 'ctrl',
|
|
19
|
+
character: '`'
|
|
20
|
+
},
|
|
21
|
+
aliases: [{
|
|
22
|
+
modifier: 'access',
|
|
23
|
+
character: 'n'
|
|
24
|
+
}]
|
|
25
|
+
});
|
|
26
|
+
registerShortcut({
|
|
27
|
+
name: 'core/edit-site/previous-region',
|
|
28
|
+
category: 'global',
|
|
29
|
+
description: __('Navigate to the previous part of the editor.'),
|
|
30
|
+
keyCombination: {
|
|
31
|
+
modifier: 'ctrlShift',
|
|
32
|
+
character: '`'
|
|
33
|
+
},
|
|
34
|
+
aliases: [{
|
|
35
|
+
modifier: 'access',
|
|
36
|
+
character: 'p'
|
|
37
|
+
}]
|
|
38
|
+
});
|
|
39
|
+
}, []);
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=use-register-shortcuts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/list/use-register-shortcuts.js"],"names":["useDispatch","useEffect","__","store","keyboardShortcutsStore","useRegisterShortcuts","registerShortcut","name","category","description","keyCombination","modifier","character","aliases"],"mappings":"AAAA;AACA;AACA;AAEA,SAASA,WAAT,QAA4B,iBAA5B;AACA,SAASC,SAAT,QAA0B,oBAA1B;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,KAAK,IAAIC,sBAAlB,QAAgD,+BAAhD;AAEA,eAAe,SAASC,oBAAT,GAAgC;AAC9C,QAAM;AAAEC,IAAAA;AAAF,MAAuBN,WAAW,CAAEI,sBAAF,CAAxC;AACAH,EAAAA,SAAS,CAAE,MAAM;AAChBK,IAAAA,gBAAgB,CAAE;AACjBC,MAAAA,IAAI,EAAE,4BADW;AAEjBC,MAAAA,QAAQ,EAAE,QAFO;AAGjBC,MAAAA,WAAW,EAAEP,EAAE,CAAE,0CAAF,CAHE;AAIjBQ,MAAAA,cAAc,EAAE;AACfC,QAAAA,QAAQ,EAAE,MADK;AAEfC,QAAAA,SAAS,EAAE;AAFI,OAJC;AAQjBC,MAAAA,OAAO,EAAE,CACR;AACCF,QAAAA,QAAQ,EAAE,QADX;AAECC,QAAAA,SAAS,EAAE;AAFZ,OADQ;AARQ,KAAF,CAAhB;AAgBAN,IAAAA,gBAAgB,CAAE;AACjBC,MAAAA,IAAI,EAAE,gCADW;AAEjBC,MAAAA,QAAQ,EAAE,QAFO;AAGjBC,MAAAA,WAAW,EAAEP,EAAE,CAAE,8CAAF,CAHE;AAIjBQ,MAAAA,cAAc,EAAE;AACfC,QAAAA,QAAQ,EAAE,WADK;AAEfC,QAAAA,SAAS,EAAE;AAFI,OAJC;AAQjBC,MAAAA,OAAO,EAAE,CACR;AACCF,QAAAA,QAAQ,EAAE,QADX;AAECC,QAAAA,SAAS,EAAE;AAFZ,OADQ;AARQ,KAAF,CAAhB;AAeA,GAhCQ,EAgCN,EAhCM,CAAT;AAiCA","sourcesContent":["/**\n * WordPress dependencies\n */\n\nimport { useDispatch } from '@wordpress/data';\nimport { useEffect } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\n\nexport default function useRegisterShortcuts() {\n\tconst { registerShortcut } = useDispatch( keyboardShortcutsStore );\n\tuseEffect( () => {\n\t\tregisterShortcut( {\n\t\t\tname: 'core/edit-site/next-region',\n\t\t\tcategory: 'global',\n\t\t\tdescription: __( 'Navigate to the next part of the editor.' ),\n\t\t\tkeyCombination: {\n\t\t\t\tmodifier: 'ctrl',\n\t\t\t\tcharacter: '`',\n\t\t\t},\n\t\t\taliases: [\n\t\t\t\t{\n\t\t\t\t\tmodifier: 'access',\n\t\t\t\t\tcharacter: 'n',\n\t\t\t\t},\n\t\t\t],\n\t\t} );\n\n\t\tregisterShortcut( {\n\t\t\tname: 'core/edit-site/previous-region',\n\t\t\tcategory: 'global',\n\t\t\tdescription: __( 'Navigate to the previous part of the editor.' ),\n\t\t\tkeyCombination: {\n\t\t\t\tmodifier: 'ctrlShift',\n\t\t\t\tcharacter: '`',\n\t\t\t},\n\t\t\taliases: [\n\t\t\t\t{\n\t\t\t\t\tmodifier: 'access',\n\t\t\t\t\tcharacter: 'p',\n\t\t\t\t},\n\t\t\t],\n\t\t} );\n\t}, [] );\n}\n"]}
|
|
@@ -3,12 +3,15 @@ import { createElement, Fragment } from "@wordpress/element";
|
|
|
3
3
|
/**
|
|
4
4
|
* WordPress dependencies
|
|
5
5
|
*/
|
|
6
|
-
import {
|
|
6
|
+
import { useEffect } from '@wordpress/element';
|
|
7
7
|
import { createSlotFill } from '@wordpress/components';
|
|
8
|
+
import { useViewportMatch } from '@wordpress/compose';
|
|
9
|
+
import { useDispatch } from '@wordpress/data';
|
|
8
10
|
/**
|
|
9
11
|
* Internal dependencies
|
|
10
12
|
*/
|
|
11
13
|
|
|
14
|
+
import { store as editSiteStore } from '../../store';
|
|
12
15
|
import NavigationPanel from './navigation-panel';
|
|
13
16
|
import NavigationToggle from './navigation-toggle';
|
|
14
17
|
export const {
|
|
@@ -17,17 +20,26 @@ export const {
|
|
|
17
20
|
} = createSlotFill('EditSiteNavigationPanelPreview');
|
|
18
21
|
export default function NavigationSidebar(_ref) {
|
|
19
22
|
let {
|
|
20
|
-
|
|
23
|
+
isDefaultOpen = false,
|
|
21
24
|
activeTemplateType
|
|
22
25
|
} = _ref;
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
26
|
+
const isDesktopViewport = useViewportMatch('medium');
|
|
27
|
+
const {
|
|
28
|
+
setIsNavigationPanelOpened
|
|
29
|
+
} = useDispatch(editSiteStore);
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
// When transitioning to desktop open the navigation if `isDefaultOpen` is true.
|
|
32
|
+
if (isDefaultOpen && isDesktopViewport) {
|
|
33
|
+
setIsNavigationPanelOpened(true);
|
|
34
|
+
} // When transitioning to mobile/tablet, close the navigation.
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
if (!isDesktopViewport) {
|
|
38
|
+
setIsNavigationPanelOpened(false);
|
|
39
|
+
}
|
|
40
|
+
}, [isDefaultOpen, isDesktopViewport, setIsNavigationPanelOpened]);
|
|
41
|
+
return createElement(Fragment, null, createElement(NavigationToggle, null), createElement(NavigationPanel, {
|
|
42
|
+
activeItem: activeTemplateType
|
|
31
43
|
}), createElement(NavigationPanelPreviewSlot, null));
|
|
32
44
|
}
|
|
33
45
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/navigation-sidebar/index.js"],"names":["
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/navigation-sidebar/index.js"],"names":["useEffect","createSlotFill","useViewportMatch","useDispatch","store","editSiteStore","NavigationPanel","NavigationToggle","Fill","NavigationPanelPreviewFill","Slot","NavigationPanelPreviewSlot","NavigationSidebar","isDefaultOpen","activeTemplateType","isDesktopViewport","setIsNavigationPanelOpened"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,oBAA1B;AACA,SAASC,cAAT,QAA+B,uBAA/B;AACA,SAASC,gBAAT,QAAiC,oBAAjC;AACA,SAASC,WAAT,QAA4B,iBAA5B;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,aAAlB,QAAuC,aAAvC;AACA,OAAOC,eAAP,MAA4B,oBAA5B;AACA,OAAOC,gBAAP,MAA6B,qBAA7B;AAEA,OAAO,MAAM;AACZC,EAAAA,IAAI,EAAEC,0BADM;AAEZC,EAAAA,IAAI,EAAEC;AAFM,IAGTV,cAAc,CAAE,gCAAF,CAHX;AAKP,eAAe,SAASW,iBAAT,OAGX;AAAA,MAHuC;AAC1CC,IAAAA,aAAa,GAAG,KAD0B;AAE1CC,IAAAA;AAF0C,GAGvC;AACH,QAAMC,iBAAiB,GAAGb,gBAAgB,CAAE,QAAF,CAA1C;AACA,QAAM;AAAEc,IAAAA;AAAF,MAAiCb,WAAW,CAAEE,aAAF,CAAlD;AAEAL,EAAAA,SAAS,CAAE,MAAM;AAChB;AACA,QAAKa,aAAa,IAAIE,iBAAtB,EAA0C;AACzCC,MAAAA,0BAA0B,CAAE,IAAF,CAA1B;AACA,KAJe,CAMhB;;;AACA,QAAK,CAAED,iBAAP,EAA2B;AAC1BC,MAAAA,0BAA0B,CAAE,KAAF,CAA1B;AACA;AACD,GAVQ,EAUN,CAAEH,aAAF,EAAiBE,iBAAjB,EAAoCC,0BAApC,CAVM,CAAT;AAYA,SACC,8BACC,cAAC,gBAAD,OADD,EAEC,cAAC,eAAD;AAAiB,IAAA,UAAU,EAAGF;AAA9B,IAFD,EAGC,cAAC,0BAAD,OAHD,CADD;AAOA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect } from '@wordpress/element';\nimport { createSlotFill } from '@wordpress/components';\nimport { useViewportMatch } from '@wordpress/compose';\nimport { useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../store';\nimport NavigationPanel from './navigation-panel';\nimport NavigationToggle from './navigation-toggle';\n\nexport const {\n\tFill: NavigationPanelPreviewFill,\n\tSlot: NavigationPanelPreviewSlot,\n} = createSlotFill( 'EditSiteNavigationPanelPreview' );\n\nexport default function NavigationSidebar( {\n\tisDefaultOpen = false,\n\tactiveTemplateType,\n} ) {\n\tconst isDesktopViewport = useViewportMatch( 'medium' );\n\tconst { setIsNavigationPanelOpened } = useDispatch( editSiteStore );\n\n\tuseEffect( () => {\n\t\t// When transitioning to desktop open the navigation if `isDefaultOpen` is true.\n\t\tif ( isDefaultOpen && isDesktopViewport ) {\n\t\t\tsetIsNavigationPanelOpened( true );\n\t\t}\n\n\t\t// When transitioning to mobile/tablet, close the navigation.\n\t\tif ( ! isDesktopViewport ) {\n\t\t\tsetIsNavigationPanelOpened( false );\n\t\t}\n\t}, [ isDefaultOpen, isDesktopViewport, setIsNavigationPanelOpened ] );\n\n\treturn (\n\t\t<>\n\t\t\t<NavigationToggle />\n\t\t\t<NavigationPanel activeItem={ activeTemplateType } />\n\t\t\t<NavigationPanelPreviewSlot />\n\t\t</>\n\t);\n}\n"]}
|