@atlaskit/tokens 13.0.3 → 13.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/CHANGELOG.md +15 -0
- package/codemods/css-to-design-tokens/lib/meta.tsx +1 -1
- package/codemods/css-to-design-tokens/lib/tokens.tsx +1 -1
- package/codemods/theme-to-design-tokens/transform.tsx +16 -14
- package/codemods/theme-to-design-tokens/utils/ast-meta.tsx +2 -151
- package/codemods/theme-to-design-tokens/utils/ast.tsx +3 -35
- package/codemods/theme-to-design-tokens/utils/clean-meta.tsx +63 -0
- package/codemods/theme-to-design-tokens/utils/color.tsx +3 -11
- package/codemods/theme-to-design-tokens/utils/contains-replaceable-css-declarations.tsx +13 -0
- package/codemods/theme-to-design-tokens/utils/css-utils.tsx +2 -35
- package/codemods/theme-to-design-tokens/utils/find-end-index-of-css-expression.tsx +21 -0
- package/codemods/theme-to-design-tokens/utils/find-first-nonspace-index-after.tsx +9 -0
- package/codemods/theme-to-design-tokens/utils/get-closest-decendant-of-type.tsx +10 -0
- package/codemods/theme-to-design-tokens/utils/get-meta-from-ancestors.tsx +87 -0
- package/codemods/theme-to-design-tokens/utils/is-bold-color.tsx +4 -0
- package/codemods/theme-to-design-tokens/utils/is-decendant-of-token.tsx +14 -0
- package/codemods/theme-to-design-tokens/utils/is-legacy-color.tsx +4 -0
- package/codemods/theme-to-design-tokens/utils/is-legacy-named-color.tsx +4 -0
- package/codemods/theme-to-design-tokens/utils/is-parent-of-token.tsx +13 -0
- package/codemods/theme-to-design-tokens/utils/kebabize.tsx +2 -0
- package/codemods/theme-to-design-tokens/utils/legacy-color-meta-map.tsx +88 -0
- package/codemods/theme-to-design-tokens/utils/legacy-color-mixins.tsx +26 -0
- package/codemods/theme-to-design-tokens/utils/legacy-colors.tsx +2 -115
- package/codemods/theme-to-design-tokens/utils/split-at-index.tsx +3 -0
- package/codemods/theme-to-design-tokens/utils/string-utils.tsx +3 -16
- package/codemods/utils/active-tokens.tsx +284 -0
- package/codemods/utils/tokens.tsx +2 -376
- package/codemods/utils/unique-words-from-tokens.tsx +91 -0
- package/dist/cjs/artifacts/replacement-mapping.js +5 -2
- package/dist/cjs/artifacts/themes/atlassian-dark-increased-contrast.js +2 -2
- package/dist/cjs/artifacts/themes/atlassian-dark.js +2 -2
- package/dist/cjs/artifacts/themes/atlassian-light-increased-contrast.js +2 -2
- package/dist/cjs/artifacts/themes/atlassian-light.js +2 -2
- package/dist/cjs/artifacts/token-default-values.js +2 -2
- package/dist/cjs/artifacts/tokens-raw/atlassian-dark-increased-contrast.js +3 -3
- package/dist/cjs/artifacts/tokens-raw/atlassian-dark.js +3 -3
- package/dist/cjs/artifacts/tokens-raw/atlassian-light-increased-contrast.js +3 -3
- package/dist/cjs/artifacts/tokens-raw/atlassian-light.js +3 -3
- package/dist/cjs/artifacts/tokens-raw/atlassian-motion.js +3 -3
- package/dist/cjs/constants.js +1 -0
- package/dist/cjs/custom-theme.js +10 -60
- package/dist/cjs/entry-points/token-metadata.codegen.js +2 -11
- package/dist/cjs/get-custom-theme-styles.js +57 -0
- package/dist/cjs/get-global-theme.js +2 -2
- package/dist/cjs/get-theme-html-attrs.js +2 -2
- package/dist/cjs/get-theme-styles.js +33 -32
- package/dist/cjs/load-custom-theme-styles.js +2 -2
- package/dist/cjs/set-global-theme.js +36 -34
- package/dist/cjs/theme-color-modes.js +13 -0
- package/dist/cjs/theme-config.js +21 -16
- package/dist/cjs/theme-ids.js +13 -0
- package/dist/cjs/theme-state-transformer.js +3 -2
- package/dist/cjs/utils/color-detection.js +9 -12
- package/dist/cjs/utils/color-utils.js +45 -46
- package/dist/cjs/utils/custom-theme-loading-utils.js +9 -11
- package/dist/cjs/utils/custom-theme-token-contrast-check.js +2 -0
- package/dist/cjs/utils/generate-custom-color-ramp.js +20 -19
- package/dist/cjs/utils/get-alpha.js +13 -0
- package/dist/cjs/utils/get-closest-color-index.js +20 -0
- package/dist/cjs/utils/get-css-custom-property.js +32 -0
- package/dist/cjs/utils/get-fully-qualified-token-id.js +19 -0
- package/dist/cjs/utils/get-theme-override-preferences.js +12 -0
- package/dist/cjs/utils/get-theme-preferences.js +8 -5
- package/dist/cjs/utils/get-token-id.js +26 -0
- package/dist/cjs/utils/hct-color-utils/argb-from-rgb.js +12 -0
- package/dist/cjs/utils/hct-color-utils/clamp-double.js +20 -0
- package/dist/cjs/utils/hct-color-utils/clamp-int.js +20 -0
- package/dist/cjs/utils/hct-color-utils/color-utils.js +42 -59
- package/dist/cjs/utils/hct-color-utils/delinearized.js +27 -0
- package/dist/cjs/utils/hct-color-utils/hct.js +19 -95
- package/dist/cjs/utils/hct-color-utils/lerp.js +14 -0
- package/dist/cjs/utils/hct-color-utils/linearized.js +22 -0
- package/dist/cjs/utils/hct-color-utils/math-utils.js +38 -107
- package/dist/cjs/utils/hct-color-utils/matrix-multiply.js +15 -0
- package/dist/cjs/utils/hct-color-utils/sanitize-degrees-double.js +19 -0
- package/dist/cjs/utils/hct-color-utils/signum.js +20 -0
- package/dist/cjs/utils/hct-color-utils/viewing-conditions.js +98 -0
- package/dist/cjs/utils/hex-to-rgba-values.js +15 -0
- package/dist/cjs/utils/hsl-to-rgb.js +18 -0
- package/dist/cjs/utils/is-valid-brand-hex.js +9 -0
- package/dist/cjs/utils/limit-size-of-custom-style-elements.js +16 -0
- package/dist/cjs/utils/load-theme-css.js +32 -0
- package/dist/cjs/utils/relative-luminance-w3-c.js +18 -0
- package/dist/cjs/utils/rgb-to-hex.js +9 -0
- package/dist/cjs/utils/theme-loading.js +18 -33
- package/dist/cjs/utils/token-ids.js +21 -62
- package/dist/es2019/artifacts/replacement-mapping.js +5 -2
- package/dist/es2019/artifacts/themes/atlassian-dark-increased-contrast.js +2 -2
- package/dist/es2019/artifacts/themes/atlassian-dark.js +2 -2
- package/dist/es2019/artifacts/themes/atlassian-light-increased-contrast.js +2 -2
- package/dist/es2019/artifacts/themes/atlassian-light.js +2 -2
- package/dist/es2019/artifacts/token-default-values.js +2 -2
- package/dist/es2019/artifacts/tokens-raw/atlassian-dark-increased-contrast.js +3 -3
- package/dist/es2019/artifacts/tokens-raw/atlassian-dark.js +3 -3
- package/dist/es2019/artifacts/tokens-raw/atlassian-light-increased-contrast.js +3 -3
- package/dist/es2019/artifacts/tokens-raw/atlassian-light.js +3 -3
- package/dist/es2019/artifacts/tokens-raw/atlassian-motion.js +3 -3
- package/dist/es2019/constants.js +1 -0
- package/dist/es2019/custom-theme.js +4 -66
- package/dist/es2019/entry-points/token-metadata.codegen.js +2 -11
- package/dist/es2019/get-custom-theme-styles.js +60 -0
- package/dist/es2019/get-global-theme.js +1 -1
- package/dist/es2019/get-theme-html-attrs.js +1 -1
- package/dist/es2019/get-theme-styles.js +4 -3
- package/dist/es2019/load-custom-theme-styles.js +1 -1
- package/dist/es2019/set-global-theme.js +3 -2
- package/dist/es2019/theme-color-modes.js +7 -0
- package/dist/es2019/theme-config.js +6 -16
- package/dist/es2019/theme-ids.js +7 -0
- package/dist/es2019/theme-state-transformer.js +2 -1
- package/dist/es2019/utils/color-detection.js +3 -11
- package/dist/es2019/utils/color-utils.js +15 -33
- package/dist/es2019/utils/custom-theme-loading-utils.js +4 -8
- package/dist/es2019/utils/custom-theme-token-contrast-check.js +2 -0
- package/dist/es2019/utils/generate-custom-color-ramp.js +11 -15
- package/dist/es2019/utils/get-alpha.js +7 -0
- package/dist/es2019/utils/get-closest-color-index.js +14 -0
- package/dist/es2019/utils/get-css-custom-property.js +23 -0
- package/dist/es2019/utils/get-fully-qualified-token-id.js +11 -0
- package/dist/es2019/utils/get-theme-override-preferences.js +4 -0
- package/dist/es2019/utils/get-theme-preferences.js +1 -4
- package/dist/es2019/utils/get-token-id.js +18 -0
- package/dist/es2019/utils/hct-color-utils/argb-from-rgb.js +6 -0
- package/dist/es2019/utils/hct-color-utils/clamp-double.js +14 -0
- package/dist/es2019/utils/hct-color-utils/clamp-int.js +14 -0
- package/dist/es2019/utils/hct-color-utils/color-utils.js +15 -45
- package/dist/es2019/utils/hct-color-utils/delinearized.js +20 -0
- package/dist/es2019/utils/hct-color-utils/hct.js +3 -76
- package/dist/es2019/utils/hct-color-utils/lerp.js +8 -0
- package/dist/es2019/utils/hct-color-utils/linearized.js +16 -0
- package/dist/es2019/utils/hct-color-utils/math-utils.js +6 -105
- package/dist/es2019/utils/hct-color-utils/matrix-multiply.js +9 -0
- package/dist/es2019/utils/hct-color-utils/sanitize-degrees-double.js +13 -0
- package/dist/es2019/utils/hct-color-utils/signum.js +14 -0
- package/dist/es2019/utils/hct-color-utils/viewing-conditions.js +78 -0
- package/dist/es2019/utils/hex-to-rgba-values.js +9 -0
- package/dist/es2019/utils/hsl-to-rgb.js +8 -0
- package/dist/es2019/utils/is-valid-brand-hex.js +1 -0
- package/dist/es2019/utils/limit-size-of-custom-style-elements.js +8 -0
- package/dist/es2019/utils/load-theme-css.js +7 -0
- package/dist/es2019/utils/relative-luminance-w3-c.js +12 -0
- package/dist/es2019/utils/rgb-to-hex.js +3 -0
- package/dist/es2019/utils/theme-loading.js +3 -8
- package/dist/es2019/utils/token-ids.js +3 -54
- package/dist/esm/artifacts/replacement-mapping.js +5 -2
- package/dist/esm/artifacts/themes/atlassian-dark-increased-contrast.js +2 -2
- package/dist/esm/artifacts/themes/atlassian-dark.js +2 -2
- package/dist/esm/artifacts/themes/atlassian-light-increased-contrast.js +2 -2
- package/dist/esm/artifacts/themes/atlassian-light.js +2 -2
- package/dist/esm/artifacts/token-default-values.js +2 -2
- package/dist/esm/artifacts/tokens-raw/atlassian-dark-increased-contrast.js +3 -3
- package/dist/esm/artifacts/tokens-raw/atlassian-dark.js +3 -3
- package/dist/esm/artifacts/tokens-raw/atlassian-light-increased-contrast.js +3 -3
- package/dist/esm/artifacts/tokens-raw/atlassian-light.js +3 -3
- package/dist/esm/artifacts/tokens-raw/atlassian-motion.js +3 -3
- package/dist/esm/constants.js +1 -0
- package/dist/esm/custom-theme.js +4 -58
- package/dist/esm/entry-points/token-metadata.codegen.js +2 -11
- package/dist/esm/get-custom-theme-styles.js +52 -0
- package/dist/esm/get-global-theme.js +1 -1
- package/dist/esm/get-theme-html-attrs.js +1 -1
- package/dist/esm/get-theme-styles.js +30 -29
- package/dist/esm/load-custom-theme-styles.js +1 -1
- package/dist/esm/set-global-theme.js +34 -32
- package/dist/esm/theme-color-modes.js +7 -0
- package/dist/esm/theme-config.js +8 -17
- package/dist/esm/theme-ids.js +7 -0
- package/dist/esm/theme-state-transformer.js +2 -1
- package/dist/esm/utils/color-detection.js +3 -11
- package/dist/esm/utils/color-utils.js +15 -39
- package/dist/esm/utils/custom-theme-loading-utils.js +4 -11
- package/dist/esm/utils/custom-theme-token-contrast-check.js +2 -0
- package/dist/esm/utils/generate-custom-color-ramp.js +11 -15
- package/dist/esm/utils/get-alpha.js +7 -0
- package/dist/esm/utils/get-closest-color-index.js +14 -0
- package/dist/esm/utils/get-css-custom-property.js +26 -0
- package/dist/esm/utils/get-fully-qualified-token-id.js +13 -0
- package/dist/esm/utils/get-theme-override-preferences.js +5 -0
- package/dist/esm/utils/get-theme-preferences.js +1 -4
- package/dist/esm/utils/get-token-id.js +20 -0
- package/dist/esm/utils/hct-color-utils/argb-from-rgb.js +6 -0
- package/dist/esm/utils/hct-color-utils/clamp-double.js +14 -0
- package/dist/esm/utils/hct-color-utils/clamp-int.js +14 -0
- package/dist/esm/utils/hct-color-utils/color-utils.js +15 -45
- package/dist/esm/utils/hct-color-utils/delinearized.js +20 -0
- package/dist/esm/utils/hct-color-utils/hct.js +5 -87
- package/dist/esm/utils/hct-color-utils/lerp.js +8 -0
- package/dist/esm/utils/hct-color-utils/linearized.js +16 -0
- package/dist/esm/utils/hct-color-utils/math-utils.js +6 -105
- package/dist/esm/utils/hct-color-utils/matrix-multiply.js +9 -0
- package/dist/esm/utils/hct-color-utils/sanitize-degrees-double.js +13 -0
- package/dist/esm/utils/hct-color-utils/signum.js +14 -0
- package/dist/esm/utils/hct-color-utils/viewing-conditions.js +89 -0
- package/dist/esm/utils/hex-to-rgba-values.js +9 -0
- package/dist/esm/utils/hsl-to-rgb.js +12 -0
- package/dist/esm/utils/is-valid-brand-hex.js +3 -0
- package/dist/esm/utils/limit-size-of-custom-style-elements.js +10 -0
- package/dist/esm/utils/load-theme-css.js +25 -0
- package/dist/esm/utils/relative-luminance-w3-c.js +12 -0
- package/dist/esm/utils/rgb-to-hex.js +3 -0
- package/dist/esm/utils/theme-loading.js +11 -32
- package/dist/esm/utils/token-ids.js +3 -61
- package/dist/types/artifacts/replacement-mapping.d.ts +1 -1
- package/dist/types/artifacts/themes/atlassian-dark-increased-contrast.d.ts +2 -2
- package/dist/types/artifacts/themes/atlassian-dark.d.ts +2 -2
- package/dist/types/artifacts/themes/atlassian-light-increased-contrast.d.ts +2 -2
- package/dist/types/artifacts/themes/atlassian-light.d.ts +2 -2
- package/dist/types/artifacts/token-default-values.d.ts +2 -2
- package/dist/types/artifacts/tokens-raw/atlassian-dark-increased-contrast.d.ts +1 -1
- package/dist/types/artifacts/tokens-raw/atlassian-dark.d.ts +1 -1
- package/dist/types/artifacts/tokens-raw/atlassian-light-increased-contrast.d.ts +1 -1
- package/dist/types/artifacts/tokens-raw/atlassian-light.d.ts +1 -1
- package/dist/types/artifacts/tokens-raw/atlassian-motion.d.ts +1 -1
- package/dist/types/artifacts/types-internal.d.ts +2 -2
- package/dist/types/artifacts/types.d.ts +2 -2
- package/dist/types/custom-theme.d.ts +1 -20
- package/dist/types/entry-points/token-metadata.codegen.d.ts +1 -1
- package/dist/types/get-custom-theme-styles.d.ts +16 -0
- package/dist/types/get-global-theme.d.ts +1 -1
- package/dist/types/theme-color-modes.d.ts +7 -0
- package/dist/types/theme-config.d.ts +4 -14
- package/dist/types/theme-ids.d.ts +7 -0
- package/dist/types/theme-state-transformer.d.ts +1 -1
- package/dist/types/utils/color-detection.d.ts +1 -6
- package/dist/types/utils/color-utils.d.ts +5 -5
- package/dist/types/utils/custom-theme-loading-utils.d.ts +1 -2
- package/dist/types/utils/generate-custom-color-ramp.d.ts +1 -2
- package/dist/types/utils/get-alpha.d.ts +1 -0
- package/dist/types/utils/get-closest-color-index.d.ts +2 -0
- package/dist/types/utils/get-css-custom-property.d.ts +15 -0
- package/dist/types/utils/get-fully-qualified-token-id.d.ts +11 -0
- package/dist/types/utils/get-theme-override-preferences.d.ts +2 -0
- package/dist/types/utils/get-theme-preferences.d.ts +1 -1
- package/dist/types/utils/get-token-id.d.ts +15 -0
- package/dist/types/utils/hct-color-utils/argb-from-rgb.d.ts +4 -0
- package/dist/types/utils/hct-color-utils/clamp-double.d.ts +7 -0
- package/dist/types/utils/hct-color-utils/clamp-int.d.ts +7 -0
- package/dist/types/utils/hct-color-utils/color-utils.d.ts +3 -23
- package/dist/types/utils/hct-color-utils/delinearized.d.ts +9 -0
- package/dist/types/utils/hct-color-utils/hct.d.ts +3 -48
- package/dist/types/utils/hct-color-utils/lerp.d.ts +6 -0
- package/dist/types/utils/hct-color-utils/linearized.d.ts +9 -0
- package/dist/types/utils/hct-color-utils/math-utils.d.ts +6 -60
- package/dist/types/utils/hct-color-utils/matrix-multiply.d.ts +4 -0
- package/dist/types/utils/hct-color-utils/sanitize-degrees-double.d.ts +7 -0
- package/dist/types/utils/hct-color-utils/signum.d.ts +6 -0
- package/dist/types/utils/hct-color-utils/viewing-conditions.d.ts +47 -0
- package/dist/types/utils/hex-to-rgba-values.d.ts +6 -0
- package/dist/types/utils/hsl-to-rgb.d.ts +1 -0
- package/dist/types/utils/is-valid-brand-hex.d.ts +1 -0
- package/dist/types/utils/limit-size-of-custom-style-elements.d.ts +1 -0
- package/dist/types/utils/load-theme-css.d.ts +2 -0
- package/dist/types/utils/relative-luminance-w3-c.d.ts +1 -0
- package/dist/types/utils/rgb-to-hex.d.ts +1 -0
- package/dist/types/utils/theme-loading.d.ts +1 -1
- package/dist/types/utils/token-ids.d.ts +3 -41
- package/dist/types-ts4.5/artifacts/replacement-mapping.d.ts +1 -1
- package/dist/types-ts4.5/artifacts/themes/atlassian-dark-increased-contrast.d.ts +2 -2
- package/dist/types-ts4.5/artifacts/themes/atlassian-dark.d.ts +2 -2
- package/dist/types-ts4.5/artifacts/themes/atlassian-light-increased-contrast.d.ts +2 -2
- package/dist/types-ts4.5/artifacts/themes/atlassian-light.d.ts +2 -2
- package/dist/types-ts4.5/artifacts/token-default-values.d.ts +2 -2
- package/dist/types-ts4.5/artifacts/tokens-raw/atlassian-dark-increased-contrast.d.ts +1 -1
- package/dist/types-ts4.5/artifacts/tokens-raw/atlassian-dark.d.ts +1 -1
- package/dist/types-ts4.5/artifacts/tokens-raw/atlassian-light-increased-contrast.d.ts +1 -1
- package/dist/types-ts4.5/artifacts/tokens-raw/atlassian-light.d.ts +1 -1
- package/dist/types-ts4.5/artifacts/tokens-raw/atlassian-motion.d.ts +1 -1
- package/dist/types-ts4.5/artifacts/types-internal.d.ts +2 -2
- package/dist/types-ts4.5/artifacts/types.d.ts +2 -2
- package/dist/types-ts4.5/custom-theme.d.ts +1 -20
- package/dist/types-ts4.5/entry-points/token-metadata.codegen.d.ts +1 -1
- package/dist/types-ts4.5/get-custom-theme-styles.d.ts +16 -0
- package/dist/types-ts4.5/get-global-theme.d.ts +1 -1
- package/dist/types-ts4.5/theme-color-modes.d.ts +11 -0
- package/dist/types-ts4.5/theme-config.d.ts +4 -29
- package/dist/types-ts4.5/theme-ids.d.ts +18 -0
- package/dist/types-ts4.5/theme-state-transformer.d.ts +1 -1
- package/dist/types-ts4.5/utils/color-detection.d.ts +1 -6
- package/dist/types-ts4.5/utils/color-utils.d.ts +5 -9
- package/dist/types-ts4.5/utils/custom-theme-loading-utils.d.ts +1 -2
- package/dist/types-ts4.5/utils/generate-custom-color-ramp.d.ts +1 -2
- package/dist/types-ts4.5/utils/get-alpha.d.ts +1 -0
- package/dist/types-ts4.5/utils/get-closest-color-index.d.ts +2 -0
- package/dist/types-ts4.5/utils/get-css-custom-property.d.ts +15 -0
- package/dist/types-ts4.5/utils/get-fully-qualified-token-id.d.ts +11 -0
- package/dist/types-ts4.5/utils/get-theme-override-preferences.d.ts +2 -0
- package/dist/types-ts4.5/utils/get-theme-preferences.d.ts +1 -1
- package/dist/types-ts4.5/utils/get-token-id.d.ts +15 -0
- package/dist/types-ts4.5/utils/hct-color-utils/argb-from-rgb.d.ts +4 -0
- package/dist/types-ts4.5/utils/hct-color-utils/clamp-double.d.ts +7 -0
- package/dist/types-ts4.5/utils/hct-color-utils/clamp-int.d.ts +7 -0
- package/dist/types-ts4.5/utils/hct-color-utils/color-utils.d.ts +3 -23
- package/dist/types-ts4.5/utils/hct-color-utils/delinearized.d.ts +9 -0
- package/dist/types-ts4.5/utils/hct-color-utils/hct.d.ts +3 -48
- package/dist/types-ts4.5/utils/hct-color-utils/lerp.d.ts +6 -0
- package/dist/types-ts4.5/utils/hct-color-utils/linearized.d.ts +9 -0
- package/dist/types-ts4.5/utils/hct-color-utils/math-utils.d.ts +6 -60
- package/dist/types-ts4.5/utils/hct-color-utils/matrix-multiply.d.ts +4 -0
- package/dist/types-ts4.5/utils/hct-color-utils/sanitize-degrees-double.d.ts +7 -0
- package/dist/types-ts4.5/utils/hct-color-utils/signum.d.ts +6 -0
- package/dist/types-ts4.5/utils/hct-color-utils/viewing-conditions.d.ts +47 -0
- package/dist/types-ts4.5/utils/hex-to-rgba-values.d.ts +6 -0
- package/dist/types-ts4.5/utils/hsl-to-rgb.d.ts +5 -0
- package/dist/types-ts4.5/utils/is-valid-brand-hex.d.ts +1 -0
- package/dist/types-ts4.5/utils/limit-size-of-custom-style-elements.d.ts +1 -0
- package/dist/types-ts4.5/utils/load-theme-css.d.ts +2 -0
- package/dist/types-ts4.5/utils/relative-luminance-w3-c.d.ts +1 -0
- package/dist/types-ts4.5/utils/rgb-to-hex.d.ts +1 -0
- package/dist/types-ts4.5/utils/theme-loading.d.ts +1 -1
- package/dist/types-ts4.5/utils/token-ids.d.ts +3 -41
- package/figma/atlassian-dark-increased-contrast.json +1 -1
- package/figma/atlassian-dark.json +1 -1
- package/figma/atlassian-light-increased-contrast.json +1 -1
- package/figma/atlassian-light.json +1 -1
- package/package.json +12 -12
- package/tokens.docs.tsx +48 -46
|
@@ -3,35 +3,50 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports
|
|
6
|
+
Object.defineProperty(exports, "HSLToRGB", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function get() {
|
|
9
|
+
return _hslToRgb.HSLToRGB;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
7
12
|
exports.deltaE = deltaE;
|
|
8
|
-
exports
|
|
13
|
+
Object.defineProperty(exports, "getAlpha", {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function get() {
|
|
16
|
+
return _getAlpha.getAlpha;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
9
19
|
exports.getContrastRatio = getContrastRatio;
|
|
10
20
|
exports.hexToHSL = hexToHSL;
|
|
11
21
|
exports.hexToRgb = hexToRgb;
|
|
12
22
|
exports.hexToRgbA = hexToRgbA;
|
|
13
|
-
exports
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
23
|
+
Object.defineProperty(exports, "isValidBrandHex", {
|
|
24
|
+
enumerable: true,
|
|
25
|
+
get: function get() {
|
|
26
|
+
return _isValidBrandHex.isValidBrandHex;
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
Object.defineProperty(exports, "relativeLuminanceW3C", {
|
|
30
|
+
enumerable: true,
|
|
31
|
+
get: function get() {
|
|
32
|
+
return _relativeLuminanceW3C.relativeLuminanceW3C;
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
Object.defineProperty(exports, "rgbToHex", {
|
|
36
|
+
enumerable: true,
|
|
37
|
+
get: function get() {
|
|
38
|
+
return _rgbToHex.rgbToHex;
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
var _getAlpha = require("./get-alpha");
|
|
42
|
+
var _relativeLuminanceW3C = require("./relative-luminance-w3-c");
|
|
43
|
+
var _isValidBrandHex = require("./is-valid-brand-hex");
|
|
44
|
+
var _rgbToHex = require("./rgb-to-hex");
|
|
45
|
+
var _hslToRgb = require("./hsl-to-rgb");
|
|
21
46
|
// valid hex color with 4, 6 or 8 digits
|
|
22
47
|
var isValidHex = function isValidHex(hex) {
|
|
23
48
|
return /^#([A-Fa-f0-9]{3,4}){1,2}$/.test(hex);
|
|
24
49
|
};
|
|
25
|
-
function rgbToHex(r, g, b) {
|
|
26
|
-
return '#' + ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1);
|
|
27
|
-
}
|
|
28
|
-
function getAlpha(hex) {
|
|
29
|
-
if (hex.length === 9) {
|
|
30
|
-
var int = parseInt(hex.slice(7, 9), 16) / 255;
|
|
31
|
-
return Number(parseFloat(int.toString()).toFixed(2));
|
|
32
|
-
}
|
|
33
|
-
return 1;
|
|
34
|
-
}
|
|
35
50
|
function hexToRgbA(hex) {
|
|
36
51
|
if (!isValidHex(hex)) {
|
|
37
52
|
throw new Error('Invalid HEX');
|
|
@@ -42,8 +57,10 @@ function hexToRgbA(hex) {
|
|
|
42
57
|
c = [c[0], c[0], c[1], c[1], c[2], c[2]];
|
|
43
58
|
}
|
|
44
59
|
c = '0x' + c.join('');
|
|
45
|
-
return [c >> 16 & 255, c >> 8 & 255, c & 255, getAlpha(hex)];
|
|
60
|
+
return [c >> 16 & 255, c >> 8 & 255, c & 255, (0, _getAlpha.getAlpha)(hex)];
|
|
46
61
|
}
|
|
62
|
+
|
|
63
|
+
// eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
|
|
47
64
|
function hexToRgb(hex) {
|
|
48
65
|
if (!isValidHex(hex)) {
|
|
49
66
|
throw new Error('Invalid HEX');
|
|
@@ -56,6 +73,8 @@ function hexToRgb(hex) {
|
|
|
56
73
|
c = '0x' + c.join('');
|
|
57
74
|
return [c >> 16 & 255, c >> 8 & 255, c & 255];
|
|
58
75
|
}
|
|
76
|
+
|
|
77
|
+
// eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
|
|
59
78
|
function hexToHSL(hex) {
|
|
60
79
|
if (!isValidHex(hex)) {
|
|
61
80
|
throw new Error('Invalid HEX');
|
|
@@ -101,43 +120,23 @@ function hexToHSL(hex) {
|
|
|
101
120
|
l = +(l * 100).toFixed(1);
|
|
102
121
|
return [h, s, l];
|
|
103
122
|
}
|
|
104
|
-
function HSLToRGB(h, s, l) {
|
|
105
|
-
s /= 100;
|
|
106
|
-
l /= 100;
|
|
107
|
-
var k = function k(n) {
|
|
108
|
-
return (n + h / 30) % 12;
|
|
109
|
-
};
|
|
110
|
-
var a = s * Math.min(l, 1 - l);
|
|
111
|
-
var f = function f(n) {
|
|
112
|
-
return l - a * Math.max(-1, Math.min(k(n) - 3, Math.min(9 - k(n), 1)));
|
|
113
|
-
};
|
|
114
|
-
return [255 * f(0), 255 * f(8), 255 * f(4)];
|
|
115
|
-
}
|
|
116
|
-
function relativeLuminanceW3C(r, g, b) {
|
|
117
|
-
var RsRGB = r / 255;
|
|
118
|
-
var GsRGB = g / 255;
|
|
119
|
-
var BsRGB = b / 255;
|
|
120
|
-
var R = RsRGB <= 0.03928 ? RsRGB / 12.92 : Math.pow((RsRGB + 0.055) / 1.055, 2.4);
|
|
121
|
-
var G = GsRGB <= 0.03928 ? GsRGB / 12.92 : Math.pow((GsRGB + 0.055) / 1.055, 2.4);
|
|
122
|
-
var B = BsRGB <= 0.03928 ? BsRGB / 12.92 : Math.pow((BsRGB + 0.055) / 1.055, 2.4);
|
|
123
123
|
|
|
124
|
-
|
|
125
|
-
var L = 0.2126 * R + 0.7152 * G + 0.0722 * B;
|
|
126
|
-
return L;
|
|
127
|
-
}
|
|
124
|
+
// eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
|
|
128
125
|
function getContrastRatio(foreground, background) {
|
|
129
126
|
if (!isValidHex(foreground) || !isValidHex(background)) {
|
|
130
127
|
throw new Error('Invalid HEX');
|
|
131
128
|
}
|
|
132
129
|
var foregroundRgb = hexToRgb(foreground);
|
|
133
130
|
var backgroundRgb = hexToRgb(background);
|
|
134
|
-
var foregroundLuminance = relativeLuminanceW3C(foregroundRgb[0], foregroundRgb[1], foregroundRgb[2]);
|
|
135
|
-
var backgroundLuminance = relativeLuminanceW3C(backgroundRgb[0], backgroundRgb[1], backgroundRgb[2]);
|
|
131
|
+
var foregroundLuminance = (0, _relativeLuminanceW3C.relativeLuminanceW3C)(foregroundRgb[0], foregroundRgb[1], foregroundRgb[2]);
|
|
132
|
+
var backgroundLuminance = (0, _relativeLuminanceW3C.relativeLuminanceW3C)(backgroundRgb[0], backgroundRgb[1], backgroundRgb[2]);
|
|
136
133
|
// calculate the color contrast ratio
|
|
137
134
|
var brightest = Math.max(foregroundLuminance, backgroundLuminance);
|
|
138
135
|
var darkest = Math.min(foregroundLuminance, backgroundLuminance);
|
|
139
136
|
return (brightest + 0.05) / (darkest + 0.05);
|
|
140
137
|
}
|
|
138
|
+
|
|
139
|
+
// eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
|
|
141
140
|
function deltaE(rgbA, rgbB) {
|
|
142
141
|
var labA = rgbToLab(rgbA);
|
|
143
142
|
var labB = rgbToLab(rgbB);
|
|
@@ -5,13 +5,18 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.findMissingCustomStyleElements = findMissingCustomStyleElements;
|
|
8
|
-
exports
|
|
8
|
+
Object.defineProperty(exports, "limitSizeOfCustomStyleElements", {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function get() {
|
|
11
|
+
return _limitSizeOfCustomStyleElements.limitSizeOfCustomStyleElements;
|
|
12
|
+
}
|
|
13
|
+
});
|
|
9
14
|
exports.reduceTokenMap = reduceTokenMap;
|
|
10
15
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
11
|
-
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
12
16
|
var _tokenNames = _interopRequireDefault(require("../artifacts/token-names"));
|
|
13
17
|
var _constants = require("../constants");
|
|
14
18
|
var _hash = require("./hash");
|
|
19
|
+
var _limitSizeOfCustomStyleElements = require("./limit-size-of-custom-style-elements");
|
|
15
20
|
function findMissingCustomStyleElements(UNSAFE_themeOptions, mode) {
|
|
16
21
|
var optionString = JSON.stringify(UNSAFE_themeOptions);
|
|
17
22
|
var uniqueId = (0, _hash.hash)(optionString);
|
|
@@ -27,15 +32,8 @@ function findMissingCustomStyleElements(UNSAFE_themeOptions, mode) {
|
|
|
27
32
|
});
|
|
28
33
|
return attrOfMissingCustomStyles;
|
|
29
34
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
if (styleTags.length < sizeThreshold) {
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
styleTags.slice(0, styleTags.length - (sizeThreshold - 1)).forEach(function (element) {
|
|
36
|
-
return element.remove();
|
|
37
|
-
});
|
|
38
|
-
}
|
|
35
|
+
|
|
36
|
+
// eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
|
|
39
37
|
function reduceTokenMap(tokenMap, themeRamp) {
|
|
40
38
|
return Object.entries(tokenMap).reduce(function (acc, _ref) {
|
|
41
39
|
var _ref2 = (0, _slicedToArray2.default)(_ref, 2),
|
|
@@ -53,6 +53,8 @@ var additionalChecks = exports.additionalChecks = [{
|
|
|
53
53
|
var getColorFromTokenRaw = function getColorFromTokenRaw(tokenName, mode) {
|
|
54
54
|
return mode === 'light' ? _atlassianLightTokenValueForContrastCheck.default[tokenName] : _atlassianDarkTokenValueForContrastCheck.default[tokenName];
|
|
55
55
|
};
|
|
56
|
+
|
|
57
|
+
// eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
|
|
56
58
|
var additionalContrastChecker = exports.additionalContrastChecker = function additionalContrastChecker(_ref) {
|
|
57
59
|
var customThemeTokenMap = _ref.customThemeTokenMap,
|
|
58
60
|
mode = _ref.mode,
|
|
@@ -4,36 +4,33 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.
|
|
7
|
+
exports.generateTokenMapWithContrastCheck = exports.generateTokenMap = exports.generateColors = void 0;
|
|
8
|
+
Object.defineProperty(exports, "getClosestColorIndex", {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function get() {
|
|
11
|
+
return _getClosestColorIndex.getClosestColorIndex;
|
|
12
|
+
}
|
|
13
|
+
});
|
|
8
14
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
15
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
10
16
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
11
17
|
var _atlassianDarkTokenValueForContrastCheck = _interopRequireDefault(require("../artifacts/atlassian-dark-token-value-for-contrast-check"));
|
|
12
18
|
var _colorUtils = require("./color-utils");
|
|
13
19
|
var _customThemeTokenContrastCheck = require("./custom-theme-token-contrast-check");
|
|
20
|
+
var _getClosestColorIndex = require("./get-closest-color-index");
|
|
14
21
|
var _hctColorUtils = require("./hct-color-utils");
|
|
22
|
+
var _hslToRgb = require("./hsl-to-rgb");
|
|
23
|
+
var _relativeLuminanceW3C = require("./relative-luminance-w3-c");
|
|
24
|
+
var _rgbToHex = require("./rgb-to-hex");
|
|
15
25
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
16
26
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
17
27
|
var lowLuminanceContrastRatios = [1.12, 1.33, 2.03, 2.73, 3.33, 4.27, 5.2, 6.62, 12.46, 14.25];
|
|
18
28
|
var highLuminanceContrastRatios = [1.08, 1.24, 1.55, 1.99, 2.45, 3.34, 4.64, 6.1, 10.19, 12.6];
|
|
19
|
-
var getClosestColorIndex = exports.getClosestColorIndex = function getClosestColorIndex(themeRamp, brandColor) {
|
|
20
|
-
// Iterate over themeRamp and find whichever color is closest to brandColor
|
|
21
|
-
var closestColorIndex = 0;
|
|
22
|
-
var closestColorDistance = null;
|
|
23
|
-
themeRamp.forEach(function (value, index) {
|
|
24
|
-
var distance = (0, _colorUtils.deltaE)((0, _colorUtils.hexToRgb)(value), (0, _colorUtils.hexToRgb)(brandColor));
|
|
25
|
-
if (closestColorDistance === null || distance < closestColorDistance) {
|
|
26
|
-
closestColorIndex = index;
|
|
27
|
-
closestColorDistance = distance;
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
return closestColorIndex;
|
|
31
|
-
};
|
|
32
29
|
var generateColors = exports.generateColors = function generateColors(brandColor) {
|
|
33
30
|
// Determine luminance
|
|
34
31
|
var HSLBrandColorHue = (0, _colorUtils.hexToHSL)(brandColor)[0];
|
|
35
|
-
var baseRgb = (0,
|
|
36
|
-
var isLowLuminance = (0,
|
|
32
|
+
var baseRgb = (0, _hslToRgb.HSLToRGB)(HSLBrandColorHue, 100, 60);
|
|
33
|
+
var isLowLuminance = (0, _relativeLuminanceW3C.relativeLuminanceW3C)(baseRgb[0], baseRgb[1], baseRgb[2]) < 0.4;
|
|
37
34
|
// Choose right palette
|
|
38
35
|
var themeRatios = isLowLuminance ? lowLuminanceContrastRatios : highLuminanceContrastRatios;
|
|
39
36
|
var brandRgba = (0, _colorUtils.hexToRgbA)(brandColor);
|
|
@@ -46,9 +43,9 @@ var generateColors = exports.generateColors = function generateColors(brandColor
|
|
|
46
43
|
var themeRamp = themeRatios.map(function (contrast) {
|
|
47
44
|
var rgbaColor = (0, _hctColorUtils.rgbaFromArgb)(_hctColorUtils.Hct.from(hctColor.hue, hctColor.chroma, _hctColorUtils.Contrast.darker(100, contrast) + 0.25 // Material's utils provide an offset
|
|
48
45
|
).toInt());
|
|
49
|
-
return (0,
|
|
46
|
+
return (0, _rgbToHex.rgbToHex)(rgbaColor.r, rgbaColor.g, rgbaColor.b);
|
|
50
47
|
});
|
|
51
|
-
var closestColorIndex = getClosestColorIndex(themeRamp, brandColor);
|
|
48
|
+
var closestColorIndex = (0, _getClosestColorIndex.getClosestColorIndex)(themeRamp, brandColor);
|
|
52
49
|
|
|
53
50
|
// Replace closet color with brandColor
|
|
54
51
|
var updatedThemeRamp = (0, _toConsumableArray2.default)(themeRamp);
|
|
@@ -79,12 +76,14 @@ function getInteractionStates(rampPosition, number, colors) {
|
|
|
79
76
|
}
|
|
80
77
|
return result;
|
|
81
78
|
}
|
|
79
|
+
|
|
80
|
+
// eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
|
|
82
81
|
var generateTokenMap = exports.generateTokenMap = function generateTokenMap(brandColor, mode, themeRamp) {
|
|
83
82
|
var _generateColors = generateColors(brandColor),
|
|
84
83
|
ramp = _generateColors.ramp,
|
|
85
84
|
replacedColor = _generateColors.replacedColor;
|
|
86
85
|
var colors = themeRamp || ramp;
|
|
87
|
-
var closestColorIndex = getClosestColorIndex(colors, brandColor);
|
|
86
|
+
var closestColorIndex = (0, _getClosestColorIndex.getClosestColorIndex)(colors, brandColor);
|
|
88
87
|
var customThemeTokenMapLight = {};
|
|
89
88
|
var customThemeTokenMapDark = {};
|
|
90
89
|
var inputContrast = (0, _colorUtils.getContrastRatio)(brandColor, '#FFFFFF');
|
|
@@ -218,6 +217,8 @@ var generateTokenMap = exports.generateTokenMap = function generateTokenMap(bran
|
|
|
218
217
|
dark: customThemeTokenMapDark
|
|
219
218
|
};
|
|
220
219
|
};
|
|
220
|
+
|
|
221
|
+
// eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
|
|
221
222
|
var generateTokenMapWithContrastCheck = exports.generateTokenMapWithContrastCheck = function generateTokenMapWithContrastCheck(brandColor, mode, themeRamp) {
|
|
222
223
|
var colors = themeRamp || generateColors(brandColor).ramp;
|
|
223
224
|
var tokenMaps = generateTokenMap(brandColor, mode, colors);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getAlpha = getAlpha;
|
|
7
|
+
function getAlpha(hex) {
|
|
8
|
+
if (hex.length === 9) {
|
|
9
|
+
var int = parseInt(hex.slice(7, 9), 16) / 255;
|
|
10
|
+
return Number(parseFloat(int.toString()).toFixed(2));
|
|
11
|
+
}
|
|
12
|
+
return 1;
|
|
13
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getClosestColorIndex = void 0;
|
|
7
|
+
var _colorUtils = require("./color-utils");
|
|
8
|
+
var getClosestColorIndex = exports.getClosestColorIndex = function getClosestColorIndex(themeRamp, brandColor) {
|
|
9
|
+
// Iterate over themeRamp and find whichever color is closest to brandColor
|
|
10
|
+
var closestColorIndex = 0;
|
|
11
|
+
var closestColorDistance = null;
|
|
12
|
+
themeRamp.forEach(function (value, index) {
|
|
13
|
+
var distance = (0, _colorUtils.deltaE)((0, _colorUtils.hexToRgb)(value), (0, _colorUtils.hexToRgb)(brandColor));
|
|
14
|
+
if (closestColorDistance === null || distance < closestColorDistance) {
|
|
15
|
+
closestColorIndex = index;
|
|
16
|
+
closestColorDistance = distance;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
return closestColorIndex;
|
|
20
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.getCSSCustomProperty = void 0;
|
|
8
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
|
+
var _constants = require("../constants");
|
|
10
|
+
/**
|
|
11
|
+
* Transforms a style dictionary token path to a CSS custom property.
|
|
12
|
+
*
|
|
13
|
+
* A css prefix will be prepended and all [default] key words will be omitted
|
|
14
|
+
* from the path
|
|
15
|
+
*
|
|
16
|
+
* @example <caption>Passing a path as an array</caption>
|
|
17
|
+
* // Returns ds-background-bold
|
|
18
|
+
* getCSSCustomProperty(['color', 'background', 'bold', '[default]'])
|
|
19
|
+
*
|
|
20
|
+
* @example <caption>Passing a path as a string</caption>
|
|
21
|
+
* // Returns ds-background-bold
|
|
22
|
+
* getCSSCustomProperty('color.background.bold.[default]')
|
|
23
|
+
*/
|
|
24
|
+
var getCSSCustomProperty = exports.getCSSCustomProperty = function getCSSCustomProperty(path) {
|
|
25
|
+
var normalizedPath = typeof path === 'string' ? path.split('.') : path;
|
|
26
|
+
|
|
27
|
+
// Opacity and other 'shallow' groups are more readable when not trimmed
|
|
28
|
+
var slice = _constants.CSS_VAR_FULL.includes(normalizedPath[0]) ? 0 : 1;
|
|
29
|
+
return "--".concat([_constants.CSS_PREFIX].concat((0, _toConsumableArray2.default)(normalizedPath.slice(slice))).filter(function (el) {
|
|
30
|
+
return el !== '[default]';
|
|
31
|
+
}).join('-'));
|
|
32
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getFullyQualifiedTokenId = void 0;
|
|
7
|
+
/**
|
|
8
|
+
* Transforms a style dictionary token path to a fully qualified token id
|
|
9
|
+
* These Ids are intended to be used internal to this package by style-dictionary
|
|
10
|
+
*
|
|
11
|
+
* [default] key words will NOT be omitted from the path
|
|
12
|
+
*
|
|
13
|
+
* @example <caption>Passing a path as a string</caption>
|
|
14
|
+
* // Returns color.background.bold.[default]
|
|
15
|
+
* getFullyQualifiedTokenId(['color', 'background', 'bold', '[default]'])
|
|
16
|
+
*/
|
|
17
|
+
var getFullyQualifiedTokenId = exports.getFullyQualifiedTokenId = function getFullyQualifiedTokenId(path) {
|
|
18
|
+
return path.join('.');
|
|
19
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.getThemeOverridePreferences = void 0;
|
|
8
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
|
+
var getThemeOverridePreferences = exports.getThemeOverridePreferences = function getThemeOverridePreferences(_themeState) {
|
|
10
|
+
var themeOverridePreferences = [];
|
|
11
|
+
return (0, _toConsumableArray2.default)(new Set(themeOverridePreferences));
|
|
12
|
+
};
|
|
@@ -4,10 +4,17 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports
|
|
7
|
+
Object.defineProperty(exports, "getThemeOverridePreferences", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function get() {
|
|
10
|
+
return _getThemeOverridePreferences.getThemeOverridePreferences;
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
exports.getThemePreferences = void 0;
|
|
8
14
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
15
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
10
16
|
var _getIncreasedContrastTheme = _interopRequireDefault(require("./get-increased-contrast-theme"));
|
|
17
|
+
var _getThemeOverridePreferences = require("./get-theme-override-preferences");
|
|
11
18
|
var getThemePreferences = exports.getThemePreferences = function getThemePreferences(themeState) {
|
|
12
19
|
var colorMode = themeState.colorMode,
|
|
13
20
|
contrastMode = themeState.contrastMode,
|
|
@@ -44,8 +51,4 @@ var getThemePreferences = exports.getThemePreferences = function getThemePrefere
|
|
|
44
51
|
}
|
|
45
52
|
});
|
|
46
53
|
return (0, _toConsumableArray2.default)(new Set(themePreferences));
|
|
47
|
-
};
|
|
48
|
-
var getThemeOverridePreferences = exports.getThemeOverridePreferences = function getThemeOverridePreferences(_themeState) {
|
|
49
|
-
var themeOverridePreferences = [];
|
|
50
|
-
return (0, _toConsumableArray2.default)(new Set(themeOverridePreferences));
|
|
51
54
|
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getTokenId = void 0;
|
|
7
|
+
/**
|
|
8
|
+
* Transforms a style dictionary token path to a shorthand token id
|
|
9
|
+
* These ids will be typically be how tokens are interacted with via typescript and css
|
|
10
|
+
*
|
|
11
|
+
* All [default] key words will be omitted from the path
|
|
12
|
+
*
|
|
13
|
+
* @example <caption>Passing a path as an array</caption>
|
|
14
|
+
* // Returns color.background.bold
|
|
15
|
+
* getTokenId(['color', 'background', 'bold', '[default]'])
|
|
16
|
+
*
|
|
17
|
+
* @example <caption>Passing a path as a string</caption>
|
|
18
|
+
* // Returns color.background.bold
|
|
19
|
+
* getTokenId('color.background.bold.[default]')
|
|
20
|
+
*/
|
|
21
|
+
var getTokenId = exports.getTokenId = function getTokenId(path) {
|
|
22
|
+
var normalizedPath = typeof path === 'string' ? path.split('.') : path;
|
|
23
|
+
return normalizedPath.filter(function (el) {
|
|
24
|
+
return el !== '[default]';
|
|
25
|
+
}).join('.');
|
|
26
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.argbFromRgb = argbFromRgb;
|
|
7
|
+
/**
|
|
8
|
+
* Converts a color from RGB components to ARGB format.
|
|
9
|
+
*/
|
|
10
|
+
function argbFromRgb(red, green, blue) {
|
|
11
|
+
return (255 << 24 | (red & 255) << 16 | (green & 255) << 8 | blue & 255) >>> 0;
|
|
12
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.clampDouble = clampDouble;
|
|
7
|
+
/**
|
|
8
|
+
* Clamps an integer between two floating-point numbers.
|
|
9
|
+
*
|
|
10
|
+
* @return input when min <= input <= max, and either min or max
|
|
11
|
+
* otherwise.
|
|
12
|
+
*/
|
|
13
|
+
function clampDouble(min, max, input) {
|
|
14
|
+
if (input < min) {
|
|
15
|
+
return min;
|
|
16
|
+
} else if (input > max) {
|
|
17
|
+
return max;
|
|
18
|
+
}
|
|
19
|
+
return input;
|
|
20
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.clampInt = clampInt;
|
|
7
|
+
/**
|
|
8
|
+
* Clamps an integer between two integers.
|
|
9
|
+
*
|
|
10
|
+
* @return input when min <= input <= max, and either min or max
|
|
11
|
+
* otherwise.
|
|
12
|
+
*/
|
|
13
|
+
function clampInt(min, max, input) {
|
|
14
|
+
if (input < min) {
|
|
15
|
+
return min;
|
|
16
|
+
} else if (input > max) {
|
|
17
|
+
return max;
|
|
18
|
+
}
|
|
19
|
+
return input;
|
|
20
|
+
}
|