@wordpress/edit-site 5.20.1 → 5.21.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/actions/trash-post.js +48 -0
- package/build/components/actions/trash-post.js.map +1 -0
- package/build/components/add-new-template/add-custom-template-modal-content.js +17 -13
- package/build/components/add-new-template/add-custom-template-modal-content.js.map +1 -1
- package/build/components/block-editor/resize-handle.js +2 -1
- package/build/components/block-editor/resize-handle.js.map +1 -1
- package/build/components/create-template-part-modal/index.js +10 -6
- package/build/components/create-template-part-modal/index.js.map +1 -1
- package/build/components/dataviews/dataviews.js +41 -32
- package/build/components/dataviews/dataviews.js.map +1 -1
- package/build/components/dataviews/field-actions.js +30 -0
- package/build/components/dataviews/field-actions.js.map +1 -0
- package/build/components/dataviews/filters.js +61 -0
- package/build/components/dataviews/filters.js.map +1 -0
- package/build/components/dataviews/in-filter.js +51 -0
- package/build/components/dataviews/in-filter.js.map +1 -0
- package/build/components/dataviews/index.js +0 -7
- package/build/components/dataviews/index.js.map +1 -1
- package/build/components/dataviews/pagination.js +75 -27
- package/build/components/dataviews/pagination.js.map +1 -1
- package/build/components/dataviews/text-filter.js +18 -12
- package/build/components/dataviews/text-filter.js.map +1 -1
- package/build/components/dataviews/view-actions.js +94 -56
- package/build/components/dataviews/view-actions.js.map +1 -1
- package/build/components/dataviews/view-grid.js +59 -0
- package/build/components/dataviews/view-grid.js.map +1 -0
- package/build/components/dataviews/view-list.js +283 -0
- package/build/components/dataviews/view-list.js.map +1 -0
- package/build/components/editor/index.js +2 -1
- package/build/components/editor/index.js.map +1 -1
- package/build/components/global-styles/font-library-modal/context.js +16 -10
- package/build/components/global-styles/font-library-modal/context.js.map +1 -1
- package/build/components/global-styles/font-library-modal/font-collection.js +20 -6
- package/build/components/global-styles/font-library-modal/font-collection.js.map +1 -1
- package/build/components/global-styles/screen-block.js +1 -2
- package/build/components/global-styles/screen-block.js.map +1 -1
- package/build/components/global-styles/screen-root.js +1 -2
- package/build/components/global-styles/screen-root.js.map +1 -1
- package/build/components/global-styles/ui.js +3 -4
- package/build/components/global-styles/ui.js.map +1 -1
- package/build/components/layout/index.js +10 -2
- package/build/components/layout/index.js.map +1 -1
- package/build/components/media/index.js +34 -0
- package/build/components/media/index.js.map +1 -0
- package/build/components/page-actions/index.js +0 -2
- package/build/components/page-actions/index.js.map +1 -1
- package/build/components/page-pages/index.js +153 -107
- package/build/components/page-pages/index.js.map +1 -1
- package/build/components/page-patterns/delete-category-menu-item.js +89 -0
- package/build/components/page-patterns/delete-category-menu-item.js.map +1 -0
- package/build/components/page-patterns/duplicate-menu-item.js +52 -131
- package/build/components/page-patterns/duplicate-menu-item.js.map +1 -1
- package/build/components/page-patterns/grid-item.js +1 -0
- package/build/components/page-patterns/grid-item.js.map +1 -1
- package/build/components/page-patterns/header.js +25 -3
- package/build/components/page-patterns/header.js.map +1 -1
- package/build/components/page-patterns/rename-category-menu-item.js +49 -0
- package/build/components/page-patterns/rename-category-menu-item.js.map +1 -0
- package/build/components/page-patterns/rename-menu-item.js +1 -1
- package/build/components/page-patterns/rename-menu-item.js.map +1 -1
- package/build/components/page-patterns/use-patterns.js +1 -0
- package/build/components/page-patterns/use-patterns.js.map +1 -1
- package/build/components/pattern-modal/duplicate.js +65 -0
- package/build/components/pattern-modal/duplicate.js.map +1 -0
- package/build/components/pattern-modal/index.js +24 -0
- package/build/components/pattern-modal/index.js.map +1 -0
- package/build/components/pattern-modal/rename.js +42 -0
- package/build/components/pattern-modal/rename.js.map +1 -0
- package/build/components/sidebar-edit-mode/template-panel/last-revision.js +3 -0
- package/build/components/sidebar-edit-mode/template-panel/last-revision.js.map +1 -1
- package/build/components/sidebar-navigation-screen-pattern/template-part-navigation-menu-list-item.js +2 -2
- package/build/components/sidebar-navigation-screen-pattern/template-part-navigation-menu-list-item.js.map +1 -1
- package/build/components/sidebar-navigation-screen-pattern/template-part-navigation-menu.js +2 -3
- package/build/components/sidebar-navigation-screen-pattern/template-part-navigation-menu.js.map +1 -1
- package/build/components/sidebar-navigation-screen-pattern/use-navigation-menu-title.js +29 -0
- package/build/components/sidebar-navigation-screen-pattern/use-navigation-menu-title.js.map +1 -0
- package/build/components/sidebar-navigation-screen-template/home-template-details.js +12 -1
- package/build/components/sidebar-navigation-screen-template/home-template-details.js.map +1 -1
- package/build/hooks/commands/use-common-commands.js +1 -2
- package/build/hooks/commands/use-common-commands.js.map +1 -1
- package/build/hooks/commands/use-edit-mode-commands.js +49 -0
- package/build/hooks/commands/use-edit-mode-commands.js.map +1 -1
- package/build/lock-unlock.js +1 -1
- package/build/lock-unlock.js.map +1 -1
- package/build/store/selectors.js +4 -5
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/actions/trash-post.js +41 -0
- package/build-module/components/actions/trash-post.js.map +1 -0
- package/build-module/components/add-new-template/add-custom-template-modal-content.js +16 -12
- package/build-module/components/add-new-template/add-custom-template-modal-content.js.map +1 -1
- package/build-module/components/block-editor/resize-handle.js +2 -1
- package/build-module/components/block-editor/resize-handle.js.map +1 -1
- package/build-module/components/create-template-part-modal/index.js +10 -6
- package/build-module/components/create-template-part-modal/index.js.map +1 -1
- package/build-module/components/dataviews/dataviews.js +40 -31
- package/build-module/components/dataviews/dataviews.js.map +1 -1
- package/build-module/components/dataviews/field-actions.js +22 -0
- package/build-module/components/dataviews/field-actions.js.map +1 -0
- package/build-module/components/dataviews/filters.js +53 -0
- package/build-module/components/dataviews/filters.js.map +1 -0
- package/build-module/components/dataviews/in-filter.js +43 -0
- package/build-module/components/dataviews/in-filter.js.map +1 -0
- package/build-module/components/dataviews/index.js +0 -1
- package/build-module/components/dataviews/index.js.map +1 -1
- package/build-module/components/dataviews/pagination.js +74 -28
- package/build-module/components/dataviews/pagination.js.map +1 -1
- package/build-module/components/dataviews/text-filter.js +19 -13
- package/build-module/components/dataviews/text-filter.js.map +1 -1
- package/build-module/components/dataviews/view-actions.js +95 -54
- package/build-module/components/dataviews/view-actions.js.map +1 -1
- package/build-module/components/dataviews/view-grid.js +51 -0
- package/build-module/components/dataviews/view-grid.js.map +1 -0
- package/build-module/components/dataviews/view-list.js +274 -0
- package/build-module/components/dataviews/view-list.js.map +1 -0
- package/build-module/components/editor/index.js +2 -1
- package/build-module/components/editor/index.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/context.js +16 -10
- package/build-module/components/global-styles/font-library-modal/context.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/font-collection.js +20 -6
- package/build-module/components/global-styles/font-library-modal/font-collection.js.map +1 -1
- package/build-module/components/global-styles/screen-block.js +1 -2
- package/build-module/components/global-styles/screen-block.js.map +1 -1
- package/build-module/components/global-styles/screen-root.js +1 -2
- package/build-module/components/global-styles/screen-root.js.map +1 -1
- package/build-module/components/global-styles/ui.js +3 -4
- package/build-module/components/global-styles/ui.js.map +1 -1
- package/build-module/components/layout/index.js +11 -3
- package/build-module/components/layout/index.js.map +1 -1
- package/build-module/components/media/index.js +26 -0
- package/build-module/components/media/index.js.map +1 -0
- package/build-module/components/page-actions/index.js +0 -2
- package/build-module/components/page-actions/index.js.map +1 -1
- package/build-module/components/page-pages/index.js +156 -110
- package/build-module/components/page-pages/index.js.map +1 -1
- package/build-module/components/page-patterns/delete-category-menu-item.js +82 -0
- package/build-module/components/page-patterns/delete-category-menu-item.js.map +1 -0
- package/build-module/components/page-patterns/duplicate-menu-item.js +54 -133
- package/build-module/components/page-patterns/duplicate-menu-item.js.map +1 -1
- package/build-module/components/page-patterns/grid-item.js +1 -0
- package/build-module/components/page-patterns/grid-item.js.map +1 -1
- package/build-module/components/page-patterns/header.js +26 -4
- package/build-module/components/page-patterns/header.js.map +1 -1
- package/build-module/components/page-patterns/rename-category-menu-item.js +42 -0
- package/build-module/components/page-patterns/rename-category-menu-item.js.map +1 -0
- package/build-module/components/page-patterns/rename-menu-item.js +1 -1
- package/build-module/components/page-patterns/rename-menu-item.js.map +1 -1
- package/build-module/components/page-patterns/use-patterns.js +1 -0
- package/build-module/components/page-patterns/use-patterns.js.map +1 -1
- package/build-module/components/pattern-modal/duplicate.js +57 -0
- package/build-module/components/pattern-modal/duplicate.js.map +1 -0
- package/build-module/components/pattern-modal/index.js +14 -0
- package/build-module/components/pattern-modal/index.js.map +1 -0
- package/build-module/components/pattern-modal/rename.js +34 -0
- package/build-module/components/pattern-modal/rename.js.map +1 -0
- package/build-module/components/sidebar-edit-mode/template-panel/last-revision.js +3 -0
- package/build-module/components/sidebar-edit-mode/template-panel/last-revision.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-pattern/template-part-navigation-menu-list-item.js +2 -2
- package/build-module/components/sidebar-navigation-screen-pattern/template-part-navigation-menu-list-item.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-pattern/template-part-navigation-menu.js +2 -3
- package/build-module/components/sidebar-navigation-screen-pattern/template-part-navigation-menu.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-pattern/use-navigation-menu-title.js +22 -0
- package/build-module/components/sidebar-navigation-screen-pattern/use-navigation-menu-title.js.map +1 -0
- package/build-module/components/sidebar-navigation-screen-template/home-template-details.js +12 -1
- package/build-module/components/sidebar-navigation-screen-template/home-template-details.js.map +1 -1
- package/build-module/hooks/commands/use-common-commands.js +1 -2
- package/build-module/hooks/commands/use-common-commands.js.map +1 -1
- package/build-module/hooks/commands/use-edit-mode-commands.js +50 -1
- package/build-module/hooks/commands/use-edit-mode-commands.js.map +1 -1
- package/build-module/lock-unlock.js +1 -1
- package/build-module/lock-unlock.js.map +1 -1
- package/build-module/store/selectors.js +4 -5
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +42 -9
- package/build-style/style.css +42 -9
- package/package.json +40 -40
- package/src/components/actions/trash-post.js +55 -0
- package/src/components/add-new-template/add-custom-template-modal-content.js +22 -17
- package/src/components/block-editor/resize-handle.js +1 -0
- package/src/components/create-template-part-modal/index.js +9 -5
- package/src/components/dataviews/README.md +107 -0
- package/src/components/dataviews/dataviews.js +44 -33
- package/src/components/dataviews/field-actions.js +28 -0
- package/src/components/dataviews/filters.js +57 -0
- package/src/components/dataviews/in-filter.js +47 -0
- package/src/components/dataviews/index.js +0 -1
- package/src/components/dataviews/pagination.js +71 -29
- package/src/components/dataviews/style.scss +11 -1
- package/src/components/dataviews/text-filter.js +19 -15
- package/src/components/dataviews/view-actions.js +108 -63
- package/src/components/dataviews/view-grid.js +60 -0
- package/src/components/dataviews/view-list.js +348 -0
- package/src/components/editor/index.js +2 -0
- package/src/components/global-styles/font-library-modal/context.js +17 -11
- package/src/components/global-styles/font-library-modal/font-collection.js +18 -10
- package/src/components/global-styles/screen-block.js +1 -2
- package/src/components/global-styles/screen-root.js +1 -2
- package/src/components/global-styles/style.scss +16 -4
- package/src/components/global-styles/ui.js +1 -2
- package/src/components/layout/index.js +12 -4
- package/src/components/media/index.js +25 -0
- package/src/components/page-actions/index.js +1 -7
- package/src/components/page-pages/index.js +156 -108
- package/src/components/page-pages/style.scss +3 -0
- package/src/components/page-patterns/delete-category-menu-item.js +104 -0
- package/src/components/page-patterns/duplicate-menu-item.js +68 -181
- package/src/components/page-patterns/grid-item.js +1 -0
- package/src/components/page-patterns/header.js +42 -6
- package/src/components/page-patterns/rename-category-menu-item.js +45 -0
- package/src/components/page-patterns/rename-menu-item.js +2 -2
- package/src/components/page-patterns/style.scss +8 -0
- package/src/components/page-patterns/use-patterns.js +5 -0
- package/src/components/pattern-modal/duplicate.js +53 -0
- package/src/components/pattern-modal/index.js +19 -0
- package/src/components/pattern-modal/rename.js +29 -0
- package/src/components/sidebar-edit-mode/template-panel/last-revision.js +4 -0
- package/src/components/sidebar-navigation-screen/style.scss +17 -5
- package/src/components/sidebar-navigation-screen-pattern/template-part-navigation-menu-list-item.js +2 -7
- package/src/components/sidebar-navigation-screen-pattern/template-part-navigation-menu.js +2 -8
- package/src/components/sidebar-navigation-screen-pattern/use-navigation-menu-title.js +32 -0
- package/src/components/sidebar-navigation-screen-template/home-template-details.js +21 -7
- package/src/hooks/commands/use-common-commands.js +1 -2
- package/src/hooks/commands/use-edit-mode-commands.js +41 -0
- package/src/lock-unlock.js +1 -1
- package/src/store/selectors.js +9 -10
- package/src/style.scss +1 -0
- package/build/components/dataviews/list-view.js +0 -89
- package/build/components/dataviews/list-view.js.map +0 -1
- package/build-module/components/dataviews/list-view.js +0 -80
- package/build-module/components/dataviews/list-view.js.map +0 -1
- package/src/components/dataviews/list-view.js +0 -106
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/edit-site",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.21.0",
|
|
4
4
|
"description": "Edit Site Page module for WordPress.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -28,44 +28,44 @@
|
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@babel/runtime": "^7.16.0",
|
|
30
30
|
"@tanstack/react-table": "^8.10.3",
|
|
31
|
-
"@wordpress/a11y": "^3.
|
|
32
|
-
"@wordpress/api-fetch": "^6.
|
|
33
|
-
"@wordpress/block-editor": "^12.
|
|
34
|
-
"@wordpress/block-library": "^8.
|
|
35
|
-
"@wordpress/blocks": "^12.
|
|
36
|
-
"@wordpress/commands": "^0.
|
|
37
|
-
"@wordpress/components": "^25.
|
|
38
|
-
"@wordpress/compose": "^6.
|
|
39
|
-
"@wordpress/core-commands": "^0.
|
|
40
|
-
"@wordpress/core-data": "^6.
|
|
41
|
-
"@wordpress/data": "^9.
|
|
42
|
-
"@wordpress/date": "^4.
|
|
43
|
-
"@wordpress/deprecated": "^3.
|
|
44
|
-
"@wordpress/dom": "^3.
|
|
45
|
-
"@wordpress/editor": "^13.
|
|
46
|
-
"@wordpress/element": "^5.
|
|
47
|
-
"@wordpress/escape-html": "^2.
|
|
48
|
-
"@wordpress/hooks": "^3.
|
|
49
|
-
"@wordpress/html-entities": "^3.
|
|
50
|
-
"@wordpress/i18n": "^4.
|
|
51
|
-
"@wordpress/icons": "^9.
|
|
52
|
-
"@wordpress/interface": "^5.
|
|
53
|
-
"@wordpress/keyboard-shortcuts": "^4.
|
|
54
|
-
"@wordpress/keycodes": "^3.
|
|
55
|
-
"@wordpress/media-utils": "^4.
|
|
56
|
-
"@wordpress/notices": "^4.
|
|
57
|
-
"@wordpress/patterns": "^1.
|
|
58
|
-
"@wordpress/plugins": "^6.
|
|
59
|
-
"@wordpress/preferences": "^3.
|
|
60
|
-
"@wordpress/primitives": "^3.
|
|
61
|
-
"@wordpress/private-apis": "^0.
|
|
62
|
-
"@wordpress/reusable-blocks": "^4.
|
|
63
|
-
"@wordpress/router": "^0.
|
|
64
|
-
"@wordpress/style-engine": "^1.
|
|
65
|
-
"@wordpress/url": "^3.
|
|
66
|
-
"@wordpress/viewport": "^5.
|
|
67
|
-
"@wordpress/widgets": "^3.
|
|
68
|
-
"@wordpress/wordcount": "^3.
|
|
31
|
+
"@wordpress/a11y": "^3.44.0",
|
|
32
|
+
"@wordpress/api-fetch": "^6.41.0",
|
|
33
|
+
"@wordpress/block-editor": "^12.12.0",
|
|
34
|
+
"@wordpress/block-library": "^8.21.0",
|
|
35
|
+
"@wordpress/blocks": "^12.21.0",
|
|
36
|
+
"@wordpress/commands": "^0.15.0",
|
|
37
|
+
"@wordpress/components": "^25.10.0",
|
|
38
|
+
"@wordpress/compose": "^6.21.0",
|
|
39
|
+
"@wordpress/core-commands": "^0.13.0",
|
|
40
|
+
"@wordpress/core-data": "^6.21.0",
|
|
41
|
+
"@wordpress/data": "^9.14.0",
|
|
42
|
+
"@wordpress/date": "^4.44.0",
|
|
43
|
+
"@wordpress/deprecated": "^3.44.0",
|
|
44
|
+
"@wordpress/dom": "^3.44.0",
|
|
45
|
+
"@wordpress/editor": "^13.21.0",
|
|
46
|
+
"@wordpress/element": "^5.21.0",
|
|
47
|
+
"@wordpress/escape-html": "^2.44.0",
|
|
48
|
+
"@wordpress/hooks": "^3.44.0",
|
|
49
|
+
"@wordpress/html-entities": "^3.44.0",
|
|
50
|
+
"@wordpress/i18n": "^4.44.0",
|
|
51
|
+
"@wordpress/icons": "^9.35.0",
|
|
52
|
+
"@wordpress/interface": "^5.21.0",
|
|
53
|
+
"@wordpress/keyboard-shortcuts": "^4.21.0",
|
|
54
|
+
"@wordpress/keycodes": "^3.44.0",
|
|
55
|
+
"@wordpress/media-utils": "^4.35.0",
|
|
56
|
+
"@wordpress/notices": "^4.12.0",
|
|
57
|
+
"@wordpress/patterns": "^1.5.0",
|
|
58
|
+
"@wordpress/plugins": "^6.12.0",
|
|
59
|
+
"@wordpress/preferences": "^3.21.0",
|
|
60
|
+
"@wordpress/primitives": "^3.42.0",
|
|
61
|
+
"@wordpress/private-apis": "^0.26.0",
|
|
62
|
+
"@wordpress/reusable-blocks": "^4.21.0",
|
|
63
|
+
"@wordpress/router": "^0.13.0",
|
|
64
|
+
"@wordpress/style-engine": "^1.27.0",
|
|
65
|
+
"@wordpress/url": "^3.45.0",
|
|
66
|
+
"@wordpress/viewport": "^5.21.0",
|
|
67
|
+
"@wordpress/widgets": "^3.21.0",
|
|
68
|
+
"@wordpress/wordcount": "^3.44.0",
|
|
69
69
|
"change-case": "^4.1.2",
|
|
70
70
|
"classnames": "^2.3.1",
|
|
71
71
|
"colord": "^2.9.2",
|
|
@@ -85,5 +85,5 @@
|
|
|
85
85
|
"publishConfig": {
|
|
86
86
|
"access": "public"
|
|
87
87
|
},
|
|
88
|
-
"gitHead": "
|
|
88
|
+
"gitHead": "f83bb1a71e8fa416131b81a9f282a72a1dc6c694"
|
|
89
89
|
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useDispatch } from '@wordpress/data';
|
|
5
|
+
import { decodeEntities } from '@wordpress/html-entities';
|
|
6
|
+
import { store as coreStore } from '@wordpress/core-data';
|
|
7
|
+
import { __, sprintf } from '@wordpress/i18n';
|
|
8
|
+
import { store as noticesStore } from '@wordpress/notices';
|
|
9
|
+
import { useMemo } from '@wordpress/element';
|
|
10
|
+
|
|
11
|
+
export default function useMoveToTrashAction() {
|
|
12
|
+
const { createSuccessNotice, createErrorNotice } =
|
|
13
|
+
useDispatch( noticesStore );
|
|
14
|
+
const { deleteEntityRecord } = useDispatch( coreStore );
|
|
15
|
+
|
|
16
|
+
return useMemo(
|
|
17
|
+
() => ( {
|
|
18
|
+
id: 'move-to-trash',
|
|
19
|
+
label: __( 'Move to Trash' ),
|
|
20
|
+
async perform( post ) {
|
|
21
|
+
try {
|
|
22
|
+
await deleteEntityRecord(
|
|
23
|
+
'postType',
|
|
24
|
+
post.type,
|
|
25
|
+
post.id,
|
|
26
|
+
{},
|
|
27
|
+
{ throwOnError: true }
|
|
28
|
+
);
|
|
29
|
+
createSuccessNotice(
|
|
30
|
+
sprintf(
|
|
31
|
+
/* translators: The page's title. */
|
|
32
|
+
__( '"%s" moved to the Trash.' ),
|
|
33
|
+
decodeEntities( post.title.rendered )
|
|
34
|
+
),
|
|
35
|
+
{
|
|
36
|
+
type: 'snackbar',
|
|
37
|
+
id: 'edit-site-page-trashed',
|
|
38
|
+
}
|
|
39
|
+
);
|
|
40
|
+
} catch ( error ) {
|
|
41
|
+
const errorMessage =
|
|
42
|
+
error.message && error.code !== 'unknown_error'
|
|
43
|
+
? error.message
|
|
44
|
+
: __(
|
|
45
|
+
'An error occurred while moving the page to the trash.'
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
createErrorNotice( errorMessage, { type: 'snackbar' } );
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
isDesctructive: true,
|
|
52
|
+
} ),
|
|
53
|
+
[ createSuccessNotice, createErrorNotice, deleteEntityRecord ]
|
|
54
|
+
);
|
|
55
|
+
}
|
|
@@ -9,11 +9,9 @@ import {
|
|
|
9
9
|
FlexItem,
|
|
10
10
|
SearchControl,
|
|
11
11
|
TextHighlight,
|
|
12
|
+
privateApis as componentsPrivateApis,
|
|
12
13
|
__experimentalText as Text,
|
|
13
14
|
__experimentalVStack as VStack,
|
|
14
|
-
__unstableComposite as Composite,
|
|
15
|
-
__unstableUseCompositeState as useCompositeState,
|
|
16
|
-
__unstableCompositeItem as CompositeItem,
|
|
17
15
|
} from '@wordpress/components';
|
|
18
16
|
import { useEntityRecords } from '@wordpress/core-data';
|
|
19
17
|
import { decodeEntities } from '@wordpress/html-entities';
|
|
@@ -21,9 +19,16 @@ import { decodeEntities } from '@wordpress/html-entities';
|
|
|
21
19
|
/**
|
|
22
20
|
* Internal dependencies
|
|
23
21
|
*/
|
|
22
|
+
import { unlock } from '../../lock-unlock';
|
|
24
23
|
import useDebouncedInput from '../../utils/use-debounced-input';
|
|
25
24
|
import { mapToIHasNameAndId } from './utils';
|
|
26
25
|
|
|
26
|
+
const {
|
|
27
|
+
CompositeV2: Composite,
|
|
28
|
+
CompositeItemV2: CompositeItem,
|
|
29
|
+
useCompositeStoreV2: useCompositeStore,
|
|
30
|
+
} = unlock( componentsPrivateApis );
|
|
31
|
+
|
|
27
32
|
const EMPTY_ARRAY = [];
|
|
28
33
|
|
|
29
34
|
function SuggestionListItem( {
|
|
@@ -31,22 +36,23 @@ function SuggestionListItem( {
|
|
|
31
36
|
search,
|
|
32
37
|
onSelect,
|
|
33
38
|
entityForSuggestions,
|
|
34
|
-
composite,
|
|
35
39
|
} ) {
|
|
36
40
|
const baseCssClass =
|
|
37
41
|
'edit-site-custom-template-modal__suggestions_list__list-item';
|
|
38
42
|
return (
|
|
39
43
|
<CompositeItem
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
44
|
+
render={
|
|
45
|
+
<Button
|
|
46
|
+
role="option"
|
|
47
|
+
className={ baseCssClass }
|
|
48
|
+
onClick={ () =>
|
|
49
|
+
onSelect(
|
|
50
|
+
entityForSuggestions.config.getSpecificTemplate(
|
|
51
|
+
suggestion
|
|
52
|
+
)
|
|
53
|
+
)
|
|
54
|
+
}
|
|
55
|
+
/>
|
|
50
56
|
}
|
|
51
57
|
>
|
|
52
58
|
<Text
|
|
@@ -112,7 +118,7 @@ function useSearchSuggestions( entityForSuggestions, search ) {
|
|
|
112
118
|
}
|
|
113
119
|
|
|
114
120
|
function SuggestionList( { entityForSuggestions, onSelect } ) {
|
|
115
|
-
const composite =
|
|
121
|
+
const composite = useCompositeStore( { orientation: 'vertical' } );
|
|
116
122
|
const [ search, setSearch, debouncedSearch ] = useDebouncedInput();
|
|
117
123
|
const suggestions = useSearchSuggestions(
|
|
118
124
|
entityForSuggestions,
|
|
@@ -136,7 +142,7 @@ function SuggestionList( { entityForSuggestions, onSelect } ) {
|
|
|
136
142
|
) }
|
|
137
143
|
{ !! suggestions?.length && (
|
|
138
144
|
<Composite
|
|
139
|
-
{
|
|
145
|
+
store={ composite }
|
|
140
146
|
role="listbox"
|
|
141
147
|
className="edit-site-custom-template-modal__suggestions_list"
|
|
142
148
|
aria-label={ __( 'Suggestions list' ) }
|
|
@@ -148,7 +154,6 @@ function SuggestionList( { entityForSuggestions, onSelect } ) {
|
|
|
148
154
|
search={ debouncedSearch }
|
|
149
155
|
onSelect={ onSelect }
|
|
150
156
|
entityForSuggestions={ entityForSuggestions }
|
|
151
|
-
composite={ composite }
|
|
152
157
|
/>
|
|
153
158
|
) ) }
|
|
154
159
|
</Composite>
|
|
@@ -35,6 +35,7 @@ export default function ResizeHandle( {
|
|
|
35
35
|
aria-label={ __( 'Drag to resize' ) }
|
|
36
36
|
aria-describedby={ `resizable-editor__resize-help-${ direction }` }
|
|
37
37
|
onKeyDown={ handleKeyDown }
|
|
38
|
+
type="button"
|
|
38
39
|
/>
|
|
39
40
|
<VisuallyHidden
|
|
40
41
|
id={ `resizable-editor__resize-help-${ direction }` }
|
|
@@ -39,17 +39,21 @@ import {
|
|
|
39
39
|
} from '../../utils/template-part-create';
|
|
40
40
|
|
|
41
41
|
export default function CreateTemplatePartModal( {
|
|
42
|
-
|
|
42
|
+
defaultArea = TEMPLATE_PART_AREA_DEFAULT_CATEGORY,
|
|
43
43
|
blocks = [],
|
|
44
|
+
confirmLabel = __( 'Create' ),
|
|
45
|
+
closeModal,
|
|
46
|
+
modalTitle = __( 'Create template part' ),
|
|
44
47
|
onCreate,
|
|
45
48
|
onError,
|
|
49
|
+
defaultTitle = '',
|
|
46
50
|
} ) {
|
|
47
51
|
const { createErrorNotice } = useDispatch( noticesStore );
|
|
48
52
|
const { saveEntityRecord } = useDispatch( coreStore );
|
|
49
53
|
const existingTemplateParts = useExistingTemplateParts();
|
|
50
54
|
|
|
51
|
-
const [ title, setTitle ] = useState(
|
|
52
|
-
const [ area, setArea ] = useState(
|
|
55
|
+
const [ title, setTitle ] = useState( defaultTitle );
|
|
56
|
+
const [ area, setArea ] = useState( defaultArea );
|
|
53
57
|
const [ isSubmitting, setIsSubmitting ] = useState( false );
|
|
54
58
|
const instanceId = useInstanceId( CreateTemplatePartModal );
|
|
55
59
|
|
|
@@ -104,7 +108,7 @@ export default function CreateTemplatePartModal( {
|
|
|
104
108
|
|
|
105
109
|
return (
|
|
106
110
|
<Modal
|
|
107
|
-
title={
|
|
111
|
+
title={ modalTitle }
|
|
108
112
|
onRequestClose={ closeModal }
|
|
109
113
|
overlayClassName="edit-site-create-template-part-modal"
|
|
110
114
|
>
|
|
@@ -181,7 +185,7 @@ export default function CreateTemplatePartModal( {
|
|
|
181
185
|
aria-disabled={ ! title || isSubmitting }
|
|
182
186
|
isBusy={ isSubmitting }
|
|
183
187
|
>
|
|
184
|
-
{
|
|
188
|
+
{ confirmLabel }
|
|
185
189
|
</Button>
|
|
186
190
|
</HStack>
|
|
187
191
|
</VStack>
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
# DataView
|
|
2
|
+
|
|
3
|
+
This file aims to document the main APIs related to the DataView component.
|
|
4
|
+
|
|
5
|
+
## View
|
|
6
|
+
|
|
7
|
+
The view is responsible for configuring how the dataset is visible to the user. For example:
|
|
8
|
+
|
|
9
|
+
```js
|
|
10
|
+
{
|
|
11
|
+
type: 'list',
|
|
12
|
+
page: 1,
|
|
13
|
+
perPage: 5,
|
|
14
|
+
sort: {
|
|
15
|
+
field: 'date',
|
|
16
|
+
direction: 'desc',
|
|
17
|
+
},
|
|
18
|
+
filters: {
|
|
19
|
+
search: '',
|
|
20
|
+
author: 2,
|
|
21
|
+
status: 'publish, draft'
|
|
22
|
+
},
|
|
23
|
+
visibleFilters: [ 'search', 'author', 'status' ],
|
|
24
|
+
hiddenFields: [ 'date', 'featured-image' ],
|
|
25
|
+
layout: {},
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
- `type`: one of `list` or `grid`.
|
|
30
|
+
- `page`: the current page.
|
|
31
|
+
- `perPage`: number of records per page.
|
|
32
|
+
- `sort.field`: field used for sorting.
|
|
33
|
+
- `sort.direction`: one of `asc` or `desc`.
|
|
34
|
+
- `filters`: the filters applied to the dataset.
|
|
35
|
+
- `visibleFilters`: the `id` of the filters that are visible in the UI.
|
|
36
|
+
- `hiddenFields`: the `id` of the fields that are hidden in the UI.
|
|
37
|
+
- `layout`: ...
|
|
38
|
+
|
|
39
|
+
The view configuration is used to retrieve the corresponding entity that holds the dataset:
|
|
40
|
+
|
|
41
|
+
```js
|
|
42
|
+
const {
|
|
43
|
+
records: pages,
|
|
44
|
+
isLoading: isLoadingPages,
|
|
45
|
+
totalItems,
|
|
46
|
+
totalPages
|
|
47
|
+
} = useEntityRecords( 'postType', 'page', {
|
|
48
|
+
per_page: view.perPage,
|
|
49
|
+
page: view.page,
|
|
50
|
+
order: view.sort?.direction,
|
|
51
|
+
orderby: view.sort?.field
|
|
52
|
+
...view.filters
|
|
53
|
+
} );
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Fields
|
|
57
|
+
|
|
58
|
+
The fields describe the dataset. For example:
|
|
59
|
+
|
|
60
|
+
```js
|
|
61
|
+
[
|
|
62
|
+
{
|
|
63
|
+
id: 'author',
|
|
64
|
+
header: __( 'Author' ),
|
|
65
|
+
getValue: ( { item } ) => item.author,
|
|
66
|
+
render: ( {item} ) => {
|
|
67
|
+
return (
|
|
68
|
+
<a href="...">{ item.author }</a>
|
|
69
|
+
);
|
|
70
|
+
},
|
|
71
|
+
elements: [
|
|
72
|
+
{ value: 1, label: 'admin' }
|
|
73
|
+
{ value: 2, label: 'user' }
|
|
74
|
+
]
|
|
75
|
+
filters: [
|
|
76
|
+
{ id: 'author', type: 'enumeration' },
|
|
77
|
+
{ id: 'author_search', type: 'search' }
|
|
78
|
+
],
|
|
79
|
+
},
|
|
80
|
+
]
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
- `id`: identifier for the field. Unique.
|
|
84
|
+
- `header`: the field name for the UI.
|
|
85
|
+
- `getValue`: function that returns the value of the field.
|
|
86
|
+
- `render`: function that renders the field.
|
|
87
|
+
- `elements`: a set of valid values for the field.
|
|
88
|
+
- `filters`: what filters are available. A filter is an object with `id` and `type` as properties:
|
|
89
|
+
- `id`: unique identifier for the filter. Matches the entity query param.
|
|
90
|
+
- `type`: the type of filter. One of `search` or `enumeration`.
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
## DataViews
|
|
94
|
+
|
|
95
|
+
The UI component responsible for rendering the dataset.
|
|
96
|
+
|
|
97
|
+
```js
|
|
98
|
+
<DataViews
|
|
99
|
+
data={ pages }
|
|
100
|
+
isLoading= { isLoadingPages }
|
|
101
|
+
fields={ fields }
|
|
102
|
+
view={ view }
|
|
103
|
+
onChangeView={ onChangeView }
|
|
104
|
+
actions={ [ trashPostAction ] }
|
|
105
|
+
paginationInfo={ { totalItems, totalPages } }
|
|
106
|
+
/>
|
|
107
|
+
```
|
|
@@ -1,14 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import {
|
|
5
|
-
getCoreRowModel,
|
|
6
|
-
getFilteredRowModel,
|
|
7
|
-
getSortedRowModel,
|
|
8
|
-
getPaginationRowModel,
|
|
9
|
-
useReactTable,
|
|
10
|
-
} from '@tanstack/react-table';
|
|
11
|
-
|
|
12
1
|
/**
|
|
13
2
|
* WordPress dependencies
|
|
14
3
|
*/
|
|
@@ -16,43 +5,65 @@ import {
|
|
|
16
5
|
__experimentalVStack as VStack,
|
|
17
6
|
__experimentalHStack as HStack,
|
|
18
7
|
} from '@wordpress/components';
|
|
8
|
+
import { useMemo } from '@wordpress/element';
|
|
19
9
|
|
|
20
10
|
/**
|
|
21
11
|
* Internal dependencies
|
|
22
12
|
*/
|
|
23
|
-
import
|
|
24
|
-
import
|
|
13
|
+
import ViewList from './view-list';
|
|
14
|
+
import Pagination from './pagination';
|
|
25
15
|
import ViewActions from './view-actions';
|
|
26
|
-
import
|
|
16
|
+
import Filters from './filters';
|
|
17
|
+
import { ViewGrid } from './view-grid';
|
|
27
18
|
|
|
28
19
|
export default function DataViews( {
|
|
29
|
-
|
|
20
|
+
view,
|
|
21
|
+
onChangeView,
|
|
30
22
|
fields,
|
|
31
|
-
|
|
23
|
+
actions,
|
|
24
|
+
data,
|
|
25
|
+
isLoading = false,
|
|
32
26
|
paginationInfo,
|
|
33
|
-
options,
|
|
34
27
|
} ) {
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
getPaginationRowModel: getPaginationRowModel(),
|
|
43
|
-
} );
|
|
28
|
+
const ViewComponent = view.type === 'list' ? ViewList : ViewGrid;
|
|
29
|
+
const _fields = useMemo( () => {
|
|
30
|
+
return fields.map( ( field ) => ( {
|
|
31
|
+
...field,
|
|
32
|
+
render: field.render || field.getValue,
|
|
33
|
+
} ) );
|
|
34
|
+
}, [ fields ] );
|
|
44
35
|
return (
|
|
45
36
|
<div className="dataviews-wrapper">
|
|
46
37
|
<VStack spacing={ 4 }>
|
|
47
|
-
<HStack
|
|
48
|
-
<
|
|
49
|
-
|
|
38
|
+
<HStack>
|
|
39
|
+
<HStack justify="start">
|
|
40
|
+
<Filters
|
|
41
|
+
fields={ fields }
|
|
42
|
+
view={ view }
|
|
43
|
+
onChangeView={ onChangeView }
|
|
44
|
+
/>
|
|
45
|
+
</HStack>
|
|
46
|
+
<HStack justify="end">
|
|
47
|
+
<ViewActions
|
|
48
|
+
fields={ fields }
|
|
49
|
+
view={ view }
|
|
50
|
+
onChangeView={ onChangeView }
|
|
51
|
+
/>
|
|
52
|
+
</HStack>
|
|
50
53
|
</HStack>
|
|
51
|
-
|
|
52
|
-
|
|
54
|
+
<ViewComponent
|
|
55
|
+
fields={ _fields }
|
|
56
|
+
view={ view }
|
|
57
|
+
onChangeView={ onChangeView }
|
|
58
|
+
paginationInfo={ paginationInfo }
|
|
59
|
+
actions={ actions }
|
|
60
|
+
data={ data }
|
|
61
|
+
isLoading={ isLoading }
|
|
62
|
+
/>
|
|
53
63
|
<Pagination
|
|
54
|
-
|
|
55
|
-
|
|
64
|
+
view={ view }
|
|
65
|
+
onChangeView={ onChangeView }
|
|
66
|
+
paginationInfo={ paginationInfo }
|
|
56
67
|
/>
|
|
57
68
|
</VStack>
|
|
58
69
|
</div>
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { DropdownMenu, MenuGroup, MenuItem } from '@wordpress/components';
|
|
5
|
+
import { __ } from '@wordpress/i18n';
|
|
6
|
+
import { moreVertical } from '@wordpress/icons';
|
|
7
|
+
|
|
8
|
+
function FieldActions( { item, actions } ) {
|
|
9
|
+
return (
|
|
10
|
+
<DropdownMenu icon={ moreVertical } label={ __( 'Actions' ) }>
|
|
11
|
+
{ () => (
|
|
12
|
+
<MenuGroup>
|
|
13
|
+
{ actions.map( ( action ) => (
|
|
14
|
+
<MenuItem
|
|
15
|
+
key={ action.id }
|
|
16
|
+
onClick={ () => action.perform( item ) }
|
|
17
|
+
isDestructive={ action.isDesctructive }
|
|
18
|
+
>
|
|
19
|
+
{ action.label }
|
|
20
|
+
</MenuItem>
|
|
21
|
+
) ) }
|
|
22
|
+
</MenuGroup>
|
|
23
|
+
) }
|
|
24
|
+
</DropdownMenu>
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export default FieldActions;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { __ } from '@wordpress/i18n';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
import TextFilter from './text-filter';
|
|
10
|
+
import InFilter from './in-filter';
|
|
11
|
+
|
|
12
|
+
export default function Filters( { fields, view, onChangeView } ) {
|
|
13
|
+
const filters = {};
|
|
14
|
+
fields.forEach( ( field ) => {
|
|
15
|
+
if ( ! field.filters ) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
field.filters.forEach( ( f ) => {
|
|
20
|
+
filters[ f.id ] = { type: f.type };
|
|
21
|
+
} );
|
|
22
|
+
} );
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
view.visibleFilters?.map( ( filterName ) => {
|
|
26
|
+
const filter = filters[ filterName ];
|
|
27
|
+
|
|
28
|
+
if ( ! filter ) {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if ( filter.type === 'search' ) {
|
|
33
|
+
return (
|
|
34
|
+
<TextFilter
|
|
35
|
+
key={ filterName }
|
|
36
|
+
id={ filterName }
|
|
37
|
+
view={ view }
|
|
38
|
+
onChangeView={ onChangeView }
|
|
39
|
+
/>
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
if ( filter.type === 'enumeration' ) {
|
|
43
|
+
return (
|
|
44
|
+
<InFilter
|
|
45
|
+
key={ filterName }
|
|
46
|
+
id={ filterName }
|
|
47
|
+
fields={ fields }
|
|
48
|
+
view={ view }
|
|
49
|
+
onChangeView={ onChangeView }
|
|
50
|
+
/>
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return null;
|
|
55
|
+
} ) || __( 'No filters available' )
|
|
56
|
+
);
|
|
57
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import {
|
|
5
|
+
__experimentalInputControlPrefixWrapper as InputControlPrefixWrapper,
|
|
6
|
+
SelectControl,
|
|
7
|
+
} from '@wordpress/components';
|
|
8
|
+
import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Internal dependencies
|
|
12
|
+
*/
|
|
13
|
+
import { unlock } from '../../lock-unlock';
|
|
14
|
+
|
|
15
|
+
const { cleanEmptyObject } = unlock( blockEditorPrivateApis );
|
|
16
|
+
|
|
17
|
+
export default ( { id, fields, view, onChangeView } ) => {
|
|
18
|
+
const field = fields.find( ( f ) => f.id === id );
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<SelectControl
|
|
22
|
+
value={ view.filters[ id ] }
|
|
23
|
+
prefix={
|
|
24
|
+
<InputControlPrefixWrapper
|
|
25
|
+
as="span"
|
|
26
|
+
className="dataviews__select-control-prefix"
|
|
27
|
+
>
|
|
28
|
+
{ field.header + ':' }
|
|
29
|
+
</InputControlPrefixWrapper>
|
|
30
|
+
}
|
|
31
|
+
options={ field?.elements || [] }
|
|
32
|
+
onChange={ ( value ) => {
|
|
33
|
+
if ( value === '' ) {
|
|
34
|
+
value = undefined;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
onChangeView( ( currentView ) => ( {
|
|
38
|
+
...currentView,
|
|
39
|
+
filters: cleanEmptyObject( {
|
|
40
|
+
...currentView.filters,
|
|
41
|
+
[ id ]: value,
|
|
42
|
+
} ),
|
|
43
|
+
} ) );
|
|
44
|
+
} }
|
|
45
|
+
/>
|
|
46
|
+
);
|
|
47
|
+
};
|