@wordpress/edit-site 5.14.0 → 5.16.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 +4 -0
- package/build/components/add-new-page/index.js +1 -6
- package/build/components/add-new-page/index.js.map +1 -1
- package/build/components/add-new-pattern/index.js +22 -7
- package/build/components/add-new-pattern/index.js.map +1 -1
- package/build/components/add-new-template/utils.js +10 -8
- package/build/components/add-new-template/utils.js.map +1 -1
- package/build/components/block-editor/constants.js +1 -1
- package/build/components/block-editor/constants.js.map +1 -1
- package/build/components/block-editor/editor-canvas.js +1 -1
- package/build/components/block-editor/editor-canvas.js.map +1 -1
- package/build/components/block-editor/index.js +0 -4
- package/build/components/block-editor/index.js.map +1 -1
- package/build/components/block-editor/use-site-editor-settings.js +114 -13
- package/build/components/block-editor/use-site-editor-settings.js.map +1 -1
- package/build/components/code-editor/index.js +60 -28
- package/build/components/code-editor/index.js.map +1 -1
- package/build/components/create-pattern-modal/index.js +7 -3
- package/build/components/create-pattern-modal/index.js.map +1 -1
- package/build/components/editor/index.js +5 -5
- package/build/components/editor/index.js.map +1 -1
- package/build/components/global-styles/global-styles-provider.js +12 -7
- package/build/components/global-styles/global-styles-provider.js.map +1 -1
- package/build/components/global-styles/screen-block.js +16 -0
- package/build/components/global-styles/screen-block.js.map +1 -1
- package/build/components/global-styles/screen-revisions/index.js +12 -5
- package/build/components/global-styles/screen-revisions/index.js.map +1 -1
- package/build/components/global-styles/screen-revisions/revisions-buttons.js +10 -22
- 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 +32 -25
- package/build/components/global-styles/screen-revisions/use-global-styles-revisions.js.map +1 -1
- package/build/components/global-styles/style-variations-container.js +5 -3
- package/build/components/global-styles/style-variations-container.js.map +1 -1
- package/build/components/header-edit-mode/document-actions/index.js +4 -2
- package/build/components/header-edit-mode/document-actions/index.js.map +1 -1
- package/build/components/header-edit-mode/index.js +13 -9
- package/build/components/header-edit-mode/index.js.map +1 -1
- package/build/components/keyboard-shortcuts/edit-mode.js +7 -5
- package/build/components/keyboard-shortcuts/edit-mode.js.map +1 -1
- package/build/components/layout/index.js +17 -5
- package/build/components/layout/index.js.map +1 -1
- package/build/components/page/index.js +3 -3
- package/build/components/page/index.js.map +1 -1
- package/build/components/page-actions/index.js +2 -2
- package/build/components/page-actions/index.js.map +1 -1
- package/build/components/page-actions/{delete-page-menu-item.js → trash-page-menu-item.js} +8 -16
- package/build/components/page-actions/trash-page-menu-item.js.map +1 -0
- package/build/components/page-content-focus-manager/disable-non-page-content-blocks.js +5 -5
- package/build/components/page-content-focus-manager/disable-non-page-content-blocks.js.map +1 -1
- package/build/components/page-patterns/duplicate-menu-item.js +163 -0
- package/build/components/page-patterns/duplicate-menu-item.js.map +1 -0
- package/build/components/page-patterns/grid-item.js +83 -58
- package/build/components/page-patterns/grid-item.js.map +1 -1
- package/build/components/page-patterns/grid.js +5 -18
- package/build/components/page-patterns/grid.js.map +1 -1
- package/build/components/page-patterns/header.js +69 -0
- package/build/components/page-patterns/header.js.map +1 -0
- package/build/components/page-patterns/index.js +3 -1
- package/build/components/page-patterns/index.js.map +1 -1
- package/build/components/page-patterns/pagination.js +63 -0
- package/build/components/page-patterns/pagination.js.map +1 -0
- package/build/components/page-patterns/patterns-list.js +110 -31
- package/build/components/page-patterns/patterns-list.js.map +1 -1
- package/build/components/page-patterns/rename-menu-item.js +109 -0
- package/build/components/page-patterns/rename-menu-item.js.map +1 -0
- package/build/components/page-patterns/use-patterns.js +116 -118
- package/build/components/page-patterns/use-patterns.js.map +1 -1
- package/build/components/page-template-parts/add-new-template-part.js +74 -0
- package/build/components/page-template-parts/add-new-template-part.js.map +1 -0
- package/build/components/page-template-parts/index.js +3 -25
- package/build/components/page-template-parts/index.js.map +1 -1
- package/build/components/page-templates/index.js +1 -16
- package/build/components/page-templates/index.js.map +1 -1
- package/build/components/resizable-frame/index.js +85 -51
- package/build/components/resizable-frame/index.js.map +1 -1
- package/build/components/save-button/index.js +4 -2
- package/build/components/save-button/index.js.map +1 -1
- package/build/components/save-hub/index.js +10 -4
- package/build/components/save-hub/index.js.map +1 -1
- package/build/components/save-panel/index.js +5 -5
- package/build/components/save-panel/index.js.map +1 -1
- package/build/components/sidebar-edit-mode/page-panels/page-content.js +4 -3
- package/build/components/sidebar-edit-mode/page-panels/page-content.js.map +1 -1
- package/build/components/sidebar-edit-mode/page-panels/page-status.js +3 -8
- package/build/components/sidebar-edit-mode/page-panels/page-status.js.map +1 -1
- package/build/components/sidebar-edit-mode/template-panel/index.js +15 -8
- package/build/components/sidebar-edit-mode/template-panel/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen/index.js +31 -15
- package/build/components/sidebar-navigation-screen/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-global-styles/index.js +34 -40
- package/build/components/sidebar-navigation-screen-global-styles/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-main/index.js +4 -2
- package/build/components/sidebar-navigation-screen-main/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-main/template-part-hint.js +45 -0
- package/build/components/sidebar-navigation-screen-main/template-part-hint.js.map +1 -0
- package/build/components/sidebar-navigation-screen-navigation-menu/index.js +4 -4
- package/build/components/sidebar-navigation-screen-navigation-menu/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-menu/more-menu.js +1 -0
- package/build/components/sidebar-navigation-screen-navigation-menu/more-menu.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-menu/single-navigation-menu.js +3 -3
- package/build/components/sidebar-navigation-screen-navigation-menu/single-navigation-menu.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-menu/use-navigation-menu-handlers.js +5 -4
- package/build/components/sidebar-navigation-screen-navigation-menu/use-navigation-menu-handlers.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-menus/constants.js +2 -0
- package/build/components/sidebar-navigation-screen-navigation-menus/constants.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-menus/index.js +4 -4
- package/build/components/sidebar-navigation-screen-navigation-menus/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-menus/leaf-more-menu.js +8 -0
- package/build/components/sidebar-navigation-screen-navigation-menus/leaf-more-menu.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js +1 -1
- package/build/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js.map +1 -1
- package/build/components/sidebar-navigation-screen-page/index.js +2 -3
- package/build/components/sidebar-navigation-screen-page/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-page/status-label.js +1 -34
- package/build/components/sidebar-navigation-screen-page/status-label.js.map +1 -1
- package/build/components/sidebar-navigation-screen-pages/index.js +35 -25
- package/build/components/sidebar-navigation-screen-pages/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-pattern/index.js +9 -7
- package/build/components/sidebar-navigation-screen-pattern/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-pattern/template-part-navigation-menu.js +4 -3
- package/build/components/sidebar-navigation-screen-pattern/template-part-navigation-menu.js.map +1 -1
- package/build/components/sidebar-navigation-screen-pattern/template-part-navigation-menus.js +3 -2
- package/build/components/sidebar-navigation-screen-pattern/template-part-navigation-menus.js.map +1 -1
- package/build/components/sidebar-navigation-screen-pattern/use-navigation-menu-content.js +19 -4
- package/build/components/sidebar-navigation-screen-pattern/use-navigation-menu-content.js.map +1 -1
- package/build/components/sidebar-navigation-screen-pattern/use-pattern-details.js +55 -28
- package/build/components/sidebar-navigation-screen-pattern/use-pattern-details.js.map +1 -1
- package/build/components/sidebar-navigation-screen-patterns/category-item.js +0 -5
- package/build/components/sidebar-navigation-screen-patterns/category-item.js.map +1 -1
- package/build/components/sidebar-navigation-screen-patterns/index.js +72 -60
- package/build/components/sidebar-navigation-screen-patterns/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-patterns/use-my-patterns.js +9 -5
- package/build/components/sidebar-navigation-screen-patterns/use-my-patterns.js.map +1 -1
- package/build/components/sidebar-navigation-screen-patterns/use-pattern-categories.js +11 -1
- package/build/components/sidebar-navigation-screen-patterns/use-pattern-categories.js.map +1 -1
- package/build/components/sidebar-navigation-screen-patterns/use-template-part-areas.js +20 -9
- package/build/components/sidebar-navigation-screen-patterns/use-template-part-areas.js.map +1 -1
- package/build/components/sidebar-navigation-screen-patterns/use-theme-patterns.js +1 -1
- package/build/components/sidebar-navigation-screen-patterns/use-theme-patterns.js.map +1 -1
- package/build/components/sidebar-navigation-screen-templates/index.js +1 -10
- package/build/components/sidebar-navigation-screen-templates/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-templates-browse/index.js +9 -0
- package/build/components/sidebar-navigation-screen-templates-browse/index.js.map +1 -1
- package/build/components/site-hub/index.js +29 -13
- package/build/components/site-hub/index.js.map +1 -1
- package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js +10 -5
- package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
- package/build/components/sync-state-with-url/use-sync-canvas-mode-with-url.js +1 -1
- package/build/components/sync-state-with-url/use-sync-canvas-mode-with-url.js.map +1 -1
- package/build/components/sync-state-with-url/use-sync-path-with-url.js +15 -12
- package/build/components/sync-state-with-url/use-sync-path-with-url.js.map +1 -1
- package/build/components/template-actions/index.js +3 -1
- package/build/components/template-actions/index.js.map +1 -1
- package/build/components/template-actions/rename-menu-item.js +12 -8
- package/build/components/template-actions/rename-menu-item.js.map +1 -1
- package/build/components/use-edited-entity-record/index.js +6 -1
- package/build/components/use-edited-entity-record/index.js.map +1 -1
- package/build/hooks/commands/use-common-commands.js +120 -32
- package/build/hooks/commands/use-common-commands.js.map +1 -1
- package/build/hooks/commands/use-edit-mode-commands.js +65 -7
- package/build/hooks/commands/use-edit-mode-commands.js.map +1 -1
- package/build/hooks/push-changes-to-global-styles/index.js +138 -57
- package/build/hooks/push-changes-to-global-styles/index.js.map +1 -1
- package/build/store/private-actions.js +9 -2
- package/build/store/private-actions.js.map +1 -1
- package/build/utils/normalize-record-key.js +19 -0
- package/build/utils/normalize-record-key.js.map +1 -0
- package/build/utils/use-activate-theme.js +1 -1
- package/build/utils/use-activate-theme.js.map +1 -1
- package/build/utils/use-debounced-input.js +5 -7
- package/build/utils/use-debounced-input.js.map +1 -1
- package/build-module/components/add-new-page/index.js +1 -6
- package/build-module/components/add-new-page/index.js.map +1 -1
- package/build-module/components/add-new-pattern/index.js +20 -7
- package/build-module/components/add-new-pattern/index.js.map +1 -1
- package/build-module/components/add-new-template/utils.js +9 -6
- package/build-module/components/add-new-template/utils.js.map +1 -1
- package/build-module/components/block-editor/constants.js +1 -1
- package/build-module/components/block-editor/constants.js.map +1 -1
- package/build-module/components/block-editor/editor-canvas.js +1 -1
- package/build-module/components/block-editor/editor-canvas.js.map +1 -1
- package/build-module/components/block-editor/index.js +0 -4
- package/build-module/components/block-editor/index.js.map +1 -1
- package/build-module/components/block-editor/use-site-editor-settings.js +116 -14
- package/build-module/components/block-editor/use-site-editor-settings.js.map +1 -1
- package/build-module/components/code-editor/index.js +62 -30
- package/build-module/components/code-editor/index.js.map +1 -1
- package/build-module/components/create-pattern-modal/index.js +6 -3
- package/build-module/components/create-pattern-modal/index.js.map +1 -1
- package/build-module/components/editor/index.js +5 -5
- package/build-module/components/editor/index.js.map +1 -1
- package/build-module/components/global-styles/global-styles-provider.js +12 -7
- package/build-module/components/global-styles/global-styles-provider.js.map +1 -1
- package/build-module/components/global-styles/screen-block.js +16 -0
- package/build-module/components/global-styles/screen-block.js.map +1 -1
- package/build-module/components/global-styles/screen-revisions/index.js +13 -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 +10 -22
- 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 +28 -21
- package/build-module/components/global-styles/screen-revisions/use-global-styles-revisions.js.map +1 -1
- package/build-module/components/global-styles/style-variations-container.js +5 -3
- package/build-module/components/global-styles/style-variations-container.js.map +1 -1
- package/build-module/components/header-edit-mode/document-actions/index.js +6 -4
- package/build-module/components/header-edit-mode/document-actions/index.js.map +1 -1
- package/build-module/components/header-edit-mode/index.js +13 -9
- package/build-module/components/header-edit-mode/index.js.map +1 -1
- package/build-module/components/keyboard-shortcuts/edit-mode.js +7 -5
- package/build-module/components/keyboard-shortcuts/edit-mode.js.map +1 -1
- package/build-module/components/layout/index.js +17 -5
- package/build-module/components/layout/index.js.map +1 -1
- package/build-module/components/page/index.js +3 -3
- package/build-module/components/page/index.js.map +1 -1
- package/build-module/components/page-actions/index.js +2 -2
- package/build-module/components/page-actions/index.js.map +1 -1
- package/build-module/components/page-actions/{delete-page-menu-item.js → trash-page-menu-item.js} +8 -17
- package/build-module/components/page-actions/trash-page-menu-item.js.map +1 -0
- package/build-module/components/page-content-focus-manager/disable-non-page-content-blocks.js +5 -3
- package/build-module/components/page-content-focus-manager/disable-non-page-content-blocks.js.map +1 -1
- package/build-module/components/page-patterns/duplicate-menu-item.js +147 -0
- package/build-module/components/page-patterns/duplicate-menu-item.js.map +1 -0
- package/build-module/components/page-patterns/grid-item.js +84 -64
- package/build-module/components/page-patterns/grid-item.js.map +1 -1
- package/build-module/components/page-patterns/grid.js +5 -17
- package/build-module/components/page-patterns/grid.js.map +1 -1
- package/build-module/components/page-patterns/header.js +54 -0
- package/build-module/components/page-patterns/header.js.map +1 -0
- package/build-module/components/page-patterns/index.js +3 -1
- package/build-module/components/page-patterns/index.js.map +1 -1
- package/build-module/components/page-patterns/pagination.js +54 -0
- package/build-module/components/page-patterns/pagination.js.map +1 -0
- package/build-module/components/page-patterns/patterns-list.js +111 -34
- package/build-module/components/page-patterns/patterns-list.js.map +1 -1
- package/build-module/components/page-patterns/rename-menu-item.js +97 -0
- package/build-module/components/page-patterns/rename-menu-item.js.map +1 -0
- package/build-module/components/page-patterns/use-patterns.js +116 -119
- package/build-module/components/page-patterns/use-patterns.js.map +1 -1
- package/build-module/components/page-template-parts/add-new-template-part.js +58 -0
- package/build-module/components/page-template-parts/add-new-template-part.js.map +1 -0
- package/build-module/components/page-template-parts/index.js +4 -24
- package/build-module/components/page-template-parts/index.js.map +1 -1
- package/build-module/components/page-templates/index.js +2 -15
- package/build-module/components/page-templates/index.js.map +1 -1
- package/build-module/components/resizable-frame/index.js +87 -55
- package/build-module/components/resizable-frame/index.js.map +1 -1
- package/build-module/components/save-button/index.js +4 -2
- package/build-module/components/save-button/index.js.map +1 -1
- package/build-module/components/save-hub/index.js +10 -4
- package/build-module/components/save-hub/index.js.map +1 -1
- package/build-module/components/save-panel/index.js +5 -5
- package/build-module/components/save-panel/index.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/page-panels/page-content.js +5 -2
- package/build-module/components/sidebar-edit-mode/page-panels/page-content.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/page-panels/page-status.js +3 -8
- package/build-module/components/sidebar-edit-mode/page-panels/page-status.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/template-panel/index.js +15 -9
- package/build-module/components/sidebar-edit-mode/template-panel/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen/index.js +29 -16
- package/build-module/components/sidebar-navigation-screen/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-global-styles/index.js +34 -40
- package/build-module/components/sidebar-navigation-screen-global-styles/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-main/index.js +4 -3
- package/build-module/components/sidebar-navigation-screen-main/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-main/template-part-hint.js +33 -0
- package/build-module/components/sidebar-navigation-screen-main/template-part-hint.js.map +1 -0
- package/build-module/components/sidebar-navigation-screen-navigation-menu/index.js +4 -4
- package/build-module/components/sidebar-navigation-screen-navigation-menu/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menu/more-menu.js +1 -0
- package/build-module/components/sidebar-navigation-screen-navigation-menu/more-menu.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menu/single-navigation-menu.js +3 -3
- package/build-module/components/sidebar-navigation-screen-navigation-menu/single-navigation-menu.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menu/use-navigation-menu-handlers.js +5 -4
- package/build-module/components/sidebar-navigation-screen-navigation-menu/use-navigation-menu-handlers.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menus/constants.js +2 -0
- package/build-module/components/sidebar-navigation-screen-navigation-menus/constants.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menus/index.js +4 -4
- package/build-module/components/sidebar-navigation-screen-navigation-menus/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menus/leaf-more-menu.js +7 -0
- package/build-module/components/sidebar-navigation-screen-navigation-menus/leaf-more-menu.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js +2 -2
- package/build-module/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-page/index.js +2 -3
- package/build-module/components/sidebar-navigation-screen-page/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-page/status-label.js +1 -32
- package/build-module/components/sidebar-navigation-screen-page/status-label.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-pages/index.js +35 -25
- package/build-module/components/sidebar-navigation-screen-pages/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-pattern/index.js +8 -7
- package/build-module/components/sidebar-navigation-screen-pattern/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-pattern/template-part-navigation-menu.js +4 -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/template-part-navigation-menus.js +3 -2
- package/build-module/components/sidebar-navigation-screen-pattern/template-part-navigation-menus.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-pattern/use-navigation-menu-content.js +18 -4
- package/build-module/components/sidebar-navigation-screen-pattern/use-navigation-menu-content.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-pattern/use-pattern-details.js +53 -28
- package/build-module/components/sidebar-navigation-screen-pattern/use-pattern-details.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-patterns/category-item.js +0 -5
- package/build-module/components/sidebar-navigation-screen-patterns/category-item.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-patterns/index.js +76 -60
- package/build-module/components/sidebar-navigation-screen-patterns/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-patterns/use-my-patterns.js +9 -5
- package/build-module/components/sidebar-navigation-screen-patterns/use-my-patterns.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-patterns/use-pattern-categories.js +10 -1
- package/build-module/components/sidebar-navigation-screen-patterns/use-pattern-categories.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-patterns/use-template-part-areas.js +18 -9
- package/build-module/components/sidebar-navigation-screen-patterns/use-template-part-areas.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-patterns/use-theme-patterns.js +1 -1
- package/build-module/components/sidebar-navigation-screen-patterns/use-theme-patterns.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-templates/index.js +1 -8
- package/build-module/components/sidebar-navigation-screen-templates/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-templates-browse/index.js +7 -0
- package/build-module/components/sidebar-navigation-screen-templates-browse/index.js.map +1 -1
- package/build-module/components/site-hub/index.js +28 -13
- package/build-module/components/site-hub/index.js.map +1 -1
- package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js +7 -5
- package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
- package/build-module/components/sync-state-with-url/use-sync-canvas-mode-with-url.js +1 -1
- package/build-module/components/sync-state-with-url/use-sync-canvas-mode-with-url.js.map +1 -1
- package/build-module/components/sync-state-with-url/use-sync-path-with-url.js +16 -12
- package/build-module/components/sync-state-with-url/use-sync-path-with-url.js.map +1 -1
- package/build-module/components/template-actions/index.js +2 -1
- package/build-module/components/template-actions/index.js.map +1 -1
- package/build-module/components/template-actions/rename-menu-item.js +11 -8
- package/build-module/components/template-actions/rename-menu-item.js.map +1 -1
- package/build-module/components/use-edited-entity-record/index.js +3 -1
- package/build-module/components/use-edited-entity-record/index.js.map +1 -1
- package/build-module/hooks/commands/use-common-commands.js +116 -32
- package/build-module/hooks/commands/use-common-commands.js.map +1 -1
- package/build-module/hooks/commands/use-edit-mode-commands.js +65 -9
- package/build-module/hooks/commands/use-edit-mode-commands.js.map +1 -1
- package/build-module/hooks/push-changes-to-global-styles/index.js +139 -57
- package/build-module/hooks/push-changes-to-global-styles/index.js.map +1 -1
- package/build-module/store/private-actions.js +9 -2
- package/build-module/store/private-actions.js.map +1 -1
- package/build-module/utils/normalize-record-key.js +12 -0
- package/build-module/utils/normalize-record-key.js.map +1 -0
- package/build-module/utils/use-activate-theme.js +1 -1
- package/build-module/utils/use-activate-theme.js.map +1 -1
- package/build-module/utils/use-debounced-input.js +5 -7
- package/build-module/utils/use-debounced-input.js.map +1 -1
- package/build-style/style-rtl.css +281 -103
- package/build-style/style.css +281 -103
- package/package.json +39 -40
- package/src/components/add-new-page/index.js +0 -3
- package/src/components/add-new-pattern/index.js +25 -12
- package/src/components/add-new-template/utils.js +9 -6
- package/src/components/block-editor/constants.js +5 -1
- package/src/components/block-editor/editor-canvas.js +1 -1
- package/src/components/block-editor/index.js +0 -4
- package/src/components/block-editor/use-site-editor-settings.js +119 -20
- package/src/components/canvas-spinner/style.scss +14 -0
- package/src/components/code-editor/index.js +51 -33
- package/src/components/create-pattern-modal/index.js +5 -2
- package/src/components/editor/index.js +5 -5
- package/src/components/global-styles/global-styles-provider.js +7 -2
- package/src/components/global-styles/screen-block.js +15 -0
- package/src/components/global-styles/screen-revisions/index.js +64 -58
- package/src/components/global-styles/screen-revisions/revisions-buttons.js +17 -31
- package/src/components/global-styles/screen-revisions/test/use-global-styles-revisions.js +14 -1
- package/src/components/global-styles/screen-revisions/use-global-styles-revisions.js +64 -48
- package/src/components/global-styles/style-variations-container.js +2 -0
- package/src/components/header-edit-mode/document-actions/index.js +8 -4
- package/src/components/header-edit-mode/document-actions/style.scss +45 -28
- package/src/components/header-edit-mode/index.js +29 -22
- package/src/components/keyboard-shortcuts/edit-mode.js +4 -5
- package/src/components/layout/index.js +49 -22
- package/src/components/layout/style.scss +4 -3
- package/src/components/page/index.js +8 -8
- package/src/components/page/style.scss +8 -5
- package/src/components/page-actions/index.js +2 -2
- package/src/components/page-actions/{delete-page-menu-item.js → trash-page-menu-item.js} +9 -22
- package/src/components/page-content-focus-manager/disable-non-page-content-blocks.js +12 -3
- package/src/components/page-patterns/duplicate-menu-item.js +196 -0
- package/src/components/page-patterns/grid-item.js +189 -133
- package/src/components/page-patterns/grid.js +3 -20
- package/src/components/page-patterns/header.js +69 -0
- package/src/components/page-patterns/index.js +6 -1
- package/src/components/page-patterns/pagination.js +80 -0
- package/src/components/page-patterns/patterns-list.js +172 -71
- package/src/components/page-patterns/rename-menu-item.js +115 -0
- package/src/components/page-patterns/style.scss +141 -30
- package/src/components/page-patterns/use-patterns.js +115 -169
- package/src/components/page-template-parts/add-new-template-part.js +57 -0
- package/src/components/page-template-parts/index.js +3 -23
- package/src/components/page-templates/index.js +6 -19
- package/src/components/resizable-frame/index.js +104 -51
- package/src/components/resizable-frame/style.scss +9 -9
- package/src/components/save-button/index.js +2 -0
- package/src/components/save-hub/index.js +6 -1
- package/src/components/save-hub/style.scss +1 -1
- package/src/components/save-panel/index.js +10 -4
- package/src/components/sidebar-edit-mode/page-panels/page-content.js +7 -5
- package/src/components/sidebar-edit-mode/page-panels/page-status.js +2 -5
- package/src/components/sidebar-edit-mode/template-panel/index.js +15 -11
- package/src/components/sidebar-navigation-item/style.scss +5 -12
- package/src/components/sidebar-navigation-screen/index.js +30 -15
- package/src/components/sidebar-navigation-screen/style.scss +18 -0
- package/src/components/sidebar-navigation-screen-details-panel/style.scss +1 -0
- package/src/components/sidebar-navigation-screen-global-styles/index.js +48 -44
- package/src/components/sidebar-navigation-screen-main/index.js +44 -40
- package/src/components/sidebar-navigation-screen-main/template-part-hint.js +34 -0
- package/src/components/sidebar-navigation-screen-navigation-menu/index.js +4 -3
- package/src/components/sidebar-navigation-screen-navigation-menu/more-menu.js +1 -0
- package/src/components/sidebar-navigation-screen-navigation-menu/single-navigation-menu.js +1 -1
- package/src/components/sidebar-navigation-screen-navigation-menu/use-navigation-menu-handlers.js +16 -7
- package/src/components/sidebar-navigation-screen-navigation-menus/constants.js +2 -0
- package/src/components/sidebar-navigation-screen-navigation-menus/index.js +4 -4
- package/src/components/sidebar-navigation-screen-navigation-menus/leaf-more-menu.js +27 -15
- package/src/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js +1 -4
- package/src/components/sidebar-navigation-screen-page/index.js +3 -3
- package/src/components/sidebar-navigation-screen-page/status-label.js +1 -35
- package/src/components/sidebar-navigation-screen-pages/index.js +48 -33
- package/src/components/sidebar-navigation-screen-pattern/index.js +5 -2
- package/src/components/sidebar-navigation-screen-pattern/template-part-navigation-menu.js +3 -2
- package/src/components/sidebar-navigation-screen-pattern/template-part-navigation-menus.js +2 -1
- package/src/components/sidebar-navigation-screen-pattern/use-navigation-menu-content.js +23 -3
- package/src/components/sidebar-navigation-screen-pattern/use-pattern-details.js +74 -43
- package/src/components/sidebar-navigation-screen-patterns/category-item.js +5 -13
- package/src/components/sidebar-navigation-screen-patterns/index.js +103 -106
- package/src/components/sidebar-navigation-screen-patterns/style.scss +20 -0
- package/src/components/sidebar-navigation-screen-patterns/use-my-patterns.js +7 -6
- package/src/components/sidebar-navigation-screen-patterns/use-pattern-categories.js +9 -0
- package/src/components/sidebar-navigation-screen-patterns/use-template-part-areas.js +31 -9
- package/src/components/sidebar-navigation-screen-patterns/use-theme-patterns.js +2 -1
- package/src/components/sidebar-navigation-screen-templates/index.js +1 -9
- package/src/components/sidebar-navigation-screen-templates-browse/index.js +10 -0
- package/src/components/site-hub/index.js +48 -29
- package/src/components/site-hub/style.scss +14 -2
- package/src/components/sync-state-with-url/use-init-edited-entity-from-url.js +8 -2
- package/src/components/sync-state-with-url/use-sync-canvas-mode-with-url.js +1 -4
- package/src/components/sync-state-with-url/use-sync-path-with-url.js +73 -66
- package/src/components/table/style.scss +1 -0
- package/src/components/template-actions/index.js +2 -1
- package/src/components/template-actions/rename-menu-item.js +17 -10
- package/src/components/use-edited-entity-record/index.js +6 -1
- package/src/hooks/commands/use-common-commands.js +105 -32
- package/src/hooks/commands/use-edit-mode-commands.js +94 -23
- package/src/hooks/push-changes-to-global-styles/index.js +141 -50
- package/src/store/private-actions.js +10 -2
- package/src/style.scss +10 -12
- package/src/utils/normalize-record-key.js +11 -0
- package/src/utils/use-activate-theme.js +1 -1
- package/src/utils/use-debounced-input.js +8 -7
- package/build/components/code-editor/code-editor-text-area.js +0 -96
- package/build/components/code-editor/code-editor-text-area.js.map +0 -1
- package/build/components/keyboard-shortcuts/index.js +0 -148
- package/build/components/keyboard-shortcuts/index.js.map +0 -1
- package/build/components/page-actions/delete-page-menu-item.js.map +0 -1
- package/build/components/page-content-focus-manager/constants.js +0 -9
- package/build/components/page-content-focus-manager/constants.js.map +0 -1
- package/build-module/components/code-editor/code-editor-text-area.js +0 -84
- package/build-module/components/code-editor/code-editor-text-area.js.map +0 -1
- package/build-module/components/keyboard-shortcuts/index.js +0 -132
- package/build-module/components/keyboard-shortcuts/index.js.map +0 -1
- package/build-module/components/page-actions/delete-page-menu-item.js.map +0 -1
- package/build-module/components/page-content-focus-manager/constants.js +0 -2
- package/build-module/components/page-content-focus-manager/constants.js.map +0 -1
- package/src/components/code-editor/code-editor-text-area.js +0 -84
- package/src/components/keyboard-shortcuts/index.js +0 -137
- package/src/components/page-content-focus-manager/constants.js +0 -5
|
@@ -16,8 +16,6 @@ var _blockEditor = require("@wordpress/block-editor");
|
|
|
16
16
|
|
|
17
17
|
var _lockUnlock = require("../../lock-unlock");
|
|
18
18
|
|
|
19
|
-
var _constants = require("./constants");
|
|
20
|
-
|
|
21
19
|
/**
|
|
22
20
|
* WordPress dependencies
|
|
23
21
|
*/
|
|
@@ -28,6 +26,7 @@ var _constants = require("./constants");
|
|
|
28
26
|
const {
|
|
29
27
|
useBlockEditingMode
|
|
30
28
|
} = (0, _lockUnlock.unlock)(_blockEditor.privateApis);
|
|
29
|
+
const PAGE_CONTENT_BLOCK_TYPES = ['core/post-title', 'core/post-featured-image', 'core/post-content'];
|
|
31
30
|
/**
|
|
32
31
|
* Component that when rendered, makes it so that the site editor allows only
|
|
33
32
|
* page content to be edited.
|
|
@@ -35,6 +34,7 @@ const {
|
|
|
35
34
|
|
|
36
35
|
function DisableNonPageContentBlocks() {
|
|
37
36
|
useDisableNonPageContentBlocks();
|
|
37
|
+
return null;
|
|
38
38
|
}
|
|
39
39
|
/**
|
|
40
40
|
* Disables non-content blocks using the `useBlockEditingMode` hook.
|
|
@@ -50,9 +50,9 @@ function useDisableNonPageContentBlocks() {
|
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
const withDisableNonPageContentBlocks = (0, _compose.createHigherOrderComponent)(BlockEdit => props => {
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
const mode =
|
|
53
|
+
const isDescendentOfQueryLoop = props.context.queryId !== undefined;
|
|
54
|
+
const isPageContent = PAGE_CONTENT_BLOCK_TYPES.includes(props.name) && !isDescendentOfQueryLoop;
|
|
55
|
+
const mode = isPageContent ? 'contentOnly' : undefined;
|
|
56
56
|
useBlockEditingMode(mode);
|
|
57
57
|
return (0, _element.createElement)(BlockEdit, { ...props
|
|
58
58
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/page-content-focus-manager/disable-non-page-content-blocks.js"],"names":["useBlockEditingMode","blockEditorPrivateApis","DisableNonPageContentBlocks","useDisableNonPageContentBlocks","withDisableNonPageContentBlocks","BlockEdit","props","
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/page-content-focus-manager/disable-non-page-content-blocks.js"],"names":["useBlockEditingMode","blockEditorPrivateApis","PAGE_CONTENT_BLOCK_TYPES","DisableNonPageContentBlocks","useDisableNonPageContentBlocks","withDisableNonPageContentBlocks","BlockEdit","props","isDescendentOfQueryLoop","context","queryId","undefined","isPageContent","includes","name","mode"],"mappings":";;;;;;;;AAMA;;AAHA;;AACA;;AACA;;AAMA;;AAXA;AACA;AACA;;AAMA;AACA;AACA;AAGA,MAAM;AAAEA,EAAAA;AAAF,IAA0B,wBAAQC,wBAAR,CAAhC;AAEA,MAAMC,wBAAwB,GAAG,CAChC,iBADgC,EAEhC,0BAFgC,EAGhC,mBAHgC,CAAjC;AAMA;AACA;AACA;AACA;;AACe,SAASC,2BAAT,GAAuC;AACrDC,EAAAA,8BAA8B;AAC9B,SAAO,IAAP;AACA;AAED;AACA;AACA;;;AACO,SAASA,8BAAT,GAA0C;AAChDJ,EAAAA,mBAAmB,CAAE,UAAF,CAAnB;AACA,0BAAW,MAAM;AAChB,0BACC,kBADD,EAEC,2CAFD,EAGCK,+BAHD;AAKA,WAAO,MACN,yBACC,kBADD,EAEC,2CAFD,CADD;AAKA,GAXD,EAWG,EAXH;AAYA;;AAED,MAAMA,+BAA+B,GAAG,yCACrCC,SAAF,IAAmBC,KAAF,IAAa;AAC7B,QAAMC,uBAAuB,GAAGD,KAAK,CAACE,OAAN,CAAcC,OAAd,KAA0BC,SAA1D;AACA,QAAMC,aAAa,GAClBV,wBAAwB,CAACW,QAAzB,CAAmCN,KAAK,CAACO,IAAzC,KACA,CAAEN,uBAFH;AAGA,QAAMO,IAAI,GAAGH,aAAa,GAAG,aAAH,GAAmBD,SAA7C;AACAX,EAAAA,mBAAmB,CAAEe,IAAF,CAAnB;AACA,SAAO,4BAAC,SAAD,OAAgBR;AAAhB,IAAP;AACA,CATsC,EAUvC,iCAVuC,CAAxC","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createHigherOrderComponent } from '@wordpress/compose';\nimport { addFilter, removeFilter } from '@wordpress/hooks';\nimport { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';\nimport { useEffect } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\n\nconst { useBlockEditingMode } = unlock( blockEditorPrivateApis );\n\nconst PAGE_CONTENT_BLOCK_TYPES = [\n\t'core/post-title',\n\t'core/post-featured-image',\n\t'core/post-content',\n];\n\n/**\n * Component that when rendered, makes it so that the site editor allows only\n * page content to be edited.\n */\nexport default function DisableNonPageContentBlocks() {\n\tuseDisableNonPageContentBlocks();\n\treturn null;\n}\n\n/**\n * Disables non-content blocks using the `useBlockEditingMode` hook.\n */\nexport function useDisableNonPageContentBlocks() {\n\tuseBlockEditingMode( 'disabled' );\n\tuseEffect( () => {\n\t\taddFilter(\n\t\t\t'editor.BlockEdit',\n\t\t\t'core/edit-site/disable-non-content-blocks',\n\t\t\twithDisableNonPageContentBlocks\n\t\t);\n\t\treturn () =>\n\t\t\tremoveFilter(\n\t\t\t\t'editor.BlockEdit',\n\t\t\t\t'core/edit-site/disable-non-content-blocks'\n\t\t\t);\n\t}, [] );\n}\n\nconst withDisableNonPageContentBlocks = createHigherOrderComponent(\n\t( BlockEdit ) => ( props ) => {\n\t\tconst isDescendentOfQueryLoop = props.context.queryId !== undefined;\n\t\tconst isPageContent =\n\t\t\tPAGE_CONTENT_BLOCK_TYPES.includes( props.name ) &&\n\t\t\t! isDescendentOfQueryLoop;\n\t\tconst mode = isPageContent ? 'contentOnly' : undefined;\n\t\tuseBlockEditingMode( mode );\n\t\treturn <BlockEdit { ...props } />;\n\t},\n\t'withDisableNonPageContentBlocks'\n);\n"]}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = DuplicateMenuItem;
|
|
7
|
+
|
|
8
|
+
var _element = require("@wordpress/element");
|
|
9
|
+
|
|
10
|
+
var _components = require("@wordpress/components");
|
|
11
|
+
|
|
12
|
+
var _coreData = require("@wordpress/core-data");
|
|
13
|
+
|
|
14
|
+
var _data = require("@wordpress/data");
|
|
15
|
+
|
|
16
|
+
var _i18n = require("@wordpress/i18n");
|
|
17
|
+
|
|
18
|
+
var _notices = require("@wordpress/notices");
|
|
19
|
+
|
|
20
|
+
var _router = require("@wordpress/router");
|
|
21
|
+
|
|
22
|
+
var _utils = require("./utils");
|
|
23
|
+
|
|
24
|
+
var _templatePartCreate = require("../../utils/template-part-create");
|
|
25
|
+
|
|
26
|
+
var _lockUnlock = require("../../lock-unlock");
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* WordPress dependencies
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Internal dependencies
|
|
34
|
+
*/
|
|
35
|
+
const {
|
|
36
|
+
useHistory
|
|
37
|
+
} = (0, _lockUnlock.unlock)(_router.privateApis);
|
|
38
|
+
|
|
39
|
+
function getPatternMeta(item) {
|
|
40
|
+
if (item.type === _utils.PATTERNS) {
|
|
41
|
+
return {
|
|
42
|
+
wp_pattern_sync_status: _utils.SYNC_TYPES.unsynced
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const syncStatus = item.reusableBlock.wp_pattern_sync_status;
|
|
47
|
+
const isUnsynced = syncStatus === _utils.SYNC_TYPES.unsynced;
|
|
48
|
+
return { ...item.reusableBlock.meta,
|
|
49
|
+
wp_pattern_sync_status: isUnsynced ? syncStatus : undefined
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function DuplicateMenuItem({
|
|
54
|
+
categoryId,
|
|
55
|
+
item,
|
|
56
|
+
label = (0, _i18n.__)('Duplicate'),
|
|
57
|
+
onClose
|
|
58
|
+
}) {
|
|
59
|
+
const {
|
|
60
|
+
saveEntityRecord
|
|
61
|
+
} = (0, _data.useDispatch)(_coreData.store);
|
|
62
|
+
const {
|
|
63
|
+
createErrorNotice,
|
|
64
|
+
createSuccessNotice
|
|
65
|
+
} = (0, _data.useDispatch)(_notices.store);
|
|
66
|
+
const history = useHistory();
|
|
67
|
+
const existingTemplateParts = (0, _templatePartCreate.useExistingTemplateParts)();
|
|
68
|
+
|
|
69
|
+
async function createTemplatePart() {
|
|
70
|
+
try {
|
|
71
|
+
const copiedTitle = (0, _i18n.sprintf)(
|
|
72
|
+
/* translators: %s: Existing template part title */
|
|
73
|
+
(0, _i18n.__)('%s (Copy)'), item.title);
|
|
74
|
+
const title = (0, _templatePartCreate.getUniqueTemplatePartTitle)(copiedTitle, existingTemplateParts);
|
|
75
|
+
const slug = (0, _templatePartCreate.getCleanTemplatePartSlug)(title);
|
|
76
|
+
const {
|
|
77
|
+
area,
|
|
78
|
+
content
|
|
79
|
+
} = item.templatePart;
|
|
80
|
+
const result = await saveEntityRecord('postType', 'wp_template_part', {
|
|
81
|
+
slug,
|
|
82
|
+
title,
|
|
83
|
+
content,
|
|
84
|
+
area
|
|
85
|
+
}, {
|
|
86
|
+
throwOnError: true
|
|
87
|
+
});
|
|
88
|
+
createSuccessNotice((0, _i18n.sprintf)( // translators: %s: The new template part's title e.g. 'Call to action (copy)'.
|
|
89
|
+
(0, _i18n.__)('"%s" created.'), title), {
|
|
90
|
+
type: 'snackbar',
|
|
91
|
+
id: 'edit-site-patterns-success',
|
|
92
|
+
actions: [{
|
|
93
|
+
label: (0, _i18n.__)('Edit'),
|
|
94
|
+
onClick: () => history.push({
|
|
95
|
+
postType: _utils.TEMPLATE_PARTS,
|
|
96
|
+
postId: result?.id,
|
|
97
|
+
categoryType: _utils.TEMPLATE_PARTS,
|
|
98
|
+
categoryId
|
|
99
|
+
})
|
|
100
|
+
}]
|
|
101
|
+
});
|
|
102
|
+
onClose();
|
|
103
|
+
} catch (error) {
|
|
104
|
+
const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : (0, _i18n.__)('An error occurred while creating the template part.');
|
|
105
|
+
createErrorNotice(errorMessage, {
|
|
106
|
+
type: 'snackbar',
|
|
107
|
+
id: 'edit-site-patterns-error'
|
|
108
|
+
});
|
|
109
|
+
onClose();
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
async function createPattern() {
|
|
114
|
+
try {
|
|
115
|
+
const isThemePattern = item.type === _utils.PATTERNS;
|
|
116
|
+
const title = (0, _i18n.sprintf)(
|
|
117
|
+
/* translators: %s: Existing pattern title */
|
|
118
|
+
(0, _i18n.__)('%s (Copy)'), item.title);
|
|
119
|
+
const result = await saveEntityRecord('postType', 'wp_block', {
|
|
120
|
+
content: isThemePattern ? item.content : item.reusableBlock.content,
|
|
121
|
+
meta: getPatternMeta(item),
|
|
122
|
+
status: 'publish',
|
|
123
|
+
title
|
|
124
|
+
}, {
|
|
125
|
+
throwOnError: true
|
|
126
|
+
});
|
|
127
|
+
const actionLabel = isThemePattern ? (0, _i18n.__)('View my patterns') : (0, _i18n.__)('Edit');
|
|
128
|
+
const newLocation = isThemePattern ? {
|
|
129
|
+
categoryType: _utils.USER_PATTERNS,
|
|
130
|
+
categoryId: _utils.USER_PATTERN_CATEGORY,
|
|
131
|
+
path: '/patterns'
|
|
132
|
+
} : {
|
|
133
|
+
categoryType: _utils.USER_PATTERNS,
|
|
134
|
+
categoryId: _utils.USER_PATTERN_CATEGORY,
|
|
135
|
+
postType: _utils.USER_PATTERNS,
|
|
136
|
+
postId: result?.id
|
|
137
|
+
};
|
|
138
|
+
createSuccessNotice((0, _i18n.sprintf)( // translators: %s: The new pattern's title e.g. 'Call to action (copy)'.
|
|
139
|
+
(0, _i18n.__)('"%s" added to my patterns.'), title), {
|
|
140
|
+
type: 'snackbar',
|
|
141
|
+
id: 'edit-site-patterns-success',
|
|
142
|
+
actions: [{
|
|
143
|
+
label: actionLabel,
|
|
144
|
+
onClick: () => history.push(newLocation)
|
|
145
|
+
}]
|
|
146
|
+
});
|
|
147
|
+
onClose();
|
|
148
|
+
} catch (error) {
|
|
149
|
+
const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : (0, _i18n.__)('An error occurred while creating the pattern.');
|
|
150
|
+
createErrorNotice(errorMessage, {
|
|
151
|
+
type: 'snackbar',
|
|
152
|
+
id: 'edit-site-patterns-error'
|
|
153
|
+
});
|
|
154
|
+
onClose();
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
const createItem = item.type === _utils.TEMPLATE_PARTS ? createTemplatePart : createPattern;
|
|
159
|
+
return (0, _element.createElement)(_components.MenuItem, {
|
|
160
|
+
onClick: createItem
|
|
161
|
+
}, label);
|
|
162
|
+
}
|
|
163
|
+
//# sourceMappingURL=duplicate-menu-item.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/page-patterns/duplicate-menu-item.js"],"names":["useHistory","routerPrivateApis","getPatternMeta","item","type","PATTERNS","wp_pattern_sync_status","SYNC_TYPES","unsynced","syncStatus","reusableBlock","isUnsynced","meta","undefined","DuplicateMenuItem","categoryId","label","onClose","saveEntityRecord","coreStore","createErrorNotice","createSuccessNotice","noticesStore","history","existingTemplateParts","createTemplatePart","copiedTitle","title","slug","area","content","templatePart","result","throwOnError","id","actions","onClick","push","postType","TEMPLATE_PARTS","postId","categoryType","error","errorMessage","message","code","createPattern","isThemePattern","status","actionLabel","newLocation","USER_PATTERNS","USER_PATTERN_CATEGORY","path","createItem"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AAOA;;AAKA;;AAzBA;AACA;AACA;;AAQA;AACA;AACA;AAeA,MAAM;AAAEA,EAAAA;AAAF,IAAiB,wBAAQC,mBAAR,CAAvB;;AAEA,SAASC,cAAT,CAAyBC,IAAzB,EAAgC;AAC/B,MAAKA,IAAI,CAACC,IAAL,KAAcC,eAAnB,EAA8B;AAC7B,WAAO;AAAEC,MAAAA,sBAAsB,EAAEC,kBAAWC;AAArC,KAAP;AACA;;AAED,QAAM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AO,4BAAC,oBAAD;AAAU,IAAA,OAAO,EAAGQ;AAApB,KAAmCtC,KAAnC,CAAP;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { MenuItem } from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useDispatch } from '@wordpress/data';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\n\n/**\n * Internal dependencies\n */\nimport {\n\tTEMPLATE_PARTS,\n\tPATTERNS,\n\tSYNC_TYPES,\n\tUSER_PATTERNS,\n\tUSER_PATTERN_CATEGORY,\n} from './utils';\nimport {\n\tuseExistingTemplateParts,\n\tgetUniqueTemplatePartTitle,\n\tgetCleanTemplatePartSlug,\n} from '../../utils/template-part-create';\nimport { unlock } from '../../lock-unlock';\n\nconst { useHistory } = unlock( routerPrivateApis );\n\nfunction getPatternMeta( item ) {\n\tif ( item.type === PATTERNS ) {\n\t\treturn { wp_pattern_sync_status: SYNC_TYPES.unsynced };\n\t}\n\n\tconst syncStatus = item.reusableBlock.wp_pattern_sync_status;\n\tconst isUnsynced = syncStatus === SYNC_TYPES.unsynced;\n\n\treturn {\n\t\t...item.reusableBlock.meta,\n\t\twp_pattern_sync_status: isUnsynced ? syncStatus : undefined,\n\t};\n}\n\nexport default function DuplicateMenuItem( {\n\tcategoryId,\n\titem,\n\tlabel = __( 'Duplicate' ),\n\tonClose,\n} ) {\n\tconst { saveEntityRecord } = useDispatch( coreStore );\n\tconst { createErrorNotice, createSuccessNotice } =\n\t\tuseDispatch( noticesStore );\n\n\tconst history = useHistory();\n\tconst existingTemplateParts = useExistingTemplateParts();\n\n\tasync function createTemplatePart() {\n\t\ttry {\n\t\t\tconst copiedTitle = sprintf(\n\t\t\t\t/* translators: %s: Existing template part title */\n\t\t\t\t__( '%s (Copy)' ),\n\t\t\t\titem.title\n\t\t\t);\n\t\t\tconst title = getUniqueTemplatePartTitle(\n\t\t\t\tcopiedTitle,\n\t\t\t\texistingTemplateParts\n\t\t\t);\n\t\t\tconst slug = getCleanTemplatePartSlug( title );\n\t\t\tconst { area, content } = item.templatePart;\n\n\t\t\tconst result = await saveEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\t'wp_template_part',\n\t\t\t\t{ slug, title, content, area },\n\t\t\t\t{ throwOnError: true }\n\t\t\t);\n\n\t\t\tcreateSuccessNotice(\n\t\t\t\tsprintf(\n\t\t\t\t\t// translators: %s: The new template part's title e.g. 'Call to action (copy)'.\n\t\t\t\t\t__( '\"%s\" created.' ),\n\t\t\t\t\ttitle\n\t\t\t\t),\n\t\t\t\t{\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\tid: 'edit-site-patterns-success',\n\t\t\t\t\tactions: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tlabel: __( 'Edit' ),\n\t\t\t\t\t\t\tonClick: () =>\n\t\t\t\t\t\t\t\thistory.push( {\n\t\t\t\t\t\t\t\t\tpostType: TEMPLATE_PARTS,\n\t\t\t\t\t\t\t\t\tpostId: result?.id,\n\t\t\t\t\t\t\t\t\tcategoryType: TEMPLATE_PARTS,\n\t\t\t\t\t\t\t\t\tcategoryId,\n\t\t\t\t\t\t\t\t} ),\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t}\n\t\t\t);\n\n\t\t\tonClose();\n\t\t} catch ( error ) {\n\t\t\tconst errorMessage =\n\t\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t\t? error.message\n\t\t\t\t\t: __(\n\t\t\t\t\t\t\t'An error occurred while creating the template part.'\n\t\t\t\t\t );\n\n\t\t\tcreateErrorNotice( errorMessage, {\n\t\t\t\ttype: 'snackbar',\n\t\t\t\tid: 'edit-site-patterns-error',\n\t\t\t} );\n\t\t\tonClose();\n\t\t}\n\t}\n\n\tasync function createPattern() {\n\t\ttry {\n\t\t\tconst isThemePattern = item.type === PATTERNS;\n\t\t\tconst title = sprintf(\n\t\t\t\t/* translators: %s: Existing pattern title */\n\t\t\t\t__( '%s (Copy)' ),\n\t\t\t\titem.title\n\t\t\t);\n\n\t\t\tconst result = await saveEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\t'wp_block',\n\t\t\t\t{\n\t\t\t\t\tcontent: isThemePattern\n\t\t\t\t\t\t? item.content\n\t\t\t\t\t\t: item.reusableBlock.content,\n\t\t\t\t\tmeta: getPatternMeta( item ),\n\t\t\t\t\tstatus: 'publish',\n\t\t\t\t\ttitle,\n\t\t\t\t},\n\t\t\t\t{ throwOnError: true }\n\t\t\t);\n\n\t\t\tconst actionLabel = isThemePattern\n\t\t\t\t? __( 'View my patterns' )\n\t\t\t\t: __( 'Edit' );\n\n\t\t\tconst newLocation = isThemePattern\n\t\t\t\t? {\n\t\t\t\t\t\tcategoryType: USER_PATTERNS,\n\t\t\t\t\t\tcategoryId: USER_PATTERN_CATEGORY,\n\t\t\t\t\t\tpath: '/patterns',\n\t\t\t\t }\n\t\t\t\t: {\n\t\t\t\t\t\tcategoryType: USER_PATTERNS,\n\t\t\t\t\t\tcategoryId: USER_PATTERN_CATEGORY,\n\t\t\t\t\t\tpostType: USER_PATTERNS,\n\t\t\t\t\t\tpostId: result?.id,\n\t\t\t\t };\n\n\t\t\tcreateSuccessNotice(\n\t\t\t\tsprintf(\n\t\t\t\t\t// translators: %s: The new pattern's title e.g. 'Call to action (copy)'.\n\t\t\t\t\t__( '\"%s\" added to my patterns.' ),\n\t\t\t\t\ttitle\n\t\t\t\t),\n\t\t\t\t{\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\tid: 'edit-site-patterns-success',\n\t\t\t\t\tactions: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tlabel: actionLabel,\n\t\t\t\t\t\t\tonClick: () => history.push( newLocation ),\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t}\n\t\t\t);\n\n\t\t\tonClose();\n\t\t} catch ( error ) {\n\t\t\tconst errorMessage =\n\t\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t\t? error.message\n\t\t\t\t\t: __( 'An error occurred while creating the pattern.' );\n\n\t\t\tcreateErrorNotice( errorMessage, {\n\t\t\t\ttype: 'snackbar',\n\t\t\t\tid: 'edit-site-patterns-error',\n\t\t\t} );\n\t\t\tonClose();\n\t\t}\n\t}\n\n\tconst createItem =\n\t\titem.type === TEMPLATE_PARTS ? createTemplatePart : createPattern;\n\n\treturn <MenuItem onClick={ createItem }>{ label }</MenuItem>;\n}\n"]}
|
|
@@ -5,7 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.default =
|
|
8
|
+
exports.default = void 0;
|
|
9
9
|
|
|
10
10
|
var _element = require("@wordpress/element");
|
|
11
11
|
|
|
@@ -25,10 +25,14 @@ var _notices = require("@wordpress/notices");
|
|
|
25
25
|
|
|
26
26
|
var _reusableBlocks = require("@wordpress/reusable-blocks");
|
|
27
27
|
|
|
28
|
-
var
|
|
28
|
+
var _renameMenuItem = _interopRequireDefault(require("./rename-menu-item"));
|
|
29
|
+
|
|
30
|
+
var _duplicateMenuItem = _interopRequireDefault(require("./duplicate-menu-item"));
|
|
29
31
|
|
|
30
32
|
var _utils = require("./utils");
|
|
31
33
|
|
|
34
|
+
var _store = require("../../store");
|
|
35
|
+
|
|
32
36
|
var _link = require("../routes/link");
|
|
33
37
|
|
|
34
38
|
/**
|
|
@@ -42,16 +46,22 @@ var _link = require("../routes/link");
|
|
|
42
46
|
/**
|
|
43
47
|
* Internal dependencies
|
|
44
48
|
*/
|
|
45
|
-
const
|
|
49
|
+
const templatePartIcons = {
|
|
50
|
+
header: _icons.header,
|
|
51
|
+
footer: _icons.footer,
|
|
52
|
+
uncategorized: _icons.symbolFilled
|
|
53
|
+
};
|
|
46
54
|
|
|
47
55
|
function GridItem({
|
|
48
56
|
categoryId,
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
item
|
|
57
|
+
item,
|
|
58
|
+
...props
|
|
52
59
|
}) {
|
|
53
60
|
const descriptionId = (0, _element.useId)();
|
|
54
61
|
const [isDeleteDialogOpen, setIsDeleteDialogOpen] = (0, _element.useState)(false);
|
|
62
|
+
const {
|
|
63
|
+
removeTemplate
|
|
64
|
+
} = (0, _data.useDispatch)(_store.store);
|
|
55
65
|
const {
|
|
56
66
|
__experimentalDeleteReusableBlock
|
|
57
67
|
} = (0, _data.useDispatch)(_reusableBlocks.store);
|
|
@@ -59,76 +69,74 @@ function GridItem({
|
|
|
59
69
|
createErrorNotice,
|
|
60
70
|
createSuccessNotice
|
|
61
71
|
} = (0, _data.useDispatch)(_notices.store);
|
|
72
|
+
const isUserPattern = item.type === _utils.USER_PATTERNS;
|
|
73
|
+
const isNonUserPattern = item.type === _utils.PATTERNS;
|
|
74
|
+
const isTemplatePart = item.type === _utils.TEMPLATE_PARTS;
|
|
62
75
|
const {
|
|
63
76
|
onClick
|
|
64
77
|
} = (0, _link.useLink)({
|
|
65
78
|
postType: item.type,
|
|
66
|
-
postId:
|
|
79
|
+
postId: isUserPattern ? item.id : item.name,
|
|
67
80
|
categoryId,
|
|
68
81
|
categoryType: item.type
|
|
69
82
|
});
|
|
70
|
-
|
|
71
|
-
const onKeyDown = event => {
|
|
72
|
-
if (_keycodes.DELETE === event.keyCode || _keycodes.BACKSPACE === event.keyCode) {
|
|
73
|
-
setIsDeleteDialogOpen(true);
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
|
|
77
83
|
const isEmpty = !item.blocks?.length;
|
|
78
84
|
const patternClassNames = (0, _classnames.default)('edit-site-patterns__pattern', {
|
|
79
85
|
'is-placeholder': isEmpty
|
|
80
86
|
});
|
|
81
87
|
const previewClassNames = (0, _classnames.default)('edit-site-patterns__preview', {
|
|
82
|
-
'is-inactive':
|
|
88
|
+
'is-inactive': isNonUserPattern
|
|
83
89
|
});
|
|
84
90
|
|
|
85
91
|
const deletePattern = async () => {
|
|
86
92
|
try {
|
|
87
93
|
await __experimentalDeleteReusableBlock(item.id);
|
|
88
|
-
createSuccessNotice((0, _i18n.
|
|
89
|
-
|
|
94
|
+
createSuccessNotice((0, _i18n.sprintf)( // translators: %s: The pattern's title e.g. 'Call to action'.
|
|
95
|
+
(0, _i18n.__)('"%s" deleted.'), item.title), {
|
|
96
|
+
type: 'snackbar',
|
|
97
|
+
id: 'edit-site-patterns-success'
|
|
90
98
|
});
|
|
91
99
|
} catch (error) {
|
|
92
100
|
const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : (0, _i18n.__)('An error occurred while deleting the pattern.');
|
|
93
101
|
createErrorNotice(errorMessage, {
|
|
94
|
-
type: 'snackbar'
|
|
102
|
+
type: 'snackbar',
|
|
103
|
+
id: 'edit-site-patterns-error'
|
|
95
104
|
});
|
|
96
105
|
}
|
|
97
106
|
};
|
|
98
107
|
|
|
99
|
-
const
|
|
108
|
+
const deleteItem = () => isTemplatePart ? removeTemplate(item) : deletePattern(); // Only custom patterns or custom template parts can be renamed or deleted.
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
const isCustomPattern = isUserPattern || isTemplatePart && item.isCustom;
|
|
112
|
+
const hasThemeFile = isTemplatePart && item.templatePart.has_theme_file;
|
|
100
113
|
const ariaDescriptions = [];
|
|
101
114
|
|
|
102
|
-
if (
|
|
115
|
+
if (isCustomPattern) {
|
|
103
116
|
// User patterns don't have descriptions, but can be edited and deleted, so include some help text.
|
|
104
117
|
ariaDescriptions.push((0, _i18n.__)('Press Enter to edit, or Delete to delete the pattern.'));
|
|
105
118
|
} else if (item.description) {
|
|
106
119
|
ariaDescriptions.push(item.description);
|
|
107
120
|
}
|
|
108
121
|
|
|
109
|
-
if (
|
|
110
|
-
ariaDescriptions.push(
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
let itemIcon = icon;
|
|
114
|
-
|
|
115
|
-
if (categoryId === 'header') {
|
|
116
|
-
itemIcon = _icons.header;
|
|
117
|
-
} else if (categoryId === 'footer') {
|
|
118
|
-
itemIcon = _icons.footer;
|
|
119
|
-
} else if (categoryId === 'uncategorized') {
|
|
120
|
-
itemIcon = _icons.symbolFilled;
|
|
122
|
+
if (isNonUserPattern) {
|
|
123
|
+
ariaDescriptions.push((0, _i18n.__)('Theme & plugin patterns cannot be edited.'));
|
|
121
124
|
}
|
|
122
125
|
|
|
123
|
-
|
|
126
|
+
const itemIcon = templatePartIcons[categoryId] || (item.syncStatus === _utils.SYNC_TYPES.full ? _icons.symbol : undefined);
|
|
127
|
+
const confirmButtonText = hasThemeFile ? (0, _i18n.__)('Clear') : (0, _i18n.__)('Delete');
|
|
128
|
+
const confirmPrompt = hasThemeFile ? (0, _i18n.__)('Are you sure you want to clear these customizations?') : (0, _i18n.sprintf)( // translators: %s: The pattern or template part's title e.g. 'Call to action'.
|
|
129
|
+
(0, _i18n.__)('Are you sure you want to delete "%s"?'), item.title);
|
|
130
|
+
return (0, _element.createElement)("li", {
|
|
124
131
|
className: patternClassNames
|
|
125
|
-
}, (0, _element.createElement)(
|
|
126
|
-
className: previewClassNames,
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
132
|
+
}, (0, _element.createElement)("button", {
|
|
133
|
+
className: previewClassNames // Even though still incomplete, passing ids helps performance.
|
|
134
|
+
// @see https://reakit.io/docs/composite/#performance.
|
|
135
|
+
,
|
|
136
|
+
id: `edit-site-patterns-${item.name}`,
|
|
137
|
+
...props,
|
|
130
138
|
onClick: item.type !== _utils.PATTERNS ? onClick : undefined,
|
|
131
|
-
|
|
139
|
+
"aria-disabled": item.type !== _utils.PATTERNS ? 'false' : 'true',
|
|
132
140
|
"aria-label": item.title,
|
|
133
141
|
"aria-describedby": ariaDescriptions.length ? ariaDescriptions.map((_, index) => `${descriptionId}-${index}`).join(' ') : undefined
|
|
134
142
|
}, isEmpty && (0, _i18n.__)('Empty pattern'), !isEmpty && (0, _element.createElement)(_blockEditor.BlockPreview, {
|
|
@@ -138,7 +146,6 @@ function GridItem({
|
|
|
138
146
|
hidden: true,
|
|
139
147
|
id: `${descriptionId}-${index}`
|
|
140
148
|
}, ariaDescription)), (0, _element.createElement)(_components.__experimentalHStack, {
|
|
141
|
-
"aria-hidden": "true",
|
|
142
149
|
className: "edit-site-patterns__footer",
|
|
143
150
|
justify: "space-between"
|
|
144
151
|
}, (0, _element.createElement)(_components.__experimentalHStack, {
|
|
@@ -146,25 +153,33 @@ function GridItem({
|
|
|
146
153
|
justify: "left",
|
|
147
154
|
spacing: 3,
|
|
148
155
|
className: "edit-site-patterns__pattern-title"
|
|
149
|
-
},
|
|
156
|
+
}, itemIcon && !isNonUserPattern && (0, _element.createElement)(_components.Tooltip, {
|
|
157
|
+
position: "top center",
|
|
158
|
+
text: (0, _i18n.__)('Editing this pattern will also update anywhere it is used')
|
|
159
|
+
}, (0, _element.createElement)("span", null, (0, _element.createElement)(_icons.Icon, {
|
|
150
160
|
className: "edit-site-patterns__pattern-icon",
|
|
151
161
|
icon: itemIcon
|
|
152
|
-
}), (0, _element.createElement)(_components.Flex, {
|
|
162
|
+
}))), (0, _element.createElement)(_components.Flex, {
|
|
153
163
|
as: "span",
|
|
154
164
|
gap: 0,
|
|
155
165
|
justify: "left"
|
|
156
|
-
}, item.
|
|
166
|
+
}, item.type === _utils.PATTERNS ? item.title : (0, _element.createElement)(_components.__experimentalHeading, {
|
|
167
|
+
level: 5
|
|
168
|
+
}, (0, _element.createElement)(_components.Button, {
|
|
169
|
+
variant: "link",
|
|
170
|
+
onClick: onClick // Required for the grid's roving tab index system.
|
|
171
|
+
// See https://github.com/WordPress/gutenberg/pull/51898#discussion_r1243399243.
|
|
172
|
+
,
|
|
173
|
+
tabIndex: "-1"
|
|
174
|
+
}, item.title)), item.type === _utils.PATTERNS && (0, _element.createElement)(_components.Tooltip, {
|
|
157
175
|
position: "top center",
|
|
158
|
-
text: (0, _i18n.__)('
|
|
176
|
+
text: (0, _i18n.__)('This pattern cannot be edited.')
|
|
159
177
|
}, (0, _element.createElement)("span", {
|
|
160
178
|
className: "edit-site-patterns__pattern-lock-icon"
|
|
161
179
|
}, (0, _element.createElement)(_icons.Icon, {
|
|
162
|
-
style: {
|
|
163
|
-
fill: 'currentcolor'
|
|
164
|
-
},
|
|
165
180
|
icon: _icons.lockSmall,
|
|
166
181
|
size: 24
|
|
167
|
-
}))))),
|
|
182
|
+
}))))), (0, _element.createElement)(_components.DropdownMenu, {
|
|
168
183
|
icon: _icons.moreHorizontal,
|
|
169
184
|
label: (0, _i18n.__)('Actions'),
|
|
170
185
|
className: "edit-site-patterns__dropdown",
|
|
@@ -176,18 +191,28 @@ function GridItem({
|
|
|
176
191
|
isSmall: true,
|
|
177
192
|
describedBy: (0, _i18n.sprintf)(
|
|
178
193
|
/* translators: %s: pattern name */
|
|
179
|
-
(0, _i18n.__)('Action menu for %s pattern'), item.title)
|
|
180
|
-
// The dropdown menu is not focusable using the
|
|
181
|
-
// keyboard as this would interfere with the grid's
|
|
182
|
-
// roving tab index system. Instead, keyboard users
|
|
183
|
-
// use keyboard shortcuts to trigger actions.
|
|
184
|
-
tabIndex: -1
|
|
194
|
+
(0, _i18n.__)('Action menu for %s pattern'), item.title)
|
|
185
195
|
}
|
|
186
|
-
}, (
|
|
196
|
+
}, ({
|
|
197
|
+
onClose
|
|
198
|
+
}) => (0, _element.createElement)(_components.MenuGroup, null, isCustomPattern && !hasThemeFile && (0, _element.createElement)(_renameMenuItem.default, {
|
|
199
|
+
item: item,
|
|
200
|
+
onClose: onClose
|
|
201
|
+
}), (0, _element.createElement)(_duplicateMenuItem.default, {
|
|
202
|
+
categoryId: categoryId,
|
|
203
|
+
item: item,
|
|
204
|
+
onClose: onClose,
|
|
205
|
+
label: isNonUserPattern ? (0, _i18n.__)('Copy to My patterns') : (0, _i18n.__)('Duplicate')
|
|
206
|
+
}), isCustomPattern && (0, _element.createElement)(_components.MenuItem, {
|
|
187
207
|
onClick: () => setIsDeleteDialogOpen(true)
|
|
188
|
-
}, (0, _i18n.__)('Delete')))))
|
|
189
|
-
|
|
208
|
+
}, hasThemeFile ? (0, _i18n.__)('Clear customizations') : (0, _i18n.__)('Delete'))))), isDeleteDialogOpen && (0, _element.createElement)(_components.__experimentalConfirmDialog, {
|
|
209
|
+
confirmButtonText: confirmButtonText,
|
|
210
|
+
onConfirm: deleteItem,
|
|
190
211
|
onCancel: () => setIsDeleteDialogOpen(false)
|
|
191
|
-
},
|
|
212
|
+
}, confirmPrompt));
|
|
192
213
|
}
|
|
214
|
+
|
|
215
|
+
var _default = (0, _element.memo)(GridItem);
|
|
216
|
+
|
|
217
|
+
exports.default = _default;
|
|
193
218
|
//# sourceMappingURL=grid-item.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/page-patterns/grid-item.js"],"names":["THEME_PATTERN_TOOLTIP","GridItem","categoryId","composite","icon","item","descriptionId","isDeleteDialogOpen","setIsDeleteDialogOpen","__experimentalDeleteReusableBlock","reusableBlocksStore","createErrorNotice","createSuccessNotice","noticesStore","onClick","postType","type","postId","USER_PATTERNS","id","name","categoryType","onKeyDown","event","DELETE","keyCode","BACKSPACE","isEmpty","blocks","length","patternClassNames","previewClassNames","PATTERNS","deletePattern","error","errorMessage","message","code","isUserPattern","ariaDescriptions","push","description","itemIcon","header","footer","symbolFilled","undefined","title","map","_","index","join","ariaDescription","fill","lockSmall","moreHorizontal","placement","className","isSmall","describedBy","tabIndex"],"mappings":";;;;;;;;;AAoBA;;AAjBA;;AAKA;;AACA;;AAUA;;AAEA;;AACA;;AAQA;;AACA;;AACA;;AAKA;;AACA;;AAtCA;AACA;AACA;;AAGA;AACA;AACA;;AA2BA;AACA;AACA;AAIA,MAAMA,qBAAqB,GAAG,cAAI,kCAAJ,CAA9B;;AAEe,SAASC,QAAT,CAAmB;AAAEC,EAAAA,UAAF;AAAcC,EAAAA,SAAd;AAAyBC,EAAAA,IAAzB;AAA+BC,EAAAA;AAA/B,CAAnB,EAA2D;AACzE,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MC;AAAM,IAAA,SAAS,EAAC;AAAhB,KACC,4BAAC,WAAD;AACC,IAAA,KAAK,EAAG;AAAEqB,MAAAA,IAAI,EAAE;AAAR,KADT;AAEC,IAAA,IAAI,EAAGC,gBAFR;AAGC,IAAA,IAAI,EAAG;AAHR,IADD,CAND,CAHF,CAZD,CALD,EAqCGjD,IAAI,CAACW,IAAL,KAAcE,oBAAd,IACD,4BAAC,wBAAD;AACC,IAAA,IAAI,EAAGqC,qBADR;AAEC,IAAA,KAAK,EAAG,cAAI,SAAJ,CAFT;AAGC,IAAA,SAAS,EAAC,8BAHX;AAIC,IAAA,YAAY,EAAG;AAAEC,MAAAA,SAAS,EAAE;AAAb,KAJhB;AAKC,IAAA,WAAW,EAAG;AACbC,MAAAA,SAAS,EAAE,4BADE;AAEbC,MAAAA,OAAO,EAAE,IAFI;AAGbC,MAAAA,WAAW,EAAE;AACZ;AACA,oBAAI,4BAAJ,CAFY,EAGZtD,IAAI,CAAC0C,KAHO,CAHA;AAQb;AACA;AACA;AACA;AACAa,MAAAA,QAAQ,EAAE,CAAC;AAZE;AALf,KAoBG,MACD,4BAAC,qBAAD,QACC,4BAAC,oBAAD;AACC,IAAA,OAAO,EAAG,MACTpD,qBAAqB,CAAE,IAAF;AAFvB,KAKG,cAAI,QAAJ,CALH,CADD,CArBF,CAtCF,CAhCD,CADD,EA0GGD,kBAAkB,IACnB,4BAAC,uCAAD;AACC,IAAA,SAAS,EAAG0B,aADb;AAEC,IAAA,QAAQ,EAAG,MAAMzB,qBAAqB,CAAE,KAAF;AAFvC,KAIG,cAAI,+CAAJ,CAJH,CA3GF,CADD;AAqHA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { BlockPreview } from '@wordpress/block-editor';\nimport {\n\t__experimentalConfirmDialog as ConfirmDialog,\n\tDropdownMenu,\n\tMenuGroup,\n\tMenuItem,\n\t__experimentalHStack as HStack,\n\t__unstableCompositeItem as CompositeItem,\n\tTooltip,\n\tFlex,\n} from '@wordpress/components';\nimport { useDispatch } from '@wordpress/data';\nimport { useState, useId } from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\tIcon,\n\theader,\n\tfooter,\n\tsymbolFilled,\n\tmoreHorizontal,\n\tlockSmall,\n} from '@wordpress/icons';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { store as reusableBlocksStore } from '@wordpress/reusable-blocks';\nimport { DELETE, BACKSPACE } from '@wordpress/keycodes';\n\n/**\n * Internal dependencies\n */\nimport { PATTERNS, USER_PATTERNS } from './utils';\nimport { useLink } from '../routes/link';\n\nconst THEME_PATTERN_TOOLTIP = __( 'Theme patterns cannot be edited.' );\n\nexport default function GridItem( { categoryId, composite, icon, item } ) {\n\tconst descriptionId = useId();\n\tconst [ isDeleteDialogOpen, setIsDeleteDialogOpen ] = useState( false );\n\n\tconst { __experimentalDeleteReusableBlock } =\n\t\tuseDispatch( reusableBlocksStore );\n\tconst { createErrorNotice, createSuccessNotice } =\n\t\tuseDispatch( noticesStore );\n\n\tconst { onClick } = useLink( {\n\t\tpostType: item.type,\n\t\tpostId: item.type === USER_PATTERNS ? item.id : item.name,\n\t\tcategoryId,\n\t\tcategoryType: item.type,\n\t} );\n\n\tconst onKeyDown = ( event ) => {\n\t\tif ( DELETE === event.keyCode || BACKSPACE === event.keyCode ) {\n\t\t\tsetIsDeleteDialogOpen( true );\n\t\t}\n\t};\n\n\tconst isEmpty = ! item.blocks?.length;\n\tconst patternClassNames = classnames( 'edit-site-patterns__pattern', {\n\t\t'is-placeholder': isEmpty,\n\t} );\n\tconst previewClassNames = classnames( 'edit-site-patterns__preview', {\n\t\t'is-inactive': item.type === PATTERNS,\n\t} );\n\n\tconst deletePattern = async () => {\n\t\ttry {\n\t\t\tawait __experimentalDeleteReusableBlock( item.id );\n\t\t\tcreateSuccessNotice( __( 'Pattern successfully deleted.' ), {\n\t\t\t\ttype: 'snackbar',\n\t\t\t} );\n\t\t} catch ( error ) {\n\t\t\tconst errorMessage =\n\t\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t\t? error.message\n\t\t\t\t\t: __( 'An error occurred while deleting the pattern.' );\n\t\t\tcreateErrorNotice( errorMessage, { type: 'snackbar' } );\n\t\t}\n\t};\n\n\tconst isUserPattern = item.type === USER_PATTERNS;\n\tconst ariaDescriptions = [];\n\tif ( isUserPattern ) {\n\t\t// User patterns don't have descriptions, but can be edited and deleted, so include some help text.\n\t\tariaDescriptions.push(\n\t\t\t__( 'Press Enter to edit, or Delete to delete the pattern.' )\n\t\t);\n\t} else if ( item.description ) {\n\t\tariaDescriptions.push( item.description );\n\t}\n\tif ( item.type === PATTERNS ) {\n\t\tariaDescriptions.push( THEME_PATTERN_TOOLTIP );\n\t}\n\n\tlet itemIcon = icon;\n\tif ( categoryId === 'header' ) {\n\t\titemIcon = header;\n\t} else if ( categoryId === 'footer' ) {\n\t\titemIcon = footer;\n\t} else if ( categoryId === 'uncategorized' ) {\n\t\titemIcon = symbolFilled;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<div className={ patternClassNames }>\n\t\t\t\t<CompositeItem\n\t\t\t\t\tclassName={ previewClassNames }\n\t\t\t\t\trole=\"option\"\n\t\t\t\t\tas=\"div\"\n\t\t\t\t\t{ ...composite }\n\t\t\t\t\tonClick={ item.type !== PATTERNS ? onClick : undefined }\n\t\t\t\t\tonKeyDown={ isUserPattern ? onKeyDown : undefined }\n\t\t\t\t\taria-label={ item.title }\n\t\t\t\t\taria-describedby={\n\t\t\t\t\t\tariaDescriptions.length\n\t\t\t\t\t\t\t? ariaDescriptions\n\t\t\t\t\t\t\t\t\t.map(\n\t\t\t\t\t\t\t\t\t\t( _, index ) =>\n\t\t\t\t\t\t\t\t\t\t\t`${ descriptionId }-${ index }`\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t.join( ' ' )\n\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t\t\t{ isEmpty && __( 'Empty pattern' ) }\n\t\t\t\t\t{ ! isEmpty && <BlockPreview blocks={ item.blocks } /> }\n\t\t\t\t</CompositeItem>\n\t\t\t\t{ ariaDescriptions.map( ( ariaDescription, index ) => (\n\t\t\t\t\t<div\n\t\t\t\t\t\tkey={ index }\n\t\t\t\t\t\thidden\n\t\t\t\t\t\tid={ `${ descriptionId }-${ index }` }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ ariaDescription }\n\t\t\t\t\t</div>\n\t\t\t\t) ) }\n\t\t\t\t<HStack\n\t\t\t\t\taria-hidden=\"true\"\n\t\t\t\t\tclassName=\"edit-site-patterns__footer\"\n\t\t\t\t\tjustify=\"space-between\"\n\t\t\t\t>\n\t\t\t\t\t<HStack\n\t\t\t\t\t\talignment=\"center\"\n\t\t\t\t\t\tjustify=\"left\"\n\t\t\t\t\t\tspacing={ 3 }\n\t\t\t\t\t\tclassName=\"edit-site-patterns__pattern-title\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ icon && (\n\t\t\t\t\t\t\t<Icon\n\t\t\t\t\t\t\t\tclassName=\"edit-site-patterns__pattern-icon\"\n\t\t\t\t\t\t\t\ticon={ itemIcon }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t<Flex as=\"span\" gap={ 0 } justify=\"left\">\n\t\t\t\t\t\t\t{ item.title }\n\t\t\t\t\t\t\t{ item.type === PATTERNS && (\n\t\t\t\t\t\t\t\t<Tooltip\n\t\t\t\t\t\t\t\t\tposition=\"top center\"\n\t\t\t\t\t\t\t\t\ttext={ __(\n\t\t\t\t\t\t\t\t\t\t'Theme patterns cannot be edited.'\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<span className=\"edit-site-patterns__pattern-lock-icon\">\n\t\t\t\t\t\t\t\t\t\t<Icon\n\t\t\t\t\t\t\t\t\t\t\tstyle={ { fill: 'currentcolor' } }\n\t\t\t\t\t\t\t\t\t\t\ticon={ lockSmall }\n\t\t\t\t\t\t\t\t\t\t\tsize={ 24 }\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t</Tooltip>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</Flex>\n\t\t\t\t\t</HStack>\n\t\t\t\t\t{ item.type === USER_PATTERNS && (\n\t\t\t\t\t\t<DropdownMenu\n\t\t\t\t\t\t\ticon={ moreHorizontal }\n\t\t\t\t\t\t\tlabel={ __( 'Actions' ) }\n\t\t\t\t\t\t\tclassName=\"edit-site-patterns__dropdown\"\n\t\t\t\t\t\t\tpopoverProps={ { placement: 'bottom-end' } }\n\t\t\t\t\t\t\ttoggleProps={ {\n\t\t\t\t\t\t\t\tclassName: 'edit-site-patterns__button',\n\t\t\t\t\t\t\t\tisSmall: true,\n\t\t\t\t\t\t\t\tdescribedBy: sprintf(\n\t\t\t\t\t\t\t\t\t/* translators: %s: pattern name */\n\t\t\t\t\t\t\t\t\t__( 'Action menu for %s pattern' ),\n\t\t\t\t\t\t\t\t\titem.title\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t// The dropdown menu is not focusable using the\n\t\t\t\t\t\t\t\t// keyboard as this would interfere with the grid's\n\t\t\t\t\t\t\t\t// roving tab index system. Instead, keyboard users\n\t\t\t\t\t\t\t\t// use keyboard shortcuts to trigger actions.\n\t\t\t\t\t\t\t\ttabIndex: -1,\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ () => (\n\t\t\t\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\t\t\t\t\t\tsetIsDeleteDialogOpen( true )\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\t\t{ __( 'Delete' ) }\n\t\t\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</DropdownMenu>\n\t\t\t\t\t) }\n\t\t\t\t</HStack>\n\t\t\t</div>\n\t\t\t{ isDeleteDialogOpen && (\n\t\t\t\t<ConfirmDialog\n\t\t\t\t\tonConfirm={ deletePattern }\n\t\t\t\t\tonCancel={ () => setIsDeleteDialogOpen( false ) }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Are you sure you want to delete this pattern?' ) }\n\t\t\t\t</ConfirmDialog>\n\t\t\t) }\n\t\t</>\n\t);\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/page-patterns/grid-item.js"],"names":["templatePartIcons","header","footer","uncategorized","GridItem","categoryId","item","props","descriptionId","isDeleteDialogOpen","setIsDeleteDialogOpen","removeTemplate","editSiteStore","__experimentalDeleteReusableBlock","reusableBlocksStore","createErrorNotice","createSuccessNotice","noticesStore","isUserPattern","type","USER_PATTERNS","isNonUserPattern","PATTERNS","isTemplatePart","TEMPLATE_PARTS","onClick","postType","postId","id","name","categoryType","isEmpty","blocks","length","patternClassNames","previewClassNames","deletePattern","title","error","errorMessage","message","code","deleteItem","isCustomPattern","isCustom","hasThemeFile","templatePart","has_theme_file","ariaDescriptions","push","description","itemIcon","syncStatus","SYNC_TYPES","full","symbol","undefined","confirmButtonText","confirmPrompt","map","_","index","join","ariaDescription","lockSmall","moreHorizontal","placement","className","isSmall","describedBy","onClose"],"mappings":";;;;;;;;;AAqBA;;AAlBA;;AAKA;;AACA;;AAWA;;AAEA;;AACA;;AASA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AA1CA;AACA;AACA;;AAGA;AACA;AACA;;AA4BA;AACA;AACA;AAOA,MAAMA,iBAAiB,GAAG;AAAEC,EAAAA,MAAM,EAANA,aAAF;AAAUC,EAAAA,MAAM,EAANA,aAAV;AAAkBC,EAAAA,aAAa,EAAbA;AAAl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EAAG;AACbC,MAAAA,SAAS,EAAE,4BADE;AAEbC,MAAAA,OAAO,EAAE,IAFI;AAGbC,MAAAA,WAAW,EAAE;AACZ;AACA,oBAAI,4BAAJ,CAFY,EAGZ/D,IAAI,CAAC+B,KAHO;AAHA;AALf,KAeG,CAAE;AAAEiC,IAAAA;AAAF,GAAF,KACD,4BAAC,qBAAD,QACG3B,eAAe,IAAI,CAAEE,YAArB,IACD,4BAAC,uBAAD;AACC,IAAA,IAAI,EAAGvC,IADR;AAEC,IAAA,OAAO,EAAGgE;AAFX,IAFF,EAOC,4BAAC,0BAAD;AACC,IAAA,UAAU,EAAGjE,UADd;AAEC,IAAA,IAAI,EAAGC,IAFR;AAGC,IAAA,OAAO,EAAGgE,OAHX;AAIC,IAAA,KAAK,EACJjD,gBAAgB,GACb,cAAI,qBAAJ,CADa,GAEb,cAAI,WAAJ;AAPL,IAPD,EAiBGsB,eAAe,IAChB,4BAAC,oBAAD;AACC,IAAA,OAAO,EAAG,MACTjC,qBAAqB,CAAE,IAAF;AAFvB,KAKGmC,YAAY,GACX,cAAI,sBAAJ,CADW,GAEX,cAAI,QAAJ,CAPJ,CAlBF,CAhBF,CArDD,CAjCD,EAuIGpC,kBAAkB,IACnB,4BAAC,uCAAD;AACC,IAAA,iBAAiB,EAAGgD,iBADrB;AAEC,IAAA,SAAS,EAAGf,UAFb;AAGC,IAAA,QAAQ,EAAG,MAAMhC,qBAAqB,CAAE,KAAF;AAHvC,KAKGgD,aALH,CAxIF,CADD;AAmJA;;eAEc,mBAAMtD,QAAN,C","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { BlockPreview } from '@wordpress/block-editor';\nimport {\n\tButton,\n\t__experimentalConfirmDialog as ConfirmDialog,\n\tDropdownMenu,\n\tMenuGroup,\n\tMenuItem,\n\t__experimentalHeading as Heading,\n\t__experimentalHStack as HStack,\n\tTooltip,\n\tFlex,\n} from '@wordpress/components';\nimport { useDispatch } from '@wordpress/data';\nimport { useState, useId, memo } from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\tIcon,\n\theader,\n\tfooter,\n\tsymbolFilled as uncategorized,\n\tsymbol,\n\tmoreHorizontal,\n\tlockSmall,\n} from '@wordpress/icons';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { store as reusableBlocksStore } from '@wordpress/reusable-blocks';\n\n/**\n * Internal dependencies\n */\nimport RenameMenuItem from './rename-menu-item';\nimport DuplicateMenuItem from './duplicate-menu-item';\nimport { PATTERNS, TEMPLATE_PARTS, USER_PATTERNS, SYNC_TYPES } from './utils';\nimport { store as editSiteStore } from '../../store';\nimport { useLink } from '../routes/link';\n\nconst templatePartIcons = { header, footer, uncategorized };\n\nfunction GridItem( { categoryId, item, ...props } ) {\n\tconst descriptionId = useId();\n\tconst [ isDeleteDialogOpen, setIsDeleteDialogOpen ] = useState( false );\n\n\tconst { removeTemplate } = useDispatch( editSiteStore );\n\tconst { __experimentalDeleteReusableBlock } =\n\t\tuseDispatch( reusableBlocksStore );\n\tconst { createErrorNotice, createSuccessNotice } =\n\t\tuseDispatch( noticesStore );\n\n\tconst isUserPattern = item.type === USER_PATTERNS;\n\tconst isNonUserPattern = item.type === PATTERNS;\n\tconst isTemplatePart = item.type === TEMPLATE_PARTS;\n\n\tconst { onClick } = useLink( {\n\t\tpostType: item.type,\n\t\tpostId: isUserPattern ? item.id : item.name,\n\t\tcategoryId,\n\t\tcategoryType: item.type,\n\t} );\n\n\tconst isEmpty = ! item.blocks?.length;\n\tconst patternClassNames = classnames( 'edit-site-patterns__pattern', {\n\t\t'is-placeholder': isEmpty,\n\t} );\n\tconst previewClassNames = classnames( 'edit-site-patterns__preview', {\n\t\t'is-inactive': isNonUserPattern,\n\t} );\n\n\tconst deletePattern = async () => {\n\t\ttry {\n\t\t\tawait __experimentalDeleteReusableBlock( item.id );\n\t\t\tcreateSuccessNotice(\n\t\t\t\tsprintf(\n\t\t\t\t\t// translators: %s: The pattern's title e.g. 'Call to action'.\n\t\t\t\t\t__( '\"%s\" deleted.' ),\n\t\t\t\t\titem.title\n\t\t\t\t),\n\t\t\t\t{ type: 'snackbar', id: 'edit-site-patterns-success' }\n\t\t\t);\n\t\t} catch ( error ) {\n\t\t\tconst errorMessage =\n\t\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t\t? error.message\n\t\t\t\t\t: __( 'An error occurred while deleting the pattern.' );\n\t\t\tcreateErrorNotice( errorMessage, {\n\t\t\t\ttype: 'snackbar',\n\t\t\t\tid: 'edit-site-patterns-error',\n\t\t\t} );\n\t\t}\n\t};\n\tconst deleteItem = () =>\n\t\tisTemplatePart ? removeTemplate( item ) : deletePattern();\n\n\t// Only custom patterns or custom template parts can be renamed or deleted.\n\tconst isCustomPattern =\n\t\tisUserPattern || ( isTemplatePart && item.isCustom );\n\tconst hasThemeFile = isTemplatePart && item.templatePart.has_theme_file;\n\tconst ariaDescriptions = [];\n\n\tif ( isCustomPattern ) {\n\t\t// User patterns don't have descriptions, but can be edited and deleted, so include some help text.\n\t\tariaDescriptions.push(\n\t\t\t__( 'Press Enter to edit, or Delete to delete the pattern.' )\n\t\t);\n\t} else if ( item.description ) {\n\t\tariaDescriptions.push( item.description );\n\t}\n\n\tif ( isNonUserPattern ) {\n\t\tariaDescriptions.push(\n\t\t\t__( 'Theme & plugin patterns cannot be edited.' )\n\t\t);\n\t}\n\n\tconst itemIcon =\n\t\ttemplatePartIcons[ categoryId ] ||\n\t\t( item.syncStatus === SYNC_TYPES.full ? symbol : undefined );\n\n\tconst confirmButtonText = hasThemeFile ? __( 'Clear' ) : __( 'Delete' );\n\tconst confirmPrompt = hasThemeFile\n\t\t? __( 'Are you sure you want to clear these customizations?' )\n\t\t: sprintf(\n\t\t\t\t// translators: %s: The pattern or template part's title e.g. 'Call to action'.\n\t\t\t\t__( 'Are you sure you want to delete \"%s\"?' ),\n\t\t\t\titem.title\n\t\t );\n\n\treturn (\n\t\t<li className={ patternClassNames }>\n\t\t\t<button\n\t\t\t\tclassName={ previewClassNames }\n\t\t\t\t// Even though still incomplete, passing ids helps performance.\n\t\t\t\t// @see https://reakit.io/docs/composite/#performance.\n\t\t\t\tid={ `edit-site-patterns-${ item.name }` }\n\t\t\t\t{ ...props }\n\t\t\t\tonClick={ item.type !== PATTERNS ? onClick : undefined }\n\t\t\t\taria-disabled={ item.type !== PATTERNS ? 'false' : 'true' }\n\t\t\t\taria-label={ item.title }\n\t\t\t\taria-describedby={\n\t\t\t\t\tariaDescriptions.length\n\t\t\t\t\t\t? ariaDescriptions\n\t\t\t\t\t\t\t\t.map(\n\t\t\t\t\t\t\t\t\t( _, index ) =>\n\t\t\t\t\t\t\t\t\t\t`${ descriptionId }-${ index }`\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t.join( ' ' )\n\t\t\t\t\t\t: undefined\n\t\t\t\t}\n\t\t\t>\n\t\t\t\t{ isEmpty && __( 'Empty pattern' ) }\n\t\t\t\t{ ! isEmpty && <BlockPreview blocks={ item.blocks } /> }\n\t\t\t</button>\n\t\t\t{ ariaDescriptions.map( ( ariaDescription, index ) => (\n\t\t\t\t<div\n\t\t\t\t\tkey={ index }\n\t\t\t\t\thidden\n\t\t\t\t\tid={ `${ descriptionId }-${ index }` }\n\t\t\t\t>\n\t\t\t\t\t{ ariaDescription }\n\t\t\t\t</div>\n\t\t\t) ) }\n\t\t\t<HStack\n\t\t\t\tclassName=\"edit-site-patterns__footer\"\n\t\t\t\tjustify=\"space-between\"\n\t\t\t>\n\t\t\t\t<HStack\n\t\t\t\t\talignment=\"center\"\n\t\t\t\t\tjustify=\"left\"\n\t\t\t\t\tspacing={ 3 }\n\t\t\t\t\tclassName=\"edit-site-patterns__pattern-title\"\n\t\t\t\t>\n\t\t\t\t\t{ itemIcon && ! isNonUserPattern && (\n\t\t\t\t\t\t<Tooltip\n\t\t\t\t\t\t\tposition=\"top center\"\n\t\t\t\t\t\t\ttext={ __(\n\t\t\t\t\t\t\t\t'Editing this pattern will also update anywhere it is used'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<span>\n\t\t\t\t\t\t\t\t<Icon\n\t\t\t\t\t\t\t\t\tclassName=\"edit-site-patterns__pattern-icon\"\n\t\t\t\t\t\t\t\t\ticon={ itemIcon }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t</Tooltip>\n\t\t\t\t\t) }\n\t\t\t\t\t<Flex as=\"span\" gap={ 0 } justify=\"left\">\n\t\t\t\t\t\t{ item.type === PATTERNS ? (\n\t\t\t\t\t\t\titem.title\n\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t<Heading level={ 5 }>\n\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\tvariant=\"link\"\n\t\t\t\t\t\t\t\t\tonClick={ onClick }\n\t\t\t\t\t\t\t\t\t// Required for the grid's roving tab index system.\n\t\t\t\t\t\t\t\t\t// See https://github.com/WordPress/gutenberg/pull/51898#discussion_r1243399243.\n\t\t\t\t\t\t\t\t\ttabIndex=\"-1\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ item.title }\n\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t</Heading>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ item.type === PATTERNS && (\n\t\t\t\t\t\t\t<Tooltip\n\t\t\t\t\t\t\t\tposition=\"top center\"\n\t\t\t\t\t\t\t\ttext={ __( 'This pattern cannot be edited.' ) }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<span className=\"edit-site-patterns__pattern-lock-icon\">\n\t\t\t\t\t\t\t\t\t<Icon icon={ lockSmall } size={ 24 } />\n\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t</Tooltip>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</Flex>\n\t\t\t\t</HStack>\n\t\t\t\t<DropdownMenu\n\t\t\t\t\ticon={ moreHorizontal }\n\t\t\t\t\tlabel={ __( 'Actions' ) }\n\t\t\t\t\tclassName=\"edit-site-patterns__dropdown\"\n\t\t\t\t\tpopoverProps={ { placement: 'bottom-end' } }\n\t\t\t\t\ttoggleProps={ {\n\t\t\t\t\t\tclassName: 'edit-site-patterns__button',\n\t\t\t\t\t\tisSmall: true,\n\t\t\t\t\t\tdescribedBy: sprintf(\n\t\t\t\t\t\t\t/* translators: %s: pattern name */\n\t\t\t\t\t\t\t__( 'Action menu for %s pattern' ),\n\t\t\t\t\t\t\titem.title\n\t\t\t\t\t\t),\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t{ ( { onClose } ) => (\n\t\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t\t{ isCustomPattern && ! hasThemeFile && (\n\t\t\t\t\t\t\t\t<RenameMenuItem\n\t\t\t\t\t\t\t\t\titem={ item }\n\t\t\t\t\t\t\t\t\tonClose={ onClose }\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<DuplicateMenuItem\n\t\t\t\t\t\t\t\tcategoryId={ categoryId }\n\t\t\t\t\t\t\t\titem={ item }\n\t\t\t\t\t\t\t\tonClose={ onClose }\n\t\t\t\t\t\t\t\tlabel={\n\t\t\t\t\t\t\t\t\tisNonUserPattern\n\t\t\t\t\t\t\t\t\t\t? __( 'Copy to My patterns' )\n\t\t\t\t\t\t\t\t\t\t: __( 'Duplicate' )\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{ isCustomPattern && (\n\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\t\t\t\t\tsetIsDeleteDialogOpen( true )\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ hasThemeFile\n\t\t\t\t\t\t\t\t\t\t? __( 'Clear customizations' )\n\t\t\t\t\t\t\t\t\t\t: __( 'Delete' ) }\n\t\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t) }\n\t\t\t\t</DropdownMenu>\n\t\t\t</HStack>\n\n\t\t\t{ isDeleteDialogOpen && (\n\t\t\t\t<ConfirmDialog\n\t\t\t\t\tconfirmButtonText={ confirmButtonText }\n\t\t\t\t\tonConfirm={ deleteItem }\n\t\t\t\t\tonCancel={ () => setIsDeleteDialogOpen( false ) }\n\t\t\t\t>\n\t\t\t\t\t{ confirmPrompt }\n\t\t\t\t</ConfirmDialog>\n\t\t\t) }\n\t\t</li>\n\t);\n}\n\nexport default memo( GridItem );\n"]}
|
|
@@ -9,41 +9,28 @@ exports.default = Grid;
|
|
|
9
9
|
|
|
10
10
|
var _element = require("@wordpress/element");
|
|
11
11
|
|
|
12
|
-
var _components = require("@wordpress/components");
|
|
13
|
-
|
|
14
12
|
var _gridItem = _interopRequireDefault(require("./grid-item"));
|
|
15
13
|
|
|
16
|
-
/**
|
|
17
|
-
* WordPress dependencies
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
14
|
/**
|
|
21
15
|
* Internal dependencies
|
|
22
16
|
*/
|
|
23
17
|
function Grid({
|
|
24
18
|
categoryId,
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
items
|
|
19
|
+
items,
|
|
20
|
+
...props
|
|
28
21
|
}) {
|
|
29
|
-
const composite = (0, _components.__unstableUseCompositeState)({
|
|
30
|
-
orientation: 'vertical'
|
|
31
|
-
});
|
|
32
|
-
|
|
33
22
|
if (!items?.length) {
|
|
34
23
|
return null;
|
|
35
24
|
}
|
|
36
25
|
|
|
37
|
-
return (0, _element.createElement)(
|
|
26
|
+
return (0, _element.createElement)("ul", {
|
|
38
27
|
role: "listbox",
|
|
39
28
|
className: "edit-site-patterns__grid",
|
|
40
|
-
|
|
29
|
+
...props
|
|
41
30
|
}, items.map(item => (0, _element.createElement)(_gridItem.default, {
|
|
42
31
|
key: item.name,
|
|
43
|
-
icon: icon,
|
|
44
32
|
item: item,
|
|
45
|
-
categoryId: categoryId
|
|
46
|
-
composite: composite
|
|
33
|
+
categoryId: categoryId
|
|
47
34
|
})));
|
|
48
35
|
}
|
|
49
36
|
//# sourceMappingURL=grid.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/page-patterns/grid.js"],"names":["Grid","categoryId","
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/page-patterns/grid.js"],"names":["Grid","categoryId","items","props","length","map","item","name"],"mappings":";;;;;;;;;;;AAGA;;AAHA;AACA;AACA;AAGe,SAASA,IAAT,CAAe;AAAEC,EAAAA,UAAF;AAAcC,EAAAA,KAAd;AAAqB,KAAGC;AAAxB,CAAf,EAAiD;AAC/D,MAAK,CAAED,KAAK,EAAEE,MAAd,EAAuB;AACtB,WAAO,IAAP;AACA;;AAED,SACC;AAAI,IAAA,IAAI,EAAC,SAAT;AAAmB,IAAA,SAAS,EAAC,0BAA7B;AAAA,OAA6DD;AAA7D,KACGD,KAAK,CAACG,GAAN,CAAaC,IAAF,IACZ,4BAAC,iBAAD;AACC,IAAA,GAAG,EAAGA,IAAI,CAACC,IADZ;AAEC,IAAA,IAAI,EAAGD,IAFR;AAGC,IAAA,UAAU,EAAGL;AAHd,IADC,CADH,CADD;AAWA","sourcesContent":["/**\n * Internal dependencies\n */\nimport GridItem from './grid-item';\n\nexport default function Grid( { categoryId, items, ...props } ) {\n\tif ( ! items?.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<ul role=\"listbox\" className=\"edit-site-patterns__grid\" { ...props }>\n\t\t\t{ items.map( ( item ) => (\n\t\t\t\t<GridItem\n\t\t\t\t\tkey={ item.name }\n\t\t\t\t\titem={ item }\n\t\t\t\t\tcategoryId={ categoryId }\n\t\t\t\t/>\n\t\t\t) ) }\n\t\t</ul>\n\t);\n}\n"]}
|