@wordpress/edit-site 5.4.0 → 5.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/build/components/add-new-template/add-custom-template-modal.js +12 -3
- package/build/components/add-new-template/add-custom-template-modal.js.map +1 -1
- package/build/components/add-new-template/new-template-part.js +8 -7
- package/build/components/add-new-template/new-template-part.js.map +1 -1
- package/build/components/add-new-template/new-template.js +19 -16
- package/build/components/add-new-template/new-template.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/editor-canvas.js +2 -1
- package/build/components/block-editor/editor-canvas.js.map +1 -1
- package/build/components/editor/index.js +5 -7
- package/build/components/editor/index.js.map +1 -1
- package/build/components/global-styles/border-panel.js +20 -159
- package/build/components/global-styles/border-panel.js.map +1 -1
- package/build/components/global-styles/context-menu.js +13 -11
- package/build/components/global-styles/context-menu.js.map +1 -1
- package/build/components/global-styles/dimensions-panel.js +41 -487
- package/build/components/global-styles/dimensions-panel.js.map +1 -1
- package/build/components/global-styles/duotone-panel.js +78 -0
- package/build/components/global-styles/duotone-panel.js.map +1 -0
- package/build/components/global-styles/filter-utils.js +17 -0
- package/build/components/global-styles/filter-utils.js.map +1 -0
- package/build/components/global-styles/hooks.js +11 -26
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/preview.js +9 -5
- package/build/components/global-styles/preview.js.map +1 -1
- package/build/components/global-styles/screen-block-list.js +6 -11
- package/build/components/global-styles/screen-block-list.js.map +1 -1
- package/build/components/global-styles/screen-border.js +14 -6
- package/build/components/global-styles/screen-border.js.map +1 -1
- package/build/components/global-styles/screen-filters.js +46 -0
- package/build/components/global-styles/screen-filters.js.map +1 -0
- package/build/components/global-styles/screen-layout.js +13 -5
- package/build/components/global-styles/screen-layout.js.map +1 -1
- package/build/components/global-styles/screen-root.js +2 -1
- package/build/components/global-styles/screen-root.js.map +1 -1
- package/build/components/global-styles/screen-style-variations.js +2 -1
- package/build/components/global-styles/screen-style-variations.js.map +1 -1
- package/build/components/global-styles/screen-variations.js +1 -1
- package/build/components/global-styles/screen-variations.js.map +1 -1
- package/build/components/global-styles/shadow-panel.js +6 -4
- package/build/components/global-styles/shadow-panel.js.map +1 -1
- package/build/components/global-styles/typography-panel.js +2 -5
- package/build/components/global-styles/typography-panel.js.map +1 -1
- package/build/components/global-styles/ui.js +7 -1
- package/build/components/global-styles/ui.js.map +1 -1
- package/build/components/keyboard-shortcut-help-modal/config.js +12 -0
- package/build/components/keyboard-shortcut-help-modal/config.js.map +1 -1
- package/build/components/keyboard-shortcuts/edit-mode.js +124 -0
- package/build/components/keyboard-shortcuts/edit-mode.js.map +1 -0
- package/build/components/keyboard-shortcuts/global.js +48 -0
- package/build/components/keyboard-shortcuts/global.js.map +1 -0
- package/build/components/keyboard-shortcuts/index.js +67 -0
- package/build/components/keyboard-shortcuts/index.js.map +1 -1
- package/build/components/keyboard-shortcuts/register.js +153 -0
- package/build/components/keyboard-shortcuts/register.js.map +1 -0
- package/build/components/layout/index.js +12 -1
- package/build/components/layout/index.js.map +1 -1
- package/build/components/list/added-by.js +127 -136
- package/build/components/list/added-by.js.map +1 -1
- package/build/components/list/index.js +2 -1
- package/build/components/list/index.js.map +1 -1
- package/build/components/list/table.js +9 -7
- package/build/components/list/table.js.map +1 -1
- package/build/components/routes/link.js +4 -1
- package/build/components/routes/link.js.map +1 -1
- package/build/components/save-hub/index.js +82 -0
- package/build/components/save-hub/index.js.map +1 -0
- package/build/components/save-panel/index.js +11 -1
- package/build/components/save-panel/index.js.map +1 -1
- package/build/components/sidebar/index.js +27 -17
- package/build/components/sidebar/index.js.map +1 -1
- package/build/components/sidebar-button/index.js +30 -0
- package/build/components/sidebar-button/index.js.map +1 -0
- package/build/components/sidebar-edit-mode/global-styles-sidebar.js +8 -2
- package/build/components/sidebar-edit-mode/global-styles-sidebar.js.map +1 -1
- package/build/components/sidebar-navigation-screen/index.js +14 -11
- package/build/components/sidebar-navigation-screen/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-main/index.js +16 -16
- package/build/components/sidebar-navigation-screen-main/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-item/index.js +22 -26
- package/build/components/sidebar-navigation-screen-navigation-item/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-menus/index.js +97 -14
- package/build/components/sidebar-navigation-screen-navigation-menus/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-menus/loader.js +19 -0
- package/build/components/sidebar-navigation-screen-navigation-menus/loader.js.map +1 -0
- package/build/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js +77 -0
- package/build/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js.map +1 -0
- package/build/components/sidebar-navigation-screen-template/index.js +66 -27
- package/build/components/sidebar-navigation-screen-template/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-templates/index.js +30 -17
- package/build/components/sidebar-navigation-screen-templates/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-templates-browse/index.js +14 -10
- package/build/components/sidebar-navigation-screen-templates-browse/index.js.map +1 -1
- package/build/components/site-hub/index.js +3 -1
- package/build/components/site-hub/index.js.map +1 -1
- package/build/components/style-book/index.js +151 -21
- package/build/components/style-book/index.js.map +1 -1
- package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js +36 -34
- package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
- package/build/components/sync-state-with-url/use-sync-canvas-mode-with-url.js +24 -8
- package/build/components/sync-state-with-url/use-sync-canvas-mode-with-url.js.map +1 -1
- package/build/components/sync-state-with-url/use-sync-path-with-url.js +67 -18
- package/build/components/sync-state-with-url/use-sync-path-with-url.js.map +1 -1
- package/build/components/template-details/index.js +5 -10
- package/build/components/template-details/index.js.map +1 -1
- package/build/components/template-part-converter/convert-to-regular.js +8 -12
- package/build/components/template-part-converter/convert-to-regular.js.map +1 -1
- package/build/components/template-part-converter/convert-to-template-part.js +2 -2
- package/build/components/template-part-converter/convert-to-template-part.js.map +1 -1
- package/build/components/template-part-converter/index.js +19 -14
- package/build/components/template-part-converter/index.js.map +1 -1
- package/build/components/use-edited-entity-record/index.js +6 -6
- package/build/components/use-edited-entity-record/index.js.map +1 -1
- package/build/index.js +13 -22
- package/build/index.js.map +1 -1
- package/build/store/actions.js +2 -2
- package/build/store/actions.js.map +1 -1
- package/build/utils/get-is-list-page.js +1 -1
- package/build/utils/get-is-list-page.js.map +1 -1
- package/build/utils/history.js +8 -2
- package/build/utils/history.js.map +1 -1
- package/build-module/components/add-new-template/add-custom-template-modal.js +13 -4
- package/build-module/components/add-new-template/add-custom-template-modal.js.map +1 -1
- package/build-module/components/add-new-template/new-template-part.js +8 -7
- package/build-module/components/add-new-template/new-template-part.js.map +1 -1
- package/build-module/components/add-new-template/new-template.js +21 -17
- package/build-module/components/add-new-template/new-template.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/editor-canvas.js +2 -1
- package/build-module/components/block-editor/editor-canvas.js.map +1 -1
- package/build-module/components/editor/index.js +5 -6
- package/build-module/components/editor/index.js.map +1 -1
- package/build-module/components/global-styles/border-panel.js +21 -157
- package/build-module/components/global-styles/border-panel.js.map +1 -1
- package/build-module/components/global-styles/context-menu.js +14 -11
- package/build-module/components/global-styles/context-menu.js.map +1 -1
- package/build-module/components/global-styles/dimensions-panel.js +43 -480
- package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
- package/build-module/components/global-styles/duotone-panel.js +67 -0
- package/build-module/components/global-styles/duotone-panel.js.map +1 -0
- package/build-module/components/global-styles/filter-utils.js +9 -0
- package/build-module/components/global-styles/filter-utils.js.map +1 -0
- package/build-module/components/global-styles/hooks.js +11 -26
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/global-styles/preview.js +10 -6
- package/build-module/components/global-styles/preview.js.map +1 -1
- package/build-module/components/global-styles/screen-block-list.js +6 -8
- package/build-module/components/global-styles/screen-block-list.js.map +1 -1
- package/build-module/components/global-styles/screen-border.js +12 -3
- package/build-module/components/global-styles/screen-border.js.map +1 -1
- package/build-module/components/global-styles/screen-filters.js +33 -0
- package/build-module/components/global-styles/screen-filters.js.map +1 -0
- package/build-module/components/global-styles/screen-layout.js +11 -2
- package/build-module/components/global-styles/screen-layout.js.map +1 -1
- package/build-module/components/global-styles/screen-root.js +2 -1
- package/build-module/components/global-styles/screen-root.js.map +1 -1
- package/build-module/components/global-styles/screen-style-variations.js +2 -1
- package/build-module/components/global-styles/screen-style-variations.js.map +1 -1
- package/build-module/components/global-styles/screen-variations.js +1 -1
- package/build-module/components/global-styles/screen-variations.js.map +1 -1
- package/build-module/components/global-styles/shadow-panel.js +6 -4
- package/build-module/components/global-styles/shadow-panel.js.map +1 -1
- package/build-module/components/global-styles/typography-panel.js +2 -5
- package/build-module/components/global-styles/typography-panel.js.map +1 -1
- package/build-module/components/global-styles/ui.js +6 -1
- package/build-module/components/global-styles/ui.js.map +1 -1
- package/build-module/components/keyboard-shortcut-help-modal/config.js +12 -0
- package/build-module/components/keyboard-shortcut-help-modal/config.js.map +1 -1
- package/build-module/components/keyboard-shortcuts/edit-mode.js +108 -0
- package/build-module/components/keyboard-shortcuts/edit-mode.js.map +1 -0
- package/build-module/components/keyboard-shortcuts/global.js +37 -0
- package/build-module/components/keyboard-shortcuts/global.js.map +1 -0
- package/build-module/components/keyboard-shortcuts/index.js +65 -0
- package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
- package/build-module/components/keyboard-shortcuts/register.js +141 -0
- package/build-module/components/keyboard-shortcuts/register.js.map +1 -0
- package/build-module/components/layout/index.js +10 -1
- package/build-module/components/layout/index.js.map +1 -1
- package/build-module/components/list/added-by.js +126 -138
- package/build-module/components/list/added-by.js.map +1 -1
- package/build-module/components/list/index.js +2 -1
- package/build-module/components/list/index.js.map +1 -1
- package/build-module/components/list/table.js +9 -7
- package/build-module/components/list/table.js.map +1 -1
- package/build-module/components/routes/link.js +5 -2
- package/build-module/components/routes/link.js.map +1 -1
- package/build-module/components/save-hub/index.js +68 -0
- package/build-module/components/save-hub/index.js.map +1 -0
- package/build-module/components/save-panel/index.js +8 -1
- package/build-module/components/save-panel/index.js.map +1 -1
- package/build-module/components/sidebar/index.js +24 -19
- package/build-module/components/sidebar/index.js.map +1 -1
- package/build-module/components/sidebar-button/index.js +18 -0
- package/build-module/components/sidebar-button/index.js.map +1 -0
- package/build-module/components/sidebar-edit-mode/global-styles-sidebar.js +8 -2
- package/build-module/components/sidebar-edit-mode/global-styles-sidebar.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen/index.js +12 -12
- package/build-module/components/sidebar-navigation-screen/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-main/index.js +16 -16
- package/build-module/components/sidebar-navigation-screen-main/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-item/index.js +24 -30
- package/build-module/components/sidebar-navigation-screen-navigation-item/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menus/index.js +91 -14
- package/build-module/components/sidebar-navigation-screen-navigation-menus/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menus/loader.js +11 -0
- package/build-module/components/sidebar-navigation-screen-navigation-menus/loader.js.map +1 -0
- package/build-module/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js +66 -0
- package/build-module/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js.map +1 -0
- package/build-module/components/sidebar-navigation-screen-template/index.js +67 -30
- package/build-module/components/sidebar-navigation-screen-template/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-templates/index.js +28 -18
- package/build-module/components/sidebar-navigation-screen-templates/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-templates-browse/index.js +13 -10
- package/build-module/components/sidebar-navigation-screen-templates-browse/index.js.map +1 -1
- package/build-module/components/site-hub/index.js +3 -1
- package/build-module/components/site-hub/index.js.map +1 -1
- package/build-module/components/style-book/index.js +152 -25
- package/build-module/components/style-book/index.js.map +1 -1
- package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js +36 -34
- package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
- package/build-module/components/sync-state-with-url/use-sync-canvas-mode-with-url.js +24 -8
- package/build-module/components/sync-state-with-url/use-sync-canvas-mode-with-url.js.map +1 -1
- package/build-module/components/sync-state-with-url/use-sync-path-with-url.js +65 -18
- package/build-module/components/sync-state-with-url/use-sync-path-with-url.js.map +1 -1
- package/build-module/components/template-details/index.js +5 -9
- package/build-module/components/template-details/index.js.map +1 -1
- package/build-module/components/template-part-converter/convert-to-regular.js +9 -13
- package/build-module/components/template-part-converter/convert-to-regular.js.map +1 -1
- package/build-module/components/template-part-converter/convert-to-template-part.js +3 -3
- package/build-module/components/template-part-converter/convert-to-template-part.js.map +1 -1
- package/build-module/components/template-part-converter/index.js +20 -15
- package/build-module/components/template-part-converter/index.js.map +1 -1
- package/build-module/components/use-edited-entity-record/index.js +6 -6
- package/build-module/components/use-edited-entity-record/index.js.map +1 -1
- package/build-module/index.js +16 -23
- package/build-module/index.js.map +1 -1
- package/build-module/store/actions.js +2 -2
- package/build-module/store/actions.js.map +1 -1
- package/build-module/utils/get-is-list-page.js +1 -1
- package/build-module/utils/get-is-list-page.js.map +1 -1
- package/build-module/utils/history.js +9 -3
- package/build-module/utils/history.js.map +1 -1
- package/build-style/style-rtl.css +203 -143
- package/build-style/style.css +203 -143
- package/package.json +31 -31
- package/src/components/add-new-template/add-custom-template-modal.js +14 -10
- package/src/components/add-new-template/new-template-part.js +7 -9
- package/src/components/add-new-template/new-template.js +60 -38
- package/src/components/add-new-template/style.scss +12 -6
- package/src/components/app/index.js +9 -6
- package/src/components/block-editor/editor-canvas.js +2 -1
- package/src/components/block-editor/style.scss +1 -1
- package/src/components/editor/index.js +62 -65
- package/src/components/editor/style.scss +0 -6
- package/src/components/global-styles/border-panel.js +24 -199
- package/src/components/global-styles/context-menu.js +18 -12
- package/src/components/global-styles/dimensions-panel.js +43 -577
- package/src/components/global-styles/duotone-panel.js +82 -0
- package/src/components/global-styles/filter-utils.js +9 -0
- package/src/components/global-styles/hooks.js +12 -36
- package/src/components/global-styles/preview.js +155 -140
- package/src/components/global-styles/screen-block-list.js +6 -11
- package/src/components/global-styles/screen-border.js +10 -3
- package/src/components/global-styles/screen-filters.js +27 -0
- package/src/components/global-styles/screen-layout.js +9 -2
- package/src/components/global-styles/screen-root.js +1 -1
- package/src/components/global-styles/screen-style-variations.js +5 -1
- package/src/components/global-styles/screen-variations.js +0 -1
- package/src/components/global-styles/shadow-panel.js +4 -3
- package/src/components/global-styles/style.scss +10 -0
- package/src/components/global-styles/typography-panel.js +5 -7
- package/src/components/global-styles/ui.js +6 -1
- package/src/components/keyboard-shortcut-help-modal/config.js +10 -0
- package/src/components/keyboard-shortcuts/edit-mode.js +116 -0
- package/src/components/keyboard-shortcuts/global.js +35 -0
- package/src/components/keyboard-shortcuts/index.js +70 -0
- package/src/components/keyboard-shortcuts/register.js +157 -0
- package/src/components/layout/index.js +19 -0
- package/src/components/layout/style.scss +9 -4
- package/src/components/list/added-by.js +152 -155
- package/src/components/list/index.js +3 -1
- package/src/components/list/style.scss +5 -13
- package/src/components/list/table.js +11 -9
- package/src/components/routes/link.js +9 -2
- package/src/components/save-hub/index.js +78 -0
- package/src/components/save-hub/style.scss +15 -0
- package/src/components/save-panel/index.js +8 -1
- package/src/components/sidebar/index.js +33 -16
- package/src/components/sidebar/style.scss +4 -3
- package/src/components/sidebar-button/index.js +21 -0
- package/src/components/sidebar-button/style.scss +24 -0
- package/src/components/sidebar-edit-mode/global-styles-sidebar.js +3 -7
- package/src/components/sidebar-edit-mode/style.scss +16 -0
- package/src/components/sidebar-navigation-item/style.scss +1 -23
- package/src/components/sidebar-navigation-screen/index.js +37 -38
- package/src/components/sidebar-navigation-screen/style.scss +16 -9
- package/src/components/sidebar-navigation-screen-main/index.js +24 -11
- package/src/components/sidebar-navigation-screen-navigation-item/index.js +39 -26
- package/src/components/sidebar-navigation-screen-navigation-menus/index.js +99 -12
- package/src/components/sidebar-navigation-screen-navigation-menus/loader.js +9 -0
- package/src/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js +78 -0
- package/src/components/sidebar-navigation-screen-navigation-menus/style.scss +108 -1
- package/src/components/sidebar-navigation-screen-template/index.js +89 -30
- package/src/components/sidebar-navigation-screen-template/style.scss +25 -0
- package/src/components/sidebar-navigation-screen-templates/index.js +29 -14
- package/src/components/sidebar-navigation-screen-templates/style.scss +0 -5
- package/src/components/sidebar-navigation-screen-templates-browse/index.js +12 -6
- package/src/components/site-hub/index.js +5 -1
- package/src/components/site-hub/style.scss +5 -1
- package/src/components/style-book/index.js +234 -55
- package/src/components/style-book/style.scss +1 -45
- package/src/components/sync-state-with-url/use-init-edited-entity-from-url.js +28 -23
- package/src/components/sync-state-with-url/use-sync-canvas-mode-with-url.js +38 -8
- package/src/components/sync-state-with-url/use-sync-path-with-url.js +77 -17
- package/src/components/template-details/index.js +4 -8
- package/src/components/template-part-converter/convert-to-regular.js +10 -17
- package/src/components/template-part-converter/convert-to-template-part.js +9 -16
- package/src/components/template-part-converter/index.js +28 -12
- package/src/components/use-edited-entity-record/index.js +26 -18
- package/src/index.js +11 -22
- package/src/store/actions.js +2 -2
- package/src/store/test/actions.js +0 -2
- package/src/style.scss +3 -1
- package/src/utils/get-is-list-page.js +1 -1
- package/src/utils/history.js +13 -9
- package/build/components/navigation-inspector/index.js +0 -161
- package/build/components/navigation-inspector/index.js.map +0 -1
- package/build/components/navigation-inspector/navigation-menu.js +0 -62
- package/build/components/navigation-inspector/navigation-menu.js.map +0 -1
- package/build-module/components/navigation-inspector/index.js +0 -146
- package/build-module/components/navigation-inspector/index.js.map +0 -1
- package/build-module/components/navigation-inspector/navigation-menu.js +0 -52
- package/build-module/components/navigation-inspector/navigation-menu.js.map +0 -1
- package/src/components/navigation-inspector/index.js +0 -191
- package/src/components/navigation-inspector/navigation-menu.js +0 -66
- package/src/components/navigation-inspector/style.scss +0 -46
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createElement } from "@wordpress/element";
|
|
2
|
+
// @ts-check
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* External dependencies
|
|
@@ -8,42 +9,116 @@ import classnames from 'classnames';
|
|
|
8
9
|
* WordPress dependencies
|
|
9
10
|
*/
|
|
10
11
|
|
|
11
|
-
import { __experimentalHStack as HStack
|
|
12
|
+
import { Icon, __experimentalHStack as HStack } from '@wordpress/components';
|
|
12
13
|
import { store as coreStore } from '@wordpress/core-data';
|
|
13
14
|
import { useSelect } from '@wordpress/data';
|
|
14
15
|
import { useState } from '@wordpress/element';
|
|
15
16
|
import { commentAuthorAvatar as authorIcon, layout as themeIcon, plugins as pluginIcon, globe as globeIcon } from '@wordpress/icons';
|
|
16
|
-
import {
|
|
17
|
-
|
|
17
|
+
import { _x } from '@wordpress/i18n';
|
|
18
|
+
/** @typedef {'wp_template'|'wp_template_part'} TemplateType */
|
|
18
19
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
/** @type {TemplateType} */
|
|
21
|
+
|
|
22
|
+
const TEMPLATE_POST_TYPE_NAMES = ['wp_template', 'wp_template_part'];
|
|
23
|
+
/**
|
|
24
|
+
* @typedef {'theme'|'plugin'|'site'|'user'} AddedByType
|
|
25
|
+
*
|
|
26
|
+
* @typedef AddedByData
|
|
27
|
+
* @type {Object}
|
|
28
|
+
* @property {AddedByType} type The type of the data.
|
|
29
|
+
* @property {JSX.Element} icon The icon to display.
|
|
30
|
+
* @property {string} [imageUrl] The optional image URL to display.
|
|
31
|
+
* @property {string} [text] The text to display.
|
|
32
|
+
* @property {boolean} isCustomized Whether the template has been customized.
|
|
33
|
+
*
|
|
34
|
+
* @param {TemplateType} postType The template post type.
|
|
35
|
+
* @param {number} postId The template post id.
|
|
36
|
+
* @return {AddedByData} The added by object or null.
|
|
37
|
+
*/
|
|
24
38
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
39
|
+
export function useAddedBy(postType, postId) {
|
|
40
|
+
return useSelect(select => {
|
|
41
|
+
var _user$avatar_urls;
|
|
28
42
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
43
|
+
const {
|
|
44
|
+
getTheme,
|
|
45
|
+
getPlugin,
|
|
46
|
+
getEntityRecord,
|
|
47
|
+
getMedia,
|
|
48
|
+
getUser,
|
|
49
|
+
getEditedEntityRecord
|
|
50
|
+
} = select(coreStore);
|
|
51
|
+
const template = getEditedEntityRecord('postType', postType, postId);
|
|
52
|
+
|
|
53
|
+
if (TEMPLATE_POST_TYPE_NAMES.includes(template.type)) {
|
|
54
|
+
// Added by theme.
|
|
55
|
+
// Template originally provided by a theme, but customized by a user.
|
|
56
|
+
// Templates originally didn't have the 'origin' field so identify
|
|
57
|
+
// older customized templates by checking for no origin and a 'theme'
|
|
58
|
+
// or 'custom' source.
|
|
59
|
+
if (template.has_theme_file && (template.origin === 'theme' || !template.origin && ['theme', 'custom'].includes(template.source))) {
|
|
60
|
+
var _getTheme, _getTheme$name;
|
|
61
|
+
|
|
62
|
+
return {
|
|
63
|
+
type: 'theme',
|
|
64
|
+
icon: themeIcon,
|
|
65
|
+
text: ((_getTheme = getTheme(template.theme)) === null || _getTheme === void 0 ? void 0 : (_getTheme$name = _getTheme.name) === null || _getTheme$name === void 0 ? void 0 : _getTheme$name.rendered) || template.theme,
|
|
66
|
+
isCustomized: template.source === 'custom'
|
|
67
|
+
};
|
|
68
|
+
} // Added by plugin.
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
if (template.has_theme_file && template.origin === 'plugin') {
|
|
72
|
+
var _getPlugin;
|
|
73
|
+
|
|
74
|
+
return {
|
|
75
|
+
type: 'plugin',
|
|
76
|
+
icon: pluginIcon,
|
|
77
|
+
text: ((_getPlugin = getPlugin(template.theme)) === null || _getPlugin === void 0 ? void 0 : _getPlugin.name) || template.theme,
|
|
78
|
+
isCustomized: template.source === 'custom'
|
|
79
|
+
};
|
|
80
|
+
} // Added by site.
|
|
81
|
+
// Template was created from scratch, but has no author. Author support
|
|
82
|
+
// was only added to templates in WordPress 5.9. Fallback to showing the
|
|
83
|
+
// site logo and title.
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
if (!template.has_theme_file && template.source === 'custom' && !template.author) {
|
|
87
|
+
var _getMedia;
|
|
88
|
+
|
|
89
|
+
const siteData = getEntityRecord('root', '__unstableBase');
|
|
90
|
+
return {
|
|
91
|
+
type: 'site',
|
|
92
|
+
icon: globeIcon,
|
|
93
|
+
imageUrl: siteData !== null && siteData !== void 0 && siteData.site_logo ? (_getMedia = getMedia(siteData.site_logo)) === null || _getMedia === void 0 ? void 0 : _getMedia.source_url : undefined,
|
|
94
|
+
text: siteData === null || siteData === void 0 ? void 0 : siteData.name,
|
|
95
|
+
isCustomized: false
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
} // Added by user.
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
const user = getUser(template.author);
|
|
102
|
+
return {
|
|
103
|
+
type: 'user',
|
|
104
|
+
icon: authorIcon,
|
|
105
|
+
imageUrl: user === null || user === void 0 ? void 0 : (_user$avatar_urls = user.avatar_urls) === null || _user$avatar_urls === void 0 ? void 0 : _user$avatar_urls[48],
|
|
106
|
+
text: user === null || user === void 0 ? void 0 : user.nickname,
|
|
107
|
+
isCustomized: false
|
|
108
|
+
};
|
|
109
|
+
}, [postType, postId]);
|
|
32
110
|
}
|
|
111
|
+
/**
|
|
112
|
+
* @param {Object} props
|
|
113
|
+
* @param {string} props.imageUrl
|
|
114
|
+
*/
|
|
33
115
|
|
|
34
|
-
function
|
|
116
|
+
function AvatarImage(_ref) {
|
|
35
117
|
let {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
imageUrl,
|
|
39
|
-
isCustomized
|
|
40
|
-
} = _ref2;
|
|
118
|
+
imageUrl
|
|
119
|
+
} = _ref;
|
|
41
120
|
const [isImageLoaded, setIsImageLoaded] = useState(false);
|
|
42
|
-
return createElement(
|
|
43
|
-
alignment: "left"
|
|
44
|
-
}, createElement(CustomizedTooltip, {
|
|
45
|
-
isCustomized: isCustomized
|
|
46
|
-
}, imageUrl ? createElement("div", {
|
|
121
|
+
return createElement("div", {
|
|
47
122
|
className: classnames('edit-site-list-added-by__avatar', {
|
|
48
123
|
'is-loaded': isImageLoaded
|
|
49
124
|
})
|
|
@@ -51,123 +126,36 @@ function BaseAddedBy(_ref2) {
|
|
|
51
126
|
onLoad: () => setIsImageLoaded(true),
|
|
52
127
|
alt: "",
|
|
53
128
|
src: imageUrl
|
|
54
|
-
}))
|
|
55
|
-
className: classnames('edit-site-list-added-by__icon', {
|
|
56
|
-
'is-customized': isCustomized
|
|
57
|
-
})
|
|
58
|
-
}, createElement(Icon, {
|
|
59
|
-
icon: icon
|
|
60
|
-
}))), createElement("span", null, text));
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
function AddedByTheme(_ref3) {
|
|
64
|
-
var _theme$name;
|
|
65
|
-
|
|
66
|
-
let {
|
|
67
|
-
slug,
|
|
68
|
-
isCustomized
|
|
69
|
-
} = _ref3;
|
|
70
|
-
const theme = useSelect(select => select(coreStore).getTheme(slug), [slug]);
|
|
71
|
-
return createElement(BaseAddedBy, {
|
|
72
|
-
icon: themeIcon,
|
|
73
|
-
text: (theme === null || theme === void 0 ? void 0 : (_theme$name = theme.name) === null || _theme$name === void 0 ? void 0 : _theme$name.rendered) || slug,
|
|
74
|
-
isCustomized: isCustomized
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
function AddedByPlugin(_ref4) {
|
|
79
|
-
let {
|
|
80
|
-
slug,
|
|
81
|
-
isCustomized
|
|
82
|
-
} = _ref4;
|
|
83
|
-
const plugin = useSelect(select => select(coreStore).getPlugin(slug), [slug]);
|
|
84
|
-
return createElement(BaseAddedBy, {
|
|
85
|
-
icon: pluginIcon,
|
|
86
|
-
text: (plugin === null || plugin === void 0 ? void 0 : plugin.name) || slug,
|
|
87
|
-
isCustomized: isCustomized
|
|
88
|
-
});
|
|
129
|
+
}));
|
|
89
130
|
}
|
|
131
|
+
/**
|
|
132
|
+
* @param {Object} props
|
|
133
|
+
* @param {TemplateType} props.postType The template post type.
|
|
134
|
+
* @param {number} props.postId The template post id.
|
|
135
|
+
*/
|
|
90
136
|
|
|
91
|
-
function AddedByAuthor(_ref5) {
|
|
92
|
-
var _user$avatar_urls;
|
|
93
137
|
|
|
138
|
+
export default function AddedBy(_ref2) {
|
|
94
139
|
let {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
return createElement(BaseAddedBy, {
|
|
99
|
-
icon: authorIcon,
|
|
100
|
-
imageUrl: user === null || user === void 0 ? void 0 : (_user$avatar_urls = user.avatar_urls) === null || _user$avatar_urls === void 0 ? void 0 : _user$avatar_urls[48],
|
|
101
|
-
text: user === null || user === void 0 ? void 0 : user.nickname
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
function AddedBySite() {
|
|
140
|
+
postType,
|
|
141
|
+
postId
|
|
142
|
+
} = _ref2;
|
|
106
143
|
const {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
icon: globeIcon,
|
|
124
|
-
imageUrl: logoURL,
|
|
125
|
-
text: name
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
export default function AddedBy(_ref6) {
|
|
130
|
-
let {
|
|
131
|
-
templateType,
|
|
132
|
-
template
|
|
133
|
-
} = _ref6;
|
|
134
|
-
|
|
135
|
-
if (!template) {
|
|
136
|
-
return;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
if (TEMPLATE_POST_TYPE_NAMES.includes(templateType)) {
|
|
140
|
-
// Template originally provided by a theme, but customized by a user.
|
|
141
|
-
// Templates originally didn't have the 'origin' field so identify
|
|
142
|
-
// older customized templates by checking for no origin and a 'theme'
|
|
143
|
-
// or 'custom' source.
|
|
144
|
-
if (template.has_theme_file && (template.origin === 'theme' || !template.origin && ['theme', 'custom'].includes(template.source))) {
|
|
145
|
-
return createElement(AddedByTheme, {
|
|
146
|
-
slug: template.theme,
|
|
147
|
-
isCustomized: template.source === 'custom'
|
|
148
|
-
});
|
|
149
|
-
} // Template originally provided by a plugin, but customized by a user.
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
if (template.has_theme_file && template.origin === 'plugin') {
|
|
153
|
-
return createElement(AddedByPlugin, {
|
|
154
|
-
slug: template.theme,
|
|
155
|
-
isCustomized: template.source === 'custom'
|
|
156
|
-
});
|
|
157
|
-
} // Template was created from scratch, but has no author. Author support
|
|
158
|
-
// was only added to templates in WordPress 5.9. Fallback to showing the
|
|
159
|
-
// site logo and title.
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
if (!template.has_theme_file && template.source === 'custom' && !template.author) {
|
|
163
|
-
return createElement(AddedBySite, null);
|
|
164
|
-
}
|
|
165
|
-
} // Simply show the author for templates created from scratch that have an
|
|
166
|
-
// author or for any other post type.
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
return createElement(AddedByAuthor, {
|
|
170
|
-
id: template.author
|
|
171
|
-
});
|
|
144
|
+
text,
|
|
145
|
+
icon,
|
|
146
|
+
imageUrl,
|
|
147
|
+
isCustomized
|
|
148
|
+
} = useAddedBy(postType, postId);
|
|
149
|
+
return createElement(HStack, {
|
|
150
|
+
alignment: "left"
|
|
151
|
+
}, imageUrl ? createElement(AvatarImage, {
|
|
152
|
+
imageUrl: imageUrl
|
|
153
|
+
}) : createElement("div", {
|
|
154
|
+
className: "edit-site-list-added-by__icon"
|
|
155
|
+
}, createElement(Icon, {
|
|
156
|
+
icon: icon
|
|
157
|
+
})), createElement("span", null, text, isCustomized && createElement("span", {
|
|
158
|
+
className: "edit-site-list-added-by__customized-info"
|
|
159
|
+
}, postType === 'wp_template' ? _x('Customized', 'template') : _x('Customized', 'template part'))));
|
|
172
160
|
}
|
|
173
161
|
//# sourceMappingURL=added-by.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/list/added-by.js"],"names":["classnames","
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/list/added-by.js"],"names":["classnames","Icon","__experimentalHStack","HStack","store","coreStore","useSelect","useState","commentAuthorAvatar","authorIcon","layout","themeIcon","plugins","pluginIcon","globe","globeIcon","_x","TEMPLATE_POST_TYPE_NAMES","useAddedBy","postType","postId","select","getTheme","getPlugin","getEntityRecord","getMedia","getUser","getEditedEntityRecord","template","includes","type","has_theme_file","origin","source","icon","text","theme","name","rendered","isCustomized","author","siteData","imageUrl","site_logo","source_url","undefined","user","avatar_urls","nickname","AvatarImage","isImageLoaded","setIsImageLoaded","AddedBy"],"mappings":";AAAA;;AACA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,IAAT,EAAeC,oBAAoB,IAAIC,MAAvC,QAAqD,uBAArD;AACA,SAASC,KAAK,IAAIC,SAAlB,QAAmC,sBAAnC;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SAASC,QAAT,QAAyB,oBAAzB;AACA,SACCC,mBAAmB,IAAIC,UADxB,EAECC,MAAM,IAAIC,SAFX,EAGCC,OAAO,IAAIC,UAHZ,EAICC,KAAK,IAAIC,SAJV,QAKO,kBALP;AAMA,SAASC,EAAT,QAAmB,iBAAnB;AAEA;;AAEA;;AACA,MAAMC,wBAAwB,GAAG,CAAE,aAAF,EAAiB,kBAAjB,CAAjC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;A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AEQ,aAAF,EAAiBC,gBAAjB,IAAsC5C,QAAQ,CAAE,KAAF,CAApD;AAEA,SACC;AACC,IAAA,SAAS,EAAGP,UAAU,CAAE,iCAAF,EAAqC;AAC1D,mBAAakD;AAD6C,KAArC;AADvB,KAKC;AACC,IAAA,MAAM,EAAG,MAAMC,gBAAgB,CAAE,IAAF,CADhC;AAEC,IAAA,GAAG,EAAC,EAFL;AAGC,IAAA,GAAG,EAAGT;AAHP,IALD,CADD;AAaA;AAED;AACA;AACA;AACA;AACA;;;AACA,eAAe,SAASU,OAAT,QAAyC;AAAA,MAAvB;AAAEjC,IAAAA,QAAF;AAAYC,IAAAA;AAAZ,GAAuB;AACvD,QAAM;AAAEe,IAAAA,IAAF;AAAQD,IAAAA,IAAR;AAAcQ,IAAAA,QAAd;AAAwBH,IAAAA;AAAxB,MAAyCrB,UAAU,CACxDC,QADwD,EAExDC,MAFwD,CAAzD;AAKA,SACC,cAAC,MAAD;AAAQ,IAAA,SAAS,EAAC;AAAlB,KACGsB,QAAQ,GACT,cAAC,WAAD;AAAa,IAAA,QAAQ,EAAGA;AAAxB,IADS,GAGT;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,cAAC,IAAD;AAAM,IAAA,IAAI,EAAGR;AAAb,IADD,CAJF,EAQC,4BACGC,IADH,EAEGI,YAAY,IACb;AAAM,IAAA,SAAS,EAAC;AAAhB,KACGpB,QAAQ,KAAK,aAAb,GACCH,EAAE,CAAE,YAAF,EAAgB,UAAhB,CADH,GAECA,EAAE,CAAE,YAAF,EAAgB,eAAhB,CAHN,CAHF,CARD,CADD;AAqBA","sourcesContent":["// @ts-check\n/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { Icon, __experimentalHStack as HStack } from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useSelect } from '@wordpress/data';\nimport { useState } from '@wordpress/element';\nimport {\n\tcommentAuthorAvatar as authorIcon,\n\tlayout as themeIcon,\n\tplugins as pluginIcon,\n\tglobe as globeIcon,\n} from '@wordpress/icons';\nimport { _x } from '@wordpress/i18n';\n\n/** @typedef {'wp_template'|'wp_template_part'} TemplateType */\n\n/** @type {TemplateType} */\nconst TEMPLATE_POST_TYPE_NAMES = [ 'wp_template', 'wp_template_part' ];\n\n/**\n * @typedef {'theme'|'plugin'|'site'|'user'} AddedByType\n *\n * @typedef AddedByData\n * @type {Object}\n * @property {AddedByType} type The type of the data.\n * @property {JSX.Element} icon The icon to display.\n * @property {string} [imageUrl] The optional image URL to display.\n * @property {string} [text] The text to display.\n * @property {boolean} isCustomized Whether the template has been customized.\n *\n * @param {TemplateType} postType The template post type.\n * @param {number} postId The template post id.\n * @return {AddedByData} The added by object or null.\n */\nexport function useAddedBy( postType, postId ) {\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetTheme,\n\t\t\t\tgetPlugin,\n\t\t\t\tgetEntityRecord,\n\t\t\t\tgetMedia,\n\t\t\t\tgetUser,\n\t\t\t\tgetEditedEntityRecord,\n\t\t\t} = select( coreStore );\n\t\t\tconst template = getEditedEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\tpostType,\n\t\t\t\tpostId\n\t\t\t);\n\n\t\t\tif ( TEMPLATE_POST_TYPE_NAMES.includes( template.type ) ) {\n\t\t\t\t// Added by theme.\n\t\t\t\t// Template originally provided by a theme, but customized by a user.\n\t\t\t\t// Templates originally didn't have the 'origin' field so identify\n\t\t\t\t// older customized templates by checking for no origin and a 'theme'\n\t\t\t\t// or 'custom' source.\n\t\t\t\tif (\n\t\t\t\t\ttemplate.has_theme_file &&\n\t\t\t\t\t( template.origin === 'theme' ||\n\t\t\t\t\t\t( ! template.origin &&\n\t\t\t\t\t\t\t[ 'theme', 'custom' ].includes(\n\t\t\t\t\t\t\t\ttemplate.source\n\t\t\t\t\t\t\t) ) )\n\t\t\t\t) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\ttype: 'theme',\n\t\t\t\t\t\ticon: themeIcon,\n\t\t\t\t\t\ttext:\n\t\t\t\t\t\t\tgetTheme( template.theme )?.name?.rendered ||\n\t\t\t\t\t\t\ttemplate.theme,\n\t\t\t\t\t\tisCustomized: template.source === 'custom',\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\t// Added by plugin.\n\t\t\t\tif ( template.has_theme_file && template.origin === 'plugin' ) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\ttype: 'plugin',\n\t\t\t\t\t\ticon: pluginIcon,\n\t\t\t\t\t\ttext:\n\t\t\t\t\t\t\tgetPlugin( template.theme )?.name || template.theme,\n\t\t\t\t\t\tisCustomized: template.source === 'custom',\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\t// Added by site.\n\t\t\t\t// Template was created from scratch, but has no author. Author support\n\t\t\t\t// was only added to templates in WordPress 5.9. Fallback to showing the\n\t\t\t\t// site logo and title.\n\t\t\t\tif (\n\t\t\t\t\t! template.has_theme_file &&\n\t\t\t\t\ttemplate.source === 'custom' &&\n\t\t\t\t\t! template.author\n\t\t\t\t) {\n\t\t\t\t\tconst siteData = getEntityRecord(\n\t\t\t\t\t\t'root',\n\t\t\t\t\t\t'__unstableBase'\n\t\t\t\t\t);\n\t\t\t\t\treturn {\n\t\t\t\t\t\ttype: 'site',\n\t\t\t\t\t\ticon: globeIcon,\n\t\t\t\t\t\timageUrl: siteData?.site_logo\n\t\t\t\t\t\t\t? getMedia( siteData.site_logo )?.source_url\n\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t\ttext: siteData?.name,\n\t\t\t\t\t\tisCustomized: false,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Added by user.\n\t\t\tconst user = getUser( template.author );\n\t\t\treturn {\n\t\t\t\ttype: 'user',\n\t\t\t\ticon: authorIcon,\n\t\t\t\timageUrl: user?.avatar_urls?.[ 48 ],\n\t\t\t\ttext: user?.nickname,\n\t\t\t\tisCustomized: false,\n\t\t\t};\n\t\t},\n\t\t[ postType, postId ]\n\t);\n}\n\n/**\n * @param {Object} props\n * @param {string} props.imageUrl\n */\nfunction AvatarImage( { imageUrl } ) {\n\tconst [ isImageLoaded, setIsImageLoaded ] = useState( false );\n\n\treturn (\n\t\t<div\n\t\t\tclassName={ classnames( 'edit-site-list-added-by__avatar', {\n\t\t\t\t'is-loaded': isImageLoaded,\n\t\t\t} ) }\n\t\t>\n\t\t\t<img\n\t\t\t\tonLoad={ () => setIsImageLoaded( true ) }\n\t\t\t\talt=\"\"\n\t\t\t\tsrc={ imageUrl }\n\t\t\t/>\n\t\t</div>\n\t);\n}\n\n/**\n * @param {Object} props\n * @param {TemplateType} props.postType The template post type.\n * @param {number} props.postId The template post id.\n */\nexport default function AddedBy( { postType, postId } ) {\n\tconst { text, icon, imageUrl, isCustomized } = useAddedBy(\n\t\tpostType,\n\t\tpostId\n\t);\n\n\treturn (\n\t\t<HStack alignment=\"left\">\n\t\t\t{ imageUrl ? (\n\t\t\t\t<AvatarImage imageUrl={ imageUrl } />\n\t\t\t) : (\n\t\t\t\t<div className=\"edit-site-list-added-by__icon\">\n\t\t\t\t\t<Icon icon={ icon } />\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t<span>\n\t\t\t\t{ text }\n\t\t\t\t{ isCustomized && (\n\t\t\t\t\t<span className=\"edit-site-list-added-by__customized-info\">\n\t\t\t\t\t\t{ postType === 'wp_template'\n\t\t\t\t\t\t\t? _x( 'Customized', 'template' )\n\t\t\t\t\t\t\t: _x( 'Customized', 'template part' ) }\n\t\t\t\t\t</span>\n\t\t\t\t) }\n\t\t\t</span>\n\t\t</HStack>\n\t);\n}\n"]}
|
|
@@ -23,9 +23,10 @@ export default function List() {
|
|
|
23
23
|
|
|
24
24
|
const {
|
|
25
25
|
params: {
|
|
26
|
-
|
|
26
|
+
path
|
|
27
27
|
}
|
|
28
28
|
} = useLocation();
|
|
29
|
+
const templateType = path === '/wp_template/all' ? 'wp_template' : 'wp_template_part';
|
|
29
30
|
useRegisterShortcuts();
|
|
30
31
|
const {
|
|
31
32
|
previousShortcut,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/list/index.js"],"names":["store","coreStore","useSelect","InterfaceSkeleton","__","sprintf","keyboardShortcutsStore","EditorSnackbars","useRegisterShortcuts","Header","Table","useLocation","useTitle","List","params","
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/list/index.js"],"names":["store","coreStore","useSelect","InterfaceSkeleton","__","sprintf","keyboardShortcutsStore","EditorSnackbars","useRegisterShortcuts","Header","Table","useLocation","useTitle","List","params","path","templateType","previousShortcut","nextShortcut","select","getAllShortcutKeyCombinations","postType","getPostType","labels","name","itemsListLabel","items_list","detailedRegionLabels","header","body","undefined","previous","next"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,KAAK,IAAIC,SAAlB,QAAmC,sBAAnC;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SAASC,iBAAT,QAAkC,sBAAlC;AACA,SAASC,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SAASL,KAAK,IAAIM,sBAAlB,QAAgD,+BAAhD;AACA,SAASC,eAAT,QAAgC,mBAAhC;AAEA;AACA;AACA;;AACA,OAAOC,oBAAP,MAAiC,0BAAjC;AACA,OAAOC,MAAP,MAAmB,UAAnB;AACA,OAAOC,KAAP,MAAkB,SAAlB;AACA,SAASC,WAAT,QAA4B,WAA5B;AACA,OAAOC,QAAP,MAAqB,qBAArB;AAEA,eAAe,SAASC,IAAT,GAAgB;AAAA;;AAC9B,QAAM;AACLC,IAAAA,MAAM,EAAE;AAAEC,MAAAA;AAAF;AADH,MAEFJ,WAAW,EAFf;AAGA,QAAMK,YAAY,GACjBD,IAAI,KAAK,kBAAT,GAA8B,aAA9B,GAA8C,kBAD/C;AAGAP,EAAAA,oBAAoB;AAEpB,QAAM;AAAES,IAAAA,gBAAF;AAAoBC,IAAAA;AAApB,MAAqChB,SAAS,CAAIiB,M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d;AAFK;AANb,IADD;AAaA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useSelect } from '@wordpress/data';\nimport { InterfaceSkeleton } from '@wordpress/interface';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\nimport { EditorSnackbars } from '@wordpress/editor';\n\n/**\n * Internal dependencies\n */\nimport useRegisterShortcuts from './use-register-shortcuts';\nimport Header from './header';\nimport Table from './table';\nimport { useLocation } from '../routes';\nimport useTitle from '../routes/use-title';\n\nexport default function List() {\n\tconst {\n\t\tparams: { path },\n\t} = useLocation();\n\tconst templateType =\n\t\tpath === '/wp_template/all' ? 'wp_template' : 'wp_template_part';\n\n\tuseRegisterShortcuts();\n\n\tconst { previousShortcut, nextShortcut } = useSelect( ( select ) => {\n\t\treturn {\n\t\t\tpreviousShortcut: select(\n\t\t\t\tkeyboardShortcutsStore\n\t\t\t).getAllShortcutKeyCombinations( 'core/edit-site/previous-region' ),\n\t\t\tnextShortcut: select(\n\t\t\t\tkeyboardShortcutsStore\n\t\t\t).getAllShortcutKeyCombinations( 'core/edit-site/next-region' ),\n\t\t};\n\t}, [] );\n\n\tconst postType = useSelect(\n\t\t( select ) => select( coreStore ).getPostType( templateType ),\n\t\t[ templateType ]\n\t);\n\n\tuseTitle( postType?.labels?.name );\n\n\t// `postType` could load in asynchronously. Only provide the detailed region labels if\n\t// the postType has loaded, otherwise `InterfaceSkeleton` will fallback to the defaults.\n\tconst itemsListLabel = postType?.labels?.items_list;\n\tconst detailedRegionLabels = postType\n\t\t? {\n\t\t\t\theader: sprintf(\n\t\t\t\t\t// translators: %s - the name of the page, 'Header' as in the header area of that page.\n\t\t\t\t\t__( '%s - Header' ),\n\t\t\t\t\titemsListLabel\n\t\t\t\t),\n\t\t\t\tbody: sprintf(\n\t\t\t\t\t// translators: %s - the name of the page, 'Content' as in the content area of that page.\n\t\t\t\t\t__( '%s - Content' ),\n\t\t\t\t\titemsListLabel\n\t\t\t\t),\n\t\t }\n\t\t: undefined;\n\n\treturn (\n\t\t<InterfaceSkeleton\n\t\t\tclassName=\"edit-site-list\"\n\t\t\tlabels={ detailedRegionLabels }\n\t\t\theader={ <Header templateType={ templateType } /> }\n\t\t\tnotices={ <EditorSnackbars /> }\n\t\t\tcontent={ <Table templateType={ templateType } /> }\n\t\t\tshortcuts={ {\n\t\t\t\tprevious: previousShortcut,\n\t\t\t\tnext: nextShortcut,\n\t\t\t} }\n\t\t/>\n\t);\n}\n"]}
|
|
@@ -38,6 +38,8 @@ export default function Table(_ref) {
|
|
|
38
38
|
__('No %s found.'), postType === null || postType === void 0 ? void 0 : (_postType$labels = postType.labels) === null || _postType$labels === void 0 ? void 0 : (_postType$labels$name = _postType$labels.name) === null || _postType$labels$name === void 0 ? void 0 : _postType$labels$name.toLowerCase()));
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
+
const sortedTemplates = [...templates];
|
|
42
|
+
sortedTemplates.sort((a, b) => a.slug.localeCompare(b.slug));
|
|
41
43
|
return (// These explicit aria roles are needed for Safari.
|
|
42
44
|
// See https://developer.mozilla.org/en-US/docs/Web/CSS/display#tables
|
|
43
45
|
createElement("table", {
|
|
@@ -55,7 +57,7 @@ export default function Table(_ref) {
|
|
|
55
57
|
}, __('Added by')), createElement("th", {
|
|
56
58
|
className: "edit-site-list-table-column",
|
|
57
59
|
role: "columnheader"
|
|
58
|
-
}, createElement(VisuallyHidden, null, __('Actions'))))), createElement("tbody", null,
|
|
60
|
+
}, createElement(VisuallyHidden, null, __('Actions'))))), createElement("tbody", null, sortedTemplates.map(template => {
|
|
59
61
|
var _template$title;
|
|
60
62
|
|
|
61
63
|
return createElement("tr", {
|
|
@@ -69,17 +71,17 @@ export default function Table(_ref) {
|
|
|
69
71
|
level: 4
|
|
70
72
|
}, createElement(Link, {
|
|
71
73
|
params: {
|
|
72
|
-
path: template.type === 'wp_template' ? '/templates/single' : '/template-parts/single',
|
|
73
74
|
postId: template.id,
|
|
74
|
-
postType: template.type
|
|
75
|
+
postType: template.type,
|
|
76
|
+
canvas: 'edit'
|
|
75
77
|
}
|
|
76
78
|
}, decodeEntities(((_template$title = template.title) === null || _template$title === void 0 ? void 0 : _template$title.rendered) || template.slug))), decodeEntities(template.description)), createElement("td", {
|
|
77
79
|
className: "edit-site-list-table-column",
|
|
78
80
|
role: "cell"
|
|
79
|
-
}, createElement(AddedBy, {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
})), createElement("td", {
|
|
81
|
+
}, template ? createElement(AddedBy, {
|
|
82
|
+
postType: template.type,
|
|
83
|
+
postId: template.id
|
|
84
|
+
}) : null), createElement("td", {
|
|
83
85
|
className: "edit-site-list-table-column",
|
|
84
86
|
role: "cell"
|
|
85
87
|
}, createElement(Actions, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/list/table.js"],"names":["useSelect","store","coreStore","useEntityRecords","__","sprintf","VisuallyHidden","__experimentalHeading","Heading","decodeEntities","Link","Actions","AddedBy","Table","templateType","records","templates","isResolving","isLoading","per_page","postType","select","getPostType","length","labels","name","toLowerCase","map","template","id","
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/list/table.js"],"names":["useSelect","store","coreStore","useEntityRecords","__","sprintf","VisuallyHidden","__experimentalHeading","Heading","decodeEntities","Link","Actions","AddedBy","Table","templateType","records","templates","isResolving","isLoading","per_page","postType","select","getPostType","length","labels","name","toLowerCase","sortedTemplates","sort","a","b","slug","localeCompare","map","template","id","postId","type","canvas","title","rendered","description"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,iBAA1B;AACA,SAASC,KAAK,IAAIC,SAAlB,EAA6BC,gBAA7B,QAAqD,sBAArD;AACA,SAASC,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SACCC,cADD,EAECC,qBAAqB,IAAIC,OAF1B,QAGO,uBAHP;AAIA,SAASC,cAAT,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AAC,OAAD;AAAS,QAAA,QAAQ,EAAGD;AAApB,QADD,CA/BD,CADsB;AAAA,KAArB,CADH,CAxBD;AAHD;AAoEA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore, useEntityRecords } from '@wordpress/core-data';\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\tVisuallyHidden,\n\t__experimentalHeading as Heading,\n} from '@wordpress/components';\nimport { decodeEntities } from '@wordpress/html-entities';\n\n/**\n * Internal dependencies\n */\nimport Link from '../routes/link';\nimport Actions from './actions';\nimport AddedBy from './added-by';\n\nexport default function Table( { templateType } ) {\n\tconst { records: templates, isResolving: isLoading } = useEntityRecords(\n\t\t'postType',\n\t\ttemplateType,\n\t\t{\n\t\t\tper_page: -1,\n\t\t}\n\t);\n\tconst postType = useSelect(\n\t\t( select ) => select( coreStore ).getPostType( templateType ),\n\t\t[ templateType ]\n\t);\n\n\tif ( ! templates || isLoading ) {\n\t\treturn null;\n\t}\n\n\tif ( ! templates.length ) {\n\t\treturn (\n\t\t\t<div>\n\t\t\t\t{ sprintf(\n\t\t\t\t\t// translators: The template type name, should be either \"templates\" or \"template parts\".\n\t\t\t\t\t__( 'No %s found.' ),\n\t\t\t\t\tpostType?.labels?.name?.toLowerCase()\n\t\t\t\t) }\n\t\t\t</div>\n\t\t);\n\t}\n\n\tconst sortedTemplates = [ ...templates ];\n\tsortedTemplates.sort( ( a, b ) => a.slug.localeCompare( b.slug ) );\n\n\treturn (\n\t\t// These explicit aria roles are needed for Safari.\n\t\t// See https://developer.mozilla.org/en-US/docs/Web/CSS/display#tables\n\t\t<table className=\"edit-site-list-table\" role=\"table\">\n\t\t\t<thead>\n\t\t\t\t<tr className=\"edit-site-list-table-head\" role=\"row\">\n\t\t\t\t\t<th\n\t\t\t\t\t\tclassName=\"edit-site-list-table-column\"\n\t\t\t\t\t\trole=\"columnheader\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Template' ) }\n\t\t\t\t\t</th>\n\t\t\t\t\t<th\n\t\t\t\t\t\tclassName=\"edit-site-list-table-column\"\n\t\t\t\t\t\trole=\"columnheader\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Added by' ) }\n\t\t\t\t\t</th>\n\t\t\t\t\t<th\n\t\t\t\t\t\tclassName=\"edit-site-list-table-column\"\n\t\t\t\t\t\trole=\"columnheader\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<VisuallyHidden>{ __( 'Actions' ) }</VisuallyHidden>\n\t\t\t\t\t</th>\n\t\t\t\t</tr>\n\t\t\t</thead>\n\n\t\t\t<tbody>\n\t\t\t\t{ sortedTemplates.map( ( template ) => (\n\t\t\t\t\t<tr\n\t\t\t\t\t\tkey={ template.id }\n\t\t\t\t\t\tclassName=\"edit-site-list-table-row\"\n\t\t\t\t\t\trole=\"row\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<td className=\"edit-site-list-table-column\" role=\"cell\">\n\t\t\t\t\t\t\t<Heading level={ 4 }>\n\t\t\t\t\t\t\t\t<Link\n\t\t\t\t\t\t\t\t\tparams={ {\n\t\t\t\t\t\t\t\t\t\tpostId: template.id,\n\t\t\t\t\t\t\t\t\t\tpostType: template.type,\n\t\t\t\t\t\t\t\t\t\tcanvas: 'edit',\n\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ decodeEntities(\n\t\t\t\t\t\t\t\t\t\ttemplate.title?.rendered ||\n\t\t\t\t\t\t\t\t\t\t\ttemplate.slug\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t</Link>\n\t\t\t\t\t\t\t</Heading>\n\t\t\t\t\t\t\t{ decodeEntities( template.description ) }\n\t\t\t\t\t\t</td>\n\n\t\t\t\t\t\t<td className=\"edit-site-list-table-column\" role=\"cell\">\n\t\t\t\t\t\t\t{ template ? (\n\t\t\t\t\t\t\t\t<AddedBy\n\t\t\t\t\t\t\t\t\tpostType={ template.type }\n\t\t\t\t\t\t\t\t\tpostId={ template.id }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t) : null }\n\t\t\t\t\t\t</td>\n\t\t\t\t\t\t<td className=\"edit-site-list-table-column\" role=\"cell\">\n\t\t\t\t\t\t\t<Actions template={ template } />\n\t\t\t\t\t\t</td>\n\t\t\t\t\t</tr>\n\t\t\t\t) ) }\n\t\t\t</tbody>\n\t\t</table>\n\t);\n}\n"]}
|
|
@@ -4,7 +4,7 @@ import { createElement } from "@wordpress/element";
|
|
|
4
4
|
/**
|
|
5
5
|
* WordPress dependencies
|
|
6
6
|
*/
|
|
7
|
-
import { addQueryArgs } from '@wordpress/url';
|
|
7
|
+
import { addQueryArgs, getQueryArgs, removeQueryArgs } from '@wordpress/url';
|
|
8
8
|
/**
|
|
9
9
|
* Internal dependencies
|
|
10
10
|
*/
|
|
@@ -26,8 +26,11 @@ export function useLink() {
|
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
+
const currentArgs = getQueryArgs(window.location.href);
|
|
30
|
+
const currentUrlWithoutArgs = removeQueryArgs(window.location.href, ...Object.keys(currentArgs));
|
|
31
|
+
const newUrl = addQueryArgs(currentUrlWithoutArgs, params);
|
|
29
32
|
return {
|
|
30
|
-
href:
|
|
33
|
+
href: newUrl,
|
|
31
34
|
onClick
|
|
32
35
|
};
|
|
33
36
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/routes/link.js"],"names":["addQueryArgs","useHistory","useLink","params","state","shouldReplace","history","onClick","event","preventDefault","replace","push","
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/routes/link.js"],"names":["addQueryArgs","getQueryArgs","removeQueryArgs","useHistory","useLink","params","state","shouldReplace","history","onClick","event","preventDefault","replace","push","currentArgs","window","location","href","currentUrlWithoutArgs","Object","keys","newUrl","Link","children","props"],"mappings":";;;AAAA;AACA;AACA;AACA,SAASA,YAAT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GU,IAAV;AAAiB,IAAA,OAAO,EAAGR;AAA3B,KAA0Ce,KAA1C,GACGD,QADH,CADD;AAKA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { addQueryArgs, getQueryArgs, removeQueryArgs } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport { useHistory } from './index';\n\nexport function useLink( params = {}, state, shouldReplace = false ) {\n\tconst history = useHistory();\n\n\tfunction onClick( event ) {\n\t\tevent.preventDefault();\n\n\t\tif ( shouldReplace ) {\n\t\t\thistory.replace( params, state );\n\t\t} else {\n\t\t\thistory.push( params, state );\n\t\t}\n\t}\n\n\tconst currentArgs = getQueryArgs( window.location.href );\n\tconst currentUrlWithoutArgs = removeQueryArgs(\n\t\twindow.location.href,\n\t\t...Object.keys( currentArgs )\n\t);\n\tconst newUrl = addQueryArgs( currentUrlWithoutArgs, params );\n\n\treturn {\n\t\thref: newUrl,\n\t\tonClick,\n\t};\n}\n\nexport default function Link( {\n\tparams = {},\n\tstate,\n\treplace: shouldReplace = false,\n\tchildren,\n\t...props\n} ) {\n\tconst { href, onClick } = useLink( params, state, shouldReplace );\n\n\treturn (\n\t\t<a href={ href } onClick={ onClick } { ...props }>\n\t\t\t{ children }\n\t\t</a>\n\t);\n}\n"]}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { createElement } from "@wordpress/element";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* WordPress dependencies
|
|
5
|
+
*/
|
|
6
|
+
import { useSelect, useDispatch } from '@wordpress/data';
|
|
7
|
+
import { Button, __experimentalHStack as HStack } from '@wordpress/components';
|
|
8
|
+
import { sprintf, __, _n } from '@wordpress/i18n';
|
|
9
|
+
import { store as coreStore } from '@wordpress/core-data';
|
|
10
|
+
import { displayShortcut } from '@wordpress/keycodes';
|
|
11
|
+
import { check } from '@wordpress/icons';
|
|
12
|
+
/**
|
|
13
|
+
* Internal dependencies
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import { store as editSiteStore } from '../../store';
|
|
17
|
+
export default function SaveButton() {
|
|
18
|
+
const {
|
|
19
|
+
countUnsavedChanges,
|
|
20
|
+
isDirty,
|
|
21
|
+
isSaving,
|
|
22
|
+
isSaveViewOpen
|
|
23
|
+
} = useSelect(select => {
|
|
24
|
+
const {
|
|
25
|
+
__experimentalGetDirtyEntityRecords,
|
|
26
|
+
isSavingEntityRecord
|
|
27
|
+
} = select(coreStore);
|
|
28
|
+
|
|
29
|
+
const dirtyEntityRecords = __experimentalGetDirtyEntityRecords();
|
|
30
|
+
|
|
31
|
+
const {
|
|
32
|
+
isSaveViewOpened
|
|
33
|
+
} = select(editSiteStore);
|
|
34
|
+
return {
|
|
35
|
+
isDirty: dirtyEntityRecords.length > 0,
|
|
36
|
+
isSaving: dirtyEntityRecords.some(record => isSavingEntityRecord(record.kind, record.name, record.key)),
|
|
37
|
+
isSaveViewOpen: isSaveViewOpened(),
|
|
38
|
+
countUnsavedChanges: dirtyEntityRecords.length
|
|
39
|
+
};
|
|
40
|
+
}, []);
|
|
41
|
+
const {
|
|
42
|
+
setIsSaveViewOpened
|
|
43
|
+
} = useDispatch(editSiteStore);
|
|
44
|
+
const disabled = !isDirty || isSaving;
|
|
45
|
+
const label = disabled ? __('Saved') : __('Save');
|
|
46
|
+
return createElement(HStack, {
|
|
47
|
+
className: "edit-site-save-hub",
|
|
48
|
+
alignment: "right",
|
|
49
|
+
spacing: 4
|
|
50
|
+
}, isDirty && createElement("span", null, sprintf( // translators: %d: number of unsaved changes (number).
|
|
51
|
+
_n('%d unsaved change', '%d unsaved changes', countUnsavedChanges), countUnsavedChanges)), createElement(Button, {
|
|
52
|
+
className: "edit-site-save-hub__button",
|
|
53
|
+
variant: disabled ? undefined : 'primary',
|
|
54
|
+
"aria-disabled": disabled,
|
|
55
|
+
"aria-expanded": isSaveViewOpen,
|
|
56
|
+
isBusy: isSaving,
|
|
57
|
+
onClick: disabled ? undefined : () => setIsSaveViewOpened(true),
|
|
58
|
+
label: label
|
|
59
|
+
/*
|
|
60
|
+
* We want the tooltip to show the keyboard shortcut only when the
|
|
61
|
+
* button does something, i.e. when it's not disabled.
|
|
62
|
+
*/
|
|
63
|
+
,
|
|
64
|
+
shortcut: disabled ? undefined : displayShortcut.primary('s'),
|
|
65
|
+
icon: disabled ? check : undefined
|
|
66
|
+
}, label));
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/save-hub/index.js"],"names":["useSelect","useDispatch","Button","__experimentalHStack","HStack","sprintf","__","_n","store","coreStore","displayShortcut","check","editSiteStore","SaveButton","countUnsavedChanges","isDirty","isSaving","isSaveViewOpen","select","__experimentalGetDirtyEntityRecords","isSavingEntityRecord","dirtyEntityRecords","isSaveViewOpened","length","some","record","kind","name","key","setIsSaveViewOpened","disabled","label","undefined","primary"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SAASC,MAAT,EAAiBC,oBAAoB,IAAIC,MAAzC,QAAuD,uBAAvD;AACA,SAASC,OAAT,EAAkBC,EAAlB,EAAsBC,EAAtB,QAAgC,iBAAhC;AACA,SAASC,KAAK,IAAIC,SAAlB,QAAmC,sBAAnC;AACA,SAASC,eAAT,QAAgC,qBAAhC;AACA,SAASC,KAAT,QAAsB,kBAAtB;AAEA;AACA;AACA;;AACA,SAASH,KAAK,IAAII,aAAlB,QAAuC,aAAvC;AAEA,eAAe,SAASC,UAAT,GAAsB;AACpC,QAAM;AAAEC,IAAAA,mBAAF;AAAuBC,IAAAA,OAAvB;AAAgCC,IAAAA,QAAhC;AAA0CC,IAAAA;AAA1C,MACLjB,SAAS,CAAIkB,MAAF,IAAc;AACxB,UAAM;AACLC,MAAAA,mCADK;AAELC,MAAAA;AAFK,QAGFF,MAAM,CAAET,SAAF,CAHV;;AAIA,UAAMY,kBAAkB,GAAGF,mCAAmC,EAA9D;;A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C,IAAA,QAAQ,EACPD,QAAQ,GAAGE,SAAH,GAAetB,eAAe,CAACuB,OAAhB,CAAyB,GAAzB,CAfzB;AAiBC,IAAA,IAAI,EAAGH,QAAQ,GAAGnB,KAAH,GAAWqB;AAjB3B,KAmBGD,KAnBH,CAdD,CADD;AAsCA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { Button, __experimentalHStack as HStack } from '@wordpress/components';\nimport { sprintf, __, _n } from '@wordpress/i18n';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { displayShortcut } from '@wordpress/keycodes';\nimport { check } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../store';\n\nexport default function SaveButton() {\n\tconst { countUnsavedChanges, isDirty, isSaving, isSaveViewOpen } =\n\t\tuseSelect( ( select ) => {\n\t\t\tconst {\n\t\t\t\t__experimentalGetDirtyEntityRecords,\n\t\t\t\tisSavingEntityRecord,\n\t\t\t} = select( coreStore );\n\t\t\tconst dirtyEntityRecords = __experimentalGetDirtyEntityRecords();\n\t\t\tconst { isSaveViewOpened } = select( editSiteStore );\n\t\t\treturn {\n\t\t\t\tisDirty: dirtyEntityRecords.length > 0,\n\t\t\t\tisSaving: dirtyEntityRecords.some( ( record ) =>\n\t\t\t\t\tisSavingEntityRecord( record.kind, record.name, record.key )\n\t\t\t\t),\n\t\t\t\tisSaveViewOpen: isSaveViewOpened(),\n\t\t\t\tcountUnsavedChanges: dirtyEntityRecords.length,\n\t\t\t};\n\t\t}, [] );\n\tconst { setIsSaveViewOpened } = useDispatch( editSiteStore );\n\n\tconst disabled = ! isDirty || isSaving;\n\n\tconst label = disabled ? __( 'Saved' ) : __( 'Save' );\n\n\treturn (\n\t\t<HStack className=\"edit-site-save-hub\" alignment=\"right\" spacing={ 4 }>\n\t\t\t{ isDirty && (\n\t\t\t\t<span>\n\t\t\t\t\t{ sprintf(\n\t\t\t\t\t\t// translators: %d: number of unsaved changes (number).\n\t\t\t\t\t\t_n(\n\t\t\t\t\t\t\t'%d unsaved change',\n\t\t\t\t\t\t\t'%d unsaved changes',\n\t\t\t\t\t\t\tcountUnsavedChanges\n\t\t\t\t\t\t),\n\t\t\t\t\t\tcountUnsavedChanges\n\t\t\t\t\t) }\n\t\t\t\t</span>\n\t\t\t) }\n\t\t\t<Button\n\t\t\t\tclassName=\"edit-site-save-hub__button\"\n\t\t\t\tvariant={ disabled ? undefined : 'primary' }\n\t\t\t\taria-disabled={ disabled }\n\t\t\t\taria-expanded={ isSaveViewOpen }\n\t\t\t\tisBusy={ isSaving }\n\t\t\t\tonClick={\n\t\t\t\t\tdisabled ? undefined : () => setIsSaveViewOpened( true )\n\t\t\t\t}\n\t\t\t\tlabel={ label }\n\t\t\t\t/*\n\t\t\t\t * We want the tooltip to show the keyboard shortcut only when the\n\t\t\t\t * button does something, i.e. when it's not disabled.\n\t\t\t\t */\n\t\t\t\tshortcut={\n\t\t\t\t\tdisabled ? undefined : displayShortcut.primary( 's' )\n\t\t\t\t}\n\t\t\t\ticon={ disabled ? check : undefined }\n\t\t\t>\n\t\t\t\t{ label }\n\t\t\t</Button>\n\t\t</HStack>\n\t);\n}\n"]}
|