@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,152 @@
|
|
|
1
|
+
import { createElement, Fragment } from "@wordpress/element";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* WordPress dependencies
|
|
5
|
+
*/
|
|
6
|
+
import { useState, useDeferredValue, useId, useMemo } from '@wordpress/element';
|
|
7
|
+
import { SearchControl, __experimentalVStack as VStack, Flex, FlexBlock, __experimentalToggleGroupControl as ToggleGroupControl, __experimentalToggleGroupControlOption as ToggleGroupControlOption, __experimentalHeading as Heading, __experimentalText as Text } from '@wordpress/components';
|
|
8
|
+
import { __, isRTL } from '@wordpress/i18n';
|
|
9
|
+
import { chevronLeft, chevronRight } from '@wordpress/icons';
|
|
10
|
+
import { privateApis as routerPrivateApis } from '@wordpress/router';
|
|
11
|
+
import { useAsyncList, useViewportMatch } from '@wordpress/compose';
|
|
12
|
+
/**
|
|
13
|
+
* Internal dependencies
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import PatternsHeader from './header';
|
|
17
|
+
import Grid from './grid';
|
|
18
|
+
import NoPatterns from './no-patterns';
|
|
19
|
+
import usePatterns from './use-patterns';
|
|
20
|
+
import SidebarButton from '../sidebar-button';
|
|
21
|
+
import useDebouncedInput from '../../utils/use-debounced-input';
|
|
22
|
+
import { unlock } from '../../lock-unlock';
|
|
23
|
+
import { SYNC_TYPES, USER_PATTERN_CATEGORY } from './utils';
|
|
24
|
+
import Pagination from './pagination';
|
|
25
|
+
const {
|
|
26
|
+
useLocation,
|
|
27
|
+
useHistory
|
|
28
|
+
} = unlock(routerPrivateApis);
|
|
29
|
+
const SYNC_FILTERS = {
|
|
30
|
+
all: __('All'),
|
|
31
|
+
[SYNC_TYPES.full]: __('Synced'),
|
|
32
|
+
[SYNC_TYPES.unsynced]: __('Standard')
|
|
33
|
+
};
|
|
34
|
+
const SYNC_DESCRIPTIONS = {
|
|
35
|
+
all: '',
|
|
36
|
+
[SYNC_TYPES.full]: __('Patterns that are kept in sync across the site.'),
|
|
37
|
+
[SYNC_TYPES.unsynced]: __('Patterns that can be changed freely without affecting the site.')
|
|
38
|
+
};
|
|
39
|
+
const PAGE_SIZE = 20;
|
|
40
|
+
export default function PatternsList({
|
|
41
|
+
categoryId,
|
|
42
|
+
type
|
|
43
|
+
}) {
|
|
44
|
+
const location = useLocation();
|
|
45
|
+
const history = useHistory();
|
|
46
|
+
const isMobileViewport = useViewportMatch('medium', '<');
|
|
47
|
+
const [filterValue, setFilterValue, delayedFilterValue] = useDebouncedInput('');
|
|
48
|
+
const deferredFilterValue = useDeferredValue(delayedFilterValue);
|
|
49
|
+
const [syncFilter, setSyncFilter] = useState('all');
|
|
50
|
+
const [currentPage, setCurrentPage] = useState(1);
|
|
51
|
+
const deferredSyncedFilter = useDeferredValue(syncFilter);
|
|
52
|
+
const {
|
|
53
|
+
patterns,
|
|
54
|
+
isResolving
|
|
55
|
+
} = usePatterns(type, categoryId !== 'uncategorized' ? categoryId : '', {
|
|
56
|
+
search: deferredFilterValue,
|
|
57
|
+
syncStatus: deferredSyncedFilter === 'all' ? undefined : deferredSyncedFilter
|
|
58
|
+
});
|
|
59
|
+
const id = useId();
|
|
60
|
+
const titleId = `${id}-title`;
|
|
61
|
+
const descriptionId = `${id}-description`;
|
|
62
|
+
const hasPatterns = patterns.length;
|
|
63
|
+
const title = SYNC_FILTERS[syncFilter];
|
|
64
|
+
const description = SYNC_DESCRIPTIONS[syncFilter];
|
|
65
|
+
const totalItems = patterns.length;
|
|
66
|
+
const pageIndex = currentPage - 1;
|
|
67
|
+
const numPages = Math.ceil(patterns.length / PAGE_SIZE);
|
|
68
|
+
const list = useMemo(() => patterns.slice(pageIndex * PAGE_SIZE, pageIndex * PAGE_SIZE + PAGE_SIZE), [pageIndex, patterns]);
|
|
69
|
+
const asyncList = useAsyncList(list, {
|
|
70
|
+
step: 10
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
const changePage = page => {
|
|
74
|
+
const scrollContainer = document.querySelector('.edit-site-patterns');
|
|
75
|
+
scrollContainer?.scrollTo(0, 0);
|
|
76
|
+
setCurrentPage(page);
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
return createElement(Fragment, null, createElement(VStack, {
|
|
80
|
+
className: "edit-site-patterns__header",
|
|
81
|
+
spacing: 6
|
|
82
|
+
}, createElement(PatternsHeader, {
|
|
83
|
+
categoryId: categoryId,
|
|
84
|
+
type: type,
|
|
85
|
+
titleId: titleId,
|
|
86
|
+
descriptionId: descriptionId
|
|
87
|
+
}), createElement(Flex, {
|
|
88
|
+
alignment: "stretch",
|
|
89
|
+
wrap: true
|
|
90
|
+
}, isMobileViewport && createElement(SidebarButton, {
|
|
91
|
+
icon: isRTL() ? chevronRight : chevronLeft,
|
|
92
|
+
label: __('Back'),
|
|
93
|
+
onClick: () => {
|
|
94
|
+
// Go back in history if we came from the Patterns page.
|
|
95
|
+
// Otherwise push a stack onto the history.
|
|
96
|
+
if (location.state?.backPath === '/patterns') {
|
|
97
|
+
history.back();
|
|
98
|
+
} else {
|
|
99
|
+
history.push({
|
|
100
|
+
path: '/patterns'
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}), createElement(FlexBlock, {
|
|
105
|
+
className: "edit-site-patterns__search-block"
|
|
106
|
+
}, createElement(SearchControl, {
|
|
107
|
+
className: "edit-site-patterns__search",
|
|
108
|
+
onChange: value => setFilterValue(value),
|
|
109
|
+
placeholder: __('Search patterns'),
|
|
110
|
+
label: __('Search patterns'),
|
|
111
|
+
value: filterValue,
|
|
112
|
+
__nextHasNoMarginBottom: true
|
|
113
|
+
})), categoryId === USER_PATTERN_CATEGORY && createElement(ToggleGroupControl, {
|
|
114
|
+
className: "edit-site-patterns__sync-status-filter",
|
|
115
|
+
hideLabelFromVision: true,
|
|
116
|
+
label: __('Filter by sync status'),
|
|
117
|
+
value: syncFilter,
|
|
118
|
+
isBlock: true,
|
|
119
|
+
onChange: value => setSyncFilter(value),
|
|
120
|
+
__nextHasNoMarginBottom: true
|
|
121
|
+
}, Object.entries(SYNC_FILTERS).map(([key, label]) => createElement(ToggleGroupControlOption, {
|
|
122
|
+
className: "edit-site-patterns__sync-status-filter-option",
|
|
123
|
+
key: key,
|
|
124
|
+
value: key,
|
|
125
|
+
label: label
|
|
126
|
+
}))))), createElement(VStack, {
|
|
127
|
+
className: "edit-site-patterns__section",
|
|
128
|
+
justify: "flex-start",
|
|
129
|
+
spacing: 6
|
|
130
|
+
}, syncFilter !== 'all' && createElement(VStack, {
|
|
131
|
+
className: "edit-site-patterns__section-header"
|
|
132
|
+
}, createElement(Heading, {
|
|
133
|
+
as: "h3",
|
|
134
|
+
level: 5,
|
|
135
|
+
id: titleId
|
|
136
|
+
}, title), description ? createElement(Text, {
|
|
137
|
+
variant: "muted",
|
|
138
|
+
as: "p",
|
|
139
|
+
id: descriptionId
|
|
140
|
+
}, description) : null), hasPatterns && createElement(Grid, {
|
|
141
|
+
categoryId: categoryId,
|
|
142
|
+
items: asyncList,
|
|
143
|
+
"aria-labelledby": titleId,
|
|
144
|
+
"aria-describedby": descriptionId
|
|
145
|
+
}), !isResolving && !hasPatterns && createElement(NoPatterns, null)), numPages > 1 && createElement(Pagination, {
|
|
146
|
+
currentPage: currentPage,
|
|
147
|
+
numPages: numPages,
|
|
148
|
+
changePage: changePage,
|
|
149
|
+
totalItems: totalItems
|
|
150
|
+
}));
|
|
151
|
+
}
|
|
152
|
+
//# sourceMappingURL=patterns-list.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/page-patterns/patterns-list.js"],"names":["useState","useDeferredValue","useId","useMemo","SearchControl","__experimentalVStack","VStack","Flex","FlexBlock","__experimentalToggleGroupControl","ToggleGroupControl","__experimentalToggleGroupControlOption","ToggleGroupControlOption","__experimentalHeading","Heading","__experimentalText","Text","__","isRTL","chevronLeft","chevronRight","privateApis","routerPrivateApis","useAsyncList","useViewportMatch","PatternsHeader","Grid","NoPatterns","usePatterns","SidebarButton","useDebouncedInput","unlock","SYNC_TYPES","USER_PATTERN_CATEGORY","Pagination","useLocation","useHistory","SYNC_FILTERS","all","full","unsynced","SYNC_DESCRIPTIONS","PAGE_SIZE","PatternsList","categoryId","type","location","history","isMobileViewport","filterValue","setFilterValue","delayedFilterValue","deferredFilterValue","syncFilter","setSyncFilter","currentPage","setCurrentPage","deferredSyncedFilter","patterns","isResolving","search","syncStatus","undefined","id","titleId","descriptionId","hasPatterns","length","title","description","totalItems","pageIndex","numPages","Math","ceil","list","slice","asyncList","step","changePage","page","scrollContainer","document","querySelector","scrollTo","state","backPath","back","push","path","value","Object","entries","map","key","label"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,QAAT,EAAmBC,gBAAnB,EAAqCC,KAArC,EAA4CC,OAA5C,QAA2D,oBAA3D;AACA,SACCC,aADD,EAECC,oBAAoB,IAAIC,MAFzB,EAGCC,IAHD,EAICC,SAJD,EAKCC,gCAAgC,IAAIC,kBALrC,EAMCC,sCAAsC,IAAIC,wBAN3C,EAOCC,qBAAqB,IAAIC,OAP1B,EAQCC,kBAAkB,IAAIC,IARvB,QASO,uBATP;AAUA,SAASC,EAAT,EAAaC,KAAb,QAA0B,iBAA1B;AACA,SAASC,WAAT,EAAsBC,YAAtB,QAA0C,kBAA1C;AACA,SAASC,WAAW,IAAIC,iBAAxB,QAAiD,mBAAjD;AACA,SAASC,YAAT,EAAuBC,gBAAvB,QAA+C,oBAA/C;AAEA;AACA;AACA;;AACA,OAAOC,cAAP,MAA2B,UAA3B;AACA,OAAOC,IAAP,MAAiB,QAAjB;AACA,OAAOC,UAAP,MAAuB,eAAvB;AACA,OAAOC,WAAP,MAAwB,gBAAxB;AACA,OAAOC,aAAP,MAA0B,mBAA1B;AACA,OAAOC,iBAAP,MAA8B,iCAA9B;AAC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IAAA,QAAQ,EAAGiB,QAFZ;AAGC,IAAA,UAAU,EAAGO,UAHd;AAIC,IAAA,UAAU,EAAGT;AAJd,IAxFF,CADD;AAkGA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useState, useDeferredValue, useId, useMemo } from '@wordpress/element';\nimport {\n\tSearchControl,\n\t__experimentalVStack as VStack,\n\tFlex,\n\tFlexBlock,\n\t__experimentalToggleGroupControl as ToggleGroupControl,\n\t__experimentalToggleGroupControlOption as ToggleGroupControlOption,\n\t__experimentalHeading as Heading,\n\t__experimentalText as Text,\n} from '@wordpress/components';\nimport { __, isRTL } from '@wordpress/i18n';\nimport { chevronLeft, chevronRight } from '@wordpress/icons';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\nimport { useAsyncList, useViewportMatch } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport PatternsHeader from './header';\nimport Grid from './grid';\nimport NoPatterns from './no-patterns';\nimport usePatterns from './use-patterns';\nimport SidebarButton from '../sidebar-button';\nimport useDebouncedInput from '../../utils/use-debounced-input';\nimport { unlock } from '../../lock-unlock';\nimport { SYNC_TYPES, USER_PATTERN_CATEGORY } from './utils';\nimport Pagination from './pagination';\n\nconst { useLocation, useHistory } = unlock( routerPrivateApis );\n\nconst SYNC_FILTERS = {\n\tall: __( 'All' ),\n\t[ SYNC_TYPES.full ]: __( 'Synced' ),\n\t[ SYNC_TYPES.unsynced ]: __( 'Standard' ),\n};\n\nconst SYNC_DESCRIPTIONS = {\n\tall: '',\n\t[ SYNC_TYPES.full ]: __(\n\t\t'Patterns that are kept in sync across the site.'\n\t),\n\t[ SYNC_TYPES.unsynced ]: __(\n\t\t'Patterns that can be changed freely without affecting the site.'\n\t),\n};\n\nconst PAGE_SIZE = 20;\n\nexport default function PatternsList( { categoryId, type } ) {\n\tconst location = useLocation();\n\tconst history = useHistory();\n\tconst isMobileViewport = useViewportMatch( 'medium', '<' );\n\tconst [ filterValue, setFilterValue, delayedFilterValue ] =\n\t\tuseDebouncedInput( '' );\n\tconst deferredFilterValue = useDeferredValue( delayedFilterValue );\n\n\tconst [ syncFilter, setSyncFilter ] = useState( 'all' );\n\tconst [ currentPage, setCurrentPage ] = useState( 1 );\n\n\tconst deferredSyncedFilter = useDeferredValue( syncFilter );\n\n\tconst { patterns, isResolving } = usePatterns(\n\t\ttype,\n\t\tcategoryId !== 'uncategorized' ? categoryId : '',\n\t\t{\n\t\t\tsearch: deferredFilterValue,\n\t\t\tsyncStatus:\n\t\t\t\tdeferredSyncedFilter === 'all'\n\t\t\t\t\t? undefined\n\t\t\t\t\t: deferredSyncedFilter,\n\t\t}\n\t);\n\n\tconst id = useId();\n\tconst titleId = `${ id }-title`;\n\tconst descriptionId = `${ id }-description`;\n\n\tconst hasPatterns = patterns.length;\n\tconst title = SYNC_FILTERS[ syncFilter ];\n\tconst description = SYNC_DESCRIPTIONS[ syncFilter ];\n\n\tconst totalItems = patterns.length;\n\tconst pageIndex = currentPage - 1;\n\tconst numPages = Math.ceil( patterns.length / PAGE_SIZE );\n\n\tconst list = useMemo(\n\t\t() =>\n\t\t\tpatterns.slice(\n\t\t\t\tpageIndex * PAGE_SIZE,\n\t\t\t\tpageIndex * PAGE_SIZE + PAGE_SIZE\n\t\t\t),\n\t\t[ pageIndex, patterns ]\n\t);\n\n\tconst asyncList = useAsyncList( list, { step: 10 } );\n\n\tconst changePage = ( page ) => {\n\t\tconst scrollContainer = document.querySelector( '.edit-site-patterns' );\n\t\tscrollContainer?.scrollTo( 0, 0 );\n\n\t\tsetCurrentPage( page );\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t<VStack className=\"edit-site-patterns__header\" spacing={ 6 }>\n\t\t\t\t<PatternsHeader\n\t\t\t\t\tcategoryId={ categoryId }\n\t\t\t\t\ttype={ type }\n\t\t\t\t\ttitleId={ titleId }\n\t\t\t\t\tdescriptionId={ descriptionId }\n\t\t\t\t/>\n\t\t\t\t<Flex alignment=\"stretch\" wrap>\n\t\t\t\t\t{ isMobileViewport && (\n\t\t\t\t\t\t<SidebarButton\n\t\t\t\t\t\t\ticon={ isRTL() ? chevronRight : chevronLeft }\n\t\t\t\t\t\t\tlabel={ __( 'Back' ) }\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t// Go back in history if we came from the Patterns page.\n\t\t\t\t\t\t\t\t// Otherwise push a stack onto the history.\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\tlocation.state?.backPath === '/patterns'\n\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\thistory.back();\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\thistory.push( { path: '/patterns' } );\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t\t<FlexBlock className=\"edit-site-patterns__search-block\">\n\t\t\t\t\t\t<SearchControl\n\t\t\t\t\t\t\tclassName=\"edit-site-patterns__search\"\n\t\t\t\t\t\t\tonChange={ ( value ) => setFilterValue( value ) }\n\t\t\t\t\t\t\tplaceholder={ __( 'Search patterns' ) }\n\t\t\t\t\t\t\tlabel={ __( 'Search patterns' ) }\n\t\t\t\t\t\t\tvalue={ filterValue }\n\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t/>\n\t\t\t\t\t</FlexBlock>\n\t\t\t\t\t{ categoryId === USER_PATTERN_CATEGORY && (\n\t\t\t\t\t\t<ToggleGroupControl\n\t\t\t\t\t\t\tclassName=\"edit-site-patterns__sync-status-filter\"\n\t\t\t\t\t\t\thideLabelFromVision\n\t\t\t\t\t\t\tlabel={ __( 'Filter by sync status' ) }\n\t\t\t\t\t\t\tvalue={ syncFilter }\n\t\t\t\t\t\t\tisBlock\n\t\t\t\t\t\t\tonChange={ ( value ) => setSyncFilter( value ) }\n\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ Object.entries( SYNC_FILTERS ).map(\n\t\t\t\t\t\t\t\t( [ key, label ] ) => (\n\t\t\t\t\t\t\t\t\t<ToggleGroupControlOption\n\t\t\t\t\t\t\t\t\t\tclassName=\"edit-site-patterns__sync-status-filter-option\"\n\t\t\t\t\t\t\t\t\t\tkey={ key }\n\t\t\t\t\t\t\t\t\t\tvalue={ key }\n\t\t\t\t\t\t\t\t\t\tlabel={ label }\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</ToggleGroupControl>\n\t\t\t\t\t) }\n\t\t\t\t</Flex>\n\t\t\t</VStack>\n\t\t\t<VStack\n\t\t\t\tclassName=\"edit-site-patterns__section\"\n\t\t\t\tjustify=\"flex-start\"\n\t\t\t\tspacing={ 6 }\n\t\t\t>\n\t\t\t\t{ syncFilter !== 'all' && (\n\t\t\t\t\t<VStack className=\"edit-site-patterns__section-header\">\n\t\t\t\t\t\t<Heading as=\"h3\" level={ 5 } id={ titleId }>\n\t\t\t\t\t\t\t{ title }\n\t\t\t\t\t\t</Heading>\n\t\t\t\t\t\t{ description ? (\n\t\t\t\t\t\t\t<Text variant=\"muted\" as=\"p\" id={ descriptionId }>\n\t\t\t\t\t\t\t\t{ description }\n\t\t\t\t\t\t\t</Text>\n\t\t\t\t\t\t) : null }\n\t\t\t\t\t</VStack>\n\t\t\t\t) }\n\t\t\t\t{ hasPatterns && (\n\t\t\t\t\t<Grid\n\t\t\t\t\t\tcategoryId={ categoryId }\n\t\t\t\t\t\titems={ asyncList }\n\t\t\t\t\t\taria-labelledby={ titleId }\n\t\t\t\t\t\taria-describedby={ descriptionId }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t{ ! isResolving && ! hasPatterns && <NoPatterns /> }\n\t\t\t</VStack>\n\t\t\t{ numPages > 1 && (\n\t\t\t\t<Pagination\n\t\t\t\t\tcurrentPage={ currentPage }\n\t\t\t\t\tnumPages={ numPages }\n\t\t\t\t\tchangePage={ changePage }\n\t\t\t\t\ttotalItems={ totalItems }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n"]}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { createElement, Fragment } from "@wordpress/element";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* WordPress dependencies
|
|
5
|
+
*/
|
|
6
|
+
import { Button, MenuItem, Modal, TextControl, __experimentalHStack as HStack, __experimentalVStack as VStack } from '@wordpress/components';
|
|
7
|
+
import { store as coreStore } from '@wordpress/core-data';
|
|
8
|
+
import { useDispatch } from '@wordpress/data';
|
|
9
|
+
import { useState } from '@wordpress/element';
|
|
10
|
+
import { __ } from '@wordpress/i18n';
|
|
11
|
+
import { store as noticesStore } from '@wordpress/notices';
|
|
12
|
+
/**
|
|
13
|
+
* Internal dependencies
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import { TEMPLATE_PARTS } from './utils';
|
|
17
|
+
export default function RenameMenuItem({
|
|
18
|
+
item,
|
|
19
|
+
onClose
|
|
20
|
+
}) {
|
|
21
|
+
const [title, setTitle] = useState(() => item.title);
|
|
22
|
+
const [isModalOpen, setIsModalOpen] = useState(false);
|
|
23
|
+
const {
|
|
24
|
+
editEntityRecord,
|
|
25
|
+
saveEditedEntityRecord
|
|
26
|
+
} = useDispatch(coreStore);
|
|
27
|
+
const {
|
|
28
|
+
createSuccessNotice,
|
|
29
|
+
createErrorNotice
|
|
30
|
+
} = useDispatch(noticesStore);
|
|
31
|
+
|
|
32
|
+
if (item.type === TEMPLATE_PARTS && !item.isCustom) {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
async function onRename(event) {
|
|
37
|
+
event.preventDefault();
|
|
38
|
+
|
|
39
|
+
try {
|
|
40
|
+
await editEntityRecord('postType', item.type, item.id, {
|
|
41
|
+
title
|
|
42
|
+
}); // Update state before saving rerenders the list.
|
|
43
|
+
|
|
44
|
+
setTitle('');
|
|
45
|
+
setIsModalOpen(false);
|
|
46
|
+
onClose(); // Persist edited entity.
|
|
47
|
+
|
|
48
|
+
await saveEditedEntityRecord('postType', item.type, item.id, {
|
|
49
|
+
throwOnError: true
|
|
50
|
+
});
|
|
51
|
+
createSuccessNotice(__('Entity renamed.'), {
|
|
52
|
+
type: 'snackbar'
|
|
53
|
+
});
|
|
54
|
+
} catch (error) {
|
|
55
|
+
const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : __('An error occurred while renaming the entity.');
|
|
56
|
+
createErrorNotice(errorMessage, {
|
|
57
|
+
type: 'snackbar'
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return createElement(Fragment, null, createElement(MenuItem, {
|
|
63
|
+
onClick: () => {
|
|
64
|
+
setIsModalOpen(true);
|
|
65
|
+
setTitle(item.title);
|
|
66
|
+
}
|
|
67
|
+
}, __('Rename')), isModalOpen && createElement(Modal, {
|
|
68
|
+
title: __('Rename'),
|
|
69
|
+
onRequestClose: () => {
|
|
70
|
+
setIsModalOpen(false);
|
|
71
|
+
onClose();
|
|
72
|
+
},
|
|
73
|
+
overlayClassName: "edit-site-list__rename_modal"
|
|
74
|
+
}, createElement("form", {
|
|
75
|
+
onSubmit: onRename
|
|
76
|
+
}, createElement(VStack, {
|
|
77
|
+
spacing: "5"
|
|
78
|
+
}, createElement(TextControl, {
|
|
79
|
+
__nextHasNoMarginBottom: true,
|
|
80
|
+
label: __('Name'),
|
|
81
|
+
value: title,
|
|
82
|
+
onChange: setTitle,
|
|
83
|
+
required: true
|
|
84
|
+
}), createElement(HStack, {
|
|
85
|
+
justify: "right"
|
|
86
|
+
}, createElement(Button, {
|
|
87
|
+
variant: "tertiary",
|
|
88
|
+
onClick: () => {
|
|
89
|
+
setIsModalOpen(false);
|
|
90
|
+
onClose();
|
|
91
|
+
}
|
|
92
|
+
}, __('Cancel')), createElement(Button, {
|
|
93
|
+
variant: "primary",
|
|
94
|
+
type: "submit"
|
|
95
|
+
}, __('Save')))))));
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=rename-menu-item.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/page-patterns/rename-menu-item.js"],"names":["Button","MenuItem","Modal","TextControl","__experimentalHStack","HStack","__experimentalVStack","VStack","store","coreStore","useDispatch","useState","__","noticesStore","TEMPLATE_PARTS","RenameMenuItem","item","onClose","title","setTitle","isModalOpen","setIsModalOpen","editEntityRecord","saveEditedEntityRecord","createSuccessNotice","createErrorNotice","type","isCustom","onRename","event","preventDefault","id","throwOnError","error","errorMessage","message","code"],"mappings":";;AAAA;AACA;AACA;AACA,SACCA,MADD,EAECC,QAFD,EAGCC,KAHD,EAICC,WAJD,EAKCC,oBAAoB,IAAIC,MALzB,EAMCC,oBAAoB,IAAIC,MANzB,QAOO,uBAPP;AAQA,SAASC,KAAK,IAAIC,SAAlB,QAAmC,sBAAnC;AACA,SAASC,WAAT,QAA4B,iBAA5B;AACA,SAASC,QAAT,QAAyB,oBAAzB;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASJ,KAAK,IAAIK,YAAlB,QAAsC,oBAAtC;AAEA;AACA;AACA;;AACA,SAASC,cAAT,QAA+B,SAA/B;AAEA,eAAe,SAASC,cAAT,CAAyB;AAAEC,EAAAA,IAAF;AAAQC,EAAAA;AAAR,CAAzB,EAA6C;AAC3D,QAAM,CAAEC,KAAF,EAASC,QAAT,IAAsBR,QAAQ,CAAE,MAAMK,IAAI,CAACE,KAAb,CAApC;AACA,QAAM,CAAEE,WAAF,EAAeC,cAAf,IAAkCV,QAAQ,CAAE,KAAF,CAAhD;AAEA,QAAM;AAAEW,IAAAA,gBAAF;AAAoBC,IAAAA;AAApB,MACLb,WAAW,CAAED,SAAF,CADZ;AAEA,QAAM;AAAEe,IAAAA,mBAAF;AAAuBC,IAAAA;AAAvB,MACLf,WAAW,CAAEG,YAAF,CADZ;;AAGA,MAAKG,IAAI,CAAC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;AAEC,IAAA,cAAc,EAAG,MAAM;AACtBS,MAAAA,cAAc,CAAE,KAAF,CAAd;AACAJ,MAAAA,OAAO;AACP,KALF;AAMC,IAAA,gBAAgB,EAAC;AANlB,KAQC;AAAM,IAAA,QAAQ,EAAGW;AAAjB,KACC,cAAC,MAAD;AAAQ,IAAA,OAAO,EAAC;AAAhB,KACC,cAAC,WAAD;AACC,IAAA,uBAAuB,MADxB;AAEC,IAAA,KAAK,EAAGhB,EAAE,CAAE,MAAF,CAFX;AAGC,IAAA,KAAK,EAAGM,KAHT;AAIC,IAAA,QAAQ,EAAGC,QAJZ;AAKC,IAAA,QAAQ;AALT,IADD,EASC,cAAC,MAAD;AAAQ,IAAA,OAAO,EAAC;AAAhB,KACC,cAAC,MAAD;AACC,IAAA,OAAO,EAAC,UADT;AAEC,IAAA,OAAO,EAAG,MAAM;AACfE,MAAAA,cAAc,CAAE,KAAF,CAAd;AACAJ,MAAAA,OAAO;AACP;AALF,KAOGL,EAAE,CAAE,QAAF,CAPL,CADD,EAWC,cAAC,MAAD;AAAQ,IAAA,OAAO,EAAC,SAAhB;AAA0B,IAAA,IAAI,EAAC;AAA/B,KACGA,EAAE,CAAE,MAAF,CADL,CAXD,CATD,CADD,CARD,CAVF,CADD;AAkDA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tButton,\n\tMenuItem,\n\tModal,\n\tTextControl,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useDispatch } from '@wordpress/data';\nimport { useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport { TEMPLATE_PARTS } from './utils';\n\nexport default function RenameMenuItem( { item, onClose } ) {\n\tconst [ title, setTitle ] = useState( () => item.title );\n\tconst [ isModalOpen, setIsModalOpen ] = useState( false );\n\n\tconst { editEntityRecord, saveEditedEntityRecord } =\n\t\tuseDispatch( coreStore );\n\tconst { createSuccessNotice, createErrorNotice } =\n\t\tuseDispatch( noticesStore );\n\n\tif ( item.type === TEMPLATE_PARTS && ! item.isCustom ) {\n\t\treturn null;\n\t}\n\n\tasync function onRename( event ) {\n\t\tevent.preventDefault();\n\n\t\ttry {\n\t\t\tawait editEntityRecord( 'postType', item.type, item.id, { title } );\n\n\t\t\t// Update state before saving rerenders the list.\n\t\t\tsetTitle( '' );\n\t\t\tsetIsModalOpen( false );\n\t\t\tonClose();\n\n\t\t\t// Persist edited entity.\n\t\t\tawait saveEditedEntityRecord( 'postType', item.type, item.id, {\n\t\t\t\tthrowOnError: true,\n\t\t\t} );\n\n\t\t\tcreateSuccessNotice( __( 'Entity renamed.' ), {\n\t\t\t\ttype: 'snackbar',\n\t\t\t} );\n\t\t} catch ( error ) {\n\t\t\tconst errorMessage =\n\t\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t\t? error.message\n\t\t\t\t\t: __( 'An error occurred while renaming the entity.' );\n\n\t\t\tcreateErrorNotice( errorMessage, { type: 'snackbar' } );\n\t\t}\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<MenuItem\n\t\t\t\tonClick={ () => {\n\t\t\t\t\tsetIsModalOpen( true );\n\t\t\t\t\tsetTitle( item.title );\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t{ __( 'Rename' ) }\n\t\t\t</MenuItem>\n\t\t\t{ isModalOpen && (\n\t\t\t\t<Modal\n\t\t\t\t\ttitle={ __( 'Rename' ) }\n\t\t\t\t\tonRequestClose={ () => {\n\t\t\t\t\t\tsetIsModalOpen( false );\n\t\t\t\t\t\tonClose();\n\t\t\t\t\t} }\n\t\t\t\t\toverlayClassName=\"edit-site-list__rename_modal\"\n\t\t\t\t>\n\t\t\t\t\t<form onSubmit={ onRename }>\n\t\t\t\t\t\t<VStack spacing=\"5\">\n\t\t\t\t\t\t\t<TextControl\n\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\tlabel={ __( 'Name' ) }\n\t\t\t\t\t\t\t\tvalue={ title }\n\t\t\t\t\t\t\t\tonChange={ setTitle }\n\t\t\t\t\t\t\t\trequired\n\t\t\t\t\t\t\t/>\n\n\t\t\t\t\t\t\t<HStack justify=\"right\">\n\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\tsetIsModalOpen( false );\n\t\t\t\t\t\t\t\t\t\tonClose();\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{ __( 'Cancel' ) }\n\t\t\t\t\t\t\t\t</Button>\n\n\t\t\t\t\t\t\t\t<Button variant=\"primary\" type=\"submit\">\n\t\t\t\t\t\t\t\t\t{ __( 'Save' ) }\n\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t</HStack>\n\t\t\t\t\t\t</VStack>\n\t\t\t\t\t</form>\n\t\t\t\t</Modal>\n\t\t\t) }\n\t\t</>\n\t);\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/page-patterns/search-items.js"],"names":["removeAccents","noCase","defaultGetName","item","name","defaultGetTitle","title","defaultGetDescription","description","defaultGetKeywords","keywords","defaultHasCategory","extractWords","input","splitRegexp","stripRegexp","split","filter","Boolean","normalizeSearchInput","replace","toLowerCase","getNormalizedSearchTerms","removeMatchingTerms","unmatchedTerms","unprocessedTerms","term","some","unprocessedTerm","includes","searchItems","items","searchInput","config","normalizedSearchTerms","onlyFilterByCategory","length","searchRankConfig","threshold","rankedItems","map","getItemSearchRank","rank","sort","rank1","rank2","searchTerm","categoryId","getName","getTitle","getDescription","getKeywords","hasCategory","normalizedSearchInput","normalizedTitle","startsWith","terms","join"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,aAAP,MAA0B,gBAA1B;AAC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AEpD,IAAF,EAAQE,KAAR,EAAeE,WAAf,EAA4B,GAAGE,QAA/B,EAA0C+C,IAA1C,CAAgD,GAAhD,CAAd;AACA,UAAMvB,qBAAqB,GAAGtB,YAAY,CAAEyC,qBAAF,CAA1C;AACA,UAAM7B,cAAc,GAAGD,mBAAmB,CACzCW,qBADyC,EAEzCsB,KAFyC,CAA1C;;AAKA,QAAKhC,cAAc,CAACY,MAAf,KAA0B,CAA/B,EAAmC;AAClCM,MAAAA,IAAI,IAAI,EAAR;AACA;AACD;;AAED,SAAOA,IAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport removeAccents from 'remove-accents';\nimport { noCase } from 'change-case';\n\n// Default search helpers.\nconst defaultGetName = ( item ) => item.name || '';\nconst defaultGetTitle = ( item ) => item.title;\nconst defaultGetDescription = ( item ) => item.description || '';\nconst defaultGetKeywords = ( item ) => item.keywords || [];\nconst defaultHasCategory = () => false;\n\n/**\n * Extracts words from an input string.\n *\n * @param {string} input The input string.\n *\n * @return {Array} Words, extracted from the input string.\n */\nfunction extractWords( input = '' ) {\n\treturn noCase( input, {\n\t\tsplitRegexp: [\n\t\t\t/([\\p{Ll}\\p{Lo}\\p{N}])([\\p{Lu}\\p{Lt}])/gu, // One lowercase or digit, followed by one uppercase.\n\t\t\t/([\\p{Lu}\\p{Lt}])([\\p{Lu}\\p{Lt}][\\p{Ll}\\p{Lo}])/gu, // One uppercase followed by one uppercase and one lowercase.\n\t\t],\n\t\tstripRegexp: /(\\p{C}|\\p{P}|\\p{S})+/giu, // Anything that's not a punctuation, symbol or control/format character.\n\t} )\n\t\t.split( ' ' )\n\t\t.filter( Boolean );\n}\n\n/**\n * Sanitizes the search input string.\n *\n * @param {string} input The search input to normalize.\n *\n * @return {string} The normalized search input.\n */\nfunction normalizeSearchInput( input = '' ) {\n\t// Disregard diacritics.\n\t// Input: \"média\"\n\tinput = removeAccents( input );\n\n\t// Accommodate leading slash, matching autocomplete expectations.\n\t// Input: \"/media\"\n\tinput = input.replace( /^\\//, '' );\n\n\t// Lowercase.\n\t// Input: \"MEDIA\"\n\tinput = input.toLowerCase();\n\n\treturn input;\n}\n\n/**\n * Converts the search term into a list of normalized terms.\n *\n * @param {string} input The search term to normalize.\n *\n * @return {string[]} The normalized list of search terms.\n */\nexport const getNormalizedSearchTerms = ( input = '' ) => {\n\treturn extractWords( normalizeSearchInput( input ) );\n};\n\nconst removeMatchingTerms = ( unmatchedTerms, unprocessedTerms ) => {\n\treturn unmatchedTerms.filter(\n\t\t( term ) =>\n\t\t\t! getNormalizedSearchTerms( unprocessedTerms ).some(\n\t\t\t\t( unprocessedTerm ) => unprocessedTerm.includes( term )\n\t\t\t)\n\t);\n};\n\n/**\n * Filters an item list given a search term.\n *\n * @param {Array} items Item list\n * @param {string} searchInput Search input.\n * @param {Object} config Search Config.\n *\n * @return {Array} Filtered item list.\n */\nexport const searchItems = ( items = [], searchInput = '', config = {} ) => {\n\tconst normalizedSearchTerms = getNormalizedSearchTerms( searchInput );\n\tconst onlyFilterByCategory = ! normalizedSearchTerms.length;\n\tconst searchRankConfig = { ...config, onlyFilterByCategory };\n\n\t// If we aren't filtering on search terms, matching on category is satisfactory.\n\t// If we are, then we need more than a category match.\n\tconst threshold = onlyFilterByCategory ? 0 : 1;\n\n\tconst rankedItems = items\n\t\t.map( ( item ) => {\n\t\t\treturn [\n\t\t\t\titem,\n\t\t\t\tgetItemSearchRank( item, searchInput, searchRankConfig ),\n\t\t\t];\n\t\t} )\n\t\t.filter( ( [ , rank ] ) => rank > threshold );\n\n\t// If we didn't have terms to search on, there's no point sorting.\n\tif ( normalizedSearchTerms.length === 0 ) {\n\t\treturn rankedItems.map( ( [ item ] ) => item );\n\t}\n\n\trankedItems.sort( ( [ , rank1 ], [ , rank2 ] ) => rank2 - rank1 );\n\treturn rankedItems.map( ( [ item ] ) => item );\n};\n\n/**\n * Get the search rank for a given item and a specific search term.\n * The better the match, the higher the rank.\n * If the rank equals 0, it should be excluded from the results.\n *\n * @param {Object} item Item to filter.\n * @param {string} searchTerm Search term.\n * @param {Object} config Search Config.\n *\n * @return {number} Search Rank.\n */\nfunction getItemSearchRank( item, searchTerm, config ) {\n\tconst {\n\t\tcategoryId,\n\t\tgetName = defaultGetName,\n\t\tgetTitle = defaultGetTitle,\n\t\tgetDescription = defaultGetDescription,\n\t\tgetKeywords = defaultGetKeywords,\n\t\thasCategory = defaultHasCategory,\n\t\tonlyFilterByCategory,\n\t} = config;\n\n\tlet rank = hasCategory( item, categoryId ) ? 1 : 0;\n\n\t// If an item doesn't belong to the current category or we don't have\n\t// search terms to filter by, return the initial rank value.\n\tif ( ! rank || onlyFilterByCategory ) {\n\t\treturn rank;\n\t}\n\n\tconst name = getName( item );\n\tconst title = getTitle( item );\n\tconst description = getDescription( item );\n\tconst keywords = getKeywords( item );\n\n\tconst normalizedSearchInput = normalizeSearchInput( searchTerm );\n\tconst normalizedTitle = normalizeSearchInput( title );\n\n\t// Prefers exact matches\n\t// Then prefers if the beginning of the title matches the search term\n\t// name, keywords, description matches come later.\n\tif ( normalizedSearchInput === normalizedTitle ) {\n\t\trank += 30;\n\t} else if ( normalizedTitle.startsWith( normalizedSearchInput ) ) {\n\t\trank += 20;\n\t} else {\n\t\tconst terms = [ name, title, description, ...keywords ].join( ' ' );\n\t\tconst normalizedSearchTerms = extractWords( normalizedSearchInput );\n\t\tconst unmatchedTerms = removeMatchingTerms(\n\t\t\tnormalizedSearchTerms,\n\t\t\tterms\n\t\t);\n\n\t\tif ( unmatchedTerms.length === 0 ) {\n\t\t\trank += 10;\n\t\t}\n\t}\n\n\treturn rank;\n}\n"]}
|
|
@@ -11,7 +11,7 @@ import { useMemo } from '@wordpress/element';
|
|
|
11
11
|
import { unlock } from '../../lock-unlock';
|
|
12
12
|
import { store as editSiteStore } from '../../store';
|
|
13
13
|
import { filterOutDuplicatesByName } from './utils';
|
|
14
|
-
export default function
|
|
14
|
+
export default function usePatternSettings() {
|
|
15
15
|
var _storedSettings$__exp;
|
|
16
16
|
|
|
17
17
|
const storedSettings = useSelect(select => {
|
|
@@ -37,4 +37,4 @@ export default function useLibrarySettings() {
|
|
|
37
37
|
}, [storedSettings, blockPatterns]);
|
|
38
38
|
return settings;
|
|
39
39
|
}
|
|
40
|
-
//# sourceMappingURL=use-
|
|
40
|
+
//# sourceMappingURL=use-pattern-settings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/page-patterns/use-pattern-settings.js"],"names":["store","coreStore","useSelect","useMemo","unlock","editSiteStore","filterOutDuplicatesByName","usePatternSettings","storedSettings","select","getSettings","settingsBlockPatterns","__experimentalAdditionalBlockPatterns","__experimentalBlockPatterns","restBlockPatterns","getBlockPatterns","blockPatterns","filter","settings","restStoredSettings","__unstableIsPreviewMode"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,KAAK,IAAIC,SAAlB,QAAmC,sBAAnC;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SAASC,OAAT,QAAwB,oBAAxB;AAEA;AACA;AACA;;AACA,SAASC,MAAT,QAAuB,mBAAvB;AACA,SAASJ,KAAK,IAAIK,aAAlB,QAAuC,aAAvC;AACA,SAASC,yBAAT,QAA0C,SAA1C;AAEA,eAAe,SAASC,kBAAT,GAA8B;AAAA;;AAC5C,QAAMC,cAAc,GAAGN,SAAS,CAAIO,MAAF,IAAc;AAC/C,UAAM;AAAEC,MAAAA;AAAF,QAAkBN,MAAM,CAAEK,MAAM,CAAEJ,aAAF,CAAR,CAA9B;AACA,WAAOK,WAAW,EAAlB;AACA,GAH+B,EAG7B,EAH6B,CAAhC;AAKA,QAAMC,qBAAqB,4BAC1BH,cAAc,CAACI,qCADW,yEAC8B;AACxDJ,EAAAA,cAAc,CAACK,2BAFhB,CAN4C,CAQC;;AAE7C,QAAMC,iBAAiB,GAAGZ,SAAS,CAChCO,MAAF,IAAcA,MAAM,CAAER,SAAF,CAAN,CAAoBc,gBAApB,EADoB,EAElC,EAFkC,CAAnC;AAKA,QAAMC,aAAa,GAAGb,OAAO,CAC5B,MACC,CACC,IAAKQ,qBAAqB,IAAI,EAA9B,CADD,EAEC,IAAKG,iBAAiB,IAAI,EAA1B,CAFD,EAGEG,MAHF,CAGUX,yBAHV,CAF2B,EAM5B,CAAEK,qBAAF,EAAyBG,iBAAzB,CAN4B,CAA7B;AASA,QAAMI,QAAQ,GAAGf,OAAO,CAAE,MAAM;AAC/B,UAAM;AAAES,MAAAA,qCAAF;AAAyC,SAAGO;AAA5C,QACLX,cADD;AAGA,WAAO,EACN,GAAGW,kBADG;AAENN,MAAAA,2BAA2B,EAAEG,aAFvB;AAGNI,MAAAA,uBAAuB,EAAE;AAHnB,KAAP;AAKA,GATuB,EASrB,CAAEZ,cAAF,EAAkBQ,aAAlB,CATqB,CAAxB;AAWA,SAAOE,QAAP;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useSelect } from '@wordpress/data';\nimport { useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\nimport { store as editSiteStore } from '../../store';\nimport { filterOutDuplicatesByName } from './utils';\n\nexport default function usePatternSettings() {\n\tconst storedSettings = useSelect( ( select ) => {\n\t\tconst { getSettings } = unlock( select( editSiteStore ) );\n\t\treturn getSettings();\n\t}, [] );\n\n\tconst settingsBlockPatterns =\n\t\tstoredSettings.__experimentalAdditionalBlockPatterns ?? // WP 6.0\n\t\tstoredSettings.__experimentalBlockPatterns; // WP 5.9\n\n\tconst restBlockPatterns = useSelect(\n\t\t( select ) => select( coreStore ).getBlockPatterns(),\n\t\t[]\n\t);\n\n\tconst blockPatterns = useMemo(\n\t\t() =>\n\t\t\t[\n\t\t\t\t...( settingsBlockPatterns || [] ),\n\t\t\t\t...( restBlockPatterns || [] ),\n\t\t\t].filter( filterOutDuplicatesByName ),\n\t\t[ settingsBlockPatterns, restBlockPatterns ]\n\t);\n\n\tconst settings = useMemo( () => {\n\t\tconst { __experimentalAdditionalBlockPatterns, ...restStoredSettings } =\n\t\t\tstoredSettings;\n\n\t\treturn {\n\t\t\t...restStoredSettings,\n\t\t\t__experimentalBlockPatterns: blockPatterns,\n\t\t\t__unstableIsPreviewMode: true,\n\t\t};\n\t}, [ storedSettings, blockPatterns ] );\n\n\treturn settings;\n}\n"]}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { parse } from '@wordpress/blocks';
|
|
5
|
+
import { useSelect } from '@wordpress/data';
|
|
6
|
+
import { store as coreStore } from '@wordpress/core-data';
|
|
7
|
+
import { decodeEntities } from '@wordpress/html-entities';
|
|
8
|
+
/**
|
|
9
|
+
* Internal dependencies
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { CORE_PATTERN_SOURCES, PATTERNS, SYNC_TYPES, TEMPLATE_PARTS, USER_PATTERNS, filterOutDuplicatesByName } from './utils';
|
|
13
|
+
import { unlock } from '../../lock-unlock';
|
|
14
|
+
import { searchItems } from './search-items';
|
|
15
|
+
import { store as editSiteStore } from '../../store';
|
|
16
|
+
const EMPTY_PATTERN_LIST = [];
|
|
17
|
+
|
|
18
|
+
const createTemplatePartId = (theme, slug) => theme && slug ? theme + '//' + slug : null;
|
|
19
|
+
|
|
20
|
+
const templatePartToPattern = templatePart => ({
|
|
21
|
+
blocks: parse(templatePart.content.raw),
|
|
22
|
+
categories: [templatePart.area],
|
|
23
|
+
description: templatePart.description || '',
|
|
24
|
+
isCustom: templatePart.source === 'custom',
|
|
25
|
+
keywords: templatePart.keywords || [],
|
|
26
|
+
id: createTemplatePartId(templatePart.theme, templatePart.slug),
|
|
27
|
+
name: createTemplatePartId(templatePart.theme, templatePart.slug),
|
|
28
|
+
title: decodeEntities(templatePart.title.rendered),
|
|
29
|
+
type: templatePart.type,
|
|
30
|
+
templatePart
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
const templatePartHasCategory = (item, category) => item.templatePart.area === category;
|
|
34
|
+
|
|
35
|
+
const selectTemplatePartsAsPatterns = (select, {
|
|
36
|
+
categoryId,
|
|
37
|
+
search = ''
|
|
38
|
+
} = {}) => {
|
|
39
|
+
var _getEntityRecords;
|
|
40
|
+
|
|
41
|
+
const {
|
|
42
|
+
getEntityRecords,
|
|
43
|
+
getIsResolving
|
|
44
|
+
} = select(coreStore);
|
|
45
|
+
const query = {
|
|
46
|
+
per_page: -1
|
|
47
|
+
};
|
|
48
|
+
const rawTemplateParts = (_getEntityRecords = getEntityRecords('postType', TEMPLATE_PARTS, query)) !== null && _getEntityRecords !== void 0 ? _getEntityRecords : EMPTY_PATTERN_LIST;
|
|
49
|
+
const templateParts = rawTemplateParts.map(templatePart => templatePartToPattern(templatePart));
|
|
50
|
+
const isResolving = getIsResolving('getEntityRecords', ['postType', 'wp_template_part', query]);
|
|
51
|
+
const patterns = searchItems(templateParts, search, {
|
|
52
|
+
categoryId,
|
|
53
|
+
hasCategory: templatePartHasCategory
|
|
54
|
+
});
|
|
55
|
+
return {
|
|
56
|
+
patterns,
|
|
57
|
+
isResolving
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const selectThemePatterns = (select, {
|
|
62
|
+
categoryId,
|
|
63
|
+
search = ''
|
|
64
|
+
} = {}) => {
|
|
65
|
+
var _settings$__experimen;
|
|
66
|
+
|
|
67
|
+
const {
|
|
68
|
+
getSettings
|
|
69
|
+
} = unlock(select(editSiteStore));
|
|
70
|
+
const settings = getSettings();
|
|
71
|
+
const blockPatterns = (_settings$__experimen = settings.__experimentalAdditionalBlockPatterns) !== null && _settings$__experimen !== void 0 ? _settings$__experimen : settings.__experimentalBlockPatterns;
|
|
72
|
+
const restBlockPatterns = select(coreStore).getBlockPatterns();
|
|
73
|
+
let patterns = [...(blockPatterns || []), ...(restBlockPatterns || [])].filter(pattern => !CORE_PATTERN_SOURCES.includes(pattern.source)).filter(filterOutDuplicatesByName).filter(pattern => pattern.inserter !== false).map(pattern => ({ ...pattern,
|
|
74
|
+
keywords: pattern.keywords || [],
|
|
75
|
+
type: 'pattern',
|
|
76
|
+
blocks: parse(pattern.content)
|
|
77
|
+
}));
|
|
78
|
+
|
|
79
|
+
if (categoryId) {
|
|
80
|
+
patterns = searchItems(patterns, search, {
|
|
81
|
+
categoryId,
|
|
82
|
+
hasCategory: (item, currentCategory) => item.categories?.includes(currentCategory)
|
|
83
|
+
});
|
|
84
|
+
} else {
|
|
85
|
+
patterns = searchItems(patterns, search, {
|
|
86
|
+
hasCategory: item => !item.hasOwnProperty('categories')
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return {
|
|
91
|
+
patterns,
|
|
92
|
+
isResolving: false
|
|
93
|
+
};
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
const reusableBlockToPattern = reusableBlock => ({
|
|
97
|
+
blocks: parse(reusableBlock.content.raw),
|
|
98
|
+
categories: reusableBlock.wp_pattern,
|
|
99
|
+
id: reusableBlock.id,
|
|
100
|
+
name: reusableBlock.slug,
|
|
101
|
+
syncStatus: reusableBlock.wp_pattern_sync_status || SYNC_TYPES.full,
|
|
102
|
+
title: reusableBlock.title.raw,
|
|
103
|
+
type: reusableBlock.type,
|
|
104
|
+
reusableBlock
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
const selectUserPatterns = (select, {
|
|
108
|
+
search = '',
|
|
109
|
+
syncStatus
|
|
110
|
+
} = {}) => {
|
|
111
|
+
const {
|
|
112
|
+
getEntityRecords,
|
|
113
|
+
getIsResolving
|
|
114
|
+
} = select(coreStore);
|
|
115
|
+
const query = {
|
|
116
|
+
per_page: -1
|
|
117
|
+
};
|
|
118
|
+
const records = getEntityRecords('postType', USER_PATTERNS, query);
|
|
119
|
+
let patterns = records ? records.map(record => reusableBlockToPattern(record)) : EMPTY_PATTERN_LIST;
|
|
120
|
+
const isResolving = getIsResolving('getEntityRecords', ['postType', USER_PATTERNS, query]);
|
|
121
|
+
|
|
122
|
+
if (syncStatus) {
|
|
123
|
+
patterns = patterns.filter(pattern => pattern.syncStatus === syncStatus);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
patterns = searchItems(patterns, search, {
|
|
127
|
+
// We exit user pattern retrieval early if we aren't in the
|
|
128
|
+
// catch-all category for user created patterns, so it has
|
|
129
|
+
// to be in the category.
|
|
130
|
+
hasCategory: () => true
|
|
131
|
+
});
|
|
132
|
+
return {
|
|
133
|
+
patterns,
|
|
134
|
+
isResolving
|
|
135
|
+
};
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
export const usePatterns = (categoryType, categoryId, {
|
|
139
|
+
search = '',
|
|
140
|
+
syncStatus
|
|
141
|
+
}) => {
|
|
142
|
+
return useSelect(select => {
|
|
143
|
+
if (categoryType === TEMPLATE_PARTS) {
|
|
144
|
+
return selectTemplatePartsAsPatterns(select, {
|
|
145
|
+
categoryId,
|
|
146
|
+
search
|
|
147
|
+
});
|
|
148
|
+
} else if (categoryType === PATTERNS) {
|
|
149
|
+
return selectThemePatterns(select, {
|
|
150
|
+
categoryId,
|
|
151
|
+
search
|
|
152
|
+
});
|
|
153
|
+
} else if (categoryType === USER_PATTERNS) {
|
|
154
|
+
return selectUserPatterns(select, {
|
|
155
|
+
search,
|
|
156
|
+
syncStatus
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
return {
|
|
161
|
+
patterns: EMPTY_PATTERN_LIST,
|
|
162
|
+
isResolving: false
|
|
163
|
+
};
|
|
164
|
+
}, [categoryId, categoryType, search, syncStatus]);
|
|
165
|
+
};
|
|
166
|
+
export default usePatterns;
|
|
167
|
+
//# sourceMappingURL=use-patterns.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/page-patterns/use-patterns.js"],"names":["parse","useSelect","store","coreStore","decodeEntities","CORE_PATTERN_SOURCES","PATTERNS","SYNC_TYPES","TEMPLATE_PARTS","USER_PATTERNS","filterOutDuplicatesByName","unlock","searchItems","editSiteStore","EMPTY_PATTERN_LIST","createTemplatePartId","theme","slug","templatePartToPattern","templatePart","blocks","content","raw","categories","area","description","isCustom","source","keywords","id","name","title","rendered","type","templatePartHasCategory","item","category","selectTemplatePartsAsPatterns","select","categoryId","search","getEntityRecords","getIsResolving","query","per_page","rawTemplateParts","templateParts","map","isResolving","patterns","hasCategory","selectThemePatterns","getSettings","settings","blockPatterns","__experimentalAdditionalBlockPatterns","__experimentalBlockPatterns","restBlockPatterns","getBlockPatterns","filter","pattern","includes","inserter","currentCategory","hasOwnProperty","reusableBlockToPattern","reusableBlock","wp_pattern","syncStatus","wp_pattern_sync_status","full","selectUserPatterns","records","record","usePatterns","categoryType"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,KAAT,QAAsB,mBAAtB;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SAASC,KAAK,IAAIC,SAAlB,QAAmC,sBAAnC;AACA,SAASC,cAAT,QAA+B,0BAA/B;AAEA;AACA;AACA;;AACA,SACCC,oBADD,EAECC,QAFD,EAGCC,UAHD,EAICC,cAJD,EAKCC,aALD,EAMCC,yBAND,QAOO,SAPP;AAQA,SAASC,MAAT,QAAuB,mBAAvB;AACA,SAASC,WAAT,QAA4B,gBAA5B;AACA,SAASV,KAAK,IAAIW,aAAlB,QAAuC,aAAvC;AAEA,MAAMC,kBAAkB,GAAG,EAA3B;;AAEA,MAAMC,oBAAoB,GAAG,CAAEC,KAAF,EAASC,IAAT,KAC5BD,KAAK,IAAIC,IAAT,GAAgBD,KAAK,GAAG,IAAR,GAAeC,IAA/B,GAAsC,IADvC;;AAGA,MAAMC,qBAAqB,GAAKC,YAAF,KAAsB;AACnDC,EAAAA,MAAM,EAAEpB,KAAK,CAAEmB,YAAY,CAACE,OAAb,CAAqBC,GAAvB,CADsC;AAEnDC,EAAAA,UAAU,EAAE,CAAEJ,YAAY,CAACK,IAAf,CAFuC;AAGnDC,EAAAA,WAAW,EAAEN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A,KAFM,MAEA,IAAKmC,YAAY,KAAKlE,aAAtB,EAAsC;AAC5C,aAAO8D,kBAAkB,CAAEjC,MAAF,EAAU;AAAEE,QAAAA,MAAF;AAAU4B,QAAAA;AAAV,OAAV,CAAzB;AACA;;AACD,WAAO;AAAEnB,MAAAA,QAAQ,EAAEnC,kBAAZ;AAAgCkC,MAAAA,WAAW,EAAE;AAA7C,KAAP;AACA,GAbc,EAcf,CAAET,UAAF,EAAcoC,YAAd,EAA4BnC,MAA5B,EAAoC4B,UAApC,CAde,CAAhB;AAgBA,CArBM;AAuBP,eAAeM,WAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { parse } from '@wordpress/blocks';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { decodeEntities } from '@wordpress/html-entities';\n\n/**\n * Internal dependencies\n */\nimport {\n\tCORE_PATTERN_SOURCES,\n\tPATTERNS,\n\tSYNC_TYPES,\n\tTEMPLATE_PARTS,\n\tUSER_PATTERNS,\n\tfilterOutDuplicatesByName,\n} from './utils';\nimport { unlock } from '../../lock-unlock';\nimport { searchItems } from './search-items';\nimport { store as editSiteStore } from '../../store';\n\nconst EMPTY_PATTERN_LIST = [];\n\nconst createTemplatePartId = ( theme, slug ) =>\n\ttheme && slug ? theme + '//' + slug : null;\n\nconst templatePartToPattern = ( templatePart ) => ( {\n\tblocks: parse( templatePart.content.raw ),\n\tcategories: [ templatePart.area ],\n\tdescription: templatePart.description || '',\n\tisCustom: templatePart.source === 'custom',\n\tkeywords: templatePart.keywords || [],\n\tid: createTemplatePartId( templatePart.theme, templatePart.slug ),\n\tname: createTemplatePartId( templatePart.theme, templatePart.slug ),\n\ttitle: decodeEntities( templatePart.title.rendered ),\n\ttype: templatePart.type,\n\ttemplatePart,\n} );\n\nconst templatePartHasCategory = ( item, category ) =>\n\titem.templatePart.area === category;\n\nconst selectTemplatePartsAsPatterns = (\n\tselect,\n\t{ categoryId, search = '' } = {}\n) => {\n\tconst { getEntityRecords, getIsResolving } = select( coreStore );\n\tconst query = { per_page: -1 };\n\tconst rawTemplateParts =\n\t\tgetEntityRecords( 'postType', TEMPLATE_PARTS, query ) ??\n\t\tEMPTY_PATTERN_LIST;\n\tconst templateParts = rawTemplateParts.map( ( templatePart ) =>\n\t\ttemplatePartToPattern( templatePart )\n\t);\n\n\tconst isResolving = getIsResolving( 'getEntityRecords', [\n\t\t'postType',\n\t\t'wp_template_part',\n\t\tquery,\n\t] );\n\n\tconst patterns = searchItems( templateParts, search, {\n\t\tcategoryId,\n\t\thasCategory: templatePartHasCategory,\n\t} );\n\n\treturn { patterns, isResolving };\n};\n\nconst selectThemePatterns = ( select, { categoryId, search = '' } = {} ) => {\n\tconst { getSettings } = unlock( select( editSiteStore ) );\n\tconst settings = getSettings();\n\tconst blockPatterns =\n\t\tsettings.__experimentalAdditionalBlockPatterns ??\n\t\tsettings.__experimentalBlockPatterns;\n\n\tconst restBlockPatterns = select( coreStore ).getBlockPatterns();\n\n\tlet patterns = [\n\t\t...( blockPatterns || [] ),\n\t\t...( restBlockPatterns || [] ),\n\t]\n\t\t.filter(\n\t\t\t( pattern ) => ! CORE_PATTERN_SOURCES.includes( pattern.source )\n\t\t)\n\t\t.filter( filterOutDuplicatesByName )\n\t\t.filter( ( pattern ) => pattern.inserter !== false )\n\t\t.map( ( pattern ) => ( {\n\t\t\t...pattern,\n\t\t\tkeywords: pattern.keywords || [],\n\t\t\ttype: 'pattern',\n\t\t\tblocks: parse( pattern.content ),\n\t\t} ) );\n\n\tif ( categoryId ) {\n\t\tpatterns = searchItems( patterns, search, {\n\t\t\tcategoryId,\n\t\t\thasCategory: ( item, currentCategory ) =>\n\t\t\t\titem.categories?.includes( currentCategory ),\n\t\t} );\n\t} else {\n\t\tpatterns = searchItems( patterns, search, {\n\t\t\thasCategory: ( item ) => ! item.hasOwnProperty( 'categories' ),\n\t\t} );\n\t}\n\n\treturn { patterns, isResolving: false };\n};\n\nconst reusableBlockToPattern = ( reusableBlock ) => ( {\n\tblocks: parse( reusableBlock.content.raw ),\n\tcategories: reusableBlock.wp_pattern,\n\tid: reusableBlock.id,\n\tname: reusableBlock.slug,\n\tsyncStatus: reusableBlock.wp_pattern_sync_status || SYNC_TYPES.full,\n\ttitle: reusableBlock.title.raw,\n\ttype: reusableBlock.type,\n\treusableBlock,\n} );\n\nconst selectUserPatterns = ( select, { search = '', syncStatus } = {} ) => {\n\tconst { getEntityRecords, getIsResolving } = select( coreStore );\n\n\tconst query = { per_page: -1 };\n\tconst records = getEntityRecords( 'postType', USER_PATTERNS, query );\n\n\tlet patterns = records\n\t\t? records.map( ( record ) => reusableBlockToPattern( record ) )\n\t\t: EMPTY_PATTERN_LIST;\n\tconst isResolving = getIsResolving( 'getEntityRecords', [\n\t\t'postType',\n\t\tUSER_PATTERNS,\n\t\tquery,\n\t] );\n\n\tif ( syncStatus ) {\n\t\tpatterns = patterns.filter(\n\t\t\t( pattern ) => pattern.syncStatus === syncStatus\n\t\t);\n\t}\n\n\tpatterns = searchItems( patterns, search, {\n\t\t// We exit user pattern retrieval early if we aren't in the\n\t\t// catch-all category for user created patterns, so it has\n\t\t// to be in the category.\n\t\thasCategory: () => true,\n\t} );\n\n\treturn { patterns, isResolving };\n};\n\nexport const usePatterns = (\n\tcategoryType,\n\tcategoryId,\n\t{ search = '', syncStatus }\n) => {\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tif ( categoryType === TEMPLATE_PARTS ) {\n\t\t\t\treturn selectTemplatePartsAsPatterns( select, {\n\t\t\t\t\tcategoryId,\n\t\t\t\t\tsearch,\n\t\t\t\t} );\n\t\t\t} else if ( categoryType === PATTERNS ) {\n\t\t\t\treturn selectThemePatterns( select, { categoryId, search } );\n\t\t\t} else if ( categoryType === USER_PATTERNS ) {\n\t\t\t\treturn selectUserPatterns( select, { search, syncStatus } );\n\t\t\t}\n\t\t\treturn { patterns: EMPTY_PATTERN_LIST, isResolving: false };\n\t\t},\n\t\t[ categoryId, categoryType, search, syncStatus ]\n\t);\n};\n\nexport default usePatterns;\n"]}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export const DEFAULT_CATEGORY = '
|
|
2
|
-
export const DEFAULT_TYPE = '
|
|
1
|
+
export const DEFAULT_CATEGORY = 'my-patterns';
|
|
2
|
+
export const DEFAULT_TYPE = 'wp_block';
|
|
3
3
|
export const PATTERNS = 'pattern';
|
|
4
4
|
export const TEMPLATE_PARTS = 'wp_template_part';
|
|
5
5
|
export const USER_PATTERNS = 'wp_block';
|
|
6
|
-
export const USER_PATTERN_CATEGORY = '
|
|
6
|
+
export const USER_PATTERN_CATEGORY = 'my-patterns';
|
|
7
7
|
export const CORE_PATTERN_SOURCES = ['core', 'pattern-directory/core', 'pattern-directory/featured', 'pattern-directory/theme'];
|
|
8
8
|
export const SYNC_TYPES = {
|
|
9
9
|
full: 'fully',
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/page-patterns/utils.js"],"names":["DEFAULT_CATEGORY","DEFAULT_TYPE","PATTERNS","TEMPLATE_PARTS","USER_PATTERNS","USER_PATTERN_CATEGORY","CORE_PATTERN_SOURCES","SYNC_TYPES","full","unsynced","filterOutDuplicatesByName","currentItem","index","items","findIndex","item","name"],"mappings":"AAAA,OAAO,MAAMA,gBAAgB,GAAG,aAAzB;AACP,OAAO,MAAMC,YAAY,GAAG,UAArB;AACP,OAAO,MAAMC,QAAQ,GAAG,SAAjB;AACP,OAAO,MAAMC,cAAc,GAAG,kBAAvB;AACP,OAAO,MAAMC,aAAa,GAAG,UAAtB;AACP,OAAO,MAAMC,qBAAqB,GAAG,aAA9B;AAEP,OAAO,MAAMC,oBAAoB,GAAG,CACnC,MADmC,EAEnC,wBAFmC,EAGnC,4BAHmC,EAInC,yBAJmC,CAA7B;AAOP,OAAO,MAAMC,UAAU,GAAG;AACzBC,EAAAA,IAAI,EAAE,OADmB;AAEzBC,EAAAA,QAAQ,EAAE;AAFe,CAAnB;AAKP,OAAO,MAAMC,yBAAyB,GAAG,CAAEC,WAAF,EAAeC,KAAf,EAAsBC,KAAtB,KACxCD,KAAK,KAAKC,KAAK,CAACC,SAAN,CAAmBC,IAAF,IAAYJ,WAAW,CAACK,IAAZ,KAAqBD,IAAI,CAACC,IAAvD,CADJ","sourcesContent":["export const DEFAULT_CATEGORY = 'my-patterns';\nexport const DEFAULT_TYPE = 'wp_block';\nexport const PATTERNS = 'pattern';\nexport const TEMPLATE_PARTS = 'wp_template_part';\nexport const USER_PATTERNS = 'wp_block';\nexport const USER_PATTERN_CATEGORY = 'my-patterns';\n\nexport const CORE_PATTERN_SOURCES = [\n\t'core',\n\t'pattern-directory/core',\n\t'pattern-directory/featured',\n\t'pattern-directory/theme',\n];\n\nexport const SYNC_TYPES = {\n\tfull: 'fully',\n\tunsynced: 'unsynced',\n};\n\nexport const filterOutDuplicatesByName = ( currentItem, index, items ) =>\n\tindex === items.findIndex( ( item ) => currentItem.name === item.name );\n"]}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { createElement, Fragment } from "@wordpress/element";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* WordPress dependencies
|
|
5
|
+
*/
|
|
6
|
+
import { privateApis as routerPrivateApis } from '@wordpress/router';
|
|
7
|
+
import { useSelect } from '@wordpress/data';
|
|
8
|
+
import { store as coreStore } from '@wordpress/core-data';
|
|
9
|
+
import { useState } from '@wordpress/element';
|
|
10
|
+
import { Button } from '@wordpress/components';
|
|
11
|
+
/**
|
|
12
|
+
* Internal dependencies
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import { unlock } from '../../lock-unlock';
|
|
16
|
+
import { store as editSiteStore } from '../../store';
|
|
17
|
+
import CreateTemplatePartModal from '../create-template-part-modal';
|
|
18
|
+
const {
|
|
19
|
+
useHistory
|
|
20
|
+
} = unlock(routerPrivateApis);
|
|
21
|
+
export default function AddNewTemplatePart() {
|
|
22
|
+
const {
|
|
23
|
+
canCreate,
|
|
24
|
+
postType
|
|
25
|
+
} = useSelect(select => {
|
|
26
|
+
const {
|
|
27
|
+
supportsTemplatePartsMode
|
|
28
|
+
} = select(editSiteStore).getSettings();
|
|
29
|
+
return {
|
|
30
|
+
canCreate: !supportsTemplatePartsMode,
|
|
31
|
+
postType: select(coreStore).getPostType('wp_template_part')
|
|
32
|
+
};
|
|
33
|
+
}, []);
|
|
34
|
+
const [isModalOpen, setIsModalOpen] = useState(false);
|
|
35
|
+
const history = useHistory();
|
|
36
|
+
|
|
37
|
+
if (!canCreate || !postType) {
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return createElement(Fragment, null, createElement(Button, {
|
|
42
|
+
variant: "primary",
|
|
43
|
+
onClick: () => setIsModalOpen(true)
|
|
44
|
+
}, postType.labels.add_new_item), isModalOpen && createElement(CreateTemplatePartModal, {
|
|
45
|
+
closeModal: () => setIsModalOpen(false),
|
|
46
|
+
blocks: [],
|
|
47
|
+
onCreate: templatePart => {
|
|
48
|
+
setIsModalOpen(false);
|
|
49
|
+
history.push({
|
|
50
|
+
postId: templatePart.id,
|
|
51
|
+
postType: 'wp_template_part',
|
|
52
|
+
canvas: 'edit'
|
|
53
|
+
});
|
|
54
|
+
},
|
|
55
|
+
onError: () => setIsModalOpen(false)
|
|
56
|
+
}));
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=add-new-template-part.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/page-template-parts/add-new-template-part.js"],"names":["privateApis","routerPrivateApis","useSelect","store","coreStore","useState","Button","unlock","editSiteStore","CreateTemplatePartModal","useHistory","AddNewTemplatePart","canCreate","postType","select","supportsTemplatePartsMode","getSettings","getPostType","isModalOpen","setIsModalOpen","history","labels","add_new_item","templatePart","push","postId","id","canvas"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,WAAW,IAAIC,iBAAxB,QAAiD,mBAAjD;AACA,SAASC,SAAT,QAA0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AAAA,cAAc,CAAE,KAAF,CAAd;AACAC,MAAAA,OAAO,CAACI,IAAR,CAAc;AACbC,QAAAA,MAAM,EAAEF,YAAY,CAACG,EADR;AAEbb,QAAAA,QAAQ,EAAE,kBAFG;AAGbc,QAAAA,MAAM,EAAE;AAHK,OAAd;AAKA,KAVF;AAWC,IAAA,OAAO,EAAG,MAAMR,cAAc,CAAE,KAAF;AAX/B,IALF,CADD;AAsBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useState } from '@wordpress/element';\nimport { Button } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\nimport { store as editSiteStore } from '../../store';\nimport CreateTemplatePartModal from '../create-template-part-modal';\n\nconst { useHistory } = unlock( routerPrivateApis );\n\nexport default function AddNewTemplatePart() {\n\tconst { canCreate, postType } = useSelect( ( select ) => {\n\t\tconst { supportsTemplatePartsMode } =\n\t\t\tselect( editSiteStore ).getSettings();\n\t\treturn {\n\t\t\tcanCreate: ! supportsTemplatePartsMode,\n\t\t\tpostType: select( coreStore ).getPostType( 'wp_template_part' ),\n\t\t};\n\t}, [] );\n\tconst [ isModalOpen, setIsModalOpen ] = useState( false );\n\tconst history = useHistory();\n\n\tif ( ! canCreate || ! postType ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<Button variant=\"primary\" onClick={ () => setIsModalOpen( true ) }>\n\t\t\t\t{ postType.labels.add_new_item }\n\t\t\t</Button>\n\t\t\t{ isModalOpen && (\n\t\t\t\t<CreateTemplatePartModal\n\t\t\t\t\tcloseModal={ () => setIsModalOpen( false ) }\n\t\t\t\t\tblocks={ [] }\n\t\t\t\t\tonCreate={ ( templatePart ) => {\n\t\t\t\t\t\tsetIsModalOpen( false );\n\t\t\t\t\t\thistory.push( {\n\t\t\t\t\t\t\tpostId: templatePart.id,\n\t\t\t\t\t\t\tpostType: 'wp_template_part',\n\t\t\t\t\t\t\tcanvas: 'edit',\n\t\t\t\t\t\t} );\n\t\t\t\t\t} }\n\t\t\t\t\tonError={ () => setIsModalOpen( false ) }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n"]}
|