@wordpress/edit-site 5.23.0 → 5.24.1
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/index.js +56 -38
- package/build/components/actions/index.js.map +1 -1
- package/build/components/block-editor/site-editor-canvas.js +7 -2
- package/build/components/block-editor/site-editor-canvas.js.map +1 -1
- package/build/components/dataviews/add-filter.js +21 -20
- package/build/components/dataviews/add-filter.js.map +1 -1
- package/build/components/dataviews/constants.js +14 -0
- package/build/components/dataviews/constants.js.map +1 -0
- package/build/components/dataviews/dataviews.js +9 -7
- package/build/components/dataviews/dataviews.js.map +1 -1
- package/build/components/dataviews/filter-summary.js +62 -0
- package/build/components/dataviews/filter-summary.js.map +1 -0
- package/build/components/dataviews/filters.js +15 -30
- package/build/components/dataviews/filters.js.map +1 -1
- package/build/components/dataviews/item-actions.js +84 -30
- package/build/components/dataviews/item-actions.js.map +1 -1
- package/build/components/dataviews/pagination.js +4 -0
- package/build/components/dataviews/pagination.js.map +1 -1
- package/build/components/dataviews/view-actions.js +24 -24
- package/build/components/dataviews/view-actions.js.map +1 -1
- package/build/components/dataviews/view-grid.js +48 -25
- package/build/components/dataviews/view-grid.js.map +1 -1
- package/build/components/dataviews/view-list.js +28 -33
- package/build/components/dataviews/view-list.js.map +1 -1
- package/build/components/editor/index.js +23 -27
- package/build/components/editor/index.js.map +1 -1
- package/build/components/global-styles/font-library-modal/utils/get-intersecting-font-faces.js +1 -1
- package/build/components/global-styles/font-library-modal/utils/get-intersecting-font-faces.js.map +1 -1
- package/build/components/global-styles/font-library-modal/utils/index.js +15 -2
- package/build/components/global-styles/font-library-modal/utils/index.js.map +1 -1
- package/build/components/global-styles/header.js +4 -2
- package/build/components/global-styles/header.js.map +1 -1
- package/build/components/global-styles/screen-block-list.js +22 -16
- package/build/components/global-styles/screen-block-list.js.map +1 -1
- package/build/components/global-styles/screen-revisions/index.js +26 -5
- package/build/components/global-styles/screen-revisions/index.js.map +1 -1
- package/build/components/global-styles/screen-revisions/revisions-buttons.js +52 -24
- package/build/components/global-styles/screen-revisions/revisions-buttons.js.map +1 -1
- package/build/components/global-styles/screen-revisions/use-global-styles-revisions.js +9 -3
- package/build/components/global-styles/screen-revisions/use-global-styles-revisions.js.map +1 -1
- package/build/components/global-styles/ui.js +28 -36
- package/build/components/global-styles/ui.js.map +1 -1
- package/build/components/header-edit-mode/document-actions/index.js +21 -16
- package/build/components/header-edit-mode/document-actions/index.js.map +1 -1
- package/build/components/header-edit-mode/index.js +2 -1
- package/build/components/header-edit-mode/index.js.map +1 -1
- package/build/components/header-edit-mode/more-menu/index.js +1 -1
- package/build/components/header-edit-mode/more-menu/index.js.map +1 -1
- package/build/components/list/added-by.js +43 -54
- package/build/components/list/added-by.js.map +1 -1
- package/build/components/{page-content-focus-manager → page-content-focus-notifications}/back-to-page-notification.js +9 -8
- package/build/components/page-content-focus-notifications/back-to-page-notification.js.map +1 -0
- package/build/components/{page-content-focus-manager → page-content-focus-notifications}/edit-template-notification.js +9 -13
- package/build/components/page-content-focus-notifications/edit-template-notification.js.map +1 -0
- package/build/components/page-content-focus-notifications/index.js +22 -0
- package/build/components/page-content-focus-notifications/index.js.map +1 -0
- package/build/components/page-pages/index.js +9 -15
- package/build/components/page-pages/index.js.map +1 -1
- package/build/components/page-patterns/use-patterns.js +1 -1
- package/build/components/page-patterns/use-patterns.js.map +1 -1
- package/build/components/page-templates/dataviews-templates.js +166 -51
- package/build/components/page-templates/dataviews-templates.js.map +1 -1
- package/build/components/preferences-modal/index.js +1 -1
- package/build/components/preferences-modal/index.js.map +1 -1
- package/build/components/save-button/index.js +9 -6
- package/build/components/save-button/index.js.map +1 -1
- package/build/components/save-hub/index.js +14 -0
- package/build/components/save-hub/index.js.map +1 -1
- package/build/components/sidebar-dataviews/custom-dataviews-list.js +3 -1
- package/build/components/sidebar-dataviews/custom-dataviews-list.js.map +1 -1
- package/build/components/sidebar-dataviews/default-views.js +7 -2
- package/build/components/sidebar-dataviews/default-views.js.map +1 -1
- package/build/components/sidebar-edit-mode/index.js +6 -5
- package/build/components/sidebar-edit-mode/index.js.map +1 -1
- package/build/components/sidebar-edit-mode/page-panels/edit-template.js +15 -26
- package/build/components/sidebar-edit-mode/page-panels/edit-template.js.map +1 -1
- package/build/components/sidebar-edit-mode/page-panels/hooks.js +22 -8
- package/build/components/sidebar-edit-mode/page-panels/hooks.js.map +1 -1
- package/build/components/sidebar-edit-mode/page-panels/page-status.js +8 -5
- package/build/components/sidebar-edit-mode/page-panels/page-status.js.map +1 -1
- package/build/components/sidebar-edit-mode/page-panels/page-summary.js +4 -8
- package/build/components/sidebar-edit-mode/page-panels/page-summary.js.map +1 -1
- package/build/components/sidebar-edit-mode/page-panels/reset-default-template.js +2 -2
- package/build/components/sidebar-edit-mode/page-panels/reset-default-template.js.map +1 -1
- package/build/components/sidebar-edit-mode/settings-header/index.js +10 -6
- package/build/components/sidebar-edit-mode/settings-header/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-page/index.js +23 -4
- package/build/components/sidebar-navigation-screen-page/index.js.map +1 -1
- package/build/components/style-book/index.js +22 -12
- package/build/components/style-book/index.js.map +1 -1
- package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js +41 -9
- package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
- package/build/components/welcome-guide/page.js +2 -2
- package/build/components/welcome-guide/page.js.map +1 -1
- package/build/components/welcome-guide/template.js +6 -3
- package/build/components/welcome-guide/template.js.map +1 -1
- package/build/hooks/commands/use-edit-mode-commands.js +24 -14
- package/build/hooks/commands/use-edit-mode-commands.js.map +1 -1
- package/build/store/actions.js +4 -1
- package/build/store/actions.js.map +1 -1
- package/build/store/private-actions.js +2 -27
- package/build/store/private-actions.js.map +1 -1
- package/build/store/private-selectors.js +0 -23
- package/build/store/private-selectors.js.map +1 -1
- package/build/store/reducer.js +1 -40
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +8 -4
- package/build/store/selectors.js.map +1 -1
- package/build/utils/constants.js +1 -12
- package/build/utils/constants.js.map +1 -1
- package/build-module/components/actions/index.js +55 -36
- package/build-module/components/actions/index.js.map +1 -1
- package/build-module/components/block-editor/site-editor-canvas.js +7 -2
- package/build-module/components/block-editor/site-editor-canvas.js.map +1 -1
- package/build-module/components/dataviews/add-filter.js +21 -20
- package/build-module/components/dataviews/add-filter.js.map +1 -1
- package/build-module/components/dataviews/constants.js +6 -0
- package/build-module/components/dataviews/constants.js.map +1 -0
- package/build-module/components/dataviews/dataviews.js +9 -7
- package/build-module/components/dataviews/dataviews.js.map +1 -1
- package/build-module/components/dataviews/filter-summary.js +55 -0
- package/build-module/components/dataviews/filter-summary.js.map +1 -0
- package/build-module/components/dataviews/filters.js +15 -28
- package/build-module/components/dataviews/filters.js.map +1 -1
- package/build-module/components/dataviews/item-actions.js +84 -30
- package/build-module/components/dataviews/item-actions.js.map +1 -1
- package/build-module/components/dataviews/pagination.js +4 -0
- package/build-module/components/dataviews/pagination.js.map +1 -1
- package/build-module/components/dataviews/view-actions.js +24 -24
- package/build-module/components/dataviews/view-actions.js.map +1 -1
- package/build-module/components/dataviews/view-grid.js +49 -26
- package/build-module/components/dataviews/view-grid.js.map +1 -1
- package/build-module/components/dataviews/view-list.js +28 -33
- package/build-module/components/dataviews/view-list.js.map +1 -1
- package/build-module/components/editor/index.js +26 -30
- package/build-module/components/editor/index.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/utils/get-intersecting-font-faces.js +1 -1
- package/build-module/components/global-styles/font-library-modal/utils/get-intersecting-font-faces.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/utils/index.js +14 -2
- package/build-module/components/global-styles/font-library-modal/utils/index.js.map +1 -1
- package/build-module/components/global-styles/header.js +4 -2
- package/build-module/components/global-styles/header.js.map +1 -1
- package/build-module/components/global-styles/screen-block-list.js +23 -17
- package/build-module/components/global-styles/screen-block-list.js.map +1 -1
- package/build-module/components/global-styles/screen-revisions/index.js +27 -6
- package/build-module/components/global-styles/screen-revisions/index.js.map +1 -1
- package/build-module/components/global-styles/screen-revisions/revisions-buttons.js +51 -24
- package/build-module/components/global-styles/screen-revisions/revisions-buttons.js.map +1 -1
- package/build-module/components/global-styles/screen-revisions/use-global-styles-revisions.js +9 -3
- package/build-module/components/global-styles/screen-revisions/use-global-styles-revisions.js.map +1 -1
- package/build-module/components/global-styles/ui.js +28 -36
- package/build-module/components/global-styles/ui.js.map +1 -1
- package/build-module/components/header-edit-mode/document-actions/index.js +21 -16
- package/build-module/components/header-edit-mode/document-actions/index.js.map +1 -1
- package/build-module/components/header-edit-mode/index.js +2 -1
- package/build-module/components/header-edit-mode/index.js.map +1 -1
- package/build-module/components/header-edit-mode/more-menu/index.js +1 -1
- package/build-module/components/header-edit-mode/more-menu/index.js.map +1 -1
- package/build-module/components/list/added-by.js +44 -55
- package/build-module/components/list/added-by.js.map +1 -1
- package/build-module/components/{page-content-focus-manager → page-content-focus-notifications}/back-to-page-notification.js +9 -8
- package/build-module/components/page-content-focus-notifications/back-to-page-notification.js.map +1 -0
- package/build-module/components/{page-content-focus-manager → page-content-focus-notifications}/edit-template-notification.js +9 -13
- package/build-module/components/page-content-focus-notifications/edit-template-notification.js.map +1 -0
- package/build-module/components/page-content-focus-notifications/index.js +14 -0
- package/build-module/components/page-content-focus-notifications/index.js.map +1 -0
- package/build-module/components/page-pages/index.js +10 -16
- package/build-module/components/page-pages/index.js.map +1 -1
- package/build-module/components/page-patterns/use-patterns.js +1 -1
- package/build-module/components/page-patterns/use-patterns.js.map +1 -1
- package/build-module/components/page-templates/dataviews-templates.js +168 -53
- package/build-module/components/page-templates/dataviews-templates.js.map +1 -1
- package/build-module/components/preferences-modal/index.js +1 -1
- package/build-module/components/preferences-modal/index.js.map +1 -1
- package/build-module/components/save-button/index.js +11 -8
- package/build-module/components/save-button/index.js.map +1 -1
- package/build-module/components/save-hub/index.js +14 -0
- package/build-module/components/save-hub/index.js.map +1 -1
- package/build-module/components/sidebar-dataviews/custom-dataviews-list.js +3 -1
- package/build-module/components/sidebar-dataviews/custom-dataviews-list.js.map +1 -1
- package/build-module/components/sidebar-dataviews/default-views.js +7 -2
- package/build-module/components/sidebar-dataviews/default-views.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/index.js +6 -5
- package/build-module/components/sidebar-edit-mode/index.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/page-panels/edit-template.js +16 -27
- package/build-module/components/sidebar-edit-mode/page-panels/edit-template.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/page-panels/hooks.js +21 -7
- package/build-module/components/sidebar-edit-mode/page-panels/hooks.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/page-panels/page-status.js +9 -6
- package/build-module/components/sidebar-edit-mode/page-panels/page-status.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/page-panels/page-summary.js +5 -9
- package/build-module/components/sidebar-edit-mode/page-panels/page-summary.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/page-panels/reset-default-template.js +3 -3
- package/build-module/components/sidebar-edit-mode/page-panels/reset-default-template.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/settings-header/index.js +10 -6
- package/build-module/components/sidebar-edit-mode/settings-header/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-page/index.js +23 -4
- package/build-module/components/sidebar-navigation-screen-page/index.js.map +1 -1
- package/build-module/components/style-book/index.js +22 -12
- package/build-module/components/style-book/index.js.map +1 -1
- package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js +41 -9
- package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
- package/build-module/components/welcome-guide/page.js +2 -2
- package/build-module/components/welcome-guide/page.js.map +1 -1
- package/build-module/components/welcome-guide/template.js +6 -3
- package/build-module/components/welcome-guide/template.js.map +1 -1
- package/build-module/hooks/commands/use-edit-mode-commands.js +24 -14
- package/build-module/hooks/commands/use-edit-mode-commands.js.map +1 -1
- package/build-module/store/actions.js +4 -1
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/private-actions.js +1 -25
- package/build-module/store/private-actions.js.map +1 -1
- package/build-module/store/private-selectors.js +0 -22
- package/build-module/store/private-selectors.js.map +1 -1
- package/build-module/store/reducer.js +1 -38
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +8 -4
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/constants.js +0 -10
- package/build-module/utils/constants.js.map +1 -1
- package/build-style/style-rtl.css +152 -62
- package/build-style/style.css +152 -62
- package/package.json +41 -41
- package/src/components/actions/index.js +76 -48
- package/src/components/block-editor/site-editor-canvas.js +8 -2
- package/src/components/dataviews/README.md +14 -11
- package/src/components/dataviews/add-filter.js +21 -24
- package/src/components/dataviews/constants.js +5 -0
- package/src/components/dataviews/dataviews.js +10 -10
- package/src/components/dataviews/filter-summary.js +79 -0
- package/src/components/dataviews/filters.js +18 -35
- package/src/components/dataviews/item-actions.js +106 -42
- package/src/components/dataviews/pagination.js +4 -0
- package/src/components/dataviews/style.scss +84 -8
- package/src/components/dataviews/view-actions.js +39 -41
- package/src/components/dataviews/view-grid.js +63 -38
- package/src/components/dataviews/view-list.js +50 -57
- package/src/components/editor/index.js +18 -34
- package/src/components/global-styles/font-library-modal/utils/get-intersecting-font-faces.js +1 -1
- package/src/components/global-styles/font-library-modal/utils/index.js +20 -9
- package/src/components/global-styles/font-library-modal/utils/test/getIntersectingFontFaces.spec.js +46 -15
- package/src/components/global-styles/font-library-modal/utils/test/wpKebabCase.spec.js +28 -0
- package/src/components/global-styles/header.js +2 -1
- package/src/components/global-styles/screen-block-list.js +37 -26
- package/src/components/global-styles/screen-revisions/index.js +39 -10
- package/src/components/global-styles/screen-revisions/revisions-buttons.js +65 -45
- package/src/components/global-styles/screen-revisions/style.scss +52 -28
- package/src/components/global-styles/screen-revisions/use-global-styles-revisions.js +15 -6
- package/src/components/global-styles/style.scss +0 -11
- package/src/components/global-styles/ui.js +59 -74
- package/src/components/header-edit-mode/document-actions/index.js +20 -18
- package/src/components/header-edit-mode/index.js +1 -0
- package/src/components/header-edit-mode/more-menu/index.js +1 -1
- package/src/components/list/added-by.js +23 -63
- package/src/components/list/style.scss +11 -13
- package/src/components/{page-content-focus-manager → page-content-focus-notifications}/back-to-page-notification.js +12 -13
- package/src/components/{page-content-focus-manager → page-content-focus-notifications}/edit-template-notification.js +9 -13
- package/src/components/page-content-focus-notifications/index.js +14 -0
- package/src/components/page-pages/index.js +15 -20
- package/src/components/page-patterns/use-patterns.js +1 -1
- package/src/components/page-templates/dataviews-templates.js +169 -48
- package/src/components/page-templates/style.scss +13 -0
- package/src/components/preferences-modal/index.js +1 -1
- package/src/components/save-button/index.js +37 -24
- package/src/components/save-hub/index.js +15 -0
- package/src/components/save-hub/style.scss +7 -0
- package/src/components/sidebar-dataviews/custom-dataviews-list.js +2 -0
- package/src/components/sidebar-dataviews/default-views.js +7 -2
- package/src/components/sidebar-dataviews/style.scss +7 -0
- package/src/components/sidebar-edit-mode/index.js +13 -9
- package/src/components/sidebar-edit-mode/page-panels/edit-template.js +33 -52
- package/src/components/sidebar-edit-mode/page-panels/hooks.js +20 -9
- package/src/components/sidebar-edit-mode/page-panels/page-status.js +6 -6
- package/src/components/sidebar-edit-mode/page-panels/page-summary.js +8 -9
- package/src/components/sidebar-edit-mode/page-panels/reset-default-template.js +3 -3
- package/src/components/sidebar-edit-mode/page-panels/style.scss +9 -19
- package/src/components/sidebar-edit-mode/settings-header/index.js +8 -9
- package/src/components/sidebar-navigation-screen/style.scss +1 -0
- package/src/components/sidebar-navigation-screen-page/index.js +24 -3
- package/src/components/sidebar-navigation-screen-template/style.scss +6 -1
- package/src/components/style-book/index.js +48 -35
- package/src/components/sync-state-with-url/use-init-edited-entity-from-url.js +69 -17
- package/src/components/welcome-guide/page.js +2 -2
- package/src/components/welcome-guide/template.js +4 -2
- package/src/hooks/commands/use-edit-mode-commands.js +22 -16
- package/src/store/actions.js +5 -1
- package/src/store/private-actions.js +1 -24
- package/src/store/private-selectors.js +0 -22
- package/src/store/reducer.js +0 -39
- package/src/store/selectors.js +12 -4
- package/src/store/test/actions.js +3 -32
- package/src/store/test/reducer.js +0 -62
- package/src/store/test/selectors.js +0 -35
- package/src/style.scss +1 -0
- package/src/utils/constants.js +0 -10
- package/build/components/dataviews/in-filter.js +0 -51
- package/build/components/dataviews/in-filter.js.map +0 -1
- package/build/components/page-content-focus-manager/back-to-page-notification.js.map +0 -1
- package/build/components/page-content-focus-manager/disable-non-page-content-blocks.js +0 -63
- package/build/components/page-content-focus-manager/disable-non-page-content-blocks.js.map +0 -1
- package/build/components/page-content-focus-manager/edit-template-notification.js.map +0 -1
- package/build/components/page-content-focus-manager/index.js +0 -61
- package/build/components/page-content-focus-manager/index.js.map +0 -1
- package/build/components/sidebar-edit-mode/page-panels/publish-date.js +0 -87
- package/build/components/sidebar-edit-mode/page-panels/publish-date.js.map +0 -1
- package/build-module/components/dataviews/in-filter.js +0 -42
- package/build-module/components/dataviews/in-filter.js.map +0 -1
- package/build-module/components/page-content-focus-manager/back-to-page-notification.js.map +0 -1
- package/build-module/components/page-content-focus-manager/disable-non-page-content-blocks.js +0 -56
- package/build-module/components/page-content-focus-manager/disable-non-page-content-blocks.js.map +0 -1
- package/build-module/components/page-content-focus-manager/edit-template-notification.js.map +0 -1
- package/build-module/components/page-content-focus-manager/index.js +0 -52
- package/build-module/components/page-content-focus-manager/index.js.map +0 -1
- package/build-module/components/sidebar-edit-mode/page-panels/publish-date.js +0 -80
- package/build-module/components/sidebar-edit-mode/page-panels/publish-date.js.map +0 -1
- package/src/components/dataviews/in-filter.js +0 -63
- package/src/components/page-content-focus-manager/disable-non-page-content-blocks.js +0 -57
- package/src/components/page-content-focus-manager/index.js +0 -51
- package/src/components/sidebar-edit-mode/page-panels/publish-date.js +0 -94
package/CHANGELOG.md
CHANGED
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.postRevisionsAction = void 0;
|
|
6
|
+
exports.trashPostAction = exports.postRevisionsAction = void 0;
|
|
7
7
|
exports.useEditPostAction = useEditPostAction;
|
|
8
8
|
exports.usePermanentlyDeletePostAction = usePermanentlyDeletePostAction;
|
|
9
9
|
exports.useRestorePostAction = useRestorePostAction;
|
|
10
|
-
exports.useTrashPostAction = useTrashPostAction;
|
|
11
10
|
exports.viewPostAction = void 0;
|
|
11
|
+
var _react = require("react");
|
|
12
12
|
var _icons = require("@wordpress/icons");
|
|
13
13
|
var _url = require("@wordpress/url");
|
|
14
14
|
var _data = require("@wordpress/data");
|
|
@@ -18,6 +18,7 @@ var _i18n = require("@wordpress/i18n");
|
|
|
18
18
|
var _notices = require("@wordpress/notices");
|
|
19
19
|
var _element = require("@wordpress/element");
|
|
20
20
|
var _router = require("@wordpress/router");
|
|
21
|
+
var _components = require("@wordpress/components");
|
|
21
22
|
var _lockUnlock = require("../../lock-unlock");
|
|
22
23
|
/**
|
|
23
24
|
* WordPress dependencies
|
|
@@ -30,43 +31,60 @@ var _lockUnlock = require("../../lock-unlock");
|
|
|
30
31
|
const {
|
|
31
32
|
useHistory
|
|
32
33
|
} = (0, _lockUnlock.unlock)(_router.privateApis);
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
34
|
+
const trashPostAction = {
|
|
35
|
+
id: 'move-to-trash',
|
|
36
|
+
label: (0, _i18n.__)('Move to Trash'),
|
|
37
|
+
isPrimary: true,
|
|
38
|
+
icon: _icons.trash,
|
|
39
|
+
isEligible({
|
|
40
|
+
status
|
|
41
|
+
}) {
|
|
42
|
+
return status !== 'trash';
|
|
43
|
+
},
|
|
44
|
+
hideModalHeader: true,
|
|
45
|
+
RenderModal: ({
|
|
46
|
+
item: post,
|
|
47
|
+
closeModal
|
|
48
|
+
}) => {
|
|
49
|
+
const {
|
|
50
|
+
createSuccessNotice,
|
|
51
|
+
createErrorNotice
|
|
52
|
+
} = (0, _data.useDispatch)(_notices.store);
|
|
53
|
+
const {
|
|
54
|
+
deleteEntityRecord
|
|
55
|
+
} = (0, _data.useDispatch)(_coreData.store);
|
|
56
|
+
return (0, _react.createElement)(_components.__experimentalVStack, {
|
|
57
|
+
spacing: "5"
|
|
58
|
+
}, (0, _react.createElement)(_components.__experimentalText, null, (0, _i18n.sprintf)(
|
|
59
|
+
// translators: %s: The page's title.
|
|
60
|
+
(0, _i18n.__)('Are you sure you want to delete "%s"?'), (0, _htmlEntities.decodeEntities)(post.title.rendered))), (0, _react.createElement)(_components.__experimentalHStack, {
|
|
61
|
+
justify: "right"
|
|
62
|
+
}, (0, _react.createElement)(_components.Button, {
|
|
63
|
+
variant: "tertiary",
|
|
64
|
+
onClick: closeModal
|
|
65
|
+
}, (0, _i18n.__)('Cancel')), (0, _react.createElement)(_components.Button, {
|
|
66
|
+
variant: "primary",
|
|
67
|
+
onClick: async () => {
|
|
68
|
+
try {
|
|
69
|
+
await deleteEntityRecord('postType', post.type, post.id, {}, {
|
|
70
|
+
throwOnError: true
|
|
71
|
+
});
|
|
72
|
+
createSuccessNotice((0, _i18n.sprintf)( /* translators: The page's title. */
|
|
73
|
+
(0, _i18n.__)('"%s" moved to the Trash.'), (0, _htmlEntities.decodeEntities)(post.title.rendered)), {
|
|
74
|
+
type: 'snackbar',
|
|
75
|
+
id: 'edit-site-page-trashed'
|
|
76
|
+
});
|
|
77
|
+
} catch (error) {
|
|
78
|
+
const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : (0, _i18n.__)('An error occurred while moving the page to the trash.');
|
|
79
|
+
createErrorNotice(errorMessage, {
|
|
80
|
+
type: 'snackbar'
|
|
81
|
+
});
|
|
82
|
+
}
|
|
66
83
|
}
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}
|
|
84
|
+
}, (0, _i18n.__)('Delete'))));
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
exports.trashPostAction = trashPostAction;
|
|
70
88
|
function usePermanentlyDeletePostAction() {
|
|
71
89
|
const {
|
|
72
90
|
createSuccessNotice,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_icons","require","_url","_data","_htmlEntities","_coreData","_i18n","_notices","_element","_router","_lockUnlock","useHistory","unlock","routerPrivateApis","useTrashPostAction","createSuccessNotice","createErrorNotice","useDispatch","noticesStore","deleteEntityRecord","coreStore","useMemo","id","label","__","isPrimary","icon","trash","isEligible","status","callback","post","type","throwOnError","sprintf","decodeEntities","title","rendered","error","errorMessage","message","code","usePermanentlyDeletePostAction","force","useRestorePostAction","editEntityRecord","saveEditedEntityRecord","backup","viewPostAction","external","document","location","href","link","exports","useEditPostAction","history","push","postId","postType","canvas","postRevisionsAction","_post$_links$predeces","_post$_links$version","lastRevisionId","_links","revisionsCount","count","addQueryArgs","revision"],"sources":["@wordpress/edit-site/src/components/actions/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { external, trash, backup } from '@wordpress/icons';\nimport { addQueryArgs } from '@wordpress/url';\nimport { useDispatch } from '@wordpress/data';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { useMemo } from '@wordpress/element';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\n\nconst { useHistory } = unlock( routerPrivateApis );\n\nexport function useTrashPostAction() {\n\tconst { createSuccessNotice, createErrorNotice } =\n\t\tuseDispatch( noticesStore );\n\tconst { deleteEntityRecord } = useDispatch( coreStore );\n\n\treturn useMemo(\n\t\t() => ( {\n\t\t\tid: 'move-to-trash',\n\t\t\tlabel: __( 'Move to Trash' ),\n\t\t\tisPrimary: true,\n\t\t\ticon: trash,\n\t\t\tisEligible( { status } ) {\n\t\t\t\treturn status !== 'trash';\n\t\t\t},\n\t\t\tasync callback( post ) {\n\t\t\t\ttry {\n\t\t\t\t\tawait deleteEntityRecord(\n\t\t\t\t\t\t'postType',\n\t\t\t\t\t\tpost.type,\n\t\t\t\t\t\tpost.id,\n\t\t\t\t\t\t{},\n\t\t\t\t\t\t{ throwOnError: true }\n\t\t\t\t\t);\n\t\t\t\t\tcreateSuccessNotice(\n\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t/* translators: The page's title. */\n\t\t\t\t\t\t\t__( '\"%s\" moved to the Trash.' ),\n\t\t\t\t\t\t\tdecodeEntities( post.title.rendered )\n\t\t\t\t\t\t),\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\t\tid: 'edit-site-page-trashed',\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\t\t\t\t} catch ( error ) {\n\t\t\t\t\tconst errorMessage =\n\t\t\t\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t\t\t\t? error.message\n\t\t\t\t\t\t\t: __(\n\t\t\t\t\t\t\t\t\t'An error occurred while moving the page to the trash.'\n\t\t\t\t\t\t\t );\n\n\t\t\t\t\tcreateErrorNotice( errorMessage, { type: 'snackbar' } );\n\t\t\t\t}\n\t\t\t},\n\t\t} ),\n\t\t[ createSuccessNotice, createErrorNotice, deleteEntityRecord ]\n\t);\n}\n\nexport function usePermanentlyDeletePostAction() {\n\tconst { createSuccessNotice, createErrorNotice } =\n\t\tuseDispatch( noticesStore );\n\tconst { deleteEntityRecord } = useDispatch( coreStore );\n\n\treturn useMemo(\n\t\t() => ( {\n\t\t\tid: 'permanently-delete',\n\t\t\tlabel: __( 'Permanently delete' ),\n\t\t\tisPrimary: true,\n\t\t\ticon: trash,\n\t\t\tisEligible( { status } ) {\n\t\t\t\treturn status === 'trash';\n\t\t\t},\n\t\t\tasync callback( post ) {\n\t\t\t\ttry {\n\t\t\t\t\tawait deleteEntityRecord(\n\t\t\t\t\t\t'postType',\n\t\t\t\t\t\tpost.type,\n\t\t\t\t\t\tpost.id,\n\t\t\t\t\t\t{ force: true },\n\t\t\t\t\t\t{ throwOnError: true }\n\t\t\t\t\t);\n\t\t\t\t\tcreateSuccessNotice(\n\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t/* translators: The posts's title. */\n\t\t\t\t\t\t\t__( '\"%s\" permanently deleted.' ),\n\t\t\t\t\t\t\tdecodeEntities( post.title.rendered )\n\t\t\t\t\t\t),\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\t\tid: 'edit-site-post-permanently-deleted',\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\t\t\t\t} catch ( error ) {\n\t\t\t\t\tconst errorMessage =\n\t\t\t\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t\t\t\t? error.message\n\t\t\t\t\t\t\t: __(\n\t\t\t\t\t\t\t\t\t'An error occurred while permanently deleting the post.'\n\t\t\t\t\t\t\t );\n\n\t\t\t\t\tcreateErrorNotice( errorMessage, { type: 'snackbar' } );\n\t\t\t\t}\n\t\t\t},\n\t\t} ),\n\t\t[ createSuccessNotice, createErrorNotice, deleteEntityRecord ]\n\t);\n}\n\nexport function useRestorePostAction() {\n\tconst { createSuccessNotice, createErrorNotice } =\n\t\tuseDispatch( noticesStore );\n\tconst { editEntityRecord, saveEditedEntityRecord } =\n\t\tuseDispatch( coreStore );\n\n\treturn useMemo(\n\t\t() => ( {\n\t\t\tid: 'restore',\n\t\t\tlabel: __( 'Restore' ),\n\t\t\tisPrimary: true,\n\t\t\ticon: backup,\n\t\t\tisEligible( { status } ) {\n\t\t\t\treturn status === 'trash';\n\t\t\t},\n\t\t\tasync callback( post ) {\n\t\t\t\tawait editEntityRecord( 'postType', post.type, post.id, {\n\t\t\t\t\tstatus: 'draft',\n\t\t\t\t} );\n\t\t\t\ttry {\n\t\t\t\t\tawait saveEditedEntityRecord(\n\t\t\t\t\t\t'postType',\n\t\t\t\t\t\tpost.type,\n\t\t\t\t\t\tpost.id,\n\t\t\t\t\t\t{ throwOnError: true }\n\t\t\t\t\t);\n\t\t\t\t\tcreateSuccessNotice(\n\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t/* translators: The posts's title. */\n\t\t\t\t\t\t\t__( '\"%s\" has been restored.' ),\n\t\t\t\t\t\t\tdecodeEntities( post.title.rendered )\n\t\t\t\t\t\t),\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\t\tid: 'edit-site-post-restored',\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\t\t\t\t} catch ( error ) {\n\t\t\t\t\tconst errorMessage =\n\t\t\t\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t\t\t\t? error.message\n\t\t\t\t\t\t\t: __(\n\t\t\t\t\t\t\t\t\t'An error occurred while restoring the post.'\n\t\t\t\t\t\t\t );\n\n\t\t\t\t\tcreateErrorNotice( errorMessage, { type: 'snackbar' } );\n\t\t\t\t}\n\t\t\t},\n\t\t} ),\n\t\t[\n\t\t\tcreateSuccessNotice,\n\t\t\tcreateErrorNotice,\n\t\t\teditEntityRecord,\n\t\t\tsaveEditedEntityRecord,\n\t\t]\n\t);\n}\n\nexport const viewPostAction = {\n\tid: 'view-post',\n\tlabel: __( 'View' ),\n\tisPrimary: true,\n\ticon: external,\n\tisEligible( post ) {\n\t\treturn post.status !== 'trash';\n\t},\n\tcallback( post ) {\n\t\tdocument.location.href = post.link;\n\t},\n};\n\nexport function useEditPostAction() {\n\tconst history = useHistory();\n\treturn useMemo(\n\t\t() => ( {\n\t\t\tid: 'edit-post',\n\t\t\tlabel: __( 'Edit' ),\n\t\t\tisEligible( { status } ) {\n\t\t\t\treturn status !== 'trash';\n\t\t\t},\n\t\t\tcallback( post ) {\n\t\t\t\thistory.push( {\n\t\t\t\t\tpostId: post.id,\n\t\t\t\t\tpostType: post.type,\n\t\t\t\t\tcanvas: 'edit',\n\t\t\t\t} );\n\t\t\t},\n\t\t} ),\n\t\t[ history ]\n\t);\n}\nexport const postRevisionsAction = {\n\tid: 'view-post-revisions',\n\tlabel: __( 'View revisions' ),\n\tisPrimary: false,\n\tisEligible: ( post ) => {\n\t\tif ( post.status === 'trash' ) {\n\t\t\treturn false;\n\t\t}\n\t\tconst lastRevisionId =\n\t\t\tpost?._links?.[ 'predecessor-version' ]?.[ 0 ]?.id ?? null;\n\t\tconst revisionsCount =\n\t\t\tpost?._links?.[ 'version-history' ]?.[ 0 ]?.count ?? 0;\n\t\treturn lastRevisionId && revisionsCount > 1;\n\t},\n\tcallback( post ) {\n\t\tconst href = addQueryArgs( 'revision.php', {\n\t\t\trevision: post?._links?.[ 'predecessor-version' ]?.[ 0 ]?.id,\n\t\t} );\n\t\tdocument.location.href = href;\n\t},\n};\n"],"mappings":";;;;;;;;;;;AAGA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,IAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,aAAA,GAAAH,OAAA;AACA,IAAAI,SAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AACA,IAAAM,QAAA,GAAAN,OAAA;AACA,IAAAO,QAAA,GAAAP,OAAA;AACA,IAAAQ,OAAA,GAAAR,OAAA;AAIA,IAAAS,WAAA,GAAAT,OAAA;AAfA;AACA;AACA;;AAUA;AACA;AACA;;AAGA,MAAM;EAAEU;AAAW,CAAC,GAAG,IAAAC,kBAAM,EAAEC,mBAAkB,CAAC;AAE3C,SA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C,IAAI,CAACF,MAAM,KAAK,OAAO,EAAG;MAC9B,OAAO,KAAK;IACb;IACA,MAAMmC,cAAc,IAAAF,qBAAA,GACnB/B,IAAI,EAAEkC,MAAM,GAAI,qBAAqB,CAAE,GAAI,CAAC,CAAE,EAAE3C,EAAE,cAAAwC,qBAAA,cAAAA,qBAAA,GAAI,IAAI;IAC3D,MAAMI,cAAc,IAAAH,oBAAA,GACnBhC,IAAI,EAAEkC,MAAM,GAAI,iBAAiB,CAAE,GAAI,CAAC,CAAE,EAAEE,KAAK,cAAAJ,oBAAA,cAAAA,oBAAA,GAAI,CAAC;IACvD,OAAOC,cAAc,IAAIE,cAAc,GAAG,CAAC;EAC5C,CAAC;EACDpC,QAAQA,CAAEC,IAAI,EAAG;IAChB,MAAMqB,IAAI,GAAG,IAAAgB,iBAAY,EAAE,cAAc,EAAE;MAC1CC,QAAQ,EAAEtC,IAAI,EAAEkC,MAAM,GAAI,qBAAqB,CAAE,GAAI,CAAC,CAAE,EAAE3C;IAC3D,CAAE,CAAC;IACH4B,QAAQ,CAACC,QAAQ,CAACC,IAAI,GAAGA,IAAI;EAC9B;AACD,CAAC;AAACE,OAAA,CAAAO,mBAAA,GAAAA,mBAAA"}
|
|
1
|
+
{"version":3,"names":["_icons","require","_url","_data","_htmlEntities","_coreData","_i18n","_notices","_element","_router","_components","_lockUnlock","useHistory","unlock","routerPrivateApis","trashPostAction","id","label","__","isPrimary","icon","trash","isEligible","status","hideModalHeader","RenderModal","item","post","closeModal","createSuccessNotice","createErrorNotice","useDispatch","noticesStore","deleteEntityRecord","coreStore","_react","createElement","__experimentalVStack","spacing","__experimentalText","sprintf","decodeEntities","title","rendered","__experimentalHStack","justify","Button","variant","onClick","type","throwOnError","error","errorMessage","message","code","exports","usePermanentlyDeletePostAction","useMemo","callback","force","useRestorePostAction","editEntityRecord","saveEditedEntityRecord","backup","viewPostAction","external","document","location","href","link","useEditPostAction","history","push","postId","postType","canvas","postRevisionsAction","_post$_links$predeces","_post$_links$version","lastRevisionId","_links","revisionsCount","count","addQueryArgs","revision"],"sources":["@wordpress/edit-site/src/components/actions/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { external, trash, backup } from '@wordpress/icons';\nimport { addQueryArgs } from '@wordpress/url';\nimport { useDispatch } from '@wordpress/data';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { useMemo } from '@wordpress/element';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\nimport {\n\tButton,\n\t__experimentalText as Text,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\n\nconst { useHistory } = unlock( routerPrivateApis );\n\nexport const trashPostAction = {\n\tid: 'move-to-trash',\n\tlabel: __( 'Move to Trash' ),\n\tisPrimary: true,\n\ticon: trash,\n\tisEligible( { status } ) {\n\t\treturn status !== 'trash';\n\t},\n\thideModalHeader: true,\n\tRenderModal: ( { item: post, closeModal } ) => {\n\t\tconst { createSuccessNotice, createErrorNotice } =\n\t\t\tuseDispatch( noticesStore );\n\t\tconst { deleteEntityRecord } = useDispatch( coreStore );\n\t\treturn (\n\t\t\t<VStack spacing=\"5\">\n\t\t\t\t<Text>\n\t\t\t\t\t{ sprintf(\n\t\t\t\t\t\t// translators: %s: The page's title.\n\t\t\t\t\t\t__( 'Are you sure you want to delete \"%s\"?' ),\n\t\t\t\t\t\tdecodeEntities( post.title.rendered )\n\t\t\t\t\t) }\n\t\t\t\t</Text>\n\t\t\t\t<HStack justify=\"right\">\n\t\t\t\t\t<Button variant=\"tertiary\" onClick={ closeModal }>\n\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t\t<Button\n\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\tonClick={ async () => {\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\tawait deleteEntityRecord(\n\t\t\t\t\t\t\t\t\t'postType',\n\t\t\t\t\t\t\t\t\tpost.type,\n\t\t\t\t\t\t\t\t\tpost.id,\n\t\t\t\t\t\t\t\t\t{},\n\t\t\t\t\t\t\t\t\t{ throwOnError: true }\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tcreateSuccessNotice(\n\t\t\t\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t\t\t\t/* translators: The page's title. */\n\t\t\t\t\t\t\t\t\t\t__( '\"%s\" moved to the Trash.' ),\n\t\t\t\t\t\t\t\t\t\tdecodeEntities( post.title.rendered )\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\t\t\t\t\tid: 'edit-site-page-trashed',\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t} catch ( error ) {\n\t\t\t\t\t\t\t\tconst errorMessage =\n\t\t\t\t\t\t\t\t\terror.message &&\n\t\t\t\t\t\t\t\t\terror.code !== 'unknown_error'\n\t\t\t\t\t\t\t\t\t\t? error.message\n\t\t\t\t\t\t\t\t\t\t: __(\n\t\t\t\t\t\t\t\t\t\t\t\t'An error occurred while moving the page to the trash.'\n\t\t\t\t\t\t\t\t\t\t );\n\n\t\t\t\t\t\t\t\tcreateErrorNotice( errorMessage, {\n\t\t\t\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Delete' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t</HStack>\n\t\t\t</VStack>\n\t\t);\n\t},\n};\n\nexport function usePermanentlyDeletePostAction() {\n\tconst { createSuccessNotice, createErrorNotice } =\n\t\tuseDispatch( noticesStore );\n\tconst { deleteEntityRecord } = useDispatch( coreStore );\n\n\treturn useMemo(\n\t\t() => ( {\n\t\t\tid: 'permanently-delete',\n\t\t\tlabel: __( 'Permanently delete' ),\n\t\t\tisPrimary: true,\n\t\t\ticon: trash,\n\t\t\tisEligible( { status } ) {\n\t\t\t\treturn status === 'trash';\n\t\t\t},\n\t\t\tasync callback( post ) {\n\t\t\t\ttry {\n\t\t\t\t\tawait deleteEntityRecord(\n\t\t\t\t\t\t'postType',\n\t\t\t\t\t\tpost.type,\n\t\t\t\t\t\tpost.id,\n\t\t\t\t\t\t{ force: true },\n\t\t\t\t\t\t{ throwOnError: true }\n\t\t\t\t\t);\n\t\t\t\t\tcreateSuccessNotice(\n\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t/* translators: The posts's title. */\n\t\t\t\t\t\t\t__( '\"%s\" permanently deleted.' ),\n\t\t\t\t\t\t\tdecodeEntities( post.title.rendered )\n\t\t\t\t\t\t),\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\t\tid: 'edit-site-post-permanently-deleted',\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\t\t\t\t} catch ( error ) {\n\t\t\t\t\tconst errorMessage =\n\t\t\t\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t\t\t\t? error.message\n\t\t\t\t\t\t\t: __(\n\t\t\t\t\t\t\t\t\t'An error occurred while permanently deleting the post.'\n\t\t\t\t\t\t\t );\n\n\t\t\t\t\tcreateErrorNotice( errorMessage, { type: 'snackbar' } );\n\t\t\t\t}\n\t\t\t},\n\t\t} ),\n\t\t[ createSuccessNotice, createErrorNotice, deleteEntityRecord ]\n\t);\n}\n\nexport function useRestorePostAction() {\n\tconst { createSuccessNotice, createErrorNotice } =\n\t\tuseDispatch( noticesStore );\n\tconst { editEntityRecord, saveEditedEntityRecord } =\n\t\tuseDispatch( coreStore );\n\n\treturn useMemo(\n\t\t() => ( {\n\t\t\tid: 'restore',\n\t\t\tlabel: __( 'Restore' ),\n\t\t\tisPrimary: true,\n\t\t\ticon: backup,\n\t\t\tisEligible( { status } ) {\n\t\t\t\treturn status === 'trash';\n\t\t\t},\n\t\t\tasync callback( post ) {\n\t\t\t\tawait editEntityRecord( 'postType', post.type, post.id, {\n\t\t\t\t\tstatus: 'draft',\n\t\t\t\t} );\n\t\t\t\ttry {\n\t\t\t\t\tawait saveEditedEntityRecord(\n\t\t\t\t\t\t'postType',\n\t\t\t\t\t\tpost.type,\n\t\t\t\t\t\tpost.id,\n\t\t\t\t\t\t{ throwOnError: true }\n\t\t\t\t\t);\n\t\t\t\t\tcreateSuccessNotice(\n\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t/* translators: The posts's title. */\n\t\t\t\t\t\t\t__( '\"%s\" has been restored.' ),\n\t\t\t\t\t\t\tdecodeEntities( post.title.rendered )\n\t\t\t\t\t\t),\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\t\tid: 'edit-site-post-restored',\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\t\t\t\t} catch ( error ) {\n\t\t\t\t\tconst errorMessage =\n\t\t\t\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t\t\t\t? error.message\n\t\t\t\t\t\t\t: __(\n\t\t\t\t\t\t\t\t\t'An error occurred while restoring the post.'\n\t\t\t\t\t\t\t );\n\n\t\t\t\t\tcreateErrorNotice( errorMessage, { type: 'snackbar' } );\n\t\t\t\t}\n\t\t\t},\n\t\t} ),\n\t\t[\n\t\t\tcreateSuccessNotice,\n\t\t\tcreateErrorNotice,\n\t\t\teditEntityRecord,\n\t\t\tsaveEditedEntityRecord,\n\t\t]\n\t);\n}\n\nexport const viewPostAction = {\n\tid: 'view-post',\n\tlabel: __( 'View' ),\n\tisPrimary: true,\n\ticon: external,\n\tisEligible( post ) {\n\t\treturn post.status !== 'trash';\n\t},\n\tcallback( post ) {\n\t\tdocument.location.href = post.link;\n\t},\n};\n\nexport function useEditPostAction() {\n\tconst history = useHistory();\n\treturn useMemo(\n\t\t() => ( {\n\t\t\tid: 'edit-post',\n\t\t\tlabel: __( 'Edit' ),\n\t\t\tisEligible( { status } ) {\n\t\t\t\treturn status !== 'trash';\n\t\t\t},\n\t\t\tcallback( post ) {\n\t\t\t\thistory.push( {\n\t\t\t\t\tpostId: post.id,\n\t\t\t\t\tpostType: post.type,\n\t\t\t\t\tcanvas: 'edit',\n\t\t\t\t} );\n\t\t\t},\n\t\t} ),\n\t\t[ history ]\n\t);\n}\nexport const postRevisionsAction = {\n\tid: 'view-post-revisions',\n\tlabel: __( 'View revisions' ),\n\tisPrimary: false,\n\tisEligible: ( post ) => {\n\t\tif ( post.status === 'trash' ) {\n\t\t\treturn false;\n\t\t}\n\t\tconst lastRevisionId =\n\t\t\tpost?._links?.[ 'predecessor-version' ]?.[ 0 ]?.id ?? null;\n\t\tconst revisionsCount =\n\t\t\tpost?._links?.[ 'version-history' ]?.[ 0 ]?.count ?? 0;\n\t\treturn lastRevisionId && revisionsCount > 1;\n\t},\n\tcallback( post ) {\n\t\tconst href = addQueryArgs( 'revision.php', {\n\t\t\trevision: post?._links?.[ 'predecessor-version' ]?.[ 0 ]?.id,\n\t\t} );\n\t\tdocument.location.href = href;\n\t},\n};\n"],"mappings":";;;;;;;;;;;AAGA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,IAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,aAAA,GAAAH,OAAA;AACA,IAAAI,SAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AACA,IAAAM,QAAA,GAAAN,OAAA;AACA,IAAAO,QAAA,GAAAP,OAAA;AACA,IAAAQ,OAAA,GAAAR,OAAA;AACA,IAAAS,WAAA,GAAAT,OAAA;AAUA,IAAAU,WAAA,GAAAV,OAAA;AAtBA;AACA;AACA;;AAiBA;AACA;AACA;;AAGA,MAAM;EAAEW;AAAW,CAAC,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DvB,QAAQA,CAAE/B,IAAI,EAAG;IAChB,MAAMyC,IAAI,GAAG,IAAAe,iBAAY,EAAE,cAAc,EAAE;MAC1CC,QAAQ,EAAEzD,IAAI,EAAEqD,MAAM,GAAI,qBAAqB,CAAE,GAAI,CAAC,CAAE,EAAEhE;IAC3D,CAAE,CAAC;IACHkD,QAAQ,CAACC,QAAQ,CAACC,IAAI,GAAGA,IAAI;EAC9B;AACD,CAAC;AAACb,OAAA,CAAAqB,mBAAA,GAAAA,mBAAA"}
|
|
@@ -19,7 +19,7 @@ var _useSiteEditorSettings = _interopRequireDefault(require("./use-site-editor-s
|
|
|
19
19
|
var _store = require("../../store");
|
|
20
20
|
var _constants = require("../../utils/constants");
|
|
21
21
|
var _lockUnlock = require("../../lock-unlock");
|
|
22
|
-
var
|
|
22
|
+
var _pageContentFocusNotifications = _interopRequireDefault(require("../page-content-focus-notifications"));
|
|
23
23
|
/**
|
|
24
24
|
* External dependencies
|
|
25
25
|
*/
|
|
@@ -108,9 +108,14 @@ function SiteEditorCanvas() {
|
|
|
108
108
|
className: (0, _classnames.default)('edit-site-block-editor__block-list wp-site-blocks', {
|
|
109
109
|
'is-navigation-block': isTemplateTypeNavigation
|
|
110
110
|
}),
|
|
111
|
+
dropZoneElement:
|
|
112
|
+
// Pass in the html element of the iframe to ensure that
|
|
113
|
+
// the drop zone extends to the very edges of the iframe,
|
|
114
|
+
// even if the template is shorter than the viewport.
|
|
115
|
+
contentRef.current?.parentNode,
|
|
111
116
|
layout: LAYOUT,
|
|
112
117
|
renderAppender: showBlockAppender
|
|
113
|
-
}))))), (0, _react.createElement)(
|
|
118
|
+
}))))), (0, _react.createElement)(_pageContentFocusNotifications.default, {
|
|
114
119
|
contentRef: contentRef
|
|
115
120
|
}));
|
|
116
121
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_classnames","_interopRequireDefault","require","_data","_element","_blockEditor","_compose","_backButton","_resizableEditor","_editorCanvas","_editorCanvasContainer","_useSiteEditorSettings","_store","_constants","_lockUnlock","
|
|
1
|
+
{"version":3,"names":["_classnames","_interopRequireDefault","require","_data","_element","_blockEditor","_compose","_backButton","_resizableEditor","_editorCanvas","_editorCanvasContainer","_useSiteEditorSettings","_store","_constants","_lockUnlock","_pageContentFocusNotifications","LAYOUT","type","alignments","SiteEditorCanvas","clearSelectedBlock","useDispatch","blockEditorStore","templateType","isFocusMode","isViewMode","useSelect","select","getEditedPostType","getCanvasMode","unlock","editSiteStore","_templateType","FOCUSABLE_ENTITIES","includes","resizeObserver","sizes","useResizeObserver","settings","useSiteEditorSettings","hasBlocks","getBlockCount","blocks","isMobileViewport","useViewportMatch","enableResizing","contentRef","useRef","isTemplateTypeNavigation","NAVIGATION_POST_TYPE","isNavigationFocusMode","showBlockAppender","undefined","forceFullHeight","_react","createElement","Fragment","default","Slot","editorCanvasView","className","BlockTools","classnames","__unstableContentRef","onClick","event","target","currentTarget","height","BlockList","dropZoneElement","current","parentNode","layout","renderAppender"],"sources":["@wordpress/edit-site/src/components/block-editor/site-editor-canvas.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useRef } from '@wordpress/element';\nimport {\n\tBlockList,\n\tBlockTools,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { useViewportMatch, useResizeObserver } from '@wordpress/compose';\n/**\n * Internal dependencies\n */\nimport BackButton from './back-button';\nimport ResizableEditor from './resizable-editor';\nimport EditorCanvas from './editor-canvas';\nimport EditorCanvasContainer from '../editor-canvas-container';\nimport useSiteEditorSettings from './use-site-editor-settings';\nimport { store as editSiteStore } from '../../store';\nimport {\n\tFOCUSABLE_ENTITIES,\n\tNAVIGATION_POST_TYPE,\n} from '../../utils/constants';\nimport { unlock } from '../../lock-unlock';\nimport PageContentFocusNotifications from '../page-content-focus-notifications';\n\nconst LAYOUT = {\n\ttype: 'default',\n\t// At the root level of the site editor, no alignments should be allowed.\n\talignments: [],\n};\n\nexport default function SiteEditorCanvas() {\n\tconst { clearSelectedBlock } = useDispatch( blockEditorStore );\n\n\tconst { templateType, isFocusMode, isViewMode } = useSelect( ( select ) => {\n\t\tconst { getEditedPostType, getCanvasMode } = unlock(\n\t\t\tselect( editSiteStore )\n\t\t);\n\n\t\tconst _templateType = getEditedPostType();\n\n\t\treturn {\n\t\t\ttemplateType: _templateType,\n\t\t\tisFocusMode: FOCUSABLE_ENTITIES.includes( _templateType ),\n\t\t\tisViewMode: getCanvasMode() === 'view',\n\t\t};\n\t}, [] );\n\n\tconst [ resizeObserver, sizes ] = useResizeObserver();\n\n\tconst settings = useSiteEditorSettings();\n\n\tconst { hasBlocks } = useSelect( ( select ) => {\n\t\tconst { getBlockCount } = select( blockEditorStore );\n\n\t\tconst blocks = getBlockCount();\n\n\t\treturn {\n\t\t\thasBlocks: !! blocks,\n\t\t};\n\t}, [] );\n\n\tconst isMobileViewport = useViewportMatch( 'small', '<' );\n\tconst enableResizing =\n\t\tisFocusMode &&\n\t\t! isViewMode &&\n\t\t// Disable resizing in mobile viewport.\n\t\t! isMobileViewport;\n\n\tconst contentRef = useRef();\n\tconst isTemplateTypeNavigation = templateType === NAVIGATION_POST_TYPE;\n\n\tconst isNavigationFocusMode = isTemplateTypeNavigation && isFocusMode;\n\n\t// Hide the appender when:\n\t// - In navigation focus mode (should only allow the root Nav block).\n\t// - In view mode (i.e. not editing).\n\tconst showBlockAppender =\n\t\t( isNavigationFocusMode && hasBlocks ) || isViewMode\n\t\t\t? false\n\t\t\t: undefined;\n\n\tconst forceFullHeight = isNavigationFocusMode;\n\n\treturn (\n\t\t<>\n\t\t\t<EditorCanvasContainer.Slot>\n\t\t\t\t{ ( [ editorCanvasView ] ) =>\n\t\t\t\t\teditorCanvasView ? (\n\t\t\t\t\t\t<div className=\"edit-site-visual-editor is-focus-mode\">\n\t\t\t\t\t\t\t{ editorCanvasView }\n\t\t\t\t\t\t</div>\n\t\t\t\t\t) : (\n\t\t\t\t\t\t<BlockTools\n\t\t\t\t\t\t\tclassName={ classnames( 'edit-site-visual-editor', {\n\t\t\t\t\t\t\t\t'is-focus-mode':\n\t\t\t\t\t\t\t\t\tisFocusMode || !! editorCanvasView,\n\t\t\t\t\t\t\t\t'is-view-mode': isViewMode,\n\t\t\t\t\t\t\t} ) }\n\t\t\t\t\t\t\t__unstableContentRef={ contentRef }\n\t\t\t\t\t\t\tonClick={ ( event ) => {\n\t\t\t\t\t\t\t\t// Clear selected block when clicking on the gray background.\n\t\t\t\t\t\t\t\tif ( event.target === event.currentTarget ) {\n\t\t\t\t\t\t\t\t\tclearSelectedBlock();\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<BackButton />\n\t\t\t\t\t\t\t<ResizableEditor\n\t\t\t\t\t\t\t\tenableResizing={ enableResizing }\n\t\t\t\t\t\t\t\theight={\n\t\t\t\t\t\t\t\t\tsizes.height && ! forceFullHeight\n\t\t\t\t\t\t\t\t\t\t? sizes.height\n\t\t\t\t\t\t\t\t\t\t: '100%'\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<EditorCanvas\n\t\t\t\t\t\t\t\t\tenableResizing={ enableResizing }\n\t\t\t\t\t\t\t\t\tsettings={ settings }\n\t\t\t\t\t\t\t\t\tcontentRef={ contentRef }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ resizeObserver }\n\t\t\t\t\t\t\t\t\t<BlockList\n\t\t\t\t\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t\t\t\t\t'edit-site-block-editor__block-list wp-site-blocks',\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t'is-navigation-block':\n\t\t\t\t\t\t\t\t\t\t\t\t\tisTemplateTypeNavigation,\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\tdropZoneElement={\n\t\t\t\t\t\t\t\t\t\t\t// Pass in the html element of the iframe to ensure that\n\t\t\t\t\t\t\t\t\t\t\t// the drop zone extends to the very edges of the iframe,\n\t\t\t\t\t\t\t\t\t\t\t// even if the template is shorter than the viewport.\n\t\t\t\t\t\t\t\t\t\t\tcontentRef.current?.parentNode\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tlayout={ LAYOUT }\n\t\t\t\t\t\t\t\t\t\trenderAppender={ showBlockAppender }\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t</EditorCanvas>\n\t\t\t\t\t\t\t</ResizableEditor>\n\t\t\t\t\t\t</BlockTools>\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t</EditorCanvasContainer.Slot>\n\t\t\t<PageContentFocusNotifications contentRef={ contentRef } />\n\t\t</>\n\t);\n}\n"],"mappings":";;;;;;;;AAGA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AAIA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,YAAA,GAAAH,OAAA;AAKA,IAAAI,QAAA,GAAAJ,OAAA;AAIA,IAAAK,WAAA,GAAAN,sBAAA,CAAAC,OAAA;AACA,IAAAM,gBAAA,GAAAP,sBAAA,CAAAC,OAAA;AACA,IAAAO,aAAA,GAAAR,sBAAA,CAAAC,OAAA;AACA,IAAAQ,sBAAA,GAAAT,sBAAA,CAAAC,OAAA;AACA,IAAAS,sBAAA,GAAAV,sBAAA,CAAAC,OAAA;AACA,IAAAU,MAAA,GAAAV,OAAA;AACA,IAAAW,UAAA,GAAAX,OAAA;AAIA,IAAAY,WAAA,GAAAZ,OAAA;AACA,IAAAa,8BAAA,GAAAd,sBAAA,CAAAC,OAAA;AA7BA;AACA;AACA;;AAEA;AACA;AACA;;AASA;AACA;AACA;;AAcA,MAAMc,MAAM,GAAG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AQ,EAAGA,QAAU;IACrBQ,UAAU,EAAGA;EAAY,GAEvBX,cAAc,EAChB,IAAAmB,MAAA,CAAAC,aAAA,EAAClD,YAAA,CAAAgE,SAAS;IACTT,SAAS,EAAG,IAAAE,mBAAU,EACrB,mDAAmD,EACnD;MACC,qBAAqB,EACpBd;IACF,CACD,CAAG;IACHsB,eAAe;IACd;IACA;IACA;IACAxB,UAAU,CAACyB,OAAO,EAAEC,UACpB;IACDC,MAAM,EAAGzD,MAAQ;IACjB0D,cAAc,EAAGvB;EAAmB,CACpC,CACY,CACE,CACN,CAGa,CAAC,EAC7B,IAAAG,MAAA,CAAAC,aAAA,EAACxC,8BAAA,CAAA0C,OAA6B;IAACX,UAAU,EAAGA;EAAY,CAAE,CACzD,CAAC;AAEL"}
|
|
@@ -9,7 +9,7 @@ var _components = require("@wordpress/components");
|
|
|
9
9
|
var _icons = require("@wordpress/icons");
|
|
10
10
|
var _i18n = require("@wordpress/i18n");
|
|
11
11
|
var _lockUnlock = require("../../lock-unlock");
|
|
12
|
-
var
|
|
12
|
+
var _constants = require("./constants");
|
|
13
13
|
/**
|
|
14
14
|
* WordPress dependencies
|
|
15
15
|
*/
|
|
@@ -19,12 +19,11 @@ var _inFilter = require("./in-filter");
|
|
|
19
19
|
*/
|
|
20
20
|
|
|
21
21
|
const {
|
|
22
|
-
DropdownMenuV2,
|
|
23
|
-
DropdownSubMenuV2,
|
|
24
|
-
DropdownSubMenuTriggerV2,
|
|
25
|
-
DropdownMenuItemV2
|
|
22
|
+
DropdownMenuV2: DropdownMenu,
|
|
23
|
+
DropdownSubMenuV2: DropdownSubMenu,
|
|
24
|
+
DropdownSubMenuTriggerV2: DropdownSubMenuTrigger,
|
|
25
|
+
DropdownMenuItemV2: DropdownMenuItem
|
|
26
26
|
} = (0, _lockUnlock.unlock)(_components.privateApis);
|
|
27
|
-
const VALID_OPERATORS = [_inFilter.OPERATOR_IN];
|
|
28
27
|
function AddFilter({
|
|
29
28
|
fields,
|
|
30
29
|
view,
|
|
@@ -32,45 +31,47 @@ function AddFilter({
|
|
|
32
31
|
}) {
|
|
33
32
|
const filters = [];
|
|
34
33
|
fields.forEach(field => {
|
|
35
|
-
if (!field.
|
|
34
|
+
if (!field.type) {
|
|
36
35
|
return;
|
|
37
36
|
}
|
|
38
|
-
field.
|
|
39
|
-
|
|
37
|
+
switch (field.type) {
|
|
38
|
+
case _constants.ENUMERATION_TYPE:
|
|
40
39
|
filters.push({
|
|
41
40
|
field: field.id,
|
|
42
41
|
name: field.header,
|
|
43
|
-
operator: filter,
|
|
44
42
|
elements: field.elements || [],
|
|
45
|
-
isVisible: view.filters.some(f => f.field === field.id && f.operator ===
|
|
43
|
+
isVisible: view.filters.some(f => f.field === field.id && f.operator === _constants.OPERATOR_IN)
|
|
46
44
|
});
|
|
47
|
-
|
|
48
|
-
});
|
|
45
|
+
}
|
|
49
46
|
});
|
|
50
47
|
if (filters.length === 0) {
|
|
51
48
|
return null;
|
|
52
49
|
}
|
|
53
|
-
return (0, _react.createElement)(
|
|
50
|
+
return (0, _react.createElement)(DropdownMenu, {
|
|
54
51
|
label: (0, _i18n.__)('Add filter'),
|
|
55
52
|
trigger: (0, _react.createElement)(_components.Button, {
|
|
56
53
|
disabled: filters.length === view.filters?.length,
|
|
57
54
|
__experimentalIsFocusable: true,
|
|
58
|
-
icon: _icons.plus,
|
|
59
55
|
variant: "tertiary",
|
|
60
56
|
size: "compact"
|
|
61
|
-
}, (0,
|
|
57
|
+
}, (0, _react.createElement)(_components.Icon, {
|
|
58
|
+
icon: _icons.plus,
|
|
59
|
+
style: {
|
|
60
|
+
flexShrink: 0
|
|
61
|
+
}
|
|
62
|
+
}), (0, _i18n.__)('Add filter'))
|
|
62
63
|
}, filters.map(filter => {
|
|
63
64
|
if (filter.isVisible) {
|
|
64
65
|
return null;
|
|
65
66
|
}
|
|
66
|
-
return (0, _react.createElement)(
|
|
67
|
+
return (0, _react.createElement)(DropdownSubMenu, {
|
|
67
68
|
key: filter.field,
|
|
68
|
-
trigger: (0, _react.createElement)(
|
|
69
|
+
trigger: (0, _react.createElement)(DropdownSubMenuTrigger, {
|
|
69
70
|
suffix: (0, _react.createElement)(_components.Icon, {
|
|
70
71
|
icon: _icons.chevronRightSmall
|
|
71
72
|
})
|
|
72
73
|
}, filter.name)
|
|
73
|
-
}, filter.elements.map(element => (0, _react.createElement)(
|
|
74
|
+
}, filter.elements.map(element => (0, _react.createElement)(DropdownMenuItem, {
|
|
74
75
|
key: element.value,
|
|
75
76
|
onSelect: () => {
|
|
76
77
|
onChangeView(currentView => ({
|
|
@@ -78,7 +79,7 @@ function AddFilter({
|
|
|
78
79
|
page: 1,
|
|
79
80
|
filters: [...currentView.filters, {
|
|
80
81
|
field: filter.field,
|
|
81
|
-
operator:
|
|
82
|
+
operator: _constants.OPERATOR_IN,
|
|
82
83
|
value: element.value
|
|
83
84
|
}]
|
|
84
85
|
}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_components","require","_icons","_i18n","_lockUnlock","
|
|
1
|
+
{"version":3,"names":["_components","require","_icons","_i18n","_lockUnlock","_constants","DropdownMenuV2","DropdownMenu","DropdownSubMenuV2","DropdownSubMenu","DropdownSubMenuTriggerV2","DropdownSubMenuTrigger","DropdownMenuItemV2","DropdownMenuItem","unlock","componentsPrivateApis","AddFilter","fields","view","onChangeView","filters","forEach","field","type","ENUMERATION_TYPE","push","id","name","header","elements","isVisible","some","f","operator","OPERATOR_IN","length","_react","createElement","label","__","trigger","Button","disabled","__experimentalIsFocusable","variant","size","Icon","icon","plus","style","flexShrink","map","filter","key","suffix","chevronRightSmall","element","value","onSelect","currentView","page","role"],"sources":["@wordpress/edit-site/src/components/dataviews/add-filter.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tprivateApis as componentsPrivateApis,\n\tButton,\n\tIcon,\n} from '@wordpress/components';\nimport { chevronRightSmall, plus } from '@wordpress/icons';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\nimport { ENUMERATION_TYPE, OPERATOR_IN } from './constants';\n\nconst {\n\tDropdownMenuV2: DropdownMenu,\n\tDropdownSubMenuV2: DropdownSubMenu,\n\tDropdownSubMenuTriggerV2: DropdownSubMenuTrigger,\n\tDropdownMenuItemV2: DropdownMenuItem,\n} = unlock( componentsPrivateApis );\n\nexport default function AddFilter( { fields, view, onChangeView } ) {\n\tconst filters = [];\n\tfields.forEach( ( field ) => {\n\t\tif ( ! field.type ) {\n\t\t\treturn;\n\t\t}\n\n\t\tswitch ( field.type ) {\n\t\t\tcase ENUMERATION_TYPE:\n\t\t\t\tfilters.push( {\n\t\t\t\t\tfield: field.id,\n\t\t\t\t\tname: field.header,\n\t\t\t\t\telements: field.elements || [],\n\t\t\t\t\tisVisible: view.filters.some(\n\t\t\t\t\t\t( f ) =>\n\t\t\t\t\t\t\tf.field === field.id && f.operator === OPERATOR_IN\n\t\t\t\t\t),\n\t\t\t\t} );\n\t\t}\n\t} );\n\n\tif ( filters.length === 0 ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<DropdownMenu\n\t\t\tlabel={ __( 'Add filter' ) }\n\t\t\ttrigger={\n\t\t\t\t<Button\n\t\t\t\t\tdisabled={ filters.length === view.filters?.length }\n\t\t\t\t\t__experimentalIsFocusable\n\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\tsize=\"compact\"\n\t\t\t\t>\n\t\t\t\t\t<Icon icon={ plus } style={ { flexShrink: 0 } } />\n\t\t\t\t\t{ __( 'Add filter' ) }\n\t\t\t\t</Button>\n\t\t\t}\n\t\t>\n\t\t\t{ filters.map( ( filter ) => {\n\t\t\t\tif ( filter.isVisible ) {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\n\t\t\t\treturn (\n\t\t\t\t\t<DropdownSubMenu\n\t\t\t\t\t\tkey={ filter.field }\n\t\t\t\t\t\ttrigger={\n\t\t\t\t\t\t\t<DropdownSubMenuTrigger\n\t\t\t\t\t\t\t\tsuffix={ <Icon icon={ chevronRightSmall } /> }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ filter.name }\n\t\t\t\t\t\t\t</DropdownSubMenuTrigger>\n\t\t\t\t\t\t}\n\t\t\t\t\t>\n\t\t\t\t\t\t{ filter.elements.map( ( element ) => (\n\t\t\t\t\t\t\t<DropdownMenuItem\n\t\t\t\t\t\t\t\tkey={ element.value }\n\t\t\t\t\t\t\t\tonSelect={ () => {\n\t\t\t\t\t\t\t\t\tonChangeView( ( currentView ) => ( {\n\t\t\t\t\t\t\t\t\t\t...currentView,\n\t\t\t\t\t\t\t\t\t\tpage: 1,\n\t\t\t\t\t\t\t\t\t\tfilters: [\n\t\t\t\t\t\t\t\t\t\t\t...currentView.filters,\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\tfield: filter.field,\n\t\t\t\t\t\t\t\t\t\t\t\toperator: OPERATOR_IN,\n\t\t\t\t\t\t\t\t\t\t\t\tvalue: element.value,\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\t} ) );\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\trole=\"menuitemcheckbox\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ element.label }\n\t\t\t\t\t\t\t</DropdownMenuItem>\n\t\t\t\t\t\t) ) }\n\t\t\t\t\t</DropdownSubMenu>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</DropdownMenu>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AAKA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AAKA,IAAAG,WAAA,GAAAH,OAAA;AACA,IAAAI,UAAA,GAAAJ,OAAA;AAfA;AACA;AACA;;AASA;AACA;AACA;;AAIA,MAAM;EACLK,cAAc,EAAEC,YAAY;EAC5BC,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N = exports.ENUMERATION_TYPE = void 0;
|
|
7
|
+
// Field types.
|
|
8
|
+
const ENUMERATION_TYPE = 'enumeration';
|
|
9
|
+
|
|
10
|
+
// Filter operators.
|
|
11
|
+
exports.ENUMERATION_TYPE = ENUMERATION_TYPE;
|
|
12
|
+
const OPERATOR_IN = 'in';
|
|
13
|
+
exports.OPERATOR_IN = OPERATOR_IN;
|
|
14
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["ENUMERATION_TYPE","exports","OPERATOR_IN"],"sources":["@wordpress/edit-site/src/components/dataviews/constants.js"],"sourcesContent":["// Field types.\nexport const ENUMERATION_TYPE = 'enumeration';\n\n// Filter operators.\nexport const OPERATOR_IN = 'in';\n"],"mappings":";;;;;;AAAA;AACO,MAAMA,gBAAgB,GAAG,aAAa;;AAE7C;AAAAC,OAAA,CAAAD,gBAAA,GAAAA,gBAAA;AACO,MAAME,WAAW,GAAG,IAAI;AAACD,OAAA,CAAAC,WAAA,GAAAA,WAAA"}
|
|
@@ -46,6 +46,7 @@ function DataViews({
|
|
|
46
46
|
searchLabel = undefined,
|
|
47
47
|
actions,
|
|
48
48
|
data,
|
|
49
|
+
getItemId,
|
|
49
50
|
isLoading = false,
|
|
50
51
|
paginationInfo,
|
|
51
52
|
supportedLayouts
|
|
@@ -62,8 +63,11 @@ function DataViews({
|
|
|
62
63
|
}, (0, _react.createElement)(_components.__experimentalVStack, {
|
|
63
64
|
spacing: 4,
|
|
64
65
|
justify: "flex-start"
|
|
65
|
-
}, (0, _react.createElement)(_components.__experimentalHStack,
|
|
66
|
-
|
|
66
|
+
}, (0, _react.createElement)(_components.__experimentalHStack, {
|
|
67
|
+
alignment: "flex-start"
|
|
68
|
+
}, (0, _react.createElement)(_components.__experimentalHStack, {
|
|
69
|
+
justify: "start",
|
|
70
|
+
wrap: true
|
|
67
71
|
}, search && (0, _react.createElement)(_search.default, {
|
|
68
72
|
label: searchLabel,
|
|
69
73
|
view: view,
|
|
@@ -72,21 +76,19 @@ function DataViews({
|
|
|
72
76
|
fields: fields,
|
|
73
77
|
view: view,
|
|
74
78
|
onChangeView: onChangeView
|
|
75
|
-
})), (0, _react.createElement)(
|
|
76
|
-
justify: "end",
|
|
77
|
-
expanded: false
|
|
78
|
-
}, (0, _react.createElement)(_viewActions.default, {
|
|
79
|
+
})), (0, _react.createElement)(_viewActions.default, {
|
|
79
80
|
fields: fields,
|
|
80
81
|
view: view,
|
|
81
82
|
onChangeView: onChangeView,
|
|
82
83
|
supportedLayouts: supportedLayouts
|
|
83
|
-
}))
|
|
84
|
+
})), (0, _react.createElement)(ViewComponent, {
|
|
84
85
|
fields: _fields,
|
|
85
86
|
view: view,
|
|
86
87
|
onChangeView: onChangeView,
|
|
87
88
|
paginationInfo: paginationInfo,
|
|
88
89
|
actions: actions,
|
|
89
90
|
data: data,
|
|
91
|
+
getItemId: getItemId,
|
|
90
92
|
isLoading: isLoading
|
|
91
93
|
}), (0, _react.createElement)(_pagination.default, {
|
|
92
94
|
view: view,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_components","require","_element","_viewList","_interopRequireDefault","_pagination","_viewActions","_filters","_search","_viewGrid","_viewSideBySide","viewTypeSupportsMap","list","grid","preview","exports","viewTypeMap","ViewList","ViewGrid","ViewSideBySide","DataViews","view","onChangeView","fields","search","searchLabel","undefined","actions","data","isLoading","paginationInfo","supportedLayouts","ViewComponent","type","_fields","useMemo","map","field","render","getValue","_react","createElement","className","__experimentalVStack","spacing","justify","__experimentalHStack","
|
|
1
|
+
{"version":3,"names":["_components","require","_element","_viewList","_interopRequireDefault","_pagination","_viewActions","_filters","_search","_viewGrid","_viewSideBySide","viewTypeSupportsMap","list","grid","preview","exports","viewTypeMap","ViewList","ViewGrid","ViewSideBySide","DataViews","view","onChangeView","fields","search","searchLabel","undefined","actions","data","getItemId","isLoading","paginationInfo","supportedLayouts","ViewComponent","type","_fields","useMemo","map","field","render","getValue","_react","createElement","className","__experimentalVStack","spacing","justify","__experimentalHStack","alignment","wrap","default","label"],"sources":["@wordpress/edit-site/src/components/dataviews/dataviews.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalVStack as VStack,\n\t__experimentalHStack as HStack,\n} from '@wordpress/components';\nimport { useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport ViewList from './view-list';\nimport Pagination from './pagination';\nimport ViewActions from './view-actions';\nimport Filters from './filters';\nimport Search from './search';\nimport { ViewGrid } from './view-grid';\nimport { ViewSideBySide } from './view-side-by-side';\n\n// To do: convert to view type registry.\nexport const viewTypeSupportsMap = {\n\tlist: {},\n\tgrid: {},\n\t'side-by-side': {\n\t\tpreview: true,\n\t},\n};\n\nconst viewTypeMap = {\n\tlist: ViewList,\n\tgrid: ViewGrid,\n\t'side-by-side': ViewSideBySide,\n};\n\nexport default function DataViews( {\n\tview,\n\tonChangeView,\n\tfields,\n\tsearch = true,\n\tsearchLabel = undefined,\n\tactions,\n\tdata,\n\tgetItemId,\n\tisLoading = false,\n\tpaginationInfo,\n\tsupportedLayouts,\n} ) {\n\tconst ViewComponent = viewTypeMap[ view.type ];\n\tconst _fields = useMemo( () => {\n\t\treturn fields.map( ( field ) => ( {\n\t\t\t...field,\n\t\t\trender: field.render || field.getValue,\n\t\t} ) );\n\t}, [ fields ] );\n\treturn (\n\t\t<div className=\"dataviews-wrapper\">\n\t\t\t<VStack spacing={ 4 } justify=\"flex-start\">\n\t\t\t\t<HStack alignment=\"flex-start\">\n\t\t\t\t\t<HStack justify=\"start\" wrap>\n\t\t\t\t\t\t{ search && (\n\t\t\t\t\t\t\t<Search\n\t\t\t\t\t\t\t\tlabel={ searchLabel }\n\t\t\t\t\t\t\t\tview={ view }\n\t\t\t\t\t\t\t\tonChangeView={ onChangeView }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t<Filters\n\t\t\t\t\t\t\tfields={ fields }\n\t\t\t\t\t\t\tview={ view }\n\t\t\t\t\t\t\tonChangeView={ onChangeView }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</HStack>\n\t\t\t\t\t<ViewActions\n\t\t\t\t\t\tfields={ fields }\n\t\t\t\t\t\tview={ view }\n\t\t\t\t\t\tonChangeView={ onChangeView }\n\t\t\t\t\t\tsupportedLayouts={ supportedLayouts }\n\t\t\t\t\t/>\n\t\t\t\t</HStack>\n\t\t\t\t<ViewComponent\n\t\t\t\t\tfields={ _fields }\n\t\t\t\t\tview={ view }\n\t\t\t\t\tonChangeView={ onChangeView }\n\t\t\t\t\tpaginationInfo={ paginationInfo }\n\t\t\t\t\tactions={ actions }\n\t\t\t\t\tdata={ data }\n\t\t\t\t\tgetItemId={ getItemId }\n\t\t\t\t\tisLoading={ isLoading }\n\t\t\t\t/>\n\t\t\t\t<Pagination\n\t\t\t\t\tview={ view }\n\t\t\t\t\tonChangeView={ onChangeView }\n\t\t\t\t\tpaginationInfo={ paginationInfo }\n\t\t\t\t/>\n\t\t\t</VStack>\n\t\t</div>\n\t);\n}\n"],"mappings":";;;;;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AAIA,IAAAC,QAAA,GAAAD,OAAA;AAKA,IAAAE,SAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,WAAA,GAAAD,sBAAA,CAAAH,OAAA;AACA,IAAAK,YAAA,GAAAF,sBAAA,CAAAH,OAAA;AACA,IAAAM,QAAA,GAAAH,sBAAA,CAAAH,OAAA;AACA,IAAAO,OAAA,GAAAJ,sBAAA,CAAAH,OAAA;AACA,IAAAQ,SAAA,GAAAR,OAAA;AACA,IAAAS,eAAA,GAAAT,OAAA;AAlBA;AACA;AACA;;AAOA;AACA;AACA;;AASA;AACO,MAAMU,mBAAmB,GAAG;EAClCC,IAAI,EAAE,CAAC,CAAC;EACRC,IAAI,EAAE,CAAC,CAAC;EACR,cAAc,EAAE;IACfC,OAAO,EAAE;EACV;AACD,CAAC;AAACC,OAAA,CAA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,QAAA,CAAA2C,OAAO;IACP3B,MAAM,EAAGA,MAAQ;IACjBF,IAAI,EAAGA,IAAM;IACbC,YAAY,EAAGA;EAAc,CAC7B,CACM,CAAC,EACT,IAAAmB,MAAA,CAAAC,aAAA,EAACpC,YAAA,CAAA4C,OAAW;IACX3B,MAAM,EAAGA,MAAQ;IACjBF,IAAI,EAAGA,IAAM;IACbC,YAAY,EAAGA,YAAc;IAC7BU,gBAAgB,EAAGA;EAAkB,CACrC,CACM,CAAC,EACT,IAAAS,MAAA,CAAAC,aAAA,EAACT,aAAa;IACbV,MAAM,EAAGY,OAAS;IAClBd,IAAI,EAAGA,IAAM;IACbC,YAAY,EAAGA,YAAc;IAC7BS,cAAc,EAAGA,cAAgB;IACjCJ,OAAO,EAAGA,OAAS;IACnBC,IAAI,EAAGA,IAAM;IACbC,SAAS,EAAGA,SAAW;IACvBC,SAAS,EAAGA;EAAW,CACvB,CAAC,EACF,IAAAW,MAAA,CAAAC,aAAA,EAACrC,WAAA,CAAA6C,OAAU;IACV7B,IAAI,EAAGA,IAAM;IACbC,YAAY,EAAGA,YAAc;IAC7BS,cAAc,EAAGA;EAAgB,CACjC,CACM,CACJ,CAAC;AAER"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = FilterSummary;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _components = require("@wordpress/components");
|
|
9
|
+
var _icons = require("@wordpress/icons");
|
|
10
|
+
var _i18n = require("@wordpress/i18n");
|
|
11
|
+
var _constants = require("./constants");
|
|
12
|
+
var _lockUnlock = require("../../lock-unlock");
|
|
13
|
+
/**
|
|
14
|
+
* WordPress dependencies
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Internal dependencies
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
const {
|
|
22
|
+
DropdownMenuV2: DropdownMenu,
|
|
23
|
+
DropdownMenuCheckboxItemV2: DropdownMenuCheckboxItem
|
|
24
|
+
} = (0, _lockUnlock.unlock)(_components.privateApis);
|
|
25
|
+
function FilterSummary({
|
|
26
|
+
filter,
|
|
27
|
+
view,
|
|
28
|
+
onChangeView
|
|
29
|
+
}) {
|
|
30
|
+
const filterInView = view.filters.find(f => f.field === filter.field);
|
|
31
|
+
const activeElement = filter.elements.find(element => element.value === filterInView?.value);
|
|
32
|
+
return (0, _react.createElement)(DropdownMenu, {
|
|
33
|
+
key: filter.field,
|
|
34
|
+
trigger: (0, _react.createElement)(_components.Button, {
|
|
35
|
+
variant: "tertiary",
|
|
36
|
+
size: "compact",
|
|
37
|
+
label: filter.name
|
|
38
|
+
}, activeElement !== undefined ? (0, _i18n.sprintf)( /* translators: 1: Filter name. 2: filter value. e.g.: "Author is Admin". */
|
|
39
|
+
(0, _i18n.__)('%1$s is %2$s'), filter.name, activeElement.label) : filter.name, (0, _react.createElement)(_components.Icon, {
|
|
40
|
+
icon: _icons.chevronDown,
|
|
41
|
+
style: {
|
|
42
|
+
flexShrink: 0
|
|
43
|
+
}
|
|
44
|
+
}))
|
|
45
|
+
}, filter.elements.map(element => {
|
|
46
|
+
return (0, _react.createElement)(DropdownMenuCheckboxItem, {
|
|
47
|
+
key: element.value,
|
|
48
|
+
value: element.value,
|
|
49
|
+
checked: activeElement?.value === element.value,
|
|
50
|
+
onSelect: () => onChangeView(currentView => ({
|
|
51
|
+
...currentView,
|
|
52
|
+
page: 1,
|
|
53
|
+
filters: [...view.filters.filter(f => f.field !== filter.field), {
|
|
54
|
+
field: filter.field,
|
|
55
|
+
operator: _constants.OPERATOR_IN,
|
|
56
|
+
value: activeElement?.value === element.value ? undefined : element.value
|
|
57
|
+
}]
|
|
58
|
+
}))
|
|
59
|
+
}, element.label);
|
|
60
|
+
}));
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=filter-summary.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_components","require","_icons","_i18n","_constants","_lockUnlock","DropdownMenuV2","DropdownMenu","DropdownMenuCheckboxItemV2","DropdownMenuCheckboxItem","unlock","componentsPrivateApis","FilterSummary","filter","view","onChangeView","filterInView","filters","find","f","field","activeElement","elements","element","value","_react","createElement","key","trigger","Button","variant","size","label","name","undefined","sprintf","__","Icon","icon","chevronDown","style","flexShrink","map","checked","onSelect","currentView","page","operator","OPERATOR_IN"],"sources":["@wordpress/edit-site/src/components/dataviews/filter-summary.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tButton,\n\tprivateApis as componentsPrivateApis,\n\tIcon,\n} from '@wordpress/components';\nimport { chevronDown } from '@wordpress/icons';\nimport { __, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { OPERATOR_IN } from './constants';\nimport { unlock } from '../../lock-unlock';\n\nconst {\n\tDropdownMenuV2: DropdownMenu,\n\tDropdownMenuCheckboxItemV2: DropdownMenuCheckboxItem,\n} = unlock( componentsPrivateApis );\n\nexport default function FilterSummary( { filter, view, onChangeView } ) {\n\tconst filterInView = view.filters.find( ( f ) => f.field === filter.field );\n\tconst activeElement = filter.elements.find(\n\t\t( element ) => element.value === filterInView?.value\n\t);\n\n\treturn (\n\t\t<DropdownMenu\n\t\t\tkey={ filter.field }\n\t\t\ttrigger={\n\t\t\t\t<Button variant=\"tertiary\" size=\"compact\" label={ filter.name }>\n\t\t\t\t\t{ activeElement !== undefined\n\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t/* translators: 1: Filter name. 2: filter value. e.g.: \"Author is Admin\". */\n\t\t\t\t\t\t\t\t__( '%1$s is %2$s' ),\n\t\t\t\t\t\t\t\tfilter.name,\n\t\t\t\t\t\t\t\tactiveElement.label\n\t\t\t\t\t\t )\n\t\t\t\t\t\t: filter.name }\n\t\t\t\t\t<Icon icon={ chevronDown } style={ { flexShrink: 0 } } />\n\t\t\t\t</Button>\n\t\t\t}\n\t\t>\n\t\t\t{ filter.elements.map( ( element ) => {\n\t\t\t\treturn (\n\t\t\t\t\t<DropdownMenuCheckboxItem\n\t\t\t\t\t\tkey={ element.value }\n\t\t\t\t\t\tvalue={ element.value }\n\t\t\t\t\t\tchecked={ activeElement?.value === element.value }\n\t\t\t\t\t\tonSelect={ () =>\n\t\t\t\t\t\t\tonChangeView( ( currentView ) => ( {\n\t\t\t\t\t\t\t\t...currentView,\n\t\t\t\t\t\t\t\tpage: 1,\n\t\t\t\t\t\t\t\tfilters: [\n\t\t\t\t\t\t\t\t\t...view.filters.filter(\n\t\t\t\t\t\t\t\t\t\t( f ) => f.field !== filter.field\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tfield: filter.field,\n\t\t\t\t\t\t\t\t\t\toperator: OPERATOR_IN,\n\t\t\t\t\t\t\t\t\t\tvalue:\n\t\t\t\t\t\t\t\t\t\t\tactiveElement?.value ===\n\t\t\t\t\t\t\t\t\t\t\telement.value\n\t\t\t\t\t\t\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t\t\t\t\t\t\t: element.value,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t} ) )\n\t\t\t\t\t\t}\n\t\t\t\t\t>\n\t\t\t\t\t\t{ element.label }\n\t\t\t\t\t</DropdownMenuCheckboxItem>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</DropdownMenu>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AAKA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AAKA,IAAAG,UAAA,GAAAH,OAAA;AACA,IAAAI,WAAA,GAAAJ,OAAA;AAfA;AACA;AACA;;AASA;AACA;AACA;;AAIA,MAAM;EACLK,cAAc,EAAEC,YAAY;EAC5BC,0BAA0B,EAAEC;AAC7B,CA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