@wordpress/edit-site 6.34.0 → 6.34.1-next.2f1c7c01b.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/build/components/add-new-pattern/index.js +6 -4
- package/build/components/add-new-pattern/index.js.map +1 -1
- package/build/components/add-new-post/index.js +3 -1
- package/build/components/add-new-post/index.js.map +1 -1
- package/build/components/add-new-template/add-custom-generic-template-modal-content.js +3 -1
- package/build/components/add-new-template/add-custom-generic-template-modal-content.js.map +1 -1
- package/build/components/add-new-template/add-custom-template-modal-content.js +4 -2
- package/build/components/add-new-template/add-custom-template-modal-content.js.map +1 -1
- package/build/components/add-new-template/index.js +7 -5
- package/build/components/add-new-template/index.js.map +1 -1
- package/build/components/add-new-template/utils.js +14 -12
- package/build/components/add-new-template/utils.js.map +1 -1
- package/build/components/app/index.js +4 -2
- package/build/components/app/index.js.map +1 -1
- package/build/components/block-editor/use-editor-iframe-props.js +3 -1
- package/build/components/block-editor/use-editor-iframe-props.js.map +1 -1
- package/build/components/block-editor/use-navigate-to-entity-record.js +3 -1
- package/build/components/block-editor/use-navigate-to-entity-record.js.map +1 -1
- package/build/components/block-editor/use-site-editor-settings.js +3 -1
- package/build/components/block-editor/use-site-editor-settings.js.map +1 -1
- package/build/components/canvas-loader/index.js +5 -3
- package/build/components/canvas-loader/index.js.map +1 -1
- package/build/components/dataviews-actions/index.js +5 -3
- package/build/components/dataviews-actions/index.js.map +1 -1
- package/build/components/editor/index.js +8 -6
- package/build/components/editor/index.js.map +1 -1
- package/build/components/editor/site-preview.js +3 -1
- package/build/components/editor/site-preview.js.map +1 -1
- package/build/components/editor/use-adapt-editor-to-canvas.js +2 -0
- package/build/components/editor/use-adapt-editor-to-canvas.js.map +1 -1
- package/build/components/editor/use-editor-title.js +3 -1
- package/build/components/editor/use-editor-title.js.map +1 -1
- package/build/components/editor/use-resolve-edited-entity.js +5 -3
- package/build/components/editor/use-resolve-edited-entity.js.map +1 -1
- package/build/components/layout/animation.js +3 -1
- package/build/components/layout/animation.js.map +1 -1
- package/build/components/layout/hooks.js +3 -1
- package/build/components/layout/hooks.js.map +1 -1
- package/build/components/layout/index.js +6 -4
- package/build/components/layout/index.js.map +1 -1
- package/build/components/media/index.js +3 -1
- package/build/components/media/index.js.map +1 -1
- package/build/components/more-menu/index.js +4 -2
- package/build/components/more-menu/index.js.map +1 -1
- package/build/components/more-menu/site-export.js +3 -1
- package/build/components/more-menu/site-export.js.map +1 -1
- package/build/components/more-menu/welcome-guide-menu-item.js +3 -1
- package/build/components/more-menu/welcome-guide-menu-item.js.map +1 -1
- package/build/components/page-patterns/actions.js +3 -1
- package/build/components/page-patterns/actions.js.map +1 -1
- package/build/components/page-patterns/delete-category-menu-item.js +4 -2
- package/build/components/page-patterns/delete-category-menu-item.js.map +1 -1
- package/build/components/page-patterns/fields.js +8 -6
- package/build/components/page-patterns/fields.js.map +1 -1
- package/build/components/page-patterns/index.js +9 -7
- package/build/components/page-patterns/index.js.map +1 -1
- package/build/components/page-patterns/rename-category-menu-item.js +4 -2
- package/build/components/page-patterns/rename-category-menu-item.js.map +1 -1
- package/build/components/page-patterns/search-items.js +10 -8
- package/build/components/page-patterns/search-items.js.map +1 -1
- package/build/components/page-patterns/use-pattern-settings.js +2 -0
- package/build/components/page-patterns/use-pattern-settings.js.map +1 -1
- package/build/components/page-patterns/use-patterns.js +8 -6
- package/build/components/page-patterns/use-patterns.js.map +1 -1
- package/build/components/page-patterns/utils.js +3 -1
- package/build/components/page-patterns/utils.js.map +1 -1
- package/build/components/page-templates/fields.js +14 -12
- package/build/components/page-templates/fields.js.map +2 -2
- package/build/components/page-templates/hooks.js +2 -0
- package/build/components/page-templates/hooks.js.map +1 -1
- package/build/components/page-templates/index.js +16 -11
- package/build/components/page-templates/index.js.map +2 -2
- package/build/components/page-templates/view-utils.js +8 -2
- package/build/components/page-templates/view-utils.js.map +2 -2
- package/build/components/pagination/index.js +3 -1
- package/build/components/pagination/index.js.map +1 -1
- package/build/components/plugin-template-setting-panel/index.js +5 -3
- package/build/components/plugin-template-setting-panel/index.js.map +1 -1
- package/build/components/post-edit/index.js +5 -3
- package/build/components/post-edit/index.js.map +1 -1
- package/build/components/post-list/index.js +8 -6
- package/build/components/post-list/index.js.map +1 -1
- package/build/components/post-list/view-utils.js +5 -3
- package/build/components/post-list/view-utils.js.map +1 -1
- package/build/components/posts-app/index.js +4 -2
- package/build/components/posts-app/index.js.map +1 -1
- package/build/components/posts-app-routes/index.js +3 -1
- package/build/components/posts-app-routes/index.js.map +1 -1
- package/build/components/posts-app-routes/post-item.js +4 -2
- package/build/components/posts-app-routes/post-item.js.map +1 -1
- package/build/components/posts-app-routes/posts.js +5 -3
- package/build/components/posts-app-routes/posts.js.map +1 -1
- package/build/components/resizable-frame/index.js +10 -8
- package/build/components/resizable-frame/index.js.map +1 -1
- package/build/components/routes/use-title.js +3 -1
- package/build/components/routes/use-title.js.map +1 -1
- package/build/components/save-button/index.js +4 -2
- package/build/components/save-button/index.js.map +1 -1
- package/build/components/save-hub/index.js +3 -1
- package/build/components/save-hub/index.js.map +1 -1
- package/build/components/save-keyboard-shortcut/index.js +3 -1
- package/build/components/save-keyboard-shortcut/index.js.map +1 -1
- package/build/components/save-panel/index.js +7 -5
- package/build/components/save-panel/index.js.map +1 -1
- package/build/components/sidebar/index.js +4 -2
- package/build/components/sidebar/index.js.map +1 -1
- package/build/components/sidebar-button/index.js +3 -1
- package/build/components/sidebar-button/index.js.map +1 -1
- package/build/components/sidebar-dataviews/dataview-item.js +4 -2
- package/build/components/sidebar-dataviews/dataview-item.js.map +1 -1
- package/build/components/sidebar-dataviews/index.js +4 -2
- package/build/components/sidebar-dataviews/index.js.map +1 -1
- package/build/components/sidebar-global-styles/index.js +7 -5
- package/build/components/sidebar-global-styles/index.js.map +1 -1
- package/build/components/sidebar-navigation-item/index.js +4 -2
- package/build/components/sidebar-navigation-item/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen/index.js +4 -2
- package/build/components/sidebar-navigation-screen/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-details-footer/index.js +3 -1
- package/build/components/sidebar-navigation-screen-details-footer/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-global-styles/content.js +4 -2
- package/build/components/sidebar-navigation-screen-global-styles/content.js.map +1 -1
- package/build/components/sidebar-navigation-screen-global-styles/index.js +4 -2
- package/build/components/sidebar-navigation-screen-global-styles/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-main/index.js +3 -1
- package/build/components/sidebar-navigation-screen-main/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-menu/delete-confirm-dialog.js +3 -1
- package/build/components/sidebar-navigation-screen-navigation-menu/delete-confirm-dialog.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-menu/index.js +5 -3
- package/build/components/sidebar-navigation-screen-navigation-menu/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-menu/more-menu.js +5 -3
- package/build/components/sidebar-navigation-screen-navigation-menu/more-menu.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-menu/navigation-menu-editor.js +4 -2
- package/build/components/sidebar-navigation-screen-navigation-menu/navigation-menu-editor.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-menu/rename-modal.js +4 -2
- 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 +3 -1
- 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 +3 -1
- 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 +2 -0
- package/build/components/sidebar-navigation-screen-navigation-menus/build-navigation-label.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-menus/constants.js +3 -1
- package/build/components/sidebar-navigation-screen-navigation-menus/constants.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-menus/index.js +4 -2
- package/build/components/sidebar-navigation-screen-navigation-menus/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-menus/leaf-more-menu.js +5 -3
- package/build/components/sidebar-navigation-screen-navigation-menus/leaf-more-menu.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js +6 -4
- package/build/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js.map +1 -1
- package/build/components/sidebar-navigation-screen-patterns/category-item.js +3 -1
- package/build/components/sidebar-navigation-screen-patterns/category-item.js.map +1 -1
- package/build/components/sidebar-navigation-screen-patterns/index.js +4 -2
- package/build/components/sidebar-navigation-screen-patterns/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-patterns/use-default-pattern-categories.js +2 -0
- package/build/components/sidebar-navigation-screen-patterns/use-default-pattern-categories.js.map +1 -1
- package/build/components/sidebar-navigation-screen-patterns/use-pattern-categories.js +2 -0
- package/build/components/sidebar-navigation-screen-patterns/use-pattern-categories.js.map +1 -1
- package/build/components/sidebar-navigation-screen-patterns/use-template-part-areas.js +3 -1
- package/build/components/sidebar-navigation-screen-patterns/use-template-part-areas.js.map +1 -1
- package/build/components/sidebar-navigation-screen-patterns/use-theme-patterns.js +2 -0
- package/build/components/sidebar-navigation-screen-patterns/use-theme-patterns.js.map +1 -1
- package/build/components/sidebar-navigation-screen-templates-browse/content.js +5 -3
- package/build/components/sidebar-navigation-screen-templates-browse/content.js.map +1 -1
- package/build/components/sidebar-navigation-screen-templates-browse/index.js +3 -1
- package/build/components/sidebar-navigation-screen-templates-browse/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-unsupported/index.js +3 -1
- package/build/components/sidebar-navigation-screen-unsupported/index.js.map +1 -1
- package/build/components/site-editor-routes/home.js +4 -2
- package/build/components/site-editor-routes/home.js.map +1 -1
- package/build/components/site-editor-routes/index.js +3 -1
- package/build/components/site-editor-routes/index.js.map +1 -1
- package/build/components/site-editor-routes/navigation-item.js +5 -3
- package/build/components/site-editor-routes/navigation-item.js.map +1 -1
- package/build/components/site-editor-routes/navigation.js +5 -3
- package/build/components/site-editor-routes/navigation.js.map +1 -1
- package/build/components/site-editor-routes/notfound.js +4 -2
- package/build/components/site-editor-routes/notfound.js.map +1 -1
- package/build/components/site-editor-routes/page-item.js +4 -2
- package/build/components/site-editor-routes/page-item.js.map +1 -1
- package/build/components/site-editor-routes/pages.js +5 -3
- package/build/components/site-editor-routes/pages.js.map +1 -1
- package/build/components/site-editor-routes/pattern-item.js +4 -2
- package/build/components/site-editor-routes/pattern-item.js.map +1 -1
- package/build/components/site-editor-routes/patterns.js +4 -2
- package/build/components/site-editor-routes/patterns.js.map +1 -1
- package/build/components/site-editor-routes/stylebook.js +5 -3
- package/build/components/site-editor-routes/stylebook.js.map +1 -1
- package/build/components/site-editor-routes/styles.js +6 -4
- package/build/components/site-editor-routes/styles.js.map +1 -1
- package/build/components/site-editor-routes/template-item.js +5 -3
- package/build/components/site-editor-routes/template-item.js.map +1 -1
- package/build/components/site-editor-routes/template-part-item.js +4 -2
- package/build/components/site-editor-routes/template-part-item.js.map +1 -1
- package/build/components/site-editor-routes/templates.js +4 -2
- package/build/components/site-editor-routes/templates.js.map +1 -1
- package/build/components/site-editor-routes/utils.js +2 -0
- package/build/components/site-editor-routes/utils.js.map +1 -1
- package/build/components/site-hub/index.js +6 -4
- package/build/components/site-hub/index.js.map +1 -1
- package/build/components/site-icon/index.js +3 -1
- package/build/components/site-icon/index.js.map +1 -1
- package/build/components/welcome-guide/editor.js +3 -1
- package/build/components/welcome-guide/editor.js.map +1 -1
- package/build/components/welcome-guide/image.js +2 -0
- package/build/components/welcome-guide/image.js.map +1 -1
- package/build/components/welcome-guide/index.js +3 -1
- package/build/components/welcome-guide/index.js.map +1 -1
- package/build/components/welcome-guide/page.js +3 -1
- package/build/components/welcome-guide/page.js.map +1 -1
- package/build/components/welcome-guide/template.js +3 -1
- package/build/components/welcome-guide/template.js.map +1 -1
- package/build/deprecated.js +5 -3
- package/build/deprecated.js.map +1 -1
- package/build/hooks/commands/use-common-commands.js +7 -5
- package/build/hooks/commands/use-common-commands.js.map +1 -1
- package/build/hooks/commands/use-set-command-context.js +4 -2
- package/build/hooks/commands/use-set-command-context.js.map +1 -1
- package/build/index.js +4 -2
- package/build/index.js.map +1 -1
- package/build/lock-unlock.js +3 -1
- package/build/lock-unlock.js.map +1 -1
- package/build/posts.js +3 -1
- package/build/posts.js.map +1 -1
- package/build/store/actions.js +14 -12
- package/build/store/actions.js.map +1 -1
- package/build/store/constants.js +3 -1
- package/build/store/constants.js.map +1 -1
- package/build/store/index.js +4 -2
- package/build/store/index.js.map +1 -1
- package/build/store/private-actions.js +2 -0
- package/build/store/private-actions.js.map +1 -1
- package/build/store/private-selectors.js +2 -0
- package/build/store/private-selectors.js.map +1 -1
- package/build/store/reducer.js +2 -0
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +11 -9
- package/build/store/selectors.js.map +1 -1
- package/build/utils/constants.js +18 -16
- package/build/utils/constants.js.map +1 -1
- package/build/utils/get-filtered-template-parts.js +3 -1
- package/build/utils/get-filtered-template-parts.js.map +1 -1
- package/build/utils/is-previewing-theme.js +2 -0
- package/build/utils/is-previewing-theme.js.map +1 -1
- package/build/utils/is-template-removable.js +2 -0
- package/build/utils/is-template-removable.js.map +1 -1
- package/build/utils/is-template-revertable.js +2 -0
- package/build/utils/is-template-revertable.js.map +2 -2
- package/build/utils/use-activate-theme.js +3 -1
- package/build/utils/use-activate-theme.js.map +1 -1
- package/build/utils/use-actual-current-theme.js +3 -1
- package/build/utils/use-actual-current-theme.js.map +1 -1
- package/build-module/components/add-new-pattern/index.js +5 -4
- package/build-module/components/add-new-pattern/index.js.map +1 -1
- package/build-module/components/add-new-post/index.js +2 -1
- package/build-module/components/add-new-post/index.js.map +1 -1
- package/build-module/components/add-new-template/add-custom-generic-template-modal-content.js +2 -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/add-custom-template-modal-content.js +3 -2
- package/build-module/components/add-new-template/add-custom-template-modal-content.js.map +1 -1
- package/build-module/components/add-new-template/index.js +6 -5
- package/build-module/components/add-new-template/index.js.map +1 -1
- package/build-module/components/add-new-template/utils.js +13 -12
- package/build-module/components/add-new-template/utils.js.map +1 -1
- package/build-module/components/app/index.js +3 -2
- package/build-module/components/app/index.js.map +1 -1
- package/build-module/components/block-editor/use-editor-iframe-props.js +2 -1
- package/build-module/components/block-editor/use-editor-iframe-props.js.map +1 -1
- package/build-module/components/block-editor/use-navigate-to-entity-record.js +2 -1
- package/build-module/components/block-editor/use-navigate-to-entity-record.js.map +1 -1
- package/build-module/components/block-editor/use-site-editor-settings.js +2 -1
- package/build-module/components/block-editor/use-site-editor-settings.js.map +1 -1
- package/build-module/components/canvas-loader/index.js +4 -3
- package/build-module/components/canvas-loader/index.js.map +1 -1
- package/build-module/components/dataviews-actions/index.js +4 -3
- package/build-module/components/dataviews-actions/index.js.map +1 -1
- package/build-module/components/editor/index.js +7 -6
- package/build-module/components/editor/index.js.map +1 -1
- package/build-module/components/editor/site-preview.js +2 -1
- package/build-module/components/editor/site-preview.js.map +1 -1
- package/build-module/components/editor/use-adapt-editor-to-canvas.js +1 -0
- package/build-module/components/editor/use-adapt-editor-to-canvas.js.map +1 -1
- package/build-module/components/editor/use-editor-title.js +2 -1
- package/build-module/components/editor/use-editor-title.js.map +1 -1
- package/build-module/components/editor/use-resolve-edited-entity.js +4 -3
- package/build-module/components/editor/use-resolve-edited-entity.js.map +1 -1
- package/build-module/components/layout/animation.js +2 -1
- package/build-module/components/layout/animation.js.map +1 -1
- package/build-module/components/layout/hooks.js +2 -1
- package/build-module/components/layout/hooks.js.map +1 -1
- package/build-module/components/layout/index.js +5 -4
- package/build-module/components/layout/index.js.map +1 -1
- package/build-module/components/media/index.js +2 -1
- package/build-module/components/media/index.js.map +1 -1
- package/build-module/components/more-menu/index.js +3 -2
- package/build-module/components/more-menu/index.js.map +1 -1
- package/build-module/components/more-menu/site-export.js +2 -1
- package/build-module/components/more-menu/site-export.js.map +1 -1
- package/build-module/components/more-menu/welcome-guide-menu-item.js +2 -1
- package/build-module/components/more-menu/welcome-guide-menu-item.js.map +1 -1
- package/build-module/components/page-patterns/actions.js +2 -1
- package/build-module/components/page-patterns/actions.js.map +1 -1
- package/build-module/components/page-patterns/delete-category-menu-item.js +3 -2
- package/build-module/components/page-patterns/delete-category-menu-item.js.map +1 -1
- package/build-module/components/page-patterns/fields.js +7 -6
- package/build-module/components/page-patterns/fields.js.map +1 -1
- package/build-module/components/page-patterns/index.js +8 -7
- package/build-module/components/page-patterns/index.js.map +1 -1
- package/build-module/components/page-patterns/rename-category-menu-item.js +3 -2
- package/build-module/components/page-patterns/rename-category-menu-item.js.map +1 -1
- package/build-module/components/page-patterns/search-items.js +11 -10
- package/build-module/components/page-patterns/search-items.js.map +1 -1
- package/build-module/components/page-patterns/use-pattern-settings.js +1 -0
- package/build-module/components/page-patterns/use-pattern-settings.js.map +1 -1
- package/build-module/components/page-patterns/use-patterns.js +7 -6
- package/build-module/components/page-patterns/use-patterns.js.map +1 -1
- package/build-module/components/page-patterns/utils.js +2 -1
- package/build-module/components/page-patterns/utils.js.map +1 -1
- package/build-module/components/page-templates/fields.js +13 -12
- package/build-module/components/page-templates/fields.js.map +2 -2
- package/build-module/components/page-templates/hooks.js +1 -0
- package/build-module/components/page-templates/hooks.js.map +1 -1
- package/build-module/components/page-templates/index.js +15 -11
- package/build-module/components/page-templates/index.js.map +2 -2
- package/build-module/components/page-templates/view-utils.js +7 -2
- package/build-module/components/page-templates/view-utils.js.map +2 -2
- package/build-module/components/pagination/index.js +2 -1
- package/build-module/components/pagination/index.js.map +1 -1
- package/build-module/components/plugin-template-setting-panel/index.js +4 -3
- package/build-module/components/plugin-template-setting-panel/index.js.map +1 -1
- package/build-module/components/post-edit/index.js +4 -3
- package/build-module/components/post-edit/index.js.map +1 -1
- package/build-module/components/post-list/index.js +7 -6
- package/build-module/components/post-list/index.js.map +1 -1
- package/build-module/components/post-list/view-utils.js +4 -3
- package/build-module/components/post-list/view-utils.js.map +1 -1
- package/build-module/components/posts-app/index.js +3 -2
- package/build-module/components/posts-app/index.js.map +1 -1
- package/build-module/components/posts-app-routes/index.js +2 -1
- package/build-module/components/posts-app-routes/index.js.map +1 -1
- package/build-module/components/posts-app-routes/post-item.js +3 -2
- package/build-module/components/posts-app-routes/post-item.js.map +1 -1
- package/build-module/components/posts-app-routes/posts.js +4 -3
- package/build-module/components/posts-app-routes/posts.js.map +1 -1
- package/build-module/components/resizable-frame/index.js +9 -8
- package/build-module/components/resizable-frame/index.js.map +1 -1
- package/build-module/components/routes/use-title.js +2 -1
- package/build-module/components/routes/use-title.js.map +1 -1
- package/build-module/components/save-button/index.js +3 -2
- package/build-module/components/save-button/index.js.map +1 -1
- package/build-module/components/save-hub/index.js +2 -1
- package/build-module/components/save-hub/index.js.map +1 -1
- package/build-module/components/save-keyboard-shortcut/index.js +2 -1
- package/build-module/components/save-keyboard-shortcut/index.js.map +1 -1
- package/build-module/components/save-panel/index.js +6 -5
- package/build-module/components/save-panel/index.js.map +1 -1
- package/build-module/components/sidebar/index.js +3 -2
- package/build-module/components/sidebar/index.js.map +1 -1
- package/build-module/components/sidebar-button/index.js +2 -1
- package/build-module/components/sidebar-button/index.js.map +1 -1
- package/build-module/components/sidebar-dataviews/dataview-item.js +3 -2
- package/build-module/components/sidebar-dataviews/dataview-item.js.map +1 -1
- package/build-module/components/sidebar-dataviews/index.js +3 -2
- package/build-module/components/sidebar-dataviews/index.js.map +1 -1
- package/build-module/components/sidebar-global-styles/index.js +6 -5
- package/build-module/components/sidebar-global-styles/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-item/index.js +3 -2
- package/build-module/components/sidebar-navigation-item/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen/index.js +3 -2
- package/build-module/components/sidebar-navigation-screen/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-details-footer/index.js +2 -1
- package/build-module/components/sidebar-navigation-screen-details-footer/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-global-styles/content.js +3 -2
- package/build-module/components/sidebar-navigation-screen-global-styles/content.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-global-styles/index.js +3 -2
- package/build-module/components/sidebar-navigation-screen-global-styles/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-main/index.js +2 -1
- package/build-module/components/sidebar-navigation-screen-main/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menu/delete-confirm-dialog.js +2 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menu/delete-confirm-dialog.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menu/index.js +4 -3
- 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 +4 -3
- package/build-module/components/sidebar-navigation-screen-navigation-menu/more-menu.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menu/navigation-menu-editor.js +3 -2
- package/build-module/components/sidebar-navigation-screen-navigation-menu/navigation-menu-editor.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menu/rename-modal.js +3 -2
- 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 +2 -1
- 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 +2 -1
- 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 +1 -0
- package/build-module/components/sidebar-navigation-screen-navigation-menus/build-navigation-label.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menus/constants.js +2 -1
- 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 +3 -2
- package/build-module/components/sidebar-navigation-screen-navigation-menus/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menus/leaf-more-menu.js +5 -4
- package/build-module/components/sidebar-navigation-screen-navigation-menus/leaf-more-menu.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js +5 -4
- package/build-module/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-patterns/category-item.js +2 -1
- package/build-module/components/sidebar-navigation-screen-patterns/category-item.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-patterns/index.js +3 -2
- package/build-module/components/sidebar-navigation-screen-patterns/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-patterns/use-default-pattern-categories.js +1 -0
- package/build-module/components/sidebar-navigation-screen-patterns/use-default-pattern-categories.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-patterns/use-pattern-categories.js +1 -0
- package/build-module/components/sidebar-navigation-screen-patterns/use-pattern-categories.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-patterns/use-template-part-areas.js +2 -1
- package/build-module/components/sidebar-navigation-screen-patterns/use-template-part-areas.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-patterns/use-theme-patterns.js +1 -0
- package/build-module/components/sidebar-navigation-screen-patterns/use-theme-patterns.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-templates-browse/content.js +4 -3
- package/build-module/components/sidebar-navigation-screen-templates-browse/content.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-templates-browse/index.js +2 -1
- package/build-module/components/sidebar-navigation-screen-templates-browse/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-unsupported/index.js +2 -1
- package/build-module/components/sidebar-navigation-screen-unsupported/index.js.map +1 -1
- package/build-module/components/site-editor-routes/home.js +3 -2
- package/build-module/components/site-editor-routes/home.js.map +1 -1
- package/build-module/components/site-editor-routes/index.js +2 -1
- package/build-module/components/site-editor-routes/index.js.map +1 -1
- package/build-module/components/site-editor-routes/navigation-item.js +4 -3
- package/build-module/components/site-editor-routes/navigation-item.js.map +1 -1
- package/build-module/components/site-editor-routes/navigation.js +4 -3
- package/build-module/components/site-editor-routes/navigation.js.map +1 -1
- package/build-module/components/site-editor-routes/notfound.js +3 -2
- package/build-module/components/site-editor-routes/notfound.js.map +1 -1
- package/build-module/components/site-editor-routes/page-item.js +3 -2
- package/build-module/components/site-editor-routes/page-item.js.map +1 -1
- package/build-module/components/site-editor-routes/pages.js +4 -3
- package/build-module/components/site-editor-routes/pages.js.map +1 -1
- package/build-module/components/site-editor-routes/pattern-item.js +3 -2
- package/build-module/components/site-editor-routes/pattern-item.js.map +1 -1
- package/build-module/components/site-editor-routes/patterns.js +3 -2
- package/build-module/components/site-editor-routes/patterns.js.map +1 -1
- package/build-module/components/site-editor-routes/stylebook.js +4 -3
- package/build-module/components/site-editor-routes/stylebook.js.map +1 -1
- package/build-module/components/site-editor-routes/styles.js +5 -4
- package/build-module/components/site-editor-routes/styles.js.map +1 -1
- package/build-module/components/site-editor-routes/template-item.js +4 -3
- package/build-module/components/site-editor-routes/template-item.js.map +1 -1
- package/build-module/components/site-editor-routes/template-part-item.js +3 -2
- package/build-module/components/site-editor-routes/template-part-item.js.map +1 -1
- package/build-module/components/site-editor-routes/templates.js +3 -2
- package/build-module/components/site-editor-routes/templates.js.map +1 -1
- package/build-module/components/site-editor-routes/utils.js +1 -0
- package/build-module/components/site-editor-routes/utils.js.map +1 -1
- package/build-module/components/site-hub/index.js +5 -4
- package/build-module/components/site-hub/index.js.map +1 -1
- package/build-module/components/site-icon/index.js +2 -1
- package/build-module/components/site-icon/index.js.map +1 -1
- package/build-module/components/welcome-guide/editor.js +2 -1
- package/build-module/components/welcome-guide/editor.js.map +1 -1
- package/build-module/components/welcome-guide/image.js +1 -0
- package/build-module/components/welcome-guide/image.js.map +1 -1
- package/build-module/components/welcome-guide/index.js +2 -1
- package/build-module/components/welcome-guide/index.js.map +1 -1
- package/build-module/components/welcome-guide/page.js +2 -1
- package/build-module/components/welcome-guide/page.js.map +1 -1
- package/build-module/components/welcome-guide/template.js +2 -1
- package/build-module/components/welcome-guide/template.js.map +1 -1
- package/build-module/deprecated.js +4 -3
- package/build-module/deprecated.js.map +1 -1
- package/build-module/hooks/commands/use-common-commands.js +6 -5
- package/build-module/hooks/commands/use-common-commands.js.map +1 -1
- package/build-module/hooks/commands/use-set-command-context.js +3 -2
- package/build-module/hooks/commands/use-set-command-context.js.map +1 -1
- package/build-module/index.js +7 -6
- package/build-module/index.js.map +1 -1
- package/build-module/lock-unlock.js +2 -1
- package/build-module/lock-unlock.js.map +1 -1
- package/build-module/posts.js +2 -1
- package/build-module/posts.js.map +1 -1
- package/build-module/store/actions.js +13 -12
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/constants.js +2 -1
- package/build-module/store/constants.js.map +1 -1
- package/build-module/store/index.js +3 -2
- package/build-module/store/index.js.map +1 -1
- package/build-module/store/private-actions.js +1 -0
- package/build-module/store/private-actions.js.map +1 -1
- package/build-module/store/private-selectors.js +1 -0
- package/build-module/store/private-selectors.js.map +1 -1
- package/build-module/store/reducer.js +1 -0
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +10 -9
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/constants.js +17 -16
- package/build-module/utils/constants.js.map +1 -1
- package/build-module/utils/get-filtered-template-parts.js +2 -1
- package/build-module/utils/get-filtered-template-parts.js.map +1 -1
- package/build-module/utils/is-previewing-theme.js +1 -0
- package/build-module/utils/is-previewing-theme.js.map +1 -1
- package/build-module/utils/is-template-removable.js +1 -0
- package/build-module/utils/is-template-removable.js.map +1 -1
- package/build-module/utils/is-template-revertable.js +1 -0
- package/build-module/utils/is-template-revertable.js.map +2 -2
- package/build-module/utils/use-activate-theme.js +2 -1
- package/build-module/utils/use-activate-theme.js.map +1 -1
- package/build-module/utils/use-actual-current-theme.js +2 -1
- package/build-module/utils/use-actual-current-theme.js.map +1 -1
- package/package.json +46 -46
- package/src/components/page-templates/fields.js +3 -3
- package/src/components/page-templates/index.js +11 -7
- package/src/components/page-templates/view-utils.js +7 -0
- package/src/utils/is-template-revertable.js +1 -2
|
@@ -16,12 +16,13 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
return to;
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// packages/edit-site/src/components/add-new-pattern/index.js
|
|
19
21
|
var add_new_pattern_exports = {};
|
|
20
22
|
__export(add_new_pattern_exports, {
|
|
21
23
|
default: () => AddNewPattern
|
|
22
24
|
});
|
|
23
25
|
module.exports = __toCommonJS(add_new_pattern_exports);
|
|
24
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
25
26
|
var import_components = require("@wordpress/components");
|
|
26
27
|
var import_element = require("@wordpress/element");
|
|
27
28
|
var import_i18n = require("@wordpress/i18n");
|
|
@@ -34,11 +35,12 @@ var import_core_data = require("@wordpress/core-data");
|
|
|
34
35
|
var import_editor = require("@wordpress/editor");
|
|
35
36
|
var import_lock_unlock = require("../../lock-unlock");
|
|
36
37
|
var import_constants = require("../../utils/constants");
|
|
37
|
-
|
|
38
|
-
|
|
38
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
39
|
+
var { useHistory, useLocation } = (0, import_lock_unlock.unlock)(import_router.privateApis);
|
|
40
|
+
var { CreatePatternModal, useAddPatternCategory } = (0, import_lock_unlock.unlock)(
|
|
39
41
|
import_patterns.privateApis
|
|
40
42
|
);
|
|
41
|
-
|
|
43
|
+
var { CreateTemplatePartModal } = (0, import_lock_unlock.unlock)(import_editor.privateApis);
|
|
42
44
|
function AddNewPattern() {
|
|
43
45
|
const history = useHistory();
|
|
44
46
|
const location = useLocation();
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/add-new-pattern/index.js"],
|
|
4
4
|
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { DropdownMenu } from '@wordpress/components';\nimport { useState, useRef } from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { symbol, symbolFilled, upload } from '@wordpress/icons';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\nimport {\n\tprivateApis as editPatternsPrivateApis,\n\tstore as patternsStore,\n} from '@wordpress/patterns';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { privateApis as editorPrivateApis } from '@wordpress/editor';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\nimport {\n\tPATTERN_TYPES,\n\tPATTERN_DEFAULT_CATEGORY,\n\tTEMPLATE_PART_POST_TYPE,\n} from '../../utils/constants';\n\nconst { useHistory, useLocation } = unlock( routerPrivateApis );\nconst { CreatePatternModal, useAddPatternCategory } = unlock(\n\teditPatternsPrivateApis\n);\nconst { CreateTemplatePartModal } = unlock( editorPrivateApis );\n\nexport default function AddNewPattern() {\n\tconst history = useHistory();\n\tconst location = useLocation();\n\tconst [ showPatternModal, setShowPatternModal ] = useState( false );\n\tconst [ showTemplatePartModal, setShowTemplatePartModal ] =\n\t\tuseState( false );\n\t// eslint-disable-next-line @wordpress/no-unused-vars-before-return\n\tconst { createPatternFromFile } = unlock( useDispatch( patternsStore ) );\n\tconst { createSuccessNotice, createErrorNotice } =\n\t\tuseDispatch( noticesStore );\n\tconst patternUploadInputRef = useRef();\n\tconst {\n\t\tisBlockBasedTheme,\n\t\taddNewPatternLabel,\n\t\taddNewTemplatePartLabel,\n\t\tcanCreatePattern,\n\t\tcanCreateTemplatePart,\n\t} = useSelect( ( select ) => {\n\t\tconst { getCurrentTheme, getPostType, canUser } = select( coreStore );\n\t\treturn {\n\t\t\tisBlockBasedTheme: getCurrentTheme()?.is_block_theme,\n\t\t\taddNewPatternLabel: getPostType( PATTERN_TYPES.user )?.labels\n\t\t\t\t?.add_new_item,\n\t\t\taddNewTemplatePartLabel: getPostType( TEMPLATE_PART_POST_TYPE )\n\t\t\t\t?.labels?.add_new_item,\n\t\t\t// Blocks refers to the wp_block post type, this checks the ability to create a post of that type.\n\t\t\tcanCreatePattern: canUser( 'create', {\n\t\t\t\tkind: 'postType',\n\t\t\t\tname: PATTERN_TYPES.user,\n\t\t\t} ),\n\t\t\tcanCreateTemplatePart: canUser( 'create', {\n\t\t\t\tkind: 'postType',\n\t\t\t\tname: TEMPLATE_PART_POST_TYPE,\n\t\t\t} ),\n\t\t};\n\t}, [] );\n\n\tfunction handleCreatePattern( { pattern } ) {\n\t\tsetShowPatternModal( false );\n\t\thistory.navigate(\n\t\t\t`/${ PATTERN_TYPES.user }/${ pattern.id }?canvas=edit`\n\t\t);\n\t}\n\n\tfunction handleCreateTemplatePart( templatePart ) {\n\t\tsetShowTemplatePartModal( false );\n\t\thistory.navigate(\n\t\t\t`/${ TEMPLATE_PART_POST_TYPE }/${ templatePart.id }?canvas=edit`\n\t\t);\n\t}\n\n\tfunction handleError() {\n\t\tsetShowPatternModal( false );\n\t\tsetShowTemplatePartModal( false );\n\t}\n\n\tconst controls = [];\n\tif ( canCreatePattern ) {\n\t\tcontrols.push( {\n\t\t\ticon: symbol,\n\t\t\tonClick: () => setShowPatternModal( true ),\n\t\t\ttitle: addNewPatternLabel,\n\t\t} );\n\t}\n\n\tif ( isBlockBasedTheme && canCreateTemplatePart ) {\n\t\tcontrols.push( {\n\t\t\ticon: symbolFilled,\n\t\t\tonClick: () => setShowTemplatePartModal( true ),\n\t\t\ttitle: addNewTemplatePartLabel,\n\t\t} );\n\t}\n\n\tif ( canCreatePattern ) {\n\t\tcontrols.push( {\n\t\t\ticon: upload,\n\t\t\tonClick: () => {\n\t\t\t\tpatternUploadInputRef.current.click();\n\t\t\t},\n\t\t\ttitle: __( 'Import pattern from JSON' ),\n\t\t} );\n\t}\n\n\tconst { categoryMap, findOrCreateTerm } = useAddPatternCategory();\n\tif ( controls.length === 0 ) {\n\t\treturn null;\n\t}\n\treturn (\n\t\t<>\n\t\t\t{ addNewPatternLabel && (\n\t\t\t\t<DropdownMenu\n\t\t\t\t\tcontrols={ controls }\n\t\t\t\t\ticon={ null }\n\t\t\t\t\ttoggleProps={ {\n\t\t\t\t\t\tvariant: 'primary',\n\t\t\t\t\t\tshowTooltip: false,\n\t\t\t\t\t\t__next40pxDefaultSize: true,\n\t\t\t\t\t} }\n\t\t\t\t\ttext={ addNewPatternLabel }\n\t\t\t\t\tlabel={ addNewPatternLabel }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ showPatternModal && (\n\t\t\t\t<CreatePatternModal\n\t\t\t\t\tonClose={ () => setShowPatternModal( false ) }\n\t\t\t\t\tonSuccess={ handleCreatePattern }\n\t\t\t\t\tonError={ handleError }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ showTemplatePartModal && (\n\t\t\t\t<CreateTemplatePartModal\n\t\t\t\t\tcloseModal={ () => setShowTemplatePartModal( false ) }\n\t\t\t\t\tblocks={ [] }\n\t\t\t\t\tonCreate={ handleCreateTemplatePart }\n\t\t\t\t\tonError={ handleError }\n\t\t\t\t/>\n\t\t\t) }\n\n\t\t\t<input\n\t\t\t\ttype=\"file\"\n\t\t\t\taccept=\".json\"\n\t\t\t\thidden\n\t\t\t\tref={ patternUploadInputRef }\n\t\t\t\tonChange={ async ( event ) => {\n\t\t\t\t\tconst file = event.target.files?.[ 0 ];\n\t\t\t\t\tif ( ! file ) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\ttry {\n\t\t\t\t\t\tlet currentCategoryId;\n\t\t\t\t\t\t// When we're not handling template parts, we should\n\t\t\t\t\t\t// add or create the proper pattern category.\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tlocation.query.postType !== TEMPLATE_PART_POST_TYPE\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t/*\n\t\t\t\t\t\t\t * categoryMap.values() returns an iterator.\n\t\t\t\t\t\t\t * Iterator.prototype.find() is not yet widely supported.\n\t\t\t\t\t\t\t * Convert to array to use the Array.prototype.find method.\n\t\t\t\t\t\t\t */\n\t\t\t\t\t\t\tconst currentCategory = Array.from(\n\t\t\t\t\t\t\t\tcategoryMap.values()\n\t\t\t\t\t\t\t).find(\n\t\t\t\t\t\t\t\t( term ) =>\n\t\t\t\t\t\t\t\t\tterm.name === location.query.categoryId\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tif ( currentCategory ) {\n\t\t\t\t\t\t\t\tcurrentCategoryId =\n\t\t\t\t\t\t\t\t\tcurrentCategory.id ||\n\t\t\t\t\t\t\t\t\t( await findOrCreateTerm(\n\t\t\t\t\t\t\t\t\t\tcurrentCategory.label\n\t\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\tconst pattern = await createPatternFromFile(\n\t\t\t\t\t\t\tfile,\n\t\t\t\t\t\t\tcurrentCategoryId\n\t\t\t\t\t\t\t\t? [ currentCategoryId ]\n\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\t// Navigate to the All patterns category for the newly created pattern\n\t\t\t\t\t\t// if we're not on that page already and if we're not in the `my-patterns`\n\t\t\t\t\t\t// category.\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t! currentCategoryId &&\n\t\t\t\t\t\t\tlocation.query.categoryId !== 'my-patterns'\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\thistory.navigate(\n\t\t\t\t\t\t\t\t`/pattern?categoryId=${ PATTERN_DEFAULT_CATEGORY }`\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tcreateSuccessNotice(\n\t\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t\t// translators: %s: The imported pattern's title.\n\t\t\t\t\t\t\t\t__( 'Imported \"%s\" from JSON.' ),\n\t\t\t\t\t\t\t\tpattern.title.raw\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\t\t\tid: 'import-pattern-success',\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t);\n\t\t\t\t\t} catch ( err ) {\n\t\t\t\t\t\tcreateErrorNotice( err.message, {\n\t\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\t\tid: 'import-pattern-error',\n\t\t\t\t\t\t} );\n\t\t\t\t\t} finally {\n\t\t\t\t\t\tevent.target.value = '';\n\t\t\t\t\t}\n\t\t\t\t} }\n\t\t\t/>\n\t\t</>\n\t);\n}\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,wBAA6B;AAC7B,qBAAiC;AACjC,kBAA4B;AAC5B,mBAA6C;AAC7C,kBAAuC;AACvC,oBAAiD;AACjD,sBAGO;AACP,qBAAsC;AACtC,uBAAmC;AACnC,oBAAiD;AAKjD,yBAAuB;AACvB,uBAIO;AAgGL;AA9FF,IAAM,EAAE,YAAY,YAAY,QAAI,2BAAQ,cAAAA,WAAkB;AAC9D,IAAM,EAAE,oBAAoB,sBAAsB,QAAI;AAAA,EACrD,gBAAAC;AACD;AACA,IAAM,EAAE,wBAAwB,QAAI,2BAAQ,cAAAC,WAAkB;AAE/C,SAAR,gBAAiC;AACvC,QAAM,UAAU,WAAW;AAC3B,QAAM,WAAW,YAAY;AAC7B,QAAM,CAAE,kBAAkB,mBAAoB,QAAI,yBAAU,KAAM;AAClE,QAAM,CAAE,uBAAuB,wBAAyB,QACvD,yBAAU,KAAM;AAEjB,QAAM,EAAE,sBAAsB,QAAI,+BAAQ,yBAAa,gBAAAC,KAAc,CAAE;AACvE,QAAM,EAAE,qBAAqB,kB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B,MACd,MAAM;AAAA,kBACP,gBAAgB;AAAA,gBACjB;AAAA,cACF;AAAA,YACD;AACA,kBAAM,UAAU,MAAM;AAAA,cACrB;AAAA,cACA,oBACG,CAAE,iBAAkB,IACpB;AAAA,YACJ;AAKA,gBACC,CAAE,qBACF,SAAS,MAAM,eAAe,eAC7B;AACD,sBAAQ;AAAA,gBACP,uBAAwB,yCAAyB;AAAA,cAClD;AAAA,YACD;AAEA;AAAA,kBACC;AAAA;AAAA,oBAEC,gBAAI,0BAA2B;AAAA,gBAC/B,QAAQ,MAAM;AAAA,cACf;AAAA,cACA;AAAA,gBACC,MAAM;AAAA,gBACN,IAAI;AAAA,cACL;AAAA,YACD;AAAA,UACD,SAAU,KAAM;AACf,8BAAmB,IAAI,SAAS;AAAA,cAC/B,MAAM;AAAA,cACN,IAAI;AAAA,YACL,CAAE;AAAA,UACH,UAAE;AACD,kBAAM,OAAO,QAAQ;AAAA,UACtB;AAAA,QACD;AAAA;AAAA,IACD;AAAA,KACD;AAEF;",
|
|
6
6
|
"names": ["routerPrivateApis", "editPatternsPrivateApis", "editorPrivateApis", "patternsStore", "noticesStore", "coreStore"]
|
|
7
7
|
}
|
|
@@ -16,12 +16,13 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
return to;
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// packages/edit-site/src/components/add-new-post/index.js
|
|
19
21
|
var add_new_post_exports = {};
|
|
20
22
|
__export(add_new_post_exports, {
|
|
21
23
|
default: () => AddNewPostModal
|
|
22
24
|
});
|
|
23
25
|
module.exports = __toCommonJS(add_new_post_exports);
|
|
24
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
25
26
|
var import_components = require("@wordpress/components");
|
|
26
27
|
var import_i18n = require("@wordpress/i18n");
|
|
27
28
|
var import_data = require("@wordpress/data");
|
|
@@ -30,6 +31,7 @@ var import_core_data = require("@wordpress/core-data");
|
|
|
30
31
|
var import_notices = require("@wordpress/notices");
|
|
31
32
|
var import_html_entities = require("@wordpress/html-entities");
|
|
32
33
|
var import_blocks = require("@wordpress/blocks");
|
|
34
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
33
35
|
function AddNewPostModal({ postType, onSave, onClose }) {
|
|
34
36
|
const labels = (0, import_data.useSelect)(
|
|
35
37
|
(select) => select(import_core_data.store).getPostType(postType)?.labels,
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/add-new-post/index.js"],
|
|
4
4
|
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tButton,\n\tModal,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n\tTextControl,\n} from '@wordpress/components';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useDispatch, useRegistry, useSelect } from '@wordpress/data';\nimport { useState } from '@wordpress/element';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { serialize, synchronizeBlocksWithTemplate } from '@wordpress/blocks';\n\nexport default function AddNewPostModal( { postType, onSave, onClose } ) {\n\tconst labels = useSelect(\n\t\t( select ) => select( coreStore ).getPostType( postType )?.labels,\n\t\t[ postType ]\n\t);\n\tconst [ isCreatingPost, setIsCreatingPost ] = useState( false );\n\tconst [ title, setTitle ] = useState( '' );\n\n\tconst { saveEntityRecord } = useDispatch( coreStore );\n\tconst { createErrorNotice, createSuccessNotice } =\n\t\tuseDispatch( noticesStore );\n\tconst { resolveSelect } = useRegistry();\n\n\tasync function createPost( event ) {\n\t\tevent.preventDefault();\n\n\t\tif ( isCreatingPost ) {\n\t\t\treturn;\n\t\t}\n\t\tsetIsCreatingPost( true );\n\t\ttry {\n\t\t\tconst postTypeObject =\n\t\t\t\tawait resolveSelect( coreStore ).getPostType( postType );\n\t\t\tconst newPage = await saveEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\tpostType,\n\t\t\t\t{\n\t\t\t\t\tstatus: 'draft',\n\t\t\t\t\ttitle,\n\t\t\t\t\tslug: title ?? undefined,\n\t\t\t\t\tcontent:\n\t\t\t\t\t\t!! postTypeObject.template &&\n\t\t\t\t\t\tpostTypeObject.template.length\n\t\t\t\t\t\t\t? serialize(\n\t\t\t\t\t\t\t\t\tsynchronizeBlocksWithTemplate(\n\t\t\t\t\t\t\t\t\t\t[],\n\t\t\t\t\t\t\t\t\t\tpostTypeObject.template\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t: undefined,\n\t\t\t\t},\n\t\t\t\t{ throwOnError: true }\n\t\t\t);\n\n\t\t\tonSave( newPage );\n\n\t\t\tcreateSuccessNotice(\n\t\t\t\tsprintf(\n\t\t\t\t\t// translators: %s: Title of the created post or template, e.g: \"Hello world\".\n\t\t\t\t\t__( '\"%s\" successfully created.' ),\n\t\t\t\t\tdecodeEntities( newPage.title?.rendered || title ) ||\n\t\t\t\t\t\t__( '(no title)' )\n\t\t\t\t),\n\t\t\t\t{ type: '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 creating the item.' );\n\n\t\t\tcreateErrorNotice( errorMessage, {\n\t\t\t\ttype: 'snackbar',\n\t\t\t} );\n\t\t} finally {\n\t\t\tsetIsCreatingPost( false );\n\t\t}\n\t}\n\n\treturn (\n\t\t<Modal\n\t\t\ttitle={\n\t\t\t\t// translators: %s: post type singular_name label e.g: \"Page\".\n\t\t\t\tsprintf( __( 'Draft new: %s' ), labels?.singular_name )\n\t\t\t}\n\t\t\tonRequestClose={ onClose }\n\t\t\tfocusOnMount=\"firstContentElement\"\n\t\t\tsize=\"small\"\n\t\t>\n\t\t\t<form onSubmit={ createPost }>\n\t\t\t\t<VStack spacing={ 4 }>\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\tlabel={ __( 'Title' ) }\n\t\t\t\t\t\tonChange={ setTitle }\n\t\t\t\t\t\tplaceholder={ __( 'No title' ) }\n\t\t\t\t\t\tvalue={ title }\n\t\t\t\t\t/>\n\t\t\t\t\t<HStack spacing={ 2 } justify=\"end\">\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\tonClick={ onClose }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\ttype=\"submit\"\n\t\t\t\t\t\t\tisBusy={ isCreatingPost }\n\t\t\t\t\t\t\taria-disabled={ isCreatingPost }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Create draft' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</HStack>\n\t\t\t\t</VStack>\n\t\t\t</form>\n\t\t</Modal>\n\t);\n}\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,wBAMO;AACP,kBAA4B;AAC5B,kBAAoD;AACpD,qBAAyB;AACzB,uBAAmC;AACnC,qBAAsC;AACtC,2BAA+B;AAC/B,oBAAyD;AAmFpD;AAjFU,SAAR,gBAAkC,EAAE,UAAU,QAAQ,QAAQ,GAAI;AACxE,QAAM,aAAS;AAAA,IACd,CAAE,WAAY,OAAQ,iBAAAA,KAAU,EAAE,YAAa,QAAS,GAAG;AAAA,IAC3D,CAAE,QAAS;AAAA,EACZ;AACA,QAAM,CAA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EvD,gBAAiB;AAAA,MACjB,cAAa;AAAA,MACb,MAAK;AAAA,MAEL,sDAAC,UAAK,UAAW,YAChB,uDAAC,kBAAAE,sBAAA,EAAO,SAAU,GACjB;AAAA;AAAA,UAAC;AAAA;AAAA,YACA,uBAAqB;AAAA,YACrB,yBAAuB;AAAA,YACvB,WAAQ,gBAAI,OAAQ;AAAA,YACpB,UAAW;AAAA,YACX,iBAAc,gBAAI,UAAW;AAAA,YAC7B,OAAQ;AAAA;AAAA,QACT;AAAA,QACA,6CAAC,kBAAAC,sBAAA,EAAO,SAAU,GAAI,SAAQ,OAC7B;AAAA;AAAA,YAAC;AAAA;AAAA,cACA,uBAAqB;AAAA,cACrB,SAAQ;AAAA,cACR,SAAU;AAAA,cAER,8BAAI,QAAS;AAAA;AAAA,UAChB;AAAA,UACA;AAAA,YAAC;AAAA;AAAA,cACA,uBAAqB;AAAA,cACrB,SAAQ;AAAA,cACR,MAAK;AAAA,cACL,QAAS;AAAA,cACT,iBAAgB;AAAA,cAEd,8BAAI,cAAe;AAAA;AAAA,UACtB;AAAA,WACD;AAAA,SACD,GACD;AAAA;AAAA,EACD;AAEF;",
|
|
6
6
|
"names": ["coreStore", "noticesStore", "VStack", "HStack"]
|
|
7
7
|
}
|
|
@@ -16,16 +16,18 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
return to;
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// packages/edit-site/src/components/add-new-template/add-custom-generic-template-modal-content.js
|
|
19
21
|
var add_custom_generic_template_modal_content_exports = {};
|
|
20
22
|
__export(add_custom_generic_template_modal_content_exports, {
|
|
21
23
|
default: () => add_custom_generic_template_modal_content_default
|
|
22
24
|
});
|
|
23
25
|
module.exports = __toCommonJS(add_custom_generic_template_modal_content_exports);
|
|
24
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
25
26
|
var import_change_case = require("change-case");
|
|
26
27
|
var import_element = require("@wordpress/element");
|
|
27
28
|
var import_i18n = require("@wordpress/i18n");
|
|
28
29
|
var import_components = require("@wordpress/components");
|
|
30
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
29
31
|
function AddCustomGenericTemplateModalContent({ createTemplate, onBack }) {
|
|
30
32
|
const [title, setTitle] = (0, import_element.useState)("");
|
|
31
33
|
const defaultTitle = (0, import_i18n.__)("Custom Template");
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/add-new-template/add-custom-generic-template-modal-content.js"],
|
|
4
4
|
"sourcesContent": ["/**\n * External dependencies\n */\nimport { paramCase as kebabCase } from 'change-case';\n\n/**\n * WordPress dependencies\n */\nimport { useState, useEffect, useRef } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tButton,\n\tTextControl,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\n\nfunction AddCustomGenericTemplateModalContent( { createTemplate, onBack } ) {\n\tconst [ title, setTitle ] = useState( '' );\n\tconst defaultTitle = __( 'Custom Template' );\n\tconst [ isBusy, setIsBusy ] = useState( false );\n\tconst inputRef = useRef();\n\n\t// Set focus to the name input when the component mounts\n\tuseEffect( () => {\n\t\tif ( inputRef.current ) {\n\t\t\tinputRef.current.focus();\n\t\t}\n\t}, [] );\n\n\tasync function onCreateTemplate( event ) {\n\t\tevent.preventDefault();\n\t\tif ( isBusy ) {\n\t\t\treturn;\n\t\t}\n\t\tsetIsBusy( true );\n\t\ttry {\n\t\t\tawait createTemplate(\n\t\t\t\t{\n\t\t\t\t\tslug:\n\t\t\t\t\t\tkebabCase( title || defaultTitle ) ||\n\t\t\t\t\t\t'wp-custom-template',\n\t\t\t\t\ttitle: title || defaultTitle,\n\t\t\t\t},\n\t\t\t\tfalse\n\t\t\t);\n\t\t} finally {\n\t\t\tsetIsBusy( false );\n\t\t}\n\t}\n\treturn (\n\t\t<form onSubmit={ onCreateTemplate }>\n\t\t\t<VStack spacing={ 6 }>\n\t\t\t\t<TextControl\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\tlabel={ __( 'Name' ) }\n\t\t\t\t\tvalue={ title }\n\t\t\t\t\tonChange={ setTitle }\n\t\t\t\t\tplaceholder={ defaultTitle }\n\t\t\t\t\tdisabled={ isBusy }\n\t\t\t\t\tref={ inputRef }\n\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t// eslint-disable-next-line no-restricted-syntax -- 'sidebar' is a common web design term for layouts\n\t\t\t\t\t\t'Describe the template, e.g. \"Post with sidebar\". A custom template can be manually applied to any post or page.'\n\t\t\t\t\t) }\n\t\t\t\t/>\n\t\t\t\t<HStack\n\t\t\t\t\tclassName=\"edit-site-custom-generic-template__modal-actions\"\n\t\t\t\t\tjustify=\"right\"\n\t\t\t\t>\n\t\t\t\t\t<Button\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\tonClick={ onBack }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Back' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t\t<Button\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\ttype=\"submit\"\n\t\t\t\t\t\tisBusy={ isBusy }\n\t\t\t\t\t\taria-disabled={ isBusy }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Create' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t</HStack>\n\t\t\t</VStack>\n\t\t</form>\n\t);\n}\n\nexport default AddCustomGenericTemplateModalContent;\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,yBAAuC;AAKvC,qBAA4C;AAC5C,kBAAmB;AACnB,wBAKO;AAsCH;A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AAA,cACL;AAAA,cACA,iBAAgB;AAAA,cAEd,8BAAI,QAAS;AAAA;AAAA,UAChB;AAAA;AAAA;AAAA,IACD;AAAA,KACD,GACD;AAEF;AAEA,IAAO,oDAAQ;",
|
|
6
6
|
"names": ["kebabCase", "VStack", "HStack"]
|
|
7
7
|
}
|
|
@@ -16,12 +16,13 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
return to;
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// packages/edit-site/src/components/add-new-template/add-custom-template-modal-content.js
|
|
19
21
|
var add_custom_template_modal_content_exports = {};
|
|
20
22
|
__export(add_custom_template_modal_content_exports, {
|
|
21
23
|
default: () => add_custom_template_modal_content_default
|
|
22
24
|
});
|
|
23
25
|
module.exports = __toCommonJS(add_custom_template_modal_content_exports);
|
|
24
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
25
26
|
var import_element = require("@wordpress/element");
|
|
26
27
|
var import_i18n = require("@wordpress/i18n");
|
|
27
28
|
var import_components = require("@wordpress/components");
|
|
@@ -31,7 +32,8 @@ var import_compose = require("@wordpress/compose");
|
|
|
31
32
|
var import_dom = require("@wordpress/dom");
|
|
32
33
|
var import_url = require("@wordpress/url");
|
|
33
34
|
var import_utils = require("./utils");
|
|
34
|
-
|
|
35
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
36
|
+
var EMPTY_ARRAY = [];
|
|
35
37
|
function SuggestionListItem({
|
|
36
38
|
suggestion,
|
|
37
39
|
search,
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/add-new-template/add-custom-template-modal-content.js"],
|
|
4
4
|
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useState, useMemo, useEffect } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tButton,\n\tFlex,\n\tFlexItem,\n\tSearchControl,\n\tTextHighlight,\n\tComposite,\n\t__experimentalText as Text,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { useEntityRecords } from '@wordpress/core-data';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { useDebouncedInput } from '@wordpress/compose';\nimport { focus } from '@wordpress/dom';\nimport { safeDecodeURI } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport { mapToIHasNameAndId } from './utils';\n\nconst EMPTY_ARRAY = [];\n\nfunction SuggestionListItem( {\n\tsuggestion,\n\tsearch,\n\tonSelect,\n\tentityForSuggestions,\n} ) {\n\tconst baseCssClass =\n\t\t'edit-site-custom-template-modal__suggestions_list__list-item';\n\treturn (\n\t\t<Composite.Item\n\t\t\trender={\n\t\t\t\t<Button\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\trole=\"option\"\n\t\t\t\t\tclassName={ baseCssClass }\n\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\tonSelect(\n\t\t\t\t\t\t\tentityForSuggestions.config.getSpecificTemplate(\n\t\t\t\t\t\t\t\tsuggestion\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/>\n\t\t\t}\n\t\t>\n\t\t\t<Text\n\t\t\t\tsize=\"body\"\n\t\t\t\tlineHeight={ 1.53846153846 } // 20px\n\t\t\t\tweight={ 500 }\n\t\t\t\tclassName={ `${ baseCssClass }__title` }\n\t\t\t>\n\t\t\t\t<TextHighlight\n\t\t\t\t\ttext={ decodeEntities( suggestion.name ) }\n\t\t\t\t\thighlight={ search }\n\t\t\t\t/>\n\t\t\t</Text>\n\t\t\t{ suggestion.link && (\n\t\t\t\t<Text\n\t\t\t\t\tsize=\"body\"\n\t\t\t\t\tlineHeight={ 1.53846153846 } // 20px\n\t\t\t\t\tclassName={ `${ baseCssClass }__info` }\n\t\t\t\t>\n\t\t\t\t\t{ safeDecodeURI( suggestion.link ) }\n\t\t\t\t</Text>\n\t\t\t) }\n\t\t</Composite.Item>\n\t);\n}\n\nfunction useSearchSuggestions( entityForSuggestions, search ) {\n\tconst { config } = entityForSuggestions;\n\tconst query = useMemo(\n\t\t() => ( {\n\t\t\torder: 'asc',\n\t\t\tcontext: 'view',\n\t\t\tsearch,\n\t\t\tper_page: search ? 20 : 10,\n\t\t\t...config.queryArgs( search ),\n\t\t} ),\n\t\t[ search, config ]\n\t);\n\tconst { records: searchResults, hasResolved: searchHasResolved } =\n\t\tuseEntityRecords(\n\t\t\tentityForSuggestions.type,\n\t\t\tentityForSuggestions.slug,\n\t\t\tquery\n\t\t);\n\tconst [ suggestions, setSuggestions ] = useState( EMPTY_ARRAY );\n\tuseEffect( () => {\n\t\tif ( ! searchHasResolved ) {\n\t\t\treturn;\n\t\t}\n\t\tlet newSuggestions = EMPTY_ARRAY;\n\t\tif ( searchResults?.length ) {\n\t\t\tnewSuggestions = searchResults;\n\t\t\tif ( config.recordNamePath ) {\n\t\t\t\tnewSuggestions = mapToIHasNameAndId(\n\t\t\t\t\tnewSuggestions,\n\t\t\t\t\tconfig.recordNamePath\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\t// Update suggestions only when the query has resolved, so as to keep\n\t\t// the previous results in the UI.\n\t\tsetSuggestions( newSuggestions );\n\t}, [ searchResults, searchHasResolved ] );\n\treturn suggestions;\n}\n\nfunction SuggestionList( { entityForSuggestions, onSelect } ) {\n\tconst [ search, setSearch, debouncedSearch ] = useDebouncedInput();\n\tconst suggestions = useSearchSuggestions(\n\t\tentityForSuggestions,\n\t\tdebouncedSearch\n\t);\n\tconst { labels } = entityForSuggestions;\n\tconst [ showSearchControl, setShowSearchControl ] = useState( false );\n\tif ( ! showSearchControl && suggestions?.length > 9 ) {\n\t\tsetShowSearchControl( true );\n\t}\n\treturn (\n\t\t<>\n\t\t\t{ showSearchControl && (\n\t\t\t\t<SearchControl\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\tonChange={ setSearch }\n\t\t\t\t\tvalue={ search }\n\t\t\t\t\tlabel={ labels.search_items }\n\t\t\t\t\tplaceholder={ labels.search_items }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ !! suggestions?.length && (\n\t\t\t\t<Composite\n\t\t\t\t\torientation=\"vertical\"\n\t\t\t\t\trole=\"listbox\"\n\t\t\t\t\tclassName=\"edit-site-custom-template-modal__suggestions_list\"\n\t\t\t\t\taria-label={ __( 'Suggestions list' ) }\n\t\t\t\t>\n\t\t\t\t\t{ suggestions.map( ( suggestion ) => (\n\t\t\t\t\t\t<SuggestionListItem\n\t\t\t\t\t\t\tkey={ suggestion.slug }\n\t\t\t\t\t\t\tsuggestion={ suggestion }\n\t\t\t\t\t\t\tsearch={ debouncedSearch }\n\t\t\t\t\t\t\tonSelect={ onSelect }\n\t\t\t\t\t\t\tentityForSuggestions={ entityForSuggestions }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) ) }\n\t\t\t\t</Composite>\n\t\t\t) }\n\t\t\t{ debouncedSearch && ! suggestions?.length && (\n\t\t\t\t<Text\n\t\t\t\t\tas=\"p\"\n\t\t\t\t\tclassName=\"edit-site-custom-template-modal__no-results\"\n\t\t\t\t>\n\t\t\t\t\t{ labels.not_found }\n\t\t\t\t</Text>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nfunction AddCustomTemplateModalContent( {\n\tonSelect,\n\tentityForSuggestions,\n\tonBack,\n\tcontainerRef,\n} ) {\n\tconst [ showSearchEntities, setShowSearchEntities ] = useState();\n\n\t// Focus on the first focusable element when the modal opens.\n\t// We handle focus management in the parent modal, just need to focus on the first focusable element.\n\tuseEffect( () => {\n\t\tif ( containerRef.current ) {\n\t\t\tconst [ firstFocusable ] = focus.focusable.find(\n\t\t\t\tcontainerRef.current\n\t\t\t);\n\t\t\tfirstFocusable?.focus();\n\t\t}\n\t}, [ showSearchEntities ] );\n\n\treturn (\n\t\t<VStack\n\t\t\tspacing={ 4 }\n\t\t\tclassName=\"edit-site-custom-template-modal__contents-wrapper\"\n\t\t\talignment=\"left\"\n\t\t>\n\t\t\t{ ! showSearchEntities && (\n\t\t\t\t<>\n\t\t\t\t\t<Text as=\"p\">\n\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t'Select whether to create a single template for all items or a specific one.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t</Text>\n\t\t\t\t\t<Flex\n\t\t\t\t\t\tclassName=\"edit-site-custom-template-modal__contents\"\n\t\t\t\t\t\tgap=\"4\"\n\t\t\t\t\t\talign=\"initial\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<FlexItem\n\t\t\t\t\t\t\tisBlock\n\t\t\t\t\t\t\tas={ Button }\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\tconst {\n\t\t\t\t\t\t\t\t\tslug,\n\t\t\t\t\t\t\t\t\ttitle,\n\t\t\t\t\t\t\t\t\tdescription,\n\t\t\t\t\t\t\t\t\ttemplatePrefix,\n\t\t\t\t\t\t\t\t} = entityForSuggestions.template;\n\t\t\t\t\t\t\t\tonSelect( {\n\t\t\t\t\t\t\t\t\tslug,\n\t\t\t\t\t\t\t\t\ttitle,\n\t\t\t\t\t\t\t\t\tdescription,\n\t\t\t\t\t\t\t\t\ttemplatePrefix,\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<Text\n\t\t\t\t\t\t\t\tas=\"span\"\n\t\t\t\t\t\t\t\tweight={ 500 }\n\t\t\t\t\t\t\t\tlineHeight={ 1.53846153846 } // 20px\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ entityForSuggestions.labels.all_items }\n\t\t\t\t\t\t\t</Text>\n\t\t\t\t\t\t\t<Text\n\t\t\t\t\t\t\t\tas=\"span\"\n\t\t\t\t\t\t\t\tlineHeight={ 1.53846153846 } // 20px\n\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// translators: The user is given the choice to set up a template for all items of a post type or taxonomy, or just a specific one.\n\t\t\t\t\t\t\t\t\t__( 'For all items' )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t</Text>\n\t\t\t\t\t\t</FlexItem>\n\t\t\t\t\t\t<FlexItem\n\t\t\t\t\t\t\tisBlock\n\t\t\t\t\t\t\tas={ Button }\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\tsetShowSearchEntities( true );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<Text\n\t\t\t\t\t\t\t\tas=\"span\"\n\t\t\t\t\t\t\t\tweight={ 500 }\n\t\t\t\t\t\t\t\tlineHeight={ 1.53846153846 } // 20px\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ entityForSuggestions.labels.singular_name }\n\t\t\t\t\t\t\t</Text>\n\t\t\t\t\t\t\t<Text\n\t\t\t\t\t\t\t\tas=\"span\"\n\t\t\t\t\t\t\t\tlineHeight={ 1.53846153846 } // 20px\n\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// translators: The user is given the choice to set up a template for all items of a post type or taxonomy, or just a specific one.\n\t\t\t\t\t\t\t\t\t__( 'For a specific item' )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t</Text>\n\t\t\t\t\t\t</FlexItem>\n\t\t\t\t\t</Flex>\n\t\t\t\t\t<Flex justify=\"right\">\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\tonClick={ onBack }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Back' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</Flex>\n\t\t\t\t</>\n\t\t\t) }\n\t\t\t{ showSearchEntities && (\n\t\t\t\t<>\n\t\t\t\t\t<Text as=\"p\">\n\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t'This template will be used only for the specific item chosen.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t</Text>\n\t\t\t\t\t<SuggestionList\n\t\t\t\t\t\tentityForSuggestions={ entityForSuggestions }\n\t\t\t\t\t\tonSelect={ onSelect }\n\t\t\t\t\t/>\n\t\t\t\t\t<Flex justify=\"right\">\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t// If general template exists, go directly back to main screen\n\t\t\t\t\t\t\t\t// instead of showing the choice screen\n\t\t\t\t\t\t\t\tif ( entityForSuggestions.hasGeneralTemplate ) {\n\t\t\t\t\t\t\t\t\tonBack();\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tsetShowSearchEntities( false );\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Back' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</Flex>\n\t\t\t\t</>\n\t\t\t) }\n\t\t</VStack>\n\t);\n}\n\nexport default AddCustomTemplateModalContent;\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAA6C;AAC7C,kBAAmB;AACnB,wBASO;AACP,uBAAiC;AACjC,2BAA+B;AAC/B,qBAAkC;AAClC,iBAAsB;AACtB,iBAA8B;AAK9B,mBAAmC;AAajC;AAXF,IAAM,cAAc,CAAC;AAErB,SAAS,mBAAoB;AAAA,EAC5B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAAI;AACH,QAAM,eACL;AACD,SACC;AAAA,IAAC,4BAAU;AAAA,IAAV;AAAA,MACA,QACC;AAAA,QAAC;AAAA;AAAA,UACA,uBAAqB;AAAA,UACrB,MAAK;AAAA,UACL,W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,sBAC/B;AAAA,sBACA;AAAA,wBAAC,kBAAAA;AAAA,wBAAA;AAAA,0BACA,IAAG;AAAA,0BACH,YAAa;AAAA;AAAA,0BAIZ,8BAAI,qBAAsB;AAAA;AAAA,sBAE5B;AAAA;AAAA;AAAA,gBACD;AAAA;AAAA;AAAA,UACD;AAAA,UACA,4CAAC,0BAAK,SAAQ,SACb;AAAA,YAAC;AAAA;AAAA,cACA,uBAAqB;AAAA,cACrB,SAAQ;AAAA,cACR,SAAU;AAAA,cAER,8BAAI,MAAO;AAAA;AAAA,UACd,GACD;AAAA,WACD;AAAA,QAEC,sBACD,4EACC;AAAA,sDAAC,kBAAAA,oBAAA,EAAK,IAAG,KACN;AAAA,YACD;AAAA,UACD,GACD;AAAA,UACA;AAAA,YAAC;AAAA;AAAA,cACA;AAAA,cACA;AAAA;AAAA,UACD;AAAA,UACA,4CAAC,0BAAK,SAAQ,SACb;AAAA,YAAC;AAAA;AAAA,cACA,uBAAqB;AAAA,cACrB,SAAQ;AAAA,cACR,SAAU,MAAM;AAGf,oBAAK,qBAAqB,oBAAqB;AAC9C,yBAAO;AAAA,gBACR,OAAO;AACN,wCAAuB,KAAM;AAAA,gBAC9B;AAAA,cACD;AAAA,cAEE,8BAAI,MAAO;AAAA;AAAA,UACd,GACD;AAAA,WACD;AAAA;AAAA;AAAA,EAEF;AAEF;AAEA,IAAO,4CAAQ;",
|
|
6
6
|
"names": ["Text", "VStack"]
|
|
7
7
|
}
|
|
@@ -26,12 +26,13 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
26
26
|
mod
|
|
27
27
|
));
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// packages/edit-site/src/components/add-new-template/index.js
|
|
29
31
|
var add_new_template_exports = {};
|
|
30
32
|
__export(add_new_template_exports, {
|
|
31
33
|
default: () => add_new_template_default
|
|
32
34
|
});
|
|
33
35
|
module.exports = __toCommonJS(add_new_template_exports);
|
|
34
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
35
36
|
var import_clsx = __toESM(require("clsx"));
|
|
36
37
|
var import_components = require("@wordpress/components");
|
|
37
38
|
var import_html_entities = require("@wordpress/html-entities");
|
|
@@ -49,8 +50,9 @@ var import_add_custom_template_modal_content = __toESM(require("./add-custom-tem
|
|
|
49
50
|
var import_utils = require("./utils");
|
|
50
51
|
var import_add_custom_generic_template_modal_content = __toESM(require("./add-custom-generic-template-modal-content"));
|
|
51
52
|
var import_lock_unlock = require("../../lock-unlock");
|
|
52
|
-
|
|
53
|
-
|
|
53
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
54
|
+
var { useHistory } = (0, import_lock_unlock.unlock)(import_router.privateApis);
|
|
55
|
+
var DEFAULT_TEMPLATE_SLUGS = [
|
|
54
56
|
"front-page",
|
|
55
57
|
"home",
|
|
56
58
|
"single",
|
|
@@ -64,7 +66,7 @@ const DEFAULT_TEMPLATE_SLUGS = [
|
|
|
64
66
|
"search",
|
|
65
67
|
"404"
|
|
66
68
|
];
|
|
67
|
-
|
|
69
|
+
var TEMPLATE_ICONS = {
|
|
68
70
|
"front-page": import_icons.home,
|
|
69
71
|
home: import_icons.verse,
|
|
70
72
|
single: import_icons.pin,
|
|
@@ -134,7 +136,7 @@ function TemplateListItem({
|
|
|
134
136
|
}
|
|
135
137
|
);
|
|
136
138
|
}
|
|
137
|
-
|
|
139
|
+
var modalContentMap = {
|
|
138
140
|
templatesList: 1,
|
|
139
141
|
customTemplate: 2,
|
|
140
142
|
customGenericTemplate: 3
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/add-new-template/index.js"],
|
|
4
4
|
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tButton,\n\tModal,\n\t__experimentalGrid as Grid,\n\t__experimentalText as Text,\n\t__experimentalVStack as VStack,\n\tFlex,\n\tIcon,\n} from '@wordpress/components';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { useState, memo, useRef, useEffect } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useViewportMatch } from '@wordpress/compose';\nimport {\n\tarchive,\n\tblockMeta,\n\tcalendar,\n\tcategory,\n\tcommentAuthorAvatar,\n\tpencil,\n\thome,\n\tlayout,\n\tlist,\n\tmedia,\n\tnotFound,\n\tpage,\n\tpin,\n\tverse,\n\tsearch,\n\ttag,\n} from '@wordpress/icons';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\nimport { focus } from '@wordpress/dom';\n\n/**\n * Internal dependencies\n */\nimport { TEMPLATE_POST_TYPE } from '../../utils/constants';\n\n/**\n * Internal dependencies\n */\nimport AddCustomTemplateModalContent from './add-custom-template-modal-content';\nimport {\n\tuseDefaultTemplateTypes,\n\tuseTaxonomiesMenuItems,\n\tusePostTypeMenuItems,\n\tuseAuthorMenuItem,\n\tusePostTypeArchiveMenuItems,\n} from './utils';\nimport AddCustomGenericTemplateModalContent from './add-custom-generic-template-modal-content';\nimport { unlock } from '../../lock-unlock';\n\nconst { useHistory } = unlock( routerPrivateApis );\n\nconst DEFAULT_TEMPLATE_SLUGS = [\n\t'front-page',\n\t'home',\n\t'single',\n\t'page',\n\t'index',\n\t'archive',\n\t'author',\n\t'category',\n\t'date',\n\t'tag',\n\t'search',\n\t'404',\n];\n\nconst TEMPLATE_ICONS = {\n\t'front-page': home,\n\thome: verse,\n\tsingle: pin,\n\tpage,\n\tarchive,\n\tsearch,\n\t404: notFound,\n\tindex: list,\n\tcategory,\n\tauthor: commentAuthorAvatar,\n\ttaxonomy: blockMeta,\n\tdate: calendar,\n\ttag,\n\tattachment: media,\n};\n\nfunction TemplateListItem( {\n\ttitle,\n\tdirection,\n\tclassName,\n\tdescription,\n\ticon,\n\tonClick,\n\tchildren,\n} ) {\n\treturn (\n\t\t<Button\n\t\t\t__next40pxDefaultSize\n\t\t\tclassName={ className }\n\t\t\tonClick={ onClick }\n\t\t\tlabel={ description }\n\t\t\tshowTooltip={ !! description }\n\t\t>\n\t\t\t<Flex\n\t\t\t\tas=\"span\"\n\t\t\t\tspacing={ 2 }\n\t\t\t\talign=\"center\"\n\t\t\t\tjustify=\"center\"\n\t\t\t\tstyle={ { width: '100%' } }\n\t\t\t\tdirection={ direction }\n\t\t\t>\n\t\t\t\t<div className=\"edit-site-add-new-template__template-icon\">\n\t\t\t\t\t<Icon icon={ icon } />\n\t\t\t\t</div>\n\t\t\t\t<VStack\n\t\t\t\t\tclassName=\"edit-site-add-new-template__template-name\"\n\t\t\t\t\talignment=\"center\"\n\t\t\t\t\tspacing={ 0 }\n\t\t\t\t>\n\t\t\t\t\t<Text\n\t\t\t\t\t\talign=\"center\"\n\t\t\t\t\t\tweight={ 500 }\n\t\t\t\t\t\tlineHeight={ 1.53846153846 } // 20px\n\t\t\t\t\t>\n\t\t\t\t\t\t{ title }\n\t\t\t\t\t</Text>\n\t\t\t\t\t{ children }\n\t\t\t\t</VStack>\n\t\t\t</Flex>\n\t\t</Button>\n\t);\n}\n\nconst modalContentMap = {\n\ttemplatesList: 1,\n\tcustomTemplate: 2,\n\tcustomGenericTemplate: 3,\n};\n\nfunction NewTemplateModal( { onClose } ) {\n\tconst [ modalContent, setModalContent ] = useState(\n\t\tmodalContentMap.templatesList\n\t);\n\tconst [ entityForSuggestions, setEntityForSuggestions ] = useState( {} );\n\tconst [ isSubmitting, setIsSubmitting ] = useState( false );\n\tconst missingTemplates = useMissingTemplates( setEntityForSuggestions, () =>\n\t\tsetModalContent( modalContentMap.customTemplate )\n\t);\n\tconst history = useHistory();\n\tconst { saveEntityRecord } = useDispatch( coreStore );\n\tconst { createErrorNotice, createSuccessNotice } =\n\t\tuseDispatch( noticesStore );\n\tconst containerRef = useRef( null );\n\tconst isMobile = useViewportMatch( 'medium', '<' );\n\n\tconst homeUrl = useSelect( ( select ) => {\n\t\t// Site index.\n\t\treturn select( coreStore ).getEntityRecord( 'root', '__unstableBase' )\n\t\t\t?.home;\n\t}, [] );\n\n\tconst TEMPLATE_SHORT_DESCRIPTIONS = {\n\t\t'front-page': homeUrl,\n\t\tdate: sprintf(\n\t\t\t// translators: %s: The homepage url.\n\t\t\t__( 'E.g. %s' ),\n\t\t\thomeUrl + '/' + new Date().getFullYear()\n\t\t),\n\t};\n\n\tuseEffect( () => {\n\t\t// Focus the first focusable element when component mounts or UI changes\n\t\t// We don't want to focus on the other modals because they have their own focus management.\n\t\tif (\n\t\t\tcontainerRef.current &&\n\t\t\tmodalContent === modalContentMap.templatesList\n\t\t) {\n\t\t\tconst [ firstFocusable ] = focus.focusable.find(\n\t\t\t\tcontainerRef.current\n\t\t\t);\n\t\t\tfirstFocusable?.focus();\n\t\t}\n\t}, [ modalContent ] );\n\n\tasync function createTemplate( template, isWPSuggestion = true ) {\n\t\tif ( isSubmitting ) {\n\t\t\treturn;\n\t\t}\n\t\tsetIsSubmitting( true );\n\t\ttry {\n\t\t\tconst { title, description, slug } = template;\n\t\t\tconst newTemplate = await saveEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\tTEMPLATE_POST_TYPE,\n\t\t\t\t{\n\t\t\t\t\tdescription,\n\t\t\t\t\t// Slugs need to be strings, so this is for template `404`\n\t\t\t\t\tslug: slug.toString(),\n\t\t\t\t\tstatus: 'publish',\n\t\t\t\t\ttitle,\n\t\t\t\t\t// This adds a post meta field in template that is part of `is_custom` value calculation.\n\t\t\t\t\tmeta: {\n\t\t\t\t\t\tis_wp_suggestion: isWPSuggestion,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{ throwOnError: true }\n\t\t\t);\n\n\t\t\t// Navigate to the created template editor.\n\t\t\thistory.navigate(\n\t\t\t\t`/${ TEMPLATE_POST_TYPE }/${ newTemplate.id }?canvas=edit`\n\t\t\t);\n\n\t\t\tcreateSuccessNotice(\n\t\t\t\tsprintf(\n\t\t\t\t\t// translators: %s: Title of the created post or template, e.g: \"Hello world\".\n\t\t\t\t\t__( '\"%s\" successfully created.' ),\n\t\t\t\t\tdecodeEntities( newTemplate.title?.rendered || title ) ||\n\t\t\t\t\t\t__( '(no title)' )\n\t\t\t\t),\n\t\t\t\t{\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t}\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 creating the template.' );\n\n\t\t\tcreateErrorNotice( errorMessage, {\n\t\t\t\ttype: 'snackbar',\n\t\t\t} );\n\t\t} finally {\n\t\t\tsetIsSubmitting( false );\n\t\t}\n\t}\n\tconst onModalClose = () => {\n\t\tonClose();\n\t\tsetModalContent( modalContentMap.templatesList );\n\t};\n\n\tlet modalTitle = __( 'Add template' );\n\tif ( modalContent === modalContentMap.customTemplate ) {\n\t\tmodalTitle = sprintf(\n\t\t\t// translators: %s: Name of the post type e.g: \"Post\".\n\t\t\t__( 'Add template: %s' ),\n\t\t\tentityForSuggestions.labels.singular_name\n\t\t);\n\t} else if ( modalContent === modalContentMap.customGenericTemplate ) {\n\t\tmodalTitle = __( 'Create custom template' );\n\t}\n\n\treturn (\n\t\t<Modal\n\t\t\ttitle={ modalTitle }\n\t\t\tclassName={ clsx( 'edit-site-add-new-template__modal', {\n\t\t\t\t'edit-site-add-new-template__modal_template_list':\n\t\t\t\t\tmodalContent === modalContentMap.templatesList,\n\t\t\t\t'edit-site-custom-template-modal':\n\t\t\t\t\tmodalContent === modalContentMap.customTemplate,\n\t\t\t} ) }\n\t\t\tonRequestClose={ onModalClose }\n\t\t\toverlayClassName={\n\t\t\t\tmodalContent === modalContentMap.customGenericTemplate\n\t\t\t\t\t? 'edit-site-custom-generic-template__modal'\n\t\t\t\t\t: undefined\n\t\t\t}\n\t\t\tref={ containerRef }\n\t\t>\n\t\t\t{ modalContent === modalContentMap.templatesList && (\n\t\t\t\t<Grid\n\t\t\t\t\tcolumns={ isMobile ? 2 : 3 }\n\t\t\t\t\tgap={ 4 }\n\t\t\t\t\talign=\"flex-start\"\n\t\t\t\t\tjustify=\"center\"\n\t\t\t\t\tclassName=\"edit-site-add-new-template__template-list__contents\"\n\t\t\t\t>\n\t\t\t\t\t<Flex className=\"edit-site-add-new-template__template-list__prompt\">\n\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t'Select what the new template should apply to:'\n\t\t\t\t\t\t) }\n\t\t\t\t\t</Flex>\n\t\t\t\t\t{ missingTemplates.map( ( template ) => {\n\t\t\t\t\t\tconst { title, slug, onClick } = template;\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<TemplateListItem\n\t\t\t\t\t\t\t\tkey={ slug }\n\t\t\t\t\t\t\t\ttitle={ title }\n\t\t\t\t\t\t\t\tdirection=\"column\"\n\t\t\t\t\t\t\t\tclassName=\"edit-site-add-new-template__template-button\"\n\t\t\t\t\t\t\t\tdescription={\n\t\t\t\t\t\t\t\t\tTEMPLATE_SHORT_DESCRIPTIONS[ slug ]\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\ticon={ TEMPLATE_ICONS[ slug ] || layout }\n\t\t\t\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\t\t\t\tonClick\n\t\t\t\t\t\t\t\t\t\t? onClick( template )\n\t\t\t\t\t\t\t\t\t\t: createTemplate( template )\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<TemplateListItem\n\t\t\t\t\t\ttitle={ __( 'Custom template' ) }\n\t\t\t\t\t\tdirection=\"row\"\n\t\t\t\t\t\tclassName=\"edit-site-add-new-template__custom-template-button\"\n\t\t\t\t\t\ticon={ pencil }\n\t\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\t\tsetModalContent(\n\t\t\t\t\t\t\t\tmodalContentMap.customGenericTemplate\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t}\n\t\t\t\t\t>\n\t\t\t\t\t\t<Text\n\t\t\t\t\t\t\tlineHeight={ 1.53846153846 } // 20px\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t'A custom template can be manually applied to any post or page.'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</Text>\n\t\t\t\t\t</TemplateListItem>\n\t\t\t\t</Grid>\n\t\t\t) }\n\t\t\t{ modalContent === modalContentMap.customTemplate && (\n\t\t\t\t<AddCustomTemplateModalContent\n\t\t\t\t\tonSelect={ createTemplate }\n\t\t\t\t\tentityForSuggestions={ entityForSuggestions }\n\t\t\t\t\tonBack={ () =>\n\t\t\t\t\t\tsetModalContent( modalContentMap.templatesList )\n\t\t\t\t\t}\n\t\t\t\t\tcontainerRef={ containerRef }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ modalContent === modalContentMap.customGenericTemplate && (\n\t\t\t\t<AddCustomGenericTemplateModalContent\n\t\t\t\t\tcreateTemplate={ createTemplate }\n\t\t\t\t\tonBack={ () =>\n\t\t\t\t\t\tsetModalContent( modalContentMap.templatesList )\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t) }\n\t\t</Modal>\n\t);\n}\n\nfunction NewTemplate() {\n\tconst [ showModal, setShowModal ] = useState( false );\n\n\tconst { postType } = useSelect( ( select ) => {\n\t\tconst { getPostType } = select( coreStore );\n\n\t\treturn {\n\t\t\tpostType: getPostType( TEMPLATE_POST_TYPE ),\n\t\t};\n\t}, [] );\n\n\tif ( ! postType ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<Button\n\t\t\t\tvariant=\"primary\"\n\t\t\t\tonClick={ () => setShowModal( true ) }\n\t\t\t\tlabel={ postType.labels.add_new_item }\n\t\t\t\t__next40pxDefaultSize\n\t\t\t>\n\t\t\t\t{ postType.labels.add_new_item }\n\t\t\t</Button>\n\t\t\t{ showModal && (\n\t\t\t\t<NewTemplateModal onClose={ () => setShowModal( false ) } />\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nfunction useMissingTemplates( setEntityForSuggestions, onClick ) {\n\tconst defaultTemplateTypes = useDefaultTemplateTypes();\n\tconst missingDefaultTemplates = ( defaultTemplateTypes || [] ).filter(\n\t\t( template ) => DEFAULT_TEMPLATE_SLUGS.includes( template.slug )\n\t);\n\tconst onClickMenuItem = ( _entityForSuggestions ) => {\n\t\tonClick?.();\n\t\tsetEntityForSuggestions( _entityForSuggestions );\n\t};\n\t// We need to replace existing default template types with\n\t// the create specific template functionality. The original\n\t// info (title, description, etc.) is preserved in the\n\t// used hooks.\n\tconst enhancedMissingDefaultTemplateTypes = [ ...missingDefaultTemplates ];\n\tconst { defaultTaxonomiesMenuItems, taxonomiesMenuItems } =\n\t\tuseTaxonomiesMenuItems( onClickMenuItem );\n\tconst { defaultPostTypesMenuItems, postTypesMenuItems } =\n\t\tusePostTypeMenuItems( onClickMenuItem );\n\n\tconst authorMenuItem = useAuthorMenuItem( onClickMenuItem );\n\t[\n\t\t...defaultTaxonomiesMenuItems,\n\t\t...defaultPostTypesMenuItems,\n\t\tauthorMenuItem,\n\t].forEach( ( menuItem ) => {\n\t\tif ( ! menuItem ) {\n\t\t\treturn;\n\t\t}\n\t\tconst matchIndex = enhancedMissingDefaultTemplateTypes.findIndex(\n\t\t\t( template ) => template.slug === menuItem.slug\n\t\t);\n\t\t// Some default template types might have been filtered above from\n\t\t// `missingDefaultTemplates` because they only check for the general\n\t\t// template. So here we either replace or append the item, augmented\n\t\t// with the check if it has available specific item to create a\n\t\t// template for.\n\t\tif ( matchIndex > -1 ) {\n\t\t\tenhancedMissingDefaultTemplateTypes[ matchIndex ] = menuItem;\n\t\t} else {\n\t\t\tenhancedMissingDefaultTemplateTypes.push( menuItem );\n\t\t}\n\t} );\n\t// Update the sort order to match the DEFAULT_TEMPLATE_SLUGS order.\n\tenhancedMissingDefaultTemplateTypes?.sort( ( template1, template2 ) => {\n\t\treturn (\n\t\t\tDEFAULT_TEMPLATE_SLUGS.indexOf( template1.slug ) -\n\t\t\tDEFAULT_TEMPLATE_SLUGS.indexOf( template2.slug )\n\t\t);\n\t} );\n\tconst missingTemplates = [\n\t\t...enhancedMissingDefaultTemplateTypes,\n\t\t...usePostTypeArchiveMenuItems(),\n\t\t...postTypesMenuItems,\n\t\t...taxonomiesMenuItems,\n\t];\n\treturn missingTemplates;\n}\n\nexport default memo( NewTemplate );\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAiB;AAKjB,wBAQO;AACP,2BAA+B;AAC/B,qBAAkD;AAClD,kBAAuC;AACvC,uBAAmC;AACnC,qBAAiC;AACjC,mBAiBO;AACP,kBAA4B;AAC5B,qBAAsC;AACtC,oBAAiD;AACjD,iBAAsB;AAKtB,uBAAmC;AAKnC,+CAA0C;AAC1C,mBAMO;AACP,uDAAiD;AACjD,yBAAuB;AA8DlB;AA5DL,IAAM,EAAE,WAAW,QAAI,2BAAQ,cAAAA,WAAkB;AAEjD,IAAM,yBAAyB;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD;AAEA,IAAM,iBAAiB;AAAA,EACtB,cAAc;AAAA,EACd,MAAM;AAAA,EACN,QAAQ;AAAA,EACR;AAAA,EACA;AAAA,EACA;AAAA,EACA,KAAK;AAAA,EACL,OAAO;AAAA,EACP;AAAA,EACA,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,MAAM;AAAA,EACN;AAAA,EACA,YAAY;AACb;AAEA,SAAS,iBAAkB;AAAA,EAC1B;AAAA,EACA;AAAA,E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
|
|
6
6
|
"names": ["routerPrivateApis", "VStack", "Text", "coreStore", "noticesStore", "clsx", "Grid", "AddCustomTemplateModalContent", "AddCustomGenericTemplateModalContent"]
|
|
7
7
|
}
|
|
@@ -16,6 +16,8 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
return to;
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// packages/edit-site/src/components/add-new-template/utils.js
|
|
19
21
|
var utils_exports = {};
|
|
20
22
|
__export(utils_exports, {
|
|
21
23
|
mapToIHasNameAndId: () => mapToIHasNameAndId,
|
|
@@ -35,8 +37,8 @@ var import_i18n = require("@wordpress/i18n");
|
|
|
35
37
|
var import_icons = require("@wordpress/icons");
|
|
36
38
|
var import_url = require("@wordpress/url");
|
|
37
39
|
var import_constants = require("../../utils/constants");
|
|
38
|
-
|
|
39
|
-
|
|
40
|
+
var EMPTY_OBJECT = {};
|
|
41
|
+
var getValueFromObjectPath = (object, path) => {
|
|
40
42
|
let value = object;
|
|
41
43
|
path.split(".").forEach((fieldName) => {
|
|
42
44
|
value = value?.[fieldName];
|
|
@@ -46,13 +48,13 @@ const getValueFromObjectPath = (object, path) => {
|
|
|
46
48
|
function prefixSlug(prefix, slug) {
|
|
47
49
|
return `${prefix}-${(0, import_url.safeDecodeURI)(slug)}`;
|
|
48
50
|
}
|
|
49
|
-
|
|
51
|
+
var mapToIHasNameAndId = (entities, path) => {
|
|
50
52
|
return (entities || []).map((entity) => ({
|
|
51
53
|
...entity,
|
|
52
54
|
name: (0, import_html_entities.decodeEntities)(getValueFromObjectPath(entity, path))
|
|
53
55
|
}));
|
|
54
56
|
};
|
|
55
|
-
|
|
57
|
+
var useExistingTemplates = () => {
|
|
56
58
|
return (0, import_data.useSelect)(
|
|
57
59
|
(select) => select(import_core_data.store).getEntityRecords(
|
|
58
60
|
"postType",
|
|
@@ -64,13 +66,13 @@ const useExistingTemplates = () => {
|
|
|
64
66
|
[]
|
|
65
67
|
);
|
|
66
68
|
};
|
|
67
|
-
|
|
69
|
+
var useDefaultTemplateTypes = () => {
|
|
68
70
|
return (0, import_data.useSelect)(
|
|
69
71
|
(select) => select(import_core_data.store).getCurrentTheme()?.default_template_types || [],
|
|
70
72
|
[]
|
|
71
73
|
);
|
|
72
74
|
};
|
|
73
|
-
|
|
75
|
+
var usePublicPostTypes = () => {
|
|
74
76
|
const postTypes = (0, import_data.useSelect)(
|
|
75
77
|
(select) => select(import_core_data.store).getPostTypes({ per_page: -1 }),
|
|
76
78
|
[]
|
|
@@ -87,7 +89,7 @@ const usePublicPostTypes = () => {
|
|
|
87
89
|
});
|
|
88
90
|
}, [postTypes]);
|
|
89
91
|
};
|
|
90
|
-
|
|
92
|
+
var usePublicTaxonomies = () => {
|
|
91
93
|
const taxonomies = (0, import_data.useSelect)(
|
|
92
94
|
(select) => select(import_core_data.store).getTaxonomies({ per_page: -1 }),
|
|
93
95
|
[]
|
|
@@ -161,7 +163,7 @@ function usePostTypeArchiveMenuItems() {
|
|
|
161
163
|
[postTypesWithArchives, existingTemplates, needsUniqueIdentifier]
|
|
162
164
|
);
|
|
163
165
|
}
|
|
164
|
-
|
|
166
|
+
var usePostTypeMenuItems = (onClickMenuItem) => {
|
|
165
167
|
const publicPostTypes = usePublicPostTypes();
|
|
166
168
|
const defaultTemplateTypes = useDefaultTemplateTypes();
|
|
167
169
|
const templateLabels = (0, import_element.useMemo)(
|
|
@@ -293,7 +295,7 @@ const usePostTypeMenuItems = (onClickMenuItem) => {
|
|
|
293
295
|
);
|
|
294
296
|
return postTypesMenuItems;
|
|
295
297
|
};
|
|
296
|
-
|
|
298
|
+
var useTaxonomiesMenuItems = (onClickMenuItem) => {
|
|
297
299
|
const publicTaxonomies = usePublicTaxonomies();
|
|
298
300
|
const existingTemplates = useExistingTemplates();
|
|
299
301
|
const defaultTemplateTypes = useDefaultTemplateTypes();
|
|
@@ -426,8 +428,8 @@ const useTaxonomiesMenuItems = (onClickMenuItem) => {
|
|
|
426
428
|
);
|
|
427
429
|
return taxonomiesMenuItems;
|
|
428
430
|
};
|
|
429
|
-
|
|
430
|
-
|
|
431
|
+
var USE_AUTHOR_MENU_ITEM_TEMPLATE_PREFIX = { user: "author" };
|
|
432
|
+
var USE_AUTHOR_MENU_ITEM_QUERY_PARAMETERS = { user: { who: "authors" } };
|
|
431
433
|
function useAuthorMenuItem(onClickMenuItem) {
|
|
432
434
|
const existingTemplates = useExistingTemplates();
|
|
433
435
|
const defaultTemplateTypes = useDefaultTemplateTypes();
|
|
@@ -497,7 +499,7 @@ function useAuthorMenuItem(onClickMenuItem) {
|
|
|
497
499
|
return authorMenuItem;
|
|
498
500
|
}
|
|
499
501
|
}
|
|
500
|
-
|
|
502
|
+
var useEntitiesInfo = (entityName, templatePrefixes, additionalQueryParameters = EMPTY_OBJECT) => {
|
|
501
503
|
const entitiesHasRecords = (0, import_data.useSelect)(
|
|
502
504
|
(select) => {
|
|
503
505
|
return Object.keys(templatePrefixes || {}).reduce(
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/add-new-template/utils.js"],
|
|
4
4
|
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { useMemo, useCallback } from '@wordpress/element';\nimport { __, _x, sprintf } from '@wordpress/i18n';\nimport { blockMeta, post, archive } from '@wordpress/icons';\nimport { safeDecodeURI } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport { TEMPLATE_POST_TYPE } from '../../utils/constants';\n\nconst EMPTY_OBJECT = {};\n\n/**\n * @typedef IHasNameAndId\n * @property {string|number} id The entity's id.\n * @property {string} name The entity's name.\n */\n\nconst getValueFromObjectPath = ( object, path ) => {\n\tlet value = object;\n\tpath.split( '.' ).forEach( ( fieldName ) => {\n\t\tvalue = value?.[ fieldName ];\n\t} );\n\treturn value;\n};\n\n/**\n * Helper that adds a prefix to a post slug. The slug needs to be URL-decoded first,\n * so that we have raw Unicode characters there. The server will truncate the slug to\n * 200 characters, respecing Unicode char boundary. On the other hand, the server\n * doesn't detect urlencoded octet boundary and can possibly construct slugs that\n * are not valid urlencoded strings.\n * @param {string} prefix The prefix to add to the slug.\n * @param {string} slug The slug to add the prefix to.\n * @return {string} The slug with the prefix.\n */\nfunction prefixSlug( prefix, slug ) {\n\treturn `${ prefix }-${ safeDecodeURI( slug ) }`;\n}\n\n/**\n * Helper util to map records to add a `name` prop from a\n * provided path, in order to handle all entities in the same\n * fashion(implementing`IHasNameAndId` interface).\n *\n * @param {Object[]} entities The array of entities.\n * @param {string} path The path to map a `name` property from the entity.\n * @return {IHasNameAndId[]} An array of entities that now implement the `IHasNameAndId` interface.\n */\nexport const mapToIHasNameAndId = ( entities, path ) => {\n\treturn ( entities || [] ).map( ( entity ) => ( {\n\t\t...entity,\n\t\tname: decodeEntities( getValueFromObjectPath( entity, path ) ),\n\t} ) );\n};\n\n/**\n * @typedef {Object} EntitiesInfo\n * @property {boolean} hasEntities If an entity has available records(posts, terms, etc..).\n * @property {number[]} existingEntitiesIds An array of the existing entities ids.\n */\n\nexport const useExistingTemplates = () => {\n\treturn useSelect(\n\t\t( select ) =>\n\t\t\tselect( coreStore ).getEntityRecords(\n\t\t\t\t'postType',\n\t\t\t\tTEMPLATE_POST_TYPE,\n\t\t\t\t{\n\t\t\t\t\tper_page: -1,\n\t\t\t\t}\n\t\t\t),\n\t\t[]\n\t);\n};\n\nexport const useDefaultTemplateTypes = () => {\n\treturn useSelect(\n\t\t( select ) =>\n\t\t\tselect( coreStore ).getCurrentTheme()?.default_template_types || [],\n\t\t[]\n\t);\n};\n\nconst usePublicPostTypes = () => {\n\tconst postTypes = useSelect(\n\t\t( select ) => select( coreStore ).getPostTypes( { per_page: -1 } ),\n\t\t[]\n\t);\n\treturn useMemo( () => {\n\t\tconst excludedPostTypes = [ 'attachment' ];\n\t\treturn postTypes\n\t\t\t?.filter(\n\t\t\t\t( { viewable, slug } ) =>\n\t\t\t\t\tviewable && ! excludedPostTypes.includes( slug )\n\t\t\t)\n\t\t\t.sort( ( a, b ) => {\n\t\t\t\t// Sort post types alphabetically by name,\n\t\t\t\t// but exclude the built-in 'post' type from sorting.\n\t\t\t\tif ( a.slug === 'post' || b.slug === 'post' ) {\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\n\t\t\t\treturn a.name.localeCompare( b.name );\n\t\t\t} );\n\t}, [ postTypes ] );\n};\n\nconst usePublicTaxonomies = () => {\n\tconst taxonomies = useSelect(\n\t\t( select ) => select( coreStore ).getTaxonomies( { per_page: -1 } ),\n\t\t[]\n\t);\n\treturn useMemo( () => {\n\t\treturn taxonomies?.filter(\n\t\t\t( { visibility } ) => visibility?.publicly_queryable\n\t\t);\n\t}, [ taxonomies ] );\n};\n\nexport function usePostTypeArchiveMenuItems() {\n\tconst publicPostTypes = usePublicPostTypes();\n\tconst postTypesWithArchives = useMemo(\n\t\t() => publicPostTypes?.filter( ( postType ) => postType.has_archive ),\n\t\t[ publicPostTypes ]\n\t);\n\tconst existingTemplates = useExistingTemplates();\n\t// We need to keep track of naming conflicts. If a conflict\n\t// occurs, we need to add slug.\n\tconst postTypeLabels = useMemo(\n\t\t() =>\n\t\t\tpublicPostTypes?.reduce( ( accumulator, { labels } ) => {\n\t\t\t\tconst singularName = labels.singular_name.toLowerCase();\n\t\t\t\taccumulator[ singularName ] =\n\t\t\t\t\t( accumulator[ singularName ] || 0 ) + 1;\n\t\t\t\treturn accumulator;\n\t\t\t}, {} ),\n\t\t[ publicPostTypes ]\n\t);\n\tconst needsUniqueIdentifier = useCallback(\n\t\t( { labels, slug } ) => {\n\t\t\tconst singularName = labels.singular_name.toLowerCase();\n\t\t\treturn postTypeLabels[ singularName ] > 1 && singularName !== slug;\n\t\t},\n\t\t[ postTypeLabels ]\n\t);\n\treturn useMemo(\n\t\t() =>\n\t\t\tpostTypesWithArchives\n\t\t\t\t?.filter(\n\t\t\t\t\t( postType ) =>\n\t\t\t\t\t\t! ( existingTemplates || [] ).some(\n\t\t\t\t\t\t\t( existingTemplate ) =>\n\t\t\t\t\t\t\t\texistingTemplate.slug ===\n\t\t\t\t\t\t\t\t'archive-' + postType.slug\n\t\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t\t.map( ( postType ) => {\n\t\t\t\t\tlet title;\n\t\t\t\t\tif ( needsUniqueIdentifier( postType ) ) {\n\t\t\t\t\t\ttitle = sprintf(\n\t\t\t\t\t\t\t// translators: %1s: Name of the post type e.g: \"Post\"; %2s: Slug of the post type e.g: \"book\".\n\t\t\t\t\t\t\t__( 'Archive: %1$s (%2$s)' ),\n\t\t\t\t\t\t\tpostType.labels.singular_name,\n\t\t\t\t\t\t\tpostType.slug\n\t\t\t\t\t\t);\n\t\t\t\t\t} else {\n\t\t\t\t\t\ttitle = sprintf(\n\t\t\t\t\t\t\t// translators: %s: Name of the post type e.g: \"Post\".\n\t\t\t\t\t\t\t__( 'Archive: %s' ),\n\t\t\t\t\t\t\tpostType.labels.singular_name\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\treturn {\n\t\t\t\t\t\tslug: 'archive-' + postType.slug,\n\t\t\t\t\t\tdescription: sprintf(\n\t\t\t\t\t\t\t// translators: %s: Name of the post type e.g: \"Post\".\n\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t'Displays an archive with the latest posts of type: %s.'\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tpostType.labels.singular_name\n\t\t\t\t\t\t),\n\t\t\t\t\t\ttitle,\n\t\t\t\t\t\t// `icon` is the `menu_icon` property of a post type. We\n\t\t\t\t\t\t// only handle `dashicons` for now, even if the `menu_icon`\n\t\t\t\t\t\t// also supports urls and svg as values.\n\t\t\t\t\t\ticon:\n\t\t\t\t\t\t\ttypeof postType.icon === 'string' &&\n\t\t\t\t\t\t\tpostType.icon.startsWith( 'dashicons-' )\n\t\t\t\t\t\t\t\t? postType.icon.slice( 10 )\n\t\t\t\t\t\t\t\t: archive,\n\t\t\t\t\t\ttemplatePrefix: 'archive',\n\t\t\t\t\t};\n\t\t\t\t} ) || [],\n\t\t[ postTypesWithArchives, existingTemplates, needsUniqueIdentifier ]\n\t);\n}\n\nexport const usePostTypeMenuItems = ( onClickMenuItem ) => {\n\tconst publicPostTypes = usePublicPostTypes();\n\tconst defaultTemplateTypes = useDefaultTemplateTypes();\n\t// We need to keep track of naming conflicts. If a conflict\n\t// occurs, we need to add slug.\n\tconst templateLabels = useMemo(\n\t\t() =>\n\t\t\tpublicPostTypes?.reduce( ( accumulator, { labels } ) => {\n\t\t\t\tconst templateName = (\n\t\t\t\t\tlabels.template_name || labels.singular_name\n\t\t\t\t).toLowerCase();\n\t\t\t\taccumulator[ templateName ] =\n\t\t\t\t\t( accumulator[ templateName ] || 0 ) + 1;\n\t\t\t\treturn accumulator;\n\t\t\t}, {} ),\n\t\t[ publicPostTypes ]\n\t);\n\tconst needsUniqueIdentifier = useCallback(\n\t\t( { labels, slug } ) => {\n\t\t\tconst templateName = (\n\t\t\t\tlabels.template_name || labels.singular_name\n\t\t\t).toLowerCase();\n\t\t\treturn templateLabels[ templateName ] > 1 && templateName !== slug;\n\t\t},\n\t\t[ templateLabels ]\n\t);\n\n\t// `page`is a special case in template hierarchy.\n\tconst templatePrefixes = useMemo(\n\t\t() =>\n\t\t\tpublicPostTypes?.reduce( ( accumulator, { slug } ) => {\n\t\t\t\tlet suffix = slug;\n\t\t\t\tif ( slug !== 'page' ) {\n\t\t\t\t\tsuffix = `single-${ suffix }`;\n\t\t\t\t}\n\t\t\t\taccumulator[ slug ] = suffix;\n\t\t\t\treturn accumulator;\n\t\t\t}, {} ),\n\t\t[ publicPostTypes ]\n\t);\n\tconst postTypesInfo = useEntitiesInfo( 'postType', templatePrefixes );\n\tconst menuItems = ( publicPostTypes || [] ).reduce(\n\t\t( accumulator, postType ) => {\n\t\t\tconst { slug, labels, icon } = postType;\n\t\t\t// We need to check if the general template is part of the\n\t\t\t// defaultTemplateTypes. If it is, just use that info and\n\t\t\t// augment it with the specific template functionality.\n\t\t\tconst generalTemplateSlug = templatePrefixes[ slug ];\n\t\t\tconst defaultTemplateType = defaultTemplateTypes?.find(\n\t\t\t\t( { slug: _slug } ) => _slug === generalTemplateSlug\n\t\t\t);\n\t\t\tconst _needsUniqueIdentifier = needsUniqueIdentifier( postType );\n\t\t\tlet menuItemTitle =\n\t\t\t\tlabels.template_name ||\n\t\t\t\tsprintf(\n\t\t\t\t\t// translators: %s: Name of the post type e.g: \"Post\".\n\t\t\t\t\t__( 'Single item: %s' ),\n\t\t\t\t\tlabels.singular_name\n\t\t\t\t);\n\t\t\tif ( _needsUniqueIdentifier ) {\n\t\t\t\tmenuItemTitle = labels.template_name\n\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t// translators: 1: Name of the template e.g: \"Single Item: Post\". 2: Slug of the post type e.g: \"book\".\n\t\t\t\t\t\t\t_x( '%1$s (%2$s)', 'post type menu label' ),\n\t\t\t\t\t\t\tlabels.template_name,\n\t\t\t\t\t\t\tslug\n\t\t\t\t\t )\n\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t// translators: 1: Name of the post type e.g: \"Post\". 2: Slug of the post type e.g: \"book\".\n\t\t\t\t\t\t\t_x(\n\t\t\t\t\t\t\t\t'Single item: %1$s (%2$s)',\n\t\t\t\t\t\t\t\t'post type menu label'\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tlabels.singular_name,\n\t\t\t\t\t\t\tslug\n\t\t\t\t\t );\n\t\t\t}\n\t\t\tconst menuItem = defaultTemplateType\n\t\t\t\t? {\n\t\t\t\t\t\t...defaultTemplateType,\n\t\t\t\t\t\ttemplatePrefix: templatePrefixes[ slug ],\n\t\t\t\t }\n\t\t\t\t: {\n\t\t\t\t\t\tslug: generalTemplateSlug,\n\t\t\t\t\t\ttitle: menuItemTitle,\n\t\t\t\t\t\tdescription: sprintf(\n\t\t\t\t\t\t\t// translators: %s: Name of the post type e.g: \"Post\".\n\t\t\t\t\t\t\t__( 'Displays a single item: %s.' ),\n\t\t\t\t\t\t\tlabels.singular_name\n\t\t\t\t\t\t),\n\t\t\t\t\t\t// `icon` is the `menu_icon` property of a post type. We\n\t\t\t\t\t\t// only handle `dashicons` for now, even if the `menu_icon`\n\t\t\t\t\t\t// also supports urls and svg as values.\n\t\t\t\t\t\ticon:\n\t\t\t\t\t\t\ttypeof icon === 'string' &&\n\t\t\t\t\t\t\ticon.startsWith( 'dashicons-' )\n\t\t\t\t\t\t\t\t? icon.slice( 10 )\n\t\t\t\t\t\t\t\t: post,\n\t\t\t\t\t\ttemplatePrefix: templatePrefixes[ slug ],\n\t\t\t\t };\n\t\t\tconst hasEntities = postTypesInfo?.[ slug ]?.hasEntities;\n\t\t\t// We have a different template creation flow only if they have entities.\n\t\t\tif ( hasEntities ) {\n\t\t\t\tmenuItem.onClick = ( template ) => {\n\t\t\t\t\tonClickMenuItem( {\n\t\t\t\t\t\ttype: 'postType',\n\t\t\t\t\t\tslug,\n\t\t\t\t\t\tconfig: {\n\t\t\t\t\t\t\trecordNamePath: 'title.rendered',\n\t\t\t\t\t\t\tqueryArgs: ( { search } ) => {\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t_fields: 'id,title,slug,link',\n\t\t\t\t\t\t\t\t\torderBy: search ? 'relevance' : 'modified',\n\t\t\t\t\t\t\t\t\texclude:\n\t\t\t\t\t\t\t\t\t\tpostTypesInfo[ slug ]\n\t\t\t\t\t\t\t\t\t\t\t.existingEntitiesIds,\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tgetSpecificTemplate: ( suggestion ) => {\n\t\t\t\t\t\t\t\tconst templateSlug = prefixSlug(\n\t\t\t\t\t\t\t\t\ttemplatePrefixes[ slug ],\n\t\t\t\t\t\t\t\t\tsuggestion.slug\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\ttitle: templateSlug,\n\t\t\t\t\t\t\t\t\tslug: templateSlug,\n\t\t\t\t\t\t\t\t\ttemplatePrefix: templatePrefixes[ slug ],\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\tlabels,\n\t\t\t\t\t\ttemplate,\n\t\t\t\t\t} );\n\t\t\t\t};\n\t\t\t}\n\t\t\t// We don't need to add the menu item if there are no entities.\n\t\t\tif ( hasEntities ) {\n\t\t\t\taccumulator.push( menuItem );\n\t\t\t}\n\t\t\treturn accumulator;\n\t\t},\n\t\t[]\n\t);\n\t// Split menu items into two groups: one for the default post types\n\t// and one for the rest.\n\tconst postTypesMenuItems = useMemo(\n\t\t() =>\n\t\t\tmenuItems.reduce(\n\t\t\t\t( accumulator, postType ) => {\n\t\t\t\t\tconst { slug } = postType;\n\t\t\t\t\tlet key = 'postTypesMenuItems';\n\t\t\t\t\tif ( slug === 'page' ) {\n\t\t\t\t\t\tkey = 'defaultPostTypesMenuItems';\n\t\t\t\t\t}\n\t\t\t\t\taccumulator[ key ].push( postType );\n\t\t\t\t\treturn accumulator;\n\t\t\t\t},\n\t\t\t\t{ defaultPostTypesMenuItems: [], postTypesMenuItems: [] }\n\t\t\t),\n\t\t[ menuItems ]\n\t);\n\treturn postTypesMenuItems;\n};\n\nexport const useTaxonomiesMenuItems = ( onClickMenuItem ) => {\n\tconst publicTaxonomies = usePublicTaxonomies();\n\tconst existingTemplates = useExistingTemplates();\n\tconst defaultTemplateTypes = useDefaultTemplateTypes();\n\t// `category` and `post_tag` are special cases in template hierarchy.\n\tconst templatePrefixes = useMemo(\n\t\t() =>\n\t\t\tpublicTaxonomies?.reduce( ( accumulator, { slug } ) => {\n\t\t\t\tlet suffix = slug;\n\t\t\t\tif ( ! [ 'category', 'post_tag' ].includes( slug ) ) {\n\t\t\t\t\tsuffix = `taxonomy-${ suffix }`;\n\t\t\t\t}\n\t\t\t\tif ( slug === 'post_tag' ) {\n\t\t\t\t\tsuffix = `tag`;\n\t\t\t\t}\n\t\t\t\taccumulator[ slug ] = suffix;\n\t\t\t\treturn accumulator;\n\t\t\t}, {} ),\n\t\t[ publicTaxonomies ]\n\t);\n\t// We need to keep track of naming conflicts. If a conflict\n\t// occurs, we need to add slug.\n\tconst taxonomyLabels = publicTaxonomies?.reduce(\n\t\t( accumulator, { labels } ) => {\n\t\t\tconst templateName = (\n\t\t\t\tlabels.template_name || labels.singular_name\n\t\t\t).toLowerCase();\n\t\t\taccumulator[ templateName ] =\n\t\t\t\t( accumulator[ templateName ] || 0 ) + 1;\n\t\t\treturn accumulator;\n\t\t},\n\t\t{}\n\t);\n\tconst needsUniqueIdentifier = ( labels, slug ) => {\n\t\tif ( [ 'category', 'post_tag' ].includes( slug ) ) {\n\t\t\treturn false;\n\t\t}\n\t\tconst templateName = (\n\t\t\tlabels.template_name || labels.singular_name\n\t\t).toLowerCase();\n\t\treturn taxonomyLabels[ templateName ] > 1 && templateName !== slug;\n\t};\n\tconst taxonomiesInfo = useEntitiesInfo( 'taxonomy', templatePrefixes );\n\tconst existingTemplateSlugs = ( existingTemplates || [] ).map(\n\t\t( { slug } ) => slug\n\t);\n\tconst menuItems = ( publicTaxonomies || [] ).reduce(\n\t\t( accumulator, taxonomy ) => {\n\t\t\tconst { slug, labels } = taxonomy;\n\t\t\t// We need to check if the general template is part of the\n\t\t\t// defaultTemplateTypes. If it is, just use that info and\n\t\t\t// augment it with the specific template functionality.\n\t\t\tconst generalTemplateSlug = templatePrefixes[ slug ];\n\t\t\tconst defaultTemplateType = defaultTemplateTypes?.find(\n\t\t\t\t( { slug: _slug } ) => _slug === generalTemplateSlug\n\t\t\t);\n\t\t\tconst hasGeneralTemplate =\n\t\t\t\texistingTemplateSlugs?.includes( generalTemplateSlug );\n\t\t\tconst _needsUniqueIdentifier = needsUniqueIdentifier(\n\t\t\t\tlabels,\n\t\t\t\tslug\n\t\t\t);\n\t\t\tlet menuItemTitle = labels.template_name || labels.singular_name;\n\t\t\tif ( _needsUniqueIdentifier ) {\n\t\t\t\tmenuItemTitle = labels.template_name\n\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t// translators: 1: Name of the template e.g: \"Products by Category\". 2: Slug of the taxonomy e.g: \"product_cat\".\n\t\t\t\t\t\t\t_x( '%1$s (%2$s)', 'taxonomy template menu label' ),\n\t\t\t\t\t\t\tlabels.template_name,\n\t\t\t\t\t\t\tslug\n\t\t\t\t\t )\n\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t// translators: 1: Name of the taxonomy e.g: \"Category\". 2: Slug of the taxonomy e.g: \"product_cat\".\n\t\t\t\t\t\t\t_x( '%1$s (%2$s)', 'taxonomy menu label' ),\n\t\t\t\t\t\t\tlabels.singular_name,\n\t\t\t\t\t\t\tslug\n\t\t\t\t\t );\n\t\t\t}\n\t\t\tconst menuItem = defaultTemplateType\n\t\t\t\t? {\n\t\t\t\t\t\t...defaultTemplateType,\n\t\t\t\t\t\ttemplatePrefix: templatePrefixes[ slug ],\n\t\t\t\t }\n\t\t\t\t: {\n\t\t\t\t\t\tslug: generalTemplateSlug,\n\t\t\t\t\t\ttitle: menuItemTitle,\n\t\t\t\t\t\tdescription: sprintf(\n\t\t\t\t\t\t\t// translators: %s: Name of the taxonomy e.g: \"Product Categories\".\n\t\t\t\t\t\t\t__( 'Displays taxonomy: %s.' ),\n\t\t\t\t\t\t\tlabels.singular_name\n\t\t\t\t\t\t),\n\t\t\t\t\t\ticon: blockMeta,\n\t\t\t\t\t\ttemplatePrefix: templatePrefixes[ slug ],\n\t\t\t\t };\n\t\t\tconst hasEntities = taxonomiesInfo?.[ slug ]?.hasEntities;\n\t\t\t// We have a different template creation flow only if they have entities.\n\t\t\tif ( hasEntities ) {\n\t\t\t\tmenuItem.onClick = ( template ) => {\n\t\t\t\t\tonClickMenuItem( {\n\t\t\t\t\t\ttype: 'taxonomy',\n\t\t\t\t\t\tslug,\n\t\t\t\t\t\tconfig: {\n\t\t\t\t\t\t\tqueryArgs: ( { search } ) => {\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t_fields: 'id,name,slug,link',\n\t\t\t\t\t\t\t\t\torderBy: search ? 'name' : 'count',\n\t\t\t\t\t\t\t\t\texclude:\n\t\t\t\t\t\t\t\t\t\ttaxonomiesInfo[ slug ]\n\t\t\t\t\t\t\t\t\t\t\t.existingEntitiesIds,\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tgetSpecificTemplate: ( suggestion ) => {\n\t\t\t\t\t\t\t\tconst templateSlug = prefixSlug(\n\t\t\t\t\t\t\t\t\ttemplatePrefixes[ slug ],\n\t\t\t\t\t\t\t\t\tsuggestion.slug\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\ttitle: templateSlug,\n\t\t\t\t\t\t\t\t\tslug: templateSlug,\n\t\t\t\t\t\t\t\t\ttemplatePrefix: templatePrefixes[ slug ],\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\tlabels,\n\t\t\t\t\t\thasGeneralTemplate,\n\t\t\t\t\t\ttemplate,\n\t\t\t\t\t} );\n\t\t\t\t};\n\t\t\t}\n\t\t\t// We don't need to add the menu item if there are no\n\t\t\t// entities and the general template exists.\n\t\t\tif ( ! hasGeneralTemplate || hasEntities ) {\n\t\t\t\taccumulator.push( menuItem );\n\t\t\t}\n\t\t\treturn accumulator;\n\t\t},\n\t\t[]\n\t);\n\t// Split menu items into two groups: one for the default taxonomies\n\t// and one for the rest.\n\tconst taxonomiesMenuItems = useMemo(\n\t\t() =>\n\t\t\tmenuItems.reduce(\n\t\t\t\t( accumulator, taxonomy ) => {\n\t\t\t\t\tconst { slug } = taxonomy;\n\t\t\t\t\tlet key = 'taxonomiesMenuItems';\n\t\t\t\t\tif ( [ 'category', 'tag' ].includes( slug ) ) {\n\t\t\t\t\t\tkey = 'defaultTaxonomiesMenuItems';\n\t\t\t\t\t}\n\t\t\t\t\taccumulator[ key ].push( taxonomy );\n\t\t\t\t\treturn accumulator;\n\t\t\t\t},\n\t\t\t\t{ defaultTaxonomiesMenuItems: [], taxonomiesMenuItems: [] }\n\t\t\t),\n\t\t[ menuItems ]\n\t);\n\treturn taxonomiesMenuItems;\n};\n\nconst USE_AUTHOR_MENU_ITEM_TEMPLATE_PREFIX = { user: 'author' };\nconst USE_AUTHOR_MENU_ITEM_QUERY_PARAMETERS = { user: { who: 'authors' } };\nexport function useAuthorMenuItem( onClickMenuItem ) {\n\tconst existingTemplates = useExistingTemplates();\n\tconst defaultTemplateTypes = useDefaultTemplateTypes();\n\tconst authorInfo = useEntitiesInfo(\n\t\t'root',\n\t\tUSE_AUTHOR_MENU_ITEM_TEMPLATE_PREFIX,\n\t\tUSE_AUTHOR_MENU_ITEM_QUERY_PARAMETERS\n\t);\n\tlet authorMenuItem = defaultTemplateTypes?.find(\n\t\t( { slug } ) => slug === 'author'\n\t);\n\tif ( ! authorMenuItem ) {\n\t\tauthorMenuItem = {\n\t\t\tdescription: __(\n\t\t\t\t'Displays latest posts written by a single author.'\n\t\t\t),\n\t\t\tslug: 'author',\n\t\t\ttitle: 'Author',\n\t\t};\n\t}\n\tconst hasGeneralTemplate = !! existingTemplates?.find(\n\t\t( { slug } ) => slug === 'author'\n\t);\n\tif ( authorInfo.user?.hasEntities ) {\n\t\tauthorMenuItem = { ...authorMenuItem, templatePrefix: 'author' };\n\t\tauthorMenuItem.onClick = ( template ) => {\n\t\t\tonClickMenuItem( {\n\t\t\t\ttype: 'root',\n\t\t\t\tslug: 'user',\n\t\t\t\tconfig: {\n\t\t\t\t\tqueryArgs: ( { search } ) => {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t_fields: 'id,name,slug,link',\n\t\t\t\t\t\t\torderBy: search ? 'name' : 'registered_date',\n\t\t\t\t\t\t\texclude: authorInfo.user.existingEntitiesIds,\n\t\t\t\t\t\t\twho: 'authors',\n\t\t\t\t\t\t};\n\t\t\t\t\t},\n\t\t\t\t\tgetSpecificTemplate: ( suggestion ) => {\n\t\t\t\t\t\tconst templateSlug = prefixSlug(\n\t\t\t\t\t\t\t'author',\n\t\t\t\t\t\t\tsuggestion.slug\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\ttitle: sprintf(\n\t\t\t\t\t\t\t\t// translators: %s: Name of the author e.g: \"Admin\".\n\t\t\t\t\t\t\t\t__( 'Author: %s' ),\n\t\t\t\t\t\t\t\tsuggestion.name\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tslug: templateSlug,\n\t\t\t\t\t\t\ttemplatePrefix: 'author',\n\t\t\t\t\t\t};\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tlabels: {\n\t\t\t\t\tsingular_name: __( 'Author' ),\n\t\t\t\t\tsearch_items: __( 'Search Authors' ),\n\t\t\t\t\tnot_found: __( 'No authors found.' ),\n\t\t\t\t\tall_items: __( 'All Authors' ),\n\t\t\t\t},\n\t\t\t\thasGeneralTemplate,\n\t\t\t\ttemplate,\n\t\t\t} );\n\t\t};\n\t}\n\tif ( ! hasGeneralTemplate || authorInfo.user?.hasEntities ) {\n\t\treturn authorMenuItem;\n\t}\n}\n\n/**\n * Helper hook that returns information about an entity having\n * records that we can create a specific template for.\n *\n * For example we can search for `terms` in `taxonomy` entity or\n * `posts` in `postType` entity.\n *\n * First we need to find the existing records with an associated template,\n * to query afterwards for any remaining record, by excluding them.\n *\n * @param {string} entityName The entity's name.\n * @param {Record<string,string>} templatePrefixes An object with the entity's slug as key and the template prefix as value.\n * @param {Record<string,Object>} additionalQueryParameters An object with the entity's slug as key and additional query parameters as value.\n * @return {Record<string,EntitiesInfo>} An object with the entity's slug as key and the EntitiesInfo as value.\n */\nconst useEntitiesInfo = (\n\tentityName,\n\ttemplatePrefixes,\n\tadditionalQueryParameters = EMPTY_OBJECT\n) => {\n\tconst entitiesHasRecords = useSelect(\n\t\t( select ) => {\n\t\t\treturn Object.keys( templatePrefixes || {} ).reduce(\n\t\t\t\t( accumulator, slug ) => {\n\t\t\t\t\taccumulator[ slug ] = !! select(\n\t\t\t\t\t\tcoreStore\n\t\t\t\t\t).getEntityRecords( entityName, slug, {\n\t\t\t\t\t\tper_page: 1,\n\t\t\t\t\t\t_fields: 'id',\n\t\t\t\t\t\tcontext: 'view',\n\t\t\t\t\t\t...additionalQueryParameters[ slug ],\n\t\t\t\t\t} )?.length;\n\t\t\t\t\treturn accumulator;\n\t\t\t\t},\n\t\t\t\t{}\n\t\t\t);\n\t\t},\n\t\t[ templatePrefixes, entityName, additionalQueryParameters ]\n\t);\n\tconst entitiesInfo = useMemo( () => {\n\t\treturn Object.keys( templatePrefixes || {} ).reduce(\n\t\t\t( accumulator, slug ) => {\n\t\t\t\taccumulator[ slug ] = {\n\t\t\t\t\thasEntities: entitiesHasRecords[ slug ],\n\t\t\t\t};\n\t\t\t\treturn accumulator;\n\t\t\t},\n\t\t\t{}\n\t\t);\n\t}, [ templatePrefixes, entitiesHasRecords ] );\n\treturn entitiesInfo;\n};\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAA0B;AAC1B,uBAAmC;AACnC,2BAA+B;AAC/B,qBAAqC;AACrC,kBAAgC;AAChC,mBAAyC;AACzC,iBAA8B;AAK9B,uBAAmC;AAEnC,IAAM,eAAe,CAAC;AAQtB,IAAM,yBAAyB,CAAE,QAAQ,SAAU;AAClD,MAAI,QAAQ;AACZ,OAAK,MAAO,GAAI,EAAE,QAAS,CAAE,cAAe;AAC3C,YAAQ,QAAS,SAAU;AAAA,EAC5B,CAAE;AACF,SAAO;AACR;AAYA,SAAS,WAAY,QAAQ,MAAO;AACnC,SAA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12 +26,13 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
26
26
|
mod
|
|
27
27
|
));
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// packages/edit-site/src/components/app/index.js
|
|
29
31
|
var app_exports = {};
|
|
30
32
|
__export(app_exports, {
|
|
31
33
|
default: () => App
|
|
32
34
|
});
|
|
33
35
|
module.exports = __toCommonJS(app_exports);
|
|
34
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
35
36
|
var import_data = require("@wordpress/data");
|
|
36
37
|
var import_router = require("@wordpress/router");
|
|
37
38
|
var import_element = require("@wordpress/element");
|
|
@@ -43,7 +44,8 @@ var import_use_common_commands = require("../../hooks/commands/use-common-comman
|
|
|
43
44
|
var import_use_set_command_context = __toESM(require("../../hooks/commands/use-set-command-context"));
|
|
44
45
|
var import_site_editor_routes = require("../site-editor-routes");
|
|
45
46
|
var import_is_previewing_theme = require("../../utils/is-previewing-theme");
|
|
46
|
-
|
|
47
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
48
|
+
var { RouterProvider } = (0, import_lock_unlock.unlock)(import_router.privateApis);
|
|
47
49
|
function AppLayout() {
|
|
48
50
|
(0, import_use_common_commands.useCommonCommands)();
|
|
49
51
|
(0, import_use_set_command_context.default)();
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/app/index.js"],
|
|
4
4
|
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\nimport { useCallback, useMemo } from '@wordpress/element';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport Layout from '../layout';\nimport { unlock } from '../../lock-unlock';\nimport { store as editSiteStore } from '../../store';\nimport { useCommonCommands } from '../../hooks/commands/use-common-commands';\nimport useSetCommandContext from '../../hooks/commands/use-set-command-context';\nimport { useRegisterSiteEditorRoutes } from '../site-editor-routes';\nimport {\n\tcurrentlyPreviewingTheme,\n\tisPreviewingTheme,\n} from '../../utils/is-previewing-theme';\n\nconst { RouterProvider } = unlock( routerPrivateApis );\n\nfunction AppLayout() {\n\tuseCommonCommands();\n\tuseSetCommandContext();\n\n\treturn <Layout />;\n}\n\nexport default function App() {\n\tuseRegisterSiteEditorRoutes();\n\tconst { routes, currentTheme, editorSettings } = useSelect( ( select ) => {\n\t\treturn {\n\t\t\troutes: unlock( select( editSiteStore ) ).getRoutes(),\n\t\t\tcurrentTheme: select( coreStore ).getCurrentTheme(),\n\t\t\t// This is a temp solution until the has_theme_json value is available for the current theme.\n\t\t\teditorSettings: select( editSiteStore ).getSettings(),\n\t\t};\n\t}, [] );\n\n\tconst beforeNavigate = useCallback( ( { path, query } ) => {\n\t\tif ( ! isPreviewingTheme() ) {\n\t\t\treturn { path, query };\n\t\t}\n\n\t\treturn {\n\t\t\tpath,\n\t\t\tquery: {\n\t\t\t\t...query,\n\t\t\t\twp_theme_preview:\n\t\t\t\t\t'wp_theme_preview' in query\n\t\t\t\t\t\t? query.wp_theme_preview\n\t\t\t\t\t\t: currentlyPreviewingTheme(),\n\t\t\t},\n\t\t};\n\t}, [] );\n\n\tconst matchResolverArgsValue = useMemo(\n\t\t() => ( {\n\t\t\tsiteData: { currentTheme, editorSettings },\n\t\t} ),\n\t\t[ currentTheme, editorSettings ]\n\t);\n\n\treturn (\n\t\t<RouterProvider\n\t\t\troutes={ routes }\n\t\t\tpathArg=\"p\"\n\t\t\tbeforeNavigate={ beforeNavigate }\n\t\t\tmatchResolverArgs={ matchResolverArgsValue }\n\t\t>\n\t\t\t<AppLayout />\n\t\t</RouterProvider>\n\t);\n}\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAA0B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