@wordpress/edit-site 5.29.0 → 5.30.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 +2 -0
- package/build/components/actions/index.js +1 -1
- package/build/components/actions/index.js.map +1 -1
- package/build/components/block-editor/editor-canvas.js +10 -11
- package/build/components/block-editor/editor-canvas.js.map +1 -1
- package/build/components/editor/index.js +1 -15
- package/build/components/editor/index.js.map +1 -1
- package/build/components/global-styles/color-palette-panel.js +9 -0
- package/build/components/global-styles/color-palette-panel.js.map +1 -1
- package/build/components/global-styles/font-families.js +1 -1
- package/build/components/global-styles/font-families.js.map +1 -1
- package/build/components/global-styles/font-library-modal/collection-font-variant.js +2 -2
- package/build/components/global-styles/font-library-modal/collection-font-variant.js.map +1 -1
- package/build/components/global-styles/font-library-modal/context.js +62 -58
- package/build/components/global-styles/font-library-modal/context.js.map +1 -1
- package/build/components/global-styles/font-library-modal/font-card.js +10 -15
- package/build/components/global-styles/font-library-modal/font-card.js.map +1 -1
- package/build/components/global-styles/font-library-modal/font-collection.js +118 -76
- package/build/components/global-styles/font-library-modal/font-collection.js.map +1 -1
- package/build/components/global-styles/font-library-modal/font-demo.js +29 -8
- package/build/components/global-styles/font-library-modal/font-demo.js.map +1 -1
- package/build/components/global-styles/font-library-modal/index.js +19 -6
- package/build/components/global-styles/font-library-modal/index.js.map +1 -1
- package/build/components/global-styles/font-library-modal/installed-fonts.js +151 -79
- package/build/components/global-styles/font-library-modal/installed-fonts.js.map +1 -1
- package/build/components/global-styles/font-library-modal/library-font-variant.js +2 -2
- package/build/components/global-styles/font-library-modal/library-font-variant.js.map +1 -1
- package/build/components/global-styles/font-library-modal/upload-fonts.js +8 -14
- package/build/components/global-styles/font-library-modal/upload-fonts.js.map +1 -1
- package/build/components/global-styles/font-library-modal/utils/index.js +38 -4
- package/build/components/global-styles/font-library-modal/utils/index.js.map +1 -1
- package/build/components/global-styles/font-library-modal/utils/preview-styles.js +1 -1
- package/build/components/global-styles/font-library-modal/utils/preview-styles.js.map +1 -1
- package/build/components/global-styles/gradients-palette-panel.js.map +1 -1
- package/build/components/global-styles/header.js +1 -1
- package/build/components/global-styles/header.js.map +1 -1
- package/build/components/global-styles/highlighted-colors.js +50 -0
- package/build/components/global-styles/highlighted-colors.js.map +1 -0
- package/build/components/global-styles/preview-colors.js +62 -0
- package/build/components/global-styles/preview-colors.js.map +1 -0
- package/build/components/global-styles/preview-iframe.js +131 -0
- package/build/components/global-styles/preview-iframe.js.map +1 -0
- package/build/components/global-styles/preview-styles.js +163 -0
- package/build/components/global-styles/preview-styles.js.map +1 -0
- package/build/components/global-styles/preview-typography.js +65 -0
- package/build/components/global-styles/preview-typography.js.map +1 -0
- package/build/components/global-styles/screen-block-list.js +1 -1
- package/build/components/global-styles/screen-block-list.js.map +1 -1
- package/build/components/global-styles/screen-block.js +1 -1
- package/build/components/global-styles/screen-block.js.map +1 -1
- package/build/components/global-styles/screen-colors.js +10 -2
- package/build/components/global-styles/screen-colors.js.map +1 -1
- package/build/components/global-styles/screen-revisions/index.js +2 -2
- package/build/components/global-styles/screen-revisions/index.js.map +1 -1
- package/build/components/global-styles/screen-root.js +2 -2
- package/build/components/global-styles/screen-root.js.map +1 -1
- package/build/components/global-styles/screen-typography.js +10 -2
- package/build/components/global-styles/screen-typography.js.map +1 -1
- package/build/components/global-styles/style-variations-container.js +12 -84
- package/build/components/global-styles/style-variations-container.js.map +1 -1
- package/build/components/global-styles/{typogrphy-elements.js → typography-elements.js} +1 -1
- package/build/components/global-styles/typography-elements.js.map +1 -0
- package/build/components/global-styles/ui.js +27 -2
- package/build/components/global-styles/ui.js.map +1 -1
- package/build/components/global-styles/utils.js +22 -0
- package/build/components/global-styles/utils.js.map +1 -1
- package/build/components/global-styles/variations/variation.js +90 -0
- package/build/components/global-styles/variations/variation.js.map +1 -0
- package/build/components/global-styles/variations/variations-color.js +36 -0
- package/build/components/global-styles/variations/variations-color.js.map +1 -0
- package/build/components/global-styles/{variations-panel.js → variations/variations-panel.js} +1 -1
- package/build/components/global-styles/variations/variations-panel.js.map +1 -0
- package/build/components/global-styles/variations/variations-typography.js +64 -0
- package/build/components/global-styles/variations/variations-typography.js.map +1 -0
- package/build/components/header-edit-mode/index.js +12 -11
- package/build/components/header-edit-mode/index.js.map +1 -1
- package/build/components/header-edit-mode/more-menu/index.js +10 -2
- package/build/components/header-edit-mode/more-menu/index.js.map +1 -1
- package/build/components/layout/index.js +4 -1
- package/build/components/layout/index.js.map +1 -1
- package/build/components/page-patterns/index.js +14 -14
- package/build/components/page-patterns/index.js.map +1 -1
- package/build/components/{list/added-by.js → page-templates-template-parts/hooks.js} +1 -61
- package/build/components/page-templates-template-parts/hooks.js.map +1 -0
- package/build/components/page-templates-template-parts/index.js +14 -6
- package/build/components/page-templates-template-parts/index.js.map +1 -1
- package/build/components/resizable-frame/index.js +2 -1
- package/build/components/resizable-frame/index.js.map +1 -1
- package/build/components/revisions/index.js.map +1 -1
- package/build/components/save-panel/index.js +18 -3
- package/build/components/save-panel/index.js.map +1 -1
- package/build/components/sidebar/index.js +1 -1
- package/build/components/sidebar/index.js.map +1 -1
- package/build/components/sidebar-dataviews/default-views.js +2 -0
- package/build/components/sidebar-dataviews/default-views.js.map +1 -1
- package/build/components/sidebar-edit-mode/page-panels/page-status.js.map +1 -1
- package/build/components/sidebar-edit-mode/template-panel/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-main/index.js +1 -2
- package/build/components/sidebar-navigation-screen-main/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-menu/delete-modal.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-menu/single-navigation-menu.js +0 -3
- package/build/components/sidebar-navigation-screen-navigation-menu/single-navigation-menu.js.map +1 -1
- package/build/components/sidebar-navigation-screen-pattern/template-part-navigation-menu.js.map +1 -1
- package/build/components/sidebar-navigation-screen-pattern/template-part-navigation-menus.js.map +1 -1
- package/build/components/sidebar-navigation-screen-pattern/use-pattern-details.js +2 -2
- package/build/components/sidebar-navigation-screen-pattern/use-pattern-details.js.map +1 -1
- package/build/components/sidebar-navigation-screen-template/index.js +2 -2
- package/build/components/sidebar-navigation-screen-template/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-templates-browse/content.js +4 -4
- package/build/components/sidebar-navigation-screen-templates-browse/content.js.map +1 -1
- package/build/components/sidebar-navigation-screen-templates-browse/index.js +7 -5
- package/build/components/sidebar-navigation-screen-templates-browse/index.js.map +1 -1
- package/build/components/start-template-options/index.js.map +1 -1
- package/build/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js +65 -0
- package/build/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js.map +1 -1
- package/build-module/components/actions/index.js +1 -1
- package/build-module/components/actions/index.js.map +1 -1
- package/build-module/components/block-editor/editor-canvas.js +10 -11
- package/build-module/components/block-editor/editor-canvas.js.map +1 -1
- package/build-module/components/editor/index.js +2 -16
- package/build-module/components/editor/index.js.map +1 -1
- package/build-module/components/global-styles/color-palette-panel.js +8 -0
- package/build-module/components/global-styles/color-palette-panel.js.map +1 -1
- package/build-module/components/global-styles/font-families.js +1 -1
- package/build-module/components/global-styles/font-families.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/collection-font-variant.js +4 -4
- package/build-module/components/global-styles/font-library-modal/collection-font-variant.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/context.js +63 -59
- package/build-module/components/global-styles/font-library-modal/context.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/font-card.js +11 -16
- package/build-module/components/global-styles/font-library-modal/font-card.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/font-collection.js +121 -79
- package/build-module/components/global-styles/font-library-modal/font-collection.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/font-demo.js +30 -9
- package/build-module/components/global-styles/font-library-modal/font-demo.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/index.js +19 -6
- package/build-module/components/global-styles/font-library-modal/index.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/installed-fonts.js +151 -79
- package/build-module/components/global-styles/font-library-modal/installed-fonts.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/library-font-variant.js +4 -4
- package/build-module/components/global-styles/font-library-modal/library-font-variant.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/upload-fonts.js +9 -15
- package/build-module/components/global-styles/font-library-modal/upload-fonts.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/utils/index.js +37 -4
- package/build-module/components/global-styles/font-library-modal/utils/index.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/utils/preview-styles.js +1 -1
- package/build-module/components/global-styles/font-library-modal/utils/preview-styles.js.map +1 -1
- package/build-module/components/global-styles/gradients-palette-panel.js.map +1 -1
- package/build-module/components/global-styles/header.js +1 -1
- package/build-module/components/global-styles/header.js.map +1 -1
- package/build-module/components/global-styles/highlighted-colors.js +43 -0
- package/build-module/components/global-styles/highlighted-colors.js.map +1 -0
- package/build-module/components/global-styles/preview-colors.js +54 -0
- package/build-module/components/global-styles/preview-colors.js.map +1 -0
- package/build-module/components/global-styles/preview-iframe.js +124 -0
- package/build-module/components/global-styles/preview-iframe.js.map +1 -0
- package/build-module/components/global-styles/preview-styles.js +155 -0
- package/build-module/components/global-styles/preview-styles.js.map +1 -0
- package/build-module/components/global-styles/preview-typography.js +58 -0
- package/build-module/components/global-styles/preview-typography.js.map +1 -0
- package/build-module/components/global-styles/screen-block-list.js +1 -1
- package/build-module/components/global-styles/screen-block-list.js.map +1 -1
- package/build-module/components/global-styles/screen-block.js +1 -1
- package/build-module/components/global-styles/screen-block.js.map +1 -1
- package/build-module/components/global-styles/screen-colors.js +10 -2
- package/build-module/components/global-styles/screen-colors.js.map +1 -1
- package/build-module/components/global-styles/screen-revisions/index.js +2 -2
- package/build-module/components/global-styles/screen-revisions/index.js.map +1 -1
- package/build-module/components/global-styles/screen-root.js +2 -2
- package/build-module/components/global-styles/screen-root.js.map +1 -1
- package/build-module/components/global-styles/screen-typography.js +10 -2
- package/build-module/components/global-styles/screen-typography.js.map +1 -1
- package/build-module/components/global-styles/style-variations-container.js +13 -85
- package/build-module/components/global-styles/style-variations-container.js.map +1 -1
- package/build-module/components/global-styles/{typogrphy-elements.js → typography-elements.js} +1 -1
- package/build-module/components/global-styles/typography-elements.js.map +1 -0
- package/build-module/components/global-styles/ui.js +27 -2
- package/build-module/components/global-styles/ui.js.map +1 -1
- package/build-module/components/global-styles/utils.js +21 -0
- package/build-module/components/global-styles/utils.js.map +1 -1
- package/build-module/components/global-styles/variations/variation.js +82 -0
- package/build-module/components/global-styles/variations/variation.js.map +1 -0
- package/build-module/components/global-styles/variations/variations-color.js +28 -0
- package/build-module/components/global-styles/variations/variations-color.js.map +1 -0
- package/build-module/components/global-styles/{variations-panel.js → variations/variations-panel.js} +1 -1
- package/build-module/components/global-styles/variations/variations-panel.js.map +1 -0
- package/build-module/components/global-styles/variations/variations-typography.js +56 -0
- package/build-module/components/global-styles/variations/variations-typography.js.map +1 -0
- package/build-module/components/header-edit-mode/index.js +13 -12
- package/build-module/components/header-edit-mode/index.js.map +1 -1
- package/build-module/components/header-edit-mode/more-menu/index.js +13 -5
- package/build-module/components/header-edit-mode/more-menu/index.js.map +1 -1
- package/build-module/components/layout/index.js +4 -1
- package/build-module/components/layout/index.js.map +1 -1
- package/build-module/components/page-patterns/index.js +14 -14
- package/build-module/components/page-patterns/index.js.map +1 -1
- package/build-module/components/{list/added-by.js → page-templates-template-parts/hooks.js} +2 -59
- package/build-module/components/page-templates-template-parts/hooks.js.map +1 -0
- package/build-module/components/page-templates-template-parts/index.js +13 -5
- package/build-module/components/page-templates-template-parts/index.js.map +1 -1
- package/build-module/components/resizable-frame/index.js +2 -1
- package/build-module/components/resizable-frame/index.js.map +1 -1
- package/build-module/components/revisions/index.js.map +1 -1
- package/build-module/components/save-panel/index.js +18 -3
- package/build-module/components/save-panel/index.js.map +1 -1
- package/build-module/components/sidebar/index.js +1 -1
- package/build-module/components/sidebar/index.js.map +1 -1
- package/build-module/components/sidebar-dataviews/default-views.js +3 -1
- package/build-module/components/sidebar-dataviews/default-views.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/page-panels/page-status.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/template-panel/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-main/index.js +1 -2
- package/build-module/components/sidebar-navigation-screen-main/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menu/delete-modal.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menu/single-navigation-menu.js +0 -3
- package/build-module/components/sidebar-navigation-screen-navigation-menu/single-navigation-menu.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-pattern/template-part-navigation-menu.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-pattern/template-part-navigation-menus.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-pattern/use-pattern-details.js +1 -1
- package/build-module/components/sidebar-navigation-screen-pattern/use-pattern-details.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-template/index.js +1 -1
- package/build-module/components/sidebar-navigation-screen-template/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-templates-browse/content.js +3 -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 +7 -5
- package/build-module/components/sidebar-navigation-screen-templates-browse/index.js.map +1 -1
- package/build-module/components/start-template-options/index.js.map +1 -1
- package/build-module/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js +63 -1
- package/build-module/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js.map +1 -1
- package/build-style/style-rtl.css +163 -286
- package/build-style/style.css +163 -286
- package/package.json +42 -42
- package/src/components/actions/index.js +1 -1
- package/src/components/block-editor/editor-canvas.js +13 -12
- package/src/components/block-editor/style.scss +0 -3
- package/src/components/editor/index.js +0 -20
- package/src/components/global-styles/color-palette-panel.js +11 -1
- package/src/components/global-styles/font-families.js +1 -1
- package/src/components/global-styles/font-library-modal/collection-font-variant.js +5 -5
- package/src/components/global-styles/font-library-modal/context.js +116 -104
- package/src/components/global-styles/font-library-modal/font-card.js +11 -26
- package/src/components/global-styles/font-library-modal/font-collection.js +297 -218
- package/src/components/global-styles/font-library-modal/font-demo.js +38 -4
- package/src/components/global-styles/font-library-modal/index.js +23 -16
- package/src/components/global-styles/font-library-modal/installed-fonts.js +243 -114
- package/src/components/global-styles/font-library-modal/library-font-variant.js +5 -5
- package/src/components/global-styles/font-library-modal/style.scss +15 -8
- package/src/components/global-styles/font-library-modal/upload-fonts.js +17 -19
- package/src/components/global-styles/font-library-modal/utils/index.js +44 -4
- package/src/components/global-styles/font-library-modal/utils/preview-styles.js +2 -1
- package/src/components/global-styles/font-library-modal/utils/test/getDisplaySrcFromFontFace.spec.js +7 -18
- package/src/components/global-styles/gradients-palette-panel.js +2 -2
- package/src/components/global-styles/header.js +1 -1
- package/src/components/global-styles/highlighted-colors.js +39 -0
- package/src/components/global-styles/preview-colors.js +61 -0
- package/src/components/global-styles/preview-iframe.js +153 -0
- package/src/components/global-styles/preview-styles.js +185 -0
- package/src/components/global-styles/preview-typography.js +62 -0
- package/src/components/global-styles/screen-block-list.js +1 -1
- package/src/components/global-styles/screen-block.js +4 -1
- package/src/components/global-styles/screen-colors.js +13 -1
- package/src/components/global-styles/screen-revisions/index.js +5 -2
- package/src/components/global-styles/screen-root.js +2 -2
- package/src/components/global-styles/screen-typography.js +19 -2
- package/src/components/global-styles/style-variations-container.js +14 -92
- package/src/components/global-styles/style.scss +0 -34
- package/src/components/global-styles/ui.js +26 -2
- package/src/components/global-styles/utils.js +37 -0
- package/src/components/global-styles/variations/style.scss +44 -0
- package/src/components/global-styles/variations/variation.js +93 -0
- package/src/components/global-styles/variations/variations-color.js +30 -0
- package/src/components/global-styles/{variations-panel.js → variations/variations-panel.js} +1 -1
- package/src/components/global-styles/variations/variations-typography.js +85 -0
- package/src/components/header-edit-mode/index.js +20 -27
- package/src/components/header-edit-mode/more-menu/index.js +17 -8
- package/src/components/header-edit-mode/style.scss +4 -0
- package/src/components/layout/index.js +5 -0
- package/src/components/page-patterns/index.js +21 -21
- package/src/components/{list/added-by.js → page-templates-template-parts/hooks.js} +1 -66
- package/src/components/page-templates-template-parts/index.js +20 -3
- package/src/components/page-templates-template-parts/style.scss +48 -0
- package/src/components/resizable-frame/index.js +1 -0
- package/src/components/revisions/index.js +1 -1
- package/src/components/save-panel/index.js +34 -12
- package/src/components/sidebar/index.js +1 -1
- package/src/components/sidebar-dataviews/default-views.js +3 -1
- package/src/components/sidebar-edit-mode/page-panels/page-status.js +1 -1
- package/src/components/sidebar-edit-mode/template-panel/index.js +1 -1
- package/src/components/sidebar-navigation-screen-main/index.js +0 -2
- package/src/components/sidebar-navigation-screen-navigation-menu/delete-modal.js +1 -1
- package/src/components/sidebar-navigation-screen-navigation-menu/single-navigation-menu.js +0 -2
- package/src/components/sidebar-navigation-screen-pattern/template-part-navigation-menu.js +1 -1
- package/src/components/sidebar-navigation-screen-pattern/template-part-navigation-menus.js +1 -1
- package/src/components/sidebar-navigation-screen-pattern/use-pattern-details.js +1 -1
- package/src/components/sidebar-navigation-screen-template/index.js +1 -1
- package/src/components/sidebar-navigation-screen-templates-browse/content.js +3 -3
- package/src/components/sidebar-navigation-screen-templates-browse/index.js +5 -3
- package/src/components/start-template-options/index.js +1 -1
- package/src/hooks/use-theme-style-variations/test/use-theme-style-variations-by-property.js +173 -0
- package/src/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js +68 -1
- package/src/style.scss +2 -2
- package/build/components/global-styles/font-library-modal/collection-font-details.js +0 -50
- package/build/components/global-styles/font-library-modal/collection-font-details.js.map +0 -1
- package/build/components/global-styles/font-library-modal/confirm-delete-dialog.js +0 -30
- package/build/components/global-styles/font-library-modal/confirm-delete-dialog.js.map +0 -1
- package/build/components/global-styles/font-library-modal/library-font-card.js +0 -39
- package/build/components/global-styles/font-library-modal/library-font-card.js.map +0 -1
- package/build/components/global-styles/font-library-modal/tab-panel-layout.js +0 -67
- package/build/components/global-styles/font-library-modal/tab-panel-layout.js.map +0 -1
- package/build/components/global-styles/preview.js +0 -271
- package/build/components/global-styles/preview.js.map +0 -1
- package/build/components/global-styles/typogrphy-elements.js.map +0 -1
- package/build/components/global-styles/variations-panel.js.map +0 -1
- package/build/components/list/added-by.js.map +0 -1
- package/build/components/list/header.js +0 -55
- package/build/components/list/header.js.map +0 -1
- package/build/components/list/index.js +0 -80
- package/build/components/list/index.js.map +0 -1
- package/build/components/list/table.js +0 -94
- package/build/components/list/table.js.map +0 -1
- package/build/components/list/use-register-shortcuts.js +0 -51
- package/build/components/list/use-register-shortcuts.js.map +0 -1
- package/build/components/sidebar-navigation-screen-main/template-part-hint.js +0 -36
- package/build/components/sidebar-navigation-screen-main/template-part-hint.js.map +0 -1
- package/build/components/sidebar-navigation-screen-navigation-menu/edit-button.js +0 -36
- package/build/components/sidebar-navigation-screen-navigation-menu/edit-button.js.map +0 -1
- package/build-module/components/global-styles/font-library-modal/collection-font-details.js +0 -42
- package/build-module/components/global-styles/font-library-modal/collection-font-details.js.map +0 -1
- package/build-module/components/global-styles/font-library-modal/confirm-delete-dialog.js +0 -23
- package/build-module/components/global-styles/font-library-modal/confirm-delete-dialog.js.map +0 -1
- package/build-module/components/global-styles/font-library-modal/library-font-card.js +0 -31
- package/build-module/components/global-styles/font-library-modal/library-font-card.js.map +0 -1
- package/build-module/components/global-styles/font-library-modal/tab-panel-layout.js +0 -60
- package/build-module/components/global-styles/font-library-modal/tab-panel-layout.js.map +0 -1
- package/build-module/components/global-styles/preview.js +0 -264
- package/build-module/components/global-styles/preview.js.map +0 -1
- package/build-module/components/global-styles/typogrphy-elements.js.map +0 -1
- package/build-module/components/global-styles/variations-panel.js.map +0 -1
- package/build-module/components/list/added-by.js.map +0 -1
- package/build-module/components/list/header.js +0 -47
- package/build-module/components/list/header.js.map +0 -1
- package/build-module/components/list/index.js +0 -72
- package/build-module/components/list/index.js.map +0 -1
- package/build-module/components/list/table.js +0 -86
- package/build-module/components/list/table.js.map +0 -1
- package/build-module/components/list/use-register-shortcuts.js +0 -45
- package/build-module/components/list/use-register-shortcuts.js.map +0 -1
- package/build-module/components/sidebar-navigation-screen-main/template-part-hint.js +0 -29
- package/build-module/components/sidebar-navigation-screen-main/template-part-hint.js.map +0 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menu/edit-button.js +0 -27
- package/build-module/components/sidebar-navigation-screen-navigation-menu/edit-button.js.map +0 -1
- package/src/components/global-styles/font-library-modal/collection-font-details.js +0 -56
- package/src/components/global-styles/font-library-modal/confirm-delete-dialog.js +0 -33
- package/src/components/global-styles/font-library-modal/library-font-card.js +0 -34
- package/src/components/global-styles/font-library-modal/tab-panel-layout.js +0 -85
- package/src/components/global-styles/preview.js +0 -327
- package/src/components/list/header.js +0 -48
- package/src/components/list/index.js +0 -87
- package/src/components/list/style.scss +0 -188
- package/src/components/list/table.js +0 -140
- package/src/components/list/use-register-shortcuts.js +0 -49
- package/src/components/sidebar-navigation-screen-main/template-part-hint.js +0 -34
- package/src/components/sidebar-navigation-screen-navigation-menu/edit-button.js +0 -22
- /package/src/components/global-styles/{typogrphy-elements.js → typography-elements.js} +0 -0
package/build/components/sidebar-navigation-screen-pattern/template-part-navigation-menu.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_i18n","require","_components","_navigationMenuEditor","_interopRequireDefault","_useNavigationMenuTitle","TemplatePartNavigationMenu","id","title","useNavigationMenuTitle","undefined","_react","createElement","Fragment","__experimentalHeading","className","size","upperCase","weight","__","default","navigationMenuId"],"sources":["@wordpress/edit-site/src/components/sidebar-navigation-screen-pattern/template-part-navigation-menu.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { __experimentalHeading as Heading } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport NavigationMenuEditor from '../sidebar-navigation-screen-navigation-menu/navigation-menu-editor';\nimport useNavigationMenuTitle from './use-navigation-menu-title';\n\nexport default function TemplatePartNavigationMenu( { id } ) {\n\tconst title = useNavigationMenuTitle( id );\n\n\tif ( ! id || title === undefined ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<Heading\n\t\t\t\tclassName=\"edit-site-sidebar-navigation-screen-template-part-navigation-menu__title\"\n\t\t\t\tsize=\"11\"\n\t\t\t\tupperCase
|
|
1
|
+
{"version":3,"names":["_i18n","require","_components","_navigationMenuEditor","_interopRequireDefault","_useNavigationMenuTitle","TemplatePartNavigationMenu","id","title","useNavigationMenuTitle","undefined","_react","createElement","Fragment","__experimentalHeading","className","size","upperCase","weight","__","default","navigationMenuId"],"sources":["@wordpress/edit-site/src/components/sidebar-navigation-screen-pattern/template-part-navigation-menu.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { __experimentalHeading as Heading } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport NavigationMenuEditor from '../sidebar-navigation-screen-navigation-menu/navigation-menu-editor';\nimport useNavigationMenuTitle from './use-navigation-menu-title';\n\nexport default function TemplatePartNavigationMenu( { id } ) {\n\tconst title = useNavigationMenuTitle( id );\n\n\tif ( ! id || title === undefined ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<Heading\n\t\t\t\tclassName=\"edit-site-sidebar-navigation-screen-template-part-navigation-menu__title\"\n\t\t\t\tsize=\"11\"\n\t\t\t\tupperCase\n\t\t\t\tweight={ 500 }\n\t\t\t>\n\t\t\t\t{ title || __( 'Navigation' ) }\n\t\t\t</Heading>\n\t\t\t<NavigationMenuEditor navigationMenuId={ id } />\n\t\t</>\n\t);\n}\n"],"mappings":";;;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AAKA,IAAAE,qBAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,uBAAA,GAAAD,sBAAA,CAAAH,OAAA;AAVA;AACA;AACA;;AAIA;AACA;AACA;;AAIe,SAASK,0BAA0BA,CAAE;EAAEC;AAAG,CAAC,EAAG;EAC5D,MAAMC,KAAK,GAAG,IAAAC,+BAAsB,EAAEF,EAAG,CAAC;EAE1C,IAAK,CAAEA,EAAE,IAAIC,KAAK,KAAKE,SAAS,EAAG;IAClC,OAAO,IAAI;EACZ;EAEA,OACC,IAAAC,MAAA,CAAAC,aAAA,EAAAD,MAAA,CAAAE,QAAA,QACC,IAAAF,MAAA,CAAAC,aAAA,EAACV,WAAA,CAAAY,qBAAO;IACPC,SAAS,EAAC,0EAA0E;IACpFC,IAAI,EAAC,IAAI;IACTC,SAAS;IACTC,MAAM,EAAG;EAAK,GAEZV,KAAK,IAAI,IAAAW,QAAE,EAAE,YAAa,CACpB,CAAC,EACV,IAAAR,MAAA,CAAAC,aAAA,EAACT,qBAAA,CAAAiB,OAAoB;IAACC,gBAAgB,EAAGd;EAAI,CAAE,CAC9C,CAAC;AAEL"}
|
package/build/components/sidebar-navigation-screen-pattern/template-part-navigation-menus.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_i18n","require","_components","_templatePartNavigationMenu","_interopRequireDefault","_templatePartNavigationMenuList","TemplatePartNavigationMenus","menus","length","_react","createElement","default","id","Fragment","__experimentalHeading","className","size","upperCase","weight","__"],"sources":["@wordpress/edit-site/src/components/sidebar-navigation-screen-pattern/template-part-navigation-menus.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { __experimentalHeading as Heading } from '@wordpress/components';\n/**\n * Internal dependencies\n */\nimport TemplatePartNavigationMenu from './template-part-navigation-menu';\nimport TemplatePartNavigationMenuList from './template-part-navigation-menu-list';\n\nexport default function TemplatePartNavigationMenus( { menus } ) {\n\tif ( ! menus.length ) return null;\n\n\t// if there is a single menu then render TemplatePartNavigationMenu\n\tif ( menus.length === 1 ) {\n\t\treturn <TemplatePartNavigationMenu id={ menus[ 0 ] } />;\n\t}\n\n\t// if there are multiple menus then render TemplatePartNavigationMenuList\n\treturn (\n\t\t<>\n\t\t\t<Heading\n\t\t\t\tclassName=\"edit-site-sidebar-navigation-screen-template-part-navigation-menu__title\"\n\t\t\t\tsize=\"11\"\n\t\t\t\tupperCase
|
|
1
|
+
{"version":3,"names":["_i18n","require","_components","_templatePartNavigationMenu","_interopRequireDefault","_templatePartNavigationMenuList","TemplatePartNavigationMenus","menus","length","_react","createElement","default","id","Fragment","__experimentalHeading","className","size","upperCase","weight","__"],"sources":["@wordpress/edit-site/src/components/sidebar-navigation-screen-pattern/template-part-navigation-menus.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { __experimentalHeading as Heading } from '@wordpress/components';\n/**\n * Internal dependencies\n */\nimport TemplatePartNavigationMenu from './template-part-navigation-menu';\nimport TemplatePartNavigationMenuList from './template-part-navigation-menu-list';\n\nexport default function TemplatePartNavigationMenus( { menus } ) {\n\tif ( ! menus.length ) return null;\n\n\t// if there is a single menu then render TemplatePartNavigationMenu\n\tif ( menus.length === 1 ) {\n\t\treturn <TemplatePartNavigationMenu id={ menus[ 0 ] } />;\n\t}\n\n\t// if there are multiple menus then render TemplatePartNavigationMenuList\n\treturn (\n\t\t<>\n\t\t\t<Heading\n\t\t\t\tclassName=\"edit-site-sidebar-navigation-screen-template-part-navigation-menu__title\"\n\t\t\t\tsize=\"11\"\n\t\t\t\tupperCase\n\t\t\t\tweight={ 500 }\n\t\t\t>\n\t\t\t\t{ __( 'Navigation' ) }\n\t\t\t</Heading>\n\t\t\t<TemplatePartNavigationMenuList menus={ menus } />\n\t\t</>\n\t);\n}\n"],"mappings":";;;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AAIA,IAAAE,2BAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,+BAAA,GAAAD,sBAAA,CAAAH,OAAA;AATA;AACA;AACA;;AAGA;AACA;AACA;;AAIe,SAASK,2BAA2BA,CAAE;EAAEC;AAAM,CAAC,EAAG;EAChE,IAAK,CAAEA,KAAK,CAACC,MAAM,EAAG,OAAO,IAAI;;EAEjC;EACA,IAAKD,KAAK,CAACC,MAAM,KAAK,CAAC,EAAG;IACzB,OAAO,IAAAC,MAAA,CAAAC,aAAA,EAACP,2BAAA,CAAAQ,OAA0B;MAACC,EAAE,EAAGL,KAAK,CAAE,CAAC;IAAI,CAAE,CAAC;EACxD;;EAEA;EACA,OACC,IAAAE,MAAA,CAAAC,aAAA,EAAAD,MAAA,CAAAI,QAAA,QACC,IAAAJ,MAAA,CAAAC,aAAA,EAACR,WAAA,CAAAY,qBAAO;IACPC,SAAS,EAAC,0EAA0E;IACpFC,IAAI,EAAC,IAAI;IACTC,SAAS;IACTC,MAAM,EAAG;EAAK,GAEZ,IAAAC,QAAE,EAAE,YAAa,CACX,CAAC,EACV,IAAAV,MAAA,CAAAC,aAAA,EAACL,+BAAA,CAAAM,OAA8B;IAACJ,KAAK,EAAGA;EAAO,CAAE,CAChD,CAAC;AAEL"}
|
|
@@ -11,7 +11,7 @@ var _i18n = require("@wordpress/i18n");
|
|
|
11
11
|
var _coreData = require("@wordpress/core-data");
|
|
12
12
|
var _editor = require("@wordpress/editor");
|
|
13
13
|
var _data = require("@wordpress/data");
|
|
14
|
-
var
|
|
14
|
+
var _hooks = require("../page-templates-template-parts/hooks");
|
|
15
15
|
var _useEditedEntityRecord = _interopRequireDefault(require("../use-edited-entity-record"));
|
|
16
16
|
var _useNavigationMenuContent = _interopRequireDefault(require("./use-navigation-menu-content"));
|
|
17
17
|
var _sidebarNavigationScreenDetailsFooter = _interopRequireDefault(require("../sidebar-navigation-screen-details-footer"));
|
|
@@ -49,7 +49,7 @@ function usePatternDetails(postType, postId) {
|
|
|
49
49
|
userPatternCategories: getUserPatternCategories()
|
|
50
50
|
};
|
|
51
51
|
}, []);
|
|
52
|
-
const addedBy = (0,
|
|
52
|
+
const addedBy = (0, _hooks.useAddedBy)(postType, postId);
|
|
53
53
|
const isAddedByActiveTheme = addedBy.type === 'theme' && record.theme === currentTheme?.stylesheet;
|
|
54
54
|
const title = getTitle();
|
|
55
55
|
let description = getDescription();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_changeCase","require","_i18n","_coreData","_editor","_data","_addedBy","_useEditedEntityRecord","_interopRequireDefault","_useNavigationMenuContent","_sidebarNavigationScreenDetailsFooter","_sidebarNavigationScreenDetailsPanel","_constants","usePatternDetails","postType","postId","getDescription","getTitle","record","useEditedEntityRecord","templatePartAreas","useSelect","select","editorStore","__experimentalGetDefaultTemplatePartAreas","currentTheme","userPatternCategories","getCurrentTheme","getUserPatternCategories","coreStore","addedBy","useAddedBy","isAddedByActiveTheme","type","theme","stylesheet","title","description","text","PATTERN_TYPES","user","sprintf","__","footer","modified","_react","createElement","default","details","TEMPLATE_PART_POST_TYPE","push","label","value","wp_pattern_sync_status","PATTERN_SYNC_TYPES","unsynced","_x","wp_pattern_category","length","patternCategories","Map","forEach","userCategory","set","id","categories","filter","category","get","map","join","templatePartArea","find","area","areaDetailValue","sentenceCase","className","origin","TEMPLATE_ORIGINS","plugin","has_theme_file","isCustomized","content","Fragment","useNavigationMenuContent","SidebarNavigationScreenDetailsPanel","spacing","SidebarNavigationScreenDetailsPanelRow","key","SidebarNavigationScreenDetailsPanelLabel","SidebarNavigationScreenDetailsPanelValue"],"sources":["@wordpress/edit-site/src/components/sidebar-navigation-screen-pattern/use-pattern-details.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { sentenceCase } from 'change-case';\n\n/**\n * WordPress dependencies\n */\nimport { __, _x, sprintf } from '@wordpress/i18n';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as editorStore } from '@wordpress/editor';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { useAddedBy } from '../list/added-by';\nimport useEditedEntityRecord from '../use-edited-entity-record';\nimport useNavigationMenuContent from './use-navigation-menu-content';\nimport SidebarNavigationScreenDetailsFooter from '../sidebar-navigation-screen-details-footer';\nimport {\n\tSidebarNavigationScreenDetailsPanel,\n\tSidebarNavigationScreenDetailsPanelRow,\n\tSidebarNavigationScreenDetailsPanelLabel,\n\tSidebarNavigationScreenDetailsPanelValue,\n} from '../sidebar-navigation-screen-details-panel';\nimport {\n\tPATTERN_TYPES,\n\tTEMPLATE_PART_POST_TYPE,\n\tPATTERN_SYNC_TYPES,\n\tTEMPLATE_ORIGINS,\n} from '../../utils/constants';\n\nexport default function usePatternDetails( postType, postId ) {\n\tconst { getDescription, getTitle, record } = useEditedEntityRecord(\n\t\tpostType,\n\t\tpostId\n\t);\n\tconst templatePartAreas = useSelect(\n\t\t( select ) =>\n\t\t\tselect( editorStore ).__experimentalGetDefaultTemplatePartAreas(),\n\t\t[]\n\t);\n\tconst { currentTheme, userPatternCategories } = useSelect( ( select ) => {\n\t\tconst { getCurrentTheme, getUserPatternCategories } =\n\t\t\tselect( coreStore );\n\n\t\treturn {\n\t\t\tcurrentTheme: getCurrentTheme(),\n\t\t\tuserPatternCategories: getUserPatternCategories(),\n\t\t};\n\t}, [] );\n\n\tconst addedBy = useAddedBy( postType, postId );\n\tconst isAddedByActiveTheme =\n\t\taddedBy.type === 'theme' && record.theme === currentTheme?.stylesheet;\n\tconst title = getTitle();\n\tlet description = getDescription();\n\n\tif ( ! description && addedBy.text ) {\n\t\tdescription =\n\t\t\tpostType === PATTERN_TYPES.user\n\t\t\t\t? sprintf(\n\t\t\t\t\t\t// translators: %s: pattern title e.g: \"Header\".\n\t\t\t\t\t\t__( 'This is the %s pattern.' ),\n\t\t\t\t\t\tgetTitle()\n\t\t\t\t )\n\t\t\t\t: sprintf(\n\t\t\t\t\t\t// translators: %s: template part title e.g: \"Header\".\n\t\t\t\t\t\t__( 'This is the %s template part.' ),\n\t\t\t\t\t\tgetTitle()\n\t\t\t\t );\n\t}\n\n\tif ( ! description && postType === PATTERN_TYPES.user && record?.title ) {\n\t\tdescription = sprintf(\n\t\t\t// translators: %s: user created pattern title e.g. \"Footer\".\n\t\t\t__( 'This is the %s pattern.' ),\n\t\t\trecord.title\n\t\t);\n\t}\n\n\tconst footer = record?.modified ? (\n\t\t<SidebarNavigationScreenDetailsFooter record={ record } />\n\t) : null;\n\n\tconst details = [];\n\n\tif (\n\t\tpostType === PATTERN_TYPES.user ||\n\t\tpostType === TEMPLATE_PART_POST_TYPE\n\t) {\n\t\tdetails.push( {\n\t\t\tlabel: __( 'Syncing' ),\n\t\t\tvalue:\n\t\t\t\trecord.wp_pattern_sync_status === PATTERN_SYNC_TYPES.unsynced\n\t\t\t\t\t? _x(\n\t\t\t\t\t\t\t'Not synced',\n\t\t\t\t\t\t\t'Text that indicates that the pattern is not synchronized'\n\t\t\t\t\t )\n\t\t\t\t\t: _x(\n\t\t\t\t\t\t\t'Synced',\n\t\t\t\t\t\t\t'Text that indicates that the pattern is synchronized'\n\t\t\t\t\t ),\n\t\t} );\n\n\t\tif ( record.wp_pattern_category?.length === 0 ) {\n\t\t\tdetails.push( {\n\t\t\t\tlabel: __( 'Categories' ),\n\t\t\t\tvalue: __( 'Uncategorized' ),\n\t\t\t} );\n\t\t}\n\t\tif ( record.wp_pattern_category?.length > 0 ) {\n\t\t\tconst patternCategories = new Map();\n\t\t\tuserPatternCategories.forEach( ( userCategory ) =>\n\t\t\t\tpatternCategories.set( userCategory.id, userCategory )\n\t\t\t);\n\n\t\t\tconst categories = record.wp_pattern_category\n\t\t\t\t.filter( ( category ) => patternCategories.get( category ) )\n\t\t\t\t.map( ( category ) => patternCategories.get( category ).label );\n\n\t\t\tdetails.push( {\n\t\t\t\tlabel: __( 'Categories' ),\n\t\t\t\tvalue: categories.length > 0 ? categories.join( ', ' ) : '',\n\t\t\t} );\n\t\t}\n\t}\n\n\tif ( postType === TEMPLATE_PART_POST_TYPE ) {\n\t\tconst templatePartArea = templatePartAreas.find(\n\t\t\t( area ) => area.area === record.area\n\t\t);\n\n\t\tlet areaDetailValue = templatePartArea?.label;\n\n\t\tif ( ! areaDetailValue ) {\n\t\t\tareaDetailValue = record.area\n\t\t\t\t? sprintf(\n\t\t\t\t\t\t// translators: %s: Sentenced cased template part area e.g: \"My custom area\".\n\t\t\t\t\t\t__( '%s (removed)' ),\n\t\t\t\t\t\tsentenceCase( record.area )\n\t\t\t\t )\n\t\t\t\t: __( 'None' );\n\t\t}\n\n\t\tdetails.push( { label: __( 'Area' ), value: areaDetailValue } );\n\t}\n\n\tif (\n\t\tpostType === TEMPLATE_PART_POST_TYPE &&\n\t\taddedBy.text &&\n\t\t! isAddedByActiveTheme\n\t) {\n\t\tdetails.push( {\n\t\t\tlabel: __( 'Added by' ),\n\t\t\tvalue: (\n\t\t\t\t<span className=\"edit-site-sidebar-navigation-screen-pattern__added-by-description-author\">\n\t\t\t\t\t{ addedBy.text }\n\t\t\t\t</span>\n\t\t\t),\n\t\t} );\n\t}\n\n\tif (\n\t\tpostType === TEMPLATE_PART_POST_TYPE &&\n\t\taddedBy.text &&\n\t\t( record.origin === TEMPLATE_ORIGINS.plugin ||\n\t\t\trecord.has_theme_file === true )\n\t) {\n\t\tdetails.push( {\n\t\t\tlabel: __( 'Customized' ),\n\t\t\tvalue: (\n\t\t\t\t<span className=\"edit-site-sidebar-navigation-screen-pattern__added-by-description-customized\">\n\t\t\t\t\t{ addedBy.isCustomized ? __( 'Yes' ) : __( 'No' ) }\n\t\t\t\t</span>\n\t\t\t),\n\t\t} );\n\t}\n\n\tconst content = (\n\t\t<>\n\t\t\t{ useNavigationMenuContent( postType, postId ) }\n\t\t\t{ !! details.length && (\n\t\t\t\t<SidebarNavigationScreenDetailsPanel\n\t\t\t\t\tspacing={ 5 }\n\t\t\t\t\ttitle={ __( 'Details' ) }\n\t\t\t\t>\n\t\t\t\t\t{ details.map( ( { label, value } ) => (\n\t\t\t\t\t\t<SidebarNavigationScreenDetailsPanelRow key={ label }>\n\t\t\t\t\t\t\t<SidebarNavigationScreenDetailsPanelLabel>\n\t\t\t\t\t\t\t\t{ label }\n\t\t\t\t\t\t\t</SidebarNavigationScreenDetailsPanelLabel>\n\t\t\t\t\t\t\t<SidebarNavigationScreenDetailsPanelValue>\n\t\t\t\t\t\t\t\t{ value }\n\t\t\t\t\t\t\t</SidebarNavigationScreenDetailsPanelValue>\n\t\t\t\t\t\t</SidebarNavigationScreenDetailsPanelRow>\n\t\t\t\t\t) ) }\n\t\t\t\t</SidebarNavigationScreenDetailsPanel>\n\t\t\t) }\n\t\t</>\n\t);\n\n\treturn { title, description, content, footer };\n}\n"],"mappings":";;;;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AAKA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AAKA,IAAAK,QAAA,GAAAL,OAAA;AACA,IAAAM,sBAAA,GAAAC,sBAAA,CAAAP,OAAA;AACA,IAAAQ,yBAAA,GAAAD,sBAAA,CAAAP,OAAA;AACA,IAAAS,qCAAA,GAAAF,sBAAA,CAAAP,OAAA;AACA,IAAAU,oCAAA,GAAAV,OAAA;AAMA,IAAAW,UAAA,GAAAX,OAAA;AA1BA;AACA;AACA;;AAGA;AACA;AACA;;AAMA;AACA;AACA;;AAkBe,SAASY,iBAAiBA,CAAEC,QAAQ,EAAEC,MAAM,EAAG;EAC7D,MAAM;IAAEC,cAAc;IAAEC,QAAQ;IAAEC;EAAO,CAAC,GAAG,IAAAC,8BAAqB,EACjEL,QAAQ,EACRC,MACD,CAAC;EACD,MAAMK,iBAAiB,GAAG,IAAAC,eAAS,EAChCC,MAAM,IACPA,MAAM,CAAEC,aAAY,CAAC,CAACC,yCAAyC,CAAC,CAAC,EAClE,EACD,CAAC;EACD,MAAM;IAAEC,YAAY;IAAEC;EAAsB,CAAC,GAAG,IAAAL,eAAS,EAAIC,MAAM,IAAM;IACxE,MAAM;MAAEK,eAAe;MAAEC;IAAyB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,CAAC,GAAG,IAAAA,QAAE,EAAE,IAAK,CAC3C;IAER,CAAE,CAAC;EACJ;EAEA,MAAMwC,OAAO,GACZ,IAAArC,MAAA,CAAAC,aAAA,EAAAD,MAAA,CAAAsC,QAAA,QACG,IAAAC,iCAAwB,EAAEtE,QAAQ,EAAEC,MAAO,CAAC,EAC5C,CAAC,CAAEiC,OAAO,CAACU,MAAM,IAClB,IAAAb,MAAA,CAAAC,aAAA,EAACnC,oCAAA,CAAA0E,mCAAmC;IACnCC,OAAO,EAAG,CAAG;IACblD,KAAK,EAAG,IAAAM,QAAE,EAAE,SAAU;EAAG,GAEvBM,OAAO,CAACqB,GAAG,CAAE,CAAE;IAAElB,KAAK;IAAEC;EAAM,CAAC,KAChC,IAAAP,MAAA,CAAAC,aAAA,EAACnC,oCAAA,CAAA4E,sCAAsC;IAACC,GAAG,EAAGrC;EAAO,GACpD,IAAAN,MAAA,CAAAC,aAAA,EAACnC,oCAAA,CAAA8E,wCAAwC,QACtCtC,KACuC,CAAC,EAC3C,IAAAN,MAAA,CAAAC,aAAA,EAACnC,oCAAA,CAAA+E,wCAAwC,QACtCtC,KACuC,CACH,CACvC,CACkC,CAErC,CACF;EAED,OAAO;IAAEhB,KAAK;IAAEC,WAAW;IAAE6C,OAAO;IAAEvC;EAAO,CAAC;AAC/C"}
|
|
1
|
+
{"version":3,"names":["_changeCase","require","_i18n","_coreData","_editor","_data","_hooks","_useEditedEntityRecord","_interopRequireDefault","_useNavigationMenuContent","_sidebarNavigationScreenDetailsFooter","_sidebarNavigationScreenDetailsPanel","_constants","usePatternDetails","postType","postId","getDescription","getTitle","record","useEditedEntityRecord","templatePartAreas","useSelect","select","editorStore","__experimentalGetDefaultTemplatePartAreas","currentTheme","userPatternCategories","getCurrentTheme","getUserPatternCategories","coreStore","addedBy","useAddedBy","isAddedByActiveTheme","type","theme","stylesheet","title","description","text","PATTERN_TYPES","user","sprintf","__","footer","modified","_react","createElement","default","details","TEMPLATE_PART_POST_TYPE","push","label","value","wp_pattern_sync_status","PATTERN_SYNC_TYPES","unsynced","_x","wp_pattern_category","length","patternCategories","Map","forEach","userCategory","set","id","categories","filter","category","get","map","join","templatePartArea","find","area","areaDetailValue","sentenceCase","className","origin","TEMPLATE_ORIGINS","plugin","has_theme_file","isCustomized","content","Fragment","useNavigationMenuContent","SidebarNavigationScreenDetailsPanel","spacing","SidebarNavigationScreenDetailsPanelRow","key","SidebarNavigationScreenDetailsPanelLabel","SidebarNavigationScreenDetailsPanelValue"],"sources":["@wordpress/edit-site/src/components/sidebar-navigation-screen-pattern/use-pattern-details.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { sentenceCase } from 'change-case';\n\n/**\n * WordPress dependencies\n */\nimport { __, _x, sprintf } from '@wordpress/i18n';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as editorStore } from '@wordpress/editor';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { useAddedBy } from '../page-templates-template-parts/hooks';\nimport useEditedEntityRecord from '../use-edited-entity-record';\nimport useNavigationMenuContent from './use-navigation-menu-content';\nimport SidebarNavigationScreenDetailsFooter from '../sidebar-navigation-screen-details-footer';\nimport {\n\tSidebarNavigationScreenDetailsPanel,\n\tSidebarNavigationScreenDetailsPanelRow,\n\tSidebarNavigationScreenDetailsPanelLabel,\n\tSidebarNavigationScreenDetailsPanelValue,\n} from '../sidebar-navigation-screen-details-panel';\nimport {\n\tPATTERN_TYPES,\n\tTEMPLATE_PART_POST_TYPE,\n\tPATTERN_SYNC_TYPES,\n\tTEMPLATE_ORIGINS,\n} from '../../utils/constants';\n\nexport default function usePatternDetails( postType, postId ) {\n\tconst { getDescription, getTitle, record } = useEditedEntityRecord(\n\t\tpostType,\n\t\tpostId\n\t);\n\tconst templatePartAreas = useSelect(\n\t\t( select ) =>\n\t\t\tselect( editorStore ).__experimentalGetDefaultTemplatePartAreas(),\n\t\t[]\n\t);\n\tconst { currentTheme, userPatternCategories } = useSelect( ( select ) => {\n\t\tconst { getCurrentTheme, getUserPatternCategories } =\n\t\t\tselect( coreStore );\n\n\t\treturn {\n\t\t\tcurrentTheme: getCurrentTheme(),\n\t\t\tuserPatternCategories: getUserPatternCategories(),\n\t\t};\n\t}, [] );\n\n\tconst addedBy = useAddedBy( postType, postId );\n\tconst isAddedByActiveTheme =\n\t\taddedBy.type === 'theme' && record.theme === currentTheme?.stylesheet;\n\tconst title = getTitle();\n\tlet description = getDescription();\n\n\tif ( ! description && addedBy.text ) {\n\t\tdescription =\n\t\t\tpostType === PATTERN_TYPES.user\n\t\t\t\t? sprintf(\n\t\t\t\t\t\t// translators: %s: pattern title e.g: \"Header\".\n\t\t\t\t\t\t__( 'This is the %s pattern.' ),\n\t\t\t\t\t\tgetTitle()\n\t\t\t\t )\n\t\t\t\t: sprintf(\n\t\t\t\t\t\t// translators: %s: template part title e.g: \"Header\".\n\t\t\t\t\t\t__( 'This is the %s template part.' ),\n\t\t\t\t\t\tgetTitle()\n\t\t\t\t );\n\t}\n\n\tif ( ! description && postType === PATTERN_TYPES.user && record?.title ) {\n\t\tdescription = sprintf(\n\t\t\t// translators: %s: user created pattern title e.g. \"Footer\".\n\t\t\t__( 'This is the %s pattern.' ),\n\t\t\trecord.title\n\t\t);\n\t}\n\n\tconst footer = record?.modified ? (\n\t\t<SidebarNavigationScreenDetailsFooter record={ record } />\n\t) : null;\n\n\tconst details = [];\n\n\tif (\n\t\tpostType === PATTERN_TYPES.user ||\n\t\tpostType === TEMPLATE_PART_POST_TYPE\n\t) {\n\t\tdetails.push( {\n\t\t\tlabel: __( 'Syncing' ),\n\t\t\tvalue:\n\t\t\t\trecord.wp_pattern_sync_status === PATTERN_SYNC_TYPES.unsynced\n\t\t\t\t\t? _x(\n\t\t\t\t\t\t\t'Not synced',\n\t\t\t\t\t\t\t'Text that indicates that the pattern is not synchronized'\n\t\t\t\t\t )\n\t\t\t\t\t: _x(\n\t\t\t\t\t\t\t'Synced',\n\t\t\t\t\t\t\t'Text that indicates that the pattern is synchronized'\n\t\t\t\t\t ),\n\t\t} );\n\n\t\tif ( record.wp_pattern_category?.length === 0 ) {\n\t\t\tdetails.push( {\n\t\t\t\tlabel: __( 'Categories' ),\n\t\t\t\tvalue: __( 'Uncategorized' ),\n\t\t\t} );\n\t\t}\n\t\tif ( record.wp_pattern_category?.length > 0 ) {\n\t\t\tconst patternCategories = new Map();\n\t\t\tuserPatternCategories.forEach( ( userCategory ) =>\n\t\t\t\tpatternCategories.set( userCategory.id, userCategory )\n\t\t\t);\n\n\t\t\tconst categories = record.wp_pattern_category\n\t\t\t\t.filter( ( category ) => patternCategories.get( category ) )\n\t\t\t\t.map( ( category ) => patternCategories.get( category ).label );\n\n\t\t\tdetails.push( {\n\t\t\t\tlabel: __( 'Categories' ),\n\t\t\t\tvalue: categories.length > 0 ? categories.join( ', ' ) : '',\n\t\t\t} );\n\t\t}\n\t}\n\n\tif ( postType === TEMPLATE_PART_POST_TYPE ) {\n\t\tconst templatePartArea = templatePartAreas.find(\n\t\t\t( area ) => area.area === record.area\n\t\t);\n\n\t\tlet areaDetailValue = templatePartArea?.label;\n\n\t\tif ( ! areaDetailValue ) {\n\t\t\tareaDetailValue = record.area\n\t\t\t\t? sprintf(\n\t\t\t\t\t\t// translators: %s: Sentenced cased template part area e.g: \"My custom area\".\n\t\t\t\t\t\t__( '%s (removed)' ),\n\t\t\t\t\t\tsentenceCase( record.area )\n\t\t\t\t )\n\t\t\t\t: __( 'None' );\n\t\t}\n\n\t\tdetails.push( { label: __( 'Area' ), value: areaDetailValue } );\n\t}\n\n\tif (\n\t\tpostType === TEMPLATE_PART_POST_TYPE &&\n\t\taddedBy.text &&\n\t\t! isAddedByActiveTheme\n\t) {\n\t\tdetails.push( {\n\t\t\tlabel: __( 'Added by' ),\n\t\t\tvalue: (\n\t\t\t\t<span className=\"edit-site-sidebar-navigation-screen-pattern__added-by-description-author\">\n\t\t\t\t\t{ addedBy.text }\n\t\t\t\t</span>\n\t\t\t),\n\t\t} );\n\t}\n\n\tif (\n\t\tpostType === TEMPLATE_PART_POST_TYPE &&\n\t\taddedBy.text &&\n\t\t( record.origin === TEMPLATE_ORIGINS.plugin ||\n\t\t\trecord.has_theme_file === true )\n\t) {\n\t\tdetails.push( {\n\t\t\tlabel: __( 'Customized' ),\n\t\t\tvalue: (\n\t\t\t\t<span className=\"edit-site-sidebar-navigation-screen-pattern__added-by-description-customized\">\n\t\t\t\t\t{ addedBy.isCustomized ? __( 'Yes' ) : __( 'No' ) }\n\t\t\t\t</span>\n\t\t\t),\n\t\t} );\n\t}\n\n\tconst content = (\n\t\t<>\n\t\t\t{ useNavigationMenuContent( postType, postId ) }\n\t\t\t{ !! details.length && (\n\t\t\t\t<SidebarNavigationScreenDetailsPanel\n\t\t\t\t\tspacing={ 5 }\n\t\t\t\t\ttitle={ __( 'Details' ) }\n\t\t\t\t>\n\t\t\t\t\t{ details.map( ( { label, value } ) => (\n\t\t\t\t\t\t<SidebarNavigationScreenDetailsPanelRow key={ label }>\n\t\t\t\t\t\t\t<SidebarNavigationScreenDetailsPanelLabel>\n\t\t\t\t\t\t\t\t{ label }\n\t\t\t\t\t\t\t</SidebarNavigationScreenDetailsPanelLabel>\n\t\t\t\t\t\t\t<SidebarNavigationScreenDetailsPanelValue>\n\t\t\t\t\t\t\t\t{ value }\n\t\t\t\t\t\t\t</SidebarNavigationScreenDetailsPanelValue>\n\t\t\t\t\t\t</SidebarNavigationScreenDetailsPanelRow>\n\t\t\t\t\t) ) }\n\t\t\t\t</SidebarNavigationScreenDetailsPanel>\n\t\t\t) }\n\t\t</>\n\t);\n\n\treturn { title, description, content, footer };\n}\n"],"mappings":";;;;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AAKA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AAKA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,sBAAA,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AA,EAACnC,oCAAA,CAAA8E,wCAAwC,QACtCtC,KACuC,CAAC,EAC3C,IAAAN,MAAA,CAAAC,aAAA,EAACnC,oCAAA,CAAA+E,wCAAwC,QACtCtC,KACuC,CACH,CACvC,CACkC,CAErC,CACF;EAED,OAAO;IAAEhB,KAAK;IAAEC,WAAW;IAAE6C,OAAO;IAAEvC;EAAO,CAAC;AAC/C"}
|
|
@@ -17,7 +17,7 @@ var _useEditedEntityRecord = _interopRequireDefault(require("../use-edited-entit
|
|
|
17
17
|
var _lockUnlock = require("../../lock-unlock");
|
|
18
18
|
var _store = require("../../store");
|
|
19
19
|
var _sidebarButton = _interopRequireDefault(require("../sidebar-button"));
|
|
20
|
-
var
|
|
20
|
+
var _hooks = require("../page-templates-template-parts/hooks");
|
|
21
21
|
var _templateActions = _interopRequireDefault(require("../template-actions"));
|
|
22
22
|
var _homeTemplateDetails = _interopRequireDefault(require("./home-template-details"));
|
|
23
23
|
var _sidebarNavigationScreenDetailsFooter = _interopRequireDefault(require("../sidebar-navigation-screen-details-footer"));
|
|
@@ -36,7 +36,7 @@ function useTemplateDetails(postType, postId) {
|
|
|
36
36
|
record
|
|
37
37
|
} = (0, _useEditedEntityRecord.default)(postType, postId);
|
|
38
38
|
const currentTheme = (0, _data.useSelect)(select => select(_coreData.store).getCurrentTheme(), []);
|
|
39
|
-
const addedBy = (0,
|
|
39
|
+
const addedBy = (0, _hooks.useAddedBy)(postType, postId);
|
|
40
40
|
const isAddedByActiveTheme = addedBy.type === 'theme' && record.theme === currentTheme?.stylesheet;
|
|
41
41
|
const title = getTitle();
|
|
42
42
|
let descriptionText = getDescription();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_i18n","require","_data","_icons","_components","_coreData","_templateAreas","_interopRequireDefault","_sidebarNavigationScreen","_useEditedEntityRecord","_lockUnlock","_store","_sidebarButton","
|
|
1
|
+
{"version":3,"names":["_i18n","require","_data","_icons","_components","_coreData","_templateAreas","_interopRequireDefault","_sidebarNavigationScreen","_useEditedEntityRecord","_lockUnlock","_store","_sidebarButton","_hooks","_templateActions","_homeTemplateDetails","_sidebarNavigationScreenDetailsFooter","useTemplateDetails","postType","postId","getDescription","getTitle","record","useEditedEntityRecord","currentTheme","useSelect","select","coreStore","getCurrentTheme","addedBy","useAddedBy","isAddedByActiveTheme","type","theme","stylesheet","title","descriptionText","text","__","content","slug","_react","createElement","Fragment","default","footer","modified","description","className","imageUrl","src","alt","width","height","Icon","icon","isCustomized","_x","SidebarNavigationScreenTemplate","navigator","useNavigator","params","setCanvasMode","unlock","useDispatch","editSiteStore","actions","toggleProps","as","SidebarButton","onRemove","goTo","onClick","label","pencil"],"sources":["@wordpress/edit-site/src/components/sidebar-navigation-screen-template/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, _x } from '@wordpress/i18n';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { pencil } from '@wordpress/icons';\nimport {\n\t__experimentalUseNavigator as useNavigator,\n\tIcon,\n} from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\n/**\n * Internal dependencies\n */\nimport TemplateAreas from './template-areas';\nimport SidebarNavigationScreen from '../sidebar-navigation-screen';\nimport useEditedEntityRecord from '../use-edited-entity-record';\nimport { unlock } from '../../lock-unlock';\nimport { store as editSiteStore } from '../../store';\nimport SidebarButton from '../sidebar-button';\nimport { useAddedBy } from '../page-templates-template-parts/hooks';\nimport TemplateActions from '../template-actions';\nimport HomeTemplateDetails from './home-template-details';\nimport SidebarNavigationScreenDetailsFooter from '../sidebar-navigation-screen-details-footer';\n\nfunction useTemplateDetails( postType, postId ) {\n\tconst { getDescription, getTitle, record } = useEditedEntityRecord(\n\t\tpostType,\n\t\tpostId\n\t);\n\tconst currentTheme = useSelect(\n\t\t( select ) => select( coreStore ).getCurrentTheme(),\n\t\t[]\n\t);\n\tconst addedBy = useAddedBy( postType, postId );\n\tconst isAddedByActiveTheme =\n\t\taddedBy.type === 'theme' && record.theme === currentTheme?.stylesheet;\n\tconst title = getTitle();\n\tlet descriptionText = getDescription();\n\n\tif ( ! descriptionText && addedBy.text ) {\n\t\tdescriptionText = __(\n\t\t\t'This is a custom template that can be applied manually to any Post or Page.'\n\t\t);\n\t}\n\n\tconst content =\n\t\trecord?.slug === 'home' || record?.slug === 'index' ? (\n\t\t\t<>\n\t\t\t\t<HomeTemplateDetails />\n\t\t\t\t<TemplateAreas />\n\t\t\t</>\n\t\t) : (\n\t\t\t<TemplateAreas />\n\t\t);\n\n\tconst footer = record?.modified ? (\n\t\t<SidebarNavigationScreenDetailsFooter record={ record } />\n\t) : null;\n\n\tconst description = (\n\t\t<>\n\t\t\t{ descriptionText }\n\n\t\t\t{ addedBy.text && ! isAddedByActiveTheme && (\n\t\t\t\t<span className=\"edit-site-sidebar-navigation-screen-template__added-by-description\">\n\t\t\t\t\t<span className=\"edit-site-sidebar-navigation-screen-template__added-by-description-author\">\n\t\t\t\t\t\t<span className=\"edit-site-sidebar-navigation-screen-template__added-by-description-author-icon\">\n\t\t\t\t\t\t\t{ addedBy.imageUrl ? (\n\t\t\t\t\t\t\t\t<img\n\t\t\t\t\t\t\t\t\tsrc={ addedBy.imageUrl }\n\t\t\t\t\t\t\t\t\talt=\"\"\n\t\t\t\t\t\t\t\t\twidth=\"24\"\n\t\t\t\t\t\t\t\t\theight=\"24\"\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t<Icon icon={ addedBy.icon } />\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</span>\n\t\t\t\t\t\t{ addedBy.text }\n\t\t\t\t\t</span>\n\n\t\t\t\t\t{ addedBy.isCustomized && (\n\t\t\t\t\t\t<span className=\"edit-site-sidebar-navigation-screen-template__added-by-description-customized\">\n\t\t\t\t\t\t\t{ _x( '(Customized)', 'template' ) }\n\t\t\t\t\t\t</span>\n\t\t\t\t\t) }\n\t\t\t\t</span>\n\t\t\t) }\n\t\t</>\n\t);\n\n\treturn { title, description, content, footer };\n}\n\nexport default function SidebarNavigationScreenTemplate() {\n\tconst navigator = useNavigator();\n\tconst {\n\t\tparams: { postType, postId },\n\t} = navigator;\n\tconst { setCanvasMode } = unlock( useDispatch( editSiteStore ) );\n\tconst { title, content, description, footer } = useTemplateDetails(\n\t\tpostType,\n\t\tpostId\n\t);\n\n\treturn (\n\t\t<SidebarNavigationScreen\n\t\t\ttitle={ title }\n\t\t\tactions={\n\t\t\t\t<>\n\t\t\t\t\t<TemplateActions\n\t\t\t\t\t\tpostType={ postType }\n\t\t\t\t\t\tpostId={ postId }\n\t\t\t\t\t\ttoggleProps={ { as: SidebarButton } }\n\t\t\t\t\t\tonRemove={ () => {\n\t\t\t\t\t\t\tnavigator.goTo( `/${ postType }/all` );\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t\t<SidebarButton\n\t\t\t\t\t\tonClick={ () => setCanvasMode( 'edit' ) }\n\t\t\t\t\t\tlabel={ __( 'Edit' ) }\n\t\t\t\t\t\ticon={ pencil }\n\t\t\t\t\t/>\n\t\t\t\t</>\n\t\t\t}\n\t\t\tdescription={ description }\n\t\t\tcontent={ content }\n\t\t\tfooter={ footer }\n\t\t/>\n\t);\n}\n"],"mappings":";;;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AAIA,IAAAI,SAAA,GAAAJ,OAAA;AAIA,IAAAK,cAAA,GAAAC,sBAAA,CAAAN,OAAA;AACA,IAAAO,wBAAA,GAAAD,sBAAA,CAAAN,OAAA;AACA,IAAAQ,sBAAA,GAAAF,sBAAA,CAAAN,OAAA;AACA,IAAAS,WAAA,GAAAT,OAAA;AACA,IAAAU,MAAA,GAAAV,OAAA;AACA,IAAAW,cAAA,GAAAL,sBAAA,CAAAN,OAAA;AACA,IAAAY,MAAA,GAAAZ,OAAA;AACA,IAAAa,gBA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;IAAEG;EAAc,CAAC,GAAG,IAAAC,kBAAM,EAAE,IAAAC,iBAAW,EAAEC,YAAc,CAAE,CAAC;EAChE,MAAM;IAAE9B,KAAK;IAAEI,OAAO;IAAEQ,WAAW;IAAEF;EAAO,CAAC,GAAG5B,kBAAkB,CACjEC,QAAQ,EACRC,MACD,CAAC;EAED,OACC,IAAAsB,MAAA,CAAAC,aAAA,EAAClC,wBAAA,CAAAoC,OAAuB;IACvBT,KAAK,EAAGA,KAAO;IACf+B,OAAO,EACN,IAAAzB,MAAA,CAAAC,aAAA,EAAAD,MAAA,CAAAE,QAAA,QACC,IAAAF,MAAA,CAAAC,aAAA,EAAC5B,gBAAA,CAAA8B,OAAe;MACf1B,QAAQ,EAAGA,QAAU;MACrBC,MAAM,EAAGA,MAAQ;MACjBgD,WAAW,EAAG;QAAEC,EAAE,EAAEC;MAAc,CAAG;MACrCC,QAAQ,EAAGA,CAAA,KAAM;QAChBX,SAAS,CAACY,IAAI,CAAG,IAAIrD,QAAU,MAAM,CAAC;MACvC;IAAG,CACH,CAAC,EACF,IAAAuB,MAAA,CAAAC,aAAA,EAAC9B,cAAA,CAAAgC,OAAa;MACb4B,OAAO,EAAGA,CAAA,KAAMV,aAAa,CAAE,MAAO,CAAG;MACzCW,KAAK,EAAG,IAAAnC,QAAE,EAAE,MAAO,CAAG;MACtBiB,IAAI,EAAGmB;IAAQ,CACf,CACA,CACF;IACD3B,WAAW,EAAGA,WAAa;IAC3BR,OAAO,EAAGA,OAAS;IACnBM,MAAM,EAAGA;EAAQ,CACjB,CAAC;AAEJ"}
|
|
@@ -10,7 +10,7 @@ var _coreData = require("@wordpress/core-data");
|
|
|
10
10
|
var _element = require("@wordpress/element");
|
|
11
11
|
var _components = require("@wordpress/components");
|
|
12
12
|
var _dataviewItem = _interopRequireDefault(require("../sidebar-dataviews/dataview-item"));
|
|
13
|
-
var
|
|
13
|
+
var _hooks = require("../page-templates-template-parts/hooks");
|
|
14
14
|
var _icons = require("@wordpress/icons");
|
|
15
15
|
/**
|
|
16
16
|
* WordPress dependencies
|
|
@@ -28,7 +28,7 @@ function TemplateDataviewItem({
|
|
|
28
28
|
const {
|
|
29
29
|
text,
|
|
30
30
|
icon
|
|
31
|
-
} = (0,
|
|
31
|
+
} = (0, _hooks.useAddedBy)(template.type, template.id);
|
|
32
32
|
return (0, _react.createElement)(_dataviewItem.default, {
|
|
33
33
|
key: text,
|
|
34
34
|
slug: text,
|
|
@@ -41,7 +41,7 @@ function TemplateDataviewItem({
|
|
|
41
41
|
function DataviewsTemplatesSidebarContent({
|
|
42
42
|
activeView,
|
|
43
43
|
postType,
|
|
44
|
-
|
|
44
|
+
title
|
|
45
45
|
}) {
|
|
46
46
|
const {
|
|
47
47
|
records
|
|
@@ -61,7 +61,7 @@ function DataviewsTemplatesSidebarContent({
|
|
|
61
61
|
}, [records]);
|
|
62
62
|
return (0, _react.createElement)(_components.__experimentalItemGroup, null, (0, _react.createElement)(_dataviewItem.default, {
|
|
63
63
|
slug: 'all',
|
|
64
|
-
title:
|
|
64
|
+
title: title,
|
|
65
65
|
icon: _icons.layout,
|
|
66
66
|
isActive: activeView === 'all',
|
|
67
67
|
isCustom: "false"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_coreData","require","_element","_components","_dataviewItem","_interopRequireDefault","
|
|
1
|
+
{"version":3,"names":["_coreData","require","_element","_components","_dataviewItem","_interopRequireDefault","_hooks","_icons","EMPTY_ARRAY","TemplateDataviewItem","template","isActive","text","icon","useAddedBy","type","id","_react","createElement","default","key","slug","title","isCustom","DataviewsTemplatesSidebarContent","activeView","postType","records","useEntityRecords","per_page","firstItemPerAuthorText","useMemo","_ref","firstItemPerAuthor","reduce","acc","author","author_text","Object","values","__experimentalItemGroup","layout","map"],"sources":["@wordpress/edit-site/src/components/sidebar-navigation-screen-templates-browse/content.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEntityRecords } from '@wordpress/core-data';\nimport { useMemo } from '@wordpress/element';\nimport { __experimentalItemGroup as ItemGroup } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport DataViewItem from '../sidebar-dataviews/dataview-item';\nimport { useAddedBy } from '../page-templates-template-parts/hooks';\nimport { layout } from '@wordpress/icons';\n\nconst EMPTY_ARRAY = [];\n\nfunction TemplateDataviewItem( { template, isActive } ) {\n\tconst { text, icon } = useAddedBy( template.type, template.id );\n\treturn (\n\t\t<DataViewItem\n\t\t\tkey={ text }\n\t\t\tslug={ text }\n\t\t\ttitle={ text }\n\t\t\ticon={ icon }\n\t\t\tisActive={ isActive }\n\t\t\tisCustom=\"false\"\n\t\t/>\n\t);\n}\n\nexport default function DataviewsTemplatesSidebarContent( {\n\tactiveView,\n\tpostType,\n\ttitle,\n} ) {\n\tconst { records } = useEntityRecords( 'postType', postType, {\n\t\tper_page: -1,\n\t} );\n\tconst firstItemPerAuthorText = useMemo( () => {\n\t\tconst firstItemPerAuthor = records?.reduce( ( acc, template ) => {\n\t\t\tconst author = template.author_text;\n\t\t\tif ( author && ! acc[ author ] ) {\n\t\t\t\tacc[ author ] = template;\n\t\t\t}\n\t\t\treturn acc;\n\t\t}, {} );\n\t\treturn (\n\t\t\t( firstItemPerAuthor && Object.values( firstItemPerAuthor ) ) ??\n\t\t\tEMPTY_ARRAY\n\t\t);\n\t}, [ records ] );\n\n\treturn (\n\t\t<ItemGroup>\n\t\t\t<DataViewItem\n\t\t\t\tslug={ 'all' }\n\t\t\t\ttitle={ title }\n\t\t\t\ticon={ layout }\n\t\t\t\tisActive={ activeView === 'all' }\n\t\t\t\tisCustom=\"false\"\n\t\t\t/>\n\t\t\t{ firstItemPerAuthorText.map( ( template ) => {\n\t\t\t\treturn (\n\t\t\t\t\t<TemplateDataviewItem\n\t\t\t\t\t\tkey={ template.author_text }\n\t\t\t\t\t\ttemplate={ template }\n\t\t\t\t\t\tisActive={ activeView === template.author_text }\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</ItemGroup>\n\t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MAAM,CAAE,GAAG1B,QAAQ;MACzB;MACA,OAAOyB,GAAG;IACX,CAAC,EAAE,CAAC,CAAE,CAAC;IACP,QAAAH,IAAA,GACGC,kBAAkB,IAAIK,MAAM,CAACC,MAAM,CAAEN,kBAAmB,CAAC,cAAAD,IAAA,cAAAA,IAAA,GAC3DxB,WAAW;EAEb,CAAC,EAAE,CAAEmB,OAAO,CAAG,CAAC;EAEhB,OACC,IAAAV,MAAA,CAAAC,aAAA,EAACf,WAAA,CAAAqC,uBAAS,QACT,IAAAvB,MAAA,CAAAC,aAAA,EAACd,aAAA,CAAAe,OAAY;IACZE,IAAI,EAAG,KAAO;IACdC,KAAK,EAAGA,KAAO;IACfT,IAAI,EAAG4B,aAAQ;IACf9B,QAAQ,EAAGc,UAAU,KAAK,KAAO;IACjCF,QAAQ,EAAC;EAAO,CAChB,CAAC,EACAO,sBAAsB,CAACY,GAAG,CAAIhC,QAAQ,IAAM;IAC7C,OACC,IAAAO,MAAA,CAAAC,aAAA,EAACT,oBAAoB;MACpBW,GAAG,EAAGV,QAAQ,CAAC2B,WAAa;MAC5B3B,QAAQ,EAAGA,QAAU;MACrBC,QAAQ,EAAGc,UAAU,KAAKf,QAAQ,CAAC2B;IAAa,CAChD,CAAC;EAEJ,CAAE,CACQ,CAAC;AAEd"}
|
|
@@ -25,13 +25,15 @@ var _content = _interopRequireDefault(require("./content"));
|
|
|
25
25
|
|
|
26
26
|
const config = {
|
|
27
27
|
[_constants.TEMPLATE_POST_TYPE]: {
|
|
28
|
-
title: (0, _i18n.__)('
|
|
29
|
-
description: (0, _i18n.__)('Create new templates, or reset any customizations made to the templates supplied by your theme.')
|
|
28
|
+
title: (0, _i18n.__)('Manage templates'),
|
|
29
|
+
description: (0, _i18n.__)('Create new templates, or reset any customizations made to the templates supplied by your theme.'),
|
|
30
|
+
contentTitle: (0, _i18n.__)('All templates')
|
|
30
31
|
},
|
|
31
32
|
[_constants.TEMPLATE_PART_POST_TYPE]: {
|
|
32
|
-
title: (0, _i18n.__)('
|
|
33
|
+
title: (0, _i18n.__)('Manage template parts'),
|
|
33
34
|
description: (0, _i18n.__)('Create new template parts, or reset any customizations made to the template parts supplied by your theme.'),
|
|
34
|
-
backPath: '/patterns'
|
|
35
|
+
backPath: '/patterns',
|
|
36
|
+
contentTitle: (0, _i18n.__)('All template parts')
|
|
35
37
|
}
|
|
36
38
|
};
|
|
37
39
|
const {
|
|
@@ -63,7 +65,7 @@ function SidebarNavigationScreenTemplatesBrowse() {
|
|
|
63
65
|
content: (0, _react.createElement)(_content.default, {
|
|
64
66
|
activeView: activeView,
|
|
65
67
|
postType: postType,
|
|
66
|
-
|
|
68
|
+
title: config[postType].contentTitle
|
|
67
69
|
})
|
|
68
70
|
});
|
|
69
71
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_i18n","require","_data","_components","_router","_sidebarNavigationScreen","_interopRequireDefault","_store","_constants","_lockUnlock","_content","config","TEMPLATE_POST_TYPE","title","__","description","TEMPLATE_PART_POST_TYPE","backPath","useLocation","unlock","routerPrivateApis","SidebarNavigationScreenTemplatesBrowse","params","postType","useNavigator","didAccessPatternsPage","activeView","isTemplatePartsMode","useSelect","select","editSiteStore","getSettings","supportsTemplatePartsMode","_react","createElement","default","isRoot","content"],"sources":["@wordpress/edit-site/src/components/sidebar-navigation-screen-templates-browse/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\n\nimport { __experimentalUseNavigator as useNavigator } from '@wordpress/components';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\n\n/**\n * Internal dependencies\n */\nimport SidebarNavigationScreen from '../sidebar-navigation-screen';\nimport { store as editSiteStore } from '../../store';\nimport {\n\tTEMPLATE_POST_TYPE,\n\tTEMPLATE_PART_POST_TYPE,\n} from '../../utils/constants';\nimport { unlock } from '../../lock-unlock';\nimport DataviewsTemplatesSidebarContent from './content';\n\nconst config = {\n\t[ TEMPLATE_POST_TYPE ]: {\n\t\ttitle: __( '
|
|
1
|
+
{"version":3,"names":["_i18n","require","_data","_components","_router","_sidebarNavigationScreen","_interopRequireDefault","_store","_constants","_lockUnlock","_content","config","TEMPLATE_POST_TYPE","title","__","description","contentTitle","TEMPLATE_PART_POST_TYPE","backPath","useLocation","unlock","routerPrivateApis","SidebarNavigationScreenTemplatesBrowse","params","postType","useNavigator","didAccessPatternsPage","activeView","isTemplatePartsMode","useSelect","select","editSiteStore","getSettings","supportsTemplatePartsMode","_react","createElement","default","isRoot","content"],"sources":["@wordpress/edit-site/src/components/sidebar-navigation-screen-templates-browse/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\n\nimport { __experimentalUseNavigator as useNavigator } from '@wordpress/components';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\n\n/**\n * Internal dependencies\n */\nimport SidebarNavigationScreen from '../sidebar-navigation-screen';\nimport { store as editSiteStore } from '../../store';\nimport {\n\tTEMPLATE_POST_TYPE,\n\tTEMPLATE_PART_POST_TYPE,\n} from '../../utils/constants';\nimport { unlock } from '../../lock-unlock';\nimport DataviewsTemplatesSidebarContent from './content';\n\nconst config = {\n\t[ TEMPLATE_POST_TYPE ]: {\n\t\ttitle: __( 'Manage templates' ),\n\t\tdescription: __(\n\t\t\t'Create new templates, or reset any customizations made to the templates supplied by your theme.'\n\t\t),\n\t\tcontentTitle: __( 'All templates' ),\n\t},\n\t[ TEMPLATE_PART_POST_TYPE ]: {\n\t\ttitle: __( 'Manage template parts' ),\n\t\tdescription: __(\n\t\t\t'Create new template parts, or reset any customizations made to the template parts supplied by your theme.'\n\t\t),\n\t\tbackPath: '/patterns',\n\t\tcontentTitle: __( 'All template parts' ),\n\t},\n};\n\nconst { useLocation } = unlock( routerPrivateApis );\n\nexport default function SidebarNavigationScreenTemplatesBrowse() {\n\tconst {\n\t\tparams: { postType },\n\t} = useNavigator();\n\tconst {\n\t\tparams: { didAccessPatternsPage, activeView = 'all' },\n\t} = useLocation();\n\n\tconst isTemplatePartsMode = useSelect( ( select ) => {\n\t\treturn !! select( editSiteStore ).getSettings()\n\t\t\t.supportsTemplatePartsMode;\n\t}, [] );\n\n\treturn (\n\t\t<SidebarNavigationScreen\n\t\t\t// If a classic theme that supports template parts has never\n\t\t\t// accessed the Patterns page, return to the dashboard.\n\t\t\tisRoot={ isTemplatePartsMode && ! didAccessPatternsPage }\n\t\t\ttitle={ config[ postType ].title }\n\t\t\tdescription={ config[ postType ].description }\n\t\t\tbackPath={ config[ postType ].backPath }\n\t\t\tcontent={\n\t\t\t\t<DataviewsTemplatesSidebarContent\n\t\t\t\t\tactiveView={ activeView }\n\t\t\t\t\tpostType={ postType }\n\t\t\t\t\ttitle={ config[ postType ].contentTitle }\n\t\t\t\t/>\n\t\t\t}\n\t\t/>\n\t);\n}\n"],"mappings":";;;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AAEA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AAKA,IAAAI,wBAAA,GAAAC,sBAAA,CAAAL,OAAA;AACA,IAAAM,MAAA,GAAAN,OAAA;AACA,IAAAO,UAAA,GAAAP,OAAA;AAIA,IAAAQ,WAAA,GAAAR,OAAA;AACA,IAAAS,QAAA,GAAAJ,sBAAA,CAAAL,OAAA;AAnBA;AACA;AACA;;AAOA;AACA;AACA;;AAUA,MAAMU,MAAM,GAAG;EACd,CAAEC,6BAAkB,GAAI;IACvBC,KAAK,EAAE,IAAAC,QAAE,EAAE,kBAAmB,CAAC;IAC/BC,WAAW,EAAE,IAAAD,QAAE,EACd,iGACD,CAAC;IACDE,YAAY,EAAE,IAAAF,QAAE,EAAE,eAAgB;EACnC,CAAC;EACD,CAAEG,kCAAuB,GAAI;IAC5BJ,KAAK,EAAE,IAAAC,QAAE,EAAE,uBAAwB,CAAC;IACpCC,WAAW,EAAE,IAAAD,QAAE,EACd,2GACD,CAAC;IACDI,QAAQ,EAAE,WAAW;IACrBF,YAAY,EAAE,IAAAF,QAAE,EAAE,oBAAqB;EACxC;AACD,CAAC;AAED,MAAM;EAAEK;AAAY,CAAC,GAAG,IAAAC,kBAAM,EAAEC,mBAAkB,CAAC;AAEpC,SAASC,sCAAsCA,CAAA,EAAG;EAChE,MAAM;IACLC,MAAM,EAAE;MAAEC;IAAS;EACpB,CAAC,GAAG,IAAAC,sCAAY,EAAC,CAAC;EAClB,MAAM;IACLF,MAAM,EAAE;MAAEG,qBAAqB;MAAEC,UAAU,GAAG;IAAM;EACrD,CAAC,GAAGR,WAAW,CAAC,CAAC;EAEjB,MAAMS,mBAAmB,GAAG,IAAAC,eAAS,EAAIC,MAAM,IAAM;IACpD,OAAO,CAAC,CAAEA,MAAM,CAAEC,YAAc,CAAC,CAACC,WAAW,CAAC,CAAC,CAC7CC,yBAAyB;EAC5B,CAAC,EAAE,EAAG,CAAC;EAEP,OACC,IAAAC,MAAA,CAAAC,aAAA,EAAC9B,wBAAA,CAAA+B;EACA;EACA;EAAA;IACAC,MAAM,EAAGT,mBAAmB,IAAI,CAAEF,qBAAuB;IACzDb,KAAK,EAAGF,MAAM,CAAEa,QAAQ,CAAE,CAACX,KAAO;IAClCE,WAAW,EAAGJ,MAAM,CAAEa,QAAQ,CAAE,CAACT,WAAa;IAC9CG,QAAQ,EAAGP,MAAM,CAAEa,QAAQ,CAAE,CAACN,QAAU;IACxCoB,OAAO,EACN,IAAAJ,MAAA,CAAAC,aAAA,EAACzB,QAAA,CAAA0B,OAAgC;MAChCT,UAAU,EAAGA,UAAY;MACzBH,QAAQ,EAAGA,QAAU;MACrBX,KAAK,EAAGF,MAAM,CAAEa,QAAQ,CAAE,CAACR;IAAc,CACzC;EACD,CACD,CAAC;AAEJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_components","require","_i18n","_element","_blockEditor","_data","_compose","_preferences","_blocks","_coreData","_store","_constants","useFallbackTemplateContent","slug","isCustom","useSelect","select","getEntityRecord","getDefaultTemplateId","coreStore","templateId","is_custom","ignore_empty","TEMPLATE_POST_TYPE","content","raw","undefined","useStartPatterns","fallbackContent","patterns","getEditedPostType","getEditedPostId","editSiteStore","getBlockPatterns","postId","postType","record","currentThemeStylesheet","getCurrentTheme","stylesheet","injectThemeAttributeInBlockTemplateContent","block","innerBlocks","find","innerBlock","name","map","attributes","theme","useMemo","blocks","parse","title","__","filter","pattern","Array","isArray","templateTypes","some","templateType","startsWith","PatternSelection","onChoosePattern","onChange","useEntityBlockEditor","blockPatterns","shownBlockPatterns","useAsyncList","_react","createElement","__experimentalBlockPatternsList","shownPatterns","onClickPattern","selection","StartModal","onClose","Modal","className","closeLabel","focusOnMount","onRequestClose","isFullScreen","Flex","justify","expanded","FlexItem","Button","variant","onClick","START_TEMPLATE_MODAL_STATES","INITIAL","CLOSED","StartTemplateOptions","modalState","setModalState","useState","shouldOpenModal","_postType","getEditedEntityRecord","hasEditsForEntityRecord","templateRecord","hasEdits","preferencesStore","get"],"sources":["@wordpress/edit-site/src/components/start-template-options/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Modal, Flex, FlexItem, Button } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useState, useMemo } from '@wordpress/element';\nimport { __experimentalBlockPatternsList as BlockPatternsList } from '@wordpress/block-editor';\nimport { useSelect } from '@wordpress/data';\nimport { useAsyncList } from '@wordpress/compose';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { parse } from '@wordpress/blocks';\nimport { store as coreStore, useEntityBlockEditor } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../store';\nimport { TEMPLATE_POST_TYPE } from '../../utils/constants';\n\nfunction useFallbackTemplateContent( slug, isCustom = false ) {\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecord, getDefaultTemplateId } =\n\t\t\t\tselect( coreStore );\n\t\t\tconst templateId = getDefaultTemplateId( {\n\t\t\t\tslug,\n\t\t\t\tis_custom: isCustom,\n\t\t\t\tignore_empty: true,\n\t\t\t} );\n\t\t\treturn templateId\n\t\t\t\t? getEntityRecord( 'postType', TEMPLATE_POST_TYPE, templateId )\n\t\t\t\t\t\t?.content?.raw\n\t\t\t\t: undefined;\n\t\t},\n\t\t[ slug, isCustom ]\n\t);\n}\n\nfunction useStartPatterns( fallbackContent ) {\n\tconst { slug, patterns } = useSelect( ( select ) => {\n\t\tconst { getEditedPostType, getEditedPostId } = select( editSiteStore );\n\t\tconst { getEntityRecord, getBlockPatterns } = select( coreStore );\n\t\tconst postId = getEditedPostId();\n\t\tconst postType = getEditedPostType();\n\t\tconst record = getEntityRecord( 'postType', postType, postId );\n\t\treturn {\n\t\t\tslug: record.slug,\n\t\t\tpatterns: getBlockPatterns(),\n\t\t};\n\t}, [] );\n\n\tconst currentThemeStylesheet = useSelect(\n\t\t( select ) => select( coreStore ).getCurrentTheme().stylesheet\n\t);\n\n\t// Duplicated from packages/block-library/src/pattern/edit.js.\n\tfunction injectThemeAttributeInBlockTemplateContent( block ) {\n\t\tif (\n\t\t\tblock.innerBlocks.find(\n\t\t\t\t( innerBlock ) => innerBlock.name === 'core/template-part'\n\t\t\t)\n\t\t) {\n\t\t\tblock.innerBlocks = block.innerBlocks.map( ( innerBlock ) => {\n\t\t\t\tif (\n\t\t\t\t\tinnerBlock.name === 'core/template-part' &&\n\t\t\t\t\tinnerBlock.attributes.theme === undefined\n\t\t\t\t) {\n\t\t\t\t\tinnerBlock.attributes.theme = currentThemeStylesheet;\n\t\t\t\t}\n\t\t\t\treturn innerBlock;\n\t\t\t} );\n\t\t}\n\n\t\tif (\n\t\t\tblock.name === 'core/template-part' &&\n\t\t\tblock.attributes.theme === undefined\n\t\t) {\n\t\t\tblock.attributes.theme = currentThemeStylesheet;\n\t\t}\n\t\treturn block;\n\t}\n\n\treturn useMemo( () => {\n\t\t// filter patterns that are supposed to be used in the current template being edited.\n\t\treturn [\n\t\t\t{\n\t\t\t\tname: 'fallback',\n\t\t\t\tblocks: parse( fallbackContent ),\n\t\t\t\ttitle: __( 'Fallback content' ),\n\t\t\t},\n\t\t\t...patterns\n\t\t\t\t.filter( ( pattern ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\tArray.isArray( pattern.templateTypes ) &&\n\t\t\t\t\t\tpattern.templateTypes.some( ( templateType ) =>\n\t\t\t\t\t\t\tslug.startsWith( templateType )\n\t\t\t\t\t\t)\n\t\t\t\t\t);\n\t\t\t\t} )\n\t\t\t\t.map( ( pattern ) => {\n\t\t\t\t\treturn {\n\t\t\t\t\t\t...pattern,\n\t\t\t\t\t\tblocks: parse( pattern.content ).map( ( block ) =>\n\t\t\t\t\t\t\tinjectThemeAttributeInBlockTemplateContent( block )\n\t\t\t\t\t\t),\n\t\t\t\t\t};\n\t\t\t\t} ),\n\t\t];\n\t}, [ fallbackContent, slug, patterns ] );\n}\n\nfunction PatternSelection( { fallbackContent, onChoosePattern, postType } ) {\n\tconst [ , , onChange ] = useEntityBlockEditor( 'postType', postType );\n\tconst blockPatterns = useStartPatterns( fallbackContent );\n\tconst shownBlockPatterns = useAsyncList( blockPatterns );\n\treturn (\n\t\t<BlockPatternsList\n\t\t\tblockPatterns={ blockPatterns }\n\t\t\tshownPatterns={ shownBlockPatterns }\n\t\t\tonClickPattern={ ( pattern, blocks ) => {\n\t\t\t\tonChange( blocks, { selection: undefined } );\n\t\t\t\tonChoosePattern();\n\t\t\t} }\n\t\t/>\n\t);\n}\n\nfunction StartModal( { slug, isCustom, onClose, postType } ) {\n\tconst fallbackContent = useFallbackTemplateContent( slug, isCustom );\n\tif ( ! fallbackContent ) {\n\t\treturn null;\n\t}\n\treturn (\n\t\t<Modal\n\t\t\tclassName=\"edit-site-start-template-options__modal\"\n\t\t\ttitle={ __( 'Choose a pattern' ) }\n\t\t\tcloseLabel={ __( 'Cancel' ) }\n\t\t\tfocusOnMount=\"firstElement\"\n\t\t\tonRequestClose={ onClose }\n\t\t\tisFullScreen={ true }\n\t\t>\n\t\t\t<div className=\"edit-site-start-template-options__modal-content\">\n\t\t\t\t<PatternSelection\n\t\t\t\t\tfallbackContent={ fallbackContent }\n\t\t\t\t\tslug={ slug }\n\t\t\t\t\tisCustom={ isCustom }\n\t\t\t\t\tpostType={ postType }\n\t\t\t\t\tonChoosePattern={ () => {\n\t\t\t\t\t\tonClose();\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t\t<Flex\n\t\t\t\tclassName=\"edit-site-start-template-options__modal__actions\"\n\t\t\t\tjustify=\"flex-end\"\n\t\t\t\texpanded={ false }\n\t\t\t>\n\t\t\t\t<FlexItem>\n\t\t\t\t\t<Button variant=\"tertiary\" onClick={ onClose }>\n\t\t\t\t\t\t{ __( 'Skip' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t</FlexItem>\n\t\t\t</Flex>\n\t\t</Modal>\n\t);\n}\n\nconst START_TEMPLATE_MODAL_STATES = {\n\tINITIAL: 'INITIAL',\n\tCLOSED: 'CLOSED',\n};\n\nexport default function StartTemplateOptions() {\n\tconst [ modalState, setModalState ] = useState(\n\t\tSTART_TEMPLATE_MODAL_STATES.INITIAL\n\t);\n\tconst { shouldOpenModal, slug, isCustom, postType } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEditedPostType, getEditedPostId } =\n\t\t\t\tselect( editSiteStore );\n\t\t\tconst _postType = getEditedPostType();\n\t\t\tconst postId = getEditedPostId();\n\t\t\tconst { getEditedEntityRecord, hasEditsForEntityRecord } =\n\t\t\t\tselect( coreStore );\n\t\t\tconst templateRecord = getEditedEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\t_postType,\n\t\t\t\tpostId\n\t\t\t);\n\t\t\tconst hasEdits = hasEditsForEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\t_postType,\n\t\t\t\tpostId\n\t\t\t);\n\n\t\t\treturn {\n\t\t\t\tshouldOpenModal:\n\t\t\t\t\t! hasEdits &&\n\t\t\t\t\t'' === templateRecord.content &&\n\t\t\t\t\tTEMPLATE_POST_TYPE === _postType &&\n\t\t\t\t\t! select( preferencesStore ).get(\n\t\t\t\t\t\t'core/edit-site',\n\t\t\t\t\t\t'welcomeGuide'\n\t\t\t\t\t),\n\t\t\t\tslug: templateRecord.slug,\n\t\t\t\tisCustom: templateRecord.is_custom,\n\t\t\t\tpostType: _postType,\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\n\tif (\n\t\t( modalState === START_TEMPLATE_MODAL_STATES.INITIAL &&\n\t\t\t! shouldOpenModal ) ||\n\t\tmodalState === START_TEMPLATE_MODAL_STATES.CLOSED\n\t) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<StartModal\n\t\t\tslug={ slug }\n\t\t\tisCustom={ isCustom }\n\t\t\tpostType={ postType }\n\t\t\tonClose={ () =>\n\t\t\t\tsetModalState( START_TEMPLATE_MODAL_STATES.CLOSED )\n\t\t\t}\n\t\t/>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,YAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AACA,IAAAK,QAAA,GAAAL,OAAA;AACA,IAAAM,YAAA,GAAAN,OAAA;AACA,IAAAO,OAAA,GAAAP,OAAA;AACA,IAAAQ,SAAA,GAAAR,OAAA;AAKA,IAAAS,MAAA,GAAAT,OAAA;AACA,IAAAU,UAAA,GAAAV,OAAA;AAjBA;AACA;AACA;;AAWA;AACA;AACA;;AAIA,SAASW,0BAA0BA,CAAEC,IAAI,EAAEC,QAAQ,GAAG,KAAK,EAAG;EAC7D,OAAO,IAAAC,eAAS,EACbC,MAAM,IAAM;IACb,MAAM;MAAEC,eAAe;MAAEC;IAAqB,CAAC,GAC9CF,MAAM,CAAEG,eAAU,CAAC;IACpB,MAAMC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d,CAAEK,QAAQ,IACV,EAAE,KAAKD,cAAc,CAAC7E,OAAO,IAC7BD,6BAAkB,KAAK2E,SAAS,IAChC,CAAElF,MAAM,CAAEuF,kBAAiB,CAAC,CAACC,GAAG,CAC/B,gBAAgB,EAChB,cACD,CAAC;MACF3F,IAAI,EAAEwF,cAAc,CAACxF,IAAI;MACzBC,QAAQ,EAAEuF,cAAc,CAAChF,SAAS;MAClCc,QAAQ,EAAE+D;IACX,CAAC;EACF,CAAC,EACD,EACD,CAAC;EAED,IACGJ,UAAU,KAAKJ,2BAA2B,CAACC,OAAO,IACnD,CAAEM,eAAe,IAClBH,UAAU,KAAKJ,2BAA2B,CAACE,MAAM,EAChD;IACD,OAAO,IAAI;EACZ;EAEA,OACC,IAAAvB,MAAA,CAAAC,aAAA,EAACK,UAAU;IACV9D,IAAI,EAAGA,IAAM;IACbC,QAAQ,EAAGA,QAAU;IACrBqB,QAAQ,EAAGA,QAAU;IACrByC,OAAO,EAAGA,CAAA,KACTmB,aAAa,CAAEL,2BAA2B,CAACE,MAAO;EAClD,CACD,CAAC;AAEJ"}
|
|
1
|
+
{"version":3,"names":["_components","require","_i18n","_element","_blockEditor","_data","_compose","_preferences","_blocks","_coreData","_store","_constants","useFallbackTemplateContent","slug","isCustom","useSelect","select","getEntityRecord","getDefaultTemplateId","coreStore","templateId","is_custom","ignore_empty","TEMPLATE_POST_TYPE","content","raw","undefined","useStartPatterns","fallbackContent","patterns","getEditedPostType","getEditedPostId","editSiteStore","getBlockPatterns","postId","postType","record","currentThemeStylesheet","getCurrentTheme","stylesheet","injectThemeAttributeInBlockTemplateContent","block","innerBlocks","find","innerBlock","name","map","attributes","theme","useMemo","blocks","parse","title","__","filter","pattern","Array","isArray","templateTypes","some","templateType","startsWith","PatternSelection","onChoosePattern","onChange","useEntityBlockEditor","blockPatterns","shownBlockPatterns","useAsyncList","_react","createElement","__experimentalBlockPatternsList","shownPatterns","onClickPattern","selection","StartModal","onClose","Modal","className","closeLabel","focusOnMount","onRequestClose","isFullScreen","Flex","justify","expanded","FlexItem","Button","variant","onClick","START_TEMPLATE_MODAL_STATES","INITIAL","CLOSED","StartTemplateOptions","modalState","setModalState","useState","shouldOpenModal","_postType","getEditedEntityRecord","hasEditsForEntityRecord","templateRecord","hasEdits","preferencesStore","get"],"sources":["@wordpress/edit-site/src/components/start-template-options/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Modal, Flex, FlexItem, Button } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useState, useMemo } from '@wordpress/element';\nimport { __experimentalBlockPatternsList as BlockPatternsList } from '@wordpress/block-editor';\nimport { useSelect } from '@wordpress/data';\nimport { useAsyncList } from '@wordpress/compose';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { parse } from '@wordpress/blocks';\nimport { store as coreStore, useEntityBlockEditor } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../store';\nimport { TEMPLATE_POST_TYPE } from '../../utils/constants';\n\nfunction useFallbackTemplateContent( slug, isCustom = false ) {\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecord, getDefaultTemplateId } =\n\t\t\t\tselect( coreStore );\n\t\t\tconst templateId = getDefaultTemplateId( {\n\t\t\t\tslug,\n\t\t\t\tis_custom: isCustom,\n\t\t\t\tignore_empty: true,\n\t\t\t} );\n\t\t\treturn templateId\n\t\t\t\t? getEntityRecord( 'postType', TEMPLATE_POST_TYPE, templateId )\n\t\t\t\t\t\t?.content?.raw\n\t\t\t\t: undefined;\n\t\t},\n\t\t[ slug, isCustom ]\n\t);\n}\n\nfunction useStartPatterns( fallbackContent ) {\n\tconst { slug, patterns } = useSelect( ( select ) => {\n\t\tconst { getEditedPostType, getEditedPostId } = select( editSiteStore );\n\t\tconst { getEntityRecord, getBlockPatterns } = select( coreStore );\n\t\tconst postId = getEditedPostId();\n\t\tconst postType = getEditedPostType();\n\t\tconst record = getEntityRecord( 'postType', postType, postId );\n\t\treturn {\n\t\t\tslug: record.slug,\n\t\t\tpatterns: getBlockPatterns(),\n\t\t};\n\t}, [] );\n\n\tconst currentThemeStylesheet = useSelect(\n\t\t( select ) => select( coreStore ).getCurrentTheme().stylesheet\n\t);\n\n\t// Duplicated from packages/block-library/src/pattern/edit.js.\n\tfunction injectThemeAttributeInBlockTemplateContent( block ) {\n\t\tif (\n\t\t\tblock.innerBlocks.find(\n\t\t\t\t( innerBlock ) => innerBlock.name === 'core/template-part'\n\t\t\t)\n\t\t) {\n\t\t\tblock.innerBlocks = block.innerBlocks.map( ( innerBlock ) => {\n\t\t\t\tif (\n\t\t\t\t\tinnerBlock.name === 'core/template-part' &&\n\t\t\t\t\tinnerBlock.attributes.theme === undefined\n\t\t\t\t) {\n\t\t\t\t\tinnerBlock.attributes.theme = currentThemeStylesheet;\n\t\t\t\t}\n\t\t\t\treturn innerBlock;\n\t\t\t} );\n\t\t}\n\n\t\tif (\n\t\t\tblock.name === 'core/template-part' &&\n\t\t\tblock.attributes.theme === undefined\n\t\t) {\n\t\t\tblock.attributes.theme = currentThemeStylesheet;\n\t\t}\n\t\treturn block;\n\t}\n\n\treturn useMemo( () => {\n\t\t// filter patterns that are supposed to be used in the current template being edited.\n\t\treturn [\n\t\t\t{\n\t\t\t\tname: 'fallback',\n\t\t\t\tblocks: parse( fallbackContent ),\n\t\t\t\ttitle: __( 'Fallback content' ),\n\t\t\t},\n\t\t\t...patterns\n\t\t\t\t.filter( ( pattern ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\tArray.isArray( pattern.templateTypes ) &&\n\t\t\t\t\t\tpattern.templateTypes.some( ( templateType ) =>\n\t\t\t\t\t\t\tslug.startsWith( templateType )\n\t\t\t\t\t\t)\n\t\t\t\t\t);\n\t\t\t\t} )\n\t\t\t\t.map( ( pattern ) => {\n\t\t\t\t\treturn {\n\t\t\t\t\t\t...pattern,\n\t\t\t\t\t\tblocks: parse( pattern.content ).map( ( block ) =>\n\t\t\t\t\t\t\tinjectThemeAttributeInBlockTemplateContent( block )\n\t\t\t\t\t\t),\n\t\t\t\t\t};\n\t\t\t\t} ),\n\t\t];\n\t}, [ fallbackContent, slug, patterns ] );\n}\n\nfunction PatternSelection( { fallbackContent, onChoosePattern, postType } ) {\n\tconst [ , , onChange ] = useEntityBlockEditor( 'postType', postType );\n\tconst blockPatterns = useStartPatterns( fallbackContent );\n\tconst shownBlockPatterns = useAsyncList( blockPatterns );\n\treturn (\n\t\t<BlockPatternsList\n\t\t\tblockPatterns={ blockPatterns }\n\t\t\tshownPatterns={ shownBlockPatterns }\n\t\t\tonClickPattern={ ( pattern, blocks ) => {\n\t\t\t\tonChange( blocks, { selection: undefined } );\n\t\t\t\tonChoosePattern();\n\t\t\t} }\n\t\t/>\n\t);\n}\n\nfunction StartModal( { slug, isCustom, onClose, postType } ) {\n\tconst fallbackContent = useFallbackTemplateContent( slug, isCustom );\n\tif ( ! fallbackContent ) {\n\t\treturn null;\n\t}\n\treturn (\n\t\t<Modal\n\t\t\tclassName=\"edit-site-start-template-options__modal\"\n\t\t\ttitle={ __( 'Choose a pattern' ) }\n\t\t\tcloseLabel={ __( 'Cancel' ) }\n\t\t\tfocusOnMount=\"firstElement\"\n\t\t\tonRequestClose={ onClose }\n\t\t\tisFullScreen\n\t\t>\n\t\t\t<div className=\"edit-site-start-template-options__modal-content\">\n\t\t\t\t<PatternSelection\n\t\t\t\t\tfallbackContent={ fallbackContent }\n\t\t\t\t\tslug={ slug }\n\t\t\t\t\tisCustom={ isCustom }\n\t\t\t\t\tpostType={ postType }\n\t\t\t\t\tonChoosePattern={ () => {\n\t\t\t\t\t\tonClose();\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t\t<Flex\n\t\t\t\tclassName=\"edit-site-start-template-options__modal__actions\"\n\t\t\t\tjustify=\"flex-end\"\n\t\t\t\texpanded={ false }\n\t\t\t>\n\t\t\t\t<FlexItem>\n\t\t\t\t\t<Button variant=\"tertiary\" onClick={ onClose }>\n\t\t\t\t\t\t{ __( 'Skip' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t</FlexItem>\n\t\t\t</Flex>\n\t\t</Modal>\n\t);\n}\n\nconst START_TEMPLATE_MODAL_STATES = {\n\tINITIAL: 'INITIAL',\n\tCLOSED: 'CLOSED',\n};\n\nexport default function StartTemplateOptions() {\n\tconst [ modalState, setModalState ] = useState(\n\t\tSTART_TEMPLATE_MODAL_STATES.INITIAL\n\t);\n\tconst { shouldOpenModal, slug, isCustom, postType } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEditedPostType, getEditedPostId } =\n\t\t\t\tselect( editSiteStore );\n\t\t\tconst _postType = getEditedPostType();\n\t\t\tconst postId = getEditedPostId();\n\t\t\tconst { getEditedEntityRecord, hasEditsForEntityRecord } =\n\t\t\t\tselect( coreStore );\n\t\t\tconst templateRecord = getEditedEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\t_postType,\n\t\t\t\tpostId\n\t\t\t);\n\t\t\tconst hasEdits = hasEditsForEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\t_postType,\n\t\t\t\tpostId\n\t\t\t);\n\n\t\t\treturn {\n\t\t\t\tshouldOpenModal:\n\t\t\t\t\t! hasEdits &&\n\t\t\t\t\t'' === templateRecord.content &&\n\t\t\t\t\tTEMPLATE_POST_TYPE === _postType &&\n\t\t\t\t\t! select( preferencesStore ).get(\n\t\t\t\t\t\t'core/edit-site',\n\t\t\t\t\t\t'welcomeGuide'\n\t\t\t\t\t),\n\t\t\t\tslug: templateRecord.slug,\n\t\t\t\tisCustom: templateRecord.is_custom,\n\t\t\t\tpostType: _postType,\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\n\tif (\n\t\t( modalState === START_TEMPLATE_MODAL_STATES.INITIAL &&\n\t\t\t! shouldOpenModal ) ||\n\t\tmodalState === START_TEMPLATE_MODAL_STATES.CLOSED\n\t) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<StartModal\n\t\t\tslug={ slug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A,EAACK,UAAU;IACV9D,IAAI,EAAGA,IAAM;IACbC,QAAQ,EAAGA,QAAU;IACrBqB,QAAQ,EAAGA,QAAU;IACrByC,OAAO,EAAGA,CAAA,KACTmB,aAAa,CAAEL,2BAA2B,CAACE,MAAO;EAClD,CACD,CAAC;AAEJ"}
|
|
@@ -6,9 +6,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.default = useThemeStyleVariationsByProperty;
|
|
8
8
|
exports.filterObjectByProperty = void 0;
|
|
9
|
+
exports.removePropertyFromObject = removePropertyFromObject;
|
|
10
|
+
exports.useCurrentMergeThemeStyleVariationsWithUserConfig = useCurrentMergeThemeStyleVariationsWithUserConfig;
|
|
11
|
+
var _data = require("@wordpress/data");
|
|
12
|
+
var _coreData = require("@wordpress/core-data");
|
|
9
13
|
var _element = require("@wordpress/element");
|
|
14
|
+
var _blockEditor = require("@wordpress/block-editor");
|
|
10
15
|
var _globalStylesProvider = require("../../components/global-styles/global-styles-provider");
|
|
11
16
|
var _cloneDeep = _interopRequireDefault(require("../../utils/clone-deep"));
|
|
17
|
+
var _lockUnlock = require("../../lock-unlock");
|
|
12
18
|
/**
|
|
13
19
|
* WordPress dependencies
|
|
14
20
|
*/
|
|
@@ -17,6 +23,61 @@ var _cloneDeep = _interopRequireDefault(require("../../utils/clone-deep"));
|
|
|
17
23
|
* Internal dependencies
|
|
18
24
|
*/
|
|
19
25
|
|
|
26
|
+
const {
|
|
27
|
+
GlobalStylesContext
|
|
28
|
+
} = (0, _lockUnlock.unlock)(_blockEditor.privateApis);
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Removes all instances of a property from an object.
|
|
32
|
+
*
|
|
33
|
+
* @param {Object} object The object to remove the property from.
|
|
34
|
+
* @param {string} property The property to remove.
|
|
35
|
+
* @return {Object} The modified object.
|
|
36
|
+
*/
|
|
37
|
+
function removePropertyFromObject(object, property) {
|
|
38
|
+
if (!property || typeof property !== 'string') {
|
|
39
|
+
return object;
|
|
40
|
+
}
|
|
41
|
+
if (typeof object !== 'object' || !Object.keys(object).length) {
|
|
42
|
+
return object;
|
|
43
|
+
}
|
|
44
|
+
for (const key in object) {
|
|
45
|
+
if (key === property) {
|
|
46
|
+
delete object[key];
|
|
47
|
+
} else if (typeof object[key] === 'object') {
|
|
48
|
+
removePropertyFromObject(object[key], property);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return object;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* A convenience wrapper for `useThemeStyleVariationsByProperty()` that fetches the current theme style variations,
|
|
56
|
+
* and user-defined global style/settings object.
|
|
57
|
+
*
|
|
58
|
+
* @param {Object} props Object of hook args.
|
|
59
|
+
* @param {string} props.property The property to filter by.
|
|
60
|
+
* @param {Function} props.filter Optional. The filter function to apply to the variations.
|
|
61
|
+
* @return {Object[]|*} The merged object.
|
|
62
|
+
*/
|
|
63
|
+
function useCurrentMergeThemeStyleVariationsWithUserConfig({
|
|
64
|
+
property,
|
|
65
|
+
filter
|
|
66
|
+
}) {
|
|
67
|
+
const variations = (0, _data.useSelect)(select => {
|
|
68
|
+
return select(_coreData.store).__experimentalGetCurrentThemeGlobalStylesVariations();
|
|
69
|
+
}, []);
|
|
70
|
+
const {
|
|
71
|
+
user: baseVariation
|
|
72
|
+
} = (0, _element.useContext)(GlobalStylesContext);
|
|
73
|
+
return useThemeStyleVariationsByProperty({
|
|
74
|
+
variations,
|
|
75
|
+
property,
|
|
76
|
+
filter,
|
|
77
|
+
baseVariation: removePropertyFromObject((0, _cloneDeep.default)(baseVariation), property)
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
|
|
20
81
|
/**
|
|
21
82
|
* Returns a new object, with properties specified in `property`,
|
|
22
83
|
* maintain the original object tree structure.
|
|
@@ -47,6 +108,10 @@ const filterObjectByProperty = (object, property) => {
|
|
|
47
108
|
|
|
48
109
|
/**
|
|
49
110
|
* Returns a new object with only the properties specified in `property`.
|
|
111
|
+
* Optional merges the baseVariation object with the variation object.
|
|
112
|
+
* Note: this function will only overwrite the specified property in baseVariation if it exists.
|
|
113
|
+
* The baseVariation will not be otherwise modified. To strip a property from the baseVariation object, use `removePropertyFromObject`.
|
|
114
|
+
* See useCurrentMergeThemeStyleVariationsWithUserConfig for an example of how to use this function.
|
|
50
115
|
*
|
|
51
116
|
* @param {Object} props Object of hook args.
|
|
52
117
|
* @param {Object[]} props.variations The theme style variations to filter.
|
package/build/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["_data","require","_coreData","_element","_blockEditor","_globalStylesProvider","_cloneDeep","_interopRequireDefault","_lockUnlock","GlobalStylesContext","unlock","blockEditorPrivateApis","removePropertyFromObject","object","property","Object","keys","length","key","useCurrentMergeThemeStyleVariationsWithUserConfig","filter","variations","useSelect","select","coreStore","__experimentalGetCurrentThemeGlobalStylesVariations","user","baseVariation","useContext","useThemeStyleVariationsByProperty","cloneDeep","filterObjectByProperty","newObject","forEach","newFilter","exports","useMemo","clonedBaseVariation","processedStyleVariations","map","variation","result","title","description","mergeBaseAndUserConfigs"],"sources":["@wordpress/edit-site/src/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useContext, useMemo } from '@wordpress/element';\nimport { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport { mergeBaseAndUserConfigs } from '../../components/global-styles/global-styles-provider';\nimport cloneDeep from '../../utils/clone-deep';\nimport { unlock } from '../../lock-unlock';\n\nconst { GlobalStylesContext } = unlock( blockEditorPrivateApis );\n\n/**\n * Removes all instances of a property from an object.\n *\n * @param {Object} object The object to remove the property from.\n * @param {string} property The property to remove.\n * @return {Object} The modified object.\n */\nexport function removePropertyFromObject( object, property ) {\n\tif ( ! property || typeof property !== 'string' ) {\n\t\treturn object;\n\t}\n\n\tif ( typeof object !== 'object' || ! Object.keys( object ).length ) {\n\t\treturn object;\n\t}\n\n\tfor ( const key in object ) {\n\t\tif ( key === property ) {\n\t\t\tdelete object[ key ];\n\t\t} else if ( typeof object[ key ] === 'object' ) {\n\t\t\tremovePropertyFromObject( object[ key ], property );\n\t\t}\n\t}\n\treturn object;\n}\n\n/**\n * A convenience wrapper for `useThemeStyleVariationsByProperty()` that fetches the current theme style variations,\n * and user-defined global style/settings object.\n *\n * @param {Object} props Object of hook args.\n * @param {string} props.property The property to filter by.\n * @param {Function} props.filter Optional. The filter function to apply to the variations.\n * @return {Object[]|*} The merged object.\n */\nexport function useCurrentMergeThemeStyleVariationsWithUserConfig( {\n\tproperty,\n\tfilter,\n} ) {\n\tconst variations = useSelect( ( select ) => {\n\t\treturn select(\n\t\t\tcoreStore\n\t\t).__experimentalGetCurrentThemeGlobalStylesVariations();\n\t}, [] );\n\tconst { user: baseVariation } = useContext( GlobalStylesContext );\n\n\treturn useThemeStyleVariationsByProperty( {\n\t\tvariations,\n\t\tproperty,\n\t\tfilter,\n\t\tbaseVariation: removePropertyFromObject(\n\t\t\tcloneDeep( baseVariation ),\n\t\t\tproperty\n\t\t),\n\t} );\n}\n\n/**\n * Returns a new object, with properties specified in `property`,\n * maintain the original object tree structure.\n * The function is recursive, so it will perform a deep search for the given property.\n * E.g., the function will return `{ a: { b: { c: { test: 1 } } } }` if the property is `test`.\n *\n * @param {Object} object The object to filter\n * @param {Object} property The property to filter by\n * @return {Object} The merged object.\n */\nexport const filterObjectByProperty = ( object, property ) => {\n\tif ( ! object ) {\n\t\treturn {};\n\t}\n\n\tconst newObject = {};\n\tObject.keys( object ).forEach( ( key ) => {\n\t\tif ( key === property ) {\n\t\t\tnewObject[ key ] = object[ key ];\n\t\t} else if ( typeof object[ key ] === 'object' ) {\n\t\t\tconst newFilter = filterObjectByProperty( object[ key ], property );\n\t\t\tif ( Object.keys( newFilter ).length ) {\n\t\t\t\tnewObject[ key ] = newFilter;\n\t\t\t}\n\t\t}\n\t} );\n\treturn newObject;\n};\n\n/**\n * Returns a new object with only the properties specified in `property`.\n * Optional merges the baseVariation object with the variation object.\n * Note: this function will only overwrite the specified property in baseVariation if it exists.\n * The baseVariation will not be otherwise modified. To strip a property from the baseVariation object, use `removePropertyFromObject`.\n * See useCurrentMergeThemeStyleVariationsWithUserConfig for an example of how to use this function.\n *\n * @param {Object} props Object of hook args.\n * @param {Object[]} props.variations The theme style variations to filter.\n * @param {string} props.property The property to filter by.\n * @param {Function} props.filter Optional. The filter function to apply to the variations.\n * @param {Object} props.baseVariation Optional. Base or user settings to be updated with variation properties.\n * @return {Object[]|*} The merged object.\n */\nexport default function useThemeStyleVariationsByProperty( {\n\tvariations,\n\tproperty,\n\tfilter,\n\tbaseVariation,\n} ) {\n\treturn useMemo( () => {\n\t\tif ( ! property || ! variations || variations?.length === 0 ) {\n\t\t\treturn variations;\n\t\t}\n\n\t\tconst clonedBaseVariation =\n\t\t\ttypeof baseVariation === 'object' &&\n\t\t\tObject.keys( baseVariation ).length > 0\n\t\t\t\t? cloneDeep( baseVariation )\n\t\t\t\t: null;\n\n\t\tlet processedStyleVariations = variations.map( ( variation ) => {\n\t\t\tlet result = {\n\t\t\t\t...filterObjectByProperty( cloneDeep( variation ), property ),\n\t\t\t\ttitle: variation?.title,\n\t\t\t\tdescription: variation?.description,\n\t\t\t};\n\n\t\t\tif ( clonedBaseVariation ) {\n\t\t\t\t/*\n\t\t\t\t * Overwrites all baseVariation object `styleProperty` properties\n\t\t\t\t * with the theme variation `styleProperty` properties.\n\t\t\t\t */\n\t\t\t\tresult = mergeBaseAndUserConfigs( clonedBaseVariation, result );\n\t\t\t}\n\t\t\treturn result;\n\t\t} );\n\n\t\tif ( 'function' === typeof filter ) {\n\t\t\tprocessedStyleVariations =\n\t\t\t\tprocessedStyleVariations.filter( filter );\n\t\t}\n\n\t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