@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,386 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var context_exports = {};
|
|
20
|
+
__export(context_exports, {
|
|
21
|
+
FontLibraryContext: () => FontLibraryContext,
|
|
22
|
+
default: () => context_default
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(context_exports);
|
|
25
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
26
|
+
var import_element = require("@wordpress/element");
|
|
27
|
+
var import_data = require("@wordpress/data");
|
|
28
|
+
var import_core_data = require("@wordpress/core-data");
|
|
29
|
+
var import_i18n = require("@wordpress/i18n");
|
|
30
|
+
var import_resolvers = require("./resolvers");
|
|
31
|
+
var import_utils = require("./utils");
|
|
32
|
+
var import_set_immutably = require("./utils/set-immutably");
|
|
33
|
+
var import_toggleFont = require("./utils/toggleFont");
|
|
34
|
+
var import_hooks = require("../hooks");
|
|
35
|
+
const FontLibraryContext = (0, import_element.createContext)(
|
|
36
|
+
{}
|
|
37
|
+
);
|
|
38
|
+
FontLibraryContext.displayName = "FontLibraryContext";
|
|
39
|
+
function FontLibraryProvider({ children }) {
|
|
40
|
+
const { saveEntityRecord } = (0, import_data.useDispatch)(import_core_data.store);
|
|
41
|
+
const { globalStylesId } = (0, import_data.useSelect)((select) => {
|
|
42
|
+
const { __experimentalGetCurrentGlobalStylesId } = select(import_core_data.store);
|
|
43
|
+
return { globalStylesId: __experimentalGetCurrentGlobalStylesId() };
|
|
44
|
+
}, []);
|
|
45
|
+
const globalStyles = (0, import_core_data.useEntityRecord)(
|
|
46
|
+
"root",
|
|
47
|
+
"globalStyles",
|
|
48
|
+
globalStylesId
|
|
49
|
+
);
|
|
50
|
+
const [isInstalling, setIsInstalling] = (0, import_element.useState)(false);
|
|
51
|
+
const [refreshKey, setRefreshKey] = (0, import_element.useState)(0);
|
|
52
|
+
const refreshLibrary = () => {
|
|
53
|
+
setRefreshKey(Date.now());
|
|
54
|
+
};
|
|
55
|
+
const { records: libraryPosts = [], isResolving: isResolvingLibrary } = (0, import_core_data.useEntityRecords)(
|
|
56
|
+
"postType",
|
|
57
|
+
"wp_font_family",
|
|
58
|
+
{
|
|
59
|
+
refreshKey,
|
|
60
|
+
_embed: true
|
|
61
|
+
}
|
|
62
|
+
);
|
|
63
|
+
const libraryFonts = (libraryPosts || []).map((fontFamilyPost) => {
|
|
64
|
+
return {
|
|
65
|
+
id: fontFamilyPost.id,
|
|
66
|
+
...fontFamilyPost.font_family_settings || {},
|
|
67
|
+
fontFace: fontFamilyPost?._embedded?.font_faces?.map(
|
|
68
|
+
(face) => face.font_face_settings
|
|
69
|
+
) || []
|
|
70
|
+
};
|
|
71
|
+
}) || [];
|
|
72
|
+
const [fontFamilies, setFontFamilies] = (0, import_hooks.useSetting)("typography.fontFamilies");
|
|
73
|
+
const saveFontFamilies = async (fonts) => {
|
|
74
|
+
const updatedGlobalStyles = globalStyles.record;
|
|
75
|
+
(0, import_set_immutably.setImmutably)(
|
|
76
|
+
updatedGlobalStyles ?? {},
|
|
77
|
+
["settings", "typography", "fontFamilies"],
|
|
78
|
+
fonts
|
|
79
|
+
);
|
|
80
|
+
await saveEntityRecord("root", "globalStyles", updatedGlobalStyles);
|
|
81
|
+
};
|
|
82
|
+
const [modalTabOpen, setModalTabOpen] = (0, import_element.useState)("");
|
|
83
|
+
const [libraryFontSelected, setLibraryFontSelected] = (0, import_element.useState)(void 0);
|
|
84
|
+
const themeFonts = fontFamilies?.theme ? fontFamilies.theme.map((f) => (0, import_utils.setUIValuesNeeded)(f, { source: "theme" })).sort((a, b) => a.name.localeCompare(b.name)) : [];
|
|
85
|
+
const customFonts = fontFamilies?.custom ? fontFamilies.custom.map((f) => (0, import_utils.setUIValuesNeeded)(f, { source: "custom" })).sort((a, b) => a.name.localeCompare(b.name)) : [];
|
|
86
|
+
const baseCustomFonts = libraryFonts ? libraryFonts.map((f) => (0, import_utils.setUIValuesNeeded)(f, { source: "custom" })).sort((a, b) => a.name.localeCompare(b.name)) : [];
|
|
87
|
+
(0, import_element.useEffect)(() => {
|
|
88
|
+
if (!modalTabOpen) {
|
|
89
|
+
setLibraryFontSelected(void 0);
|
|
90
|
+
}
|
|
91
|
+
}, [modalTabOpen]);
|
|
92
|
+
const handleSetLibraryFontSelected = (font) => {
|
|
93
|
+
if (!font) {
|
|
94
|
+
setLibraryFontSelected(void 0);
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
const fonts = font.source === "theme" ? themeFonts : baseCustomFonts;
|
|
98
|
+
const fontSelected = fonts.find((f) => f.slug === font.slug);
|
|
99
|
+
setLibraryFontSelected({
|
|
100
|
+
...fontSelected || font,
|
|
101
|
+
source: font.source
|
|
102
|
+
});
|
|
103
|
+
};
|
|
104
|
+
const [loadedFontUrls] = (0, import_element.useState)(/* @__PURE__ */ new Set());
|
|
105
|
+
const getAvailableFontsOutline = (availableFontFamilies) => {
|
|
106
|
+
const outline = availableFontFamilies.reduce(
|
|
107
|
+
(acc, font) => {
|
|
108
|
+
const availableFontFaces = font?.fontFace && font.fontFace?.length > 0 ? font?.fontFace.map(
|
|
109
|
+
(face) => `${face.fontStyle ?? ""}${face.fontWeight ?? ""}`
|
|
110
|
+
) : ["normal400"];
|
|
111
|
+
acc[font.slug] = availableFontFaces;
|
|
112
|
+
return acc;
|
|
113
|
+
},
|
|
114
|
+
{}
|
|
115
|
+
);
|
|
116
|
+
return outline;
|
|
117
|
+
};
|
|
118
|
+
const getActivatedFontsOutline = (source) => {
|
|
119
|
+
switch (source) {
|
|
120
|
+
case "theme":
|
|
121
|
+
return getAvailableFontsOutline(themeFonts);
|
|
122
|
+
case "custom":
|
|
123
|
+
default:
|
|
124
|
+
return getAvailableFontsOutline(customFonts);
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
const isFontActivated = (slug, style, weight, source) => {
|
|
128
|
+
if (!style && !weight) {
|
|
129
|
+
return !!getActivatedFontsOutline(source)[slug];
|
|
130
|
+
}
|
|
131
|
+
return !!getActivatedFontsOutline(source)[slug]?.includes(
|
|
132
|
+
(style ?? "") + (weight ?? "")
|
|
133
|
+
);
|
|
134
|
+
};
|
|
135
|
+
const getFontFacesActivated = (slug, source) => {
|
|
136
|
+
return getActivatedFontsOutline(source)[slug] || [];
|
|
137
|
+
};
|
|
138
|
+
async function installFonts(fontFamiliesToInstall) {
|
|
139
|
+
setIsInstalling(true);
|
|
140
|
+
try {
|
|
141
|
+
const fontFamiliesToActivate = [];
|
|
142
|
+
let installationErrors = [];
|
|
143
|
+
for (const fontFamilyToInstall of fontFamiliesToInstall) {
|
|
144
|
+
let isANewFontFamily = false;
|
|
145
|
+
let installedFontFamily = await (0, import_resolvers.fetchGetFontFamilyBySlug)(
|
|
146
|
+
fontFamilyToInstall.slug
|
|
147
|
+
);
|
|
148
|
+
if (!installedFontFamily) {
|
|
149
|
+
isANewFontFamily = true;
|
|
150
|
+
installedFontFamily = await (0, import_resolvers.fetchInstallFontFamily)(
|
|
151
|
+
(0, import_utils.makeFontFamilyFormData)(fontFamilyToInstall)
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
const alreadyInstalledFontFaces = installedFontFamily.fontFace && fontFamilyToInstall.fontFace ? installedFontFamily.fontFace.filter(
|
|
155
|
+
(fontFaceToInstall) => fontFaceToInstall && fontFamilyToInstall.fontFace && (0, import_utils.checkFontFaceInstalled)(
|
|
156
|
+
fontFaceToInstall,
|
|
157
|
+
fontFamilyToInstall.fontFace
|
|
158
|
+
)
|
|
159
|
+
) : [];
|
|
160
|
+
if (installedFontFamily.fontFace && fontFamilyToInstall.fontFace) {
|
|
161
|
+
fontFamilyToInstall.fontFace = fontFamilyToInstall.fontFace.filter(
|
|
162
|
+
(fontFaceToInstall) => !(0, import_utils.checkFontFaceInstalled)(
|
|
163
|
+
fontFaceToInstall,
|
|
164
|
+
installedFontFamily.fontFace
|
|
165
|
+
)
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
let successfullyInstalledFontFaces = [];
|
|
169
|
+
let unsuccessfullyInstalledFontFaces = [];
|
|
170
|
+
if (fontFamilyToInstall?.fontFace?.length ?? 0 > 0) {
|
|
171
|
+
const response = await (0, import_utils.batchInstallFontFaces)(
|
|
172
|
+
installedFontFamily.id,
|
|
173
|
+
(0, import_utils.makeFontFacesFormData)(
|
|
174
|
+
fontFamilyToInstall
|
|
175
|
+
)
|
|
176
|
+
);
|
|
177
|
+
successfullyInstalledFontFaces = response?.successes;
|
|
178
|
+
unsuccessfullyInstalledFontFaces = response?.errors;
|
|
179
|
+
}
|
|
180
|
+
if (successfullyInstalledFontFaces?.length > 0 || alreadyInstalledFontFaces?.length > 0) {
|
|
181
|
+
installedFontFamily.fontFace = [
|
|
182
|
+
...successfullyInstalledFontFaces
|
|
183
|
+
];
|
|
184
|
+
fontFamiliesToActivate.push(installedFontFamily);
|
|
185
|
+
}
|
|
186
|
+
if (installedFontFamily && !fontFamilyToInstall?.fontFace?.length) {
|
|
187
|
+
fontFamiliesToActivate.push(installedFontFamily);
|
|
188
|
+
}
|
|
189
|
+
if (isANewFontFamily && (fontFamilyToInstall?.fontFace?.length ?? 0) > 0 && successfullyInstalledFontFaces?.length === 0) {
|
|
190
|
+
await (0, import_resolvers.fetchUninstallFontFamily)(installedFontFamily.id);
|
|
191
|
+
}
|
|
192
|
+
installationErrors = installationErrors.concat(
|
|
193
|
+
unsuccessfullyInstalledFontFaces
|
|
194
|
+
);
|
|
195
|
+
}
|
|
196
|
+
const installationErrorMessages = installationErrors.reduce(
|
|
197
|
+
(unique, item) => unique.includes(item.message) ? unique : [...unique, item.message],
|
|
198
|
+
[]
|
|
199
|
+
);
|
|
200
|
+
if (fontFamiliesToActivate.length > 0) {
|
|
201
|
+
const activeFonts = activateCustomFontFamilies(
|
|
202
|
+
fontFamiliesToActivate
|
|
203
|
+
);
|
|
204
|
+
await saveFontFamilies(activeFonts);
|
|
205
|
+
refreshLibrary();
|
|
206
|
+
}
|
|
207
|
+
if (installationErrorMessages.length > 0) {
|
|
208
|
+
const installError = new Error((0, import_i18n.__)("There was an error installing fonts."));
|
|
209
|
+
installError.installationErrors = installationErrorMessages;
|
|
210
|
+
throw installError;
|
|
211
|
+
}
|
|
212
|
+
} finally {
|
|
213
|
+
setIsInstalling(false);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
async function uninstallFontFamily(fontFamilyToUninstall) {
|
|
217
|
+
if (!fontFamilyToUninstall?.id) {
|
|
218
|
+
throw new Error((0, import_i18n.__)("Font family to uninstall is not defined."));
|
|
219
|
+
}
|
|
220
|
+
try {
|
|
221
|
+
const uninstalledFontFamily = await (0, import_resolvers.fetchUninstallFontFamily)(
|
|
222
|
+
fontFamilyToUninstall.id
|
|
223
|
+
);
|
|
224
|
+
if (uninstalledFontFamily.deleted) {
|
|
225
|
+
const activeFonts = deactivateFontFamily(
|
|
226
|
+
fontFamilyToUninstall
|
|
227
|
+
);
|
|
228
|
+
await saveFontFamilies(activeFonts);
|
|
229
|
+
}
|
|
230
|
+
refreshLibrary();
|
|
231
|
+
return uninstalledFontFamily;
|
|
232
|
+
} catch (error) {
|
|
233
|
+
console.error(
|
|
234
|
+
`There was an error uninstalling the font family:`,
|
|
235
|
+
error
|
|
236
|
+
);
|
|
237
|
+
throw error;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
const deactivateFontFamily = (font) => {
|
|
241
|
+
const initialCustomFonts = fontFamilies?.[font.source ?? ""] ?? [];
|
|
242
|
+
const newCustomFonts = initialCustomFonts.filter(
|
|
243
|
+
(f) => f.slug !== font.slug
|
|
244
|
+
);
|
|
245
|
+
const activeFonts = {
|
|
246
|
+
...fontFamilies,
|
|
247
|
+
[font.source ?? ""]: newCustomFonts
|
|
248
|
+
};
|
|
249
|
+
setFontFamilies(activeFonts);
|
|
250
|
+
if (font.fontFace) {
|
|
251
|
+
font.fontFace.forEach((face) => {
|
|
252
|
+
(0, import_utils.unloadFontFaceInBrowser)(face, "all");
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
return activeFonts;
|
|
256
|
+
};
|
|
257
|
+
const activateCustomFontFamilies = (fontsToAdd) => {
|
|
258
|
+
const fontsToActivate = cleanFontsForSave(fontsToAdd);
|
|
259
|
+
const activeFonts = {
|
|
260
|
+
...fontFamilies,
|
|
261
|
+
// Merge the existing custom fonts with the new fonts.
|
|
262
|
+
custom: (0, import_utils.mergeFontFamilies)(fontFamilies?.custom, fontsToActivate)
|
|
263
|
+
};
|
|
264
|
+
setFontFamilies(activeFonts);
|
|
265
|
+
loadFontsInBrowser(fontsToActivate);
|
|
266
|
+
return activeFonts;
|
|
267
|
+
};
|
|
268
|
+
const cleanFontsForSave = (fonts) => {
|
|
269
|
+
return fonts.map(({ id: _familyDbId, fontFace, ...font }) => ({
|
|
270
|
+
...font,
|
|
271
|
+
...fontFace && fontFace.length > 0 ? {
|
|
272
|
+
fontFace: fontFace.map(
|
|
273
|
+
({ id: _faceDbId, ...face }) => face
|
|
274
|
+
)
|
|
275
|
+
} : {}
|
|
276
|
+
}));
|
|
277
|
+
};
|
|
278
|
+
const loadFontsInBrowser = (fonts) => {
|
|
279
|
+
fonts.forEach((font) => {
|
|
280
|
+
if (font.fontFace) {
|
|
281
|
+
font.fontFace.forEach((face) => {
|
|
282
|
+
const displaySrc = (0, import_utils.getDisplaySrcFromFontFace)(
|
|
283
|
+
face?.src ?? ""
|
|
284
|
+
);
|
|
285
|
+
if (displaySrc) {
|
|
286
|
+
(0, import_utils.loadFontFaceInBrowser)(face, displaySrc, "all");
|
|
287
|
+
}
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
});
|
|
291
|
+
};
|
|
292
|
+
const toggleActivateFont = (font, face) => {
|
|
293
|
+
const initialFonts = fontFamilies?.[font.source ?? ""] ?? [];
|
|
294
|
+
const newFonts = (0, import_toggleFont.toggleFont)(font, face, initialFonts);
|
|
295
|
+
setFontFamilies({
|
|
296
|
+
...fontFamilies,
|
|
297
|
+
[font.source ?? ""]: newFonts
|
|
298
|
+
});
|
|
299
|
+
const isFaceActivated = isFontActivated(
|
|
300
|
+
font.slug,
|
|
301
|
+
face?.fontStyle ?? "",
|
|
302
|
+
face?.fontWeight ?? "",
|
|
303
|
+
font.source ?? "custom"
|
|
304
|
+
);
|
|
305
|
+
if (face && isFaceActivated) {
|
|
306
|
+
(0, import_utils.unloadFontFaceInBrowser)(face, "all");
|
|
307
|
+
} else {
|
|
308
|
+
const displaySrc = (0, import_utils.getDisplaySrcFromFontFace)(face?.src ?? "");
|
|
309
|
+
if (face && displaySrc) {
|
|
310
|
+
(0, import_utils.loadFontFaceInBrowser)(face, displaySrc, "all");
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
};
|
|
314
|
+
const loadFontFaceAsset = async (fontFace) => {
|
|
315
|
+
if (!fontFace.src) {
|
|
316
|
+
return;
|
|
317
|
+
}
|
|
318
|
+
const src = (0, import_utils.getDisplaySrcFromFontFace)(fontFace.src);
|
|
319
|
+
if (!src || loadedFontUrls.has(src)) {
|
|
320
|
+
return;
|
|
321
|
+
}
|
|
322
|
+
(0, import_utils.loadFontFaceInBrowser)(fontFace, src, "document");
|
|
323
|
+
loadedFontUrls.add(src);
|
|
324
|
+
};
|
|
325
|
+
const [collections, setFontCollections] = (0, import_element.useState)(
|
|
326
|
+
[]
|
|
327
|
+
);
|
|
328
|
+
const getFontCollections = async () => {
|
|
329
|
+
const response = await (0, import_resolvers.fetchFontCollections)();
|
|
330
|
+
setFontCollections(response);
|
|
331
|
+
};
|
|
332
|
+
const getFontCollection = async (slug) => {
|
|
333
|
+
try {
|
|
334
|
+
const hasData = !!collections.find(
|
|
335
|
+
(collection) => collection.slug === slug
|
|
336
|
+
)?.font_families;
|
|
337
|
+
if (hasData) {
|
|
338
|
+
return;
|
|
339
|
+
}
|
|
340
|
+
const response = await (0, import_resolvers.fetchFontCollection)(slug);
|
|
341
|
+
const updatedCollections = collections.map(
|
|
342
|
+
(collection) => collection.slug === slug ? { ...collection, ...response } : collection
|
|
343
|
+
);
|
|
344
|
+
setFontCollections(updatedCollections);
|
|
345
|
+
} catch (e) {
|
|
346
|
+
console.error(e);
|
|
347
|
+
throw e;
|
|
348
|
+
}
|
|
349
|
+
};
|
|
350
|
+
(0, import_element.useEffect)(() => {
|
|
351
|
+
getFontCollections();
|
|
352
|
+
}, []);
|
|
353
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
354
|
+
FontLibraryContext.Provider,
|
|
355
|
+
{
|
|
356
|
+
value: {
|
|
357
|
+
libraryFontSelected,
|
|
358
|
+
handleSetLibraryFontSelected,
|
|
359
|
+
fontFamilies: fontFamilies ?? {},
|
|
360
|
+
baseCustomFonts,
|
|
361
|
+
isFontActivated,
|
|
362
|
+
getFontFacesActivated,
|
|
363
|
+
loadFontFaceAsset,
|
|
364
|
+
installFonts,
|
|
365
|
+
uninstallFontFamily,
|
|
366
|
+
toggleActivateFont,
|
|
367
|
+
getAvailableFontsOutline,
|
|
368
|
+
modalTabOpen,
|
|
369
|
+
setModalTabOpen,
|
|
370
|
+
refreshLibrary,
|
|
371
|
+
saveFontFamilies,
|
|
372
|
+
isResolvingLibrary,
|
|
373
|
+
isInstalling,
|
|
374
|
+
collections,
|
|
375
|
+
getFontCollection
|
|
376
|
+
},
|
|
377
|
+
children
|
|
378
|
+
}
|
|
379
|
+
);
|
|
380
|
+
}
|
|
381
|
+
var context_default = FontLibraryProvider;
|
|
382
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
383
|
+
0 && (module.exports = {
|
|
384
|
+
FontLibraryContext
|
|
385
|
+
});
|
|
386
|
+
//# sourceMappingURL=context.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/font-library-modal/context.tsx"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { createContext, useState, useEffect } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tuseEntityRecord,\n\tuseEntityRecords,\n\tstore as coreStore,\n} from '@wordpress/core-data';\nimport { __ } from '@wordpress/i18n';\nimport type {\n\tFontFamilyPreset,\n\tGlobalStylesConfig,\n} from '@wordpress/global-styles-engine';\n\n/**\n * Internal dependencies\n */\nimport {\n\tfetchGetFontFamilyBySlug,\n\tfetchInstallFontFamily,\n\tfetchUninstallFontFamily,\n\tfetchFontCollections,\n\tfetchFontCollection,\n} from './resolvers';\nimport {\n\tsetUIValuesNeeded,\n\tmergeFontFamilies,\n\tloadFontFaceInBrowser,\n\tunloadFontFaceInBrowser,\n\tgetDisplaySrcFromFontFace,\n\tmakeFontFacesFormData,\n\tmakeFontFamilyFormData,\n\tbatchInstallFontFaces,\n\tcheckFontFaceInstalled,\n} from './utils';\nimport { setImmutably } from './utils/set-immutably';\nimport { toggleFont } from './utils/toggleFont';\nimport type {\n\tCollectionFontFamily,\n\tFontCollection,\n\tFontFace,\n\tFontFamily,\n\tFontLibraryState,\n} from './types';\nimport { useSetting } from '../hooks';\n\nexport const FontLibraryContext = createContext< FontLibraryState >(\n\t{} as FontLibraryState\n);\nFontLibraryContext.displayName = 'FontLibraryContext';\n\nfunction FontLibraryProvider( { children }: { children: React.ReactNode } ) {\n\tconst { saveEntityRecord } = useDispatch( coreStore );\n\tconst { globalStylesId } = useSelect( ( select ) => {\n\t\tconst { __experimentalGetCurrentGlobalStylesId } = select( coreStore );\n\t\treturn { globalStylesId: __experimentalGetCurrentGlobalStylesId() };\n\t}, [] );\n\n\tconst globalStyles = useEntityRecord< GlobalStylesConfig >(\n\t\t'root',\n\t\t'globalStyles',\n\t\tglobalStylesId\n\t);\n\n\tconst [ isInstalling, setIsInstalling ] = useState( false );\n\tconst [ refreshKey, setRefreshKey ] = useState( 0 );\n\n\tconst refreshLibrary = () => {\n\t\tsetRefreshKey( Date.now() );\n\t};\n\n\tconst { records: libraryPosts = [], isResolving: isResolvingLibrary } =\n\t\tuseEntityRecords< CollectionFontFamily >(\n\t\t\t'postType',\n\t\t\t'wp_font_family',\n\t\t\t{\n\t\t\t\trefreshKey,\n\t\t\t\t_embed: true,\n\t\t\t}\n\t\t);\n\n\tconst libraryFonts: FontFamilyPreset[] =\n\t\t( libraryPosts || [] ).map( ( fontFamilyPost ) => {\n\t\t\treturn {\n\t\t\t\tid: fontFamilyPost.id,\n\t\t\t\t...( fontFamilyPost.font_family_settings || {} ),\n\t\t\t\tfontFace:\n\t\t\t\t\tfontFamilyPost?._embedded?.font_faces?.map(\n\t\t\t\t\t\t( face ) => face.font_face_settings\n\t\t\t\t\t) || [],\n\t\t\t};\n\t\t} ) || [];\n\n\t// Global Styles (settings) font families\n\tconst [ fontFamilies, setFontFamilies ] = useSetting<\n\t\tRecord< string, FontFamilyPreset[] > | undefined\n\t>( 'typography.fontFamilies' );\n\n\t/*\n\t * Save the font families to the database.\n\n\t * This function is called when the user activates or deactivates a font family.\n\t * It only updates the global styles post content in the database for new font families.\n\t * This avoids saving other styles/settings changed by the user using other parts of the editor.\n\t *\n\t * It uses the font families from the param to avoid using the font families from an outdated state.\n\t *\n\t * @param {Array} fonts - The font families that will be saved to the database.\n\t */\n\tconst saveFontFamilies = async (\n\t\tfonts:\n\t\t\t| FontFamilyPreset[]\n\t\t\t| Record< string, FontFamilyPreset[] >\n\t\t\t| undefined\n\t) => {\n\t\t// Gets the global styles database post content.\n\t\tconst updatedGlobalStyles = globalStyles.record;\n\n\t\t// Updates the database version of global styles with the edited font families in the client.\n\t\tsetImmutably(\n\t\t\tupdatedGlobalStyles ?? {},\n\t\t\t[ 'settings', 'typography', 'fontFamilies' ],\n\t\t\tfonts\n\t\t);\n\n\t\t// Saves a new version of the global styles in the database.\n\t\tawait saveEntityRecord( 'root', 'globalStyles', updatedGlobalStyles );\n\t};\n\n\t// Library Fonts\n\tconst [ modalTabOpen, setModalTabOpen ] = useState( '' );\n\tconst [ libraryFontSelected, setLibraryFontSelected ] = useState<\n\t\tFontFamily | undefined\n\t>( undefined );\n\n\t// Themes Fonts are the fonts defined in the global styles (database persisted theme.json data).\n\tconst themeFonts = fontFamilies?.theme\n\t\t? fontFamilies.theme\n\t\t\t\t.map( ( f ) => setUIValuesNeeded( f, { source: 'theme' } ) )\n\t\t\t\t.sort( ( a, b ) => a.name.localeCompare( b.name ) )\n\t\t: [];\n\n\tconst customFonts = fontFamilies?.custom\n\t\t? fontFamilies.custom\n\t\t\t\t.map( ( f ) => setUIValuesNeeded( f, { source: 'custom' } ) )\n\t\t\t\t.sort( ( a, b ) => a.name.localeCompare( b.name ) )\n\t\t: [];\n\n\tconst baseCustomFonts = libraryFonts\n\t\t? libraryFonts\n\t\t\t\t.map( ( f ) => setUIValuesNeeded( f, { source: 'custom' } ) )\n\t\t\t\t.sort( ( a, b ) => a.name.localeCompare( b.name ) )\n\t\t: [];\n\n\tuseEffect( () => {\n\t\tif ( ! modalTabOpen ) {\n\t\t\tsetLibraryFontSelected( undefined );\n\t\t}\n\t}, [ modalTabOpen ] );\n\n\tconst handleSetLibraryFontSelected = ( font?: FontFamily ) => {\n\t\t// If font is null, reset the selected font\n\t\tif ( ! font ) {\n\t\t\tsetLibraryFontSelected( undefined );\n\t\t\treturn;\n\t\t}\n\n\t\tconst fonts = font.source === 'theme' ? themeFonts : baseCustomFonts;\n\n\t\t// Tries to find the font in the installed fonts\n\t\tconst fontSelected = fonts.find( ( f ) => f.slug === font.slug );\n\t\t// If the font is not found (it is only defined in custom styles), use the font from custom styles\n\t\tsetLibraryFontSelected( {\n\t\t\t...( fontSelected || font ),\n\t\t\tsource: font.source,\n\t\t} );\n\t};\n\n\t// Demo\n\tconst [ loadedFontUrls ] = useState( new Set() );\n\n\tconst getAvailableFontsOutline = (\n\t\tavailableFontFamilies: FontFamily[]\n\t) => {\n\t\tconst outline: Record< string, string[] > =\n\t\t\tavailableFontFamilies.reduce(\n\t\t\t\t( acc: Record< string, string[] >, font ) => {\n\t\t\t\t\tconst availableFontFaces =\n\t\t\t\t\t\tfont?.fontFace && font.fontFace?.length > 0\n\t\t\t\t\t\t\t? font?.fontFace.map(\n\t\t\t\t\t\t\t\t\t( face ) =>\n\t\t\t\t\t\t\t\t\t\t`${ face.fontStyle ?? '' }${\n\t\t\t\t\t\t\t\t\t\t\tface.fontWeight ?? ''\n\t\t\t\t\t\t\t\t\t\t}`\n\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t: [ 'normal400' ]; // If the font doesn't have fontFace, we assume it is a system font and we add the defaults: normal 400\n\n\t\t\t\t\tacc[ font.slug ] = availableFontFaces;\n\t\t\t\t\treturn acc;\n\t\t\t\t},\n\t\t\t\t{}\n\t\t\t);\n\t\treturn outline;\n\t};\n\n\tconst getActivatedFontsOutline = ( source?: string ) => {\n\t\tswitch ( source ) {\n\t\t\tcase 'theme':\n\t\t\t\treturn getAvailableFontsOutline( themeFonts );\n\t\t\tcase 'custom':\n\t\t\tdefault:\n\t\t\t\treturn getAvailableFontsOutline( customFonts );\n\t\t}\n\t};\n\n\tconst isFontActivated = (\n\t\tslug: string,\n\t\tstyle?: string,\n\t\tweight?: string | number,\n\t\tsource?: string\n\t) => {\n\t\tif ( ! style && ! weight ) {\n\t\t\treturn !! getActivatedFontsOutline( source )[ slug ];\n\t\t}\n\t\treturn !! getActivatedFontsOutline( source )[ slug ]?.includes(\n\t\t\t( style ?? '' ) + ( weight ?? '' )\n\t\t);\n\t};\n\n\tconst getFontFacesActivated = ( slug: string, source?: string ) => {\n\t\treturn getActivatedFontsOutline( source )[ slug ] || [];\n\t};\n\n\tasync function installFonts( fontFamiliesToInstall: FontFamily[] ) {\n\t\tsetIsInstalling( true );\n\t\ttry {\n\t\t\tconst fontFamiliesToActivate = [];\n\t\t\tlet installationErrors: Array< {\n\t\t\t\tmessage: string;\n\t\t\t} > = [];\n\n\t\t\tfor ( const fontFamilyToInstall of fontFamiliesToInstall ) {\n\t\t\t\tlet isANewFontFamily = false;\n\n\t\t\t\t// Get the font family if it already exists.\n\t\t\t\tlet installedFontFamily = await fetchGetFontFamilyBySlug(\n\t\t\t\t\tfontFamilyToInstall.slug\n\t\t\t\t);\n\n\t\t\t\t// Otherwise create it.\n\t\t\t\tif ( ! installedFontFamily ) {\n\t\t\t\t\tisANewFontFamily = true;\n\t\t\t\t\t// Prepare font family form data to install.\n\t\t\t\t\tinstalledFontFamily = await fetchInstallFontFamily(\n\t\t\t\t\t\tmakeFontFamilyFormData( fontFamilyToInstall )\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\t// Collect font faces that have already been installed (to be activated later)\n\t\t\t\tconst alreadyInstalledFontFaces =\n\t\t\t\t\tinstalledFontFamily.fontFace && fontFamilyToInstall.fontFace\n\t\t\t\t\t\t? installedFontFamily.fontFace.filter(\n\t\t\t\t\t\t\t\t( fontFaceToInstall: FontFace ) =>\n\t\t\t\t\t\t\t\t\tfontFaceToInstall &&\n\t\t\t\t\t\t\t\t\tfontFamilyToInstall.fontFace &&\n\t\t\t\t\t\t\t\t\tcheckFontFaceInstalled(\n\t\t\t\t\t\t\t\t\t\tfontFaceToInstall,\n\t\t\t\t\t\t\t\t\t\tfontFamilyToInstall.fontFace\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t )\n\t\t\t\t\t\t: [];\n\n\t\t\t\t// Filter out Font Faces that have already been installed (so that they are not re-installed)\n\t\t\t\tif (\n\t\t\t\t\tinstalledFontFamily.fontFace &&\n\t\t\t\t\tfontFamilyToInstall.fontFace\n\t\t\t\t) {\n\t\t\t\t\tfontFamilyToInstall.fontFace =\n\t\t\t\t\t\tfontFamilyToInstall.fontFace.filter(\n\t\t\t\t\t\t\t( fontFaceToInstall ) =>\n\t\t\t\t\t\t\t\t! checkFontFaceInstalled(\n\t\t\t\t\t\t\t\t\tfontFaceToInstall,\n\t\t\t\t\t\t\t\t\tinstalledFontFamily.fontFace\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\t// Install the fonts (upload the font files to the server and create the post in the database).\n\t\t\t\tlet successfullyInstalledFontFaces: FontFace[] = [];\n\t\t\t\tlet unsuccessfullyInstalledFontFaces: {\n\t\t\t\t\tmessage: string;\n\t\t\t\t}[] = [];\n\t\t\t\tif ( fontFamilyToInstall?.fontFace?.length ?? 0 > 0 ) {\n\t\t\t\t\tconst response = await batchInstallFontFaces(\n\t\t\t\t\t\tinstalledFontFamily.id,\n\t\t\t\t\t\tmakeFontFacesFormData(\n\t\t\t\t\t\t\tfontFamilyToInstall as FontFamily\n\t\t\t\t\t\t)\n\t\t\t\t\t);\n\t\t\t\t\tsuccessfullyInstalledFontFaces = response?.successes;\n\t\t\t\t\tunsuccessfullyInstalledFontFaces = response?.errors;\n\t\t\t\t}\n\n\t\t\t\t// Use the successfully installed font faces\n\t\t\t\t// As well as any font faces that were already installed (those will be activated)\n\t\t\t\tif (\n\t\t\t\t\tsuccessfullyInstalledFontFaces?.length > 0 ||\n\t\t\t\t\talreadyInstalledFontFaces?.length > 0\n\t\t\t\t) {\n\t\t\t\t\t// Use font data from REST API not from client to ensure\n\t\t\t\t\t// correct font information is used.\n\t\t\t\t\tinstalledFontFamily.fontFace = [\n\t\t\t\t\t\t...successfullyInstalledFontFaces,\n\t\t\t\t\t];\n\n\t\t\t\t\tfontFamiliesToActivate.push( installedFontFamily );\n\t\t\t\t}\n\n\t\t\t\t// If it's a system font but was installed successfully, activate it.\n\t\t\t\tif (\n\t\t\t\t\tinstalledFontFamily &&\n\t\t\t\t\t! fontFamilyToInstall?.fontFace?.length\n\t\t\t\t) {\n\t\t\t\t\tfontFamiliesToActivate.push( installedFontFamily );\n\t\t\t\t}\n\n\t\t\t\t// If the font family is new and is not a system font, delete it to avoid having font families without font faces.\n\t\t\t\tif (\n\t\t\t\t\tisANewFontFamily &&\n\t\t\t\t\t( fontFamilyToInstall?.fontFace?.length ?? 0 ) > 0 &&\n\t\t\t\t\tsuccessfullyInstalledFontFaces?.length === 0\n\t\t\t\t) {\n\t\t\t\t\tawait fetchUninstallFontFamily( installedFontFamily.id );\n\t\t\t\t}\n\n\t\t\t\tinstallationErrors = installationErrors.concat(\n\t\t\t\t\tunsuccessfullyInstalledFontFaces\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst installationErrorMessages: string[] =\n\t\t\t\tinstallationErrors.reduce(\n\t\t\t\t\t( unique: string[], item ) =>\n\t\t\t\t\t\tunique.includes( item.message )\n\t\t\t\t\t\t\t? unique\n\t\t\t\t\t\t\t: [ ...unique, item.message ],\n\t\t\t\t\t[]\n\t\t\t\t);\n\n\t\t\tif ( fontFamiliesToActivate.length > 0 ) {\n\t\t\t\t// Activate the font family (add the font family to the global styles).\n\t\t\t\tconst activeFonts = activateCustomFontFamilies(\n\t\t\t\t\tfontFamiliesToActivate\n\t\t\t\t);\n\t\t\t\t// Save the global styles to the database.\n\t\t\t\tawait saveFontFamilies( activeFonts );\n\n\t\t\t\trefreshLibrary();\n\t\t\t}\n\n\t\t\tif ( installationErrorMessages.length > 0 ) {\n\t\t\t\tconst installError: Error & {\n\t\t\t\t\tinstallationErrors?: string[];\n\t\t\t\t} = new Error( __( 'There was an error installing fonts.' ) );\n\n\t\t\t\tinstallError.installationErrors = installationErrorMessages;\n\n\t\t\t\tthrow installError;\n\t\t\t}\n\t\t} finally {\n\t\t\tsetIsInstalling( false );\n\t\t}\n\t}\n\n\tasync function uninstallFontFamily( fontFamilyToUninstall: FontFamily ) {\n\t\tif ( ! fontFamilyToUninstall?.id ) {\n\t\t\tthrow new Error( __( 'Font family to uninstall is not defined.' ) );\n\t\t}\n\t\ttry {\n\t\t\t// Uninstall the font family.\n\t\t\t// (Removes the font files from the server and the posts from the database).\n\t\t\tconst uninstalledFontFamily = await fetchUninstallFontFamily(\n\t\t\t\tfontFamilyToUninstall.id\n\t\t\t);\n\n\t\t\t// Deactivate the font family if delete request is successful\n\t\t\t// (Removes the font family from the global styles).\n\t\t\tif ( uninstalledFontFamily.deleted ) {\n\t\t\t\tconst activeFonts = deactivateFontFamily(\n\t\t\t\t\tfontFamilyToUninstall\n\t\t\t\t);\n\t\t\t\t// Save the global styles to the database.\n\t\t\t\tawait saveFontFamilies( activeFonts );\n\t\t\t}\n\n\t\t\t// Refresh the library (the library font families from database).\n\t\t\trefreshLibrary();\n\n\t\t\treturn uninstalledFontFamily;\n\t\t} catch ( error ) {\n\t\t\t// eslint-disable-next-line no-console\n\t\t\tconsole.error(\n\t\t\t\t`There was an error uninstalling the font family:`,\n\t\t\t\terror\n\t\t\t);\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\tconst deactivateFontFamily = ( font: FontFamily ) => {\n\t\t// If the user doesn't have custom fonts defined, include as custom fonts all the theme fonts\n\t\t// We want to save as active all the theme fonts at the beginning\n\t\tconst initialCustomFonts = fontFamilies?.[ font.source ?? '' ] ?? [];\n\t\tconst newCustomFonts = initialCustomFonts.filter(\n\t\t\t( f ) => f.slug !== font.slug\n\t\t);\n\t\tconst activeFonts = {\n\t\t\t...fontFamilies,\n\t\t\t[ font.source ?? '' ]: newCustomFonts,\n\t\t};\n\t\tsetFontFamilies( activeFonts );\n\n\t\tif ( font.fontFace ) {\n\t\t\tfont.fontFace.forEach( ( face ) => {\n\t\t\t\tunloadFontFaceInBrowser( face, 'all' );\n\t\t\t} );\n\t\t}\n\t\treturn activeFonts;\n\t};\n\n\tconst activateCustomFontFamilies = ( fontsToAdd: FontFamily[] ) => {\n\t\tconst fontsToActivate = cleanFontsForSave( fontsToAdd );\n\n\t\tconst activeFonts = {\n\t\t\t...fontFamilies,\n\t\t\t// Merge the existing custom fonts with the new fonts.\n\t\t\tcustom: mergeFontFamilies( fontFamilies?.custom, fontsToActivate ),\n\t\t};\n\n\t\t// Activate the fonts by set the new custom fonts array.\n\t\tsetFontFamilies( activeFonts );\n\n\t\tloadFontsInBrowser( fontsToActivate );\n\n\t\treturn activeFonts;\n\t};\n\n\t// Removes the id from the families and faces to avoid saving that to global styles post content.\n\tconst cleanFontsForSave = ( fonts: FontFamily[] ) => {\n\t\treturn fonts.map( ( { id: _familyDbId, fontFace, ...font } ) => ( {\n\t\t\t...font,\n\t\t\t...( fontFace && fontFace.length > 0\n\t\t\t\t? {\n\t\t\t\t\t\tfontFace: fontFace.map(\n\t\t\t\t\t\t\t( { id: _faceDbId, ...face } ) => face\n\t\t\t\t\t\t),\n\t\t\t\t }\n\t\t\t\t: {} ),\n\t\t} ) );\n\t};\n\n\tconst loadFontsInBrowser = ( fonts: FontFamily[] ) => {\n\t\t// Add custom fonts to the browser.\n\t\tfonts.forEach( ( font ) => {\n\t\t\tif ( font.fontFace ) {\n\t\t\t\tfont.fontFace.forEach( ( face ) => {\n\t\t\t\t\tconst displaySrc = getDisplaySrcFromFontFace(\n\t\t\t\t\t\tface?.src ?? ''\n\t\t\t\t\t);\n\t\t\t\t\tif ( displaySrc ) {\n\t\t\t\t\t\t// Load font faces just in the iframe because they already are in the document.\n\t\t\t\t\t\tloadFontFaceInBrowser( face, displaySrc, 'all' );\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t}\n\t\t} );\n\t};\n\n\tconst toggleActivateFont = ( font: FontFamily, face?: FontFace ) => {\n\t\t// If the user doesn't have custom fonts defined, include as custom fonts all the theme fonts\n\t\t// We want to save as active all the theme fonts at the beginning\n\t\tconst initialFonts = fontFamilies?.[ font.source ?? '' ] ?? [];\n\t\t// Toggles the received font family or font face\n\t\tconst newFonts = toggleFont( font, face, initialFonts );\n\t\t// Updates the font families activated in global settings:\n\t\tsetFontFamilies( {\n\t\t\t...fontFamilies,\n\t\t\t[ font.source ?? '' ]: newFonts,\n\t\t} );\n\n\t\tconst isFaceActivated = isFontActivated(\n\t\t\tfont.slug,\n\t\t\tface?.fontStyle ?? '',\n\t\t\tface?.fontWeight ?? '',\n\t\t\tfont.source ?? 'custom'\n\t\t);\n\n\t\tif ( face && isFaceActivated ) {\n\t\t\tunloadFontFaceInBrowser( face, 'all' );\n\t\t} else {\n\t\t\tconst displaySrc = getDisplaySrcFromFontFace( face?.src ?? '' );\n\t\t\t// If the font doesn't have a src, don't load it.\n\t\t\tif ( face && displaySrc ) {\n\t\t\t\tloadFontFaceInBrowser( face, displaySrc, 'all' );\n\t\t\t}\n\t\t}\n\t};\n\n\tconst loadFontFaceAsset = async ( fontFace: FontFace ) => {\n\t\t// If the font doesn't have a src, don't load it.\n\t\tif ( ! fontFace.src ) {\n\t\t\treturn;\n\t\t}\n\t\t// Get the src of the font.\n\t\tconst src = getDisplaySrcFromFontFace( fontFace.src );\n\t\t// If the font is already loaded, don't load it again.\n\t\tif ( ! src || loadedFontUrls.has( src ) ) {\n\t\t\treturn;\n\t\t}\n\t\t// Load the font in the browser.\n\t\tloadFontFaceInBrowser( fontFace, src, 'document' );\n\t\t// Add the font to the loaded fonts list.\n\t\tloadedFontUrls.add( src );\n\t};\n\n\t// Font Collections\n\tconst [ collections, setFontCollections ] = useState< FontCollection[] >(\n\t\t[]\n\t);\n\tconst getFontCollections = async () => {\n\t\tconst response = await fetchFontCollections();\n\t\tsetFontCollections( response );\n\t};\n\tconst getFontCollection = async ( slug: string ) => {\n\t\ttry {\n\t\t\tconst hasData = !! collections.find(\n\t\t\t\t( collection ) => collection.slug === slug\n\t\t\t)?.font_families;\n\t\t\tif ( hasData ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst response = await fetchFontCollection( slug );\n\t\t\tconst updatedCollections = collections.map( ( collection ) =>\n\t\t\t\tcollection.slug === slug\n\t\t\t\t\t? { ...collection, ...response }\n\t\t\t\t\t: collection\n\t\t\t);\n\t\t\tsetFontCollections( updatedCollections );\n\t\t} catch ( e ) {\n\t\t\t// eslint-disable-next-line no-console\n\t\t\tconsole.error( e );\n\t\t\tthrow e;\n\t\t}\n\t};\n\n\tuseEffect( () => {\n\t\tgetFontCollections();\n\t}, [] );\n\n\treturn (\n\t\t<FontLibraryContext.Provider\n\t\t\tvalue={ {\n\t\t\t\tlibraryFontSelected,\n\t\t\t\thandleSetLibraryFontSelected,\n\t\t\t\tfontFamilies: fontFamilies ?? {},\n\t\t\t\tbaseCustomFonts,\n\t\t\t\tisFontActivated,\n\t\t\t\tgetFontFacesActivated,\n\t\t\t\tloadFontFaceAsset,\n\t\t\t\tinstallFonts,\n\t\t\t\tuninstallFontFamily,\n\t\t\t\ttoggleActivateFont,\n\t\t\t\tgetAvailableFontsOutline,\n\t\t\t\tmodalTabOpen,\n\t\t\t\tsetModalTabOpen,\n\t\t\t\trefreshLibrary,\n\t\t\t\tsaveFontFamilies,\n\t\t\t\tisResolvingLibrary,\n\t\t\t\tisInstalling,\n\t\t\t\tcollections,\n\t\t\t\tgetFontCollection,\n\t\t\t} }\n\t\t>\n\t\t\t{ children }\n\t\t</FontLibraryContext.Provider>\n\t);\n}\n\nexport default FontLibraryProvider;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAkjBE;AA/iBF,qBAAmD;AACnD,kBAAuC;AACvC,uBAIO;AACP,kBAAmB;AASnB,uBAMO;AACP,mBAUO;AACP,2BAA6B;AAC7B,wBAA2B;AAQ3B,mBAA2B;AAEpB,MAAM,yBAAqB;AAAA,EACjC,CAAC;AACF;AACA,mBAAmB,cAAc;AAEjC,SAAS,oBAAqB,EAAE,SAAS,GAAmC;AAC3E,QAAM,EAAE,iBAAiB,QAAI,yBAAa,iBAAAA,KAAU;AACpD,QAAM,EAAE,eAAe,QAAI,uBAAW,CAAE,WAAY;AACnD,UAAM,EAAE,uCAAuC,IAAI,OAAQ,iBAAAA,KAAU;AACrE,WAAO,EAAE,gBAAgB,uCAAuC,EAAE;AAA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AC5C,uBAAoB,QAAS;AAAA,EAC9B;AACA,QAAM,oBAAoB,OAAQ,SAAkB;AACnD,QAAI;AACH,YAAM,UAAU,CAAC,CAAE,YAAY;AAAA,QAC9B,CAAE,eAAgB,WAAW,SAAS;AAAA,MACvC,GAAG;AACH,UAAK,SAAU;AACd;AAAA,MACD;AACA,YAAM,WAAW,UAAM,sCAAqB,IAAK;AACjD,YAAM,qBAAqB,YAAY;AAAA,QAAK,CAAE,eAC7C,WAAW,SAAS,OACjB,EAAE,GAAG,YAAY,GAAG,SAAS,IAC7B;AAAA,MACJ;AACA,yBAAoB,kBAAmB;AAAA,IACxC,SAAU,GAAI;AAEb,cAAQ,MAAO,CAAE;AACjB,YAAM;AAAA,IACP;AAAA,EACD;AAEA,gCAAW,MAAM;AAChB,uBAAmB;AAAA,EACpB,GAAG,CAAC,CAAE;AAEN,SACC;AAAA,IAAC,mBAAmB;AAAA,IAAnB;AAAA,MACA,OAAQ;AAAA,QACP;AAAA,QACA;AAAA,QACA,cAAc,gBAAgB,CAAC;AAAA,QAC/B;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACD;AAAA,MAEE;AAAA;AAAA,EACH;AAEF;AAEA,IAAO,kBAAQ;",
|
|
6
|
+
"names": ["coreStore"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var font_card_exports = {};
|
|
30
|
+
__export(font_card_exports, {
|
|
31
|
+
default: () => font_card_default
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(font_card_exports);
|
|
34
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
35
|
+
var import_i18n = require("@wordpress/i18n");
|
|
36
|
+
var import_components = require("@wordpress/components");
|
|
37
|
+
var import_icons = require("@wordpress/icons");
|
|
38
|
+
var import_font_demo = __toESM(require("./font-demo"));
|
|
39
|
+
function FontCard({
|
|
40
|
+
font,
|
|
41
|
+
onClick,
|
|
42
|
+
variantsText,
|
|
43
|
+
navigatorPath
|
|
44
|
+
}) {
|
|
45
|
+
const variantsCount = font.fontFace?.length || 1;
|
|
46
|
+
const style = {
|
|
47
|
+
cursor: !!onClick ? "pointer" : "default"
|
|
48
|
+
};
|
|
49
|
+
const navigator = (0, import_components.useNavigator)();
|
|
50
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
51
|
+
import_components.Button,
|
|
52
|
+
{
|
|
53
|
+
__next40pxDefaultSize: true,
|
|
54
|
+
onClick: () => {
|
|
55
|
+
onClick();
|
|
56
|
+
if (navigatorPath) {
|
|
57
|
+
navigator.goTo(navigatorPath);
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
style,
|
|
61
|
+
className: "font-library-modal__font-card",
|
|
62
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_components.Flex, { justify: "space-between", wrap: false, children: [
|
|
63
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_font_demo.default, { font }),
|
|
64
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_components.Flex, { justify: "flex-end", children: [
|
|
65
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.FlexItem, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.__experimentalText, { className: "font-library-modal__font-card__count", children: variantsText || (0, import_i18n.sprintf)(
|
|
66
|
+
/* translators: %d: Number of font variants. */
|
|
67
|
+
(0, import_i18n._n)(
|
|
68
|
+
"%d variant",
|
|
69
|
+
"%d variants",
|
|
70
|
+
variantsCount
|
|
71
|
+
),
|
|
72
|
+
variantsCount
|
|
73
|
+
) }) }),
|
|
74
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.FlexItem, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons.Icon, { icon: (0, import_i18n.isRTL)() ? import_icons.chevronLeft : import_icons.chevronRight }) })
|
|
75
|
+
] })
|
|
76
|
+
] })
|
|
77
|
+
}
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
var font_card_default = FontCard;
|
|
81
|
+
//# sourceMappingURL=font-card.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/font-library-modal/font-card.tsx"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { _n, sprintf, isRTL } from '@wordpress/i18n';\nimport {\n\tuseNavigator,\n\t__experimentalText as Text,\n\tButton,\n\tFlex,\n\tFlexItem,\n} from '@wordpress/components';\nimport { Icon, chevronLeft, chevronRight } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport FontDemo from './font-demo';\nimport type { FontFamily } from './types';\n\nfunction FontCard( {\n\tfont,\n\tonClick,\n\tvariantsText,\n\tnavigatorPath,\n}: {\n\tfont: FontFamily;\n\tonClick: () => void;\n\tvariantsText?: string;\n\tnavigatorPath?: string;\n} ) {\n\tconst variantsCount = font.fontFace?.length || 1;\n\n\tconst style = {\n\t\tcursor: !! onClick ? 'pointer' : 'default',\n\t};\n\n\tconst navigator = useNavigator();\n\n\treturn (\n\t\t<Button\n\t\t\t__next40pxDefaultSize\n\t\t\tonClick={ () => {\n\t\t\t\tonClick();\n\t\t\t\tif ( navigatorPath ) {\n\t\t\t\t\tnavigator.goTo( navigatorPath );\n\t\t\t\t}\n\t\t\t} }\n\t\t\tstyle={ style }\n\t\t\tclassName=\"font-library-modal__font-card\"\n\t\t>\n\t\t\t<Flex justify=\"space-between\" wrap={ false }>\n\t\t\t\t<FontDemo font={ font } />\n\t\t\t\t<Flex justify=\"flex-end\">\n\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t<Text className=\"font-library-modal__font-card__count\">\n\t\t\t\t\t\t\t{ variantsText ||\n\t\t\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t\t\t/* translators: %d: Number of font variants. */\n\t\t\t\t\t\t\t\t\t_n(\n\t\t\t\t\t\t\t\t\t\t'%d variant',\n\t\t\t\t\t\t\t\t\t\t'%d variants',\n\t\t\t\t\t\t\t\t\t\tvariantsCount\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\tvariantsCount\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</Text>\n\t\t\t\t\t</FlexItem>\n\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t<Icon icon={ isRTL() ? chevronLeft : chevronRight } />\n\t\t\t\t\t</FlexItem>\n\t\t\t\t</Flex>\n\t\t\t</Flex>\n\t\t</Button>\n\t);\n}\n\nexport default FontCard;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAmDI;AAhDJ,kBAAmC;AACnC,wBAMO;AACP,mBAAgD;AAKhD,uBAAqB;AAGrB,SAAS,SAAU;AAAA,EAClB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAKI;AACH,QAAM,gBAAgB,KAAK,UAAU,UAAU;AAE/C,QAAM,QAAQ;AAAA,IACb,QAAQ,CAAC,CAAE,UAAU,YAAY;AAAA,EAClC;AAEA,QAAM,gBAAY,gCAAa;AAE/B,SACC;AAAA,IAAC;AAAA;AAAA,MACA,uBAAqB;AAAA,MACrB,SAAU,MAAM;AACf,gBAAQ;AACR,YAAK,eAAgB;AACpB,oBAAU,KAAM,aAAc;AAAA,QAC/B;AAAA,MACD;AAAA,MACA;AAAA,MACA,WAAU;AAAA,MAEV,uDAAC,0BAAK,SAAQ,iBAAgB,MAAO,OACpC;AAAA,oDAAC,iBAAAA,SAAA,EAAS,MAAc;AAAA,QACxB,6CAAC,0BAAK,SAAQ,YACb;AAAA,sDAAC,8BACA,sDAAC,kBAAAC,oBAAA,EAAK,WAAU,wCACb,8BACD;AAAA;AAAA,gBAEC;AAAA,cACC;AAAA,cACA;AAAA,cACA;AAAA,YACD;AAAA,YACA;AAAA,UACD,GACF,GACD;AAAA,UACA,4CAAC,8BACA,sDAAC,qBAAK,UAAO,mBAAM,IAAI,2BAAc,2BAAe,GACrD;AAAA,WACD;AAAA,SACD;AAAA;AAAA,EACD;AAEF;AAEA,IAAO,oBAAQ;",
|
|
6
|
+
"names": ["FontDemo", "Text"]
|
|
7
|
+
}
|