@wordpress/global-styles-ui 1.1.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/LICENSE.md +788 -0
- package/README.md +48 -0
- package/build/background-panel.js +62 -0
- package/build/background-panel.js.map +7 -0
- package/build/block-preview-panel.js +90 -0
- package/build/block-preview-panel.js.map +7 -0
- package/build/color-indicator-wrapper.js +55 -0
- package/build/color-indicator-wrapper.js.map +7 -0
- package/build/color-palette-panel.js +123 -0
- package/build/color-palette-panel.js.map +7 -0
- package/build/color-preview.js +94 -0
- package/build/color-preview.js.map +7 -0
- package/build/color-variations.js +41 -0
- package/build/color-variations.js.map +7 -0
- package/build/confirm-reset-shadow-dialog.js +55 -0
- package/build/confirm-reset-shadow-dialog.js.map +7 -0
- package/build/context.js +37 -0
- package/build/context.js.map +7 -0
- package/build/dimensions-panel.js +89 -0
- package/build/dimensions-panel.js.map +7 -0
- package/build/font-families.js +114 -0
- package/build/font-families.js.map +7 -0
- package/build/font-family-item.js +48 -0
- package/build/font-family-item.js.map +7 -0
- package/build/font-library-modal/collection-font-variant.js +75 -0
- package/build/font-library-modal/collection-font-variant.js.map +7 -0
- package/build/font-library-modal/context.js +386 -0
- package/build/font-library-modal/context.js.map +7 -0
- package/build/font-library-modal/font-card.js +81 -0
- package/build/font-library-modal/font-card.js.map +7 -0
- package/build/font-library-modal/font-collection.js +510 -0
- package/build/font-library-modal/font-collection.js.map +7 -0
- package/build/font-library-modal/font-demo.js +111 -0
- package/build/font-library-modal/font-demo.js.map +7 -0
- package/build/font-library-modal/google-fonts-confirm-dialog.js +58 -0
- package/build/font-library-modal/google-fonts-confirm-dialog.js.map +7 -0
- package/build/font-library-modal/index.js +110 -0
- package/build/font-library-modal/index.js.map +7 -0
- package/build/font-library-modal/installed-fonts.js +453 -0
- package/build/font-library-modal/installed-fonts.js.map +7 -0
- package/build/font-library-modal/lib/inflate.js +2628 -0
- package/build/font-library-modal/lib/inflate.js.map +7 -0
- package/build/font-library-modal/lib/lib-font.browser.d.js +33 -0
- package/build/font-library-modal/lib/lib-font.browser.d.js.map +7 -0
- package/build/font-library-modal/lib/lib-font.browser.js +3788 -0
- package/build/font-library-modal/lib/lib-font.browser.js.map +7 -0
- package/build/font-library-modal/lib/unbrotli.js +3678 -0
- package/build/font-library-modal/lib/unbrotli.js.map +7 -0
- package/build/font-library-modal/library-font-details.js +63 -0
- package/build/font-library-modal/library-font-details.js.map +7 -0
- package/build/font-library-modal/library-font-variant.js +81 -0
- package/build/font-library-modal/library-font-variant.js.map +7 -0
- package/build/font-library-modal/resolvers.js +115 -0
- package/build/font-library-modal/resolvers.js.map +7 -0
- package/build/font-library-modal/types.js +17 -0
- package/build/font-library-modal/types.js.map +7 -0
- package/build/font-library-modal/upload-fonts.js +207 -0
- package/build/font-library-modal/upload-fonts.js.map +7 -0
- package/build/font-library-modal/utils/constants.js +49 -0
- package/build/font-library-modal/utils/constants.js.map +7 -0
- package/build/font-library-modal/utils/filter-fonts.js +39 -0
- package/build/font-library-modal/utils/filter-fonts.js.map +7 -0
- package/build/font-library-modal/utils/fonts-outline.js +51 -0
- package/build/font-library-modal/utils/fonts-outline.js.map +7 -0
- package/build/font-library-modal/utils/index.js +274 -0
- package/build/font-library-modal/utils/index.js.map +7 -0
- package/build/font-library-modal/utils/make-families-from-faces.js +45 -0
- package/build/font-library-modal/utils/make-families-from-faces.js.map +7 -0
- package/build/font-library-modal/utils/preview-styles.js +119 -0
- package/build/font-library-modal/utils/preview-styles.js.map +7 -0
- package/build/font-library-modal/utils/set-immutably.js +40 -0
- package/build/font-library-modal/utils/set-immutably.js.map +7 -0
- package/build/font-library-modal/utils/sort-font-faces.js +59 -0
- package/build/font-library-modal/utils/sort-font-faces.js.map +7 -0
- package/build/font-library-modal/utils/toggleFont.js +67 -0
- package/build/font-library-modal/utils/toggleFont.js.map +7 -0
- package/build/font-sizes/confirm-delete-font-size-dialog.js +60 -0
- package/build/font-sizes/confirm-delete-font-size-dialog.js.map +7 -0
- package/build/font-sizes/confirm-reset-font-sizes-dialog.js +55 -0
- package/build/font-sizes/confirm-reset-font-sizes-dialog.js.map +7 -0
- package/build/font-sizes/font-size-preview.js +50 -0
- package/build/font-sizes/font-size-preview.js.map +7 -0
- package/build/font-sizes/font-size.js +261 -0
- package/build/font-sizes/font-size.js.map +7 -0
- package/build/font-sizes/font-sizes-count.js +40 -0
- package/build/font-sizes/font-sizes-count.js.map +7 -0
- package/build/font-sizes/font-sizes.js +215 -0
- package/build/font-sizes/font-sizes.js.map +7 -0
- package/build/font-sizes/rename-font-size-dialog.js +96 -0
- package/build/font-sizes/rename-font-size-dialog.js.map +7 -0
- package/build/global-styles-ui.js +213 -0
- package/build/global-styles-ui.js.map +7 -0
- package/build/gradients-palette-panel.js +133 -0
- package/build/gradients-palette-panel.js.map +7 -0
- package/build/highlighted-colors.js +57 -0
- package/build/highlighted-colors.js.map +7 -0
- package/build/hooks.js +176 -0
- package/build/hooks.js.map +7 -0
- package/build/icon-with-current-color.js +56 -0
- package/build/icon-with-current-color.js.map +7 -0
- package/build/index.js +51 -0
- package/build/index.js.map +7 -0
- package/build/lock-unlock.js +35 -0
- package/build/lock-unlock.js.map +7 -0
- package/build/navigation-button.js +52 -0
- package/build/navigation-button.js.map +7 -0
- package/build/pagination/index.js +133 -0
- package/build/pagination/index.js.map +7 -0
- package/build/palette.js +93 -0
- package/build/palette.js.map +7 -0
- package/build/preset-colors.js +40 -0
- package/build/preset-colors.js.map +7 -0
- package/build/preview-colors.js +86 -0
- package/build/preview-colors.js.map +7 -0
- package/build/preview-hooks.js +60 -0
- package/build/preview-hooks.js.map +7 -0
- package/build/preview-styles.js +219 -0
- package/build/preview-styles.js.map +7 -0
- package/build/preview-typography.js +72 -0
- package/build/preview-typography.js.map +7 -0
- package/build/preview-wrapper.js +102 -0
- package/build/preview-wrapper.js.map +7 -0
- package/build/provider.js +54 -0
- package/build/provider.js.map +7 -0
- package/build/root-menu.js +72 -0
- package/build/root-menu.js.map +7 -0
- package/build/screen-background.js +58 -0
- package/build/screen-background.js.map +7 -0
- package/build/screen-block-list.js +160 -0
- package/build/screen-block-list.js.map +7 -0
- package/build/screen-block.js +316 -0
- package/build/screen-block.js.map +7 -0
- package/build/screen-color-palette.js +64 -0
- package/build/screen-color-palette.js.map +7 -0
- package/build/screen-colors.js +85 -0
- package/build/screen-colors.js.map +7 -0
- package/build/screen-css.js +68 -0
- package/build/screen-css.js.map +7 -0
- package/build/screen-header.js +61 -0
- package/build/screen-header.js.map +7 -0
- package/build/screen-layout.js +54 -0
- package/build/screen-layout.js.map +7 -0
- package/build/screen-revisions/index.js +147 -0
- package/build/screen-revisions/index.js.map +7 -0
- package/build/screen-revisions/revisions-buttons.js +198 -0
- package/build/screen-revisions/revisions-buttons.js.map +7 -0
- package/build/screen-revisions/types.js +17 -0
- package/build/screen-revisions/types.js.map +7 -0
- package/build/screen-revisions/use-global-styles-revisions.js +163 -0
- package/build/screen-revisions/use-global-styles-revisions.js.map +7 -0
- package/build/screen-root.js +134 -0
- package/build/screen-root.js.map +7 -0
- package/build/screen-shadows.js +49 -0
- package/build/screen-shadows.js.map +7 -0
- package/build/screen-style-variations.js +52 -0
- package/build/screen-style-variations.js.map +7 -0
- package/build/screen-typography-element.js +167 -0
- package/build/screen-typography-element.js.map +7 -0
- package/build/screen-typography.js +65 -0
- package/build/screen-typography.js.map +7 -0
- package/build/shadow-utils.js +125 -0
- package/build/shadow-utils.js.map +7 -0
- package/build/shadows-edit-panel.js +503 -0
- package/build/shadows-edit-panel.js.map +7 -0
- package/build/shadows-panel.js +203 -0
- package/build/shadows-panel.js.map +7 -0
- package/build/size-control/index.js +86 -0
- package/build/size-control/index.js.map +7 -0
- package/build/style-variations-container.js +130 -0
- package/build/style-variations-container.js.map +7 -0
- package/build/style-variations-content.js +52 -0
- package/build/style-variations-content.js.map +7 -0
- package/build/style-variations.js +41 -0
- package/build/style-variations.js.map +7 -0
- package/build/subtitle.js +33 -0
- package/build/subtitle.js.map +7 -0
- package/build/typography-elements.js +117 -0
- package/build/typography-elements.js.map +7 -0
- package/build/typography-example.js +79 -0
- package/build/typography-example.js.map +7 -0
- package/build/typography-panel.js +64 -0
- package/build/typography-panel.js.map +7 -0
- package/build/typography-preview.js +70 -0
- package/build/typography-preview.js.map +7 -0
- package/build/typography-variations.js +41 -0
- package/build/typography-variations.js.map +7 -0
- package/build/utils.js +210 -0
- package/build/utils.js.map +7 -0
- package/build/variations/variation.js +116 -0
- package/build/variations/variation.js.map +7 -0
- package/build/variations/variations-color.js +64 -0
- package/build/variations/variations-color.js.map +7 -0
- package/build/variations/variations-panel.js +69 -0
- package/build/variations/variations-panel.js.map +7 -0
- package/build/variations/variations-typography.js +80 -0
- package/build/variations/variations-typography.js.map +7 -0
- package/build/with-global-styles-provider.js +48 -0
- package/build/with-global-styles-provider.js.map +7 -0
- package/build-module/background-panel.js +38 -0
- package/build-module/background-panel.js.map +7 -0
- package/build-module/block-preview-panel.js +70 -0
- package/build-module/block-preview-panel.js.map +7 -0
- package/build-module/color-indicator-wrapper.js +25 -0
- package/build-module/color-indicator-wrapper.js.map +7 -0
- package/build-module/color-palette-panel.js +97 -0
- package/build-module/color-palette-panel.js.map +7 -0
- package/build-module/color-preview.js +70 -0
- package/build-module/color-preview.js.map +7 -0
- package/build-module/color-variations.js +7 -0
- package/build-module/color-variations.js.map +7 -0
- package/build-module/confirm-reset-shadow-dialog.js +35 -0
- package/build-module/confirm-reset-shadow-dialog.js.map +7 -0
- package/build-module/context.js +13 -0
- package/build-module/context.js.map +7 -0
- package/build-module/dimensions-panel.js +69 -0
- package/build-module/dimensions-panel.js.map +7 -0
- package/build-module/font-families.js +92 -0
- package/build-module/font-families.js.map +7 -0
- package/build-module/font-family-item.js +32 -0
- package/build-module/font-family-item.js.map +7 -0
- package/build-module/font-library-modal/collection-font-variant.js +45 -0
- package/build-module/font-library-modal/collection-font-variant.js.map +7 -0
- package/build-module/font-library-modal/context.js +382 -0
- package/build-module/font-library-modal/context.js.map +7 -0
- package/build-module/font-library-modal/font-card.js +57 -0
- package/build-module/font-library-modal/font-card.js.map +7 -0
- package/build-module/font-library-modal/font-collection.js +510 -0
- package/build-module/font-library-modal/font-collection.js.map +7 -0
- package/build-module/font-library-modal/font-demo.js +94 -0
- package/build-module/font-library-modal/font-demo.js.map +7 -0
- package/build-module/font-library-modal/google-fonts-confirm-dialog.js +45 -0
- package/build-module/font-library-modal/google-fonts-confirm-dialog.js.map +7 -0
- package/build-module/font-library-modal/index.js +83 -0
- package/build-module/font-library-modal/index.js.map +7 -0
- package/build-module/font-library-modal/installed-fonts.js +442 -0
- package/build-module/font-library-modal/installed-fonts.js.map +7 -0
- package/build-module/font-library-modal/lib/inflate.js +2636 -0
- package/build-module/font-library-modal/lib/inflate.js.map +7 -0
- package/build-module/font-library-modal/lib/lib-font.browser.d.js +9 -0
- package/build-module/font-library-modal/lib/lib-font.browser.d.js.map +7 -0
- package/build-module/font-library-modal/lib/lib-font.browser.js +3754 -0
- package/build-module/font-library-modal/lib/lib-font.browser.js.map +7 -0
- package/build-module/font-library-modal/lib/unbrotli.js +3686 -0
- package/build-module/font-library-modal/lib/unbrotli.js.map +7 -0
- package/build-module/font-library-modal/library-font-details.js +36 -0
- package/build-module/font-library-modal/library-font-details.js.map +7 -0
- package/build-module/font-library-modal/library-font-variant.js +51 -0
- package/build-module/font-library-modal/library-font-variant.js.map +7 -0
- package/build-module/font-library-modal/resolvers.js +76 -0
- package/build-module/font-library-modal/resolvers.js.map +7 -0
- package/build-module/font-library-modal/types.js +1 -0
- package/build-module/font-library-modal/types.js.map +7 -0
- package/build-module/font-library-modal/upload-fonts.js +187 -0
- package/build-module/font-library-modal/upload-fonts.js.map +7 -0
- package/build-module/font-library-modal/utils/constants.js +23 -0
- package/build-module/font-library-modal/utils/constants.js.map +7 -0
- package/build-module/font-library-modal/utils/filter-fonts.js +19 -0
- package/build-module/font-library-modal/utils/filter-fonts.js.map +7 -0
- package/build-module/font-library-modal/utils/fonts-outline.js +26 -0
- package/build-module/font-library-modal/utils/fonts-outline.js.map +7 -0
- package/build-module/font-library-modal/utils/index.js +238 -0
- package/build-module/font-library-modal/utils/index.js.map +7 -0
- package/build-module/font-library-modal/utils/make-families-from-faces.js +25 -0
- package/build-module/font-library-modal/utils/make-families-from-faces.js.map +7 -0
- package/build-module/font-library-modal/utils/preview-styles.js +92 -0
- package/build-module/font-library-modal/utils/preview-styles.js.map +7 -0
- package/build-module/font-library-modal/utils/set-immutably.js +16 -0
- package/build-module/font-library-modal/utils/set-immutably.js.map +7 -0
- package/build-module/font-library-modal/utils/sort-font-faces.js +35 -0
- package/build-module/font-library-modal/utils/sort-font-faces.js.map +7 -0
- package/build-module/font-library-modal/utils/toggleFont.js +43 -0
- package/build-module/font-library-modal/utils/toggleFont.js.map +7 -0
- package/build-module/font-sizes/confirm-delete-font-size-dialog.js +40 -0
- package/build-module/font-sizes/confirm-delete-font-size-dialog.js.map +7 -0
- package/build-module/font-sizes/confirm-reset-font-sizes-dialog.js +35 -0
- package/build-module/font-sizes/confirm-reset-font-sizes-dialog.js.map +7 -0
- package/build-module/font-sizes/font-size-preview.js +30 -0
- package/build-module/font-sizes/font-size-preview.js.map +7 -0
- package/build-module/font-sizes/font-size.js +241 -0
- package/build-module/font-sizes/font-size.js.map +7 -0
- package/build-module/font-sizes/font-sizes-count.js +25 -0
- package/build-module/font-sizes/font-sizes-count.js.map +7 -0
- package/build-module/font-sizes/font-sizes.js +200 -0
- package/build-module/font-sizes/font-sizes.js.map +7 -0
- package/build-module/font-sizes/rename-font-size-dialog.js +82 -0
- package/build-module/font-sizes/rename-font-size-dialog.js.map +7 -0
- package/build-module/global-styles-ui.js +182 -0
- package/build-module/global-styles-ui.js.map +7 -0
- package/build-module/gradients-palette-panel.js +118 -0
- package/build-module/gradients-palette-panel.js.map +7 -0
- package/build-module/highlighted-colors.js +37 -0
- package/build-module/highlighted-colors.js.map +7 -0
- package/build-module/hooks.js +144 -0
- package/build-module/hooks.js.map +7 -0
- package/build-module/icon-with-current-color.js +22 -0
- package/build-module/icon-with-current-color.js.map +7 -0
- package/build-module/index.js +13 -0
- package/build-module/index.js.map +7 -0
- package/build-module/lock-unlock.js +10 -0
- package/build-module/lock-unlock.js.map +7 -0
- package/build-module/navigation-button.js +32 -0
- package/build-module/navigation-button.js.map +7 -0
- package/build-module/pagination/index.js +107 -0
- package/build-module/pagination/index.js.map +7 -0
- package/build-module/palette.js +70 -0
- package/build-module/palette.js.map +7 -0
- package/build-module/preset-colors.js +20 -0
- package/build-module/preset-colors.js.map +7 -0
- package/build-module/preview-colors.js +59 -0
- package/build-module/preview-colors.js.map +7 -0
- package/build-module/preview-hooks.js +36 -0
- package/build-module/preview-hooks.js.map +7 -0
- package/build-module/preview-styles.js +193 -0
- package/build-module/preview-styles.js.map +7 -0
- package/build-module/preview-typography.js +42 -0
- package/build-module/preview-typography.js.map +7 -0
- package/build-module/preview-wrapper.js +86 -0
- package/build-module/preview-wrapper.js.map +7 -0
- package/build-module/provider.js +30 -0
- package/build-module/provider.js.map +7 -0
- package/build-module/root-menu.js +58 -0
- package/build-module/root-menu.js.map +7 -0
- package/build-module/screen-background.js +28 -0
- package/build-module/screen-background.js.map +7 -0
- package/build-module/screen-block-list.js +150 -0
- package/build-module/screen-block-list.js.map +7 -0
- package/build-module/screen-block.js +293 -0
- package/build-module/screen-block.js.map +7 -0
- package/build-module/screen-color-palette.js +34 -0
- package/build-module/screen-color-palette.js.map +7 -0
- package/build-module/screen-colors.js +55 -0
- package/build-module/screen-colors.js.map +7 -0
- package/build-module/screen-css.js +48 -0
- package/build-module/screen-css.js.map +7 -0
- package/build-module/screen-header.js +44 -0
- package/build-module/screen-header.js.map +7 -0
- package/build-module/screen-layout.js +24 -0
- package/build-module/screen-layout.js.map +7 -0
- package/build-module/screen-revisions/index.js +121 -0
- package/build-module/screen-revisions/index.js.map +7 -0
- package/build-module/screen-revisions/revisions-buttons.js +178 -0
- package/build-module/screen-revisions/revisions-buttons.js.map +7 -0
- package/build-module/screen-revisions/types.js +1 -0
- package/build-module/screen-revisions/types.js.map +7 -0
- package/build-module/screen-revisions/use-global-styles-revisions.js +145 -0
- package/build-module/screen-revisions/use-global-styles-revisions.js.map +7 -0
- package/build-module/screen-root.js +114 -0
- package/build-module/screen-root.js.map +7 -0
- package/build-module/screen-shadows.js +14 -0
- package/build-module/screen-shadows.js.map +7 -0
- package/build-module/screen-style-variations.js +32 -0
- package/build-module/screen-style-variations.js.map +7 -0
- package/build-module/screen-typography-element.js +141 -0
- package/build-module/screen-typography-element.js.map +7 -0
- package/build-module/screen-typography.js +35 -0
- package/build-module/screen-typography.js.map +7 -0
- package/build-module/shadow-utils.js +98 -0
- package/build-module/shadow-utils.js.map +7 -0
- package/build-module/shadows-edit-panel.js +502 -0
- package/build-module/shadows-edit-panel.js.map +7 -0
- package/build-module/shadows-panel.js +182 -0
- package/build-module/shadows-panel.js.map +7 -0
- package/build-module/size-control/index.js +72 -0
- package/build-module/size-control/index.js.map +7 -0
- package/build-module/style-variations-container.js +100 -0
- package/build-module/style-variations-container.js.map +7 -0
- package/build-module/style-variations-content.js +18 -0
- package/build-module/style-variations-content.js.map +7 -0
- package/build-module/style-variations.js +7 -0
- package/build-module/style-variations.js.map +7 -0
- package/build-module/subtitle.js +9 -0
- package/build-module/subtitle.js.map +7 -0
- package/build-module/typography-elements.js +102 -0
- package/build-module/typography-elements.js.map +7 -0
- package/build-module/typography-example.js +59 -0
- package/build-module/typography-example.js.map +7 -0
- package/build-module/typography-panel.js +44 -0
- package/build-module/typography-panel.js.map +7 -0
- package/build-module/typography-preview.js +50 -0
- package/build-module/typography-preview.js.map +7 -0
- package/build-module/typography-variations.js +7 -0
- package/build-module/typography-variations.js.map +7 -0
- package/build-module/utils.js +179 -0
- package/build-module/utils.js.map +7 -0
- package/build-module/variations/variation.js +86 -0
- package/build-module/variations/variation.js.map +7 -0
- package/build-module/variations/variations-color.js +37 -0
- package/build-module/variations/variations-color.js.map +7 -0
- package/build-module/variations/variations-panel.js +44 -0
- package/build-module/variations/variations-panel.js.map +7 -0
- package/build-module/variations/variations-typography.js +53 -0
- package/build-module/variations/variations-typography.js.map +7 -0
- package/build-module/with-global-styles-provider.js +24 -0
- package/build-module/with-global-styles-provider.js.map +7 -0
- package/build-style/style-rtl.css +717 -0
- package/build-style/style.css +718 -0
- package/build-types/background-panel.d.ts +10 -0
- package/build-types/background-panel.d.ts.map +1 -0
- package/build-types/block-preview-panel.d.ts +7 -0
- package/build-types/block-preview-panel.d.ts.map +1 -0
- package/build-types/color-indicator-wrapper.d.ts +7 -0
- package/build-types/color-indicator-wrapper.d.ts.map +1 -0
- package/build-types/color-palette-panel.d.ts +6 -0
- package/build-types/color-palette-panel.d.ts.map +1 -0
- package/build-types/color-preview.d.ts +2 -0
- package/build-types/color-preview.d.ts.map +1 -0
- package/build-types/color-variations.d.ts +27 -0
- package/build-types/color-variations.d.ts.map +1 -0
- package/build-types/confirm-reset-shadow-dialog.d.ts +10 -0
- package/build-types/confirm-reset-shadow-dialog.d.ts.map +1 -0
- package/build-types/context.d.ts +10 -0
- package/build-types/context.d.ts.map +1 -0
- package/build-types/dimensions-panel.d.ts +2 -0
- package/build-types/dimensions-panel.d.ts.map +1 -0
- package/build-types/font-families.d.ts +4 -0
- package/build-types/font-families.d.ts.map +1 -0
- package/build-types/font-family-item.d.ts +7 -0
- package/build-types/font-family-item.d.ts.map +1 -0
- package/build-types/font-library-modal/collection-font-variant.d.ts +4 -0
- package/build-types/font-library-modal/collection-font-variant.d.ts.map +1 -0
- package/build-types/font-library-modal/context.d.ts +7 -0
- package/build-types/font-library-modal/context.d.ts.map +1 -0
- package/build-types/font-library-modal/font-card.d.ts +9 -0
- package/build-types/font-library-modal/font-card.d.ts.map +1 -0
- package/build-types/font-library-modal/font-collection.d.ts +5 -0
- package/build-types/font-library-modal/font-collection.d.ts.map +1 -0
- package/build-types/font-library-modal/font-demo.d.ts +4 -0
- package/build-types/font-library-modal/font-demo.d.ts.map +1 -0
- package/build-types/font-library-modal/google-fonts-confirm-dialog.d.ts +3 -0
- package/build-types/font-library-modal/google-fonts-confirm-dialog.d.ts.map +1 -0
- package/build-types/font-library-modal/index.d.ts +6 -0
- package/build-types/font-library-modal/index.d.ts.map +1 -0
- package/build-types/font-library-modal/installed-fonts.d.ts +3 -0
- package/build-types/font-library-modal/installed-fonts.d.ts.map +1 -0
- package/build-types/font-library-modal/library-font-details.d.ts +6 -0
- package/build-types/font-library-modal/library-font-details.d.ts.map +1 -0
- package/build-types/font-library-modal/library-font-variant.d.ts +7 -0
- package/build-types/font-library-modal/library-font-variant.d.ts.map +1 -0
- package/build-types/font-library-modal/resolvers.d.ts +43 -0
- package/build-types/font-library-modal/resolvers.d.ts.map +1 -0
- package/build-types/font-library-modal/types.d.ts +133 -0
- package/build-types/font-library-modal/types.d.ts.map +1 -0
- package/build-types/font-library-modal/upload-fonts.d.ts +3 -0
- package/build-types/font-library-modal/upload-fonts.d.ts.map +1 -0
- package/build-types/font-library-modal/utils/constants.d.ts +4 -0
- package/build-types/font-library-modal/utils/constants.d.ts.map +1 -0
- package/build-types/font-library-modal/utils/filter-fonts.d.ts +25 -0
- package/build-types/font-library-modal/utils/filter-fonts.d.ts.map +1 -0
- package/build-types/font-library-modal/utils/fonts-outline.d.ts +7 -0
- package/build-types/font-library-modal/utils/fonts-outline.d.ts.map +1 -0
- package/build-types/font-library-modal/utils/index.d.ts +21 -0
- package/build-types/font-library-modal/utils/index.d.ts.map +1 -0
- package/build-types/font-library-modal/utils/make-families-from-faces.d.ts +6 -0
- package/build-types/font-library-modal/utils/make-families-from-faces.d.ts.map +1 -0
- package/build-types/font-library-modal/utils/preview-styles.d.ts +13 -0
- package/build-types/font-library-modal/utils/preview-styles.d.ts.map +1 -0
- package/build-types/font-library-modal/utils/set-immutably.d.ts +13 -0
- package/build-types/font-library-modal/utils/set-immutably.d.ts.map +1 -0
- package/build-types/font-library-modal/utils/sort-font-faces.d.ts +6 -0
- package/build-types/font-library-modal/utils/sort-font-faces.d.ts.map +1 -0
- package/build-types/font-library-modal/utils/toggleFont.d.ts +38 -0
- package/build-types/font-library-modal/utils/toggleFont.d.ts.map +1 -0
- package/build-types/font-sizes/confirm-delete-font-size-dialog.d.ts +10 -0
- package/build-types/font-sizes/confirm-delete-font-size-dialog.d.ts.map +1 -0
- package/build-types/font-sizes/confirm-reset-font-sizes-dialog.d.ts +10 -0
- package/build-types/font-sizes/confirm-reset-font-sizes-dialog.d.ts.map +1 -0
- package/build-types/font-sizes/font-size-preview.d.ts +7 -0
- package/build-types/font-sizes/font-size-preview.d.ts.map +1 -0
- package/build-types/font-sizes/font-size.d.ts +4 -0
- package/build-types/font-sizes/font-size.d.ts.map +1 -0
- package/build-types/font-sizes/font-sizes-count.d.ts +3 -0
- package/build-types/font-sizes/font-sizes-count.d.ts.map +1 -0
- package/build-types/font-sizes/font-sizes.d.ts +3 -0
- package/build-types/font-sizes/font-sizes.d.ts.map +1 -0
- package/build-types/font-sizes/rename-font-size-dialog.d.ts +9 -0
- package/build-types/font-sizes/rename-font-size-dialog.d.ts.map +1 -0
- package/build-types/global-styles-ui.d.ts +26 -0
- package/build-types/global-styles-ui.d.ts.map +1 -0
- package/build-types/gradients-palette-panel.d.ts +6 -0
- package/build-types/gradients-palette-panel.d.ts.map +1 -0
- package/build-types/highlighted-colors.d.ts +7 -0
- package/build-types/highlighted-colors.d.ts.map +1 -0
- package/build-types/hooks.d.ts +46 -0
- package/build-types/hooks.d.ts.map +1 -0
- package/build-types/icon-with-current-color.d.ts +9 -0
- package/build-types/icon-with-current-color.d.ts.map +1 -0
- package/build-types/index.d.ts +6 -0
- package/build-types/index.d.ts.map +1 -0
- package/build-types/lock-unlock.d.ts +2 -0
- package/build-types/lock-unlock.d.ts.map +1 -0
- package/build-types/navigation-button.d.ts +10 -0
- package/build-types/navigation-button.d.ts.map +1 -0
- package/build-types/pagination/index.d.ts +13 -0
- package/build-types/pagination/index.d.ts.map +1 -0
- package/build-types/palette.d.ts +6 -0
- package/build-types/palette.d.ts.map +1 -0
- package/build-types/preset-colors.d.ts +2 -0
- package/build-types/preset-colors.d.ts.map +1 -0
- package/build-types/preview-colors.d.ts +8 -0
- package/build-types/preview-colors.d.ts.map +1 -0
- package/build-types/preview-hooks.d.ts +9 -0
- package/build-types/preview-hooks.d.ts.map +1 -0
- package/build-types/preview-styles.d.ts +9 -0
- package/build-types/preview-styles.d.ts.map +1 -0
- package/build-types/preview-typography.d.ts +8 -0
- package/build-types/preview-typography.d.ts.map +1 -0
- package/build-types/preview-wrapper.d.ts +15 -0
- package/build-types/preview-wrapper.d.ts.map +1 -0
- package/build-types/provider.d.ts +15 -0
- package/build-types/provider.d.ts.map +1 -0
- package/build-types/root-menu.d.ts +3 -0
- package/build-types/root-menu.d.ts.map +1 -0
- package/build-types/screen-background.d.ts +3 -0
- package/build-types/screen-background.d.ts.map +1 -0
- package/build-types/screen-block-list.d.ts +4 -0
- package/build-types/screen-block-list.d.ts.map +1 -0
- package/build-types/screen-block.d.ts +7 -0
- package/build-types/screen-block.d.ts.map +1 -0
- package/build-types/screen-color-palette.d.ts +5 -0
- package/build-types/screen-color-palette.d.ts.map +1 -0
- package/build-types/screen-colors.d.ts +3 -0
- package/build-types/screen-colors.d.ts.map +1 -0
- package/build-types/screen-css.d.ts +3 -0
- package/build-types/screen-css.d.ts.map +1 -0
- package/build-types/screen-header.d.ts +8 -0
- package/build-types/screen-header.d.ts.map +1 -0
- package/build-types/screen-layout.d.ts +3 -0
- package/build-types/screen-layout.d.ts.map +1 -0
- package/build-types/screen-revisions/index.d.ts +6 -0
- package/build-types/screen-revisions/index.d.ts.map +1 -0
- package/build-types/screen-revisions/revisions-buttons.d.ts +23 -0
- package/build-types/screen-revisions/revisions-buttons.d.ts.map +1 -0
- package/build-types/screen-revisions/types.d.ts +17 -0
- package/build-types/screen-revisions/types.d.ts.map +1 -0
- package/build-types/screen-revisions/use-global-styles-revisions.d.ts +17 -0
- package/build-types/screen-revisions/use-global-styles-revisions.d.ts.map +1 -0
- package/build-types/screen-root.d.ts +3 -0
- package/build-types/screen-root.d.ts.map +1 -0
- package/build-types/screen-shadows.d.ts +3 -0
- package/build-types/screen-shadows.d.ts.map +1 -0
- package/build-types/screen-style-variations.d.ts +3 -0
- package/build-types/screen-style-variations.d.ts.map +1 -0
- package/build-types/screen-typography-element.d.ts +28 -0
- package/build-types/screen-typography-element.d.ts.map +1 -0
- package/build-types/screen-typography.d.ts +3 -0
- package/build-types/screen-typography.d.ts.map +1 -0
- package/build-types/shadow-utils.d.ts +126 -0
- package/build-types/shadow-utils.d.ts.map +1 -0
- package/build-types/shadows-edit-panel.d.ts +2 -0
- package/build-types/shadows-edit-panel.d.ts.map +1 -0
- package/build-types/shadows-panel.d.ts +3 -0
- package/build-types/shadows-panel.d.ts.map +1 -0
- package/build-types/size-control/index.d.ts +11 -0
- package/build-types/size-control/index.d.ts.map +1 -0
- package/build-types/stories/index.story.d.ts +6 -0
- package/build-types/stories/index.story.d.ts.map +1 -0
- package/build-types/style-variations-container.d.ts +6 -0
- package/build-types/style-variations-container.d.ts.map +1 -0
- package/build-types/style-variations-content.d.ts +2 -0
- package/build-types/style-variations-content.d.ts.map +1 -0
- package/build-types/style-variations.d.ts +25 -0
- package/build-types/style-variations.d.ts.map +1 -0
- package/build-types/subtitle.d.ts +7 -0
- package/build-types/subtitle.d.ts.map +1 -0
- package/build-types/test/shadow-utils.spec.d.ts +2 -0
- package/build-types/test/shadow-utils.spec.d.ts.map +1 -0
- package/build-types/test/utils.spec.d.ts +2 -0
- package/build-types/test/utils.spec.d.ts.map +1 -0
- package/build-types/typography-elements.d.ts +3 -0
- package/build-types/typography-elements.d.ts.map +1 -0
- package/build-types/typography-example.d.ts +7 -0
- package/build-types/typography-example.d.ts.map +1 -0
- package/build-types/typography-panel.d.ts +7 -0
- package/build-types/typography-panel.d.ts.map +1 -0
- package/build-types/typography-preview.d.ts +8 -0
- package/build-types/typography-preview.d.ts.map +1 -0
- package/build-types/typography-variations.d.ts +27 -0
- package/build-types/typography-variations.d.ts.map +1 -0
- package/build-types/utils.d.ts +63 -0
- package/build-types/utils.d.ts.map +1 -0
- package/build-types/variations/variation.d.ts +10 -0
- package/build-types/variations/variation.d.ts.map +1 -0
- package/build-types/variations/variations-color.d.ts +7 -0
- package/build-types/variations/variations-color.d.ts.map +1 -0
- package/build-types/variations/variations-panel.d.ts +13 -0
- package/build-types/variations/variations-panel.d.ts.map +1 -0
- package/build-types/variations/variations-typography.d.ts +7 -0
- package/build-types/variations/variations-typography.d.ts.map +1 -0
- package/build-types/with-global-styles-provider.d.ts +20 -0
- package/build-types/with-global-styles-provider.d.ts.map +1 -0
- package/package.json +67 -0
- package/src/README.md +99 -0
- package/src/background-panel.tsx +56 -0
- package/src/block-preview-panel.tsx +91 -0
- package/src/color-indicator-wrapper.tsx +34 -0
- package/src/color-palette-panel.tsx +111 -0
- package/src/color-preview.tsx +78 -0
- package/src/color-variations.tsx +35 -0
- package/src/confirm-reset-shadow-dialog.tsx +45 -0
- package/src/context.ts +21 -0
- package/src/dimensions-panel.tsx +85 -0
- package/src/font-families.tsx +127 -0
- package/src/font-family-item.tsx +52 -0
- package/src/font-library-modal/collection-font-variant.tsx +52 -0
- package/src/font-library-modal/context.tsx +591 -0
- package/src/font-library-modal/font-card.tsx +77 -0
- package/src/font-library-modal/font-collection.tsx +592 -0
- package/src/font-library-modal/font-demo.tsx +123 -0
- package/src/font-library-modal/google-fonts-confirm-dialog.tsx +57 -0
- package/src/font-library-modal/index.tsx +110 -0
- package/src/font-library-modal/installed-fonts.tsx +547 -0
- package/src/font-library-modal/lib/inflate.js +4112 -0
- package/src/font-library-modal/lib/lib-font.browser.d.ts +11 -0
- package/src/font-library-modal/lib/lib-font.browser.js +3861 -0
- package/src/font-library-modal/lib/unbrotli.js +2706 -0
- package/src/font-library-modal/library-font-details.tsx +46 -0
- package/src/font-library-modal/library-font-variant.tsx +67 -0
- package/src/font-library-modal/resolvers.tsx +100 -0
- package/src/font-library-modal/style.scss +222 -0
- package/src/font-library-modal/types.ts +176 -0
- package/src/font-library-modal/upload-fonts.tsx +269 -0
- package/src/font-library-modal/utils/constants.ts +23 -0
- package/src/font-library-modal/utils/filter-fonts.ts +47 -0
- package/src/font-library-modal/utils/fonts-outline.ts +33 -0
- package/src/font-library-modal/utils/index.ts +368 -0
- package/src/font-library-modal/utils/make-families-from-faces.ts +34 -0
- package/src/font-library-modal/utils/preview-styles.ts +167 -0
- package/src/font-library-modal/utils/set-immutably.ts +37 -0
- package/src/font-library-modal/utils/sort-font-faces.ts +46 -0
- package/src/font-library-modal/utils/toggleFont.ts +109 -0
- package/src/font-sizes/confirm-delete-font-size-dialog.tsx +51 -0
- package/src/font-sizes/confirm-reset-font-sizes-dialog.tsx +45 -0
- package/src/font-sizes/font-size-preview.tsx +47 -0
- package/src/font-sizes/font-size.tsx +289 -0
- package/src/font-sizes/font-sizes-count.tsx +37 -0
- package/src/font-sizes/font-sizes.tsx +265 -0
- package/src/font-sizes/rename-font-size-dialog.tsx +83 -0
- package/src/global-styles-ui.tsx +292 -0
- package/src/gradients-palette-panel.tsx +126 -0
- package/src/highlighted-colors.tsx +44 -0
- package/src/hooks.ts +251 -0
- package/src/icon-with-current-color.tsx +31 -0
- package/src/index.ts +7 -0
- package/src/lock-unlock.ts +10 -0
- package/src/navigation-button.tsx +53 -0
- package/src/pagination/index.tsx +107 -0
- package/src/pagination/style.scss +7 -0
- package/src/palette.tsx +101 -0
- package/src/preset-colors.tsx +18 -0
- package/src/preview-colors.tsx +68 -0
- package/src/preview-hooks.tsx +58 -0
- package/src/preview-styles.tsx +196 -0
- package/src/preview-typography.tsx +49 -0
- package/src/preview-wrapper.tsx +137 -0
- package/src/provider.tsx +54 -0
- package/src/root-menu.tsx +87 -0
- package/src/screen-background.tsx +37 -0
- package/src/screen-block-list.tsx +198 -0
- package/src/screen-block.tsx +370 -0
- package/src/screen-color-palette.tsx +47 -0
- package/src/screen-colors.tsx +67 -0
- package/src/screen-css.tsx +56 -0
- package/src/screen-header.tsx +56 -0
- package/src/screen-layout.tsx +34 -0
- package/src/screen-revisions/index.tsx +158 -0
- package/src/screen-revisions/revisions-buttons.tsx +259 -0
- package/src/screen-revisions/style.scss +194 -0
- package/src/screen-revisions/types.ts +18 -0
- package/src/screen-revisions/use-global-styles-revisions.tsx +204 -0
- package/src/screen-root.tsx +146 -0
- package/src/screen-shadows.tsx +13 -0
- package/src/screen-style-variations.tsx +36 -0
- package/src/screen-typography-element.tsx +127 -0
- package/src/screen-typography.tsx +41 -0
- package/src/shadow-utils.ts +167 -0
- package/src/shadows-edit-panel.tsx +559 -0
- package/src/shadows-panel.tsx +207 -0
- package/src/size-control/index.tsx +97 -0
- package/src/size-control/style.scss +7 -0
- package/src/stories/index.story.js +410 -0
- package/src/style-variations-container.tsx +153 -0
- package/src/style-variations-content.tsx +24 -0
- package/src/style-variations.tsx +33 -0
- package/src/style.scss +287 -0
- package/src/subtitle.tsx +17 -0
- package/src/test/shadow-utils.spec.js +251 -0
- package/src/test/utils.spec.js +59 -0
- package/src/typography-elements.tsx +113 -0
- package/src/typography-example.tsx +78 -0
- package/src/typography-panel.tsx +56 -0
- package/src/typography-preview.tsx +61 -0
- package/src/typography-variations.tsx +35 -0
- package/src/utils.ts +301 -0
- package/src/variations/style.scss +43 -0
- package/src/variations/variation.tsx +113 -0
- package/src/variations/variations-color.tsx +54 -0
- package/src/variations/variations-panel.tsx +79 -0
- package/src/variations/variations-typography.tsx +65 -0
- package/src/with-global-styles-provider.tsx +44 -0
- package/tsconfig.json +26 -0
- package/tsconfig.tsbuildinfo +1 -0
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { __ } from "@wordpress/i18n";
|
|
3
|
+
import { ExternalLink } from "@wordpress/components";
|
|
4
|
+
import { privateApis as blockEditorPrivateApis } from "@wordpress/block-editor";
|
|
5
|
+
import { ScreenHeader } from "./screen-header";
|
|
6
|
+
import { useStyle } from "./hooks";
|
|
7
|
+
import { unlock } from "./lock-unlock";
|
|
8
|
+
const { AdvancedPanel: StylesAdvancedPanel } = unlock(blockEditorPrivateApis);
|
|
9
|
+
function ScreenCSS() {
|
|
10
|
+
const description = __(
|
|
11
|
+
"Add your own CSS to customize the appearance and layout of your site."
|
|
12
|
+
);
|
|
13
|
+
const [style] = useStyle("", void 0, "user", false);
|
|
14
|
+
const [inheritedStyle, setStyle] = useStyle(
|
|
15
|
+
"",
|
|
16
|
+
void 0,
|
|
17
|
+
"merged",
|
|
18
|
+
false
|
|
19
|
+
);
|
|
20
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
21
|
+
/* @__PURE__ */ jsx(ScreenHeader, { title: __("CSS"), description }),
|
|
22
|
+
/* @__PURE__ */ jsxs("div", { className: "global-styles-ui-screen-css", children: [
|
|
23
|
+
/* @__PURE__ */ jsx(
|
|
24
|
+
ExternalLink,
|
|
25
|
+
{
|
|
26
|
+
href: __(
|
|
27
|
+
"https://developer.wordpress.org/advanced-administration/wordpress/css/"
|
|
28
|
+
),
|
|
29
|
+
className: "global-styles-ui-screen-css-help-link",
|
|
30
|
+
children: __("Learn more about CSS")
|
|
31
|
+
}
|
|
32
|
+
),
|
|
33
|
+
/* @__PURE__ */ jsx(
|
|
34
|
+
StylesAdvancedPanel,
|
|
35
|
+
{
|
|
36
|
+
value: style,
|
|
37
|
+
onChange: setStyle,
|
|
38
|
+
inheritedValue: inheritedStyle
|
|
39
|
+
}
|
|
40
|
+
)
|
|
41
|
+
] })
|
|
42
|
+
] });
|
|
43
|
+
}
|
|
44
|
+
var screen_css_default = ScreenCSS;
|
|
45
|
+
export {
|
|
46
|
+
screen_css_default as default
|
|
47
|
+
};
|
|
48
|
+
//# sourceMappingURL=screen-css.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/screen-css.tsx"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { ExternalLink } from '@wordpress/components';\n// @ts-expect-error: Not typed yet.\nimport { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport { ScreenHeader } from './screen-header';\nimport { useStyle } from './hooks';\nimport { unlock } from './lock-unlock';\n\n// Access AdvancedPanel from block-editor private APIs\nconst { AdvancedPanel: StylesAdvancedPanel } = unlock( blockEditorPrivateApis );\n\nfunction ScreenCSS() {\n\tconst description = __(\n\t\t'Add your own CSS to customize the appearance and layout of your site.'\n\t);\n\n\t// Get user-only styles (should not decode/encode to preserve raw CSS)\n\tconst [ style ] = useStyle( '', undefined, 'user', false );\n\t// Get all styles (inherited + user) for context\n\tconst [ inheritedStyle, setStyle ] = useStyle(\n\t\t'',\n\t\tundefined,\n\t\t'merged',\n\t\tfalse\n\t);\n\n\treturn (\n\t\t<>\n\t\t\t<ScreenHeader title={ __( 'CSS' ) } description={ description } />\n\t\t\t<div className=\"global-styles-ui-screen-css\">\n\t\t\t\t<ExternalLink\n\t\t\t\t\thref={ __(\n\t\t\t\t\t\t'https://developer.wordpress.org/advanced-administration/wordpress/css/'\n\t\t\t\t\t) }\n\t\t\t\t\tclassName=\"global-styles-ui-screen-css-help-link\"\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Learn more about CSS' ) }\n\t\t\t\t</ExternalLink>\n\t\t\t\t<StylesAdvancedPanel\n\t\t\t\t\tvalue={ style }\n\t\t\t\t\tonChange={ setStyle }\n\t\t\t\t\tinheritedValue={ inheritedStyle }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t</>\n\t);\n}\n\nexport default ScreenCSS;\n"],
|
|
5
|
+
"mappings": "AAkCE,mBACC,KACA,YAFD;AA/BF,SAAS,UAAU;AACnB,SAAS,oBAAoB;AAE7B,SAAS,eAAe,8BAA8B;AAKtD,SAAS,oBAAoB;AAC7B,SAAS,gBAAgB;AACzB,SAAS,cAAc;AAGvB,MAAM,EAAE,eAAe,oBAAoB,IAAI,OAAQ,sBAAuB;AAE9E,SAAS,YAAY;AACpB,QAAM,cAAc;AAAA,IACnB;AAAA,EACD;AAGA,QAAM,CAAE,KAAM,IAAI,SAAU,IAAI,QAAW,QAAQ,KAAM;AAEzD,QAAM,CAAE,gBAAgB,QAAS,IAAI;AAAA,IACpC;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD;AAEA,SACC,iCACC;AAAA,wBAAC,gBAAa,OAAQ,GAAI,KAAM,GAAI,aAA4B;AAAA,IAChE,qBAAC,SAAI,WAAU,+BACd;AAAA;AAAA,QAAC;AAAA;AAAA,UACA,MAAO;AAAA,YACN;AAAA,UACD;AAAA,UACA,WAAU;AAAA,UAER,aAAI,sBAAuB;AAAA;AAAA,MAC9B;AAAA,MACA;AAAA,QAAC;AAAA;AAAA,UACA,OAAQ;AAAA,UACR,UAAW;AAAA,UACX,gBAAiB;AAAA;AAAA,MAClB;AAAA,OACD;AAAA,KACD;AAEF;AAEA,IAAO,qBAAQ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import {
|
|
3
|
+
__experimentalHStack as HStack,
|
|
4
|
+
__experimentalVStack as VStack,
|
|
5
|
+
__experimentalSpacer as Spacer,
|
|
6
|
+
__experimentalHeading as Heading,
|
|
7
|
+
__experimentalView as View,
|
|
8
|
+
Navigator
|
|
9
|
+
} from "@wordpress/components";
|
|
10
|
+
import { isRTL, __ } from "@wordpress/i18n";
|
|
11
|
+
import { chevronRight, chevronLeft } from "@wordpress/icons";
|
|
12
|
+
function ScreenHeader({
|
|
13
|
+
title,
|
|
14
|
+
description,
|
|
15
|
+
onBack
|
|
16
|
+
}) {
|
|
17
|
+
return /* @__PURE__ */ jsxs(VStack, { spacing: 0, children: [
|
|
18
|
+
/* @__PURE__ */ jsx(View, { children: /* @__PURE__ */ jsx(Spacer, { marginBottom: 0, paddingX: 4, paddingY: 3, children: /* @__PURE__ */ jsxs(HStack, { spacing: 2, children: [
|
|
19
|
+
/* @__PURE__ */ jsx(
|
|
20
|
+
Navigator.BackButton,
|
|
21
|
+
{
|
|
22
|
+
icon: isRTL() ? chevronRight : chevronLeft,
|
|
23
|
+
size: "small",
|
|
24
|
+
label: __("Back"),
|
|
25
|
+
onClick: onBack
|
|
26
|
+
}
|
|
27
|
+
),
|
|
28
|
+
/* @__PURE__ */ jsx(Spacer, { children: /* @__PURE__ */ jsx(
|
|
29
|
+
Heading,
|
|
30
|
+
{
|
|
31
|
+
className: "global-styles-ui-header",
|
|
32
|
+
level: 2,
|
|
33
|
+
size: 13,
|
|
34
|
+
children: title
|
|
35
|
+
}
|
|
36
|
+
) })
|
|
37
|
+
] }) }) }),
|
|
38
|
+
description && /* @__PURE__ */ jsx("p", { className: "global-styles-ui-header__description", children: description })
|
|
39
|
+
] });
|
|
40
|
+
}
|
|
41
|
+
export {
|
|
42
|
+
ScreenHeader
|
|
43
|
+
};
|
|
44
|
+
//# sourceMappingURL=screen-header.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/screen-header.tsx"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n\t__experimentalSpacer as Spacer,\n\t__experimentalHeading as Heading,\n\t__experimentalView as View,\n\tNavigator,\n} from '@wordpress/components';\nimport { isRTL, __ } from '@wordpress/i18n';\nimport { chevronRight, chevronLeft } from '@wordpress/icons';\n\ninterface ScreenHeaderProps {\n\ttitle: string;\n\tdescription?: string | React.ReactElement;\n\tonBack?: () => void;\n}\n\nexport function ScreenHeader( {\n\ttitle,\n\tdescription,\n\tonBack,\n}: ScreenHeaderProps ) {\n\treturn (\n\t\t<VStack spacing={ 0 }>\n\t\t\t<View>\n\t\t\t\t<Spacer marginBottom={ 0 } paddingX={ 4 } paddingY={ 3 }>\n\t\t\t\t\t<HStack spacing={ 2 }>\n\t\t\t\t\t\t<Navigator.BackButton\n\t\t\t\t\t\t\ticon={ isRTL() ? chevronRight : chevronLeft }\n\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\tlabel={ __( 'Back' ) }\n\t\t\t\t\t\t\tonClick={ onBack }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<Spacer>\n\t\t\t\t\t\t\t<Heading\n\t\t\t\t\t\t\t\tclassName=\"global-styles-ui-header\"\n\t\t\t\t\t\t\t\tlevel={ 2 }\n\t\t\t\t\t\t\t\tsize={ 13 }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ title }\n\t\t\t\t\t\t\t</Heading>\n\t\t\t\t\t\t</Spacer>\n\t\t\t\t\t</HStack>\n\t\t\t\t</Spacer>\n\t\t\t</View>\n\t\t\t{ description && (\n\t\t\t\t<p className=\"global-styles-ui-header__description\">\n\t\t\t\t\t{ description }\n\t\t\t\t</p>\n\t\t\t) }\n\t\t</VStack>\n\t);\n}\n"],
|
|
5
|
+
"mappings": "AA6BK,SACC,KADD;AA1BL;AAAA,EACC,wBAAwB;AAAA,EACxB,wBAAwB;AAAA,EACxB,wBAAwB;AAAA,EACxB,yBAAyB;AAAA,EACzB,sBAAsB;AAAA,EACtB;AAAA,OACM;AACP,SAAS,OAAO,UAAU;AAC1B,SAAS,cAAc,mBAAmB;AAQnC,SAAS,aAAc;AAAA,EAC7B;AAAA,EACA;AAAA,EACA;AACD,GAAuB;AACtB,SACC,qBAAC,UAAO,SAAU,GACjB;AAAA,wBAAC,QACA,8BAAC,UAAO,cAAe,GAAI,UAAW,GAAI,UAAW,GACpD,+BAAC,UAAO,SAAU,GACjB;AAAA;AAAA,QAAC,UAAU;AAAA,QAAV;AAAA,UACA,MAAO,MAAM,IAAI,eAAe;AAAA,UAChC,MAAK;AAAA,UACL,OAAQ,GAAI,MAAO;AAAA,UACnB,SAAU;AAAA;AAAA,MACX;AAAA,MACA,oBAAC,UACA;AAAA,QAAC;AAAA;AAAA,UACA,WAAU;AAAA,UACV,OAAQ;AAAA,UACR,MAAO;AAAA,UAEL;AAAA;AAAA,MACH,GACD;AAAA,OACD,GACD,GACD;AAAA,IACE,eACD,oBAAC,OAAE,WAAU,wCACV,uBACH;AAAA,KAEF;AAEF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { __ } from "@wordpress/i18n";
|
|
3
|
+
import { privateApis as blockEditorPrivateApis } from "@wordpress/block-editor";
|
|
4
|
+
import { ScreenHeader } from "./screen-header";
|
|
5
|
+
import DimensionsPanel from "./dimensions-panel";
|
|
6
|
+
import { useSetting } from "./hooks";
|
|
7
|
+
import { unlock } from "./lock-unlock";
|
|
8
|
+
const { useHasDimensionsPanel, useSettingsForBlockElement } = unlock(
|
|
9
|
+
blockEditorPrivateApis
|
|
10
|
+
);
|
|
11
|
+
function ScreenLayout() {
|
|
12
|
+
const [rawSettings] = useSetting("");
|
|
13
|
+
const settings = useSettingsForBlockElement(rawSettings);
|
|
14
|
+
const hasDimensionsPanel = useHasDimensionsPanel(settings);
|
|
15
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
16
|
+
/* @__PURE__ */ jsx(ScreenHeader, { title: __("Layout") }),
|
|
17
|
+
hasDimensionsPanel && /* @__PURE__ */ jsx(DimensionsPanel, {})
|
|
18
|
+
] });
|
|
19
|
+
}
|
|
20
|
+
var screen_layout_default = ScreenLayout;
|
|
21
|
+
export {
|
|
22
|
+
screen_layout_default as default
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=screen-layout.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/screen-layout.tsx"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\n// @ts-expect-error: Not typed yet.\nimport { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';\nimport type { GlobalStylesSettings } from '@wordpress/global-styles-engine';\n\n/**\n * Internal dependencies\n */\nimport { ScreenHeader } from './screen-header';\nimport DimensionsPanel from './dimensions-panel';\nimport { useSetting } from './hooks';\nimport { unlock } from './lock-unlock';\n\nconst { useHasDimensionsPanel, useSettingsForBlockElement } = unlock(\n\tblockEditorPrivateApis\n);\n\nfunction ScreenLayout() {\n\tconst [ rawSettings ] = useSetting< GlobalStylesSettings >( '' );\n\tconst settings = useSettingsForBlockElement( rawSettings );\n\tconst hasDimensionsPanel = useHasDimensionsPanel( settings );\n\n\treturn (\n\t\t<>\n\t\t\t<ScreenHeader title={ __( 'Layout' ) } />\n\t\t\t{ hasDimensionsPanel && <DimensionsPanel /> }\n\t\t</>\n\t);\n}\n\nexport default ScreenLayout;\n"],
|
|
5
|
+
"mappings": "AA0BE,mBACC,KADD;AAvBF,SAAS,UAAU;AAEnB,SAAS,eAAe,8BAA8B;AAMtD,SAAS,oBAAoB;AAC7B,OAAO,qBAAqB;AAC5B,SAAS,kBAAkB;AAC3B,SAAS,cAAc;AAEvB,MAAM,EAAE,uBAAuB,2BAA2B,IAAI;AAAA,EAC7D;AACD;AAEA,SAAS,eAAe;AACvB,QAAM,CAAE,WAAY,IAAI,WAAoC,EAAG;AAC/D,QAAM,WAAW,2BAA4B,WAAY;AACzD,QAAM,qBAAqB,sBAAuB,QAAS;AAE3D,SACC,iCACC;AAAA,wBAAC,gBAAa,OAAQ,GAAI,QAAS,GAAI;AAAA,IACrC,sBAAsB,oBAAC,mBAAgB;AAAA,KAC1C;AAEF;AAEA,IAAO,wBAAQ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { __, sprintf } from "@wordpress/i18n";
|
|
3
|
+
import {
|
|
4
|
+
__experimentalConfirmDialog as ConfirmDialog,
|
|
5
|
+
Spinner,
|
|
6
|
+
useNavigator
|
|
7
|
+
} from "@wordpress/components";
|
|
8
|
+
import { useContext, useState, useMemo } from "@wordpress/element";
|
|
9
|
+
import { areGlobalStylesEqual } from "@wordpress/global-styles-engine";
|
|
10
|
+
import { ScreenHeader } from "../screen-header";
|
|
11
|
+
import { GlobalStylesContext } from "../context";
|
|
12
|
+
import useGlobalStylesRevisions from "./use-global-styles-revisions";
|
|
13
|
+
import RevisionsButtons from "./revisions-buttons";
|
|
14
|
+
import Pagination from "../pagination";
|
|
15
|
+
const PAGE_SIZE = 10;
|
|
16
|
+
function ScreenRevisions({ onClose } = {}) {
|
|
17
|
+
const { user: currentEditorGlobalStyles, onChange: setUserConfig } = useContext(GlobalStylesContext);
|
|
18
|
+
const { params, goTo } = useNavigator();
|
|
19
|
+
const { revisionId } = params;
|
|
20
|
+
const [currentPage, setCurrentPage] = useState(1);
|
|
21
|
+
const { revisions, isLoading, hasUnsavedChanges, revisionsCount } = useGlobalStylesRevisions({
|
|
22
|
+
query: {
|
|
23
|
+
per_page: PAGE_SIZE,
|
|
24
|
+
page: currentPage
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
const numPages = Math.ceil(revisionsCount / PAGE_SIZE);
|
|
28
|
+
const [
|
|
29
|
+
isLoadingRevisionWithUnsavedChanges,
|
|
30
|
+
setIsLoadingRevisionWithUnsavedChanges
|
|
31
|
+
] = useState(false);
|
|
32
|
+
const currentlySelectedRevision = useMemo(() => {
|
|
33
|
+
if (!revisionId) {
|
|
34
|
+
return currentEditorGlobalStyles;
|
|
35
|
+
}
|
|
36
|
+
const revision = revisions.find(
|
|
37
|
+
(rev) => String(rev.id) === String(revisionId)
|
|
38
|
+
);
|
|
39
|
+
return revision || currentEditorGlobalStyles;
|
|
40
|
+
}, [revisionId, revisions, currentEditorGlobalStyles]);
|
|
41
|
+
const selectedRevisionMatchesEditorStyles = areGlobalStylesEqual(
|
|
42
|
+
currentlySelectedRevision,
|
|
43
|
+
currentEditorGlobalStyles
|
|
44
|
+
);
|
|
45
|
+
const onCloseRevisions = () => {
|
|
46
|
+
if (onClose) {
|
|
47
|
+
onClose();
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
const restoreRevision = (revision) => {
|
|
51
|
+
setUserConfig(revision);
|
|
52
|
+
setIsLoadingRevisionWithUnsavedChanges(false);
|
|
53
|
+
onCloseRevisions();
|
|
54
|
+
};
|
|
55
|
+
const handleRevisionSelect = (revision) => {
|
|
56
|
+
goTo(`/revisions/${revision.id}`);
|
|
57
|
+
};
|
|
58
|
+
const currentlySelectedRevisionId = (
|
|
59
|
+
// @ts-expect-error: revision id is not present in the fallback (default object).
|
|
60
|
+
currentlySelectedRevision?.id ?? revisions[0]?.id
|
|
61
|
+
);
|
|
62
|
+
const isLoadButtonEnabled = !!currentlySelectedRevisionId && currentlySelectedRevisionId !== "unsaved" && !selectedRevisionMatchesEditorStyles;
|
|
63
|
+
const hasRevisions = !!revisions.length;
|
|
64
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
65
|
+
/* @__PURE__ */ jsx(
|
|
66
|
+
ScreenHeader,
|
|
67
|
+
{
|
|
68
|
+
title: revisionsCount ? sprintf(
|
|
69
|
+
// translators: %d: number of revisions.
|
|
70
|
+
__("Revisions (%d)"),
|
|
71
|
+
revisionsCount
|
|
72
|
+
) : __("Revisions"),
|
|
73
|
+
description: __(
|
|
74
|
+
`Click on previously saved styles to preview them. To restore a selected version to the editor, hit "Apply." When you're ready, use the Save button to save your changes.`
|
|
75
|
+
),
|
|
76
|
+
onBack: onCloseRevisions
|
|
77
|
+
}
|
|
78
|
+
),
|
|
79
|
+
!hasRevisions && /* @__PURE__ */ jsx(Spinner, { className: "global-styles-ui-screen-revisions__loading" }),
|
|
80
|
+
/* @__PURE__ */ jsx(
|
|
81
|
+
RevisionsButtons,
|
|
82
|
+
{
|
|
83
|
+
onChange: handleRevisionSelect,
|
|
84
|
+
selectedRevisionId: currentlySelectedRevisionId,
|
|
85
|
+
userRevisions: revisions,
|
|
86
|
+
canApplyRevision: isLoadButtonEnabled,
|
|
87
|
+
onApplyRevision: () => hasUnsavedChanges ? setIsLoadingRevisionWithUnsavedChanges(true) : restoreRevision(currentlySelectedRevision)
|
|
88
|
+
}
|
|
89
|
+
),
|
|
90
|
+
numPages > 1 && /* @__PURE__ */ jsx("div", { className: "global-styles-ui-screen-revisions__footer", children: /* @__PURE__ */ jsx(
|
|
91
|
+
Pagination,
|
|
92
|
+
{
|
|
93
|
+
className: "global-styles-ui-screen-revisions__pagination",
|
|
94
|
+
currentPage,
|
|
95
|
+
numPages,
|
|
96
|
+
changePage: setCurrentPage,
|
|
97
|
+
totalItems: revisionsCount,
|
|
98
|
+
disabled: isLoading,
|
|
99
|
+
label: __("Global Styles pagination")
|
|
100
|
+
}
|
|
101
|
+
) }),
|
|
102
|
+
isLoadingRevisionWithUnsavedChanges && /* @__PURE__ */ jsx(
|
|
103
|
+
ConfirmDialog,
|
|
104
|
+
{
|
|
105
|
+
isOpen: isLoadingRevisionWithUnsavedChanges,
|
|
106
|
+
confirmButtonText: __("Apply"),
|
|
107
|
+
onConfirm: () => restoreRevision(currentlySelectedRevision),
|
|
108
|
+
onCancel: () => setIsLoadingRevisionWithUnsavedChanges(false),
|
|
109
|
+
size: "medium",
|
|
110
|
+
children: __(
|
|
111
|
+
"Are you sure you want to apply this revision? Any unsaved changes will be lost."
|
|
112
|
+
)
|
|
113
|
+
}
|
|
114
|
+
)
|
|
115
|
+
] });
|
|
116
|
+
}
|
|
117
|
+
var screen_revisions_default = ScreenRevisions;
|
|
118
|
+
export {
|
|
119
|
+
screen_revisions_default as default
|
|
120
|
+
};
|
|
121
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/screen-revisions/index.tsx"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\t__experimentalConfirmDialog as ConfirmDialog,\n\tSpinner,\n\tuseNavigator,\n} from '@wordpress/components';\nimport { useContext, useState, useMemo } from '@wordpress/element';\nimport { areGlobalStylesEqual } from '@wordpress/global-styles-engine';\n\n/**\n * Internal dependencies\n */\nimport { ScreenHeader } from '../screen-header';\nimport { GlobalStylesContext } from '../context';\nimport useGlobalStylesRevisions from './use-global-styles-revisions';\nimport RevisionsButtons from './revisions-buttons';\nimport Pagination from '../pagination';\n\nconst PAGE_SIZE = 10;\n\ninterface ScreenRevisionsProps {\n\tonClose?: () => void;\n}\n\nfunction ScreenRevisions( { onClose }: ScreenRevisionsProps = {} ) {\n\tconst { user: currentEditorGlobalStyles, onChange: setUserConfig } =\n\t\tuseContext( GlobalStylesContext );\n\tconst { params, goTo } = useNavigator();\n\tconst { revisionId } = params;\n\tconst [ currentPage, setCurrentPage ] = useState( 1 );\n\tconst { revisions, isLoading, hasUnsavedChanges, revisionsCount } =\n\t\tuseGlobalStylesRevisions( {\n\t\t\tquery: {\n\t\t\t\tper_page: PAGE_SIZE,\n\t\t\t\tpage: currentPage,\n\t\t\t},\n\t\t} );\n\n\tconst numPages = Math.ceil( revisionsCount / PAGE_SIZE );\n\n\tconst [\n\t\tisLoadingRevisionWithUnsavedChanges,\n\t\tsetIsLoadingRevisionWithUnsavedChanges,\n\t] = useState( false );\n\n\t// Derive the currently selected revision from the path parameter\n\tconst currentlySelectedRevision = useMemo( () => {\n\t\tif ( ! revisionId ) {\n\t\t\treturn currentEditorGlobalStyles;\n\t\t}\n\t\tconst revision = revisions.find(\n\t\t\t( rev ) => String( rev.id ) === String( revisionId )\n\t\t);\n\t\treturn revision || currentEditorGlobalStyles;\n\t}, [ revisionId, revisions, currentEditorGlobalStyles ] );\n\n\tconst selectedRevisionMatchesEditorStyles = areGlobalStylesEqual(\n\t\tcurrentlySelectedRevision,\n\t\tcurrentEditorGlobalStyles\n\t);\n\n\tconst onCloseRevisions = () => {\n\t\tif ( onClose ) {\n\t\t\tonClose();\n\t\t}\n\t};\n\n\tconst restoreRevision = ( revision: any ) => {\n\t\tsetUserConfig( revision );\n\t\tsetIsLoadingRevisionWithUnsavedChanges( false );\n\t\tonCloseRevisions();\n\t};\n\n\tconst handleRevisionSelect = ( revision: any ) => {\n\t\tgoTo( `/revisions/${ revision.id }` );\n\t};\n\n\tconst currentlySelectedRevisionId =\n\t\t// @ts-expect-error: revision id is not present in the fallback (default object).\n\t\tcurrentlySelectedRevision?.id ?? revisions[ 0 ]?.id;\n\n\t// Only display load button if there is a revision to load,\n\t// and it is different from the current editor styles.\n\tconst isLoadButtonEnabled =\n\t\t!! currentlySelectedRevisionId &&\n\t\tcurrentlySelectedRevisionId !== 'unsaved' &&\n\t\t! selectedRevisionMatchesEditorStyles;\n\tconst hasRevisions = !! revisions.length;\n\n\treturn (\n\t\t<>\n\t\t\t<ScreenHeader\n\t\t\t\ttitle={\n\t\t\t\t\trevisionsCount\n\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t// translators: %d: number of revisions.\n\t\t\t\t\t\t\t\t__( 'Revisions (%d)' ),\n\t\t\t\t\t\t\t\trevisionsCount\n\t\t\t\t\t\t )\n\t\t\t\t\t\t: __( 'Revisions' )\n\t\t\t\t}\n\t\t\t\tdescription={ __(\n\t\t\t\t\t'Click on previously saved styles to preview them. To restore a selected version to the editor, hit \"Apply.\" When you\\'re ready, use the Save button to save your changes.'\n\t\t\t\t) }\n\t\t\t\tonBack={ onCloseRevisions }\n\t\t\t/>\n\t\t\t{ ! hasRevisions && (\n\t\t\t\t<Spinner className=\"global-styles-ui-screen-revisions__loading\" />\n\t\t\t) }\n\t\t\t<RevisionsButtons\n\t\t\t\tonChange={ handleRevisionSelect }\n\t\t\t\tselectedRevisionId={ currentlySelectedRevisionId }\n\t\t\t\tuserRevisions={ revisions }\n\t\t\t\tcanApplyRevision={ isLoadButtonEnabled }\n\t\t\t\tonApplyRevision={ () =>\n\t\t\t\t\thasUnsavedChanges\n\t\t\t\t\t\t? setIsLoadingRevisionWithUnsavedChanges( true )\n\t\t\t\t\t\t: restoreRevision( currentlySelectedRevision )\n\t\t\t\t}\n\t\t\t/>\n\t\t\t{ numPages > 1 && (\n\t\t\t\t<div className=\"global-styles-ui-screen-revisions__footer\">\n\t\t\t\t\t<Pagination\n\t\t\t\t\t\tclassName=\"global-styles-ui-screen-revisions__pagination\"\n\t\t\t\t\t\tcurrentPage={ currentPage }\n\t\t\t\t\t\tnumPages={ numPages }\n\t\t\t\t\t\tchangePage={ setCurrentPage }\n\t\t\t\t\t\ttotalItems={ revisionsCount }\n\t\t\t\t\t\tdisabled={ isLoading }\n\t\t\t\t\t\tlabel={ __( 'Global Styles pagination' ) }\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t{ isLoadingRevisionWithUnsavedChanges && (\n\t\t\t\t<ConfirmDialog\n\t\t\t\t\tisOpen={ isLoadingRevisionWithUnsavedChanges }\n\t\t\t\t\tconfirmButtonText={ __( 'Apply' ) }\n\t\t\t\t\tonConfirm={ () =>\n\t\t\t\t\t\trestoreRevision( currentlySelectedRevision )\n\t\t\t\t\t}\n\t\t\t\t\tonCancel={ () =>\n\t\t\t\t\t\tsetIsLoadingRevisionWithUnsavedChanges( false )\n\t\t\t\t\t}\n\t\t\t\t\tsize=\"medium\"\n\t\t\t\t>\n\t\t\t\t\t{ __(\n\t\t\t\t\t\t'Are you sure you want to apply this revision? Any unsaved changes will be lost.'\n\t\t\t\t\t) }\n\t\t\t\t</ConfirmDialog>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport default ScreenRevisions;\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { __, sprintf } from "@wordpress/i18n";
|
|
3
|
+
import { Button, Composite } from "@wordpress/components";
|
|
4
|
+
import { dateI18n, getDate, humanTimeDiff, getSettings } from "@wordpress/date";
|
|
5
|
+
import { store as coreStore } from "@wordpress/core-data";
|
|
6
|
+
import { useSelect } from "@wordpress/data";
|
|
7
|
+
import { getGlobalStylesChanges } from "@wordpress/global-styles-engine";
|
|
8
|
+
import { ENTER, SPACE } from "@wordpress/keycodes";
|
|
9
|
+
const DAY_IN_MILLISECONDS = 60 * 60 * 1e3 * 24;
|
|
10
|
+
function ChangesSummary({ revision, previousRevision }) {
|
|
11
|
+
const changes = getGlobalStylesChanges(
|
|
12
|
+
revision,
|
|
13
|
+
previousRevision,
|
|
14
|
+
{
|
|
15
|
+
maxResults: 7
|
|
16
|
+
}
|
|
17
|
+
);
|
|
18
|
+
if (!changes.length) {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
return /* @__PURE__ */ jsx(
|
|
22
|
+
"ul",
|
|
23
|
+
{
|
|
24
|
+
"data-testid": "global-styles-revision-changes",
|
|
25
|
+
className: "global-styles-ui-screen-revisions__changes",
|
|
26
|
+
children: changes.map((change) => /* @__PURE__ */ jsx("li", { children: change }, change))
|
|
27
|
+
}
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
function getRevisionLabel(id, authorDisplayName, formattedModifiedDate, areStylesEqual) {
|
|
31
|
+
if ("parent" === id) {
|
|
32
|
+
return __("Reset the styles to the theme defaults");
|
|
33
|
+
}
|
|
34
|
+
if ("unsaved" === id) {
|
|
35
|
+
return sprintf(
|
|
36
|
+
/* translators: %s: author display name */
|
|
37
|
+
__("Unsaved changes by %s"),
|
|
38
|
+
authorDisplayName
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
return areStylesEqual ? sprintf(
|
|
42
|
+
// translators: 1: author display name. 2: revision creation date.
|
|
43
|
+
__(
|
|
44
|
+
"Changes saved by %1$s on %2$s. This revision matches current editor styles."
|
|
45
|
+
),
|
|
46
|
+
authorDisplayName,
|
|
47
|
+
formattedModifiedDate
|
|
48
|
+
) : sprintf(
|
|
49
|
+
// translators: 1: author display name. 2: revision creation date.
|
|
50
|
+
__("Changes saved by %1$s on %2$s"),
|
|
51
|
+
authorDisplayName,
|
|
52
|
+
formattedModifiedDate
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
function RevisionsButtons({
|
|
56
|
+
userRevisions,
|
|
57
|
+
selectedRevisionId,
|
|
58
|
+
onChange,
|
|
59
|
+
canApplyRevision,
|
|
60
|
+
onApplyRevision
|
|
61
|
+
}) {
|
|
62
|
+
const { currentThemeName, currentUser } = useSelect((select) => {
|
|
63
|
+
const { getCurrentTheme, getCurrentUser } = select(coreStore);
|
|
64
|
+
const currentTheme = getCurrentTheme();
|
|
65
|
+
return {
|
|
66
|
+
currentThemeName: currentTheme?.name?.rendered || currentTheme?.stylesheet,
|
|
67
|
+
currentUser: getCurrentUser()
|
|
68
|
+
};
|
|
69
|
+
}, []);
|
|
70
|
+
const dateNowInMs = getDate(null).getTime();
|
|
71
|
+
const { datetimeAbbreviated } = getSettings().formats;
|
|
72
|
+
return /* @__PURE__ */ jsx(
|
|
73
|
+
Composite,
|
|
74
|
+
{
|
|
75
|
+
orientation: "vertical",
|
|
76
|
+
className: "global-styles-ui-screen-revisions__revisions-list",
|
|
77
|
+
"aria-label": __("Global styles revisions list"),
|
|
78
|
+
role: "listbox",
|
|
79
|
+
children: userRevisions.map((revision, index) => {
|
|
80
|
+
const { id, author, modified } = revision;
|
|
81
|
+
const isUnsaved = "unsaved" === id;
|
|
82
|
+
const revisionAuthor = isUnsaved ? currentUser : author;
|
|
83
|
+
const authorDisplayName = revisionAuthor?.name || __("User");
|
|
84
|
+
const authorAvatar = revisionAuthor?.avatar_urls?.["48"];
|
|
85
|
+
const isFirstItem = index === 0;
|
|
86
|
+
const isSelected = selectedRevisionId ? selectedRevisionId === id : isFirstItem;
|
|
87
|
+
const areStylesEqual = !canApplyRevision && isSelected;
|
|
88
|
+
const isReset = "parent" === id;
|
|
89
|
+
const modifiedString = modified instanceof Date ? modified.toISOString() : modified;
|
|
90
|
+
const modifiedDate = getDate(modifiedString ?? null);
|
|
91
|
+
const displayDate = modifiedString && dateNowInMs - modifiedDate.getTime() > DAY_IN_MILLISECONDS ? dateI18n(datetimeAbbreviated, modifiedDate) : humanTimeDiff(
|
|
92
|
+
modifiedString ?? modifiedDate,
|
|
93
|
+
void 0
|
|
94
|
+
);
|
|
95
|
+
const revisionLabel = getRevisionLabel(
|
|
96
|
+
id,
|
|
97
|
+
authorDisplayName,
|
|
98
|
+
dateI18n(datetimeAbbreviated, modifiedDate),
|
|
99
|
+
areStylesEqual
|
|
100
|
+
);
|
|
101
|
+
return /* @__PURE__ */ jsxs(
|
|
102
|
+
Composite.Item,
|
|
103
|
+
{
|
|
104
|
+
className: "global-styles-ui-screen-revisions__revision-item",
|
|
105
|
+
"aria-current": isSelected,
|
|
106
|
+
role: "option",
|
|
107
|
+
onKeyDown: (event) => {
|
|
108
|
+
const { keyCode } = event;
|
|
109
|
+
if (keyCode === ENTER || keyCode === SPACE) {
|
|
110
|
+
onChange(revision);
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
onClick: (event) => {
|
|
114
|
+
event.preventDefault();
|
|
115
|
+
onChange(revision);
|
|
116
|
+
},
|
|
117
|
+
"aria-selected": isSelected,
|
|
118
|
+
"aria-label": revisionLabel,
|
|
119
|
+
render: /* @__PURE__ */ jsx("div", {}),
|
|
120
|
+
children: [
|
|
121
|
+
/* @__PURE__ */ jsx("span", { className: "global-styles-ui-screen-revisions__revision-item-wrapper", children: isReset ? /* @__PURE__ */ jsxs("span", { className: "global-styles-ui-screen-revisions__description", children: [
|
|
122
|
+
__("Default styles"),
|
|
123
|
+
/* @__PURE__ */ jsx("span", { className: "global-styles-ui-screen-revisions__meta", children: currentThemeName })
|
|
124
|
+
] }) : /* @__PURE__ */ jsxs("span", { className: "global-styles-ui-screen-revisions__description", children: [
|
|
125
|
+
isUnsaved ? /* @__PURE__ */ jsx("span", { className: "global-styles-ui-screen-revisions__date", children: __("(Unsaved)") }) : /* @__PURE__ */ jsx(
|
|
126
|
+
"time",
|
|
127
|
+
{
|
|
128
|
+
className: "global-styles-ui-screen-revisions__date",
|
|
129
|
+
dateTime: modifiedString,
|
|
130
|
+
children: displayDate
|
|
131
|
+
}
|
|
132
|
+
),
|
|
133
|
+
/* @__PURE__ */ jsxs("span", { className: "global-styles-ui-screen-revisions__meta", children: [
|
|
134
|
+
/* @__PURE__ */ jsx(
|
|
135
|
+
"img",
|
|
136
|
+
{
|
|
137
|
+
alt: authorDisplayName,
|
|
138
|
+
src: authorAvatar
|
|
139
|
+
}
|
|
140
|
+
),
|
|
141
|
+
authorDisplayName
|
|
142
|
+
] }),
|
|
143
|
+
isSelected && /* @__PURE__ */ jsx(
|
|
144
|
+
ChangesSummary,
|
|
145
|
+
{
|
|
146
|
+
revision,
|
|
147
|
+
previousRevision: index < userRevisions.length ? userRevisions[index + 1] : void 0
|
|
148
|
+
}
|
|
149
|
+
)
|
|
150
|
+
] }) }),
|
|
151
|
+
isSelected && (areStylesEqual ? /* @__PURE__ */ jsx("p", { className: "global-styles-ui-screen-revisions__applied-text", children: __(
|
|
152
|
+
"These styles are already applied to your site."
|
|
153
|
+
) }) : /* @__PURE__ */ jsx(
|
|
154
|
+
Button,
|
|
155
|
+
{
|
|
156
|
+
size: "compact",
|
|
157
|
+
variant: "primary",
|
|
158
|
+
className: "global-styles-ui-screen-revisions__apply-button",
|
|
159
|
+
onClick: onApplyRevision,
|
|
160
|
+
"aria-label": __(
|
|
161
|
+
"Apply the selected revision to your site."
|
|
162
|
+
),
|
|
163
|
+
children: isReset ? __("Reset to defaults") : __("Apply")
|
|
164
|
+
}
|
|
165
|
+
))
|
|
166
|
+
]
|
|
167
|
+
},
|
|
168
|
+
id
|
|
169
|
+
);
|
|
170
|
+
})
|
|
171
|
+
}
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
var revisions_buttons_default = RevisionsButtons;
|
|
175
|
+
export {
|
|
176
|
+
revisions_buttons_default as default
|
|
177
|
+
};
|
|
178
|
+
//# sourceMappingURL=revisions-buttons.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/screen-revisions/revisions-buttons.tsx"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { Button, Composite } from '@wordpress/components';\nimport { dateI18n, getDate, humanTimeDiff, getSettings } from '@wordpress/date';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useSelect } from '@wordpress/data';\nimport { getGlobalStylesChanges } from '@wordpress/global-styles-engine';\nimport { ENTER, SPACE } from '@wordpress/keycodes';\n\n/**\n * Internal dependencies\n */\nimport type { Revision } from './types';\n\nconst DAY_IN_MILLISECONDS = 60 * 60 * 1000 * 24;\n\ninterface ChangesSummaryProps {\n\trevision: Revision;\n\tpreviousRevision?: Revision;\n}\n\nfunction ChangesSummary( { revision, previousRevision }: ChangesSummaryProps ) {\n\tconst changes: string[] = getGlobalStylesChanges(\n\t\trevision,\n\t\tpreviousRevision,\n\t\t{\n\t\t\tmaxResults: 7,\n\t\t}\n\t);\n\n\tif ( ! changes.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<ul\n\t\t\tdata-testid=\"global-styles-revision-changes\"\n\t\t\tclassName=\"global-styles-ui-screen-revisions__changes\"\n\t\t>\n\t\t\t{ changes.map( ( change ) => (\n\t\t\t\t<li key={ change }>{ change }</li>\n\t\t\t) ) }\n\t\t</ul>\n\t);\n}\n\n/**\n * Returns a button label for the revision.\n * @param id\n * @param authorDisplayName\n * @param formattedModifiedDate\n * @param areStylesEqual\n */\nfunction getRevisionLabel(\n\tid: string | number,\n\tauthorDisplayName: string,\n\tformattedModifiedDate: string,\n\tareStylesEqual: boolean\n): string {\n\tif ( 'parent' === id ) {\n\t\treturn __( 'Reset the styles to the theme defaults' );\n\t}\n\n\tif ( 'unsaved' === id ) {\n\t\treturn sprintf(\n\t\t\t/* translators: %s: author display name */\n\t\t\t__( 'Unsaved changes by %s' ),\n\t\t\tauthorDisplayName\n\t\t);\n\t}\n\n\treturn areStylesEqual\n\t\t? sprintf(\n\t\t\t\t// translators: 1: author display name. 2: revision creation date.\n\t\t\t\t__(\n\t\t\t\t\t'Changes saved by %1$s on %2$s. This revision matches current editor styles.'\n\t\t\t\t),\n\t\t\t\tauthorDisplayName,\n\t\t\t\tformattedModifiedDate\n\t\t )\n\t\t: sprintf(\n\t\t\t\t// translators: 1: author display name. 2: revision creation date.\n\t\t\t\t__( 'Changes saved by %1$s on %2$s' ),\n\t\t\t\tauthorDisplayName,\n\t\t\t\tformattedModifiedDate\n\t\t );\n}\n\ninterface RevisionButtonsProps {\n\tuserRevisions: Revision[];\n\tselectedRevisionId?: string | number;\n\tonChange: ( revision: Revision ) => void;\n\tcanApplyRevision?: boolean;\n\tonApplyRevision?: () => void;\n}\n\n/**\n * Returns a rendered list of revisions buttons.\n * @param root0\n * @param root0.userRevisions\n * @param root0.selectedRevisionId\n * @param root0.onChange\n * @param root0.canApplyRevision\n * @param root0.onApplyRevision\n */\nfunction RevisionsButtons( {\n\tuserRevisions,\n\tselectedRevisionId,\n\tonChange,\n\tcanApplyRevision,\n\tonApplyRevision,\n}: RevisionButtonsProps ) {\n\tconst { currentThemeName, currentUser } = useSelect( ( select ) => {\n\t\tconst { getCurrentTheme, getCurrentUser } = select( coreStore );\n\t\tconst currentTheme = getCurrentTheme();\n\t\treturn {\n\t\t\tcurrentThemeName:\n\t\t\t\tcurrentTheme?.name?.rendered || currentTheme?.stylesheet,\n\t\t\tcurrentUser: getCurrentUser(),\n\t\t};\n\t}, [] );\n\tconst dateNowInMs = getDate( null ).getTime();\n\tconst { datetimeAbbreviated } = getSettings().formats;\n\n\treturn (\n\t\t<Composite\n\t\t\torientation=\"vertical\"\n\t\t\tclassName=\"global-styles-ui-screen-revisions__revisions-list\"\n\t\t\taria-label={ __( 'Global styles revisions list' ) }\n\t\t\trole=\"listbox\"\n\t\t>\n\t\t\t{ userRevisions.map( ( revision, index ) => {\n\t\t\t\tconst { id, author, modified } = revision;\n\t\t\t\tconst isUnsaved = 'unsaved' === id;\n\t\t\t\t// Unsaved changes are created by the current user.\n\t\t\t\tconst revisionAuthor = isUnsaved ? currentUser : author;\n\t\t\t\tconst authorDisplayName = revisionAuthor?.name || __( 'User' );\n\t\t\t\tconst authorAvatar = revisionAuthor?.avatar_urls?.[ '48' ];\n\t\t\t\tconst isFirstItem = index === 0;\n\t\t\t\tconst isSelected = selectedRevisionId\n\t\t\t\t\t? selectedRevisionId === id\n\t\t\t\t\t: isFirstItem;\n\t\t\t\tconst areStylesEqual = ! canApplyRevision && isSelected;\n\t\t\t\tconst isReset = 'parent' === id;\n\t\t\t\t// Convert modified to string if it's a Date, for type compatibility\n\t\t\t\tconst modifiedString =\n\t\t\t\t\tmodified instanceof Date\n\t\t\t\t\t\t? modified.toISOString()\n\t\t\t\t\t\t: modified;\n\t\t\t\tconst modifiedDate = getDate( modifiedString ?? null );\n\t\t\t\tconst displayDate =\n\t\t\t\t\tmodifiedString &&\n\t\t\t\t\tdateNowInMs - modifiedDate.getTime() > DAY_IN_MILLISECONDS\n\t\t\t\t\t\t? dateI18n( datetimeAbbreviated, modifiedDate )\n\t\t\t\t\t\t: humanTimeDiff(\n\t\t\t\t\t\t\t\tmodifiedString ?? modifiedDate,\n\t\t\t\t\t\t\t\tundefined\n\t\t\t\t\t\t );\n\t\t\t\tconst revisionLabel = getRevisionLabel(\n\t\t\t\t\tid,\n\t\t\t\t\tauthorDisplayName,\n\t\t\t\t\tdateI18n( datetimeAbbreviated, modifiedDate ),\n\t\t\t\t\tareStylesEqual\n\t\t\t\t);\n\n\t\t\t\treturn (\n\t\t\t\t\t<Composite.Item\n\t\t\t\t\t\tkey={ id }\n\t\t\t\t\t\tclassName=\"global-styles-ui-screen-revisions__revision-item\"\n\t\t\t\t\t\taria-current={ isSelected }\n\t\t\t\t\t\trole=\"option\"\n\t\t\t\t\t\tonKeyDown={ ( event ) => {\n\t\t\t\t\t\t\tconst { keyCode } = event;\n\t\t\t\t\t\t\tif ( keyCode === ENTER || keyCode === SPACE ) {\n\t\t\t\t\t\t\t\tonChange( revision );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tonClick={ ( event ) => {\n\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\tonChange( revision );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\taria-selected={ isSelected }\n\t\t\t\t\t\taria-label={ revisionLabel }\n\t\t\t\t\t\trender={ <div /> }\n\t\t\t\t\t>\n\t\t\t\t\t\t<span className=\"global-styles-ui-screen-revisions__revision-item-wrapper\">\n\t\t\t\t\t\t\t{ isReset ? (\n\t\t\t\t\t\t\t\t<span className=\"global-styles-ui-screen-revisions__description\">\n\t\t\t\t\t\t\t\t\t{ __( 'Default styles' ) }\n\t\t\t\t\t\t\t\t\t<span className=\"global-styles-ui-screen-revisions__meta\">\n\t\t\t\t\t\t\t\t\t\t{ currentThemeName }\n\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t<span className=\"global-styles-ui-screen-revisions__description\">\n\t\t\t\t\t\t\t\t\t{ isUnsaved ? (\n\t\t\t\t\t\t\t\t\t\t<span className=\"global-styles-ui-screen-revisions__date\">\n\t\t\t\t\t\t\t\t\t\t\t{ __( '(Unsaved)' ) }\n\t\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t\t\t<time\n\t\t\t\t\t\t\t\t\t\t\tclassName=\"global-styles-ui-screen-revisions__date\"\n\t\t\t\t\t\t\t\t\t\t\tdateTime={ modifiedString }\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t{ displayDate }\n\t\t\t\t\t\t\t\t\t\t</time>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t<span className=\"global-styles-ui-screen-revisions__meta\">\n\t\t\t\t\t\t\t\t\t\t<img\n\t\t\t\t\t\t\t\t\t\t\talt={ authorDisplayName }\n\t\t\t\t\t\t\t\t\t\t\tsrc={ authorAvatar }\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t{ authorDisplayName }\n\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t{ isSelected && (\n\t\t\t\t\t\t\t\t\t\t<ChangesSummary\n\t\t\t\t\t\t\t\t\t\t\trevision={ revision }\n\t\t\t\t\t\t\t\t\t\t\tpreviousRevision={\n\t\t\t\t\t\t\t\t\t\t\t\tindex < userRevisions.length\n\t\t\t\t\t\t\t\t\t\t\t\t\t? userRevisions[ index + 1 ]\n\t\t\t\t\t\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</span>\n\t\t\t\t\t\t{ isSelected &&\n\t\t\t\t\t\t\t( areStylesEqual ? (\n\t\t\t\t\t\t\t\t<p className=\"global-styles-ui-screen-revisions__applied-text\">\n\t\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t\t'These styles are already applied to your site.'\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\t\t\tclassName=\"global-styles-ui-screen-revisions__apply-button\"\n\t\t\t\t\t\t\t\t\tonClick={ onApplyRevision }\n\t\t\t\t\t\t\t\t\taria-label={ __(\n\t\t\t\t\t\t\t\t\t\t'Apply the selected revision to your site.'\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{ isReset\n\t\t\t\t\t\t\t\t\t\t? __( 'Reset to defaults' )\n\t\t\t\t\t\t\t\t\t\t: __( 'Apply' ) }\n\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t) ) }\n\t\t\t\t\t</Composite.Item>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</Composite>\n\t);\n}\n\nexport default RevisionsButtons;\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { useSelect } from "@wordpress/data";
|
|
2
|
+
import {
|
|
3
|
+
store as coreStore
|
|
4
|
+
} from "@wordpress/core-data";
|
|
5
|
+
import { useContext, useMemo } from "@wordpress/element";
|
|
6
|
+
import { GlobalStylesContext } from "../context";
|
|
7
|
+
const SITE_EDITOR_AUTHORS_QUERY = {
|
|
8
|
+
per_page: -1,
|
|
9
|
+
_fields: "id,name,avatar_urls",
|
|
10
|
+
context: "view",
|
|
11
|
+
capabilities: ["edit_theme_options"]
|
|
12
|
+
};
|
|
13
|
+
const DEFAULT_QUERY = { per_page: 100, page: 1 };
|
|
14
|
+
const EMPTY_ARRAY = [];
|
|
15
|
+
function useGlobalStylesRevisions({
|
|
16
|
+
query
|
|
17
|
+
} = {}) {
|
|
18
|
+
const { user: userConfig } = useContext(GlobalStylesContext);
|
|
19
|
+
const _query = useMemo(
|
|
20
|
+
() => ({ ...DEFAULT_QUERY, ...query }),
|
|
21
|
+
[query]
|
|
22
|
+
);
|
|
23
|
+
const {
|
|
24
|
+
authors,
|
|
25
|
+
currentUser,
|
|
26
|
+
isDirty,
|
|
27
|
+
revisions,
|
|
28
|
+
isLoadingGlobalStylesRevisions,
|
|
29
|
+
revisionsCount
|
|
30
|
+
} = useSelect(
|
|
31
|
+
(select) => {
|
|
32
|
+
const {
|
|
33
|
+
__experimentalGetDirtyEntityRecords,
|
|
34
|
+
getCurrentUser,
|
|
35
|
+
getUsers,
|
|
36
|
+
getRevisions,
|
|
37
|
+
__experimentalGetCurrentGlobalStylesId,
|
|
38
|
+
getEntityRecord,
|
|
39
|
+
// @ts-expect-error
|
|
40
|
+
isResolving
|
|
41
|
+
} = select(coreStore);
|
|
42
|
+
const dirtyEntityRecords = __experimentalGetDirtyEntityRecords() || [];
|
|
43
|
+
const _currentUser = getCurrentUser();
|
|
44
|
+
const _isDirty = dirtyEntityRecords.length > 0;
|
|
45
|
+
const globalStylesId = __experimentalGetCurrentGlobalStylesId();
|
|
46
|
+
const globalStyles = globalStylesId ? getEntityRecord(
|
|
47
|
+
"root",
|
|
48
|
+
"globalStyles",
|
|
49
|
+
globalStylesId
|
|
50
|
+
) : void 0;
|
|
51
|
+
const _revisionsCount = (
|
|
52
|
+
// @ts-expect-error - _links is not typed in GlobalStylesRevision
|
|
53
|
+
globalStyles?._links?.["version-history"]?.[0]?.count ?? 0
|
|
54
|
+
);
|
|
55
|
+
const globalStylesRevisions = globalStylesId ? getRevisions(
|
|
56
|
+
"root",
|
|
57
|
+
"globalStyles",
|
|
58
|
+
globalStylesId,
|
|
59
|
+
_query
|
|
60
|
+
) || EMPTY_ARRAY : EMPTY_ARRAY;
|
|
61
|
+
const _authors = getUsers(SITE_EDITOR_AUTHORS_QUERY) || [];
|
|
62
|
+
const _isResolving = globalStylesId ? isResolving("getRevisions", [
|
|
63
|
+
"root",
|
|
64
|
+
"globalStyles",
|
|
65
|
+
globalStylesId,
|
|
66
|
+
_query
|
|
67
|
+
]) : false;
|
|
68
|
+
return {
|
|
69
|
+
authors: _authors,
|
|
70
|
+
currentUser: _currentUser,
|
|
71
|
+
isDirty: _isDirty,
|
|
72
|
+
revisions: globalStylesRevisions,
|
|
73
|
+
isLoadingGlobalStylesRevisions: _isResolving,
|
|
74
|
+
revisionsCount: _revisionsCount
|
|
75
|
+
};
|
|
76
|
+
},
|
|
77
|
+
[_query]
|
|
78
|
+
);
|
|
79
|
+
return useMemo(() => {
|
|
80
|
+
if (!authors.length || isLoadingGlobalStylesRevisions) {
|
|
81
|
+
return {
|
|
82
|
+
revisions: EMPTY_ARRAY,
|
|
83
|
+
hasUnsavedChanges: isDirty,
|
|
84
|
+
isLoading: true,
|
|
85
|
+
revisionsCount
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
const _modifiedRevisions = revisions.map((revision) => {
|
|
89
|
+
return {
|
|
90
|
+
...revision,
|
|
91
|
+
author: authors.find(
|
|
92
|
+
(author) => author.id === revision.author
|
|
93
|
+
)
|
|
94
|
+
};
|
|
95
|
+
});
|
|
96
|
+
const fetchedRevisionsCount = revisions.length;
|
|
97
|
+
if (fetchedRevisionsCount) {
|
|
98
|
+
if (_modifiedRevisions[0].id !== "unsaved" && _query.page === 1) {
|
|
99
|
+
_modifiedRevisions[0].isLatest = true;
|
|
100
|
+
}
|
|
101
|
+
if (isDirty && userConfig && Object.keys(userConfig).length > 0 && currentUser && _query.page === 1) {
|
|
102
|
+
const unsavedRevision = {
|
|
103
|
+
id: "unsaved",
|
|
104
|
+
styles: userConfig?.styles,
|
|
105
|
+
settings: userConfig?.settings,
|
|
106
|
+
_links: userConfig?._links,
|
|
107
|
+
author: {
|
|
108
|
+
name: currentUser?.name || "",
|
|
109
|
+
// @ts-expect-error - avatar_urls is not typed in User
|
|
110
|
+
avatar_urls: currentUser?.avatar_urls || {}
|
|
111
|
+
},
|
|
112
|
+
modified: /* @__PURE__ */ new Date()
|
|
113
|
+
};
|
|
114
|
+
_modifiedRevisions.unshift(unsavedRevision);
|
|
115
|
+
}
|
|
116
|
+
if (_query.per_page && _query.page === Math.ceil(revisionsCount / _query.per_page)) {
|
|
117
|
+
_modifiedRevisions.push({
|
|
118
|
+
id: "parent",
|
|
119
|
+
styles: {},
|
|
120
|
+
settings: {}
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return {
|
|
125
|
+
revisions: _modifiedRevisions,
|
|
126
|
+
hasUnsavedChanges: isDirty,
|
|
127
|
+
isLoading: false,
|
|
128
|
+
revisionsCount
|
|
129
|
+
};
|
|
130
|
+
}, [
|
|
131
|
+
isDirty,
|
|
132
|
+
revisions,
|
|
133
|
+
currentUser,
|
|
134
|
+
authors,
|
|
135
|
+
userConfig,
|
|
136
|
+
isLoadingGlobalStylesRevisions,
|
|
137
|
+
revisionsCount,
|
|
138
|
+
_query.page,
|
|
139
|
+
_query.per_page
|
|
140
|
+
]);
|
|
141
|
+
}
|
|
142
|
+
export {
|
|
143
|
+
useGlobalStylesRevisions as default
|
|
144
|
+
};
|
|
145
|
+
//# sourceMappingURL=use-global-styles-revisions.js.map
|