@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,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/font-library-modal/library-font-details.tsx"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalVStack as VStack,\n\t__experimentalSpacer as Spacer,\n} from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport LibraryFontVariant from './library-font-variant';\nimport { sortFontFaces } from './utils/sort-font-faces';\nimport type { FontFamily } from './types';\n\nfunction LibraryFontDetails( { font }: { font: FontFamily } ) {\n\tconst fontFaces =\n\t\tfont.fontFace && font.fontFace.length\n\t\t\t? sortFontFaces( font.fontFace )\n\t\t\t: [\n\t\t\t\t\t{\n\t\t\t\t\t\tfontFamily: font.fontFamily,\n\t\t\t\t\t\tfontStyle: 'normal',\n\t\t\t\t\t\tfontWeight: '400',\n\t\t\t\t\t},\n\t\t\t ];\n\n\treturn (\n\t\t<>\n\t\t\t<Spacer margin={ 4 } />\n\t\t\t<VStack spacing={ 0 }>\n\t\t\t\t<Spacer margin={ 8 } />\n\t\t\t\t{ fontFaces.map( ( face, i ) => (\n\t\t\t\t\t<LibraryFontVariant\n\t\t\t\t\t\tfont={ font }\n\t\t\t\t\t\tface={ face }\n\t\t\t\t\t\tkey={ `face${ i }` }\n\t\t\t\t\t/>\n\t\t\t\t) ) }\n\t\t\t</VStack>\n\t\t\t<Spacer margin={ 8 } />\n\t\t</>\n\t);\n}\n\nexport default LibraryFontDetails;\n"],
|
|
5
|
+
"mappings": "AA4BE,mBACC,KACA,YAFD;AAzBF;AAAA,EACC,wBAAwB;AAAA,EACxB,wBAAwB;AAAA,OAClB;AAKP,OAAO,wBAAwB;AAC/B,SAAS,qBAAqB;AAG9B,SAAS,mBAAoB,EAAE,KAAK,GAA0B;AAC7D,QAAM,YACL,KAAK,YAAY,KAAK,SAAS,SAC5B,cAAe,KAAK,QAAS,IAC7B;AAAA,IACA;AAAA,MACC,YAAY,KAAK;AAAA,MACjB,WAAW;AAAA,MACX,YAAY;AAAA,IACb;AAAA,EACA;AAEJ,SACC,iCACC;AAAA,wBAAC,UAAO,QAAS,GAAI;AAAA,IACrB,qBAAC,UAAO,SAAU,GACjB;AAAA,0BAAC,UAAO,QAAS,GAAI;AAAA,MACnB,UAAU,IAAK,CAAE,MAAM,MACxB;AAAA,QAAC;AAAA;AAAA,UACA;AAAA,UACA;AAAA;AAAA,QACM,OAAQ,CAAE;AAAA,MACjB,CACC;AAAA,OACH;AAAA,IACA,oBAAC,UAAO,QAAS,GAAI;AAAA,KACtB;AAEF;AAEA,IAAO,+BAAQ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useContext, useId } from "@wordpress/element";
|
|
3
|
+
import { CheckboxControl, Flex } from "@wordpress/components";
|
|
4
|
+
import { getFontFaceVariantName } from "./utils";
|
|
5
|
+
import { FontLibraryContext } from "./context";
|
|
6
|
+
import FontDemo from "./font-demo";
|
|
7
|
+
function LibraryFontVariant({
|
|
8
|
+
face,
|
|
9
|
+
font
|
|
10
|
+
}) {
|
|
11
|
+
const { isFontActivated, toggleActivateFont } = useContext(FontLibraryContext);
|
|
12
|
+
const isInstalled = (font?.fontFace?.length ?? 0) > 0 ? isFontActivated(
|
|
13
|
+
font.slug,
|
|
14
|
+
face.fontStyle,
|
|
15
|
+
face.fontWeight,
|
|
16
|
+
font.source
|
|
17
|
+
) : isFontActivated(font.slug, void 0, void 0, font.source);
|
|
18
|
+
const handleToggleActivation = () => {
|
|
19
|
+
if ((font?.fontFace?.length ?? 0) > 0) {
|
|
20
|
+
toggleActivateFont(font, face);
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
toggleActivateFont(font);
|
|
24
|
+
};
|
|
25
|
+
const displayName = font.name + " " + getFontFaceVariantName(face);
|
|
26
|
+
const checkboxId = useId();
|
|
27
|
+
return /* @__PURE__ */ jsx("div", { className: "font-library-modal__font-card", children: /* @__PURE__ */ jsxs(Flex, { justify: "flex-start", align: "center", gap: "1rem", children: [
|
|
28
|
+
/* @__PURE__ */ jsx(
|
|
29
|
+
CheckboxControl,
|
|
30
|
+
{
|
|
31
|
+
checked: isInstalled,
|
|
32
|
+
onChange: handleToggleActivation,
|
|
33
|
+
__nextHasNoMarginBottom: true,
|
|
34
|
+
id: checkboxId
|
|
35
|
+
}
|
|
36
|
+
),
|
|
37
|
+
/* @__PURE__ */ jsx("label", { htmlFor: checkboxId, children: /* @__PURE__ */ jsx(
|
|
38
|
+
FontDemo,
|
|
39
|
+
{
|
|
40
|
+
font: face,
|
|
41
|
+
text: displayName,
|
|
42
|
+
onClick: handleToggleActivation
|
|
43
|
+
}
|
|
44
|
+
) })
|
|
45
|
+
] }) });
|
|
46
|
+
}
|
|
47
|
+
var library_font_variant_default = LibraryFontVariant;
|
|
48
|
+
export {
|
|
49
|
+
library_font_variant_default as default
|
|
50
|
+
};
|
|
51
|
+
//# sourceMappingURL=library-font-variant.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/font-library-modal/library-font-variant.tsx"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useContext, useId } from '@wordpress/element';\nimport { CheckboxControl, Flex } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport { getFontFaceVariantName } from './utils';\nimport { FontLibraryContext } from './context';\nimport FontDemo from './font-demo';\nimport type { FontFace, FontFamily } from './types';\n\nfunction LibraryFontVariant( {\n\tface,\n\tfont,\n}: {\n\tface: FontFace;\n\tfont: FontFamily;\n} ) {\n\tconst { isFontActivated, toggleActivateFont } =\n\t\tuseContext( FontLibraryContext );\n\n\tconst isInstalled =\n\t\t( font?.fontFace?.length ?? 0 ) > 0\n\t\t\t? isFontActivated(\n\t\t\t\t\tfont.slug,\n\t\t\t\t\tface.fontStyle,\n\t\t\t\t\tface.fontWeight,\n\t\t\t\t\tfont.source\n\t\t\t )\n\t\t\t: isFontActivated( font.slug, undefined, undefined, font.source );\n\n\tconst handleToggleActivation = () => {\n\t\tif ( ( font?.fontFace?.length ?? 0 ) > 0 ) {\n\t\t\ttoggleActivateFont( font, face );\n\t\t\treturn;\n\t\t}\n\t\ttoggleActivateFont( font );\n\t};\n\n\tconst displayName = font.name + ' ' + getFontFaceVariantName( face );\n\tconst checkboxId = useId();\n\n\treturn (\n\t\t<div className=\"font-library-modal__font-card\">\n\t\t\t<Flex justify=\"flex-start\" align=\"center\" gap=\"1rem\">\n\t\t\t\t<CheckboxControl\n\t\t\t\t\tchecked={ isInstalled }\n\t\t\t\t\tonChange={ handleToggleActivation }\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\tid={ checkboxId }\n\t\t\t\t/>\n\t\t\t\t<label htmlFor={ checkboxId }>\n\t\t\t\t\t<FontDemo\n\t\t\t\t\t\tfont={ face }\n\t\t\t\t\t\ttext={ displayName }\n\t\t\t\t\t\tonClick={ handleToggleActivation }\n\t\t\t\t\t/>\n\t\t\t\t</label>\n\t\t\t</Flex>\n\t\t</div>\n\t);\n}\n\nexport default LibraryFontVariant;\n"],
|
|
5
|
+
"mappings": "AA+CG,SACC,KADD;AA5CH,SAAS,YAAY,aAAa;AAClC,SAAS,iBAAiB,YAAY;AAKtC,SAAS,8BAA8B;AACvC,SAAS,0BAA0B;AACnC,OAAO,cAAc;AAGrB,SAAS,mBAAoB;AAAA,EAC5B;AAAA,EACA;AACD,GAGI;AACH,QAAM,EAAE,iBAAiB,mBAAmB,IAC3C,WAAY,kBAAmB;AAEhC,QAAM,eACH,MAAM,UAAU,UAAU,KAAM,IAC/B;AAAA,IACA,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,EACL,IACA,gBAAiB,KAAK,MAAM,QAAW,QAAW,KAAK,MAAO;AAElE,QAAM,yBAAyB,MAAM;AACpC,SAAO,MAAM,UAAU,UAAU,KAAM,GAAI;AAC1C,yBAAoB,MAAM,IAAK;AAC/B;AAAA,IACD;AACA,uBAAoB,IAAK;AAAA,EAC1B;AAEA,QAAM,cAAc,KAAK,OAAO,MAAM,uBAAwB,IAAK;AACnE,QAAM,aAAa,MAAM;AAEzB,SACC,oBAAC,SAAI,WAAU,iCACd,+BAAC,QAAK,SAAQ,cAAa,OAAM,UAAS,KAAI,QAC7C;AAAA;AAAA,MAAC;AAAA;AAAA,QACA,SAAU;AAAA,QACV,UAAW;AAAA,QACX,yBAAuB;AAAA,QACvB,IAAK;AAAA;AAAA,IACN;AAAA,IACA,oBAAC,WAAM,SAAU,YAChB;AAAA,MAAC;AAAA;AAAA,QACA,MAAO;AAAA,QACP,MAAO;AAAA,QACP,SAAU;AAAA;AAAA,IACX,GACD;AAAA,KACD,GACD;AAEF;AAEA,IAAO,+BAAQ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import apiFetch from "@wordpress/api-fetch";
|
|
2
|
+
const FONT_FAMILIES_URL = "/wp/v2/font-families";
|
|
3
|
+
const FONT_COLLECTIONS_URL = "/wp/v2/font-collections";
|
|
4
|
+
async function fetchInstallFontFamily(data) {
|
|
5
|
+
const config = {
|
|
6
|
+
path: FONT_FAMILIES_URL,
|
|
7
|
+
method: "POST",
|
|
8
|
+
body: data
|
|
9
|
+
};
|
|
10
|
+
const response = await apiFetch(config);
|
|
11
|
+
return {
|
|
12
|
+
id: response.id,
|
|
13
|
+
...response.font_family_settings,
|
|
14
|
+
fontFace: []
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
async function fetchInstallFontFace(fontFamilyId, data) {
|
|
18
|
+
const config = {
|
|
19
|
+
path: `${FONT_FAMILIES_URL}/${fontFamilyId}/font-faces`,
|
|
20
|
+
method: "POST",
|
|
21
|
+
body: data
|
|
22
|
+
};
|
|
23
|
+
const response = await apiFetch(config);
|
|
24
|
+
return {
|
|
25
|
+
id: response.id,
|
|
26
|
+
...response.font_face_settings
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
async function fetchGetFontFamilyBySlug(slug) {
|
|
30
|
+
const config = {
|
|
31
|
+
path: `${FONT_FAMILIES_URL}?slug=${slug}&_embed=true`,
|
|
32
|
+
method: "GET"
|
|
33
|
+
};
|
|
34
|
+
const response = await apiFetch(config);
|
|
35
|
+
if (!response || response.length === 0) {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
const fontFamilyPost = response[0];
|
|
39
|
+
return {
|
|
40
|
+
id: fontFamilyPost.id,
|
|
41
|
+
...fontFamilyPost.font_family_settings,
|
|
42
|
+
fontFace: (fontFamilyPost?._embedded?.font_faces ?? []).map(
|
|
43
|
+
(face) => face.font_face_settings
|
|
44
|
+
) || []
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
async function fetchUninstallFontFamily(fontFamilyId) {
|
|
48
|
+
const config = {
|
|
49
|
+
path: `${FONT_FAMILIES_URL}/${fontFamilyId}?force=true`,
|
|
50
|
+
method: "DELETE"
|
|
51
|
+
};
|
|
52
|
+
return await apiFetch(config);
|
|
53
|
+
}
|
|
54
|
+
async function fetchFontCollections() {
|
|
55
|
+
const config = {
|
|
56
|
+
path: `${FONT_COLLECTIONS_URL}?_fields=slug,name,description`,
|
|
57
|
+
method: "GET"
|
|
58
|
+
};
|
|
59
|
+
return await apiFetch(config);
|
|
60
|
+
}
|
|
61
|
+
async function fetchFontCollection(id) {
|
|
62
|
+
const config = {
|
|
63
|
+
path: `${FONT_COLLECTIONS_URL}/${id}`,
|
|
64
|
+
method: "GET"
|
|
65
|
+
};
|
|
66
|
+
return await apiFetch(config);
|
|
67
|
+
}
|
|
68
|
+
export {
|
|
69
|
+
fetchFontCollection,
|
|
70
|
+
fetchFontCollections,
|
|
71
|
+
fetchGetFontFamilyBySlug,
|
|
72
|
+
fetchInstallFontFace,
|
|
73
|
+
fetchInstallFontFamily,
|
|
74
|
+
fetchUninstallFontFamily
|
|
75
|
+
};
|
|
76
|
+
//# sourceMappingURL=resolvers.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/font-library-modal/resolvers.tsx"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\n// The font library modal is pre-existent in Gutenberg\n// It needs to be refactored to move all the API calls to core-data.\n// eslint-disable-next-line no-restricted-imports\nimport apiFetch from '@wordpress/api-fetch';\n\n/**\n * Internal dependencies\n */\nimport type {\n\tCollectionFontFace,\n\tCollectionFontFamily,\n\tFontCollection,\n\tFontFace,\n} from './types';\n\nconst FONT_FAMILIES_URL = '/wp/v2/font-families';\nconst FONT_COLLECTIONS_URL = '/wp/v2/font-collections';\n\nexport async function fetchInstallFontFamily( data: FormData ) {\n\tconst config = {\n\t\tpath: FONT_FAMILIES_URL,\n\t\tmethod: 'POST',\n\t\tbody: data,\n\t};\n\tconst response: CollectionFontFamily = await apiFetch( config );\n\treturn {\n\t\tid: response.id as string,\n\t\t...response.font_family_settings,\n\t\tfontFace: [],\n\t};\n}\n\nexport async function fetchInstallFontFace(\n\tfontFamilyId: string,\n\tdata: FormData\n): Promise< FontFace > {\n\tconst config = {\n\t\tpath: `${ FONT_FAMILIES_URL }/${ fontFamilyId }/font-faces`,\n\t\tmethod: 'POST',\n\t\tbody: data,\n\t};\n\tconst response = ( await apiFetch( config ) ) as CollectionFontFace;\n\treturn {\n\t\tid: response.id,\n\t\t...response.font_face_settings,\n\t};\n}\n\nexport async function fetchGetFontFamilyBySlug( slug: string ) {\n\tconst config = {\n\t\tpath: `${ FONT_FAMILIES_URL }?slug=${ slug }&_embed=true`,\n\t\tmethod: 'GET',\n\t};\n\tconst response = ( await apiFetch( config ) ) as\n\t\t| CollectionFontFamily[]\n\t\t| undefined;\n\tif ( ! response || response.length === 0 ) {\n\t\treturn null;\n\t}\n\tconst fontFamilyPost = response[ 0 ];\n\treturn {\n\t\tid: fontFamilyPost.id,\n\t\t...fontFamilyPost.font_family_settings,\n\t\tfontFace:\n\t\t\t( fontFamilyPost?._embedded?.font_faces ?? [] ).map(\n\t\t\t\t( face ) => face.font_face_settings\n\t\t\t) || [],\n\t};\n}\n\nexport async function fetchUninstallFontFamily(\n\tfontFamilyId: string\n): Promise< {\n\tdeleted: boolean;\n} > {\n\tconst config = {\n\t\tpath: `${ FONT_FAMILIES_URL }/${ fontFamilyId }?force=true`,\n\t\tmethod: 'DELETE',\n\t};\n\treturn await apiFetch( config );\n}\n\nexport async function fetchFontCollections() {\n\tconst config = {\n\t\tpath: `${ FONT_COLLECTIONS_URL }?_fields=slug,name,description`,\n\t\tmethod: 'GET',\n\t};\n\treturn ( await apiFetch( config ) ) as FontCollection[];\n}\n\nexport async function fetchFontCollection( id: string ) {\n\tconst config = {\n\t\tpath: `${ FONT_COLLECTIONS_URL }/${ id }`,\n\t\tmethod: 'GET',\n\t};\n\treturn ( await apiFetch( config ) ) as FontCollection;\n}\n"],
|
|
5
|
+
"mappings": "AAMA,OAAO,cAAc;AAYrB,MAAM,oBAAoB;AAC1B,MAAM,uBAAuB;AAE7B,eAAsB,uBAAwB,MAAiB;AAC9D,QAAM,SAAS;AAAA,IACd,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,MAAM;AAAA,EACP;AACA,QAAM,WAAiC,MAAM,SAAU,MAAO;AAC9D,SAAO;AAAA,IACN,IAAI,SAAS;AAAA,IACb,GAAG,SAAS;AAAA,IACZ,UAAU,CAAC;AAAA,EACZ;AACD;AAEA,eAAsB,qBACrB,cACA,MACsB;AACtB,QAAM,SAAS;AAAA,IACd,MAAM,GAAI,iBAAkB,IAAK,YAAa;AAAA,IAC9C,QAAQ;AAAA,IACR,MAAM;AAAA,EACP;AACA,QAAM,WAAa,MAAM,SAAU,MAAO;AAC1C,SAAO;AAAA,IACN,IAAI,SAAS;AAAA,IACb,GAAG,SAAS;AAAA,EACb;AACD;AAEA,eAAsB,yBAA0B,MAAe;AAC9D,QAAM,SAAS;AAAA,IACd,MAAM,GAAI,iBAAkB,SAAU,IAAK;AAAA,IAC3C,QAAQ;AAAA,EACT;AACA,QAAM,WAAa,MAAM,SAAU,MAAO;AAG1C,MAAK,CAAE,YAAY,SAAS,WAAW,GAAI;AAC1C,WAAO;AAAA,EACR;AACA,QAAM,iBAAiB,SAAU,CAAE;AACnC,SAAO;AAAA,IACN,IAAI,eAAe;AAAA,IACnB,GAAG,eAAe;AAAA,IAClB,WACG,gBAAgB,WAAW,cAAc,CAAC,GAAI;AAAA,MAC/C,CAAE,SAAU,KAAK;AAAA,IAClB,KAAK,CAAC;AAAA,EACR;AACD;AAEA,eAAsB,yBACrB,cAGG;AACH,QAAM,SAAS;AAAA,IACd,MAAM,GAAI,iBAAkB,IAAK,YAAa;AAAA,IAC9C,QAAQ;AAAA,EACT;AACA,SAAO,MAAM,SAAU,MAAO;AAC/B;AAEA,eAAsB,uBAAuB;AAC5C,QAAM,SAAS;AAAA,IACd,MAAM,GAAI,oBAAqB;AAAA,IAC/B,QAAQ;AAAA,EACT;AACA,SAAS,MAAM,SAAU,MAAO;AACjC;AAEA,eAAsB,oBAAqB,IAAa;AACvD,QAAM,SAAS;AAAA,IACd,MAAM,GAAI,oBAAqB,IAAK,EAAG;AAAA,IACvC,QAAQ;AAAA,EACT;AACA,SAAS,MAAM,SAAU,MAAO;AACjC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { __ } from "@wordpress/i18n";
|
|
3
|
+
import {
|
|
4
|
+
__experimentalSpacer as Spacer,
|
|
5
|
+
__experimentalText as Text,
|
|
6
|
+
__experimentalVStack as VStack,
|
|
7
|
+
Button,
|
|
8
|
+
DropZone,
|
|
9
|
+
Notice,
|
|
10
|
+
FormFileUpload,
|
|
11
|
+
FlexItem,
|
|
12
|
+
ProgressBar
|
|
13
|
+
} from "@wordpress/components";
|
|
14
|
+
import { useContext, useState } from "@wordpress/element";
|
|
15
|
+
import { ALLOWED_FILE_EXTENSIONS } from "./utils/constants";
|
|
16
|
+
import { FontLibraryContext } from "./context";
|
|
17
|
+
import { Font } from "./lib/lib-font.browser";
|
|
18
|
+
import makeFamiliesFromFaces from "./utils/make-families-from-faces";
|
|
19
|
+
import { loadFontFaceInBrowser } from "./utils";
|
|
20
|
+
function UploadFonts() {
|
|
21
|
+
const { installFonts } = useContext(FontLibraryContext);
|
|
22
|
+
const [isUploading, setIsUploading] = useState(false);
|
|
23
|
+
const [notice, setNotice] = useState(null);
|
|
24
|
+
const handleDropZone = (files) => {
|
|
25
|
+
handleFilesUpload(files);
|
|
26
|
+
};
|
|
27
|
+
const onFilesUpload = (event) => {
|
|
28
|
+
handleFilesUpload(event.target.files);
|
|
29
|
+
};
|
|
30
|
+
const handleFilesUpload = async (files) => {
|
|
31
|
+
if (!files) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
setNotice(null);
|
|
35
|
+
setIsUploading(true);
|
|
36
|
+
const uniqueFilenames = /* @__PURE__ */ new Set();
|
|
37
|
+
const selectedFiles = [...files];
|
|
38
|
+
let hasInvalidFiles = false;
|
|
39
|
+
const checkFilesPromises = selectedFiles.map(async (file) => {
|
|
40
|
+
const isFont = await isFontFile(file);
|
|
41
|
+
if (!isFont) {
|
|
42
|
+
hasInvalidFiles = true;
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
if (uniqueFilenames.has(file.name)) {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
const fileExtension = (((file.name ?? "").split(".") ?? []).pop() ?? "").toLowerCase();
|
|
49
|
+
if (ALLOWED_FILE_EXTENSIONS.includes(fileExtension)) {
|
|
50
|
+
uniqueFilenames.add(file.name);
|
|
51
|
+
return file;
|
|
52
|
+
}
|
|
53
|
+
return null;
|
|
54
|
+
});
|
|
55
|
+
const allowedFiles = (await Promise.all(checkFilesPromises)).filter((file) => null !== file);
|
|
56
|
+
if (allowedFiles.length > 0) {
|
|
57
|
+
loadFiles(allowedFiles);
|
|
58
|
+
} else {
|
|
59
|
+
const message = hasInvalidFiles ? __("Sorry, you are not allowed to upload this file type.") : __("No fonts found to install.");
|
|
60
|
+
setNotice({
|
|
61
|
+
type: "error",
|
|
62
|
+
message
|
|
63
|
+
});
|
|
64
|
+
setIsUploading(false);
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
const loadFiles = async (files) => {
|
|
68
|
+
const fontFacesLoaded = await Promise.all(
|
|
69
|
+
files.map(async (fontFile) => {
|
|
70
|
+
const fontFaceData = await getFontFaceMetadata(fontFile);
|
|
71
|
+
await loadFontFaceInBrowser(
|
|
72
|
+
fontFaceData,
|
|
73
|
+
fontFaceData.file,
|
|
74
|
+
"all"
|
|
75
|
+
);
|
|
76
|
+
return fontFaceData;
|
|
77
|
+
})
|
|
78
|
+
);
|
|
79
|
+
handleInstall(fontFacesLoaded);
|
|
80
|
+
};
|
|
81
|
+
async function isFontFile(file) {
|
|
82
|
+
const font = new Font("Uploaded Font");
|
|
83
|
+
try {
|
|
84
|
+
const buffer = await readFileAsArrayBuffer(file);
|
|
85
|
+
await font.fromDataBuffer(buffer, "font");
|
|
86
|
+
return true;
|
|
87
|
+
} catch (error) {
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
async function readFileAsArrayBuffer(file) {
|
|
92
|
+
return new Promise((resolve, reject) => {
|
|
93
|
+
const reader = new window.FileReader();
|
|
94
|
+
reader.readAsArrayBuffer(file);
|
|
95
|
+
reader.onload = () => resolve(reader.result);
|
|
96
|
+
reader.onerror = reject;
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
const getFontFaceMetadata = async (fontFile) => {
|
|
100
|
+
const buffer = await readFileAsArrayBuffer(fontFile);
|
|
101
|
+
const fontObj = new Font("Uploaded Font");
|
|
102
|
+
fontObj.fromDataBuffer(buffer, fontFile.name);
|
|
103
|
+
const onloadEvent = await new Promise(
|
|
104
|
+
(resolve) => fontObj.onload = resolve
|
|
105
|
+
);
|
|
106
|
+
const font = onloadEvent.detail.font;
|
|
107
|
+
const { name } = font.opentype.tables;
|
|
108
|
+
const fontName = name.get(16) || name.get(1);
|
|
109
|
+
const isItalic = name.get(2).toLowerCase().includes("italic");
|
|
110
|
+
const fontWeight = font.opentype.tables["OS/2"].usWeightClass || "normal";
|
|
111
|
+
const isVariable = !!font.opentype.tables.fvar;
|
|
112
|
+
const weightAxis = isVariable && font.opentype.tables.fvar.axes.find(
|
|
113
|
+
({ tag }) => tag === "wght"
|
|
114
|
+
);
|
|
115
|
+
const weightRange = weightAxis ? `${weightAxis.minValue} ${weightAxis.maxValue}` : null;
|
|
116
|
+
return {
|
|
117
|
+
file: fontFile,
|
|
118
|
+
fontFamily: fontName,
|
|
119
|
+
fontStyle: isItalic ? "italic" : "normal",
|
|
120
|
+
fontWeight: weightRange || fontWeight
|
|
121
|
+
};
|
|
122
|
+
};
|
|
123
|
+
const handleInstall = async (fontFaces) => {
|
|
124
|
+
const fontFamilies = makeFamiliesFromFaces(fontFaces);
|
|
125
|
+
try {
|
|
126
|
+
await installFonts(fontFamilies);
|
|
127
|
+
setNotice({
|
|
128
|
+
type: "success",
|
|
129
|
+
message: __("Fonts were installed successfully.")
|
|
130
|
+
});
|
|
131
|
+
} catch (error) {
|
|
132
|
+
const typedError = error;
|
|
133
|
+
setNotice({
|
|
134
|
+
type: "error",
|
|
135
|
+
message: typedError.message,
|
|
136
|
+
errors: typedError?.installationErrors
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
setIsUploading(false);
|
|
140
|
+
};
|
|
141
|
+
return /* @__PURE__ */ jsxs("div", { className: "font-library-modal__tabpanel-layout", children: [
|
|
142
|
+
/* @__PURE__ */ jsx(DropZone, { onFilesDrop: handleDropZone }),
|
|
143
|
+
/* @__PURE__ */ jsxs(VStack, { className: "font-library-modal__local-fonts", children: [
|
|
144
|
+
notice && /* @__PURE__ */ jsxs(
|
|
145
|
+
Notice,
|
|
146
|
+
{
|
|
147
|
+
status: notice.type,
|
|
148
|
+
__unstableHTML: true,
|
|
149
|
+
onRemove: () => setNotice(null),
|
|
150
|
+
children: [
|
|
151
|
+
notice.message,
|
|
152
|
+
notice.errors && /* @__PURE__ */ jsx("ul", { children: notice.errors.map((error, index) => /* @__PURE__ */ jsx("li", { children: error }, index)) })
|
|
153
|
+
]
|
|
154
|
+
}
|
|
155
|
+
),
|
|
156
|
+
isUploading && /* @__PURE__ */ jsx(FlexItem, { children: /* @__PURE__ */ jsx("div", { className: "font-library-modal__upload-area", children: /* @__PURE__ */ jsx(ProgressBar, {}) }) }),
|
|
157
|
+
!isUploading && /* @__PURE__ */ jsx(
|
|
158
|
+
FormFileUpload,
|
|
159
|
+
{
|
|
160
|
+
accept: ALLOWED_FILE_EXTENSIONS.map(
|
|
161
|
+
(ext) => `.${ext}`
|
|
162
|
+
).join(","),
|
|
163
|
+
multiple: true,
|
|
164
|
+
onChange: onFilesUpload,
|
|
165
|
+
render: ({ openFileDialog }) => /* @__PURE__ */ jsx(
|
|
166
|
+
Button,
|
|
167
|
+
{
|
|
168
|
+
__next40pxDefaultSize: true,
|
|
169
|
+
className: "font-library-modal__upload-area",
|
|
170
|
+
onClick: openFileDialog,
|
|
171
|
+
children: __("Upload font")
|
|
172
|
+
}
|
|
173
|
+
)
|
|
174
|
+
}
|
|
175
|
+
),
|
|
176
|
+
/* @__PURE__ */ jsx(Spacer, { margin: 2 }),
|
|
177
|
+
/* @__PURE__ */ jsx(Text, { className: "font-library-modal__upload-area__text", children: __(
|
|
178
|
+
"Uploaded fonts appear in your library and can be used in your theme. Supported formats: .ttf, .otf, .woff, and .woff2."
|
|
179
|
+
) })
|
|
180
|
+
] })
|
|
181
|
+
] });
|
|
182
|
+
}
|
|
183
|
+
var upload_fonts_default = UploadFonts;
|
|
184
|
+
export {
|
|
185
|
+
upload_fonts_default as default
|
|
186
|
+
};
|
|
187
|
+
//# sourceMappingURL=upload-fonts.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/font-library-modal/upload-fonts.tsx"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\t__experimentalSpacer as Spacer,\n\t__experimentalText as Text,\n\t__experimentalVStack as VStack,\n\tButton,\n\tDropZone,\n\tNotice,\n\tFormFileUpload,\n\tFlexItem,\n\tProgressBar,\n} from '@wordpress/components';\nimport { useContext, useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { ALLOWED_FILE_EXTENSIONS } from './utils/constants';\nimport { FontLibraryContext } from './context';\nimport { Font } from './lib/lib-font.browser';\nimport makeFamiliesFromFaces from './utils/make-families-from-faces';\nimport { loadFontFaceInBrowser } from './utils';\nimport type { FontFace } from './types';\n\nfunction UploadFonts() {\n\tconst { installFonts } = useContext( FontLibraryContext );\n\tconst [ isUploading, setIsUploading ] = useState( false );\n\tconst [ notice, setNotice ] = useState< {\n\t\ttype: 'success' | 'error';\n\t\tmessage: string;\n\t\terrors?: string[];\n\t} | null >( null );\n\n\tconst handleDropZone = ( files: File[] ) => {\n\t\thandleFilesUpload( files );\n\t};\n\tconst onFilesUpload = ( event: React.ChangeEvent< HTMLInputElement > ) => {\n\t\thandleFilesUpload( event.target.files );\n\t};\n\n\t/**\n\t * Filters the selected files to only allow the ones with the allowed extensions\n\t *\n\t * @param {Array} files The files to be filtered\n\t * @return {void}\n\t */\n\tconst handleFilesUpload = async ( files: FileList | File[] | null ) => {\n\t\tif ( ! files ) {\n\t\t\treturn;\n\t\t}\n\t\tsetNotice( null );\n\t\tsetIsUploading( true );\n\t\tconst uniqueFilenames = new Set();\n\t\tconst selectedFiles = [ ...files ];\n\t\tlet hasInvalidFiles = false;\n\n\t\t// Use map to create a promise for each file check, then filter with Promise.all.\n\t\tconst checkFilesPromises = selectedFiles.map( async ( file ) => {\n\t\t\tconst isFont = await isFontFile( file );\n\t\t\tif ( ! isFont ) {\n\t\t\t\thasInvalidFiles = true;\n\t\t\t\treturn null; // Return null for invalid files.\n\t\t\t}\n\t\t\t// Check for duplicates\n\t\t\tif ( uniqueFilenames.has( file.name ) ) {\n\t\t\t\treturn null; // Return null for duplicates.\n\t\t\t}\n\t\t\t// Check if the file extension is allowed.\n\t\t\tconst fileExtension = (\n\t\t\t\t( ( file.name ?? '' ).split( '.' ) ?? [] ).pop() ?? ''\n\t\t\t).toLowerCase();\n\t\t\tif ( ALLOWED_FILE_EXTENSIONS.includes( fileExtension ) ) {\n\t\t\t\tuniqueFilenames.add( file.name );\n\t\t\t\treturn file; // Return the file if it passes all checks.\n\t\t\t}\n\t\t\treturn null; // Return null for disallowed file extensions.\n\t\t} );\n\n\t\t// Filter out the nulls after all promises have resolved.\n\t\tconst allowedFiles: File[] = (\n\t\t\tawait Promise.all( checkFilesPromises )\n\t\t).filter( ( file ) => null !== file );\n\n\t\tif ( allowedFiles.length > 0 ) {\n\t\t\tloadFiles( allowedFiles );\n\t\t} else {\n\t\t\tconst message = hasInvalidFiles\n\t\t\t\t? __( 'Sorry, you are not allowed to upload this file type.' )\n\t\t\t\t: __( 'No fonts found to install.' );\n\n\t\t\tsetNotice( {\n\t\t\t\ttype: 'error',\n\t\t\t\tmessage,\n\t\t\t} );\n\t\t\tsetIsUploading( false );\n\t\t}\n\t};\n\n\t/**\n\t * Loads the selected files and reads the font metadata\n\t *\n\t * @param {Array} files The files to be loaded\n\t * @return {void}\n\t */\n\tconst loadFiles = async ( files: File[] ) => {\n\t\tconst fontFacesLoaded = await Promise.all(\n\t\t\tfiles.map( async ( fontFile: File ) => {\n\t\t\t\tconst fontFaceData = await getFontFaceMetadata( fontFile );\n\t\t\t\tawait loadFontFaceInBrowser(\n\t\t\t\t\tfontFaceData,\n\t\t\t\t\tfontFaceData.file,\n\t\t\t\t\t'all'\n\t\t\t\t);\n\t\t\t\treturn fontFaceData;\n\t\t\t} )\n\t\t);\n\t\thandleInstall( fontFacesLoaded );\n\t};\n\n\t/**\n\t * Checks if a file is a valid Font file.\n\t *\n\t * @param {File} file The file to be checked.\n\t * @return {boolean} Whether the file is a valid font file.\n\t */\n\tasync function isFontFile( file: File ) {\n\t\tconst font = new Font( 'Uploaded Font' );\n\t\ttry {\n\t\t\tconst buffer = await readFileAsArrayBuffer( file );\n\t\t\tawait font.fromDataBuffer( buffer, 'font' );\n\t\t\treturn true;\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unused-vars\n\t\t} catch ( error ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\t// Create a function to read the file as array buffer\n\tasync function readFileAsArrayBuffer( file: File ) {\n\t\treturn new Promise( ( resolve, reject ) => {\n\t\t\tconst reader = new window.FileReader();\n\t\t\treader.readAsArrayBuffer( file );\n\t\t\treader.onload = () => resolve( reader.result );\n\t\t\treader.onerror = reject;\n\t\t} );\n\t}\n\n\tconst getFontFaceMetadata = async ( fontFile: File ) => {\n\t\tconst buffer = await readFileAsArrayBuffer( fontFile );\n\t\tconst fontObj: Font & {\n\t\t\tonload?: ( val: { detail: { font: any } } ) => void;\n\t\t} = new Font( 'Uploaded Font' );\n\t\tfontObj.fromDataBuffer( buffer, fontFile.name );\n\t\t// Assuming that fromDataBuffer triggers onload event and returning a Promise\n\t\tconst onloadEvent: { detail: { font: any } } = await new Promise(\n\t\t\t( resolve ) => ( fontObj.onload = resolve )\n\t\t);\n\t\tconst font = onloadEvent.detail.font;\n\t\tconst { name } = font.opentype.tables;\n\t\tconst fontName = name.get( 16 ) || name.get( 1 );\n\t\tconst isItalic = name.get( 2 ).toLowerCase().includes( 'italic' );\n\t\tconst fontWeight =\n\t\t\tfont.opentype.tables[ 'OS/2' ].usWeightClass || 'normal';\n\t\tconst isVariable = !! font.opentype.tables.fvar;\n\t\tconst weightAxis =\n\t\t\tisVariable &&\n\t\t\tfont.opentype.tables.fvar.axes.find(\n\t\t\t\t( { tag }: { tag: string } ) => tag === 'wght'\n\t\t\t);\n\t\tconst weightRange = weightAxis\n\t\t\t? `${ weightAxis.minValue } ${ weightAxis.maxValue }`\n\t\t\t: null;\n\t\treturn {\n\t\t\tfile: fontFile,\n\t\t\tfontFamily: fontName,\n\t\t\tfontStyle: isItalic ? 'italic' : 'normal',\n\t\t\tfontWeight: weightRange || fontWeight,\n\t\t};\n\t};\n\n\t/**\n\t * Creates the font family definition and sends it to the server\n\t *\n\t * @param {Array} fontFaces The font faces to be installed\n\t * @return {void}\n\t */\n\tconst handleInstall = async ( fontFaces: FontFace[] ) => {\n\t\tconst fontFamilies = makeFamiliesFromFaces( fontFaces );\n\n\t\ttry {\n\t\t\tawait installFonts( fontFamilies );\n\t\t\tsetNotice( {\n\t\t\t\ttype: 'success',\n\t\t\t\tmessage: __( 'Fonts were installed successfully.' ),\n\t\t\t} );\n\t\t} catch ( error ) {\n\t\t\tconst typedError = error as Error & {\n\t\t\t\tinstallationErrors?: string[];\n\t\t\t};\n\t\t\tsetNotice( {\n\t\t\t\ttype: 'error',\n\t\t\t\tmessage: typedError.message,\n\t\t\t\terrors: typedError?.installationErrors,\n\t\t\t} );\n\t\t}\n\n\t\tsetIsUploading( false );\n\t};\n\n\treturn (\n\t\t<div className=\"font-library-modal__tabpanel-layout\">\n\t\t\t<DropZone onFilesDrop={ handleDropZone } />\n\t\t\t<VStack className=\"font-library-modal__local-fonts\">\n\t\t\t\t{ notice && (\n\t\t\t\t\t<Notice\n\t\t\t\t\t\tstatus={ notice.type }\n\t\t\t\t\t\t__unstableHTML\n\t\t\t\t\t\tonRemove={ () => setNotice( null ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ notice.message }\n\t\t\t\t\t\t{ notice.errors && (\n\t\t\t\t\t\t\t<ul>\n\t\t\t\t\t\t\t\t{ notice.errors.map( ( error, index ) => (\n\t\t\t\t\t\t\t\t\t<li key={ index }>{ error }</li>\n\t\t\t\t\t\t\t\t) ) }\n\t\t\t\t\t\t\t</ul>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</Notice>\n\t\t\t\t) }\n\t\t\t\t{ isUploading && (\n\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t<div className=\"font-library-modal__upload-area\">\n\t\t\t\t\t\t\t<ProgressBar />\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</FlexItem>\n\t\t\t\t) }\n\t\t\t\t{ ! isUploading && (\n\t\t\t\t\t<FormFileUpload\n\t\t\t\t\t\taccept={ ALLOWED_FILE_EXTENSIONS.map(\n\t\t\t\t\t\t\t( ext ) => `.${ ext }`\n\t\t\t\t\t\t).join( ',' ) }\n\t\t\t\t\t\tmultiple\n\t\t\t\t\t\tonChange={ onFilesUpload }\n\t\t\t\t\t\trender={ ( { openFileDialog } ) => (\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t\tclassName=\"font-library-modal__upload-area\"\n\t\t\t\t\t\t\t\tonClick={ openFileDialog }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ __( 'Upload font' ) }\n\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t) }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t<Spacer margin={ 2 } />\n\t\t\t\t<Text className=\"font-library-modal__upload-area__text\">\n\t\t\t\t\t{ __(\n\t\t\t\t\t\t'Uploaded fonts appear in your library and can be used in your theme. Supported formats: .ttf, .otf, .woff, and .woff2.'\n\t\t\t\t\t) }\n\t\t\t\t</Text>\n\t\t\t</VStack>\n\t\t</div>\n\t);\n}\n\nexport default UploadFonts;\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { _x } from "@wordpress/i18n";
|
|
2
|
+
const ALLOWED_FILE_EXTENSIONS = ["otf", "ttf", "woff", "woff2"];
|
|
3
|
+
const FONT_WEIGHTS = {
|
|
4
|
+
100: _x("Thin", "font weight"),
|
|
5
|
+
200: _x("Extra-light", "font weight"),
|
|
6
|
+
300: _x("Light", "font weight"),
|
|
7
|
+
400: _x("Normal", "font weight"),
|
|
8
|
+
500: _x("Medium", "font weight"),
|
|
9
|
+
600: _x("Semi-bold", "font weight"),
|
|
10
|
+
700: _x("Bold", "font weight"),
|
|
11
|
+
800: _x("Extra-bold", "font weight"),
|
|
12
|
+
900: _x("Black", "font weight")
|
|
13
|
+
};
|
|
14
|
+
const FONT_STYLES = {
|
|
15
|
+
normal: _x("Normal", "font style"),
|
|
16
|
+
italic: _x("Italic", "font style")
|
|
17
|
+
};
|
|
18
|
+
export {
|
|
19
|
+
ALLOWED_FILE_EXTENSIONS,
|
|
20
|
+
FONT_STYLES,
|
|
21
|
+
FONT_WEIGHTS
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/font-library-modal/utils/constants.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { _x } from '@wordpress/i18n';\n\nexport const ALLOWED_FILE_EXTENSIONS = [ 'otf', 'ttf', 'woff', 'woff2' ];\n\nexport const FONT_WEIGHTS: Record< string, string > = {\n\t100: _x( 'Thin', 'font weight' ),\n\t200: _x( 'Extra-light', 'font weight' ),\n\t300: _x( 'Light', 'font weight' ),\n\t400: _x( 'Normal', 'font weight' ),\n\t500: _x( 'Medium', 'font weight' ),\n\t600: _x( 'Semi-bold', 'font weight' ),\n\t700: _x( 'Bold', 'font weight' ),\n\t800: _x( 'Extra-bold', 'font weight' ),\n\t900: _x( 'Black', 'font weight' ),\n};\n\nexport const FONT_STYLES: Record< string, string > = {\n\tnormal: _x( 'Normal', 'font style' ),\n\titalic: _x( 'Italic', 'font style' ),\n};\n"],
|
|
5
|
+
"mappings": "AAGA,SAAS,UAAU;AAEZ,MAAM,0BAA0B,CAAE,OAAO,OAAO,QAAQ,OAAQ;AAEhE,MAAM,eAAyC;AAAA,EACrD,KAAK,GAAI,QAAQ,aAAc;AAAA,EAC/B,KAAK,GAAI,eAAe,aAAc;AAAA,EACtC,KAAK,GAAI,SAAS,aAAc;AAAA,EAChC,KAAK,GAAI,UAAU,aAAc;AAAA,EACjC,KAAK,GAAI,UAAU,aAAc;AAAA,EACjC,KAAK,GAAI,aAAa,aAAc;AAAA,EACpC,KAAK,GAAI,QAAQ,aAAc;AAAA,EAC/B,KAAK,GAAI,cAAc,aAAc;AAAA,EACrC,KAAK,GAAI,SAAS,aAAc;AACjC;AAEO,MAAM,cAAwC;AAAA,EACpD,QAAQ,GAAI,UAAU,YAAa;AAAA,EACnC,QAAQ,GAAI,UAAU,YAAa;AACpC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
function filterFonts(fonts, filters) {
|
|
2
|
+
const { category, search } = filters;
|
|
3
|
+
let filteredFonts = fonts || [];
|
|
4
|
+
if (category && category !== "all") {
|
|
5
|
+
filteredFonts = filteredFonts.filter(
|
|
6
|
+
(font) => font.categories && font.categories.indexOf(category) !== -1
|
|
7
|
+
);
|
|
8
|
+
}
|
|
9
|
+
if (search) {
|
|
10
|
+
filteredFonts = filteredFonts.filter(
|
|
11
|
+
(font) => font.font_family_settings && font.font_family_settings.name.toLowerCase().includes(search.toLowerCase())
|
|
12
|
+
);
|
|
13
|
+
}
|
|
14
|
+
return filteredFonts;
|
|
15
|
+
}
|
|
16
|
+
export {
|
|
17
|
+
filterFonts as default
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=filter-fonts.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/font-library-modal/utils/filter-fonts.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Internal dependencies\n */\nimport type { CollectionFontFamily } from '../types';\n\n/**\n * Filters a list of fonts based on the specified filters.\n *\n * This function filters a given array of fonts based on the criteria provided in the filters object.\n * It supports filtering by category and a search term. If the category is provided and not equal to 'all',\n * the function filters the fonts array to include only those fonts that belong to the specified category.\n * Additionally, if a search term is provided, it filters the fonts array to include only those fonts\n * whose name includes the search term, case-insensitively.\n *\n * @param fonts Array of font objects in font-collection schema fashion to be filtered. Each font object should have a 'categories' property and a 'font_family_settings' property with a 'name' key.\n * @param filters Object containing the filter criteria. It should have a 'category' key and/or a 'search' key.\n * @param filters.category The category to filter fonts by. If 'all', no category filtering is applied.\n * @param filters.search The search term to filter fonts by. If provided, only fonts whose\n *\n * @return Array of filtered font objects based on the provided criteria.\n */\nexport default function filterFonts(\n\tfonts: CollectionFontFamily[],\n\tfilters: { category?: string; search?: string }\n): CollectionFontFamily[] {\n\tconst { category, search } = filters;\n\tlet filteredFonts = fonts || [];\n\n\tif ( category && category !== 'all' ) {\n\t\tfilteredFonts = filteredFonts.filter(\n\t\t\t( font ) =>\n\t\t\t\tfont.categories && font.categories.indexOf( category ) !== -1\n\t\t);\n\t}\n\n\tif ( search ) {\n\t\tfilteredFonts = filteredFonts.filter(\n\t\t\t( font ) =>\n\t\t\t\tfont.font_family_settings &&\n\t\t\t\tfont.font_family_settings.name\n\t\t\t\t\t.toLowerCase()\n\t\t\t\t\t.includes( search.toLowerCase() )\n\t\t);\n\t}\n\n\treturn filteredFonts;\n}\n"],
|
|
5
|
+
"mappings": "AAqBe,SAAR,YACN,OACA,SACyB;AACzB,QAAM,EAAE,UAAU,OAAO,IAAI;AAC7B,MAAI,gBAAgB,SAAS,CAAC;AAE9B,MAAK,YAAY,aAAa,OAAQ;AACrC,oBAAgB,cAAc;AAAA,MAC7B,CAAE,SACD,KAAK,cAAc,KAAK,WAAW,QAAS,QAAS,MAAM;AAAA,IAC7D;AAAA,EACD;AAEA,MAAK,QAAS;AACb,oBAAgB,cAAc;AAAA,MAC7B,CAAE,SACD,KAAK,wBACL,KAAK,qBAAqB,KACxB,YAAY,EACZ,SAAU,OAAO,YAAY,CAAE;AAAA,IACnC;AAAA,EACD;AAEA,SAAO;AACR;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
function getFontsOutline(fonts) {
|
|
2
|
+
return fonts.reduce(
|
|
3
|
+
(acc, font) => ({
|
|
4
|
+
...acc,
|
|
5
|
+
[font.slug]: (font?.fontFace || []).reduce(
|
|
6
|
+
(faces, face) => ({
|
|
7
|
+
...faces,
|
|
8
|
+
[`${face.fontStyle}-${face.fontWeight}`]: true
|
|
9
|
+
}),
|
|
10
|
+
{}
|
|
11
|
+
)
|
|
12
|
+
}),
|
|
13
|
+
{}
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
function isFontFontFaceInOutline(slug, face, outline) {
|
|
17
|
+
if (!face) {
|
|
18
|
+
return !!outline[slug];
|
|
19
|
+
}
|
|
20
|
+
return !!outline[slug]?.[`${face.fontStyle}-${face.fontWeight}`];
|
|
21
|
+
}
|
|
22
|
+
export {
|
|
23
|
+
getFontsOutline,
|
|
24
|
+
isFontFontFaceInOutline
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=fonts-outline.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/font-library-modal/utils/fonts-outline.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Internal dependencies\n */\nimport type { FontFace, FontFamily } from '../types';\n\nexport function getFontsOutline(\n\tfonts: FontFamily[]\n): Record< string, Record< string, boolean > > {\n\treturn fonts.reduce(\n\t\t( acc, font ) => ( {\n\t\t\t...acc,\n\t\t\t[ font.slug ]: ( font?.fontFace || [] ).reduce(\n\t\t\t\t( faces, face ) => ( {\n\t\t\t\t\t...faces,\n\t\t\t\t\t[ `${ face.fontStyle }-${ face.fontWeight }` ]: true,\n\t\t\t\t} ),\n\t\t\t\t{}\n\t\t\t),\n\t\t} ),\n\t\t{}\n\t);\n}\n\nexport function isFontFontFaceInOutline(\n\tslug: string,\n\tface: FontFace | null,\n\toutline: Record< string, Record< string, boolean > >\n): boolean {\n\tif ( ! face ) {\n\t\treturn !! outline[ slug ];\n\t}\n\treturn !! outline[ slug ]?.[ `${ face.fontStyle }-${ face.fontWeight }` ];\n}\n"],
|
|
5
|
+
"mappings": "AAKO,SAAS,gBACf,OAC8C;AAC9C,SAAO,MAAM;AAAA,IACZ,CAAE,KAAK,UAAY;AAAA,MAClB,GAAG;AAAA,MACH,CAAE,KAAK,IAAK,IAAK,MAAM,YAAY,CAAC,GAAI;AAAA,QACvC,CAAE,OAAO,UAAY;AAAA,UACpB,GAAG;AAAA,UACH,CAAE,GAAI,KAAK,SAAU,IAAK,KAAK,UAAW,EAAG,GAAG;AAAA,QACjD;AAAA,QACA,CAAC;AAAA,MACF;AAAA,IACD;AAAA,IACA,CAAC;AAAA,EACF;AACD;AAEO,SAAS,wBACf,MACA,MACA,SACU;AACV,MAAK,CAAE,MAAO;AACb,WAAO,CAAC,CAAE,QAAS,IAAK;AAAA,EACzB;AACA,SAAO,CAAC,CAAE,QAAS,IAAK,IAAK,GAAI,KAAK,SAAU,IAAK,KAAK,UAAW,EAAG;AACzE;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|