@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
package/build-module/components/page-content-focus-manager/disable-non-page-content-blocks.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/page-content-focus-manager/disable-non-page-content-blocks.js"],"names":["createHigherOrderComponent","addFilter","removeFilter","privateApis","blockEditorPrivateApis","useEffect","unlock","
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/page-content-focus-manager/disable-non-page-content-blocks.js"],"names":["createHigherOrderComponent","addFilter","removeFilter","privateApis","blockEditorPrivateApis","useEffect","unlock","useBlockEditingMode","PAGE_CONTENT_BLOCK_TYPES","DisableNonPageContentBlocks","useDisableNonPageContentBlocks","withDisableNonPageContentBlocks","BlockEdit","props","isDescendentOfQueryLoop","context","queryId","undefined","isPageContent","includes","name","mode"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,0BAAT,QAA2C,oBAA3C;AACA,SAASC,SAAT,EAAoBC,YAApB,QAAwC,kBAAxC;AACA,SAASC,WAAW,IAAIC,sBAAxB,QAAsD,yBAAtD;AACA,SAASC,SAAT,QAA0B,oBAA1B;AAEA;AACA;AACA;;AACA,SAASC,MAAT,QAAuB,mBAAvB;AAEA,MAAM;AAAEC,EAAAA;AAAF,IAA0BD,MAAM,CAAEF,sBAAF,CAAtC;AAEA,MAAMI,wBAAwB,GAAG,CAChC,iBADgC,EAEhC,0BAFgC,EAGhC,mBAHgC,CAAjC;AAMA;AACA;AACA;AACA;;AACA,eAAe,SAASC,2BAAT,GAAuC;AACrDC,EAAAA,8BAA8B;AAC9B,SAAO,IAAP;AACA;AAED;AACA;AACA;;AACA,OAAO,SAASA,8BAAT,GAA0C;AAChDH,EAAAA,mBAAmB,CAAE,UAAF,CAAnB;AACAF,EAAAA,SAAS,CAAE,MAAM;AAChBJ,IAAAA,SAAS,CACR,kBADQ,EAER,2CAFQ,EAGRU,+BAHQ,CAAT;AAKA,WAAO,MACNT,YAAY,CACX,kBADW,EAEX,2CAFW,CADb;AAKA,GAXQ,EAWN,EAXM,CAAT;AAYA;AAED,MAAMS,+BAA+B,GAAGX,0BAA0B,CAC/DY,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;AACAV,EAAAA,mBAAmB,CAAEc,IAAF,CAAnB;AACA,SAAO,cAAC,SAAD,OAAgBR;AAAhB,IAAP;AACA,CATgE,EAUjE,iCAViE,CAAlE","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,147 @@
|
|
|
1
|
+
import { createElement } from "@wordpress/element";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* WordPress dependencies
|
|
5
|
+
*/
|
|
6
|
+
import { MenuItem } from '@wordpress/components';
|
|
7
|
+
import { store as coreStore } from '@wordpress/core-data';
|
|
8
|
+
import { useDispatch } from '@wordpress/data';
|
|
9
|
+
import { __, sprintf } from '@wordpress/i18n';
|
|
10
|
+
import { store as noticesStore } from '@wordpress/notices';
|
|
11
|
+
import { privateApis as routerPrivateApis } from '@wordpress/router';
|
|
12
|
+
/**
|
|
13
|
+
* Internal dependencies
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import { TEMPLATE_PARTS, PATTERNS, SYNC_TYPES, USER_PATTERNS, USER_PATTERN_CATEGORY } from './utils';
|
|
17
|
+
import { useExistingTemplateParts, getUniqueTemplatePartTitle, getCleanTemplatePartSlug } from '../../utils/template-part-create';
|
|
18
|
+
import { unlock } from '../../lock-unlock';
|
|
19
|
+
const {
|
|
20
|
+
useHistory
|
|
21
|
+
} = unlock(routerPrivateApis);
|
|
22
|
+
|
|
23
|
+
function getPatternMeta(item) {
|
|
24
|
+
if (item.type === PATTERNS) {
|
|
25
|
+
return {
|
|
26
|
+
wp_pattern_sync_status: SYNC_TYPES.unsynced
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const syncStatus = item.reusableBlock.wp_pattern_sync_status;
|
|
31
|
+
const isUnsynced = syncStatus === SYNC_TYPES.unsynced;
|
|
32
|
+
return { ...item.reusableBlock.meta,
|
|
33
|
+
wp_pattern_sync_status: isUnsynced ? syncStatus : undefined
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export default function DuplicateMenuItem({
|
|
38
|
+
categoryId,
|
|
39
|
+
item,
|
|
40
|
+
label = __('Duplicate'),
|
|
41
|
+
onClose
|
|
42
|
+
}) {
|
|
43
|
+
const {
|
|
44
|
+
saveEntityRecord
|
|
45
|
+
} = useDispatch(coreStore);
|
|
46
|
+
const {
|
|
47
|
+
createErrorNotice,
|
|
48
|
+
createSuccessNotice
|
|
49
|
+
} = useDispatch(noticesStore);
|
|
50
|
+
const history = useHistory();
|
|
51
|
+
const existingTemplateParts = useExistingTemplateParts();
|
|
52
|
+
|
|
53
|
+
async function createTemplatePart() {
|
|
54
|
+
try {
|
|
55
|
+
const copiedTitle = sprintf(
|
|
56
|
+
/* translators: %s: Existing template part title */
|
|
57
|
+
__('%s (Copy)'), item.title);
|
|
58
|
+
const title = getUniqueTemplatePartTitle(copiedTitle, existingTemplateParts);
|
|
59
|
+
const slug = getCleanTemplatePartSlug(title);
|
|
60
|
+
const {
|
|
61
|
+
area,
|
|
62
|
+
content
|
|
63
|
+
} = item.templatePart;
|
|
64
|
+
const result = await saveEntityRecord('postType', 'wp_template_part', {
|
|
65
|
+
slug,
|
|
66
|
+
title,
|
|
67
|
+
content,
|
|
68
|
+
area
|
|
69
|
+
}, {
|
|
70
|
+
throwOnError: true
|
|
71
|
+
});
|
|
72
|
+
createSuccessNotice(sprintf( // translators: %s: The new template part's title e.g. 'Call to action (copy)'.
|
|
73
|
+
__('"%s" created.'), title), {
|
|
74
|
+
type: 'snackbar',
|
|
75
|
+
id: 'edit-site-patterns-success',
|
|
76
|
+
actions: [{
|
|
77
|
+
label: __('Edit'),
|
|
78
|
+
onClick: () => history.push({
|
|
79
|
+
postType: TEMPLATE_PARTS,
|
|
80
|
+
postId: result?.id,
|
|
81
|
+
categoryType: TEMPLATE_PARTS,
|
|
82
|
+
categoryId
|
|
83
|
+
})
|
|
84
|
+
}]
|
|
85
|
+
});
|
|
86
|
+
onClose();
|
|
87
|
+
} catch (error) {
|
|
88
|
+
const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : __('An error occurred while creating the template part.');
|
|
89
|
+
createErrorNotice(errorMessage, {
|
|
90
|
+
type: 'snackbar',
|
|
91
|
+
id: 'edit-site-patterns-error'
|
|
92
|
+
});
|
|
93
|
+
onClose();
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
async function createPattern() {
|
|
98
|
+
try {
|
|
99
|
+
const isThemePattern = item.type === PATTERNS;
|
|
100
|
+
const title = sprintf(
|
|
101
|
+
/* translators: %s: Existing pattern title */
|
|
102
|
+
__('%s (Copy)'), item.title);
|
|
103
|
+
const result = await saveEntityRecord('postType', 'wp_block', {
|
|
104
|
+
content: isThemePattern ? item.content : item.reusableBlock.content,
|
|
105
|
+
meta: getPatternMeta(item),
|
|
106
|
+
status: 'publish',
|
|
107
|
+
title
|
|
108
|
+
}, {
|
|
109
|
+
throwOnError: true
|
|
110
|
+
});
|
|
111
|
+
const actionLabel = isThemePattern ? __('View my patterns') : __('Edit');
|
|
112
|
+
const newLocation = isThemePattern ? {
|
|
113
|
+
categoryType: USER_PATTERNS,
|
|
114
|
+
categoryId: USER_PATTERN_CATEGORY,
|
|
115
|
+
path: '/patterns'
|
|
116
|
+
} : {
|
|
117
|
+
categoryType: USER_PATTERNS,
|
|
118
|
+
categoryId: USER_PATTERN_CATEGORY,
|
|
119
|
+
postType: USER_PATTERNS,
|
|
120
|
+
postId: result?.id
|
|
121
|
+
};
|
|
122
|
+
createSuccessNotice(sprintf( // translators: %s: The new pattern's title e.g. 'Call to action (copy)'.
|
|
123
|
+
__('"%s" added to my patterns.'), title), {
|
|
124
|
+
type: 'snackbar',
|
|
125
|
+
id: 'edit-site-patterns-success',
|
|
126
|
+
actions: [{
|
|
127
|
+
label: actionLabel,
|
|
128
|
+
onClick: () => history.push(newLocation)
|
|
129
|
+
}]
|
|
130
|
+
});
|
|
131
|
+
onClose();
|
|
132
|
+
} catch (error) {
|
|
133
|
+
const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : __('An error occurred while creating the pattern.');
|
|
134
|
+
createErrorNotice(errorMessage, {
|
|
135
|
+
type: 'snackbar',
|
|
136
|
+
id: 'edit-site-patterns-error'
|
|
137
|
+
});
|
|
138
|
+
onClose();
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
const createItem = item.type === TEMPLATE_PARTS ? createTemplatePart : createPattern;
|
|
143
|
+
return createElement(MenuItem, {
|
|
144
|
+
onClick: createItem
|
|
145
|
+
}, label);
|
|
146
|
+
}
|
|
147
|
+
//# 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":["MenuItem","store","coreStore","useDispatch","__","sprintf","noticesStore","privateApis","routerPrivateApis","TEMPLATE_PARTS","PATTERNS","SYNC_TYPES","USER_PATTERNS","USER_PATTERN_CATEGORY","useExistingTemplateParts","getUniqueTemplatePartTitle","getCleanTemplatePartSlug","unlock","useHistory","getPatternMeta","item","type","wp_pattern_sync_status","unsynced","syncStatus","reusableBlock","isUnsynced","meta","undefined","DuplicateMenuItem","categoryId","label","onClose","saveEntityRecord","createErrorNotice","createSuccessNotice","history","existingTemplateParts","createTemplatePart","copiedTitle","title","slug","area","content","templatePart","result","throwOnError","id","actions","onClick","push","postType","postId","categoryType","error","errorMessage","message","code","createPattern","isThemePattern","status","actionLabel","newLocation","path","createItem"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,QAAT,QAAyB,uBAAzB;AACA,SAASC,KAAK,IAAIC,SAAlB,QAAmC,sBAAnC;AACA,SAASC,WAAT,QAA4B,iBAA5B;AACA,SAASC,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SAASJ,KAAK,IAAIK,YAAlB,QAAsC,oBAAtC;AACA,SAASC,WAAW,IAAIC,iBAAxB,QAAiD,mBAAjD;AA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QAAAA,OAAO,EAAE,CACR;AACCjB,UAAAA,KAAK,EAAE8B,WADR;AAECZ,UAAAA,OAAO,EAAE,MAAMb,OAAO,CAACc,IAAR,CAAcY,WAAd;AAFhB,SADQ;AAHV,OANkB,CAAnB;AAkBA9B,MAAAA,OAAO;AACP,KA1DD,CA0DE,OAAQsB,KAAR,EAAgB;AACjB,YAAMC,YAAY,GACjBD,KAAK,CAACE,OAAN,IAAiBF,KAAK,CAACG,IAAN,KAAe,eAAhC,GACGH,KAAK,CAACE,OADT,GAEGpD,EAAE,CAAE,+CAAF,CAHN;AAKA8B,MAAAA,iBAAiB,CAAEqB,YAAF,EAAgB;AAChClC,QAAAA,IAAI,EAAE,UAD0B;AAEhC0B,QAAAA,EAAE,EAAE;AAF4B,OAAhB,CAAjB;AAIAf,MAAAA,OAAO;AACP;AACD;;AAED,QAAMgC,UAAU,GACf5C,IAAI,CAACC,IAAL,KAAcZ,cAAd,GAA+B6B,kBAA/B,GAAoDoB,aADrD;AAGA,SAAO,cAAC,QAAD;AAAU,IAAA,OAAO,EAAGM;AAApB,KAAmCjC,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"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createElement
|
|
1
|
+
import { createElement } from "@wordpress/element";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* External dependencies
|
|
@@ -9,31 +9,38 @@ import classnames from 'classnames';
|
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
import { BlockPreview } from '@wordpress/block-editor';
|
|
12
|
-
import { __experimentalConfirmDialog as ConfirmDialog, DropdownMenu, MenuGroup, MenuItem,
|
|
12
|
+
import { Button, __experimentalConfirmDialog as ConfirmDialog, DropdownMenu, MenuGroup, MenuItem, __experimentalHeading as Heading, __experimentalHStack as HStack, Tooltip, Flex } from '@wordpress/components';
|
|
13
13
|
import { useDispatch } from '@wordpress/data';
|
|
14
|
-
import { useState, useId } from '@wordpress/element';
|
|
14
|
+
import { useState, useId, memo } from '@wordpress/element';
|
|
15
15
|
import { __, sprintf } from '@wordpress/i18n';
|
|
16
|
-
import { Icon, header, footer, symbolFilled, moreHorizontal, lockSmall } from '@wordpress/icons';
|
|
16
|
+
import { Icon, header, footer, symbolFilled as uncategorized, symbol, moreHorizontal, lockSmall } from '@wordpress/icons';
|
|
17
17
|
import { store as noticesStore } from '@wordpress/notices';
|
|
18
18
|
import { store as reusableBlocksStore } from '@wordpress/reusable-blocks';
|
|
19
|
-
import { DELETE, BACKSPACE } from '@wordpress/keycodes';
|
|
20
19
|
/**
|
|
21
20
|
* Internal dependencies
|
|
22
21
|
*/
|
|
23
22
|
|
|
24
|
-
import
|
|
23
|
+
import RenameMenuItem from './rename-menu-item';
|
|
24
|
+
import DuplicateMenuItem from './duplicate-menu-item';
|
|
25
|
+
import { PATTERNS, TEMPLATE_PARTS, USER_PATTERNS, SYNC_TYPES } from './utils';
|
|
26
|
+
import { store as editSiteStore } from '../../store';
|
|
25
27
|
import { useLink } from '../routes/link';
|
|
28
|
+
const templatePartIcons = {
|
|
29
|
+
header,
|
|
30
|
+
footer,
|
|
31
|
+
uncategorized
|
|
32
|
+
};
|
|
26
33
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
export default function GridItem({
|
|
34
|
+
function GridItem({
|
|
30
35
|
categoryId,
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
item
|
|
36
|
+
item,
|
|
37
|
+
...props
|
|
34
38
|
}) {
|
|
35
39
|
const descriptionId = useId();
|
|
36
40
|
const [isDeleteDialogOpen, setIsDeleteDialogOpen] = useState(false);
|
|
41
|
+
const {
|
|
42
|
+
removeTemplate
|
|
43
|
+
} = useDispatch(editSiteStore);
|
|
37
44
|
const {
|
|
38
45
|
__experimentalDeleteReusableBlock
|
|
39
46
|
} = useDispatch(reusableBlocksStore);
|
|
@@ -41,76 +48,74 @@ export default function GridItem({
|
|
|
41
48
|
createErrorNotice,
|
|
42
49
|
createSuccessNotice
|
|
43
50
|
} = useDispatch(noticesStore);
|
|
51
|
+
const isUserPattern = item.type === USER_PATTERNS;
|
|
52
|
+
const isNonUserPattern = item.type === PATTERNS;
|
|
53
|
+
const isTemplatePart = item.type === TEMPLATE_PARTS;
|
|
44
54
|
const {
|
|
45
55
|
onClick
|
|
46
56
|
} = useLink({
|
|
47
57
|
postType: item.type,
|
|
48
|
-
postId:
|
|
58
|
+
postId: isUserPattern ? item.id : item.name,
|
|
49
59
|
categoryId,
|
|
50
60
|
categoryType: item.type
|
|
51
61
|
});
|
|
52
|
-
|
|
53
|
-
const onKeyDown = event => {
|
|
54
|
-
if (DELETE === event.keyCode || BACKSPACE === event.keyCode) {
|
|
55
|
-
setIsDeleteDialogOpen(true);
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
|
|
59
62
|
const isEmpty = !item.blocks?.length;
|
|
60
63
|
const patternClassNames = classnames('edit-site-patterns__pattern', {
|
|
61
64
|
'is-placeholder': isEmpty
|
|
62
65
|
});
|
|
63
66
|
const previewClassNames = classnames('edit-site-patterns__preview', {
|
|
64
|
-
'is-inactive':
|
|
67
|
+
'is-inactive': isNonUserPattern
|
|
65
68
|
});
|
|
66
69
|
|
|
67
70
|
const deletePattern = async () => {
|
|
68
71
|
try {
|
|
69
72
|
await __experimentalDeleteReusableBlock(item.id);
|
|
70
|
-
createSuccessNotice(
|
|
71
|
-
|
|
73
|
+
createSuccessNotice(sprintf( // translators: %s: The pattern's title e.g. 'Call to action'.
|
|
74
|
+
__('"%s" deleted.'), item.title), {
|
|
75
|
+
type: 'snackbar',
|
|
76
|
+
id: 'edit-site-patterns-success'
|
|
72
77
|
});
|
|
73
78
|
} catch (error) {
|
|
74
79
|
const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : __('An error occurred while deleting the pattern.');
|
|
75
80
|
createErrorNotice(errorMessage, {
|
|
76
|
-
type: 'snackbar'
|
|
81
|
+
type: 'snackbar',
|
|
82
|
+
id: 'edit-site-patterns-error'
|
|
77
83
|
});
|
|
78
84
|
}
|
|
79
85
|
};
|
|
80
86
|
|
|
81
|
-
const
|
|
87
|
+
const deleteItem = () => isTemplatePart ? removeTemplate(item) : deletePattern(); // Only custom patterns or custom template parts can be renamed or deleted.
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
const isCustomPattern = isUserPattern || isTemplatePart && item.isCustom;
|
|
91
|
+
const hasThemeFile = isTemplatePart && item.templatePart.has_theme_file;
|
|
82
92
|
const ariaDescriptions = [];
|
|
83
93
|
|
|
84
|
-
if (
|
|
94
|
+
if (isCustomPattern) {
|
|
85
95
|
// User patterns don't have descriptions, but can be edited and deleted, so include some help text.
|
|
86
96
|
ariaDescriptions.push(__('Press Enter to edit, or Delete to delete the pattern.'));
|
|
87
97
|
} else if (item.description) {
|
|
88
98
|
ariaDescriptions.push(item.description);
|
|
89
99
|
}
|
|
90
100
|
|
|
91
|
-
if (
|
|
92
|
-
ariaDescriptions.push(
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
let itemIcon = icon;
|
|
96
|
-
|
|
97
|
-
if (categoryId === 'header') {
|
|
98
|
-
itemIcon = header;
|
|
99
|
-
} else if (categoryId === 'footer') {
|
|
100
|
-
itemIcon = footer;
|
|
101
|
-
} else if (categoryId === 'uncategorized') {
|
|
102
|
-
itemIcon = symbolFilled;
|
|
101
|
+
if (isNonUserPattern) {
|
|
102
|
+
ariaDescriptions.push(__('Theme & plugin patterns cannot be edited.'));
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
-
|
|
105
|
+
const itemIcon = templatePartIcons[categoryId] || (item.syncStatus === SYNC_TYPES.full ? symbol : undefined);
|
|
106
|
+
const confirmButtonText = hasThemeFile ? __('Clear') : __('Delete');
|
|
107
|
+
const confirmPrompt = hasThemeFile ? __('Are you sure you want to clear these customizations?') : sprintf( // translators: %s: The pattern or template part's title e.g. 'Call to action'.
|
|
108
|
+
__('Are you sure you want to delete "%s"?'), item.title);
|
|
109
|
+
return createElement("li", {
|
|
106
110
|
className: patternClassNames
|
|
107
|
-
}, createElement(
|
|
108
|
-
className: previewClassNames,
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
111
|
+
}, createElement("button", {
|
|
112
|
+
className: previewClassNames // Even though still incomplete, passing ids helps performance.
|
|
113
|
+
// @see https://reakit.io/docs/composite/#performance.
|
|
114
|
+
,
|
|
115
|
+
id: `edit-site-patterns-${item.name}`,
|
|
116
|
+
...props,
|
|
112
117
|
onClick: item.type !== PATTERNS ? onClick : undefined,
|
|
113
|
-
|
|
118
|
+
"aria-disabled": item.type !== PATTERNS ? 'false' : 'true',
|
|
114
119
|
"aria-label": item.title,
|
|
115
120
|
"aria-describedby": ariaDescriptions.length ? ariaDescriptions.map((_, index) => `${descriptionId}-${index}`).join(' ') : undefined
|
|
116
121
|
}, isEmpty && __('Empty pattern'), !isEmpty && createElement(BlockPreview, {
|
|
@@ -120,7 +125,6 @@ export default function GridItem({
|
|
|
120
125
|
hidden: true,
|
|
121
126
|
id: `${descriptionId}-${index}`
|
|
122
127
|
}, ariaDescription)), createElement(HStack, {
|
|
123
|
-
"aria-hidden": "true",
|
|
124
128
|
className: "edit-site-patterns__footer",
|
|
125
129
|
justify: "space-between"
|
|
126
130
|
}, createElement(HStack, {
|
|
@@ -128,25 +132,33 @@ export default function GridItem({
|
|
|
128
132
|
justify: "left",
|
|
129
133
|
spacing: 3,
|
|
130
134
|
className: "edit-site-patterns__pattern-title"
|
|
131
|
-
},
|
|
135
|
+
}, itemIcon && !isNonUserPattern && createElement(Tooltip, {
|
|
136
|
+
position: "top center",
|
|
137
|
+
text: __('Editing this pattern will also update anywhere it is used')
|
|
138
|
+
}, createElement("span", null, createElement(Icon, {
|
|
132
139
|
className: "edit-site-patterns__pattern-icon",
|
|
133
140
|
icon: itemIcon
|
|
134
|
-
}), createElement(Flex, {
|
|
141
|
+
}))), createElement(Flex, {
|
|
135
142
|
as: "span",
|
|
136
143
|
gap: 0,
|
|
137
144
|
justify: "left"
|
|
138
|
-
}, item.
|
|
145
|
+
}, item.type === PATTERNS ? item.title : createElement(Heading, {
|
|
146
|
+
level: 5
|
|
147
|
+
}, createElement(Button, {
|
|
148
|
+
variant: "link",
|
|
149
|
+
onClick: onClick // Required for the grid's roving tab index system.
|
|
150
|
+
// See https://github.com/WordPress/gutenberg/pull/51898#discussion_r1243399243.
|
|
151
|
+
,
|
|
152
|
+
tabIndex: "-1"
|
|
153
|
+
}, item.title)), item.type === PATTERNS && createElement(Tooltip, {
|
|
139
154
|
position: "top center",
|
|
140
|
-
text: __('
|
|
155
|
+
text: __('This pattern cannot be edited.')
|
|
141
156
|
}, createElement("span", {
|
|
142
157
|
className: "edit-site-patterns__pattern-lock-icon"
|
|
143
158
|
}, createElement(Icon, {
|
|
144
|
-
style: {
|
|
145
|
-
fill: 'currentcolor'
|
|
146
|
-
},
|
|
147
159
|
icon: lockSmall,
|
|
148
160
|
size: 24
|
|
149
|
-
}))))),
|
|
161
|
+
}))))), createElement(DropdownMenu, {
|
|
150
162
|
icon: moreHorizontal,
|
|
151
163
|
label: __('Actions'),
|
|
152
164
|
className: "edit-site-patterns__dropdown",
|
|
@@ -158,18 +170,26 @@ export default function GridItem({
|
|
|
158
170
|
isSmall: true,
|
|
159
171
|
describedBy: sprintf(
|
|
160
172
|
/* translators: %s: pattern name */
|
|
161
|
-
__('Action menu for %s pattern'), item.title)
|
|
162
|
-
// The dropdown menu is not focusable using the
|
|
163
|
-
// keyboard as this would interfere with the grid's
|
|
164
|
-
// roving tab index system. Instead, keyboard users
|
|
165
|
-
// use keyboard shortcuts to trigger actions.
|
|
166
|
-
tabIndex: -1
|
|
173
|
+
__('Action menu for %s pattern'), item.title)
|
|
167
174
|
}
|
|
168
|
-
}, (
|
|
175
|
+
}, ({
|
|
176
|
+
onClose
|
|
177
|
+
}) => createElement(MenuGroup, null, isCustomPattern && !hasThemeFile && createElement(RenameMenuItem, {
|
|
178
|
+
item: item,
|
|
179
|
+
onClose: onClose
|
|
180
|
+
}), createElement(DuplicateMenuItem, {
|
|
181
|
+
categoryId: categoryId,
|
|
182
|
+
item: item,
|
|
183
|
+
onClose: onClose,
|
|
184
|
+
label: isNonUserPattern ? __('Copy to My patterns') : __('Duplicate')
|
|
185
|
+
}), isCustomPattern && createElement(MenuItem, {
|
|
169
186
|
onClick: () => setIsDeleteDialogOpen(true)
|
|
170
|
-
}, __('Delete')))))
|
|
171
|
-
|
|
187
|
+
}, hasThemeFile ? __('Clear customizations') : __('Delete'))))), isDeleteDialogOpen && createElement(ConfirmDialog, {
|
|
188
|
+
confirmButtonText: confirmButtonText,
|
|
189
|
+
onConfirm: deleteItem,
|
|
172
190
|
onCancel: () => setIsDeleteDialogOpen(false)
|
|
173
|
-
},
|
|
191
|
+
}, confirmPrompt));
|
|
174
192
|
}
|
|
193
|
+
|
|
194
|
+
export default memo(GridItem);
|
|
175
195
|
//# sourceMappingURL=grid-item.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/page-patterns/grid-item.js"],"names":["classnames","BlockPreview","__experimentalConfirmDialog","ConfirmDialog","DropdownMenu","MenuGroup","MenuItem","__experimentalHStack","HStack","__unstableCompositeItem","CompositeItem","Tooltip","Flex","useDispatch","useState","useId","__","sprintf","Icon","header","footer","symbolFilled","moreHorizontal","lockSmall","store","noticesStore","reusableBlocksStore","DELETE","BACKSPACE","PATTERNS","USER_PATTERNS","useLink","THEME_PATTERN_TOOLTIP","GridItem","categoryId","composite","icon","item","descriptionId","isDeleteDialogOpen","setIsDeleteDialogOpen","__experimentalDeleteReusableBlock","createErrorNotice","createSuccessNotice","onClick","postType","type","postId","id","name","categoryType","onKeyDown","event","keyCode","isEmpty","blocks","length","patternClassNames","previewClassNames","deletePattern","error","errorMessage","message","code","isUserPattern","ariaDescriptions","push","description","itemIcon","undefined","title","map","_","index","join","ariaDescription","fill","placement","className","isSmall","describedBy","tabIndex"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,YAAT,QAA6B,yBAA7B;AACA,SACCC,2BAA2B,IAAIC,aADhC,EAECC,YAFD,EAGCC,SAHD,EAICC,QAJD,EAKCC,oBAAoB,IAAIC,MALzB,EAMCC,uBAAuB,IAAIC,aAN5B,EAOCC,OAPD,EAQCC,IARD,QASO,uBATP;AAUA,SAASC,WAAT,QAA4B,iBAA5B;AACA,SAASC,QAAT,EAAmBC,KAAnB,QAAgC,oBAAhC;AACA,SAASC,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SACCC,IADD,EAECC,MAFD,EAGCC,MAHD,EAICC,YAJD,EAKCC,cALD,EAMCC,SAND,QAOO,kBAPP;AAQA,SAASC,KAAK,IAAIC,YAAlB,QAAsC,oBAAtC;AACA,SAASD,KAAK,IAAIE,mBAAlB,QAA6C,4BAA7C;AACA,SAASC,MAAT,EAAiBC,SAAjB,QAAkC,qBAAlC;AAEA;AACA;AACA;;AACA,SAASC,QAAT,EAAmBC,aAAnB,QAAwC,SAAxC;AACA,SAASC,OAAT,QAAwB,gBAAxB;;AAEA,MAAMC,qBAAqB,GAAGhB,EAAE,CAAE,kCAAF,CAAhC;;AAEA,eAAe,SAASiB,QAAT,CAAmB;AAAEC,EAAAA,UAAF;AAAcC,EAAAA,SAAd;AAAyBC,EAAAA,IAAzB;AAA+BC,EAAAA;AAA/B,CAAnB,EAA2D;AACzE,QAAMC,aAAa,GAAGvB,KAAK,EAA3B;AACA,QAAM,CAAEwB,kBAAF,EAAsBC,qBAAtB,IAAgD1B,QAAQ,CAAE,KAAF,CAA9D;AAEA,QAAM;AAAE2B,IAAAA;AAAF,MACL5B,WAA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4D,MAAAA,IAAI,EAAE;AAAR,KADT;AAEC,IAAA,IAAI,EAAGrD,SAFR;AAGC,IAAA,IAAI,EAAG;AAHR,IADD,CAND,CAHF,CAZD,CALD,EAqCGc,IAAI,CAACS,IAAL,KAAchB,aAAd,IACD,cAAC,YAAD;AACC,IAAA,IAAI,EAAGR,cADR;AAEC,IAAA,KAAK,EAAGN,EAAE,CAAE,SAAF,CAFX;AAGC,IAAA,SAAS,EAAC,8BAHX;AAIC,IAAA,YAAY,EAAG;AAAE6D,MAAAA,SAAS,EAAE;AAAb,KAJhB;AAKC,IAAA,WAAW,EAAG;AACbC,MAAAA,SAAS,EAAE,4BADE;AAEbC,MAAAA,OAAO,EAAE,IAFI;AAGbC,MAAAA,WAAW,EAAE/D,OAAO;AACnB;AACAD,MAAAA,EAAE,CAAE,4BAAF,CAFiB,EAGnBqB,IAAI,CAACiC,KAHc,CAHP;AAQb;AACA;AACA;AACA;AACAW,MAAAA,QAAQ,EAAE,CAAC;AAZE;AALf,KAoBG,MACD,cAAC,SAAD,QACC,cAAC,QAAD;AACC,IAAA,OAAO,EAAG,MACTzC,qBAAqB,CAAE,IAAF;AAFvB,KAKGxB,EAAE,CAAE,QAAF,CALL,CADD,CArBF,CAtCF,CAhCD,CADD,EA0GGuB,kBAAkB,IACnB,cAAC,aAAD;AACC,IAAA,SAAS,EAAGoB,aADb;AAEC,IAAA,QAAQ,EAAG,MAAMnB,qBAAqB,CAAE,KAAF;AAFvC,KAIGxB,EAAE,CAAE,+CAAF,CAJL,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":["classnames","BlockPreview","Button","__experimentalConfirmDialog","ConfirmDialog","DropdownMenu","MenuGroup","MenuItem","__experimentalHeading","Heading","__experimentalHStack","HStack","Tooltip","Flex","useDispatch","useState","useId","memo","__","sprintf","Icon","header","footer","symbolFilled","uncategorized","symbol","moreHorizontal","lockSmall","store","noticesStore","reusableBlocksStore","RenameMenuItem","DuplicateMenuItem","PATTERNS","TEMPLATE_PARTS","USER_PATTERNS","SYNC_TYPES","editSiteStore","useLink","templatePartIcons","GridItem","categoryId","item","props","descriptionId","isDeleteDialogOpen","setIsDeleteDialogOpen","removeTemplate","__experimentalDeleteReusableBlock","createErrorNotice","createSuccessNotice","isUserPattern","type","isNonUserPattern","isTemplatePart","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","full","undefined","confirmButtonText","confirmPrompt","map","_","index","join","ariaDescription","placement","className","isSmall","describedBy","onClose"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,YAAT,QAA6B,yBAA7B;AACA,SACCC,MADD,EAECC,2BAA2B,IAAIC,aAFhC,EAGCC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AAEE,YAArB,IACD,cAAC,cAAD;AACC,IAAA,IAAI,EAAGjC,IADR;AAEC,IAAA,OAAO,EAAGsD;AAFX,IAFF,EAOC,cAAC,iBAAD;AACC,IAAA,UAAU,EAAGvD,UADd;AAEC,IAAA,IAAI,EAAGC,IAFR;AAGC,IAAA,OAAO,EAAGsD,OAHX;AAIC,IAAA,KAAK,EACJ3C,gBAAgB,GACbnC,EAAE,CAAE,qBAAF,CADW,GAEbA,EAAE,CAAE,WAAF;AAPP,IAPD,EAiBGuD,eAAe,IAChB,cAAC,QAAD;AACC,IAAA,OAAO,EAAG,MACT3B,qBAAqB,CAAE,IAAF;AAFvB,KAKG6B,YAAY,GACXzD,EAAE,CAAE,sBAAF,CADS,GAEXA,EAAE,CAAE,QAAF,CAPN,CAlBF,CAhBF,CArDD,CAjCD,EAuIG2B,kBAAkB,IACnB,cAAC,aAAD;AACC,IAAA,iBAAiB,EAAGwC,iBADrB;AAEC,IAAA,SAAS,EAAGb,UAFb;AAGC,IAAA,QAAQ,EAAG,MAAM1B,qBAAqB,CAAE,KAAF;AAHvC,KAKGwC,aALH,CAxIF,CADD;AAmJA;;AAED,eAAerE,IAAI,CAAEuB,QAAF,CAAnB","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"]}
|
|
@@ -1,38 +1,26 @@
|
|
|
1
1
|
import { createElement } from "@wordpress/element";
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
* WordPress dependencies
|
|
5
|
-
*/
|
|
6
|
-
import { __unstableComposite as Composite, __unstableUseCompositeState as useCompositeState } from '@wordpress/components';
|
|
7
3
|
/**
|
|
8
4
|
* Internal dependencies
|
|
9
5
|
*/
|
|
10
|
-
|
|
11
6
|
import GridItem from './grid-item';
|
|
12
7
|
export default function Grid({
|
|
13
8
|
categoryId,
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
items
|
|
9
|
+
items,
|
|
10
|
+
...props
|
|
17
11
|
}) {
|
|
18
|
-
const composite = useCompositeState({
|
|
19
|
-
orientation: 'vertical'
|
|
20
|
-
});
|
|
21
|
-
|
|
22
12
|
if (!items?.length) {
|
|
23
13
|
return null;
|
|
24
14
|
}
|
|
25
15
|
|
|
26
|
-
return createElement(
|
|
16
|
+
return createElement("ul", {
|
|
27
17
|
role: "listbox",
|
|
28
18
|
className: "edit-site-patterns__grid",
|
|
29
|
-
|
|
19
|
+
...props
|
|
30
20
|
}, items.map(item => createElement(GridItem, {
|
|
31
21
|
key: item.name,
|
|
32
|
-
icon: icon,
|
|
33
22
|
item: item,
|
|
34
|
-
categoryId: categoryId
|
|
35
|
-
composite: composite
|
|
23
|
+
categoryId: categoryId
|
|
36
24
|
})));
|
|
37
25
|
}
|
|
38
26
|
//# sourceMappingURL=grid.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/page-patterns/grid.js"],"names":["
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/page-patterns/grid.js"],"names":["GridItem","Grid","categoryId","items","props","length","map","item","name"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,QAAP,MAAqB,aAArB;AAEA,eAAe,SAASC,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,cAAC,QAAD;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"]}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { createElement } from "@wordpress/element";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* WordPress dependencies
|
|
5
|
+
*/
|
|
6
|
+
import { __experimentalVStack as VStack, __experimentalHeading as Heading, __experimentalText as Text } from '@wordpress/components';
|
|
7
|
+
import { __ } from '@wordpress/i18n';
|
|
8
|
+
import { store as editorStore } from '@wordpress/editor';
|
|
9
|
+
import { useSelect } from '@wordpress/data';
|
|
10
|
+
/**
|
|
11
|
+
* Internal dependencies
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import usePatternCategories from '../sidebar-navigation-screen-patterns/use-pattern-categories';
|
|
15
|
+
import { USER_PATTERN_CATEGORY, USER_PATTERNS, TEMPLATE_PARTS, PATTERNS } from './utils';
|
|
16
|
+
export default function PatternsHeader({
|
|
17
|
+
categoryId,
|
|
18
|
+
type,
|
|
19
|
+
titleId,
|
|
20
|
+
descriptionId
|
|
21
|
+
}) {
|
|
22
|
+
const {
|
|
23
|
+
patternCategories
|
|
24
|
+
} = usePatternCategories();
|
|
25
|
+
const templatePartAreas = useSelect(select => select(editorStore).__experimentalGetDefaultTemplatePartAreas(), []);
|
|
26
|
+
let title, description;
|
|
27
|
+
|
|
28
|
+
if (categoryId === USER_PATTERN_CATEGORY && type === USER_PATTERNS) {
|
|
29
|
+
title = __('My Patterns');
|
|
30
|
+
description = '';
|
|
31
|
+
} else if (type === TEMPLATE_PARTS) {
|
|
32
|
+
const templatePartArea = templatePartAreas.find(area => area.area === categoryId);
|
|
33
|
+
title = templatePartArea?.label;
|
|
34
|
+
description = templatePartArea?.description;
|
|
35
|
+
} else if (type === PATTERNS) {
|
|
36
|
+
const patternCategory = patternCategories.find(category => category.name === categoryId);
|
|
37
|
+
title = patternCategory?.label;
|
|
38
|
+
description = patternCategory?.description;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (!title) return null;
|
|
42
|
+
return createElement(VStack, {
|
|
43
|
+
className: "edit-site-patterns__section-header"
|
|
44
|
+
}, createElement(Heading, {
|
|
45
|
+
as: "h2",
|
|
46
|
+
level: 4,
|
|
47
|
+
id: titleId
|
|
48
|
+
}, title), description ? createElement(Text, {
|
|
49
|
+
variant: "muted",
|
|
50
|
+
as: "p",
|
|
51
|
+
id: descriptionId
|
|
52
|
+
}, description) : null);
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=header.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/page-patterns/header.js"],"names":["__experimentalVStack","VStack","__experimentalHeading","Heading","__experimentalText","Text","__","store","editorStore","useSelect","usePatternCategories","USER_PATTERN_CATEGORY","USER_PATTERNS","TEMPLATE_PARTS","PATTERNS","PatternsHeader","categoryId","type","titleId","descriptionId","patternCategories","templatePartAreas","select","__experimentalGetDefaultTemplatePartAreas","title","description","templatePartArea","find","area","label","patternCategory","category","name"],"mappings":";;AAAA;AACA;AACA;AACA,SACCA,oBAAoB,IAAIC,MADzB,EAECC,qBAAqB,IAAIC,OAF1B,EAGCC,kBAAkB,IAAIC,IAHvB,QAIO,uBAJP;AAKA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,KAAK,IAAIC,WAAlB,QAAqC,mBAArC;AACA,SAASC,SAAT,QAA0B,iBAA1B;AAEA;AACA;AACA;;AACA,OAAOC,oBAAP,MAAiC,8DAAjC;AACA,SACCC,qBADD,EAECC,aAFD,EAGCC,cAHD,EAICC,QAJD,QAKO,SALP;AAOA,eAAe,SAASC,cAAT,CAAyB;AACvCC,EAAAA,UADuC;AAEvCC,EAAAA,IAFuC;AAGvCC,EAAAA,OAHuC;AAIvCC,EAAAA;AAJuC,CAAzB,EAKX;AACH,QAAM;AAAEC,IAAAA;AAAF,MAAwBV,oBAAoB,EAAlD;AACA,QAAMW,iBAAiB,GAAGZ,SAAS,CAChCa,MAAF,IACCA,MAAM,CAAEd,WAAF,CAAN,CAAsBe,yCAAtB,EAFiC,EAGlC,EAHkC,CAAnC;AAMA,MAAIC,KAAJ,EAAWC,WAAX;;AACA,MAAKT,UAAU,KAAKL,qBAAf,IAAwCM,IAAI,KAAKL,aAAtD,EAAsE;AACrEY,IAAAA,KAAK,GAAGlB,EAAE,CAAE,aAAF,CAAV;AACAmB,IAAAA,WAAW,GAAG,EAAd;AACA,GAHD,MAGO,IAAKR,IAAI,KAAKJ,cAAd,EAA+B;AACrC,UAAMa,gBAAgB,GAAGL,iBAAiB,CAACM,IAAlB,CACtBC,IAAF,IAAYA,IAAI,CAACA,IAAL,KAAcZ,UADF,CAAzB;AAGAQ,IAAAA,KAAK,GAAGE,gBAAgB,EAAEG,KAA1B;AACAJ,IAAAA,WAAW,GAAGC,gBAAgB,EAAED,WAAhC;AACA,GANM,MAMA,IAAKR,IAAI,KAAKH,QAAd,EAAyB;AAC/B,UAAMgB,eAAe,GAAGV,iBAAiB,CAACO,IAAlB,CACrBI,QAAF,IAAgBA,QAAQ,CAACC,IAAT,KAAkBhB,UADX,CAAxB;AAGAQ,IAAAA,KAAK,GAAGM,eAAe,EAAED,KAAzB;AACAJ,IAAAA,WAAW,GAAGK,eAAe,EAAEL,WAA/B;AACA;;AAED,MAAK,CAAED,KAAP,EAAe,OAAO,IAAP;AAEf,SACC,cAAC,MAAD;AAAQ,IAAA,SAAS,EAAC;AAAlB,KACC,cAAC,OAAD;AAAS,IAAA,EAAE,EAAC,IAAZ;AAAiB,IAAA,KAAK,EAAG,CAAzB;AAA6B,IAAA,EAAE,EAAGN;AAAlC,KACGM,KADH,CADD,EAIGC,WAAW,GACZ,cAAC,IAAD;AAAM,IAAA,OAAO,EAAC,OAAd;AAAsB,IAAA,EAAE,EAAC,GAAzB;AAA6B,IAAA,EAAE,EAAGN;AAAlC,KACGM,WADH,CADY,GAIT,IARL,CADD;AAYA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalVStack as VStack,\n\t__experimentalHeading as Heading,\n\t__experimentalText as Text,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { store as editorStore } from '@wordpress/editor';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport usePatternCategories from '../sidebar-navigation-screen-patterns/use-pattern-categories';\nimport {\n\tUSER_PATTERN_CATEGORY,\n\tUSER_PATTERNS,\n\tTEMPLATE_PARTS,\n\tPATTERNS,\n} from './utils';\n\nexport default function PatternsHeader( {\n\tcategoryId,\n\ttype,\n\ttitleId,\n\tdescriptionId,\n} ) {\n\tconst { patternCategories } = usePatternCategories();\n\tconst templatePartAreas = useSelect(\n\t\t( select ) =>\n\t\t\tselect( editorStore ).__experimentalGetDefaultTemplatePartAreas(),\n\t\t[]\n\t);\n\n\tlet title, description;\n\tif ( categoryId === USER_PATTERN_CATEGORY && type === USER_PATTERNS ) {\n\t\ttitle = __( 'My Patterns' );\n\t\tdescription = '';\n\t} else if ( type === TEMPLATE_PARTS ) {\n\t\tconst templatePartArea = templatePartAreas.find(\n\t\t\t( area ) => area.area === categoryId\n\t\t);\n\t\ttitle = templatePartArea?.label;\n\t\tdescription = templatePartArea?.description;\n\t} else if ( type === PATTERNS ) {\n\t\tconst patternCategory = patternCategories.find(\n\t\t\t( category ) => category.name === categoryId\n\t\t);\n\t\ttitle = patternCategory?.label;\n\t\tdescription = patternCategory?.description;\n\t}\n\n\tif ( ! title ) return null;\n\n\treturn (\n\t\t<VStack className=\"edit-site-patterns__section-header\">\n\t\t\t<Heading as=\"h2\" level={ 4 } id={ titleId }>\n\t\t\t\t{ title }\n\t\t\t</Heading>\n\t\t\t{ description ? (\n\t\t\t\t<Text variant=\"muted\" as=\"p\" id={ descriptionId }>\n\t\t\t\t\t{ description }\n\t\t\t\t</Text>\n\t\t\t) : null }\n\t\t</VStack>\n\t);\n}\n"]}
|