@wordpress/edit-site 6.3.0 → 6.4.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 +8 -2
- package/build/components/add-new-pattern/index.js.map +1 -1
- package/build/components/add-new-template/index.js +3 -1
- package/build/components/add-new-template/index.js.map +1 -1
- package/build/components/block-editor/use-site-editor-settings.js +1 -82
- package/build/components/block-editor/use-site-editor-settings.js.map +1 -1
- package/build/components/global-styles/block-preview-panel.js +14 -5
- package/build/components/global-styles/block-preview-panel.js.map +1 -1
- package/build/components/global-styles/font-families.js +42 -23
- package/build/components/global-styles/font-families.js.map +1 -1
- package/build/components/global-styles/font-library-modal/index.js +4 -4
- package/build/components/global-styles/font-library-modal/index.js.map +1 -1
- package/build/components/global-styles/font-library-modal/installed-fonts.js +58 -10
- package/build/components/global-styles/font-library-modal/installed-fonts.js.map +1 -1
- package/build/components/global-styles/font-sizes/confirm-delete-font-size-dialog.js +39 -0
- package/build/components/global-styles/font-sizes/confirm-delete-font-size-dialog.js.map +1 -0
- package/build/components/global-styles/font-sizes/confirm-reset-font-sizes-dialog.js +39 -0
- package/build/components/global-styles/font-sizes/confirm-reset-font-sizes-dialog.js.map +1 -0
- package/build/components/global-styles/font-sizes/font-size-preview.js +44 -0
- package/build/components/global-styles/font-sizes/font-size-preview.js.map +1 -0
- package/build/components/global-styles/font-sizes/font-size.js +213 -0
- package/build/components/global-styles/font-sizes/font-size.js.map +1 -0
- package/build/components/global-styles/font-sizes/font-sizes-count.js +50 -0
- package/build/components/global-styles/font-sizes/font-sizes-count.js.map +1 -0
- package/build/components/global-styles/font-sizes/font-sizes.js +163 -0
- package/build/components/global-styles/font-sizes/font-sizes.js.map +1 -0
- package/build/components/global-styles/font-sizes/rename-font-size-dialog.js +67 -0
- package/build/components/global-styles/font-sizes/rename-font-size-dialog.js.map +1 -0
- package/build/components/global-styles/screen-block.js +10 -8
- package/build/components/global-styles/screen-block.js.map +1 -1
- package/build/components/global-styles/screen-style-variations.js +2 -2
- package/build/components/global-styles/screen-style-variations.js.map +1 -1
- package/build/components/global-styles/screen-typography.js +3 -2
- package/build/components/global-styles/screen-typography.js.map +1 -1
- package/build/components/global-styles/size-control/index.js +85 -0
- package/build/components/global-styles/size-control/index.js.map +1 -0
- package/build/components/global-styles/style-variations-container.js +3 -0
- package/build/components/global-styles/style-variations-container.js.map +1 -1
- package/build/components/global-styles/ui.js +8 -0
- package/build/components/global-styles/ui.js.map +1 -1
- package/build/components/global-styles/variations/variations-color.js.map +1 -1
- package/build/components/global-styles/variations/variations-typography.js +1 -1
- package/build/components/global-styles/variations/variations-typography.js.map +1 -1
- package/build/components/layout/index.js +6 -0
- package/build/components/layout/index.js.map +1 -1
- package/build/components/layout/router.js +14 -6
- package/build/components/layout/router.js.map +1 -1
- package/build/components/page-patterns/header.js +1 -1
- package/build/components/page-patterns/header.js.map +1 -1
- package/build/components/page-patterns/index.js +23 -11
- package/build/components/page-patterns/index.js.map +1 -1
- package/build/components/page-templates/index.js +41 -34
- package/build/components/page-templates/index.js.map +1 -1
- package/build/components/post-edit/index.js +105 -0
- package/build/components/post-edit/index.js.map +1 -0
- package/build/components/post-fields/index.js +314 -0
- package/build/components/post-fields/index.js.map +1 -0
- package/build/components/post-list/index.js +281 -0
- package/build/components/post-list/index.js.map +1 -0
- package/build/components/posts-app/router.js +3 -3
- package/build/components/posts-app/router.js.map +1 -1
- package/build/components/sidebar-dataviews/default-views.js +22 -10
- package/build/components/sidebar-dataviews/default-views.js.map +1 -1
- package/build/components/sidebar-dataviews/index.js +40 -1
- package/build/components/sidebar-dataviews/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-global-styles/content.js +64 -0
- package/build/components/sidebar-navigation-screen-global-styles/content.js.map +1 -0
- package/build/components/sidebar-navigation-screen-global-styles/index.js +2 -47
- package/build/components/sidebar-navigation-screen-global-styles/index.js.map +1 -1
- package/build/hooks/push-changes-to-global-styles/index.js +1 -1
- package/build/hooks/push-changes-to-global-styles/index.js.map +1 -1
- package/build/index.js +5 -1
- package/build/index.js.map +1 -1
- package/build/store/selectors.js +34 -6
- package/build/store/selectors.js.map +1 -1
- package/build/utils/get-filtered-template-parts.js +64 -0
- package/build/utils/get-filtered-template-parts.js.map +1 -0
- package/build-module/components/add-new-pattern/index.js +8 -2
- package/build-module/components/add-new-pattern/index.js.map +1 -1
- package/build-module/components/add-new-template/index.js +3 -1
- package/build-module/components/add-new-template/index.js.map +1 -1
- package/build-module/components/block-editor/use-site-editor-settings.js +1 -82
- package/build-module/components/block-editor/use-site-editor-settings.js.map +1 -1
- package/build-module/components/global-styles/block-preview-panel.js +14 -5
- package/build-module/components/global-styles/block-preview-panel.js.map +1 -1
- package/build-module/components/global-styles/font-families.js +44 -25
- package/build-module/components/global-styles/font-families.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/index.js +4 -4
- 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 +61 -13
- package/build-module/components/global-styles/font-library-modal/installed-fonts.js.map +1 -1
- package/build-module/components/global-styles/font-sizes/confirm-delete-font-size-dialog.js +32 -0
- package/build-module/components/global-styles/font-sizes/confirm-delete-font-size-dialog.js.map +1 -0
- package/build-module/components/global-styles/font-sizes/confirm-reset-font-sizes-dialog.js +32 -0
- package/build-module/components/global-styles/font-sizes/confirm-reset-font-sizes-dialog.js.map +1 -0
- package/build-module/components/global-styles/font-sizes/font-size-preview.js +37 -0
- package/build-module/components/global-styles/font-sizes/font-size-preview.js.map +1 -0
- package/build-module/components/global-styles/font-sizes/font-size.js +207 -0
- package/build-module/components/global-styles/font-sizes/font-size.js.map +1 -0
- package/build-module/components/global-styles/font-sizes/font-sizes-count.js +43 -0
- package/build-module/components/global-styles/font-sizes/font-sizes-count.js.map +1 -0
- package/build-module/components/global-styles/font-sizes/font-sizes.js +157 -0
- package/build-module/components/global-styles/font-sizes/font-sizes.js.map +1 -0
- package/build-module/components/global-styles/font-sizes/rename-font-size-dialog.js +61 -0
- package/build-module/components/global-styles/font-sizes/rename-font-size-dialog.js.map +1 -0
- package/build-module/components/global-styles/screen-block.js +10 -8
- package/build-module/components/global-styles/screen-block.js.map +1 -1
- package/build-module/components/global-styles/screen-style-variations.js +2 -2
- package/build-module/components/global-styles/screen-style-variations.js.map +1 -1
- package/build-module/components/global-styles/screen-typography.js +3 -2
- package/build-module/components/global-styles/screen-typography.js.map +1 -1
- package/build-module/components/global-styles/size-control/index.js +79 -0
- package/build-module/components/global-styles/size-control/index.js.map +1 -0
- package/build-module/components/global-styles/style-variations-container.js +3 -0
- package/build-module/components/global-styles/style-variations-container.js.map +1 -1
- package/build-module/components/global-styles/ui.js +8 -0
- package/build-module/components/global-styles/ui.js.map +1 -1
- package/build-module/components/global-styles/variations/variations-color.js +1 -1
- package/build-module/components/global-styles/variations/variations-color.js.map +1 -1
- package/build-module/components/global-styles/variations/variations-typography.js +1 -2
- package/build-module/components/global-styles/variations/variations-typography.js.map +1 -1
- package/build-module/components/layout/index.js +6 -0
- package/build-module/components/layout/index.js.map +1 -1
- package/build-module/components/layout/router.js +14 -6
- package/build-module/components/layout/router.js.map +1 -1
- package/build-module/components/page-patterns/header.js +1 -1
- package/build-module/components/page-patterns/header.js.map +1 -1
- package/build-module/components/page-patterns/index.js +23 -11
- package/build-module/components/page-patterns/index.js.map +1 -1
- package/build-module/components/page-templates/index.js +43 -37
- package/build-module/components/page-templates/index.js.map +1 -1
- package/build-module/components/post-edit/index.js +98 -0
- package/build-module/components/post-edit/index.js.map +1 -0
- package/build-module/components/post-fields/index.js +306 -0
- package/build-module/components/post-fields/index.js.map +1 -0
- package/build-module/components/post-list/index.js +275 -0
- package/build-module/components/post-list/index.js.map +1 -0
- package/build-module/components/posts-app/router.js +3 -3
- package/build-module/components/posts-app/router.js.map +1 -1
- package/build-module/components/sidebar-dataviews/default-views.js +21 -9
- package/build-module/components/sidebar-dataviews/default-views.js.map +1 -1
- package/build-module/components/sidebar-dataviews/index.js +42 -3
- package/build-module/components/sidebar-dataviews/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-global-styles/content.js +57 -0
- package/build-module/components/sidebar-navigation-screen-global-styles/content.js.map +1 -0
- package/build-module/components/sidebar-navigation-screen-global-styles/index.js +2 -47
- package/build-module/components/sidebar-navigation-screen-global-styles/index.js.map +1 -1
- package/build-module/hooks/push-changes-to-global-styles/index.js +1 -1
- package/build-module/hooks/push-changes-to-global-styles/index.js.map +1 -1
- package/build-module/index.js +5 -1
- package/build-module/index.js.map +1 -1
- package/build-module/store/selectors.js +35 -7
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/get-filtered-template-parts.js +57 -0
- package/build-module/utils/get-filtered-template-parts.js.map +1 -0
- package/build-style/posts-rtl.css +581 -503
- package/build-style/posts.css +581 -503
- package/build-style/style-rtl.css +621 -519
- package/build-style/style.css +621 -519
- package/package.json +41 -41
- package/src/components/add-new-pattern/index.js +8 -2
- package/src/components/add-new-template/index.js +4 -1
- package/src/components/add-new-template/style.scss +4 -6
- package/src/components/block-editor/use-site-editor-settings.js +15 -111
- package/src/components/global-styles/block-preview-panel.js +22 -9
- package/src/components/global-styles/font-families.js +66 -31
- package/src/components/global-styles/font-library-modal/index.js +4 -2
- package/src/components/global-styles/font-library-modal/installed-fonts.js +92 -11
- package/src/components/global-styles/font-library-modal/style.scss +9 -0
- package/src/components/global-styles/font-sizes/confirm-delete-font-size-dialog.js +43 -0
- package/src/components/global-styles/font-sizes/confirm-reset-font-sizes-dialog.js +37 -0
- package/src/components/global-styles/font-sizes/font-size-preview.js +43 -0
- package/src/components/global-styles/font-sizes/font-size.js +250 -0
- package/src/components/global-styles/font-sizes/font-sizes-count.js +40 -0
- package/src/components/global-styles/font-sizes/font-sizes.js +263 -0
- package/src/components/global-styles/font-sizes/rename-font-size-dialog.js +70 -0
- package/src/components/global-styles/screen-block.js +12 -14
- package/src/components/global-styles/screen-style-variations.js +2 -2
- package/src/components/global-styles/screen-typography.js +3 -2
- package/src/components/global-styles/size-control/index.js +86 -0
- package/src/components/global-styles/style-variations-container.js +4 -0
- package/src/components/global-styles/style.scss +13 -3
- package/src/components/global-styles/ui.js +10 -0
- package/src/components/global-styles/variations/variations-color.js +1 -1
- package/src/components/global-styles/variations/variations-typography.js +1 -2
- package/src/components/layout/index.js +11 -0
- package/src/components/layout/router.js +13 -5
- package/src/components/layout/style.scss +26 -8
- package/src/components/page-patterns/header.js +1 -1
- package/src/components/page-patterns/index.js +15 -8
- package/src/components/page-templates/index.js +51 -46
- package/src/components/page-templates/style.scss +5 -3
- package/src/components/post-edit/index.js +96 -0
- package/src/components/post-edit/style.scss +9 -0
- package/src/components/post-fields/index.js +345 -0
- package/src/components/post-list/index.js +326 -0
- package/src/components/{posts-app → post-list}/style.scss +12 -9
- package/src/components/posts-app/router.js +3 -3
- package/src/components/sidebar-dataviews/default-views.js +21 -9
- package/src/components/sidebar-dataviews/index.js +36 -1
- package/src/components/sidebar-navigation-screen-global-styles/content.js +55 -0
- package/src/components/sidebar-navigation-screen-global-styles/index.js +1 -55
- package/src/hooks/push-changes-to-global-styles/index.js +1 -1
- package/src/index.js +7 -1
- package/src/posts.scss +1 -1
- package/src/store/selectors.js +53 -14
- package/src/store/test/selectors.js +1 -26
- package/src/style.scss +2 -1
- package/src/utils/get-filtered-template-parts.js +61 -0
- package/src/utils/test/get-filtered-template-parts.js +127 -0
- package/build/components/global-styles/screen-background.js +0 -36
- package/build/components/global-styles/screen-background.js.map +0 -1
- package/build/components/posts-app/posts-list.js +0 -568
- package/build/components/posts-app/posts-list.js.map +0 -1
- package/build-module/components/global-styles/screen-background.js +0 -30
- package/build-module/components/global-styles/screen-background.js.map +0 -1
- package/build-module/components/posts-app/posts-list.js +0 -560
- package/build-module/components/posts-app/posts-list.js.map +0 -1
- package/src/components/global-styles/screen-background.js +0 -29
- package/src/components/posts-app/posts-list.js +0 -651
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { Button } from '@wordpress/components';
|
|
5
|
+
import { useEntityRecords, store as coreStore } from '@wordpress/core-data';
|
|
6
|
+
import { useState, useMemo, useCallback, useEffect } from '@wordpress/element';
|
|
7
|
+
import { privateApis as routerPrivateApis } from '@wordpress/router';
|
|
8
|
+
import { useSelect, useDispatch } from '@wordpress/data';
|
|
9
|
+
import { DataViews } from '@wordpress/dataviews';
|
|
10
|
+
import { privateApis as editorPrivateApis } from '@wordpress/editor';
|
|
11
|
+
import { __ } from '@wordpress/i18n';
|
|
12
|
+
import { drawerRight } from '@wordpress/icons';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Internal dependencies
|
|
16
|
+
*/
|
|
17
|
+
import Page from '../page';
|
|
18
|
+
import { useDefaultViews, defaultLayouts } from '../sidebar-dataviews/default-views';
|
|
19
|
+
import { OPERATOR_IS_ANY, OPERATOR_IS_NONE, LAYOUT_LIST } from '../../utils/constants';
|
|
20
|
+
import AddNewPostModal from '../add-new-post';
|
|
21
|
+
import { unlock } from '../../lock-unlock';
|
|
22
|
+
import { useEditPostAction } from '../dataviews-actions';
|
|
23
|
+
import { usePrevious } from '@wordpress/compose';
|
|
24
|
+
import usePostFields from '../post-fields';
|
|
25
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
26
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
27
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
28
|
+
const {
|
|
29
|
+
usePostActions
|
|
30
|
+
} = unlock(editorPrivateApis);
|
|
31
|
+
const {
|
|
32
|
+
useLocation,
|
|
33
|
+
useHistory
|
|
34
|
+
} = unlock(routerPrivateApis);
|
|
35
|
+
const EMPTY_ARRAY = [];
|
|
36
|
+
function useView(postType) {
|
|
37
|
+
const {
|
|
38
|
+
params: {
|
|
39
|
+
activeView = 'all',
|
|
40
|
+
isCustom = 'false',
|
|
41
|
+
layout
|
|
42
|
+
}
|
|
43
|
+
} = useLocation();
|
|
44
|
+
const history = useHistory();
|
|
45
|
+
const DEFAULT_VIEWS = useDefaultViews({
|
|
46
|
+
postType
|
|
47
|
+
});
|
|
48
|
+
const selectedDefaultView = useMemo(() => {
|
|
49
|
+
const defaultView = isCustom === 'false' && DEFAULT_VIEWS[postType].find(({
|
|
50
|
+
slug
|
|
51
|
+
}) => slug === activeView)?.view;
|
|
52
|
+
if (isCustom === 'false' && layout) {
|
|
53
|
+
return {
|
|
54
|
+
...defaultView,
|
|
55
|
+
type: layout,
|
|
56
|
+
layout: defaultLayouts[layout]?.layout
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
return defaultView;
|
|
60
|
+
}, [isCustom, activeView, layout, postType, DEFAULT_VIEWS]);
|
|
61
|
+
const [view, setView] = useState(selectedDefaultView);
|
|
62
|
+
useEffect(() => {
|
|
63
|
+
if (selectedDefaultView) {
|
|
64
|
+
setView(selectedDefaultView);
|
|
65
|
+
}
|
|
66
|
+
}, [selectedDefaultView]);
|
|
67
|
+
const editedViewRecord = useSelect(select => {
|
|
68
|
+
if (isCustom !== 'true') {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
const {
|
|
72
|
+
getEditedEntityRecord
|
|
73
|
+
} = select(coreStore);
|
|
74
|
+
const dataviewRecord = getEditedEntityRecord('postType', 'wp_dataviews', Number(activeView));
|
|
75
|
+
return dataviewRecord;
|
|
76
|
+
}, [activeView, isCustom]);
|
|
77
|
+
const {
|
|
78
|
+
editEntityRecord
|
|
79
|
+
} = useDispatch(coreStore);
|
|
80
|
+
const customView = useMemo(() => {
|
|
81
|
+
const storedView = editedViewRecord?.content && JSON.parse(editedViewRecord?.content);
|
|
82
|
+
if (!storedView) {
|
|
83
|
+
return storedView;
|
|
84
|
+
}
|
|
85
|
+
return {
|
|
86
|
+
...storedView,
|
|
87
|
+
layout: defaultLayouts[storedView?.type]?.layout
|
|
88
|
+
};
|
|
89
|
+
}, [editedViewRecord?.content]);
|
|
90
|
+
const setCustomView = useCallback(viewToSet => {
|
|
91
|
+
editEntityRecord('postType', 'wp_dataviews', editedViewRecord?.id, {
|
|
92
|
+
content: JSON.stringify(viewToSet)
|
|
93
|
+
});
|
|
94
|
+
}, [editEntityRecord, editedViewRecord?.id]);
|
|
95
|
+
const setDefaultViewAndUpdateUrl = useCallback(viewToSet => {
|
|
96
|
+
if (viewToSet.type !== view?.type) {
|
|
97
|
+
const {
|
|
98
|
+
params
|
|
99
|
+
} = history.getLocationWithParams();
|
|
100
|
+
history.push({
|
|
101
|
+
...params,
|
|
102
|
+
layout: viewToSet.type
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
setView(viewToSet);
|
|
106
|
+
}, [history, view?.type]);
|
|
107
|
+
if (isCustom === 'false') {
|
|
108
|
+
return [view, setDefaultViewAndUpdateUrl];
|
|
109
|
+
} else if (isCustom === 'true' && customView) {
|
|
110
|
+
return [customView, setCustomView];
|
|
111
|
+
}
|
|
112
|
+
// Loading state where no the view was not found on custom views or default views.
|
|
113
|
+
return [DEFAULT_VIEWS[postType][0].view, setDefaultViewAndUpdateUrl];
|
|
114
|
+
}
|
|
115
|
+
const DEFAULT_STATUSES = 'draft,future,pending,private,publish'; // All but 'trash'.
|
|
116
|
+
|
|
117
|
+
function getItemId(item) {
|
|
118
|
+
return item.id.toString();
|
|
119
|
+
}
|
|
120
|
+
export default function PostList({
|
|
121
|
+
postType
|
|
122
|
+
}) {
|
|
123
|
+
var _postId$split, _records$map, _usePrevious;
|
|
124
|
+
const [view, setView] = useView(postType);
|
|
125
|
+
const history = useHistory();
|
|
126
|
+
const location = useLocation();
|
|
127
|
+
const {
|
|
128
|
+
postId,
|
|
129
|
+
quickEdit = false
|
|
130
|
+
} = location.params;
|
|
131
|
+
const [selection, setSelection] = useState((_postId$split = postId?.split(',')) !== null && _postId$split !== void 0 ? _postId$split : []);
|
|
132
|
+
const onChangeSelection = useCallback(items => {
|
|
133
|
+
var _params$isCustom;
|
|
134
|
+
setSelection(items);
|
|
135
|
+
const {
|
|
136
|
+
params
|
|
137
|
+
} = history.getLocationWithParams();
|
|
138
|
+
if (((_params$isCustom = params.isCustom) !== null && _params$isCustom !== void 0 ? _params$isCustom : 'false') === 'false') {
|
|
139
|
+
history.push({
|
|
140
|
+
...params,
|
|
141
|
+
postId: items.join(',')
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
}, [history]);
|
|
145
|
+
const queryArgs = useMemo(() => {
|
|
146
|
+
const filters = {};
|
|
147
|
+
view.filters.forEach(filter => {
|
|
148
|
+
if (filter.field === 'status' && filter.operator === OPERATOR_IS_ANY) {
|
|
149
|
+
filters.status = filter.value;
|
|
150
|
+
}
|
|
151
|
+
if (filter.field === 'author' && filter.operator === OPERATOR_IS_ANY) {
|
|
152
|
+
filters.author = filter.value;
|
|
153
|
+
} else if (filter.field === 'author' && filter.operator === OPERATOR_IS_NONE) {
|
|
154
|
+
filters.author_exclude = filter.value;
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
// We want to provide a different default item for the status filter
|
|
158
|
+
// than the REST API provides.
|
|
159
|
+
if (!filters.status || filters.status === '') {
|
|
160
|
+
filters.status = DEFAULT_STATUSES;
|
|
161
|
+
}
|
|
162
|
+
return {
|
|
163
|
+
per_page: view.perPage,
|
|
164
|
+
page: view.page,
|
|
165
|
+
_embed: 'author',
|
|
166
|
+
order: view.sort?.direction,
|
|
167
|
+
orderby: view.sort?.field,
|
|
168
|
+
search: view.search,
|
|
169
|
+
...filters
|
|
170
|
+
};
|
|
171
|
+
}, [view]);
|
|
172
|
+
const {
|
|
173
|
+
records,
|
|
174
|
+
isResolving: isLoadingMainEntities,
|
|
175
|
+
totalItems,
|
|
176
|
+
totalPages
|
|
177
|
+
} = useEntityRecords('postType', postType, queryArgs);
|
|
178
|
+
const ids = (_records$map = records?.map(record => getItemId(record))) !== null && _records$map !== void 0 ? _records$map : [];
|
|
179
|
+
const prevIds = (_usePrevious = usePrevious(ids)) !== null && _usePrevious !== void 0 ? _usePrevious : [];
|
|
180
|
+
const deletedIds = prevIds.filter(id => !ids.includes(id));
|
|
181
|
+
const postIdWasDeleted = deletedIds.includes(postId);
|
|
182
|
+
useEffect(() => {
|
|
183
|
+
if (postIdWasDeleted) {
|
|
184
|
+
history.push({
|
|
185
|
+
...history.getLocationWithParams().params,
|
|
186
|
+
postId: undefined
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
}, [postIdWasDeleted, history]);
|
|
190
|
+
const paginationInfo = useMemo(() => ({
|
|
191
|
+
totalItems,
|
|
192
|
+
totalPages
|
|
193
|
+
}), [totalItems, totalPages]);
|
|
194
|
+
const {
|
|
195
|
+
labels,
|
|
196
|
+
canCreateRecord
|
|
197
|
+
} = useSelect(select => {
|
|
198
|
+
const {
|
|
199
|
+
getPostType,
|
|
200
|
+
canUser
|
|
201
|
+
} = select(coreStore);
|
|
202
|
+
return {
|
|
203
|
+
labels: getPostType(postType)?.labels,
|
|
204
|
+
canCreateRecord: canUser('create', {
|
|
205
|
+
kind: 'postType',
|
|
206
|
+
name: postType
|
|
207
|
+
})
|
|
208
|
+
};
|
|
209
|
+
}, [postType]);
|
|
210
|
+
const postTypeActions = usePostActions({
|
|
211
|
+
postType,
|
|
212
|
+
context: 'list'
|
|
213
|
+
});
|
|
214
|
+
const editAction = useEditPostAction();
|
|
215
|
+
const actions = useMemo(() => [editAction, ...postTypeActions], [postTypeActions, editAction]);
|
|
216
|
+
const [showAddPostModal, setShowAddPostModal] = useState(false);
|
|
217
|
+
const openModal = () => setShowAddPostModal(true);
|
|
218
|
+
const closeModal = () => setShowAddPostModal(false);
|
|
219
|
+
const handleNewPage = ({
|
|
220
|
+
type,
|
|
221
|
+
id
|
|
222
|
+
}) => {
|
|
223
|
+
history.push({
|
|
224
|
+
postId: id,
|
|
225
|
+
postType: type,
|
|
226
|
+
canvas: 'edit'
|
|
227
|
+
});
|
|
228
|
+
closeModal();
|
|
229
|
+
};
|
|
230
|
+
const {
|
|
231
|
+
isLoading: isLoadingFields,
|
|
232
|
+
fields
|
|
233
|
+
} = usePostFields(view.type);
|
|
234
|
+
return /*#__PURE__*/_jsx(Page, {
|
|
235
|
+
title: labels?.name,
|
|
236
|
+
actions: labels?.add_new_item && canCreateRecord && /*#__PURE__*/_jsxs(_Fragment, {
|
|
237
|
+
children: [/*#__PURE__*/_jsx(Button, {
|
|
238
|
+
variant: "primary",
|
|
239
|
+
onClick: openModal,
|
|
240
|
+
__next40pxDefaultSize: true,
|
|
241
|
+
children: labels.add_new_item
|
|
242
|
+
}), showAddPostModal && /*#__PURE__*/_jsx(AddNewPostModal, {
|
|
243
|
+
postType: postType,
|
|
244
|
+
onSave: handleNewPage,
|
|
245
|
+
onClose: closeModal
|
|
246
|
+
})]
|
|
247
|
+
}),
|
|
248
|
+
children: /*#__PURE__*/_jsx(DataViews, {
|
|
249
|
+
paginationInfo: paginationInfo,
|
|
250
|
+
fields: fields,
|
|
251
|
+
actions: actions,
|
|
252
|
+
data: records || EMPTY_ARRAY,
|
|
253
|
+
isLoading: isLoadingMainEntities || isLoadingFields,
|
|
254
|
+
view: view,
|
|
255
|
+
onChangeView: setView,
|
|
256
|
+
selection: selection,
|
|
257
|
+
onChangeSelection: onChangeSelection,
|
|
258
|
+
getItemId: getItemId,
|
|
259
|
+
defaultLayouts: defaultLayouts,
|
|
260
|
+
header: window.__experimentalQuickEditDataViews && view.type !== LAYOUT_LIST && postType === 'page' && /*#__PURE__*/_jsx(Button, {
|
|
261
|
+
size: "compact",
|
|
262
|
+
isPressed: quickEdit,
|
|
263
|
+
icon: drawerRight,
|
|
264
|
+
label: !quickEdit ? __('Show quick edit sidebar') : __('Close quick edit sidebar'),
|
|
265
|
+
onClick: () => {
|
|
266
|
+
history.push({
|
|
267
|
+
...location.params,
|
|
268
|
+
quickEdit: quickEdit ? undefined : true
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
})
|
|
272
|
+
})
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Button","useEntityRecords","store","coreStore","useState","useMemo","useCallback","useEffect","privateApis","routerPrivateApis","useSelect","useDispatch","DataViews","editorPrivateApis","__","drawerRight","Page","useDefaultViews","defaultLayouts","OPERATOR_IS_ANY","OPERATOR_IS_NONE","LAYOUT_LIST","AddNewPostModal","unlock","useEditPostAction","usePrevious","usePostFields","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","usePostActions","useLocation","useHistory","EMPTY_ARRAY","useView","postType","params","activeView","isCustom","layout","history","DEFAULT_VIEWS","selectedDefaultView","defaultView","find","slug","view","type","setView","editedViewRecord","select","getEditedEntityRecord","dataviewRecord","Number","editEntityRecord","customView","storedView","content","JSON","parse","setCustomView","viewToSet","id","stringify","setDefaultViewAndUpdateUrl","getLocationWithParams","push","DEFAULT_STATUSES","getItemId","item","toString","PostList","_postId$split","_records$map","_usePrevious","location","postId","quickEdit","selection","setSelection","split","onChangeSelection","items","_params$isCustom","join","queryArgs","filters","forEach","filter","field","operator","status","value","author","author_exclude","per_page","perPage","page","_embed","order","sort","direction","orderby","search","records","isResolving","isLoadingMainEntities","totalItems","totalPages","ids","map","record","prevIds","deletedIds","includes","postIdWasDeleted","undefined","paginationInfo","labels","canCreateRecord","getPostType","canUser","kind","name","postTypeActions","context","editAction","actions","showAddPostModal","setShowAddPostModal","openModal","closeModal","handleNewPage","canvas","isLoading","isLoadingFields","fields","title","add_new_item","children","variant","onClick","__next40pxDefaultSize","onSave","onClose","data","onChangeView","header","window","__experimentalQuickEditDataViews","size","isPressed","icon","label"],"sources":["@wordpress/edit-site/src/components/post-list/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Button } from '@wordpress/components';\nimport { useEntityRecords, store as coreStore } from '@wordpress/core-data';\nimport { useState, useMemo, useCallback, useEffect } from '@wordpress/element';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { DataViews } from '@wordpress/dataviews';\nimport { privateApis as editorPrivateApis } from '@wordpress/editor';\nimport { __ } from '@wordpress/i18n';\nimport { drawerRight } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport Page from '../page';\nimport {\n\tuseDefaultViews,\n\tdefaultLayouts,\n} from '../sidebar-dataviews/default-views';\nimport {\n\tOPERATOR_IS_ANY,\n\tOPERATOR_IS_NONE,\n\tLAYOUT_LIST,\n} from '../../utils/constants';\n\nimport AddNewPostModal from '../add-new-post';\nimport { unlock } from '../../lock-unlock';\nimport { useEditPostAction } from '../dataviews-actions';\nimport { usePrevious } from '@wordpress/compose';\nimport usePostFields from '../post-fields';\n\nconst { usePostActions } = unlock( editorPrivateApis );\nconst { useLocation, useHistory } = unlock( routerPrivateApis );\nconst EMPTY_ARRAY = [];\n\nfunction useView( postType ) {\n\tconst {\n\t\tparams: { activeView = 'all', isCustom = 'false', layout },\n\t} = useLocation();\n\tconst history = useHistory();\n\tconst DEFAULT_VIEWS = useDefaultViews( { postType } );\n\tconst selectedDefaultView = useMemo( () => {\n\t\tconst defaultView =\n\t\t\tisCustom === 'false' &&\n\t\t\tDEFAULT_VIEWS[ postType ].find(\n\t\t\t\t( { slug } ) => slug === activeView\n\t\t\t)?.view;\n\t\tif ( isCustom === 'false' && layout ) {\n\t\t\treturn {\n\t\t\t\t...defaultView,\n\t\t\t\ttype: layout,\n\t\t\t\tlayout: defaultLayouts[ layout ]?.layout,\n\t\t\t};\n\t\t}\n\t\treturn defaultView;\n\t}, [ isCustom, activeView, layout, postType, DEFAULT_VIEWS ] );\n\tconst [ view, setView ] = useState( selectedDefaultView );\n\n\tuseEffect( () => {\n\t\tif ( selectedDefaultView ) {\n\t\t\tsetView( selectedDefaultView );\n\t\t}\n\t}, [ selectedDefaultView ] );\n\tconst editedViewRecord = useSelect(\n\t\t( select ) => {\n\t\t\tif ( isCustom !== 'true' ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst { getEditedEntityRecord } = select( coreStore );\n\t\t\tconst dataviewRecord = getEditedEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\t'wp_dataviews',\n\t\t\t\tNumber( activeView )\n\t\t\t);\n\t\t\treturn dataviewRecord;\n\t\t},\n\t\t[ activeView, isCustom ]\n\t);\n\tconst { editEntityRecord } = useDispatch( coreStore );\n\n\tconst customView = useMemo( () => {\n\t\tconst storedView =\n\t\t\teditedViewRecord?.content &&\n\t\t\tJSON.parse( editedViewRecord?.content );\n\t\tif ( ! storedView ) {\n\t\t\treturn storedView;\n\t\t}\n\n\t\treturn {\n\t\t\t...storedView,\n\t\t\tlayout: defaultLayouts[ storedView?.type ]?.layout,\n\t\t};\n\t}, [ editedViewRecord?.content ] );\n\n\tconst setCustomView = useCallback(\n\t\t( viewToSet ) => {\n\t\t\teditEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\t'wp_dataviews',\n\t\t\t\teditedViewRecord?.id,\n\t\t\t\t{\n\t\t\t\t\tcontent: JSON.stringify( viewToSet ),\n\t\t\t\t}\n\t\t\t);\n\t\t},\n\t\t[ editEntityRecord, editedViewRecord?.id ]\n\t);\n\n\tconst setDefaultViewAndUpdateUrl = useCallback(\n\t\t( viewToSet ) => {\n\t\t\tif ( viewToSet.type !== view?.type ) {\n\t\t\t\tconst { params } = history.getLocationWithParams();\n\t\t\t\thistory.push( {\n\t\t\t\t\t...params,\n\t\t\t\t\tlayout: viewToSet.type,\n\t\t\t\t} );\n\t\t\t}\n\t\t\tsetView( viewToSet );\n\t\t},\n\t\t[ history, view?.type ]\n\t);\n\n\tif ( isCustom === 'false' ) {\n\t\treturn [ view, setDefaultViewAndUpdateUrl ];\n\t} else if ( isCustom === 'true' && customView ) {\n\t\treturn [ customView, setCustomView ];\n\t}\n\t// Loading state where no the view was not found on custom views or default views.\n\treturn [ DEFAULT_VIEWS[ postType ][ 0 ].view, setDefaultViewAndUpdateUrl ];\n}\n\nconst DEFAULT_STATUSES = 'draft,future,pending,private,publish'; // All but 'trash'.\n\nfunction getItemId( item ) {\n\treturn item.id.toString();\n}\n\nexport default function PostList( { postType } ) {\n\tconst [ view, setView ] = useView( postType );\n\tconst history = useHistory();\n\tconst location = useLocation();\n\tconst { postId, quickEdit = false } = location.params;\n\tconst [ selection, setSelection ] = useState( postId?.split( ',' ) ?? [] );\n\tconst onChangeSelection = useCallback(\n\t\t( items ) => {\n\t\t\tsetSelection( items );\n\t\t\tconst { params } = history.getLocationWithParams();\n\t\t\tif ( ( params.isCustom ?? 'false' ) === 'false' ) {\n\t\t\t\thistory.push( {\n\t\t\t\t\t...params,\n\t\t\t\t\tpostId: items.join( ',' ),\n\t\t\t\t} );\n\t\t\t}\n\t\t},\n\t\t[ history ]\n\t);\n\n\tconst queryArgs = useMemo( () => {\n\t\tconst filters = {};\n\t\tview.filters.forEach( ( filter ) => {\n\t\t\tif (\n\t\t\t\tfilter.field === 'status' &&\n\t\t\t\tfilter.operator === OPERATOR_IS_ANY\n\t\t\t) {\n\t\t\t\tfilters.status = filter.value;\n\t\t\t}\n\t\t\tif (\n\t\t\t\tfilter.field === 'author' &&\n\t\t\t\tfilter.operator === OPERATOR_IS_ANY\n\t\t\t) {\n\t\t\t\tfilters.author = filter.value;\n\t\t\t} else if (\n\t\t\t\tfilter.field === 'author' &&\n\t\t\t\tfilter.operator === OPERATOR_IS_NONE\n\t\t\t) {\n\t\t\t\tfilters.author_exclude = filter.value;\n\t\t\t}\n\t\t} );\n\t\t// We want to provide a different default item for the status filter\n\t\t// than the REST API provides.\n\t\tif ( ! filters.status || filters.status === '' ) {\n\t\t\tfilters.status = DEFAULT_STATUSES;\n\t\t}\n\n\t\treturn {\n\t\t\tper_page: view.perPage,\n\t\t\tpage: view.page,\n\t\t\t_embed: 'author',\n\t\t\torder: view.sort?.direction,\n\t\t\torderby: view.sort?.field,\n\t\t\tsearch: view.search,\n\t\t\t...filters,\n\t\t};\n\t}, [ view ] );\n\tconst {\n\t\trecords,\n\t\tisResolving: isLoadingMainEntities,\n\t\ttotalItems,\n\t\ttotalPages,\n\t} = useEntityRecords( 'postType', postType, queryArgs );\n\n\tconst ids = records?.map( ( record ) => getItemId( record ) ) ?? [];\n\tconst prevIds = usePrevious( ids ) ?? [];\n\tconst deletedIds = prevIds.filter( ( id ) => ! ids.includes( id ) );\n\tconst postIdWasDeleted = deletedIds.includes( postId );\n\n\tuseEffect( () => {\n\t\tif ( postIdWasDeleted ) {\n\t\t\thistory.push( {\n\t\t\t\t...history.getLocationWithParams().params,\n\t\t\t\tpostId: undefined,\n\t\t\t} );\n\t\t}\n\t}, [ postIdWasDeleted, history ] );\n\n\tconst paginationInfo = useMemo(\n\t\t() => ( {\n\t\t\ttotalItems,\n\t\t\ttotalPages,\n\t\t} ),\n\t\t[ totalItems, totalPages ]\n\t);\n\n\tconst { labels, canCreateRecord } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getPostType, canUser } = select( coreStore );\n\t\t\treturn {\n\t\t\t\tlabels: getPostType( postType )?.labels,\n\t\t\t\tcanCreateRecord: canUser( 'create', {\n\t\t\t\t\tkind: 'postType',\n\t\t\t\t\tname: postType,\n\t\t\t\t} ),\n\t\t\t};\n\t\t},\n\t\t[ postType ]\n\t);\n\n\tconst postTypeActions = usePostActions( {\n\t\tpostType,\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 [ showAddPostModal, setShowAddPostModal ] = useState( false );\n\n\tconst openModal = () => setShowAddPostModal( true );\n\tconst closeModal = () => setShowAddPostModal( false );\n\tconst handleNewPage = ( { type, id } ) => {\n\t\thistory.push( {\n\t\t\tpostId: id,\n\t\t\tpostType: type,\n\t\t\tcanvas: 'edit',\n\t\t} );\n\t\tcloseModal();\n\t};\n\tconst { isLoading: isLoadingFields, fields } = usePostFields( view.type );\n\n\treturn (\n\t\t<Page\n\t\t\ttitle={ labels?.name }\n\t\t\tactions={\n\t\t\t\tlabels?.add_new_item &&\n\t\t\t\tcanCreateRecord && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\tonClick={ openModal }\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ labels.add_new_item }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t{ showAddPostModal && (\n\t\t\t\t\t\t\t<AddNewPostModal\n\t\t\t\t\t\t\t\tpostType={ postType }\n\t\t\t\t\t\t\t\tonSave={ handleNewPage }\n\t\t\t\t\t\t\t\tonClose={ closeModal }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</>\n\t\t\t\t)\n\t\t\t}\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={ records || EMPTY_ARRAY }\n\t\t\t\tisLoading={ isLoadingMainEntities || isLoadingFields }\n\t\t\t\tview={ view }\n\t\t\t\tonChangeView={ setView }\n\t\t\t\tselection={ selection }\n\t\t\t\tonChangeSelection={ onChangeSelection }\n\t\t\t\tgetItemId={ getItemId }\n\t\t\t\tdefaultLayouts={ defaultLayouts }\n\t\t\t\theader={\n\t\t\t\t\twindow.__experimentalQuickEditDataViews &&\n\t\t\t\t\tview.type !== LAYOUT_LIST &&\n\t\t\t\t\tpostType === 'page' && (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\t\tisPressed={ quickEdit }\n\t\t\t\t\t\t\ticon={ drawerRight }\n\t\t\t\t\t\t\tlabel={\n\t\t\t\t\t\t\t\t! quickEdit\n\t\t\t\t\t\t\t\t\t? __( 'Show quick edit sidebar' )\n\t\t\t\t\t\t\t\t\t: __( 'Close quick edit sidebar' )\n\t\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C,SAAS,EAAEA,SAAS,GAAGuC,SAAS,GAAG;UACpC,CAAE,CAAC;QACJ;MAAG,CACH;IAEF,CACD;EAAC,CACG,CAAC;AAET","ignoreList":[]}
|
|
@@ -13,7 +13,7 @@ import Editor from '../editor';
|
|
|
13
13
|
import SidebarNavigationScreen from '../sidebar-navigation-screen';
|
|
14
14
|
import SidebarNavigationScreenMain from '../sidebar-navigation-screen-main';
|
|
15
15
|
import DataViewsSidebarContent from '../sidebar-dataviews';
|
|
16
|
-
import
|
|
16
|
+
import PostList from '../post-list';
|
|
17
17
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
18
18
|
const {
|
|
19
19
|
useLocation
|
|
@@ -42,7 +42,7 @@ export default function useLayoutAreas() {
|
|
|
42
42
|
isRoot: true,
|
|
43
43
|
content: /*#__PURE__*/_jsx(DataViewsSidebarContent, {})
|
|
44
44
|
}),
|
|
45
|
-
content: /*#__PURE__*/_jsx(
|
|
45
|
+
content: /*#__PURE__*/_jsx(PostList, {
|
|
46
46
|
postType: postType
|
|
47
47
|
}),
|
|
48
48
|
preview: (isListLayout || canvas === 'edit') && /*#__PURE__*/_jsx(Editor, {
|
|
@@ -50,7 +50,7 @@ export default function useLayoutAreas() {
|
|
|
50
50
|
}),
|
|
51
51
|
mobile: canvas === 'edit' ? /*#__PURE__*/_jsx(Editor, {
|
|
52
52
|
isPostsList: true
|
|
53
|
-
}) : /*#__PURE__*/_jsx(
|
|
53
|
+
}) : /*#__PURE__*/_jsx(PostList, {
|
|
54
54
|
postType: postType
|
|
55
55
|
})
|
|
56
56
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["privateApis","routerPrivateApis","useSelect","store","coreStore","unlock","Editor","SidebarNavigationScreen","SidebarNavigationScreenMain","DataViewsSidebarContent","
|
|
1
|
+
{"version":3,"names":["privateApis","routerPrivateApis","useSelect","store","coreStore","unlock","Editor","SidebarNavigationScreen","SidebarNavigationScreenMain","DataViewsSidebarContent","PostList","jsx","_jsx","useLocation","useLayoutAreas","params","postType","layout","canvas","labels","select","getPostType","includes","isListLayout","key","areas","sidebar","title","name","isRoot","content","preview","isPostsList","mobile","widths","undefined"],"sources":["@wordpress/edit-site/src/components/posts-app/router.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\nimport Editor from '../editor';\nimport SidebarNavigationScreen from '../sidebar-navigation-screen';\nimport SidebarNavigationScreenMain from '../sidebar-navigation-screen-main';\nimport DataViewsSidebarContent from '../sidebar-dataviews';\nimport PostList from '../post-list';\n\nconst { useLocation } = unlock( routerPrivateApis );\n\nexport default function useLayoutAreas() {\n\tconst { params = {} } = useLocation();\n\tconst { postType, layout, canvas } = params;\n\tconst labels = useSelect(\n\t\t( select ) => {\n\t\t\treturn select( coreStore ).getPostType( postType )?.labels;\n\t\t},\n\t\t[ postType ]\n\t);\n\n\t// Posts list.\n\tif ( [ 'post' ].includes( postType ) ) {\n\t\tconst isListLayout = layout === 'list' || ! layout;\n\t\treturn {\n\t\t\tkey: 'posts-list',\n\t\t\tareas: {\n\t\t\t\tsidebar: (\n\t\t\t\t\t<SidebarNavigationScreen\n\t\t\t\t\t\ttitle={ labels?.name }\n\t\t\t\t\t\tisRoot\n\t\t\t\t\t\tcontent={ <DataViewsSidebarContent /> }\n\t\t\t\t\t/>\n\t\t\t\t),\n\t\t\t\tcontent: <PostList postType={ postType } />,\n\t\t\t\tpreview: ( isListLayout || canvas === 'edit' ) && (\n\t\t\t\t\t<Editor isPostsList />\n\t\t\t\t),\n\t\t\t\tmobile:\n\t\t\t\t\tcanvas === 'edit' ? (\n\t\t\t\t\t\t<Editor isPostsList />\n\t\t\t\t\t) : (\n\t\t\t\t\t\t<PostList postType={ postType } />\n\t\t\t\t\t),\n\t\t\t},\n\t\t\twidths: {\n\t\t\t\tcontent: isListLayout ? 380 : undefined,\n\t\t\t},\n\t\t};\n\t}\n\n\t// Fallback shows the home page preview\n\treturn {\n\t\tkey: 'default',\n\t\tareas: {\n\t\t\tsidebar: <SidebarNavigationScreenMain />,\n\t\t\tpreview: <Editor isPostsList />,\n\t\t\tmobile: canvas === 'edit' && <Editor isPostsList />,\n\t\t},\n\t};\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,WAAW,IAAIC,iBAAiB,QAAQ,mBAAmB;AACpE,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;;AAEzD;AACA;AACA;AACA,SAASC,MAAM,QAAQ,mBAAmB;AAC1C,OAAOC,MAAM,MAAM,WAAW;AAC9B,OAAOC,uBAAuB,MAAM,8BAA8B;AAClE,OAAOC,2BAA2B,MAAM,mCAAmC;AAC3E,OAAOC,uBAAuB,MAAM,sBAAsB;AAC1D,OAAOC,QAAQ,MAAM,cAAc;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAEpC,MAAM;EAAEC;AAAY,CAAC,GAAGR,MAAM,CAAEJ,iBAAkB,CAAC;AAEnD,eAAe,SAASa,cAAcA,CAAA,EAAG;EACxC,MAAM;IAAEC,MAAM,GAAG,CAAC;EAAE,CAAC,GAAGF,WAAW,CAAC,CAAC;EACrC,MAAM;IAAEG,QAAQ;IAAEC,MAAM;IAAEC;EAAO,CAAC,GAAGH,MAAM;EAC3C,MAAMI,MAAM,GAAGjB,SAAS,CACrBkB,MAAM,IAAM;IACb,OAAOA,MAAM,CAAEhB,SAAU,CAAC,CAACiB,WAAW,CAAEL,QAAS,CAAC,EAAEG,MAAM;EAC3D,CAAC,EACD,CAAEH,QAAQ,CACX,CAAC;;EAED;EACA,IAAK,CAAE,MAAM,CAAE,CAACM,QAAQ,CAAEN,QAAS,CAAC,EAAG;IACtC,MAAMO,YAAY,GAAGN,MAAM,KAAK,MAAM,IAAI,CAAEA,MAAM;IAClD,OAAO;MACNO,GAAG,EAAE,YAAY;MACjBC,KAAK,EAAE;QACNC,OAAO,eACNd,IAAA,CAACL,uBAAuB;UACvBoB,KAAK,EAAGR,MAAM,EAAES,IAAM;UACtBC,MAAM;UACNC,OAAO,eAAGlB,IAAA,CAACH,uBAAuB,IAAE;QAAG,CACvC,CACD;QACDqB,OAAO,eAAElB,IAAA,CAACF,QAAQ;UAACM,QAAQ,EAAGA;QAAU,CAAE,CAAC;QAC3Ce,OAAO,EAAE,CAAER,YAAY,IAAIL,MAAM,KAAK,MAAM,kBAC3CN,IAAA,CAACN,MAAM;UAAC0B,WAAW;QAAA,CAAE,CACrB;QACDC,MAAM,EACLf,MAAM,KAAK,MAAM,gBAChBN,IAAA,CAACN,MAAM;UAAC0B,WAAW;QAAA,CAAE,CAAC,gBAEtBpB,IAAA,CAACF,QAAQ;UAACM,QAAQ,EAAGA;QAAU,CAAE;MAEpC,CAAC;MACDkB,MAAM,EAAE;QACPJ,OAAO,EAAEP,YAAY,GAAG,GAAG,GAAGY;MAC/B;IACD,CAAC;EACF;;EAEA;EACA,OAAO;IACNX,GAAG,EAAE,SAAS;IACdC,KAAK,EAAE;MACNC,OAAO,eAAEd,IAAA,CAACJ,2BAA2B,IAAE,CAAC;MACxCuB,OAAO,eAAEnB,IAAA,CAACN,MAAM;QAAC0B,WAAW;MAAA,CAAE,CAAC;MAC/BC,MAAM,EAAEf,MAAM,KAAK,MAAM,iBAAIN,IAAA,CAACN,MAAM;QAAC0B,WAAW;MAAA,CAAE;IACnD;EACD,CAAC;AACF","ignoreList":[]}
|
|
@@ -11,17 +11,31 @@ import { useMemo } from '@wordpress/element';
|
|
|
11
11
|
* Internal dependencies
|
|
12
12
|
*/
|
|
13
13
|
import { LAYOUT_LIST, LAYOUT_TABLE, LAYOUT_GRID, OPERATOR_IS_ANY } from '../../utils/constants';
|
|
14
|
-
export const
|
|
14
|
+
export const defaultLayouts = {
|
|
15
15
|
[LAYOUT_TABLE]: {
|
|
16
|
-
|
|
16
|
+
layout: {
|
|
17
|
+
primaryField: 'title',
|
|
18
|
+
styles: {
|
|
19
|
+
'featured-image': {
|
|
20
|
+
width: '1%'
|
|
21
|
+
},
|
|
22
|
+
title: {
|
|
23
|
+
maxWidth: 300
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
17
27
|
},
|
|
18
28
|
[LAYOUT_GRID]: {
|
|
19
|
-
|
|
20
|
-
|
|
29
|
+
layout: {
|
|
30
|
+
mediaField: 'featured-image',
|
|
31
|
+
primaryField: 'title'
|
|
32
|
+
}
|
|
21
33
|
},
|
|
22
34
|
[LAYOUT_LIST]: {
|
|
23
|
-
|
|
24
|
-
|
|
35
|
+
layout: {
|
|
36
|
+
primaryField: 'title',
|
|
37
|
+
mediaField: 'featured-image'
|
|
38
|
+
}
|
|
25
39
|
}
|
|
26
40
|
};
|
|
27
41
|
const DEFAULT_POST_BASE = {
|
|
@@ -35,9 +49,7 @@ const DEFAULT_POST_BASE = {
|
|
|
35
49
|
direction: 'desc'
|
|
36
50
|
},
|
|
37
51
|
fields: ['title', 'author', 'status'],
|
|
38
|
-
layout:
|
|
39
|
-
...DEFAULT_CONFIG_PER_VIEW_TYPE[LAYOUT_LIST]
|
|
40
|
-
}
|
|
52
|
+
layout: defaultLayouts[LAYOUT_LIST].layout
|
|
41
53
|
};
|
|
42
54
|
export function useDefaultViews({
|
|
43
55
|
postType
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__","trash","pages","drafts","published","scheduled","pending","notAllowed","useSelect","store","coreStore","useMemo","LAYOUT_LIST","LAYOUT_TABLE","LAYOUT_GRID","OPERATOR_IS_ANY","
|
|
1
|
+
{"version":3,"names":["__","trash","pages","drafts","published","scheduled","pending","notAllowed","useSelect","store","coreStore","useMemo","LAYOUT_LIST","LAYOUT_TABLE","LAYOUT_GRID","OPERATOR_IS_ANY","defaultLayouts","layout","primaryField","styles","width","title","maxWidth","mediaField","DEFAULT_POST_BASE","type","search","filters","page","perPage","sort","field","direction","fields","useDefaultViews","postType","labels","select","getPostType","all_items","slug","icon","view","operator","value"],"sources":["@wordpress/edit-site/src/components/sidebar-dataviews/default-views.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\n\nimport {\n\ttrash,\n\tpages,\n\tdrafts,\n\tpublished,\n\tscheduled,\n\tpending,\n\tnotAllowed,\n} from '@wordpress/icons';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport {\n\tLAYOUT_LIST,\n\tLAYOUT_TABLE,\n\tLAYOUT_GRID,\n\tOPERATOR_IS_ANY,\n} from '../../utils/constants';\n\nexport const defaultLayouts = {\n\t[ LAYOUT_TABLE ]: {\n\t\tlayout: {\n\t\t\tprimaryField: 'title',\n\t\t\tstyles: {\n\t\t\t\t'featured-image': {\n\t\t\t\t\twidth: '1%',\n\t\t\t\t},\n\t\t\t\ttitle: {\n\t\t\t\t\tmaxWidth: 300,\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t},\n\t[ LAYOUT_GRID ]: {\n\t\tlayout: {\n\t\t\tmediaField: 'featured-image',\n\t\t\tprimaryField: 'title',\n\t\t},\n\t},\n\t[ LAYOUT_LIST ]: {\n\t\tlayout: {\n\t\t\tprimaryField: 'title',\n\t\t\tmediaField: 'featured-image',\n\t\t},\n\t},\n};\n\nconst DEFAULT_POST_BASE = {\n\ttype: LAYOUT_LIST,\n\tsearch: '',\n\tfilters: [],\n\tpage: 1,\n\tperPage: 20,\n\tsort: {\n\t\tfield: 'date',\n\t\tdirection: 'desc',\n\t},\n\tfields: [ 'title', 'author', 'status' ],\n\tlayout: defaultLayouts[ LAYOUT_LIST ].layout,\n};\n\nexport function useDefaultViews( { postType } ) {\n\tconst labels = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getPostType } = select( coreStore );\n\t\t\treturn getPostType( postType )?.labels;\n\t\t},\n\t\t[ postType ]\n\t);\n\treturn useMemo( () => {\n\t\treturn {\n\t\t\t[ postType ]: [\n\t\t\t\t{\n\t\t\t\t\ttitle: labels?.all_items || __( 'All items' ),\n\t\t\t\t\tslug: 'all',\n\t\t\t\t\ticon: pages,\n\t\t\t\t\tview: DEFAULT_POST_BASE,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\ttitle: __( 'Published' ),\n\t\t\t\t\tslug: 'published',\n\t\t\t\t\ticon: published,\n\t\t\t\t\tview: {\n\t\t\t\t\t\t...DEFAULT_POST_BASE,\n\t\t\t\t\t\tfilters: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tfield: 'status',\n\t\t\t\t\t\t\t\toperator: OPERATOR_IS_ANY,\n\t\t\t\t\t\t\t\tvalue: 'publish',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\ttitle: __( 'Scheduled' ),\n\t\t\t\t\tslug: 'future',\n\t\t\t\t\ticon: scheduled,\n\t\t\t\t\tview: {\n\t\t\t\t\t\t...DEFAULT_POST_BASE,\n\t\t\t\t\t\tfilters: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tfield: 'status',\n\t\t\t\t\t\t\t\toperator: OPERATOR_IS_ANY,\n\t\t\t\t\t\t\t\tvalue: 'future',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\ttitle: __( 'Drafts' ),\n\t\t\t\t\tslug: 'drafts',\n\t\t\t\t\ticon: drafts,\n\t\t\t\t\tview: {\n\t\t\t\t\t\t...DEFAULT_POST_BASE,\n\t\t\t\t\t\tfilters: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tfield: 'status',\n\t\t\t\t\t\t\t\toperator: OPERATOR_IS_ANY,\n\t\t\t\t\t\t\t\tvalue: 'draft',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\ttitle: __( 'Pending' ),\n\t\t\t\t\tslug: 'pending',\n\t\t\t\t\ticon: pending,\n\t\t\t\t\tview: {\n\t\t\t\t\t\t...DEFAULT_POST_BASE,\n\t\t\t\t\t\tfilters: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tfield: 'status',\n\t\t\t\t\t\t\t\toperator: OPERATOR_IS_ANY,\n\t\t\t\t\t\t\t\tvalue: 'pending',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\ttitle: __( 'Private' ),\n\t\t\t\t\tslug: 'private',\n\t\t\t\t\ticon: notAllowed,\n\t\t\t\t\tview: {\n\t\t\t\t\t\t...DEFAULT_POST_BASE,\n\t\t\t\t\t\tfilters: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tfield: 'status',\n\t\t\t\t\t\t\t\toperator: OPERATOR_IS_ANY,\n\t\t\t\t\t\t\t\tvalue: 'private',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\ttitle: __( 'Trash' ),\n\t\t\t\t\tslug: 'trash',\n\t\t\t\t\ticon: trash,\n\t\t\t\t\tview: {\n\t\t\t\t\t\t...DEFAULT_POST_BASE,\n\t\t\t\t\t\tfilters: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tfield: 'status',\n\t\t\t\t\t\t\t\toperator: OPERATOR_IS_ANY,\n\t\t\t\t\t\t\t\tvalue: 'trash',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t],\n\t\t};\n\t}, [ labels, postType ] );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;A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IAAI,EAAE,SAAS;QACfC,IAAI,EAAEnC,OAAO;QACboC,IAAI,EAAE;UACL,GAAGlB,iBAAiB;UACpBG,OAAO,EAAE,CACR;YACCI,KAAK,EAAE,QAAQ;YACfY,QAAQ,EAAE5B,eAAe;YACzB6B,KAAK,EAAE;UACR,CAAC;QAEH;MACD,CAAC,EACD;QACCvB,KAAK,EAAErB,EAAE,CAAE,SAAU,CAAC;QACtBwC,IAAI,EAAE,SAAS;QACfC,IAAI,EAAElC,UAAU;QAChBmC,IAAI,EAAE;UACL,GAAGlB,iBAAiB;UACpBG,OAAO,EAAE,CACR;YACCI,KAAK,EAAE,QAAQ;YACfY,QAAQ,EAAE5B,eAAe;YACzB6B,KAAK,EAAE;UACR,CAAC;QAEH;MACD,CAAC,EACD;QACCvB,KAAK,EAAErB,EAAE,CAAE,OAAQ,CAAC;QACpBwC,IAAI,EAAE,OAAO;QACbC,IAAI,EAAExC,KAAK;QACXyC,IAAI,EAAE;UACL,GAAGlB,iBAAiB;UACpBG,OAAO,EAAE,CACR;YACCI,KAAK,EAAE,QAAQ;YACfY,QAAQ,EAAE5B,eAAe;YACzB6B,KAAK,EAAE;UACR,CAAC;QAEH;MACD,CAAC;IAEH,CAAC;EACF,CAAC,EAAE,CAAER,MAAM,EAAED,QAAQ,CAAG,CAAC;AAC1B","ignoreList":[]}
|
|
@@ -3,20 +3,58 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { __experimentalItemGroup as ItemGroup } from '@wordpress/components';
|
|
5
5
|
import { privateApis as routerPrivateApis } from '@wordpress/router';
|
|
6
|
+
import { useRef, useEffect } from '@wordpress/element';
|
|
7
|
+
import { usePrevious } from '@wordpress/compose';
|
|
6
8
|
|
|
7
9
|
/**
|
|
8
10
|
* Internal dependencies
|
|
9
11
|
*/
|
|
10
12
|
import { useDefaultViews } from './default-views';
|
|
11
13
|
import { unlock } from '../../lock-unlock';
|
|
12
|
-
const {
|
|
13
|
-
useLocation
|
|
14
|
-
} = unlock(routerPrivateApis);
|
|
15
14
|
import DataViewItem from './dataview-item';
|
|
16
15
|
import CustomDataViewsList from './custom-dataviews-list';
|
|
17
16
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
18
17
|
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
19
18
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
19
|
+
const {
|
|
20
|
+
useLocation,
|
|
21
|
+
useHistory
|
|
22
|
+
} = unlock(routerPrivateApis);
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Hook to switch to table layout when switching to the trash view.
|
|
26
|
+
* When going out of the trash view, it switches back to the previous layout if
|
|
27
|
+
* there was an automatic switch to table layout.
|
|
28
|
+
*/
|
|
29
|
+
function useSwitchToTableOnTrash() {
|
|
30
|
+
const {
|
|
31
|
+
params: {
|
|
32
|
+
activeView,
|
|
33
|
+
layout,
|
|
34
|
+
...restParams
|
|
35
|
+
}
|
|
36
|
+
} = useLocation();
|
|
37
|
+
const history = useHistory();
|
|
38
|
+
const viewToSwitchOutOfTrash = useRef(undefined);
|
|
39
|
+
const previousActiveView = usePrevious(activeView);
|
|
40
|
+
useEffect(() => {
|
|
41
|
+
if (activeView === 'trash' && previousActiveView !== 'trash') {
|
|
42
|
+
viewToSwitchOutOfTrash.current = layout || 'list';
|
|
43
|
+
history.push({
|
|
44
|
+
...restParams,
|
|
45
|
+
layout: 'table',
|
|
46
|
+
activeView
|
|
47
|
+
});
|
|
48
|
+
} else if (previousActiveView === 'trash' && activeView !== 'trash' && viewToSwitchOutOfTrash.current) {
|
|
49
|
+
history.push({
|
|
50
|
+
...restParams,
|
|
51
|
+
layout: viewToSwitchOutOfTrash.current,
|
|
52
|
+
activeView
|
|
53
|
+
});
|
|
54
|
+
viewToSwitchOutOfTrash.current = undefined;
|
|
55
|
+
}
|
|
56
|
+
}, [previousActiveView, activeView, layout, history, restParams]);
|
|
57
|
+
}
|
|
20
58
|
export default function DataViewsSidebarContent() {
|
|
21
59
|
const {
|
|
22
60
|
params: {
|
|
@@ -25,6 +63,7 @@ export default function DataViewsSidebarContent() {
|
|
|
25
63
|
isCustom = 'false'
|
|
26
64
|
}
|
|
27
65
|
} = useLocation();
|
|
66
|
+
useSwitchToTableOnTrash();
|
|
28
67
|
const DEFAULT_VIEWS = useDefaultViews({
|
|
29
68
|
postType
|
|
30
69
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__experimentalItemGroup","ItemGroup","privateApis","routerPrivateApis","
|
|
1
|
+
{"version":3,"names":["__experimentalItemGroup","ItemGroup","privateApis","routerPrivateApis","useRef","useEffect","usePrevious","useDefaultViews","unlock","DataViewItem","CustomDataViewsList","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","useLocation","useHistory","useSwitchToTableOnTrash","params","activeView","layout","restParams","history","viewToSwitchOutOfTrash","undefined","previousActiveView","current","push","DataViewsSidebarContent","postType","isCustom","DEFAULT_VIEWS","isCustomBoolean","children","map","dataview","slug","title","icon","type","view","isActive","window","__experimentalCustomViews"],"sources":["@wordpress/edit-site/src/components/sidebar-dataviews/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __experimentalItemGroup as ItemGroup } from '@wordpress/components';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\nimport { useRef, useEffect } from '@wordpress/element';\nimport { usePrevious } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { useDefaultViews } from './default-views';\nimport { unlock } from '../../lock-unlock';\nimport DataViewItem from './dataview-item';\nimport CustomDataViewsList from './custom-dataviews-list';\n\nconst { useLocation, useHistory } = unlock( routerPrivateApis );\n\n/**\n * Hook to switch to table layout when switching to the trash view.\n * When going out of the trash view, it switches back to the previous layout if\n * there was an automatic switch to table layout.\n */\nfunction useSwitchToTableOnTrash() {\n\tconst {\n\t\tparams: { activeView, layout, ...restParams },\n\t} = useLocation();\n\tconst history = useHistory();\n\tconst viewToSwitchOutOfTrash = useRef( undefined );\n\tconst previousActiveView = usePrevious( activeView );\n\tuseEffect( () => {\n\t\tif ( activeView === 'trash' && previousActiveView !== 'trash' ) {\n\t\t\tviewToSwitchOutOfTrash.current = layout || 'list';\n\t\t\thistory.push( { ...restParams, layout: 'table', activeView } );\n\t\t} else if (\n\t\t\tpreviousActiveView === 'trash' &&\n\t\t\tactiveView !== 'trash' &&\n\t\t\tviewToSwitchOutOfTrash.current\n\t\t) {\n\t\t\thistory.push( {\n\t\t\t\t...restParams,\n\t\t\t\tlayout: viewToSwitchOutOfTrash.current,\n\t\t\t\tactiveView,\n\t\t\t} );\n\t\t\tviewToSwitchOutOfTrash.current = undefined;\n\t\t}\n\t}, [ previousActiveView, activeView, layout, history, restParams ] );\n}\n\nexport default function DataViewsSidebarContent() {\n\tconst {\n\t\tparams: { postType, activeView = 'all', isCustom = 'false' },\n\t} = useLocation();\n\tuseSwitchToTableOnTrash();\n\tconst DEFAULT_VIEWS = useDefaultViews( { postType } );\n\tif ( ! postType ) {\n\t\treturn null;\n\t}\n\tconst isCustomBoolean = isCustom === 'true';\n\n\treturn (\n\t\t<>\n\t\t\t<ItemGroup>\n\t\t\t\t{ DEFAULT_VIEWS[ postType ].map( ( dataview ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<DataViewItem\n\t\t\t\t\t\t\tkey={ dataview.slug }\n\t\t\t\t\t\t\tslug={ dataview.slug }\n\t\t\t\t\t\t\ttitle={ dataview.title }\n\t\t\t\t\t\t\ticon={ dataview.icon }\n\t\t\t\t\t\t\ttype={ dataview.view.type }\n\t\t\t\t\t\t\tisActive={\n\t\t\t\t\t\t\t\t! isCustomBoolean &&\n\t\t\t\t\t\t\t\tdataview.slug === activeView\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tisCustom={ false }\n\t\t\t\t\t\t/>\n\t\t\t\t\t);\n\t\t\t\t} ) }\n\t\t\t</ItemGroup>\n\t\t\t{ window?.__experimentalCustomViews && (\n\t\t\t\t<CustomDataViewsList\n\t\t\t\t\tactiveView={ activeView }\n\t\t\t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,MAAM,EAAEC,yBAAyB,iBAClCjC,IAAA,CAACF,mBAAmB;MACnBW,UAAU,EAAGA,UAAY;MACzBoB,IAAI,EAAGV,QAAU;MACjBC,QAAQ;IAAA,CACR,CACD;EAAA,CACA,CAAC;AAEL","ignoreList":[]}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { __ } from '@wordpress/i18n';
|
|
5
|
+
import { useSelect } from '@wordpress/data';
|
|
6
|
+
import { __experimentalVStack as VStack } from '@wordpress/components';
|
|
7
|
+
import { BlockEditorProvider } from '@wordpress/block-editor';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Internal dependencies
|
|
11
|
+
*/
|
|
12
|
+
import StyleVariationsContainer from '../global-styles/style-variations-container';
|
|
13
|
+
import { unlock } from '../../lock-unlock';
|
|
14
|
+
import { store as editSiteStore } from '../../store';
|
|
15
|
+
import ColorVariations from '../global-styles/variations/variations-color';
|
|
16
|
+
import TypographyVariations from '../global-styles/variations/variations-typography';
|
|
17
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
18
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
19
|
+
const noop = () => {};
|
|
20
|
+
export default function SidebarNavigationScreenGlobalStylesContent() {
|
|
21
|
+
const {
|
|
22
|
+
storedSettings
|
|
23
|
+
} = useSelect(select => {
|
|
24
|
+
const {
|
|
25
|
+
getSettings
|
|
26
|
+
} = unlock(select(editSiteStore));
|
|
27
|
+
return {
|
|
28
|
+
storedSettings: getSettings()
|
|
29
|
+
};
|
|
30
|
+
}, []);
|
|
31
|
+
const gap = 3;
|
|
32
|
+
|
|
33
|
+
// Wrap in a BlockEditorProvider to ensure that the Iframe's dependencies are
|
|
34
|
+
// loaded. This is necessary because the Iframe component waits until
|
|
35
|
+
// the block editor store's `__internalIsInitialized` is true before
|
|
36
|
+
// rendering the iframe. Without this, the iframe previews will not render
|
|
37
|
+
// in mobile viewport sizes, where the editor canvas is hidden.
|
|
38
|
+
return /*#__PURE__*/_jsx(BlockEditorProvider, {
|
|
39
|
+
settings: storedSettings,
|
|
40
|
+
onChange: noop,
|
|
41
|
+
onInput: noop,
|
|
42
|
+
children: /*#__PURE__*/_jsxs(VStack, {
|
|
43
|
+
spacing: 10,
|
|
44
|
+
className: "edit-site-global-styles-variation-container",
|
|
45
|
+
children: [/*#__PURE__*/_jsx(StyleVariationsContainer, {
|
|
46
|
+
gap: gap
|
|
47
|
+
}), /*#__PURE__*/_jsx(ColorVariations, {
|
|
48
|
+
title: __('Palettes'),
|
|
49
|
+
gap: gap
|
|
50
|
+
}), /*#__PURE__*/_jsx(TypographyVariations, {
|
|
51
|
+
title: __('Typography'),
|
|
52
|
+
gap: gap
|
|
53
|
+
})]
|
|
54
|
+
})
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=content.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["__","useSelect","__experimentalVStack","VStack","BlockEditorProvider","StyleVariationsContainer","unlock","store","editSiteStore","ColorVariations","TypographyVariations","jsx","_jsx","jsxs","_jsxs","noop","SidebarNavigationScreenGlobalStylesContent","storedSettings","select","getSettings","gap","settings","onChange","onInput","children","spacing","className","title"],"sources":["@wordpress/edit-site/src/components/sidebar-navigation-screen-global-styles/content.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\nimport { __experimentalVStack as VStack } from '@wordpress/components';\nimport { BlockEditorProvider } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport StyleVariationsContainer from '../global-styles/style-variations-container';\nimport { unlock } from '../../lock-unlock';\nimport { store as editSiteStore } from '../../store';\nimport ColorVariations from '../global-styles/variations/variations-color';\nimport TypographyVariations from '../global-styles/variations/variations-typography';\n\nconst noop = () => {};\n\nexport default function SidebarNavigationScreenGlobalStylesContent() {\n\tconst { storedSettings } = useSelect( ( select ) => {\n\t\tconst { getSettings } = unlock( select( editSiteStore ) );\n\n\t\treturn {\n\t\t\tstoredSettings: getSettings(),\n\t\t};\n\t}, [] );\n\n\tconst gap = 3;\n\n\t// Wrap in a BlockEditorProvider to ensure that the Iframe's dependencies are\n\t// loaded. This is necessary because the Iframe component waits until\n\t// the block editor store's `__internalIsInitialized` is true before\n\t// rendering the iframe. Without this, the iframe previews will not render\n\t// in mobile viewport sizes, where the editor canvas is hidden.\n\treturn (\n\t\t<BlockEditorProvider\n\t\t\tsettings={ storedSettings }\n\t\t\tonChange={ noop }\n\t\t\tonInput={ noop }\n\t\t>\n\t\t\t<VStack\n\t\t\t\tspacing={ 10 }\n\t\t\t\tclassName=\"edit-site-global-styles-variation-container\"\n\t\t\t>\n\t\t\t\t<StyleVariationsContainer gap={ gap } />\n\t\t\t\t<ColorVariations title={ __( 'Palettes' ) } gap={ gap } />\n\t\t\t\t<TypographyVariations\n\t\t\t\t\ttitle={ __( 'Typography' ) }\n\t\t\t\t\tgap={ gap }\n\t\t\t\t/>\n\t\t\t</VStack>\n\t\t</BlockEditorProvider>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;AACpC,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,oBAAoB,IAAIC,MAAM,QAAQ,uBAAuB;AACtE,SAASC,mBAAmB,QAAQ,yBAAyB;;AAE7D;AACA;AACA;AACA,OAAOC,wBAAwB,MAAM,6CAA6C;AAClF,SAASC,MAAM,QAAQ,mBAAmB;AAC1C,SAASC,KAAK,IAAIC,aAAa,QAAQ,aAAa;AACpD,OAAOC,eAAe,MAAM,8CAA8C;AAC1E,OAAOC,oBAAoB,MAAM,mDAAmD;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAAA,SAAAC,IAAA,IAAAC,KAAA;AAErF,MAAMC,IAAI,GAAGA,CAAA,KAAM,CAAC,CAAC;AAErB,eAAe,SAASC,0CA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