@wordpress/edit-site 5.13.0 → 5.15.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 +2 -13
- package/build/components/add-new-page/index.js.map +1 -1
- package/build/components/add-new-pattern/index.js +29 -15
- package/build/components/add-new-pattern/index.js.map +1 -1
- package/build/components/add-new-template/add-custom-generic-template-modal-content.js +2 -2
- package/build/components/add-new-template/add-custom-generic-template-modal-content.js.map +1 -1
- package/build/components/add-new-template/new-template.js +69 -14
- package/build/components/add-new-template/new-template.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/inserter-media-categories.js +1 -22
- package/build/components/block-editor/inserter-media-categories.js.map +1 -1
- package/build/components/block-editor/site-editor-canvas.js +29 -32
- package/build/components/block-editor/site-editor-canvas.js.map +1 -1
- package/build/components/block-editor/use-site-editor-settings.js +90 -19
- package/build/components/block-editor/use-site-editor-settings.js.map +1 -1
- package/build/components/canvas-spinner/index.js +1 -18
- package/build/components/canvas-spinner/index.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 +15 -11
- package/build/components/create-pattern-modal/index.js.map +1 -1
- package/build/components/create-template-part-modal/index.js +1 -1
- package/build/components/create-template-part-modal/index.js.map +1 -1
- package/build/components/editor/index.js +11 -1
- package/build/components/editor/index.js.map +1 -1
- package/build/components/global-styles/palette.js +1 -1
- package/build/components/global-styles/palette.js.map +1 -1
- package/build/components/global-styles/ui.js +7 -2
- package/build/components/global-styles/ui.js.map +1 -1
- package/build/components/header-edit-mode/document-actions/index.js +9 -1
- package/build/components/header-edit-mode/document-actions/index.js.map +1 -1
- package/build/components/header-edit-mode/index.js +49 -14
- package/build/components/header-edit-mode/index.js.map +1 -1
- package/build/components/header-edit-mode/more-menu/index.js +47 -17
- package/build/components/header-edit-mode/more-menu/index.js.map +1 -1
- package/build/components/keyboard-shortcut-help-modal/index.js +17 -4
- package/build/components/keyboard-shortcut-help-modal/index.js.map +1 -1
- package/build/components/keyboard-shortcuts/edit-mode.js +32 -1
- package/build/components/keyboard-shortcuts/edit-mode.js.map +1 -1
- package/build/components/keyboard-shortcuts/register.js +9 -0
- package/build/components/keyboard-shortcuts/register.js.map +1 -1
- package/build/components/layout/index.js +110 -28
- package/build/components/layout/index.js.map +1 -1
- package/build/components/page/header.js +1 -1
- package/build/components/page/header.js.map +1 -1
- package/build/components/page/index.js +3 -1
- 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 -15
- package/build/components/page-actions/trash-page-menu-item.js.map +1 -0
- package/build/components/page-content-focus-manager/back-to-page-notification.js +9 -3
- package/build/components/page-content-focus-manager/back-to-page-notification.js.map +1 -1
- 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-main/index.js +8 -4
- package/build/components/page-main/index.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 +218 -0
- package/build/components/page-patterns/grid-item.js.map +1 -0
- package/build/components/{page-library → page-patterns}/grid.js +6 -19
- package/build/components/page-patterns/grid.js.map +1 -0
- package/build/components/page-patterns/header.js +69 -0
- package/build/components/page-patterns/header.js.map +1 -0
- package/build/components/{page-library → page-patterns}/index.js +9 -7
- package/build/components/page-patterns/index.js.map +1 -0
- package/build/components/{page-library → page-patterns}/no-patterns.js +1 -1
- package/build/components/page-patterns/no-patterns.js.map +1 -0
- 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 +175 -0
- package/build/components/page-patterns/patterns-list.js.map +1 -0
- 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/search-items.js.map +1 -0
- package/build/components/{page-library/use-library-settings.js → page-patterns/use-pattern-settings.js} +3 -3
- package/build/components/page-patterns/use-pattern-settings.js.map +1 -0
- package/build/components/page-patterns/use-patterns.js +185 -0
- package/build/components/page-patterns/use-patterns.js.map +1 -0
- package/build/components/{page-library → page-patterns}/utils.js +3 -3
- package/build/components/page-patterns/utils.js.map +1 -0
- 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 +82 -0
- package/build/components/page-template-parts/index.js.map +1 -0
- package/build/components/page-templates/index.js +1 -0
- package/build/components/page-templates/index.js.map +1 -1
- package/build/components/preferences-modal/enable-feature.js +5 -1
- package/build/components/preferences-modal/enable-feature.js.map +1 -1
- package/build/components/preferences-modal/index.js +43 -4
- package/build/components/preferences-modal/index.js.map +1 -1
- package/build/components/resizable-frame/index.js +78 -36
- package/build/components/resizable-frame/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/index.js +6 -6
- package/build/components/sidebar/index.js.map +1 -1
- package/build/components/sidebar-edit-mode/index.js +4 -2
- package/build/components/sidebar-edit-mode/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/settings-header/index.js +7 -1
- package/build/components/sidebar-edit-mode/settings-header/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen/index.js +21 -11
- package/build/components/sidebar-navigation-screen/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-global-styles/index.js +69 -5
- package/build/components/sidebar-navigation-screen-global-styles/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-main/index.js +5 -3
- 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/delete-modal.js +7 -16
- package/build/components/sidebar-navigation-screen-navigation-menu/delete-modal.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-menu/edit-button.js +10 -11
- package/build/components/sidebar-navigation-screen-navigation-menu/edit-button.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-menu/index.js +10 -10
- 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/rename-modal.js +10 -1
- package/build/components/sidebar-navigation-screen-navigation-menu/rename-modal.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-menu/single-navigation-menu.js +9 -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 +9 -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/build-navigation-label.js +29 -0
- package/build/components/sidebar-navigation-screen-navigation-menus/build-navigation-label.js.map +1 -0
- 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 +27 -4
- package/build/components/sidebar-navigation-screen-navigation-menus/index.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/page-details.js +11 -4
- package/build/components/sidebar-navigation-screen-page/page-details.js.map +1 -1
- package/build/components/sidebar-navigation-screen-page/status-label.js +2 -35
- package/build/components/sidebar-navigation-screen-page/status-label.js.map +1 -1
- package/build/components/sidebar-navigation-screen-pages/index.js +33 -25
- package/build/components/sidebar-navigation-screen-pages/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-pattern/index.js +20 -13
- 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 +11 -3
- 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 +28 -2
- package/build/components/sidebar-navigation-screen-pattern/use-pattern-details.js.map +1 -1
- package/build/components/{sidebar-navigation-screen-library → sidebar-navigation-screen-patterns}/category-item.js +4 -4
- package/build/components/sidebar-navigation-screen-patterns/category-item.js.map +1 -0
- package/build/components/sidebar-navigation-screen-patterns/index.js +173 -0
- package/build/components/sidebar-navigation-screen-patterns/index.js.map +1 -0
- package/build/components/sidebar-navigation-screen-patterns/use-default-pattern-categories.js.map +1 -0
- package/build/components/sidebar-navigation-screen-patterns/use-my-patterns.js +34 -0
- package/build/components/sidebar-navigation-screen-patterns/use-my-patterns.js.map +1 -0
- package/build/components/{sidebar-navigation-screen-library → sidebar-navigation-screen-patterns}/use-pattern-categories.js +11 -19
- package/build/components/sidebar-navigation-screen-patterns/use-pattern-categories.js.map +1 -0
- package/build/components/sidebar-navigation-screen-patterns/use-template-part-areas.js +52 -0
- package/build/components/sidebar-navigation-screen-patterns/use-template-part-areas.js.map +1 -0
- package/build/components/{sidebar-navigation-screen-library → sidebar-navigation-screen-patterns}/use-theme-patterns.js +2 -2
- package/build/components/sidebar-navigation-screen-patterns/use-theme-patterns.js.map +1 -0
- package/build/components/sidebar-navigation-screen-templates/index.js +11 -63
- package/build/components/sidebar-navigation-screen-templates/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-templates-browse/index.js +4 -2
- package/build/components/sidebar-navigation-screen-templates-browse/index.js.map +1 -1
- package/build/components/site-hub/index.js +25 -12
- 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-path-with-url.js +16 -13
- package/build/components/sync-state-with-url/use-sync-path-with-url.js.map +1 -1
- package/build/components/template-actions/index.js +25 -7
- 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/components/welcome-guide/editor.js +1 -1
- package/build/components/welcome-guide/editor.js.map +1 -1
- package/build/components/welcome-guide/index.js +5 -1
- package/build/components/welcome-guide/index.js.map +1 -1
- package/build/components/welcome-guide/page.js +70 -0
- package/build/components/welcome-guide/page.js.map +1 -0
- package/build/components/welcome-guide/styles.js +1 -1
- package/build/components/welcome-guide/styles.js.map +1 -1
- package/build/components/welcome-guide/template.js +71 -0
- package/build/components/welcome-guide/template.js.map +1 -0
- package/build/hooks/commands/use-common-commands.js +115 -20
- package/build/hooks/commands/use-common-commands.js.map +1 -1
- package/build/hooks/commands/use-edit-mode-commands.js +195 -44
- package/build/hooks/commands/use-edit-mode-commands.js.map +1 -1
- package/build/hooks/push-changes-to-global-styles/index.js +56 -10
- package/build/hooks/push-changes-to-global-styles/index.js.map +1 -1
- package/build/index.js +9 -0
- package/build/index.js.map +1 -1
- package/build/store/actions.js +5 -2
- package/build/store/actions.js.map +1 -1
- package/build/store/private-actions.js +7 -1
- package/build/store/private-actions.js.map +1 -1
- package/build/store/selectors.js +2 -1
- package/build/store/selectors.js.map +1 -1
- package/build/utils/get-is-list-page.js +2 -2
- package/build/utils/get-is-list-page.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/template-part-create.js +2 -2
- package/build/utils/template-part-create.js.map +1 -1
- package/build/utils/use-activate-theme.js +1 -1
- package/build/utils/use-activate-theme.js.map +1 -1
- package/build-module/components/add-new-page/index.js +2 -12
- package/build-module/components/add-new-page/index.js.map +1 -1
- package/build-module/components/add-new-pattern/index.js +28 -16
- package/build-module/components/add-new-pattern/index.js.map +1 -1
- package/build-module/components/add-new-template/add-custom-generic-template-modal-content.js +1 -1
- package/build-module/components/add-new-template/add-custom-generic-template-modal-content.js.map +1 -1
- package/build-module/components/add-new-template/new-template.js +72 -17
- package/build-module/components/add-new-template/new-template.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/inserter-media-categories.js +1 -22
- package/build-module/components/block-editor/inserter-media-categories.js.map +1 -1
- package/build-module/components/block-editor/site-editor-canvas.js +29 -32
- package/build-module/components/block-editor/site-editor-canvas.js.map +1 -1
- package/build-module/components/block-editor/use-site-editor-settings.js +92 -20
- package/build-module/components/block-editor/use-site-editor-settings.js.map +1 -1
- package/build-module/components/canvas-spinner/index.js +1 -15
- package/build-module/components/canvas-spinner/index.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 +14 -11
- package/build-module/components/create-pattern-modal/index.js.map +1 -1
- package/build-module/components/create-template-part-modal/index.js +1 -1
- package/build-module/components/create-template-part-modal/index.js.map +1 -1
- package/build-module/components/editor/index.js +11 -1
- package/build-module/components/editor/index.js.map +1 -1
- package/build-module/components/global-styles/palette.js +1 -1
- package/build-module/components/global-styles/palette.js.map +1 -1
- package/build-module/components/global-styles/ui.js +8 -3
- package/build-module/components/global-styles/ui.js.map +1 -1
- package/build-module/components/header-edit-mode/document-actions/index.js +10 -2
- package/build-module/components/header-edit-mode/document-actions/index.js.map +1 -1
- package/build-module/components/header-edit-mode/index.js +51 -16
- package/build-module/components/header-edit-mode/index.js.map +1 -1
- package/build-module/components/header-edit-mode/more-menu/index.js +44 -20
- package/build-module/components/header-edit-mode/more-menu/index.js.map +1 -1
- package/build-module/components/keyboard-shortcut-help-modal/index.js +15 -6
- package/build-module/components/keyboard-shortcut-help-modal/index.js.map +1 -1
- package/build-module/components/keyboard-shortcuts/edit-mode.js +29 -1
- package/build-module/components/keyboard-shortcuts/edit-mode.js.map +1 -1
- package/build-module/components/keyboard-shortcuts/register.js +9 -0
- package/build-module/components/keyboard-shortcuts/register.js.map +1 -1
- package/build-module/components/layout/index.js +110 -28
- package/build-module/components/layout/index.js.map +1 -1
- package/build-module/components/page/header.js +1 -1
- package/build-module/components/page/header.js.map +1 -1
- package/build-module/components/page/index.js +2 -1
- 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 -16
- package/build-module/components/page-actions/trash-page-menu-item.js.map +1 -0
- package/build-module/components/page-content-focus-manager/back-to-page-notification.js +9 -3
- package/build-module/components/page-content-focus-manager/back-to-page-notification.js.map +1 -1
- 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-main/index.js +6 -3
- package/build-module/components/page-main/index.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 +195 -0
- package/build-module/components/page-patterns/grid-item.js.map +1 -0
- package/build-module/components/page-patterns/grid.js +26 -0
- package/build-module/components/page-patterns/grid.js.map +1 -0
- 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-library → page-patterns}/index.js +8 -6
- package/build-module/components/page-patterns/index.js.map +1 -0
- package/build-module/components/{page-library → page-patterns}/no-patterns.js +1 -1
- package/build-module/components/page-patterns/no-patterns.js.map +1 -0
- 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 +152 -0
- package/build-module/components/page-patterns/patterns-list.js.map +1 -0
- 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/search-items.js.map +1 -0
- package/build-module/components/{page-library/use-library-settings.js → page-patterns/use-pattern-settings.js} +2 -2
- package/build-module/components/page-patterns/use-pattern-settings.js.map +1 -0
- package/build-module/components/page-patterns/use-patterns.js +167 -0
- package/build-module/components/page-patterns/use-patterns.js.map +1 -0
- package/build-module/components/{page-library → page-patterns}/utils.js +3 -3
- package/build-module/components/page-patterns/utils.js.map +1 -0
- 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 +63 -0
- package/build-module/components/page-template-parts/index.js.map +1 -0
- package/build-module/components/page-templates/index.js +1 -0
- package/build-module/components/page-templates/index.js.map +1 -1
- package/build-module/components/preferences-modal/enable-feature.js +5 -1
- package/build-module/components/preferences-modal/enable-feature.js.map +1 -1
- package/build-module/components/preferences-modal/index.js +38 -5
- package/build-module/components/preferences-modal/index.js.map +1 -1
- package/build-module/components/resizable-frame/index.js +79 -39
- package/build-module/components/resizable-frame/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/index.js +5 -5
- package/build-module/components/sidebar/index.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/index.js +4 -2
- package/build-module/components/sidebar-edit-mode/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/settings-header/index.js +6 -1
- package/build-module/components/sidebar-edit-mode/settings-header/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen/index.js +22 -12
- package/build-module/components/sidebar-navigation-screen/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-global-styles/index.js +67 -5
- package/build-module/components/sidebar-navigation-screen-global-styles/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-main/index.js +5 -4
- 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/delete-modal.js +8 -17
- package/build-module/components/sidebar-navigation-screen-navigation-menu/delete-modal.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menu/edit-button.js +10 -9
- package/build-module/components/sidebar-navigation-screen-navigation-menu/edit-button.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menu/index.js +9 -10
- 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/rename-modal.js +11 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menu/rename-modal.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menu/single-navigation-menu.js +8 -4
- 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 +9 -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/build-navigation-label.js +20 -0
- package/build-module/components/sidebar-navigation-screen-navigation-menus/build-navigation-label.js.map +1 -0
- 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 +26 -6
- package/build-module/components/sidebar-navigation-screen-navigation-menus/index.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/page-details.js +11 -4
- package/build-module/components/sidebar-navigation-screen-page/page-details.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-page/status-label.js +2 -33
- package/build-module/components/sidebar-navigation-screen-page/status-label.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-pages/index.js +34 -26
- package/build-module/components/sidebar-navigation-screen-pages/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-pattern/index.js +18 -12
- 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 +11 -3
- 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 +25 -2
- package/build-module/components/sidebar-navigation-screen-pattern/use-pattern-details.js.map +1 -1
- package/build-module/components/{sidebar-navigation-screen-library → sidebar-navigation-screen-patterns}/category-item.js +4 -4
- package/build-module/components/sidebar-navigation-screen-patterns/category-item.js.map +1 -0
- package/build-module/components/sidebar-navigation-screen-patterns/index.js +148 -0
- package/build-module/components/sidebar-navigation-screen-patterns/index.js.map +1 -0
- package/build-module/components/sidebar-navigation-screen-patterns/use-default-pattern-categories.js.map +1 -0
- package/build-module/components/sidebar-navigation-screen-patterns/use-my-patterns.js +24 -0
- package/build-module/components/sidebar-navigation-screen-patterns/use-my-patterns.js.map +1 -0
- package/build-module/components/{sidebar-navigation-screen-library → sidebar-navigation-screen-patterns}/use-pattern-categories.js +11 -17
- package/build-module/components/sidebar-navigation-screen-patterns/use-pattern-categories.js.map +1 -0
- package/build-module/components/sidebar-navigation-screen-patterns/use-template-part-areas.js +43 -0
- package/build-module/components/sidebar-navigation-screen-patterns/use-template-part-areas.js.map +1 -0
- package/build-module/components/{sidebar-navigation-screen-library → sidebar-navigation-screen-patterns}/use-theme-patterns.js +2 -2
- package/build-module/components/sidebar-navigation-screen-patterns/use-theme-patterns.js.map +1 -0
- package/build-module/components/sidebar-navigation-screen-templates/index.js +12 -62
- package/build-module/components/sidebar-navigation-screen-templates/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-templates-browse/index.js +4 -2
- package/build-module/components/sidebar-navigation-screen-templates-browse/index.js.map +1 -1
- package/build-module/components/site-hub/index.js +25 -12
- 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-path-with-url.js +17 -13
- 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 +26 -8
- 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/components/welcome-guide/editor.js +1 -1
- package/build-module/components/welcome-guide/editor.js.map +1 -1
- package/build-module/components/welcome-guide/index.js +3 -1
- package/build-module/components/welcome-guide/index.js.map +1 -1
- package/build-module/components/welcome-guide/page.js +59 -0
- package/build-module/components/welcome-guide/page.js.map +1 -0
- package/build-module/components/welcome-guide/styles.js +1 -1
- package/build-module/components/welcome-guide/styles.js.map +1 -1
- package/build-module/components/welcome-guide/template.js +60 -0
- package/build-module/components/welcome-guide/template.js.map +1 -0
- package/build-module/hooks/commands/use-common-commands.js +111 -21
- package/build-module/hooks/commands/use-common-commands.js.map +1 -1
- package/build-module/hooks/commands/use-edit-mode-commands.js +193 -46
- package/build-module/hooks/commands/use-edit-mode-commands.js.map +1 -1
- package/build-module/hooks/push-changes-to-global-styles/index.js +57 -10
- package/build-module/hooks/push-changes-to-global-styles/index.js.map +1 -1
- package/build-module/index.js +4 -0
- package/build-module/index.js.map +1 -1
- package/build-module/store/actions.js +5 -2
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/private-actions.js +7 -1
- package/build-module/store/private-actions.js.map +1 -1
- package/build-module/store/selectors.js +2 -1
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/get-is-list-page.js +2 -2
- package/build-module/utils/get-is-list-page.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/template-part-create.js +1 -1
- package/build-module/utils/template-part-create.js.map +1 -1
- package/build-module/utils/use-activate-theme.js +1 -1
- package/build-module/utils/use-activate-theme.js.map +1 -1
- package/build-style/style-rtl.css +383 -109
- package/build-style/style.css +383 -109
- package/package.json +39 -40
- package/src/components/add-new-page/index.js +1 -9
- package/src/components/add-new-pattern/index.js +30 -21
- package/src/components/add-new-template/add-custom-generic-template-modal-content.js +1 -1
- package/src/components/add-new-template/new-template.js +120 -24
- package/src/components/add-new-template/style.scss +30 -2
- 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 +3 -1
- package/src/components/block-editor/index.js +0 -4
- package/src/components/block-editor/inserter-media-categories.js +1 -21
- package/src/components/block-editor/site-editor-canvas.js +7 -1
- package/src/components/block-editor/use-site-editor-settings.js +100 -25
- package/src/components/canvas-spinner/index.js +1 -11
- package/src/components/canvas-spinner/style.scss +18 -0
- package/src/components/code-editor/index.js +51 -33
- package/src/components/create-pattern-modal/index.js +15 -13
- package/src/components/create-template-part-modal/index.js +1 -1
- package/src/components/editor/index.js +16 -1
- package/src/components/editor/style.scss +4 -0
- package/src/components/global-styles/palette.js +10 -9
- package/src/components/global-styles/stories/index.js +1 -0
- package/src/components/global-styles/ui.js +34 -24
- package/src/components/header-edit-mode/document-actions/index.js +9 -1
- package/src/components/header-edit-mode/document-actions/style.scss +12 -0
- package/src/components/header-edit-mode/index.js +136 -79
- package/src/components/header-edit-mode/more-menu/index.js +74 -30
- package/src/components/keyboard-shortcut-help-modal/index.js +21 -7
- package/src/components/keyboard-shortcuts/edit-mode.js +35 -2
- package/src/components/keyboard-shortcuts/register.js +10 -0
- package/src/components/layout/index.js +156 -78
- package/src/components/layout/style.scss +49 -2
- package/src/components/page/header.js +1 -1
- package/src/components/page/index.js +5 -1
- 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 -21
- package/src/components/page-content-focus-manager/back-to-page-notification.js +7 -2
- package/src/components/page-content-focus-manager/disable-non-page-content-blocks.js +12 -3
- package/src/components/page-main/index.js +6 -3
- package/src/components/page-patterns/duplicate-menu-item.js +196 -0
- package/src/components/page-patterns/grid-item.js +284 -0
- package/src/components/page-patterns/grid.js +22 -0
- package/src/components/page-patterns/header.js +69 -0
- package/src/components/{page-library → page-patterns}/index.js +11 -6
- package/src/components/{page-library → page-patterns}/no-patterns.js +1 -1
- package/src/components/page-patterns/pagination.js +80 -0
- package/src/components/page-patterns/patterns-list.js +206 -0
- package/src/components/page-patterns/rename-menu-item.js +115 -0
- package/src/components/page-patterns/style.scss +219 -0
- package/src/components/{page-library/use-library-settings.js → page-patterns/use-pattern-settings.js} +1 -1
- package/src/components/page-patterns/use-patterns.js +177 -0
- package/src/components/{page-library → page-patterns}/utils.js +3 -3
- package/src/components/page-template-parts/add-new-template-part.js +57 -0
- package/src/components/page-template-parts/index.js +86 -0
- package/src/components/page-templates/index.js +1 -1
- package/src/components/preferences-modal/enable-feature.js +5 -2
- package/src/components/preferences-modal/index.js +35 -4
- package/src/components/resizable-frame/index.js +102 -34
- package/src/components/resizable-frame/style.scss +9 -9
- package/src/components/save-panel/index.js +10 -4
- package/src/components/sidebar/index.js +6 -6
- package/src/components/sidebar-button/style.scss +1 -1
- package/src/components/sidebar-edit-mode/index.js +4 -2
- 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/settings-header/index.js +7 -2
- package/src/components/sidebar-navigation-item/style.scss +7 -13
- package/src/components/sidebar-navigation-screen/index.js +18 -9
- package/src/components/sidebar-navigation-screen/style.scss +21 -2
- package/src/components/sidebar-navigation-screen-details-panel/style.scss +1 -1
- package/src/components/sidebar-navigation-screen-global-styles/index.js +57 -17
- 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/delete-modal.js +14 -35
- package/src/components/sidebar-navigation-screen-navigation-menu/edit-button.js +8 -11
- package/src/components/sidebar-navigation-screen-navigation-menu/index.js +13 -11
- package/src/components/sidebar-navigation-screen-navigation-menu/more-menu.js +1 -0
- package/src/components/sidebar-navigation-screen-navigation-menu/rename-modal.js +12 -1
- package/src/components/sidebar-navigation-screen-navigation-menu/single-navigation-menu.js +16 -7
- package/src/components/sidebar-navigation-screen-navigation-menu/style.scss +2 -7
- package/src/components/sidebar-navigation-screen-navigation-menu/use-navigation-menu-handlers.js +20 -6
- package/src/components/sidebar-navigation-screen-navigation-menus/build-navigation-label.js +24 -0
- package/src/components/sidebar-navigation-screen-navigation-menus/constants.js +2 -0
- package/src/components/sidebar-navigation-screen-navigation-menus/index.js +39 -8
- package/src/components/sidebar-navigation-screen-page/index.js +3 -3
- package/src/components/sidebar-navigation-screen-page/page-details.js +8 -3
- package/src/components/sidebar-navigation-screen-page/status-label.js +2 -36
- package/src/components/sidebar-navigation-screen-pages/index.js +40 -30
- package/src/components/sidebar-navigation-screen-pattern/index.js +18 -8
- package/src/components/sidebar-navigation-screen-pattern/style.scss +29 -0
- 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 +12 -2
- package/src/components/sidebar-navigation-screen-pattern/use-pattern-details.js +48 -3
- package/src/components/{sidebar-navigation-screen-library → sidebar-navigation-screen-patterns}/category-item.js +4 -4
- package/src/components/sidebar-navigation-screen-patterns/index.js +194 -0
- package/src/components/sidebar-navigation-screen-patterns/style.scss +23 -0
- package/src/components/sidebar-navigation-screen-patterns/use-my-patterns.js +24 -0
- package/src/components/{sidebar-navigation-screen-library → sidebar-navigation-screen-patterns}/use-pattern-categories.js +9 -17
- package/src/components/sidebar-navigation-screen-patterns/use-template-part-areas.js +55 -0
- package/src/components/{sidebar-navigation-screen-library → sidebar-navigation-screen-patterns}/use-theme-patterns.js +3 -2
- package/src/components/sidebar-navigation-screen-template/style.scss +15 -15
- package/src/components/sidebar-navigation-screen-templates/index.js +15 -82
- package/src/components/sidebar-navigation-screen-templates-browse/index.js +2 -0
- package/src/components/site-hub/index.js +46 -29
- package/src/components/site-hub/style.scss +17 -3
- package/src/components/start-template-options/style.scss +0 -3
- 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-path-with-url.js +73 -66
- package/src/components/template-actions/index.js +40 -9
- package/src/components/template-actions/rename-menu-item.js +17 -10
- package/src/components/use-edited-entity-record/index.js +6 -1
- package/src/components/welcome-guide/editor.js +1 -1
- package/src/components/welcome-guide/index.js +4 -0
- package/src/components/welcome-guide/page.js +75 -0
- package/src/components/welcome-guide/style.scss +15 -1
- package/src/components/welcome-guide/styles.js +1 -1
- package/src/components/welcome-guide/template.js +82 -0
- package/src/hooks/commands/use-common-commands.js +88 -24
- package/src/hooks/commands/use-edit-mode-commands.js +182 -38
- package/src/hooks/push-changes-to-global-styles/index.js +63 -9
- package/src/index.js +4 -0
- package/src/store/actions.js +8 -1
- package/src/store/private-actions.js +5 -1
- package/src/store/selectors.js +5 -0
- package/src/store/test/selectors.js +2 -0
- package/src/style.scss +13 -14
- package/src/utils/get-is-list-page.js +4 -3
- package/src/utils/normalize-record-key.js +11 -0
- package/src/utils/template-part-create.js +1 -1
- package/src/utils/use-activate-theme.js +1 -1
- 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/components/page-library/grid-item.js +0 -165
- package/build/components/page-library/grid-item.js.map +0 -1
- package/build/components/page-library/grid.js.map +0 -1
- package/build/components/page-library/index.js.map +0 -1
- package/build/components/page-library/no-patterns.js.map +0 -1
- package/build/components/page-library/patterns-list.js +0 -108
- package/build/components/page-library/patterns-list.js.map +0 -1
- package/build/components/page-library/search-items.js.map +0 -1
- package/build/components/page-library/use-library-settings.js.map +0 -1
- package/build/components/page-library/use-patterns.js +0 -194
- package/build/components/page-library/use-patterns.js.map +0 -1
- package/build/components/page-library/utils.js.map +0 -1
- package/build/components/sidebar-navigation-screen-library/category-item.js.map +0 -1
- package/build/components/sidebar-navigation-screen-library/index.js +0 -112
- package/build/components/sidebar-navigation-screen-library/index.js.map +0 -1
- package/build/components/sidebar-navigation-screen-library/use-default-pattern-categories.js.map +0 -1
- package/build/components/sidebar-navigation-screen-library/use-pattern-categories.js.map +0 -1
- package/build/components/sidebar-navigation-screen-library/use-template-part-areas.js +0 -41
- package/build/components/sidebar-navigation-screen-library/use-template-part-areas.js.map +0 -1
- package/build/components/sidebar-navigation-screen-library/use-theme-patterns.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/build-module/components/page-library/grid-item.js +0 -145
- package/build-module/components/page-library/grid-item.js.map +0 -1
- package/build-module/components/page-library/grid.js +0 -38
- package/build-module/components/page-library/grid.js.map +0 -1
- package/build-module/components/page-library/index.js.map +0 -1
- package/build-module/components/page-library/no-patterns.js.map +0 -1
- package/build-module/components/page-library/patterns-list.js +0 -87
- package/build-module/components/page-library/patterns-list.js.map +0 -1
- package/build-module/components/page-library/search-items.js.map +0 -1
- package/build-module/components/page-library/use-library-settings.js.map +0 -1
- package/build-module/components/page-library/use-patterns.js +0 -176
- package/build-module/components/page-library/use-patterns.js.map +0 -1
- package/build-module/components/page-library/utils.js.map +0 -1
- package/build-module/components/sidebar-navigation-screen-library/category-item.js.map +0 -1
- package/build-module/components/sidebar-navigation-screen-library/index.js +0 -87
- package/build-module/components/sidebar-navigation-screen-library/index.js.map +0 -1
- package/build-module/components/sidebar-navigation-screen-library/use-default-pattern-categories.js.map +0 -1
- package/build-module/components/sidebar-navigation-screen-library/use-pattern-categories.js.map +0 -1
- package/build-module/components/sidebar-navigation-screen-library/use-template-part-areas.js +0 -34
- package/build-module/components/sidebar-navigation-screen-library/use-template-part-areas.js.map +0 -1
- package/build-module/components/sidebar-navigation-screen-library/use-theme-patterns.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/src/components/page-library/grid-item.js +0 -179
- package/src/components/page-library/grid.js +0 -39
- package/src/components/page-library/patterns-list.js +0 -114
- package/src/components/page-library/style.scss +0 -105
- package/src/components/page-library/use-patterns.js +0 -238
- package/src/components/sidebar-navigation-screen-library/index.js +0 -136
- package/src/components/sidebar-navigation-screen-library/style.scss +0 -7
- package/src/components/sidebar-navigation-screen-library/use-template-part-areas.js +0 -33
- /package/build/components/{page-library → page-patterns}/search-items.js +0 -0
- /package/build/components/{sidebar-navigation-screen-library → sidebar-navigation-screen-patterns}/use-default-pattern-categories.js +0 -0
- /package/build-module/components/{page-library → page-patterns}/search-items.js +0 -0
- /package/build-module/components/{sidebar-navigation-screen-library → sidebar-navigation-screen-patterns}/use-default-pattern-categories.js +0 -0
- /package/src/components/{page-library → page-patterns}/search-items.js +0 -0
- /package/src/components/{sidebar-navigation-screen-library → sidebar-navigation-screen-patterns}/use-default-pattern-categories.js +0 -0
|
@@ -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;AAEA;AACA;AACA;;AACA,SACCC,cADD,EAECC,QAFD,EAGC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AE8B,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"]}
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import { createElement } from "@wordpress/element";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* External dependencies
|
|
5
|
+
*/
|
|
6
|
+
import classnames from 'classnames';
|
|
7
|
+
/**
|
|
8
|
+
* WordPress dependencies
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { BlockPreview } from '@wordpress/block-editor';
|
|
12
|
+
import { Button, __experimentalConfirmDialog as ConfirmDialog, DropdownMenu, MenuGroup, MenuItem, __experimentalHeading as Heading, __experimentalHStack as HStack, Tooltip, Flex } from '@wordpress/components';
|
|
13
|
+
import { useDispatch } from '@wordpress/data';
|
|
14
|
+
import { useState, useId, memo } from '@wordpress/element';
|
|
15
|
+
import { __, sprintf } from '@wordpress/i18n';
|
|
16
|
+
import { Icon, header, footer, symbolFilled as uncategorized, symbol, moreHorizontal, lockSmall } from '@wordpress/icons';
|
|
17
|
+
import { store as noticesStore } from '@wordpress/notices';
|
|
18
|
+
import { store as reusableBlocksStore } from '@wordpress/reusable-blocks';
|
|
19
|
+
/**
|
|
20
|
+
* Internal dependencies
|
|
21
|
+
*/
|
|
22
|
+
|
|
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';
|
|
27
|
+
import { useLink } from '../routes/link';
|
|
28
|
+
const templatePartIcons = {
|
|
29
|
+
header,
|
|
30
|
+
footer,
|
|
31
|
+
uncategorized
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
function GridItem({
|
|
35
|
+
categoryId,
|
|
36
|
+
item,
|
|
37
|
+
...props
|
|
38
|
+
}) {
|
|
39
|
+
const descriptionId = useId();
|
|
40
|
+
const [isDeleteDialogOpen, setIsDeleteDialogOpen] = useState(false);
|
|
41
|
+
const {
|
|
42
|
+
removeTemplate
|
|
43
|
+
} = useDispatch(editSiteStore);
|
|
44
|
+
const {
|
|
45
|
+
__experimentalDeleteReusableBlock
|
|
46
|
+
} = useDispatch(reusableBlocksStore);
|
|
47
|
+
const {
|
|
48
|
+
createErrorNotice,
|
|
49
|
+
createSuccessNotice
|
|
50
|
+
} = useDispatch(noticesStore);
|
|
51
|
+
const isUserPattern = item.type === USER_PATTERNS;
|
|
52
|
+
const isNonUserPattern = item.type === PATTERNS;
|
|
53
|
+
const isTemplatePart = item.type === TEMPLATE_PARTS;
|
|
54
|
+
const {
|
|
55
|
+
onClick
|
|
56
|
+
} = useLink({
|
|
57
|
+
postType: item.type,
|
|
58
|
+
postId: isUserPattern ? item.id : item.name,
|
|
59
|
+
categoryId,
|
|
60
|
+
categoryType: item.type
|
|
61
|
+
});
|
|
62
|
+
const isEmpty = !item.blocks?.length;
|
|
63
|
+
const patternClassNames = classnames('edit-site-patterns__pattern', {
|
|
64
|
+
'is-placeholder': isEmpty
|
|
65
|
+
});
|
|
66
|
+
const previewClassNames = classnames('edit-site-patterns__preview', {
|
|
67
|
+
'is-inactive': isNonUserPattern
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
const deletePattern = async () => {
|
|
71
|
+
try {
|
|
72
|
+
await __experimentalDeleteReusableBlock(item.id);
|
|
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'
|
|
77
|
+
});
|
|
78
|
+
} catch (error) {
|
|
79
|
+
const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : __('An error occurred while deleting the pattern.');
|
|
80
|
+
createErrorNotice(errorMessage, {
|
|
81
|
+
type: 'snackbar',
|
|
82
|
+
id: 'edit-site-patterns-error'
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
|
|
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;
|
|
92
|
+
const ariaDescriptions = [];
|
|
93
|
+
|
|
94
|
+
if (isCustomPattern) {
|
|
95
|
+
// User patterns don't have descriptions, but can be edited and deleted, so include some help text.
|
|
96
|
+
ariaDescriptions.push(__('Press Enter to edit, or Delete to delete the pattern.'));
|
|
97
|
+
} else if (item.description) {
|
|
98
|
+
ariaDescriptions.push(item.description);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (isNonUserPattern) {
|
|
102
|
+
ariaDescriptions.push(__('Theme & plugin patterns cannot be edited.'));
|
|
103
|
+
}
|
|
104
|
+
|
|
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", {
|
|
110
|
+
className: patternClassNames
|
|
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,
|
|
117
|
+
onClick: item.type !== PATTERNS ? onClick : undefined,
|
|
118
|
+
"aria-disabled": item.type !== PATTERNS ? 'false' : 'true',
|
|
119
|
+
"aria-label": item.title,
|
|
120
|
+
"aria-describedby": ariaDescriptions.length ? ariaDescriptions.map((_, index) => `${descriptionId}-${index}`).join(' ') : undefined
|
|
121
|
+
}, isEmpty && __('Empty pattern'), !isEmpty && createElement(BlockPreview, {
|
|
122
|
+
blocks: item.blocks
|
|
123
|
+
})), ariaDescriptions.map((ariaDescription, index) => createElement("div", {
|
|
124
|
+
key: index,
|
|
125
|
+
hidden: true,
|
|
126
|
+
id: `${descriptionId}-${index}`
|
|
127
|
+
}, ariaDescription)), createElement(HStack, {
|
|
128
|
+
className: "edit-site-patterns__footer",
|
|
129
|
+
justify: "space-between"
|
|
130
|
+
}, createElement(HStack, {
|
|
131
|
+
alignment: "center",
|
|
132
|
+
justify: "left",
|
|
133
|
+
spacing: 3,
|
|
134
|
+
className: "edit-site-patterns__pattern-title"
|
|
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, {
|
|
139
|
+
className: "edit-site-patterns__pattern-icon",
|
|
140
|
+
icon: itemIcon
|
|
141
|
+
}))), createElement(Flex, {
|
|
142
|
+
as: "span",
|
|
143
|
+
gap: 0,
|
|
144
|
+
justify: "left"
|
|
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, {
|
|
154
|
+
position: "top center",
|
|
155
|
+
text: __('This pattern cannot be edited.')
|
|
156
|
+
}, createElement("span", {
|
|
157
|
+
className: "edit-site-patterns__pattern-lock-icon"
|
|
158
|
+
}, createElement(Icon, {
|
|
159
|
+
icon: lockSmall,
|
|
160
|
+
size: 24
|
|
161
|
+
}))))), createElement(DropdownMenu, {
|
|
162
|
+
icon: moreHorizontal,
|
|
163
|
+
label: __('Actions'),
|
|
164
|
+
className: "edit-site-patterns__dropdown",
|
|
165
|
+
popoverProps: {
|
|
166
|
+
placement: 'bottom-end'
|
|
167
|
+
},
|
|
168
|
+
toggleProps: {
|
|
169
|
+
className: 'edit-site-patterns__button',
|
|
170
|
+
isSmall: true,
|
|
171
|
+
describedBy: sprintf(
|
|
172
|
+
/* translators: %s: pattern name */
|
|
173
|
+
__('Action menu for %s pattern'), item.title)
|
|
174
|
+
}
|
|
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, {
|
|
186
|
+
onClick: () => setIsDeleteDialogOpen(true)
|
|
187
|
+
}, hasThemeFile ? __('Clear customizations') : __('Delete'))))), isDeleteDialogOpen && createElement(ConfirmDialog, {
|
|
188
|
+
confirmButtonText: confirmButtonText,
|
|
189
|
+
onConfirm: deleteItem,
|
|
190
|
+
onCancel: () => setIsDeleteDialogOpen(false)
|
|
191
|
+
}, confirmPrompt));
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
export default memo(GridItem);
|
|
195
|
+
//# sourceMappingURL=grid-item.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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,YAHD,EAICC,SAJD,EAKCC,QALD,EAMCC,qBAAqB,IAAIC,OAN1B,EAOCC,oBAAoB,IAAIC,MAPzB,EAQCC,OARD,EASCC,IATD,QAUO,uBAVP;AAWA,SAASC,WAAT,QAA4B,iBAA5B;AACA,SAASC,QAAT,EAAmBC,KAAnB,EAA0BC,IAA1B,QAAsC,oBAAtC;AACA,SAASC,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SACCC,IADD,EAECC,MAFD,EAGCC,MAHD,EAICC,YAAY,IAAIC,aAJjB,EAKCC,MALD,EAMCC,cAND,EAOCC,SAPD,QAQO,kBARP;AASA,SAASC,KAAK,IAAIC,YAAlB,QAAsC,oBAAtC;AACA,SAASD,KAAK,IAAIE,mBAAlB,QAA6C,4BAA7C;AAEA;AACA;AACA;;AACA,OAAOC,cAAP,MAA2B,oBAA3B;AACA,OAAOC,iBAAP,MAA8B,uBAA9B;AACA,SAASC,QAAT,EAAmBC,cAAnB,EAAmCC,aAAnC,EAAkDC,UAAlD,QAAoE,SAApE;AACA,SAASR,KAAK,IAAIS,aAAlB,QAAuC,aAAvC;AACA,SAASC,OAAT,QAAwB,gBAAxB;AAEA,MAAMC,iBAAiB,GAAG;AAAElB,EAAAA,MAAF;AAAUC,EAAAA,MAAV;AAAkBE,EAAAA;AAAlB,CAA1B;;AAEA,SAASgB,QAAT,CAAmB;AAAEC,EAAAA,UAAF;AAAcC,EAAAA,IAAd;AAAoB,KAAGC;AAAvB,CAAnB,EAAoD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S,EAAE;AAAb,KAJhB;AAKC,IAAA,WAAW,EAAG;AACbC,MAAAA,SAAS,EAAE,4BADE;AAEbC,MAAAA,OAAO,EAAE,IAFI;AAGbC,MAAAA,WAAW,EAAE5E,OAAO;AACnB;AACAD,MAAAA,EAAE,CAAE,4BAAF,CAFiB,EAGnBwB,IAAI,CAACyB,KAHc;AAHP;AALf,KAeG,CAAE;AAAE6B,IAAAA;AAAF,GAAF,KACD,cAAC,SAAD,QACGvB,eAAe,IAAI,CAAEE,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"]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { createElement } from "@wordpress/element";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Internal dependencies
|
|
5
|
+
*/
|
|
6
|
+
import GridItem from './grid-item';
|
|
7
|
+
export default function Grid({
|
|
8
|
+
categoryId,
|
|
9
|
+
items,
|
|
10
|
+
...props
|
|
11
|
+
}) {
|
|
12
|
+
if (!items?.length) {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return createElement("ul", {
|
|
17
|
+
role: "listbox",
|
|
18
|
+
className: "edit-site-patterns__grid",
|
|
19
|
+
...props
|
|
20
|
+
}, items.map(item => createElement(GridItem, {
|
|
21
|
+
key: item.name,
|
|
22
|
+
item: item,
|
|
23
|
+
categoryId: categoryId
|
|
24
|
+
})));
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=grid.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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"]}
|
|
@@ -13,29 +13,31 @@ import { getQueryArgs } from '@wordpress/url';
|
|
|
13
13
|
import { DEFAULT_CATEGORY, DEFAULT_TYPE } from './utils';
|
|
14
14
|
import Page from '../page';
|
|
15
15
|
import PatternsList from './patterns-list';
|
|
16
|
-
import
|
|
16
|
+
import usePatternSettings from './use-pattern-settings';
|
|
17
17
|
import { unlock } from '../../lock-unlock';
|
|
18
18
|
const {
|
|
19
19
|
ExperimentalBlockEditorProvider
|
|
20
20
|
} = unlock(blockEditorPrivateApis);
|
|
21
|
-
export default function
|
|
21
|
+
export default function PagePatterns() {
|
|
22
22
|
const {
|
|
23
23
|
categoryType,
|
|
24
24
|
categoryId
|
|
25
25
|
} = getQueryArgs(window.location.href);
|
|
26
26
|
const type = categoryType || DEFAULT_TYPE;
|
|
27
27
|
const category = categoryId || DEFAULT_CATEGORY;
|
|
28
|
-
const settings =
|
|
28
|
+
const settings = usePatternSettings(); // Wrap everything in a block editor provider.
|
|
29
29
|
// This ensures 'styles' that are needed for the previews are synced
|
|
30
30
|
// from the site editor store to the block editor store.
|
|
31
31
|
|
|
32
32
|
return createElement(ExperimentalBlockEditorProvider, {
|
|
33
33
|
settings: settings
|
|
34
34
|
}, createElement(Page, {
|
|
35
|
-
className: "edit-site-
|
|
36
|
-
title: __('
|
|
35
|
+
className: "edit-site-patterns",
|
|
36
|
+
title: __('Patterns content'),
|
|
37
37
|
hideTitleFromUI: true
|
|
38
|
-
}, createElement(PatternsList
|
|
38
|
+
}, createElement(PatternsList // Reset the states when switching between categories and types.
|
|
39
|
+
, {
|
|
40
|
+
key: `${type}-${category}`,
|
|
39
41
|
type: type,
|
|
40
42
|
categoryId: category
|
|
41
43
|
})));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/page-patterns/index.js"],"names":["__","privateApis","blockEditorPrivateApis","getQueryArgs","DEFAULT_CATEGORY","DEFAULT_TYPE","Page","PatternsList","usePatternSettings","unlock","ExperimentalBlockEditorProvider","PagePatterns","categoryType","categoryId","window","location","href","type","category","settings"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,EAAT,QAAmB,iBAAnB;AACA,SAASC,WAAW,IAAIC,sBAAxB,QAAsD,yBAAtD;AACA,SAASC,YAAT,QAA6B,gBAA7B;AAEA;AACA;AACA;;AACA,SAASC,gBAAT,EAA2BC,YAA3B,QAA+C,SAA/C;AACA,OAAOC,IAAP,MAAiB,SAAjB;AACA,OAAOC,YAAP,MAAyB,iBAAzB;AACA,OAAOC,kBAAP,MAA+B,wBAA/B;AACA,SAASC,MAAT,QAAuB,mBAAvB;AAEA,MAAM;AAAEC,EAAAA;AAAF,IAAsCD,MAAM,CAAEP,sBAAF,CAAlD;AAEA,eAAe,SAASS,YAAT,GAAwB;AACtC,QAAM;AAAEC,IAAAA,YAAF;AAAgBC,IAAAA;AAAhB,MAA+BV,YAAY,CAAEW,MAAM,CAACC,QAAP,CAAgBC,IAAlB,CAAjD;AACA,QAAMC,IAAI,GAAGL,YAAY,IAAIP,YAA7B;AACA,QAAMa,QAAQ,GAAGL,UAAU,IAAIT,gBAA/B;AACA,QAAMe,QAAQ,GAAGX,kBAAkB,EAAnC,CAJsC,CAMtC;AACA;AACA;;AACA,SACC,cAAC,+BAAD;AAAiC,IAAA,QAAQ,EAAGW;AAA5C,KACC,cAAC,IAAD;AACC,IAAA,SAAS,EAAC,oBADX;AAEC,IAAA,KAAK,EAAGnB,EAAE,CAAE,kBAAF,CAFX;AAGC,IAAA,eAAe;AAHhB,KAKC,cAAC,YAAD,CACC;AADD;AAEC,IAAA,GAAG,EAAI,GAAGiB,IAAM,IAAIC,QAAU,EAF/B;AAGC,IAAA,IAAI,EAAGD,IAHR;AAIC,IAAA,UAAU,EAAGC;AAJd,IALD,CADD,CADD;AAgBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';\nimport { getQueryArgs } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport { DEFAULT_CATEGORY, DEFAULT_TYPE } from './utils';\nimport Page from '../page';\nimport PatternsList from './patterns-list';\nimport usePatternSettings from './use-pattern-settings';\nimport { unlock } from '../../lock-unlock';\n\nconst { ExperimentalBlockEditorProvider } = unlock( blockEditorPrivateApis );\n\nexport default function PagePatterns() {\n\tconst { categoryType, categoryId } = getQueryArgs( window.location.href );\n\tconst type = categoryType || DEFAULT_TYPE;\n\tconst category = categoryId || DEFAULT_CATEGORY;\n\tconst settings = usePatternSettings();\n\n\t// Wrap everything in a block editor provider.\n\t// This ensures 'styles' that are needed for the previews are synced\n\t// from the site editor store to the block editor store.\n\treturn (\n\t\t<ExperimentalBlockEditorProvider settings={ settings }>\n\t\t\t<Page\n\t\t\t\tclassName=\"edit-site-patterns\"\n\t\t\t\ttitle={ __( 'Patterns content' ) }\n\t\t\t\thideTitleFromUI\n\t\t\t>\n\t\t\t\t<PatternsList\n\t\t\t\t\t// Reset the states when switching between categories and types.\n\t\t\t\t\tkey={ `${ type }-${ category }` }\n\t\t\t\t\ttype={ type }\n\t\t\t\t\tcategoryId={ category }\n\t\t\t\t/>\n\t\t\t</Page>\n\t\t</ExperimentalBlockEditorProvider>\n\t);\n}\n"]}
|
|
@@ -6,7 +6,7 @@ import { createElement } from "@wordpress/element";
|
|
|
6
6
|
import { __ } from '@wordpress/i18n';
|
|
7
7
|
export default function NoPatterns() {
|
|
8
8
|
return createElement("div", {
|
|
9
|
-
className: "edit-site-
|
|
9
|
+
className: "edit-site-patterns__no-results"
|
|
10
10
|
}, __('No patterns found.'));
|
|
11
11
|
}
|
|
12
12
|
//# sourceMappingURL=no-patterns.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/page-patterns/no-patterns.js"],"names":["__","NoPatterns"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,EAAT,QAAmB,iBAAnB;AAEA,eAAe,SAASC,UAAT,GAAsB;AACpC,SACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACGD,EAAE,CAAE,oBAAF,CADL,CADD;AAKA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\n\nexport default function NoPatterns() {\n\treturn (\n\t\t<div className=\"edit-site-patterns__no-results\">\n\t\t\t{ __( 'No patterns found.' ) }\n\t\t</div>\n\t);\n}\n"]}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { createElement } from "@wordpress/element";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* WordPress dependencies
|
|
5
|
+
*/
|
|
6
|
+
import { __experimentalHStack as HStack, __experimentalText as Text, Button } from '@wordpress/components';
|
|
7
|
+
import { __, _x, _n, sprintf } from '@wordpress/i18n';
|
|
8
|
+
export default function Pagination({
|
|
9
|
+
currentPage,
|
|
10
|
+
numPages,
|
|
11
|
+
changePage,
|
|
12
|
+
totalItems
|
|
13
|
+
}) {
|
|
14
|
+
return createElement(HStack, {
|
|
15
|
+
expanded: false,
|
|
16
|
+
spacing: 3,
|
|
17
|
+
justify: "flex-start",
|
|
18
|
+
className: "edit-site-patterns__grid-pagination"
|
|
19
|
+
}, createElement(Text, {
|
|
20
|
+
variant: "muted"
|
|
21
|
+
}, // translators: %s: Total number of patterns.
|
|
22
|
+
sprintf( // translators: %s: Total number of patterns.
|
|
23
|
+
_n('%s item', '%s items', totalItems), totalItems)), createElement(HStack, {
|
|
24
|
+
expanded: false,
|
|
25
|
+
spacing: 1
|
|
26
|
+
}, createElement(Button, {
|
|
27
|
+
variant: "tertiary",
|
|
28
|
+
onClick: () => changePage(1),
|
|
29
|
+
disabled: currentPage === 1,
|
|
30
|
+
"aria-label": __('First page')
|
|
31
|
+
}, "\xAB"), createElement(Button, {
|
|
32
|
+
variant: "tertiary",
|
|
33
|
+
onClick: () => changePage(currentPage - 1),
|
|
34
|
+
disabled: currentPage === 1,
|
|
35
|
+
"aria-label": __('Previous page')
|
|
36
|
+
}, "\u2039")), createElement(Text, {
|
|
37
|
+
variant: "muted"
|
|
38
|
+
}, sprintf( // translators: %1$s: Current page number, %2$s: Total number of pages.
|
|
39
|
+
_x('%1$s of %2$s', 'paging'), currentPage, numPages)), createElement(HStack, {
|
|
40
|
+
expanded: false,
|
|
41
|
+
spacing: 1
|
|
42
|
+
}, createElement(Button, {
|
|
43
|
+
variant: "tertiary",
|
|
44
|
+
onClick: () => changePage(currentPage + 1),
|
|
45
|
+
disabled: currentPage === numPages,
|
|
46
|
+
"aria-label": __('Next page')
|
|
47
|
+
}, "\u203A"), createElement(Button, {
|
|
48
|
+
variant: "tertiary",
|
|
49
|
+
onClick: () => changePage(numPages),
|
|
50
|
+
disabled: currentPage === numPages,
|
|
51
|
+
"aria-label": __('Last page')
|
|
52
|
+
}, "\xBB")));
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=pagination.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/page-patterns/pagination.js"],"names":["__experimentalHStack","HStack","__experimentalText","Text","Button","__","_x","_n","sprintf","Pagination","currentPage","numPages","changePage","totalItems"],"mappings":";;AAAA;AACA;AACA;AACA,SACCA,oBAAoB,IAAIC,MADzB,EAECC,kBAAkB,IAAIC,IAFvB,EAGCC,MAHD,QAIO,uBAJP;AAKA,SAASC,EAAT,EAAaC,EAAb,EAAiBC,EAAjB,EAAqBC,OAArB,QAAoC,iBAApC;AAEA,eAAe,SAASC,UAAT,CAAqB;AACnCC,EAAAA,WADmC;AAEnCC,EAAAA,QAFmC;AAGnCC,EAAAA,UAHmC;AAInCC,EAAAA;AAJmC,CAArB,EAKX;AACH,SACC,cAAC,MAAD;AACC,IAAA,QAAQ,EAAG,KADZ;AAEC,IAAA,OAAO,EAAG,CAFX;AAGC,IAAA,OAAO,EAAC,YAHT;AAIC,IAAA,SAAS,EAAC;AAJX,KAMC,cAAC,IAAD;AAAM,IAAA,OAAO,EAAC;AAAd,KAEE;AACAL,EAAAA,OAAO,EACN;AACAD,EAAAA,EAAE,CAAE,SAAF,EAAa,UAAb,EAAyBM,UAAzB,CAFI,EAGNA,UAHM,CAHT,CAND,EAgBC,cAAC,MAAD;AAAQ,IAAA,QAAQ,EAAG,KAAnB;AAA2B,IAAA,OAAO,EAAG;AAArC,KACC,cAAC,MAAD;AACC,IAAA,OAAO,EAAC,UADT;AAEC,IAAA,OAAO,EAAG,MAAMD,UAAU,CAAE,CAAF,CAF3B;AAGC,IAAA,QAAQ,EAAGF,WAAW,KAAK,CAH5B;AAIC,kBAAaL,EAAE,CAAE,YAAF;AAJhB,YADD,EASC,cAAC,MAAD;AACC,IAAA,OAAO,EAAC,UADT;AAEC,IAAA,OAAO,EAAG,MAAMO,UAAU,CAAEF,WAAW,GAAG,CAAhB,CAF3B;AAGC,IAAA,QAAQ,EAAGA,WAAW,KAAK,CAH5B;AAIC,kBAAaL,EAAE,CAAE,eAAF;AAJhB,cATD,CAhBD,EAkCC,cAAC,IAAD;AAAM,IAAA,OAAO,EAAC;AAAd,KACGG,OAAO,EACR;AACAF,EAAAA,EAAE,CAAE,cAAF,EAAkB,QAAlB,CAFM,EAGRI,WAHQ,EAIRC,QAJQ,CADV,CAlCD,EA0CC,cAAC,MAAD;AAAQ,IAAA,QAAQ,EAAG,KAAnB;AAA2B,IAAA,OAAO,EAAG;AAArC,KACC,cAAC,MAAD;AACC,IAAA,OAAO,EAAC,UADT;AAEC,IAAA,OAAO,EAAG,MAAMC,UAAU,CAAEF,WAAW,GAAG,CAAhB,CAF3B;AAGC,IAAA,QAAQ,EAAGA,WAAW,KAAKC,QAH5B;AAIC,kBAAaN,EAAE,CAAE,WAAF;AAJhB,cADD,EASC,cAAC,MAAD;AACC,IAAA,OAAO,EAAC,UADT;AAEC,IAAA,OAAO,EAAG,MAAMO,UAAU,CAAED,QAAF,CAF3B;AAGC,IAAA,QAAQ,EAAGD,WAAW,KAAKC,QAH5B;AAIC,kBAAaN,EAAE,CAAE,WAAF;AAJhB,YATD,CA1CD,CADD;AA+DA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalHStack as HStack,\n\t__experimentalText as Text,\n\tButton,\n} from '@wordpress/components';\nimport { __, _x, _n, sprintf } from '@wordpress/i18n';\n\nexport default function Pagination( {\n\tcurrentPage,\n\tnumPages,\n\tchangePage,\n\ttotalItems,\n} ) {\n\treturn (\n\t\t<HStack\n\t\t\texpanded={ false }\n\t\t\tspacing={ 3 }\n\t\t\tjustify=\"flex-start\"\n\t\t\tclassName=\"edit-site-patterns__grid-pagination\"\n\t\t>\n\t\t\t<Text variant=\"muted\">\n\t\t\t\t{\n\t\t\t\t\t// translators: %s: Total number of patterns.\n\t\t\t\t\tsprintf(\n\t\t\t\t\t\t// translators: %s: Total number of patterns.\n\t\t\t\t\t\t_n( '%s item', '%s items', totalItems ),\n\t\t\t\t\t\ttotalItems\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t</Text>\n\t\t\t<HStack expanded={ false } spacing={ 1 }>\n\t\t\t\t<Button\n\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\tonClick={ () => changePage( 1 ) }\n\t\t\t\t\tdisabled={ currentPage === 1 }\n\t\t\t\t\taria-label={ __( 'First page' ) }\n\t\t\t\t>\n\t\t\t\t\t«\n\t\t\t\t</Button>\n\t\t\t\t<Button\n\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\tonClick={ () => changePage( currentPage - 1 ) }\n\t\t\t\t\tdisabled={ currentPage === 1 }\n\t\t\t\t\taria-label={ __( 'Previous page' ) }\n\t\t\t\t>\n\t\t\t\t\t‹\n\t\t\t\t</Button>\n\t\t\t</HStack>\n\t\t\t<Text variant=\"muted\">\n\t\t\t\t{ sprintf(\n\t\t\t\t\t// translators: %1$s: Current page number, %2$s: Total number of pages.\n\t\t\t\t\t_x( '%1$s of %2$s', 'paging' ),\n\t\t\t\t\tcurrentPage,\n\t\t\t\t\tnumPages\n\t\t\t\t) }\n\t\t\t</Text>\n\t\t\t<HStack expanded={ false } spacing={ 1 }>\n\t\t\t\t<Button\n\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\tonClick={ () => changePage( currentPage + 1 ) }\n\t\t\t\t\tdisabled={ currentPage === numPages }\n\t\t\t\t\taria-label={ __( 'Next page' ) }\n\t\t\t\t>\n\t\t\t\t\t›\n\t\t\t\t</Button>\n\t\t\t\t<Button\n\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\tonClick={ () => changePage( numPages ) }\n\t\t\t\t\tdisabled={ currentPage === numPages }\n\t\t\t\t\taria-label={ __( 'Last page' ) }\n\t\t\t\t>\n\t\t\t\t\t»\n\t\t\t\t</Button>\n\t\t\t</HStack>\n\t\t</HStack>\n\t);\n}\n"]}
|