@wordpress/edit-site 5.14.0 → 5.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/build/components/add-new-page/index.js +1 -6
- package/build/components/add-new-page/index.js.map +1 -1
- package/build/components/add-new-pattern/index.js +21 -7
- package/build/components/add-new-pattern/index.js.map +1 -1
- package/build/components/add-new-template/utils.js +10 -8
- package/build/components/add-new-template/utils.js.map +1 -1
- package/build/components/block-editor/constants.js +1 -1
- package/build/components/block-editor/constants.js.map +1 -1
- package/build/components/block-editor/editor-canvas.js +1 -1
- package/build/components/block-editor/editor-canvas.js.map +1 -1
- package/build/components/block-editor/index.js +0 -4
- package/build/components/block-editor/index.js.map +1 -1
- package/build/components/block-editor/use-site-editor-settings.js +87 -13
- package/build/components/block-editor/use-site-editor-settings.js.map +1 -1
- package/build/components/code-editor/index.js +60 -28
- package/build/components/code-editor/index.js.map +1 -1
- package/build/components/create-pattern-modal/index.js +7 -3
- package/build/components/create-pattern-modal/index.js.map +1 -1
- package/build/components/editor/index.js +1 -1
- package/build/components/editor/index.js.map +1 -1
- package/build/components/header-edit-mode/index.js +13 -9
- package/build/components/header-edit-mode/index.js.map +1 -1
- package/build/components/layout/index.js +8 -3
- package/build/components/layout/index.js.map +1 -1
- package/build/components/page-actions/index.js +2 -2
- package/build/components/page-actions/index.js.map +1 -1
- package/build/components/page-actions/{delete-page-menu-item.js → trash-page-menu-item.js} +8 -16
- package/build/components/page-actions/trash-page-menu-item.js.map +1 -0
- package/build/components/page-content-focus-manager/disable-non-page-content-blocks.js +5 -5
- package/build/components/page-content-focus-manager/disable-non-page-content-blocks.js.map +1 -1
- package/build/components/page-patterns/duplicate-menu-item.js +163 -0
- package/build/components/page-patterns/duplicate-menu-item.js.map +1 -0
- package/build/components/page-patterns/grid-item.js +83 -58
- package/build/components/page-patterns/grid-item.js.map +1 -1
- package/build/components/page-patterns/grid.js +5 -18
- package/build/components/page-patterns/grid.js.map +1 -1
- package/build/components/page-patterns/header.js +69 -0
- package/build/components/page-patterns/header.js.map +1 -0
- package/build/components/page-patterns/index.js +3 -1
- package/build/components/page-patterns/index.js.map +1 -1
- package/build/components/page-patterns/pagination.js +63 -0
- package/build/components/page-patterns/pagination.js.map +1 -0
- package/build/components/page-patterns/patterns-list.js +95 -30
- package/build/components/page-patterns/patterns-list.js.map +1 -1
- package/build/components/page-patterns/rename-menu-item.js +109 -0
- package/build/components/page-patterns/rename-menu-item.js.map +1 -0
- package/build/components/page-patterns/use-patterns.js +102 -121
- package/build/components/page-patterns/use-patterns.js.map +1 -1
- package/build/components/page-template-parts/add-new-template-part.js +74 -0
- package/build/components/page-template-parts/add-new-template-part.js.map +1 -0
- package/build/components/page-template-parts/index.js +2 -23
- package/build/components/page-template-parts/index.js.map +1 -1
- package/build/components/resizable-frame/index.js +78 -36
- package/build/components/resizable-frame/index.js.map +1 -1
- package/build/components/save-panel/index.js +5 -5
- package/build/components/save-panel/index.js.map +1 -1
- package/build/components/sidebar-edit-mode/page-panels/page-content.js +4 -3
- package/build/components/sidebar-edit-mode/page-panels/page-content.js.map +1 -1
- package/build/components/sidebar-edit-mode/page-panels/page-status.js +3 -8
- package/build/components/sidebar-edit-mode/page-panels/page-status.js.map +1 -1
- package/build/components/sidebar-navigation-screen/index.js +14 -8
- package/build/components/sidebar-navigation-screen/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-main/index.js +4 -2
- package/build/components/sidebar-navigation-screen-main/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-main/template-part-hint.js +45 -0
- package/build/components/sidebar-navigation-screen-main/template-part-hint.js.map +1 -0
- package/build/components/sidebar-navigation-screen-navigation-menu/index.js +4 -4
- package/build/components/sidebar-navigation-screen-navigation-menu/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-menu/more-menu.js +1 -0
- package/build/components/sidebar-navigation-screen-navigation-menu/more-menu.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-menu/single-navigation-menu.js +3 -3
- package/build/components/sidebar-navigation-screen-navigation-menu/single-navigation-menu.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-menu/use-navigation-menu-handlers.js +4 -3
- package/build/components/sidebar-navigation-screen-navigation-menu/use-navigation-menu-handlers.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-menus/constants.js +2 -0
- package/build/components/sidebar-navigation-screen-navigation-menus/constants.js.map +1 -1
- package/build/components/sidebar-navigation-screen-page/index.js +2 -3
- package/build/components/sidebar-navigation-screen-page/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-page/status-label.js +1 -34
- package/build/components/sidebar-navigation-screen-page/status-label.js.map +1 -1
- package/build/components/sidebar-navigation-screen-pages/index.js +33 -25
- package/build/components/sidebar-navigation-screen-pages/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-pattern/index.js +9 -7
- package/build/components/sidebar-navigation-screen-pattern/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-pattern/template-part-navigation-menu.js +3 -2
- package/build/components/sidebar-navigation-screen-pattern/template-part-navigation-menu.js.map +1 -1
- package/build/components/sidebar-navigation-screen-pattern/template-part-navigation-menus.js +3 -2
- package/build/components/sidebar-navigation-screen-pattern/template-part-navigation-menus.js.map +1 -1
- package/build/components/sidebar-navigation-screen-pattern/use-navigation-menu-content.js +11 -3
- package/build/components/sidebar-navigation-screen-pattern/use-navigation-menu-content.js.map +1 -1
- package/build/components/sidebar-navigation-screen-pattern/use-pattern-details.js +5 -2
- package/build/components/sidebar-navigation-screen-pattern/use-pattern-details.js.map +1 -1
- package/build/components/sidebar-navigation-screen-patterns/index.js +72 -51
- package/build/components/sidebar-navigation-screen-patterns/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-patterns/use-my-patterns.js +9 -5
- package/build/components/sidebar-navigation-screen-patterns/use-my-patterns.js.map +1 -1
- package/build/components/sidebar-navigation-screen-patterns/use-pattern-categories.js +11 -1
- package/build/components/sidebar-navigation-screen-patterns/use-pattern-categories.js.map +1 -1
- package/build/components/sidebar-navigation-screen-patterns/use-template-part-areas.js +20 -9
- package/build/components/sidebar-navigation-screen-patterns/use-template-part-areas.js.map +1 -1
- package/build/components/sidebar-navigation-screen-patterns/use-theme-patterns.js +1 -1
- package/build/components/sidebar-navigation-screen-patterns/use-theme-patterns.js.map +1 -1
- package/build/components/site-hub/index.js +24 -11
- package/build/components/site-hub/index.js.map +1 -1
- package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js +10 -5
- package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
- package/build/components/sync-state-with-url/use-sync-path-with-url.js +15 -12
- package/build/components/sync-state-with-url/use-sync-path-with-url.js.map +1 -1
- package/build/components/template-actions/index.js +3 -1
- package/build/components/template-actions/index.js.map +1 -1
- package/build/components/template-actions/rename-menu-item.js +12 -8
- package/build/components/template-actions/rename-menu-item.js.map +1 -1
- package/build/components/use-edited-entity-record/index.js +6 -1
- package/build/components/use-edited-entity-record/index.js.map +1 -1
- package/build/hooks/commands/use-common-commands.js +78 -20
- package/build/hooks/commands/use-common-commands.js.map +1 -1
- package/build/hooks/push-changes-to-global-styles/index.js +56 -10
- package/build/hooks/push-changes-to-global-styles/index.js.map +1 -1
- package/build/store/private-actions.js +7 -1
- package/build/store/private-actions.js.map +1 -1
- package/build/utils/normalize-record-key.js +19 -0
- package/build/utils/normalize-record-key.js.map +1 -0
- package/build/utils/use-activate-theme.js +1 -1
- package/build/utils/use-activate-theme.js.map +1 -1
- package/build-module/components/add-new-page/index.js +1 -6
- package/build-module/components/add-new-page/index.js.map +1 -1
- package/build-module/components/add-new-pattern/index.js +19 -7
- package/build-module/components/add-new-pattern/index.js.map +1 -1
- package/build-module/components/add-new-template/utils.js +9 -6
- package/build-module/components/add-new-template/utils.js.map +1 -1
- package/build-module/components/block-editor/constants.js +1 -1
- package/build-module/components/block-editor/constants.js.map +1 -1
- package/build-module/components/block-editor/editor-canvas.js +1 -1
- package/build-module/components/block-editor/editor-canvas.js.map +1 -1
- package/build-module/components/block-editor/index.js +0 -4
- package/build-module/components/block-editor/index.js.map +1 -1
- package/build-module/components/block-editor/use-site-editor-settings.js +89 -14
- package/build-module/components/block-editor/use-site-editor-settings.js.map +1 -1
- package/build-module/components/code-editor/index.js +62 -30
- package/build-module/components/code-editor/index.js.map +1 -1
- package/build-module/components/create-pattern-modal/index.js +6 -3
- package/build-module/components/create-pattern-modal/index.js.map +1 -1
- package/build-module/components/editor/index.js +1 -1
- package/build-module/components/editor/index.js.map +1 -1
- package/build-module/components/header-edit-mode/index.js +13 -9
- package/build-module/components/header-edit-mode/index.js.map +1 -1
- package/build-module/components/layout/index.js +8 -3
- package/build-module/components/layout/index.js.map +1 -1
- package/build-module/components/page-actions/index.js +2 -2
- package/build-module/components/page-actions/index.js.map +1 -1
- package/build-module/components/page-actions/{delete-page-menu-item.js → trash-page-menu-item.js} +8 -17
- package/build-module/components/page-actions/trash-page-menu-item.js.map +1 -0
- package/build-module/components/page-content-focus-manager/disable-non-page-content-blocks.js +5 -3
- package/build-module/components/page-content-focus-manager/disable-non-page-content-blocks.js.map +1 -1
- package/build-module/components/page-patterns/duplicate-menu-item.js +147 -0
- package/build-module/components/page-patterns/duplicate-menu-item.js.map +1 -0
- package/build-module/components/page-patterns/grid-item.js +84 -64
- package/build-module/components/page-patterns/grid-item.js.map +1 -1
- package/build-module/components/page-patterns/grid.js +5 -17
- package/build-module/components/page-patterns/grid.js.map +1 -1
- package/build-module/components/page-patterns/header.js +54 -0
- package/build-module/components/page-patterns/header.js.map +1 -0
- package/build-module/components/page-patterns/index.js +3 -1
- package/build-module/components/page-patterns/index.js.map +1 -1
- package/build-module/components/page-patterns/pagination.js +54 -0
- package/build-module/components/page-patterns/pagination.js.map +1 -0
- package/build-module/components/page-patterns/patterns-list.js +96 -33
- package/build-module/components/page-patterns/patterns-list.js.map +1 -1
- package/build-module/components/page-patterns/rename-menu-item.js +97 -0
- package/build-module/components/page-patterns/rename-menu-item.js.map +1 -0
- package/build-module/components/page-patterns/use-patterns.js +103 -122
- package/build-module/components/page-patterns/use-patterns.js.map +1 -1
- package/build-module/components/page-template-parts/add-new-template-part.js +58 -0
- package/build-module/components/page-template-parts/add-new-template-part.js.map +1 -0
- package/build-module/components/page-template-parts/index.js +3 -22
- package/build-module/components/page-template-parts/index.js.map +1 -1
- package/build-module/components/resizable-frame/index.js +79 -39
- package/build-module/components/resizable-frame/index.js.map +1 -1
- package/build-module/components/save-panel/index.js +5 -5
- package/build-module/components/save-panel/index.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/page-panels/page-content.js +5 -2
- package/build-module/components/sidebar-edit-mode/page-panels/page-content.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/page-panels/page-status.js +3 -8
- package/build-module/components/sidebar-edit-mode/page-panels/page-status.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen/index.js +15 -9
- package/build-module/components/sidebar-navigation-screen/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-main/index.js +4 -3
- package/build-module/components/sidebar-navigation-screen-main/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-main/template-part-hint.js +33 -0
- package/build-module/components/sidebar-navigation-screen-main/template-part-hint.js.map +1 -0
- package/build-module/components/sidebar-navigation-screen-navigation-menu/index.js +4 -4
- package/build-module/components/sidebar-navigation-screen-navigation-menu/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menu/more-menu.js +1 -0
- package/build-module/components/sidebar-navigation-screen-navigation-menu/more-menu.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menu/single-navigation-menu.js +3 -3
- package/build-module/components/sidebar-navigation-screen-navigation-menu/single-navigation-menu.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menu/use-navigation-menu-handlers.js +4 -3
- package/build-module/components/sidebar-navigation-screen-navigation-menu/use-navigation-menu-handlers.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menus/constants.js +2 -0
- package/build-module/components/sidebar-navigation-screen-navigation-menus/constants.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-page/index.js +2 -3
- package/build-module/components/sidebar-navigation-screen-page/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-page/status-label.js +1 -32
- package/build-module/components/sidebar-navigation-screen-page/status-label.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-pages/index.js +33 -25
- package/build-module/components/sidebar-navigation-screen-pages/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-pattern/index.js +8 -7
- package/build-module/components/sidebar-navigation-screen-pattern/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-pattern/template-part-navigation-menu.js +3 -2
- package/build-module/components/sidebar-navigation-screen-pattern/template-part-navigation-menu.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-pattern/template-part-navigation-menus.js +3 -2
- package/build-module/components/sidebar-navigation-screen-pattern/template-part-navigation-menus.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-pattern/use-navigation-menu-content.js +11 -3
- package/build-module/components/sidebar-navigation-screen-pattern/use-navigation-menu-content.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-pattern/use-pattern-details.js +4 -2
- package/build-module/components/sidebar-navigation-screen-pattern/use-pattern-details.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-patterns/index.js +76 -53
- package/build-module/components/sidebar-navigation-screen-patterns/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-patterns/use-my-patterns.js +9 -5
- package/build-module/components/sidebar-navigation-screen-patterns/use-my-patterns.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-patterns/use-pattern-categories.js +10 -1
- package/build-module/components/sidebar-navigation-screen-patterns/use-pattern-categories.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-patterns/use-template-part-areas.js +18 -9
- package/build-module/components/sidebar-navigation-screen-patterns/use-template-part-areas.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-patterns/use-theme-patterns.js +1 -1
- package/build-module/components/sidebar-navigation-screen-patterns/use-theme-patterns.js.map +1 -1
- package/build-module/components/site-hub/index.js +24 -11
- package/build-module/components/site-hub/index.js.map +1 -1
- package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js +7 -5
- package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
- package/build-module/components/sync-state-with-url/use-sync-path-with-url.js +16 -12
- package/build-module/components/sync-state-with-url/use-sync-path-with-url.js.map +1 -1
- package/build-module/components/template-actions/index.js +2 -1
- package/build-module/components/template-actions/index.js.map +1 -1
- package/build-module/components/template-actions/rename-menu-item.js +11 -8
- package/build-module/components/template-actions/rename-menu-item.js.map +1 -1
- package/build-module/components/use-edited-entity-record/index.js +3 -1
- package/build-module/components/use-edited-entity-record/index.js.map +1 -1
- package/build-module/hooks/commands/use-common-commands.js +74 -20
- package/build-module/hooks/commands/use-common-commands.js.map +1 -1
- package/build-module/hooks/push-changes-to-global-styles/index.js +57 -10
- package/build-module/hooks/push-changes-to-global-styles/index.js.map +1 -1
- package/build-module/store/private-actions.js +7 -1
- package/build-module/store/private-actions.js.map +1 -1
- package/build-module/utils/normalize-record-key.js +12 -0
- package/build-module/utils/normalize-record-key.js.map +1 -0
- package/build-module/utils/use-activate-theme.js +1 -1
- package/build-module/utils/use-activate-theme.js.map +1 -1
- package/build-style/style-rtl.css +221 -63
- package/build-style/style.css +221 -63
- package/package.json +39 -40
- package/src/components/add-new-page/index.js +0 -3
- package/src/components/add-new-pattern/index.js +23 -12
- package/src/components/add-new-template/utils.js +9 -6
- package/src/components/block-editor/constants.js +5 -1
- package/src/components/block-editor/editor-canvas.js +1 -1
- package/src/components/block-editor/index.js +0 -4
- package/src/components/block-editor/use-site-editor-settings.js +99 -20
- package/src/components/canvas-spinner/style.scss +14 -0
- package/src/components/code-editor/index.js +51 -33
- package/src/components/create-pattern-modal/index.js +5 -2
- package/src/components/editor/index.js +2 -2
- package/src/components/header-edit-mode/document-actions/style.scss +4 -0
- package/src/components/header-edit-mode/index.js +29 -22
- package/src/components/layout/index.js +16 -2
- package/src/components/layout/style.scss +2 -1
- package/src/components/page-actions/index.js +2 -2
- package/src/components/page-actions/{delete-page-menu-item.js → trash-page-menu-item.js} +9 -22
- package/src/components/page-content-focus-manager/disable-non-page-content-blocks.js +12 -3
- package/src/components/page-patterns/duplicate-menu-item.js +196 -0
- package/src/components/page-patterns/grid-item.js +189 -133
- package/src/components/page-patterns/grid.js +3 -20
- package/src/components/page-patterns/header.js +69 -0
- package/src/components/page-patterns/index.js +6 -1
- package/src/components/page-patterns/pagination.js +80 -0
- package/src/components/page-patterns/patterns-list.js +160 -72
- package/src/components/page-patterns/rename-menu-item.js +115 -0
- package/src/components/page-patterns/style.scss +140 -30
- package/src/components/page-patterns/use-patterns.js +102 -172
- package/src/components/page-template-parts/add-new-template-part.js +57 -0
- package/src/components/page-template-parts/index.js +3 -22
- package/src/components/resizable-frame/index.js +102 -34
- package/src/components/resizable-frame/style.scss +9 -9
- package/src/components/save-panel/index.js +10 -4
- package/src/components/sidebar-edit-mode/page-panels/page-content.js +7 -5
- package/src/components/sidebar-edit-mode/page-panels/page-status.js +2 -5
- package/src/components/sidebar-navigation-item/style.scss +5 -12
- package/src/components/sidebar-navigation-screen/index.js +14 -7
- package/src/components/sidebar-navigation-screen/style.scss +14 -0
- package/src/components/sidebar-navigation-screen-main/index.js +44 -40
- package/src/components/sidebar-navigation-screen-main/template-part-hint.js +34 -0
- package/src/components/sidebar-navigation-screen-navigation-menu/index.js +4 -3
- package/src/components/sidebar-navigation-screen-navigation-menu/more-menu.js +1 -0
- package/src/components/sidebar-navigation-screen-navigation-menu/single-navigation-menu.js +1 -1
- package/src/components/sidebar-navigation-screen-navigation-menu/use-navigation-menu-handlers.js +15 -5
- package/src/components/sidebar-navigation-screen-navigation-menus/constants.js +2 -0
- package/src/components/sidebar-navigation-screen-page/index.js +3 -3
- package/src/components/sidebar-navigation-screen-page/status-label.js +1 -35
- package/src/components/sidebar-navigation-screen-pages/index.js +39 -29
- package/src/components/sidebar-navigation-screen-pattern/index.js +5 -2
- package/src/components/sidebar-navigation-screen-pattern/template-part-navigation-menu.js +2 -1
- package/src/components/sidebar-navigation-screen-pattern/template-part-navigation-menus.js +2 -1
- package/src/components/sidebar-navigation-screen-pattern/use-navigation-menu-content.js +12 -2
- package/src/components/sidebar-navigation-screen-pattern/use-pattern-details.js +5 -2
- package/src/components/sidebar-navigation-screen-patterns/index.js +103 -98
- package/src/components/sidebar-navigation-screen-patterns/style.scss +20 -0
- package/src/components/sidebar-navigation-screen-patterns/use-my-patterns.js +7 -6
- package/src/components/sidebar-navigation-screen-patterns/use-pattern-categories.js +9 -0
- package/src/components/sidebar-navigation-screen-patterns/use-template-part-areas.js +31 -9
- package/src/components/sidebar-navigation-screen-patterns/use-theme-patterns.js +2 -1
- package/src/components/site-hub/index.js +45 -28
- package/src/components/site-hub/style.scss +13 -0
- package/src/components/sync-state-with-url/use-init-edited-entity-from-url.js +8 -2
- package/src/components/sync-state-with-url/use-sync-path-with-url.js +73 -66
- package/src/components/template-actions/index.js +2 -1
- package/src/components/template-actions/rename-menu-item.js +17 -10
- package/src/components/use-edited-entity-record/index.js +6 -1
- package/src/hooks/commands/use-common-commands.js +56 -23
- package/src/hooks/push-changes-to-global-styles/index.js +63 -9
- package/src/store/private-actions.js +5 -1
- package/src/style.scss +10 -12
- package/src/utils/normalize-record-key.js +11 -0
- package/src/utils/use-activate-theme.js +1 -1
- package/build/components/code-editor/code-editor-text-area.js +0 -96
- package/build/components/code-editor/code-editor-text-area.js.map +0 -1
- package/build/components/keyboard-shortcuts/index.js +0 -148
- package/build/components/keyboard-shortcuts/index.js.map +0 -1
- package/build/components/page-actions/delete-page-menu-item.js.map +0 -1
- package/build/components/page-content-focus-manager/constants.js +0 -9
- package/build/components/page-content-focus-manager/constants.js.map +0 -1
- package/build-module/components/code-editor/code-editor-text-area.js +0 -84
- package/build-module/components/code-editor/code-editor-text-area.js.map +0 -1
- package/build-module/components/keyboard-shortcuts/index.js +0 -132
- package/build-module/components/keyboard-shortcuts/index.js.map +0 -1
- package/build-module/components/page-actions/delete-page-menu-item.js.map +0 -1
- package/build-module/components/page-content-focus-manager/constants.js +0 -2
- package/build-module/components/page-content-focus-manager/constants.js.map +0 -1
- package/src/components/code-editor/code-editor-text-area.js +0 -84
- package/src/components/keyboard-shortcuts/index.js +0 -137
- package/src/components/page-content-focus-manager/constants.js +0 -5
|
@@ -3,25 +3,40 @@ import { createElement, Fragment } from "@wordpress/element";
|
|
|
3
3
|
/**
|
|
4
4
|
* WordPress dependencies
|
|
5
5
|
*/
|
|
6
|
-
import {
|
|
6
|
+
import { useState, useDeferredValue, useId, useMemo } from '@wordpress/element';
|
|
7
|
+
import { SearchControl, __experimentalVStack as VStack, Flex, FlexBlock, __experimentalToggleGroupControl as ToggleGroupControl, __experimentalToggleGroupControlOption as ToggleGroupControlOption, __experimentalHeading as Heading, __experimentalText as Text } from '@wordpress/components';
|
|
7
8
|
import { __, isRTL } from '@wordpress/i18n';
|
|
8
|
-
import {
|
|
9
|
+
import { chevronLeft, chevronRight } from '@wordpress/icons';
|
|
9
10
|
import { privateApis as routerPrivateApis } from '@wordpress/router';
|
|
10
|
-
import { useViewportMatch } from '@wordpress/compose';
|
|
11
|
+
import { useAsyncList, useViewportMatch } from '@wordpress/compose';
|
|
11
12
|
/**
|
|
12
13
|
* Internal dependencies
|
|
13
14
|
*/
|
|
14
15
|
|
|
16
|
+
import PatternsHeader from './header';
|
|
15
17
|
import Grid from './grid';
|
|
16
18
|
import NoPatterns from './no-patterns';
|
|
17
19
|
import usePatterns from './use-patterns';
|
|
18
20
|
import SidebarButton from '../sidebar-button';
|
|
19
21
|
import useDebouncedInput from '../../utils/use-debounced-input';
|
|
20
22
|
import { unlock } from '../../lock-unlock';
|
|
23
|
+
import { SYNC_TYPES, USER_PATTERN_CATEGORY } from './utils';
|
|
24
|
+
import Pagination from './pagination';
|
|
21
25
|
const {
|
|
22
26
|
useLocation,
|
|
23
27
|
useHistory
|
|
24
28
|
} = unlock(routerPrivateApis);
|
|
29
|
+
const SYNC_FILTERS = {
|
|
30
|
+
all: __('All'),
|
|
31
|
+
[SYNC_TYPES.full]: __('Synced'),
|
|
32
|
+
[SYNC_TYPES.unsynced]: __('Standard')
|
|
33
|
+
};
|
|
34
|
+
const SYNC_DESCRIPTIONS = {
|
|
35
|
+
all: '',
|
|
36
|
+
[SYNC_TYPES.full]: __('Patterns that are kept in sync across the site.'),
|
|
37
|
+
[SYNC_TYPES.unsynced]: __('Patterns that can be changed freely without affecting the site.')
|
|
38
|
+
};
|
|
39
|
+
const PAGE_SIZE = 20;
|
|
25
40
|
export default function PatternsList({
|
|
26
41
|
categoryId,
|
|
27
42
|
type
|
|
@@ -30,15 +45,49 @@ export default function PatternsList({
|
|
|
30
45
|
const history = useHistory();
|
|
31
46
|
const isMobileViewport = useViewportMatch('medium', '<');
|
|
32
47
|
const [filterValue, setFilterValue, delayedFilterValue] = useDebouncedInput('');
|
|
33
|
-
const
|
|
48
|
+
const deferredFilterValue = useDeferredValue(delayedFilterValue);
|
|
49
|
+
const [syncFilter, setSyncFilter] = useState('all');
|
|
50
|
+
const [currentPage, setCurrentPage] = useState(1);
|
|
51
|
+
const deferredSyncedFilter = useDeferredValue(syncFilter);
|
|
34
52
|
const {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
} =
|
|
38
|
-
|
|
39
|
-
|
|
53
|
+
patterns,
|
|
54
|
+
isResolving
|
|
55
|
+
} = usePatterns(type, categoryId !== 'uncategorized' ? categoryId : '', {
|
|
56
|
+
search: deferredFilterValue,
|
|
57
|
+
syncStatus: deferredSyncedFilter === 'all' ? undefined : deferredSyncedFilter
|
|
58
|
+
});
|
|
59
|
+
const id = useId();
|
|
60
|
+
const titleId = `${id}-title`;
|
|
61
|
+
const descriptionId = `${id}-description`;
|
|
62
|
+
const hasPatterns = patterns.length;
|
|
63
|
+
const title = SYNC_FILTERS[syncFilter];
|
|
64
|
+
const description = SYNC_DESCRIPTIONS[syncFilter];
|
|
65
|
+
const totalItems = patterns.length;
|
|
66
|
+
const pageIndex = currentPage - 1;
|
|
67
|
+
const numPages = Math.ceil(patterns.length / PAGE_SIZE);
|
|
68
|
+
const list = useMemo(() => patterns.slice(pageIndex * PAGE_SIZE, pageIndex * PAGE_SIZE + PAGE_SIZE), [pageIndex, patterns]);
|
|
69
|
+
const asyncList = useAsyncList(list, {
|
|
70
|
+
step: 10
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
const changePage = page => {
|
|
74
|
+
const scrollContainer = document.querySelector('.edit-site-patterns');
|
|
75
|
+
scrollContainer?.scrollTo(0, 0);
|
|
76
|
+
setCurrentPage(page);
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
return createElement(Fragment, null, createElement(VStack, {
|
|
80
|
+
className: "edit-site-patterns__header",
|
|
40
81
|
spacing: 6
|
|
41
|
-
}, createElement(
|
|
82
|
+
}, createElement(PatternsHeader, {
|
|
83
|
+
categoryId: categoryId,
|
|
84
|
+
type: type,
|
|
85
|
+
titleId: titleId,
|
|
86
|
+
descriptionId: descriptionId
|
|
87
|
+
}), createElement(Flex, {
|
|
88
|
+
alignment: "stretch",
|
|
89
|
+
wrap: true
|
|
90
|
+
}, isMobileViewport && createElement(SidebarButton, {
|
|
42
91
|
icon: isRTL() ? chevronRight : chevronLeft,
|
|
43
92
|
label: __('Back'),
|
|
44
93
|
onClick: () => {
|
|
@@ -52,38 +101,52 @@ export default function PatternsList({
|
|
|
52
101
|
});
|
|
53
102
|
}
|
|
54
103
|
}
|
|
55
|
-
}), createElement(FlexBlock,
|
|
104
|
+
}), createElement(FlexBlock, {
|
|
105
|
+
className: "edit-site-patterns__search-block"
|
|
106
|
+
}, createElement(SearchControl, {
|
|
56
107
|
className: "edit-site-patterns__search",
|
|
57
108
|
onChange: value => setFilterValue(value),
|
|
58
109
|
placeholder: __('Search patterns'),
|
|
59
110
|
label: __('Search patterns'),
|
|
60
111
|
value: filterValue,
|
|
61
112
|
__nextHasNoMarginBottom: true
|
|
62
|
-
}))
|
|
63
|
-
className: "edit-site-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
},
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
})),
|
|
113
|
+
})), categoryId === USER_PATTERN_CATEGORY && createElement(ToggleGroupControl, {
|
|
114
|
+
className: "edit-site-patterns__sync-status-filter",
|
|
115
|
+
hideLabelFromVision: true,
|
|
116
|
+
label: __('Filter by sync status'),
|
|
117
|
+
value: syncFilter,
|
|
118
|
+
isBlock: true,
|
|
119
|
+
onChange: value => setSyncFilter(value),
|
|
120
|
+
__nextHasNoMarginBottom: true
|
|
121
|
+
}, Object.entries(SYNC_FILTERS).map(([key, label]) => createElement(ToggleGroupControlOption, {
|
|
122
|
+
className: "edit-site-patterns__sync-status-filter-option",
|
|
123
|
+
key: key,
|
|
124
|
+
value: key,
|
|
125
|
+
label: label
|
|
126
|
+
}))))), createElement(VStack, {
|
|
127
|
+
className: "edit-site-patterns__section",
|
|
128
|
+
justify: "flex-start",
|
|
129
|
+
spacing: 6
|
|
130
|
+
}, syncFilter !== 'all' && createElement(VStack, {
|
|
76
131
|
className: "edit-site-patterns__section-header"
|
|
77
132
|
}, createElement(Heading, {
|
|
78
|
-
as: "
|
|
79
|
-
level:
|
|
80
|
-
|
|
133
|
+
as: "h3",
|
|
134
|
+
level: 5,
|
|
135
|
+
id: titleId
|
|
136
|
+
}, title), description ? createElement(Text, {
|
|
81
137
|
variant: "muted",
|
|
82
|
-
as: "p"
|
|
83
|
-
|
|
138
|
+
as: "p",
|
|
139
|
+
id: descriptionId
|
|
140
|
+
}, description) : null), hasPatterns && createElement(Grid, {
|
|
84
141
|
categoryId: categoryId,
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
142
|
+
items: asyncList,
|
|
143
|
+
"aria-labelledby": titleId,
|
|
144
|
+
"aria-describedby": descriptionId
|
|
145
|
+
}), !isResolving && !hasPatterns && createElement(NoPatterns, null)), numPages > 1 && createElement(Pagination, {
|
|
146
|
+
currentPage: currentPage,
|
|
147
|
+
numPages: numPages,
|
|
148
|
+
changePage: changePage,
|
|
149
|
+
totalItems: totalItems
|
|
150
|
+
}));
|
|
88
151
|
}
|
|
89
152
|
//# sourceMappingURL=patterns-list.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/page-patterns/patterns-list.js"],"names":["SearchControl","__experimentalHeading","Heading","__experimentalText","Text","__experimentalVStack","VStack","Flex","FlexBlock","__","isRTL","symbol","chevronLeft","chevronRight","privateApis","routerPrivateApis","useViewportMatch","Grid","NoPatterns","usePatterns","SidebarButton","useDebouncedInput","unlock","useLocation","useHistory","PatternsList","categoryId","type","location","history","isMobileViewport","filterValue","setFilterValue","delayedFilterValue","patterns","isResolving","syncedPatterns","unsyncedPatterns","hasPatterns","length","state","backPath","back","push","path","value"],"mappings":";;AAAA;AACA;AACA;AAEA,SACCA,aADD,EAECC,qBAAqB,IAAIC,OAF1B,EAGCC,kBAAkB,IAAIC,IAHvB,EAICC,oBAAoB,IAAIC,MAJzB,EAKCC,IALD,EAMCC,SAND,QAOO,uBAPP;AAQA,SAASC,EAAT,EAAaC,KAAb,QAA0B,iBAA1B;AACA,SAASC,MAAT,EAAiBC,WAAjB,EAA8BC,YAA9B,QAAkD,kBAAlD;AACA,SAASC,WAAW,IAAIC,iBAAxB,QAAiD,mBAAjD;AACA,SAASC,gBAAT,QAAiC,oBAAjC;AAEA;AACA;AACA;;AACA,OAAOC,IAAP,MAAiB,QAAjB;AACA,OAAOC,UAAP,MAAuB,eAAvB;AACA,OAAOC,WAAP,MAAwB,gBAAxB;AACA,OAAOC,aAAP,MAA0B,mBAA1B;AACA,OAAOC,iBAAP,MAA8B,iCAA9B;AACA,SAASC,MAAT,QAAuB,mBAAvB;AAEA,MAAM;AAAEC,EAAAA,WAAF;AA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AGC,IAAA,KAAK,EAAG4B;AAHT,IAXD,CAlDF,EAoEG,CAAEF,WAAF,IAAiB,CAAEG,WAAnB,IAAkC,cAAC,UAAD,OApErC,CADD;AAwEA","sourcesContent":["/**\n * WordPress dependencies\n */\n\nimport {\n\tSearchControl,\n\t__experimentalHeading as Heading,\n\t__experimentalText as Text,\n\t__experimentalVStack as VStack,\n\tFlex,\n\tFlexBlock,\n} from '@wordpress/components';\nimport { __, isRTL } from '@wordpress/i18n';\nimport { symbol, chevronLeft, chevronRight } from '@wordpress/icons';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\nimport { useViewportMatch } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport Grid from './grid';\nimport NoPatterns from './no-patterns';\nimport usePatterns from './use-patterns';\nimport SidebarButton from '../sidebar-button';\nimport useDebouncedInput from '../../utils/use-debounced-input';\nimport { unlock } from '../../lock-unlock';\n\nconst { useLocation, useHistory } = unlock( routerPrivateApis );\n\nexport default function PatternsList( { categoryId, type } ) {\n\tconst location = useLocation();\n\tconst history = useHistory();\n\tconst isMobileViewport = useViewportMatch( 'medium', '<' );\n\tconst [ filterValue, setFilterValue, delayedFilterValue ] =\n\t\tuseDebouncedInput( '' );\n\n\tconst [ patterns, isResolving ] = usePatterns(\n\t\ttype,\n\t\tcategoryId,\n\t\tdelayedFilterValue\n\t);\n\n\tconst { syncedPatterns, unsyncedPatterns } = patterns;\n\tconst hasPatterns = !! syncedPatterns.length || !! unsyncedPatterns.length;\n\n\treturn (\n\t\t<VStack spacing={ 6 }>\n\t\t\t<Flex>\n\t\t\t\t{ isMobileViewport && (\n\t\t\t\t\t<SidebarButton\n\t\t\t\t\t\ticon={ isRTL() ? chevronRight : chevronLeft }\n\t\t\t\t\t\tlabel={ __( 'Back' ) }\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t// Go back in history if we came from the Patterns page.\n\t\t\t\t\t\t\t// Otherwise push a stack onto the history.\n\t\t\t\t\t\t\tif ( location.state?.backPath === '/patterns' ) {\n\t\t\t\t\t\t\t\thistory.back();\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\thistory.push( { path: '/patterns' } );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t<FlexBlock>\n\t\t\t\t\t<SearchControl\n\t\t\t\t\t\tclassName=\"edit-site-patterns__search\"\n\t\t\t\t\t\tonChange={ ( value ) => setFilterValue( value ) }\n\t\t\t\t\t\tplaceholder={ __( 'Search patterns' ) }\n\t\t\t\t\t\tlabel={ __( 'Search patterns' ) }\n\t\t\t\t\t\tvalue={ filterValue }\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t/>\n\t\t\t\t</FlexBlock>\n\t\t\t</Flex>\n\t\t\t{ isResolving && __( 'Loading' ) }\n\t\t\t{ ! isResolving && !! syncedPatterns.length && (\n\t\t\t\t<>\n\t\t\t\t\t<VStack className=\"edit-site-patterns__section-header\">\n\t\t\t\t\t\t<Heading as=\"h2\" level={ 4 }>\n\t\t\t\t\t\t\t{ __( 'Synced' ) }\n\t\t\t\t\t\t</Heading>\n\t\t\t\t\t\t<Text variant=\"muted\" as=\"p\">\n\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t'Patterns that are kept in sync across your site'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</Text>\n\t\t\t\t\t</VStack>\n\t\t\t\t\t<Grid\n\t\t\t\t\t\ticon={ symbol }\n\t\t\t\t\t\tcategoryId={ categoryId }\n\t\t\t\t\t\tlabel={ __( 'Synced' ) }\n\t\t\t\t\t\titems={ syncedPatterns }\n\t\t\t\t\t/>\n\t\t\t\t</>\n\t\t\t) }\n\t\t\t{ ! isResolving && !! unsyncedPatterns.length && (\n\t\t\t\t<>\n\t\t\t\t\t<VStack className=\"edit-site-patterns__section-header\">\n\t\t\t\t\t\t<Heading as=\"h2\" level={ 4 }>\n\t\t\t\t\t\t\t{ __( 'Standard' ) }\n\t\t\t\t\t\t</Heading>\n\t\t\t\t\t\t<Text variant=\"muted\" as=\"p\">\n\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t'Patterns that can be changed freely without affecting your site'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</Text>\n\t\t\t\t\t</VStack>\n\t\t\t\t\t<Grid\n\t\t\t\t\t\tcategoryId={ categoryId }\n\t\t\t\t\t\tlabel={ __( 'Standard patterns' ) }\n\t\t\t\t\t\titems={ unsyncedPatterns }\n\t\t\t\t\t/>\n\t\t\t\t</>\n\t\t\t) }\n\t\t\t{ ! isResolving && ! hasPatterns && <NoPatterns /> }\n\t\t</VStack>\n\t);\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/page-patterns/patterns-list.js"],"names":["useState","useDeferredValue","useId","useMemo","SearchControl","__experimentalVStack","VStack","Flex","FlexBlock","__experimentalToggleGroupControl","ToggleGroupControl","__experimentalToggleGroupControlOption","ToggleGroupControlOption","__experimentalHeading","Heading","__experimentalText","Text","__","isRTL","chevronLeft","chevronRight","privateApis","routerPrivateApis","useAsyncList","useViewportMatch","PatternsHeader","Grid","NoPatterns","usePatterns","SidebarButton","useDebouncedInput","unlock","SYNC_TYPES","USER_PATTERN_CATEGORY","Pagination","useLocation","useHistory","SYNC_FILTERS","all","full","unsynced","SYNC_DESCRIPTIONS","PAGE_SIZE","PatternsList","categoryId","type","location","history","isMobileViewport","filterValue","setFilterValue","delayedFilterValue","deferredFilterValue","syncFilter","setSyncFilter","currentPage","setCurrentPage","deferredSyncedFilter","patterns","isResolving","search","syncStatus","undefined","id","titleId","descriptionId","hasPatterns","length","title","description","totalItems","pageIndex","numPages","Math","ceil","list","slice","asyncList","step","changePage","page","scrollContainer","document","querySelector","scrollTo","state","backPath","back","push","path","value","Object","entries","map","key","label"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,QAAT,EAAmBC,gBAAnB,EAAqCC,KAArC,EAA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cAAC,MAAD;AAAQ,IAAA,SAAS,EAAC;AAAlB,KACC,cAAC,OAAD;AAAS,IAAA,EAAE,EAAC,IAAZ;AAAiB,IAAA,KAAK,EAAG,CAAzB;AAA6B,IAAA,EAAE,EAAGW;AAAlC,KACGI,KADH,CADD,EAIGC,WAAW,GACZ,cAAC,IAAD;AAAM,IAAA,OAAO,EAAC,OAAd;AAAsB,IAAA,EAAE,EAAC,GAAzB;AAA6B,IAAA,EAAE,EAAGJ;AAAlC,KACGI,WADH,CADY,GAIT,IARL,CANF,EAiBGH,WAAW,IACZ,cAAC,IAAD;AACC,IAAA,UAAU,EAAGtB,UADd;AAEC,IAAA,KAAK,EAAGiC,SAFT;AAGC,uBAAkBb,OAHnB;AAIC,wBAAmBC;AAJpB,IAlBF,EAyBG,CAAEN,WAAF,IAAiB,CAAEO,WAAnB,IAAkC,cAAC,UAAD,OAzBrC,CA5DD,EAuFGM,QAAQ,GAAG,CAAX,IACD,cAAC,UAAD;AACC,IAAA,WAAW,EAAGjB,WADf;AAEC,IAAA,QAAQ,EAAGiB,QAFZ;AAGC,IAAA,UAAU,EAAGO,UAHd;AAIC,IAAA,UAAU,EAAGT;AAJd,IAxFF,CADD;AAkGA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useState, useDeferredValue, useId, useMemo } from '@wordpress/element';\nimport {\n\tSearchControl,\n\t__experimentalVStack as VStack,\n\tFlex,\n\tFlexBlock,\n\t__experimentalToggleGroupControl as ToggleGroupControl,\n\t__experimentalToggleGroupControlOption as ToggleGroupControlOption,\n\t__experimentalHeading as Heading,\n\t__experimentalText as Text,\n} from '@wordpress/components';\nimport { __, isRTL } from '@wordpress/i18n';\nimport { chevronLeft, chevronRight } from '@wordpress/icons';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\nimport { useAsyncList, useViewportMatch } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport PatternsHeader from './header';\nimport Grid from './grid';\nimport NoPatterns from './no-patterns';\nimport usePatterns from './use-patterns';\nimport SidebarButton from '../sidebar-button';\nimport useDebouncedInput from '../../utils/use-debounced-input';\nimport { unlock } from '../../lock-unlock';\nimport { SYNC_TYPES, USER_PATTERN_CATEGORY } from './utils';\nimport Pagination from './pagination';\n\nconst { useLocation, useHistory } = unlock( routerPrivateApis );\n\nconst SYNC_FILTERS = {\n\tall: __( 'All' ),\n\t[ SYNC_TYPES.full ]: __( 'Synced' ),\n\t[ SYNC_TYPES.unsynced ]: __( 'Standard' ),\n};\n\nconst SYNC_DESCRIPTIONS = {\n\tall: '',\n\t[ SYNC_TYPES.full ]: __(\n\t\t'Patterns that are kept in sync across the site.'\n\t),\n\t[ SYNC_TYPES.unsynced ]: __(\n\t\t'Patterns that can be changed freely without affecting the site.'\n\t),\n};\n\nconst PAGE_SIZE = 20;\n\nexport default function PatternsList( { categoryId, type } ) {\n\tconst location = useLocation();\n\tconst history = useHistory();\n\tconst isMobileViewport = useViewportMatch( 'medium', '<' );\n\tconst [ filterValue, setFilterValue, delayedFilterValue ] =\n\t\tuseDebouncedInput( '' );\n\tconst deferredFilterValue = useDeferredValue( delayedFilterValue );\n\n\tconst [ syncFilter, setSyncFilter ] = useState( 'all' );\n\tconst [ currentPage, setCurrentPage ] = useState( 1 );\n\n\tconst deferredSyncedFilter = useDeferredValue( syncFilter );\n\n\tconst { patterns, isResolving } = usePatterns(\n\t\ttype,\n\t\tcategoryId !== 'uncategorized' ? categoryId : '',\n\t\t{\n\t\t\tsearch: deferredFilterValue,\n\t\t\tsyncStatus:\n\t\t\t\tdeferredSyncedFilter === 'all'\n\t\t\t\t\t? undefined\n\t\t\t\t\t: deferredSyncedFilter,\n\t\t}\n\t);\n\n\tconst id = useId();\n\tconst titleId = `${ id }-title`;\n\tconst descriptionId = `${ id }-description`;\n\n\tconst hasPatterns = patterns.length;\n\tconst title = SYNC_FILTERS[ syncFilter ];\n\tconst description = SYNC_DESCRIPTIONS[ syncFilter ];\n\n\tconst totalItems = patterns.length;\n\tconst pageIndex = currentPage - 1;\n\tconst numPages = Math.ceil( patterns.length / PAGE_SIZE );\n\n\tconst list = useMemo(\n\t\t() =>\n\t\t\tpatterns.slice(\n\t\t\t\tpageIndex * PAGE_SIZE,\n\t\t\t\tpageIndex * PAGE_SIZE + PAGE_SIZE\n\t\t\t),\n\t\t[ pageIndex, patterns ]\n\t);\n\n\tconst asyncList = useAsyncList( list, { step: 10 } );\n\n\tconst changePage = ( page ) => {\n\t\tconst scrollContainer = document.querySelector( '.edit-site-patterns' );\n\t\tscrollContainer?.scrollTo( 0, 0 );\n\n\t\tsetCurrentPage( page );\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t<VStack className=\"edit-site-patterns__header\" spacing={ 6 }>\n\t\t\t\t<PatternsHeader\n\t\t\t\t\tcategoryId={ categoryId }\n\t\t\t\t\ttype={ type }\n\t\t\t\t\ttitleId={ titleId }\n\t\t\t\t\tdescriptionId={ descriptionId }\n\t\t\t\t/>\n\t\t\t\t<Flex alignment=\"stretch\" wrap>\n\t\t\t\t\t{ isMobileViewport && (\n\t\t\t\t\t\t<SidebarButton\n\t\t\t\t\t\t\ticon={ isRTL() ? chevronRight : chevronLeft }\n\t\t\t\t\t\t\tlabel={ __( 'Back' ) }\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t// Go back in history if we came from the Patterns page.\n\t\t\t\t\t\t\t\t// Otherwise push a stack onto the history.\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\tlocation.state?.backPath === '/patterns'\n\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\thistory.back();\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\thistory.push( { path: '/patterns' } );\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t\t<FlexBlock className=\"edit-site-patterns__search-block\">\n\t\t\t\t\t\t<SearchControl\n\t\t\t\t\t\t\tclassName=\"edit-site-patterns__search\"\n\t\t\t\t\t\t\tonChange={ ( value ) => setFilterValue( value ) }\n\t\t\t\t\t\t\tplaceholder={ __( 'Search patterns' ) }\n\t\t\t\t\t\t\tlabel={ __( 'Search patterns' ) }\n\t\t\t\t\t\t\tvalue={ filterValue }\n\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t/>\n\t\t\t\t\t</FlexBlock>\n\t\t\t\t\t{ categoryId === USER_PATTERN_CATEGORY && (\n\t\t\t\t\t\t<ToggleGroupControl\n\t\t\t\t\t\t\tclassName=\"edit-site-patterns__sync-status-filter\"\n\t\t\t\t\t\t\thideLabelFromVision\n\t\t\t\t\t\t\tlabel={ __( 'Filter by sync status' ) }\n\t\t\t\t\t\t\tvalue={ syncFilter }\n\t\t\t\t\t\t\tisBlock\n\t\t\t\t\t\t\tonChange={ ( value ) => setSyncFilter( value ) }\n\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ Object.entries( SYNC_FILTERS ).map(\n\t\t\t\t\t\t\t\t( [ key, label ] ) => (\n\t\t\t\t\t\t\t\t\t<ToggleGroupControlOption\n\t\t\t\t\t\t\t\t\t\tclassName=\"edit-site-patterns__sync-status-filter-option\"\n\t\t\t\t\t\t\t\t\t\tkey={ key }\n\t\t\t\t\t\t\t\t\t\tvalue={ key }\n\t\t\t\t\t\t\t\t\t\tlabel={ label }\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</ToggleGroupControl>\n\t\t\t\t\t) }\n\t\t\t\t</Flex>\n\t\t\t</VStack>\n\t\t\t<VStack\n\t\t\t\tclassName=\"edit-site-patterns__section\"\n\t\t\t\tjustify=\"flex-start\"\n\t\t\t\tspacing={ 6 }\n\t\t\t>\n\t\t\t\t{ syncFilter !== 'all' && (\n\t\t\t\t\t<VStack className=\"edit-site-patterns__section-header\">\n\t\t\t\t\t\t<Heading as=\"h3\" level={ 5 } id={ titleId }>\n\t\t\t\t\t\t\t{ title }\n\t\t\t\t\t\t</Heading>\n\t\t\t\t\t\t{ description ? (\n\t\t\t\t\t\t\t<Text variant=\"muted\" as=\"p\" id={ descriptionId }>\n\t\t\t\t\t\t\t\t{ description }\n\t\t\t\t\t\t\t</Text>\n\t\t\t\t\t\t) : null }\n\t\t\t\t\t</VStack>\n\t\t\t\t) }\n\t\t\t\t{ hasPatterns && (\n\t\t\t\t\t<Grid\n\t\t\t\t\t\tcategoryId={ categoryId }\n\t\t\t\t\t\titems={ asyncList }\n\t\t\t\t\t\taria-labelledby={ titleId }\n\t\t\t\t\t\taria-describedby={ descriptionId }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t{ ! isResolving && ! hasPatterns && <NoPatterns /> }\n\t\t\t</VStack>\n\t\t\t{ numPages > 1 && (\n\t\t\t\t<Pagination\n\t\t\t\t\tcurrentPage={ currentPage }\n\t\t\t\t\tnumPages={ numPages }\n\t\t\t\t\tchangePage={ changePage }\n\t\t\t\t\ttotalItems={ totalItems }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n"]}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { createElement, Fragment } from "@wordpress/element";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* WordPress dependencies
|
|
5
|
+
*/
|
|
6
|
+
import { Button, MenuItem, Modal, TextControl, __experimentalHStack as HStack, __experimentalVStack as VStack } from '@wordpress/components';
|
|
7
|
+
import { store as coreStore } from '@wordpress/core-data';
|
|
8
|
+
import { useDispatch } from '@wordpress/data';
|
|
9
|
+
import { useState } from '@wordpress/element';
|
|
10
|
+
import { __ } from '@wordpress/i18n';
|
|
11
|
+
import { store as noticesStore } from '@wordpress/notices';
|
|
12
|
+
/**
|
|
13
|
+
* Internal dependencies
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import { TEMPLATE_PARTS } from './utils';
|
|
17
|
+
export default function RenameMenuItem({
|
|
18
|
+
item,
|
|
19
|
+
onClose
|
|
20
|
+
}) {
|
|
21
|
+
const [title, setTitle] = useState(() => item.title);
|
|
22
|
+
const [isModalOpen, setIsModalOpen] = useState(false);
|
|
23
|
+
const {
|
|
24
|
+
editEntityRecord,
|
|
25
|
+
saveEditedEntityRecord
|
|
26
|
+
} = useDispatch(coreStore);
|
|
27
|
+
const {
|
|
28
|
+
createSuccessNotice,
|
|
29
|
+
createErrorNotice
|
|
30
|
+
} = useDispatch(noticesStore);
|
|
31
|
+
|
|
32
|
+
if (item.type === TEMPLATE_PARTS && !item.isCustom) {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
async function onRename(event) {
|
|
37
|
+
event.preventDefault();
|
|
38
|
+
|
|
39
|
+
try {
|
|
40
|
+
await editEntityRecord('postType', item.type, item.id, {
|
|
41
|
+
title
|
|
42
|
+
}); // Update state before saving rerenders the list.
|
|
43
|
+
|
|
44
|
+
setTitle('');
|
|
45
|
+
setIsModalOpen(false);
|
|
46
|
+
onClose(); // Persist edited entity.
|
|
47
|
+
|
|
48
|
+
await saveEditedEntityRecord('postType', item.type, item.id, {
|
|
49
|
+
throwOnError: true
|
|
50
|
+
});
|
|
51
|
+
createSuccessNotice(__('Entity renamed.'), {
|
|
52
|
+
type: 'snackbar'
|
|
53
|
+
});
|
|
54
|
+
} catch (error) {
|
|
55
|
+
const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : __('An error occurred while renaming the entity.');
|
|
56
|
+
createErrorNotice(errorMessage, {
|
|
57
|
+
type: 'snackbar'
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return createElement(Fragment, null, createElement(MenuItem, {
|
|
63
|
+
onClick: () => {
|
|
64
|
+
setIsModalOpen(true);
|
|
65
|
+
setTitle(item.title);
|
|
66
|
+
}
|
|
67
|
+
}, __('Rename')), isModalOpen && createElement(Modal, {
|
|
68
|
+
title: __('Rename'),
|
|
69
|
+
onRequestClose: () => {
|
|
70
|
+
setIsModalOpen(false);
|
|
71
|
+
onClose();
|
|
72
|
+
},
|
|
73
|
+
overlayClassName: "edit-site-list__rename_modal"
|
|
74
|
+
}, createElement("form", {
|
|
75
|
+
onSubmit: onRename
|
|
76
|
+
}, createElement(VStack, {
|
|
77
|
+
spacing: "5"
|
|
78
|
+
}, createElement(TextControl, {
|
|
79
|
+
__nextHasNoMarginBottom: true,
|
|
80
|
+
label: __('Name'),
|
|
81
|
+
value: title,
|
|
82
|
+
onChange: setTitle,
|
|
83
|
+
required: true
|
|
84
|
+
}), createElement(HStack, {
|
|
85
|
+
justify: "right"
|
|
86
|
+
}, createElement(Button, {
|
|
87
|
+
variant: "tertiary",
|
|
88
|
+
onClick: () => {
|
|
89
|
+
setIsModalOpen(false);
|
|
90
|
+
onClose();
|
|
91
|
+
}
|
|
92
|
+
}, __('Cancel')), createElement(Button, {
|
|
93
|
+
variant: "primary",
|
|
94
|
+
type: "submit"
|
|
95
|
+
}, __('Save')))))));
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=rename-menu-item.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/page-patterns/rename-menu-item.js"],"names":["Button","MenuItem","Modal","TextControl","__experimentalHStack","HStack","__experimentalVStack","VStack","store","coreStore","useDispatch","useState","__","noticesStore","TEMPLATE_PARTS","RenameMenuItem","item","onClose","title","setTitle","isModalOpen","setIsModalOpen","editEntityRecord","saveEditedEntityRecord","createSuccessNotice","createErrorNotice","type","isCustom","onRename","event","preventDefault","id","throwOnError","error","errorMessage","message","code"],"mappings":";;AAAA;AACA;AACA;AACA,SACCA,MADD,EAECC,QAFD,EAGCC,KAHD,EAICC,WAJD,EAKCC,oBAAoB,IAAIC,MALzB,EAMCC,oBAAoB,IAAIC,MANzB,QAOO,uBAPP;AAQA,SAASC,KAAK,IAAIC,SAAlB,QAAmC,sBAAnC;A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P;AALF,KAOGL,EAAE,CAAE,QAAF,CAPL,CADD,EAWC,cAAC,MAAD;AAAQ,IAAA,OAAO,EAAC,SAAhB;AAA0B,IAAA,IAAI,EAAC;AAA/B,KACGA,EAAE,CAAE,MAAF,CADL,CAXD,CATD,CADD,CARD,CAVF,CADD;AAkDA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tButton,\n\tMenuItem,\n\tModal,\n\tTextControl,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useDispatch } from '@wordpress/data';\nimport { useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport { TEMPLATE_PARTS } from './utils';\n\nexport default function RenameMenuItem( { item, onClose } ) {\n\tconst [ title, setTitle ] = useState( () => item.title );\n\tconst [ isModalOpen, setIsModalOpen ] = useState( false );\n\n\tconst { editEntityRecord, saveEditedEntityRecord } =\n\t\tuseDispatch( coreStore );\n\tconst { createSuccessNotice, createErrorNotice } =\n\t\tuseDispatch( noticesStore );\n\n\tif ( item.type === TEMPLATE_PARTS && ! item.isCustom ) {\n\t\treturn null;\n\t}\n\n\tasync function onRename( event ) {\n\t\tevent.preventDefault();\n\n\t\ttry {\n\t\t\tawait editEntityRecord( 'postType', item.type, item.id, { title } );\n\n\t\t\t// Update state before saving rerenders the list.\n\t\t\tsetTitle( '' );\n\t\t\tsetIsModalOpen( false );\n\t\t\tonClose();\n\n\t\t\t// Persist edited entity.\n\t\t\tawait saveEditedEntityRecord( 'postType', item.type, item.id, {\n\t\t\t\tthrowOnError: true,\n\t\t\t} );\n\n\t\t\tcreateSuccessNotice( __( 'Entity renamed.' ), {\n\t\t\t\ttype: 'snackbar',\n\t\t\t} );\n\t\t} catch ( error ) {\n\t\t\tconst errorMessage =\n\t\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t\t? error.message\n\t\t\t\t\t: __( 'An error occurred while renaming the entity.' );\n\n\t\t\tcreateErrorNotice( errorMessage, { type: 'snackbar' } );\n\t\t}\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<MenuItem\n\t\t\t\tonClick={ () => {\n\t\t\t\t\tsetIsModalOpen( true );\n\t\t\t\t\tsetTitle( item.title );\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t{ __( 'Rename' ) }\n\t\t\t</MenuItem>\n\t\t\t{ isModalOpen && (\n\t\t\t\t<Modal\n\t\t\t\t\ttitle={ __( 'Rename' ) }\n\t\t\t\t\tonRequestClose={ () => {\n\t\t\t\t\t\tsetIsModalOpen( false );\n\t\t\t\t\t\tonClose();\n\t\t\t\t\t} }\n\t\t\t\t\toverlayClassName=\"edit-site-list__rename_modal\"\n\t\t\t\t>\n\t\t\t\t\t<form onSubmit={ onRename }>\n\t\t\t\t\t\t<VStack spacing=\"5\">\n\t\t\t\t\t\t\t<TextControl\n\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\tlabel={ __( 'Name' ) }\n\t\t\t\t\t\t\t\tvalue={ title }\n\t\t\t\t\t\t\t\tonChange={ setTitle }\n\t\t\t\t\t\t\t\trequired\n\t\t\t\t\t\t\t/>\n\n\t\t\t\t\t\t\t<HStack justify=\"right\">\n\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\tsetIsModalOpen( false );\n\t\t\t\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t\t\t\t</Button>\n\n\t\t\t\t\t\t\t\t<Button variant=\"primary\" type=\"submit\">\n\t\t\t\t\t\t\t\t\t{ __( 'Save' ) }\n\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t</HStack>\n\t\t\t\t\t\t</VStack>\n\t\t\t\t\t</form>\n\t\t\t\t</Modal>\n\t\t\t) }\n\t\t</>\n\t);\n}\n"]}
|
|
@@ -4,12 +4,12 @@
|
|
|
4
4
|
import { parse } from '@wordpress/blocks';
|
|
5
5
|
import { useSelect } from '@wordpress/data';
|
|
6
6
|
import { store as coreStore } from '@wordpress/core-data';
|
|
7
|
-
import {
|
|
7
|
+
import { decodeEntities } from '@wordpress/html-entities';
|
|
8
8
|
/**
|
|
9
9
|
* Internal dependencies
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
import { CORE_PATTERN_SOURCES, PATTERNS, SYNC_TYPES, TEMPLATE_PARTS, USER_PATTERNS,
|
|
12
|
+
import { CORE_PATTERN_SOURCES, PATTERNS, SYNC_TYPES, TEMPLATE_PARTS, USER_PATTERNS, filterOutDuplicatesByName } from './utils';
|
|
13
13
|
import { unlock } from '../../lock-unlock';
|
|
14
14
|
import { searchItems } from './search-items';
|
|
15
15
|
import { store as editSiteStore } from '../../store';
|
|
@@ -21,92 +21,76 @@ const templatePartToPattern = templatePart => ({
|
|
|
21
21
|
blocks: parse(templatePart.content.raw),
|
|
22
22
|
categories: [templatePart.area],
|
|
23
23
|
description: templatePart.description || '',
|
|
24
|
+
isCustom: templatePart.source === 'custom',
|
|
24
25
|
keywords: templatePart.keywords || [],
|
|
26
|
+
id: createTemplatePartId(templatePart.theme, templatePart.slug),
|
|
25
27
|
name: createTemplatePartId(templatePart.theme, templatePart.slug),
|
|
26
|
-
title: templatePart.title.rendered,
|
|
28
|
+
title: decodeEntities(templatePart.title.rendered),
|
|
27
29
|
type: templatePart.type,
|
|
28
30
|
templatePart
|
|
29
31
|
});
|
|
30
32
|
|
|
31
|
-
const
|
|
33
|
+
const templatePartHasCategory = (item, category) => item.templatePart.area === category;
|
|
32
34
|
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
return item.templatePart.area === category;
|
|
39
|
-
};
|
|
35
|
+
const selectTemplatePartsAsPatterns = (select, {
|
|
36
|
+
categoryId,
|
|
37
|
+
search = ''
|
|
38
|
+
} = {}) => {
|
|
39
|
+
var _getEntityRecords;
|
|
40
40
|
|
|
41
|
-
const useTemplatePartsAsPatterns = (categoryId, postType = TEMPLATE_PARTS, filterValue = '') => {
|
|
42
41
|
const {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
} =
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
} = select(coreStore);
|
|
57
|
-
const query = {
|
|
58
|
-
per_page: -1
|
|
59
|
-
};
|
|
60
|
-
const rawTemplateParts = getEntityRecords('postType', postType, query);
|
|
61
|
-
const partsAsPatterns = rawTemplateParts?.map(templatePart => templatePartToPattern(templatePart));
|
|
62
|
-
return {
|
|
63
|
-
templateParts: partsAsPatterns,
|
|
64
|
-
isResolving: _isResolving('getEntityRecords', ['postType', 'wp_template_part', query])
|
|
65
|
-
};
|
|
66
|
-
}, [postType]);
|
|
67
|
-
const filteredTemplateParts = useMemo(() => {
|
|
68
|
-
if (!templateParts) {
|
|
69
|
-
return EMPTY_PATTERN_LIST;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
return searchItems(templateParts, filterValue, {
|
|
73
|
-
categoryId,
|
|
74
|
-
hasCategory: templatePartHasCategory
|
|
75
|
-
});
|
|
76
|
-
}, [templateParts, filterValue, categoryId]);
|
|
42
|
+
getEntityRecords,
|
|
43
|
+
getIsResolving
|
|
44
|
+
} = select(coreStore);
|
|
45
|
+
const query = {
|
|
46
|
+
per_page: -1
|
|
47
|
+
};
|
|
48
|
+
const rawTemplateParts = (_getEntityRecords = getEntityRecords('postType', TEMPLATE_PARTS, query)) !== null && _getEntityRecords !== void 0 ? _getEntityRecords : EMPTY_PATTERN_LIST;
|
|
49
|
+
const templateParts = rawTemplateParts.map(templatePart => templatePartToPattern(templatePart));
|
|
50
|
+
const isResolving = getIsResolving('getEntityRecords', ['postType', 'wp_template_part', query]);
|
|
51
|
+
const patterns = searchItems(templateParts, search, {
|
|
52
|
+
categoryId,
|
|
53
|
+
hasCategory: templatePartHasCategory
|
|
54
|
+
});
|
|
77
55
|
return {
|
|
78
|
-
|
|
56
|
+
patterns,
|
|
79
57
|
isResolving
|
|
80
58
|
};
|
|
81
59
|
};
|
|
82
60
|
|
|
83
|
-
const
|
|
84
|
-
|
|
85
|
-
|
|
61
|
+
const selectThemePatterns = (select, {
|
|
62
|
+
categoryId,
|
|
63
|
+
search = ''
|
|
64
|
+
} = {}) => {
|
|
65
|
+
var _settings$__experimen;
|
|
86
66
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
const patterns = useMemo(() => [...(blockPatterns || []), ...(restBlockPatterns || [])].filter(pattern => !CORE_PATTERN_SOURCES.includes(pattern.source)).filter(filterOutDuplicatesByName).map(pattern => ({ ...pattern,
|
|
67
|
+
const {
|
|
68
|
+
getSettings
|
|
69
|
+
} = unlock(select(editSiteStore));
|
|
70
|
+
const settings = getSettings();
|
|
71
|
+
const blockPatterns = (_settings$__experimen = settings.__experimentalAdditionalBlockPatterns) !== null && _settings$__experimen !== void 0 ? _settings$__experimen : settings.__experimentalBlockPatterns;
|
|
72
|
+
const restBlockPatterns = select(coreStore).getBlockPatterns();
|
|
73
|
+
let patterns = [...(blockPatterns || []), ...(restBlockPatterns || [])].filter(pattern => !CORE_PATTERN_SOURCES.includes(pattern.source)).filter(filterOutDuplicatesByName).filter(pattern => pattern.inserter !== false).map(pattern => ({ ...pattern,
|
|
95
74
|
keywords: pattern.keywords || [],
|
|
96
75
|
type: 'pattern',
|
|
97
76
|
blocks: parse(pattern.content)
|
|
98
|
-
}))
|
|
99
|
-
const filteredPatterns = useMemo(() => {
|
|
100
|
-
if (postType !== PATTERNS) {
|
|
101
|
-
return EMPTY_PATTERN_LIST;
|
|
102
|
-
}
|
|
77
|
+
}));
|
|
103
78
|
|
|
104
|
-
|
|
79
|
+
if (categoryId) {
|
|
80
|
+
patterns = searchItems(patterns, search, {
|
|
105
81
|
categoryId,
|
|
106
82
|
hasCategory: (item, currentCategory) => item.categories?.includes(currentCategory)
|
|
107
83
|
});
|
|
108
|
-
}
|
|
109
|
-
|
|
84
|
+
} else {
|
|
85
|
+
patterns = searchItems(patterns, search, {
|
|
86
|
+
hasCategory: item => !item.hasOwnProperty('categories')
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return {
|
|
91
|
+
patterns,
|
|
92
|
+
isResolving: false
|
|
93
|
+
};
|
|
110
94
|
};
|
|
111
95
|
|
|
112
96
|
const reusableBlockToPattern = reusableBlock => ({
|
|
@@ -120,67 +104,64 @@ const reusableBlockToPattern = reusableBlock => ({
|
|
|
120
104
|
reusableBlock
|
|
121
105
|
});
|
|
122
106
|
|
|
123
|
-
const
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
if (!records) {
|
|
138
|
-
return EMPTY_PATTERN_LIST;
|
|
139
|
-
}
|
|
107
|
+
const selectUserPatterns = (select, {
|
|
108
|
+
search = '',
|
|
109
|
+
syncStatus
|
|
110
|
+
} = {}) => {
|
|
111
|
+
const {
|
|
112
|
+
getEntityRecords,
|
|
113
|
+
getIsResolving
|
|
114
|
+
} = select(coreStore);
|
|
115
|
+
const query = {
|
|
116
|
+
per_page: -1
|
|
117
|
+
};
|
|
118
|
+
const records = getEntityRecords('postType', USER_PATTERNS, query);
|
|
119
|
+
let patterns = records ? records.map(record => reusableBlockToPattern(record)) : EMPTY_PATTERN_LIST;
|
|
120
|
+
const isResolving = getIsResolving('getEntityRecords', ['postType', USER_PATTERNS, query]);
|
|
140
121
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
if (!unfilteredPatterns.length) {
|
|
145
|
-
return EMPTY_PATTERN_LIST;
|
|
146
|
-
}
|
|
122
|
+
if (syncStatus) {
|
|
123
|
+
patterns = patterns.filter(pattern => pattern.syncStatus === syncStatus);
|
|
124
|
+
}
|
|
147
125
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
});
|
|
154
|
-
}, [unfilteredPatterns, filterValue]);
|
|
155
|
-
const patterns = {
|
|
156
|
-
syncedPatterns: [],
|
|
157
|
-
unsyncedPatterns: []
|
|
158
|
-
};
|
|
159
|
-
filteredPatterns.forEach(pattern => {
|
|
160
|
-
if (pattern.syncStatus === SYNC_TYPES.full) {
|
|
161
|
-
patterns.syncedPatterns.push(pattern);
|
|
162
|
-
} else {
|
|
163
|
-
patterns.unsyncedPatterns.push(pattern);
|
|
164
|
-
}
|
|
126
|
+
patterns = searchItems(patterns, search, {
|
|
127
|
+
// We exit user pattern retrieval early if we aren't in the
|
|
128
|
+
// catch-all category for user created patterns, so it has
|
|
129
|
+
// to be in the category.
|
|
130
|
+
hasCategory: () => true
|
|
165
131
|
});
|
|
166
|
-
return
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
export const usePatterns = (categoryType, categoryId, filterValue) => {
|
|
170
|
-
const blockPatterns = useThemePatterns(categoryId, categoryType, filterValue);
|
|
171
|
-
const {
|
|
172
|
-
syncedPatterns = [],
|
|
173
|
-
unsyncedPatterns = []
|
|
174
|
-
} = useUserPatterns(categoryId, categoryType, filterValue);
|
|
175
|
-
const {
|
|
176
|
-
templateParts,
|
|
132
|
+
return {
|
|
133
|
+
patterns,
|
|
177
134
|
isResolving
|
|
178
|
-
} = useTemplatePartsAsPatterns(categoryId, categoryType, filterValue);
|
|
179
|
-
const patterns = {
|
|
180
|
-
syncedPatterns: [...templateParts, ...syncedPatterns],
|
|
181
|
-
unsyncedPatterns: [...blockPatterns, ...unsyncedPatterns]
|
|
182
135
|
};
|
|
183
|
-
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
export const usePatterns = (categoryType, categoryId, {
|
|
139
|
+
search = '',
|
|
140
|
+
syncStatus
|
|
141
|
+
}) => {
|
|
142
|
+
return useSelect(select => {
|
|
143
|
+
if (categoryType === TEMPLATE_PARTS) {
|
|
144
|
+
return selectTemplatePartsAsPatterns(select, {
|
|
145
|
+
categoryId,
|
|
146
|
+
search
|
|
147
|
+
});
|
|
148
|
+
} else if (categoryType === PATTERNS) {
|
|
149
|
+
return selectThemePatterns(select, {
|
|
150
|
+
categoryId,
|
|
151
|
+
search
|
|
152
|
+
});
|
|
153
|
+
} else if (categoryType === USER_PATTERNS) {
|
|
154
|
+
return selectUserPatterns(select, {
|
|
155
|
+
search,
|
|
156
|
+
syncStatus
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
return {
|
|
161
|
+
patterns: EMPTY_PATTERN_LIST,
|
|
162
|
+
isResolving: false
|
|
163
|
+
};
|
|
164
|
+
}, [categoryId, categoryType, search, syncStatus]);
|
|
184
165
|
};
|
|
185
166
|
export default usePatterns;
|
|
186
167
|
//# sourceMappingURL=use-patterns.js.map
|