@atlaskit/tokens 13.0.3 → 13.0.4

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.
Files changed (260) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/codemods/css-to-design-tokens/lib/meta.tsx +1 -1
  3. package/codemods/css-to-design-tokens/lib/tokens.tsx +1 -1
  4. package/codemods/theme-to-design-tokens/transform.tsx +16 -14
  5. package/codemods/theme-to-design-tokens/utils/ast-meta.tsx +2 -151
  6. package/codemods/theme-to-design-tokens/utils/ast.tsx +3 -35
  7. package/codemods/theme-to-design-tokens/utils/clean-meta.tsx +63 -0
  8. package/codemods/theme-to-design-tokens/utils/color.tsx +3 -11
  9. package/codemods/theme-to-design-tokens/utils/contains-replaceable-css-declarations.tsx +13 -0
  10. package/codemods/theme-to-design-tokens/utils/css-utils.tsx +2 -35
  11. package/codemods/theme-to-design-tokens/utils/find-end-index-of-css-expression.tsx +21 -0
  12. package/codemods/theme-to-design-tokens/utils/find-first-nonspace-index-after.tsx +9 -0
  13. package/codemods/theme-to-design-tokens/utils/get-closest-decendant-of-type.tsx +10 -0
  14. package/codemods/theme-to-design-tokens/utils/get-meta-from-ancestors.tsx +87 -0
  15. package/codemods/theme-to-design-tokens/utils/is-bold-color.tsx +4 -0
  16. package/codemods/theme-to-design-tokens/utils/is-decendant-of-token.tsx +14 -0
  17. package/codemods/theme-to-design-tokens/utils/is-legacy-color.tsx +4 -0
  18. package/codemods/theme-to-design-tokens/utils/is-legacy-named-color.tsx +4 -0
  19. package/codemods/theme-to-design-tokens/utils/is-parent-of-token.tsx +13 -0
  20. package/codemods/theme-to-design-tokens/utils/kebabize.tsx +2 -0
  21. package/codemods/theme-to-design-tokens/utils/legacy-color-meta-map.tsx +88 -0
  22. package/codemods/theme-to-design-tokens/utils/legacy-color-mixins.tsx +26 -0
  23. package/codemods/theme-to-design-tokens/utils/legacy-colors.tsx +2 -115
  24. package/codemods/theme-to-design-tokens/utils/split-at-index.tsx +3 -0
  25. package/codemods/theme-to-design-tokens/utils/string-utils.tsx +3 -16
  26. package/codemods/utils/active-tokens.tsx +284 -0
  27. package/codemods/utils/tokens.tsx +2 -376
  28. package/codemods/utils/unique-words-from-tokens.tsx +91 -0
  29. package/dist/cjs/artifacts/replacement-mapping.js +5 -2
  30. package/dist/cjs/artifacts/tokens-raw/atlassian-motion.js +3 -3
  31. package/dist/cjs/custom-theme.js +10 -60
  32. package/dist/cjs/entry-points/token-metadata.codegen.js +1 -10
  33. package/dist/cjs/get-custom-theme-styles.js +57 -0
  34. package/dist/cjs/get-global-theme.js +2 -2
  35. package/dist/cjs/get-theme-html-attrs.js +2 -2
  36. package/dist/cjs/get-theme-styles.js +6 -5
  37. package/dist/cjs/load-custom-theme-styles.js +2 -2
  38. package/dist/cjs/set-global-theme.js +4 -3
  39. package/dist/cjs/theme-color-modes.js +13 -0
  40. package/dist/cjs/theme-config.js +19 -16
  41. package/dist/cjs/theme-ids.js +13 -0
  42. package/dist/cjs/theme-state-transformer.js +2 -2
  43. package/dist/cjs/utils/color-detection.js +9 -12
  44. package/dist/cjs/utils/color-utils.js +38 -47
  45. package/dist/cjs/utils/custom-theme-loading-utils.js +7 -11
  46. package/dist/cjs/utils/generate-custom-color-ramp.js +16 -19
  47. package/dist/cjs/utils/get-alpha.js +13 -0
  48. package/dist/cjs/utils/get-closest-color-index.js +20 -0
  49. package/dist/cjs/utils/get-css-custom-property.js +32 -0
  50. package/dist/cjs/utils/get-fully-qualified-token-id.js +19 -0
  51. package/dist/cjs/utils/get-theme-override-preferences.js +12 -0
  52. package/dist/cjs/utils/get-theme-preferences.js +8 -5
  53. package/dist/cjs/utils/get-token-id.js +26 -0
  54. package/dist/cjs/utils/hct-color-utils/argb-from-rgb.js +12 -0
  55. package/dist/cjs/utils/hct-color-utils/clamp-double.js +20 -0
  56. package/dist/cjs/utils/hct-color-utils/clamp-int.js +20 -0
  57. package/dist/cjs/utils/hct-color-utils/color-utils.js +34 -59
  58. package/dist/cjs/utils/hct-color-utils/delinearized.js +27 -0
  59. package/dist/cjs/utils/hct-color-utils/hct.js +19 -95
  60. package/dist/cjs/utils/hct-color-utils/lerp.js +14 -0
  61. package/dist/cjs/utils/hct-color-utils/linearized.js +22 -0
  62. package/dist/cjs/utils/hct-color-utils/math-utils.js +38 -107
  63. package/dist/cjs/utils/hct-color-utils/matrix-multiply.js +15 -0
  64. package/dist/cjs/utils/hct-color-utils/sanitize-degrees-double.js +19 -0
  65. package/dist/cjs/utils/hct-color-utils/signum.js +20 -0
  66. package/dist/cjs/utils/hct-color-utils/viewing-conditions.js +98 -0
  67. package/dist/cjs/utils/hex-to-rgba-values.js +15 -0
  68. package/dist/cjs/utils/hsl-to-rgb.js +18 -0
  69. package/dist/cjs/utils/is-valid-brand-hex.js +9 -0
  70. package/dist/cjs/utils/limit-size-of-custom-style-elements.js +16 -0
  71. package/dist/cjs/utils/load-theme-css.js +32 -0
  72. package/dist/cjs/utils/relative-luminance-w3-c.js +18 -0
  73. package/dist/cjs/utils/rgb-to-hex.js +9 -0
  74. package/dist/cjs/utils/theme-loading.js +10 -25
  75. package/dist/cjs/utils/token-ids.js +21 -62
  76. package/dist/es2019/artifacts/replacement-mapping.js +5 -2
  77. package/dist/es2019/artifacts/tokens-raw/atlassian-motion.js +3 -3
  78. package/dist/es2019/custom-theme.js +4 -66
  79. package/dist/es2019/entry-points/token-metadata.codegen.js +1 -10
  80. package/dist/es2019/get-custom-theme-styles.js +60 -0
  81. package/dist/es2019/get-global-theme.js +1 -1
  82. package/dist/es2019/get-theme-html-attrs.js +1 -1
  83. package/dist/es2019/get-theme-styles.js +4 -3
  84. package/dist/es2019/load-custom-theme-styles.js +1 -1
  85. package/dist/es2019/set-global-theme.js +3 -2
  86. package/dist/es2019/theme-color-modes.js +7 -0
  87. package/dist/es2019/theme-config.js +4 -16
  88. package/dist/es2019/theme-ids.js +7 -0
  89. package/dist/es2019/theme-state-transformer.js +1 -1
  90. package/dist/es2019/utils/color-detection.js +3 -11
  91. package/dist/es2019/utils/color-utils.js +8 -34
  92. package/dist/es2019/utils/custom-theme-loading-utils.js +2 -8
  93. package/dist/es2019/utils/generate-custom-color-ramp.js +7 -15
  94. package/dist/es2019/utils/get-alpha.js +7 -0
  95. package/dist/es2019/utils/get-closest-color-index.js +14 -0
  96. package/dist/es2019/utils/get-css-custom-property.js +23 -0
  97. package/dist/es2019/utils/get-fully-qualified-token-id.js +11 -0
  98. package/dist/es2019/utils/get-theme-override-preferences.js +4 -0
  99. package/dist/es2019/utils/get-theme-preferences.js +1 -4
  100. package/dist/es2019/utils/get-token-id.js +18 -0
  101. package/dist/es2019/utils/hct-color-utils/argb-from-rgb.js +6 -0
  102. package/dist/es2019/utils/hct-color-utils/clamp-double.js +14 -0
  103. package/dist/es2019/utils/hct-color-utils/clamp-int.js +14 -0
  104. package/dist/es2019/utils/hct-color-utils/color-utils.js +7 -45
  105. package/dist/es2019/utils/hct-color-utils/delinearized.js +20 -0
  106. package/dist/es2019/utils/hct-color-utils/hct.js +3 -76
  107. package/dist/es2019/utils/hct-color-utils/lerp.js +8 -0
  108. package/dist/es2019/utils/hct-color-utils/linearized.js +16 -0
  109. package/dist/es2019/utils/hct-color-utils/math-utils.js +6 -105
  110. package/dist/es2019/utils/hct-color-utils/matrix-multiply.js +9 -0
  111. package/dist/es2019/utils/hct-color-utils/sanitize-degrees-double.js +13 -0
  112. package/dist/es2019/utils/hct-color-utils/signum.js +14 -0
  113. package/dist/es2019/utils/hct-color-utils/viewing-conditions.js +78 -0
  114. package/dist/es2019/utils/hex-to-rgba-values.js +9 -0
  115. package/dist/es2019/utils/hsl-to-rgb.js +8 -0
  116. package/dist/es2019/utils/is-valid-brand-hex.js +1 -0
  117. package/dist/es2019/utils/limit-size-of-custom-style-elements.js +8 -0
  118. package/dist/es2019/utils/load-theme-css.js +7 -0
  119. package/dist/es2019/utils/relative-luminance-w3-c.js +12 -0
  120. package/dist/es2019/utils/rgb-to-hex.js +3 -0
  121. package/dist/es2019/utils/theme-loading.js +3 -8
  122. package/dist/es2019/utils/token-ids.js +3 -54
  123. package/dist/esm/artifacts/replacement-mapping.js +5 -2
  124. package/dist/esm/artifacts/tokens-raw/atlassian-motion.js +3 -3
  125. package/dist/esm/custom-theme.js +4 -58
  126. package/dist/esm/entry-points/token-metadata.codegen.js +1 -10
  127. package/dist/esm/get-custom-theme-styles.js +52 -0
  128. package/dist/esm/get-global-theme.js +1 -1
  129. package/dist/esm/get-theme-html-attrs.js +1 -1
  130. package/dist/esm/get-theme-styles.js +4 -3
  131. package/dist/esm/load-custom-theme-styles.js +1 -1
  132. package/dist/esm/set-global-theme.js +3 -2
  133. package/dist/esm/theme-color-modes.js +7 -0
  134. package/dist/esm/theme-config.js +6 -17
  135. package/dist/esm/theme-ids.js +7 -0
  136. package/dist/esm/theme-state-transformer.js +1 -1
  137. package/dist/esm/utils/color-detection.js +3 -11
  138. package/dist/esm/utils/color-utils.js +8 -40
  139. package/dist/esm/utils/custom-theme-loading-utils.js +2 -11
  140. package/dist/esm/utils/generate-custom-color-ramp.js +7 -15
  141. package/dist/esm/utils/get-alpha.js +7 -0
  142. package/dist/esm/utils/get-closest-color-index.js +14 -0
  143. package/dist/esm/utils/get-css-custom-property.js +26 -0
  144. package/dist/esm/utils/get-fully-qualified-token-id.js +13 -0
  145. package/dist/esm/utils/get-theme-override-preferences.js +5 -0
  146. package/dist/esm/utils/get-theme-preferences.js +1 -4
  147. package/dist/esm/utils/get-token-id.js +20 -0
  148. package/dist/esm/utils/hct-color-utils/argb-from-rgb.js +6 -0
  149. package/dist/esm/utils/hct-color-utils/clamp-double.js +14 -0
  150. package/dist/esm/utils/hct-color-utils/clamp-int.js +14 -0
  151. package/dist/esm/utils/hct-color-utils/color-utils.js +7 -45
  152. package/dist/esm/utils/hct-color-utils/delinearized.js +20 -0
  153. package/dist/esm/utils/hct-color-utils/hct.js +5 -87
  154. package/dist/esm/utils/hct-color-utils/lerp.js +8 -0
  155. package/dist/esm/utils/hct-color-utils/linearized.js +16 -0
  156. package/dist/esm/utils/hct-color-utils/math-utils.js +6 -105
  157. package/dist/esm/utils/hct-color-utils/matrix-multiply.js +9 -0
  158. package/dist/esm/utils/hct-color-utils/sanitize-degrees-double.js +13 -0
  159. package/dist/esm/utils/hct-color-utils/signum.js +14 -0
  160. package/dist/esm/utils/hct-color-utils/viewing-conditions.js +89 -0
  161. package/dist/esm/utils/hex-to-rgba-values.js +9 -0
  162. package/dist/esm/utils/hsl-to-rgb.js +12 -0
  163. package/dist/esm/utils/is-valid-brand-hex.js +3 -0
  164. package/dist/esm/utils/limit-size-of-custom-style-elements.js +10 -0
  165. package/dist/esm/utils/load-theme-css.js +25 -0
  166. package/dist/esm/utils/relative-luminance-w3-c.js +12 -0
  167. package/dist/esm/utils/rgb-to-hex.js +3 -0
  168. package/dist/esm/utils/theme-loading.js +3 -24
  169. package/dist/esm/utils/token-ids.js +3 -61
  170. package/dist/types/artifacts/replacement-mapping.d.ts +1 -1
  171. package/dist/types/artifacts/tokens-raw/atlassian-motion.d.ts +1 -1
  172. package/dist/types/artifacts/types-internal.d.ts +2 -2
  173. package/dist/types/artifacts/types.d.ts +2 -2
  174. package/dist/types/custom-theme.d.ts +1 -20
  175. package/dist/types/entry-points/token-metadata.codegen.d.ts +1 -1
  176. package/dist/types/get-custom-theme-styles.d.ts +16 -0
  177. package/dist/types/get-global-theme.d.ts +1 -1
  178. package/dist/types/theme-color-modes.d.ts +7 -0
  179. package/dist/types/theme-config.d.ts +4 -14
  180. package/dist/types/theme-ids.d.ts +7 -0
  181. package/dist/types/theme-state-transformer.d.ts +1 -1
  182. package/dist/types/utils/color-detection.d.ts +1 -6
  183. package/dist/types/utils/color-utils.d.ts +5 -5
  184. package/dist/types/utils/custom-theme-loading-utils.d.ts +1 -2
  185. package/dist/types/utils/generate-custom-color-ramp.d.ts +1 -2
  186. package/dist/types/utils/get-alpha.d.ts +1 -0
  187. package/dist/types/utils/get-closest-color-index.d.ts +2 -0
  188. package/dist/types/utils/get-css-custom-property.d.ts +15 -0
  189. package/dist/types/utils/get-fully-qualified-token-id.d.ts +11 -0
  190. package/dist/types/utils/get-theme-override-preferences.d.ts +2 -0
  191. package/dist/types/utils/get-theme-preferences.d.ts +1 -1
  192. package/dist/types/utils/get-token-id.d.ts +15 -0
  193. package/dist/types/utils/hct-color-utils/argb-from-rgb.d.ts +4 -0
  194. package/dist/types/utils/hct-color-utils/clamp-double.d.ts +7 -0
  195. package/dist/types/utils/hct-color-utils/clamp-int.d.ts +7 -0
  196. package/dist/types/utils/hct-color-utils/color-utils.d.ts +3 -23
  197. package/dist/types/utils/hct-color-utils/delinearized.d.ts +9 -0
  198. package/dist/types/utils/hct-color-utils/hct.d.ts +3 -48
  199. package/dist/types/utils/hct-color-utils/lerp.d.ts +6 -0
  200. package/dist/types/utils/hct-color-utils/linearized.d.ts +9 -0
  201. package/dist/types/utils/hct-color-utils/math-utils.d.ts +6 -60
  202. package/dist/types/utils/hct-color-utils/matrix-multiply.d.ts +4 -0
  203. package/dist/types/utils/hct-color-utils/sanitize-degrees-double.d.ts +7 -0
  204. package/dist/types/utils/hct-color-utils/signum.d.ts +6 -0
  205. package/dist/types/utils/hct-color-utils/viewing-conditions.d.ts +47 -0
  206. package/dist/types/utils/hex-to-rgba-values.d.ts +6 -0
  207. package/dist/types/utils/hsl-to-rgb.d.ts +1 -0
  208. package/dist/types/utils/is-valid-brand-hex.d.ts +1 -0
  209. package/dist/types/utils/limit-size-of-custom-style-elements.d.ts +1 -0
  210. package/dist/types/utils/load-theme-css.d.ts +2 -0
  211. package/dist/types/utils/relative-luminance-w3-c.d.ts +1 -0
  212. package/dist/types/utils/rgb-to-hex.d.ts +1 -0
  213. package/dist/types/utils/theme-loading.d.ts +1 -1
  214. package/dist/types/utils/token-ids.d.ts +3 -41
  215. package/dist/types-ts4.5/artifacts/replacement-mapping.d.ts +1 -1
  216. package/dist/types-ts4.5/artifacts/tokens-raw/atlassian-motion.d.ts +1 -1
  217. package/dist/types-ts4.5/artifacts/types-internal.d.ts +2 -2
  218. package/dist/types-ts4.5/artifacts/types.d.ts +2 -2
  219. package/dist/types-ts4.5/custom-theme.d.ts +1 -20
  220. package/dist/types-ts4.5/entry-points/token-metadata.codegen.d.ts +1 -1
  221. package/dist/types-ts4.5/get-custom-theme-styles.d.ts +16 -0
  222. package/dist/types-ts4.5/get-global-theme.d.ts +1 -1
  223. package/dist/types-ts4.5/theme-color-modes.d.ts +11 -0
  224. package/dist/types-ts4.5/theme-config.d.ts +4 -29
  225. package/dist/types-ts4.5/theme-ids.d.ts +18 -0
  226. package/dist/types-ts4.5/theme-state-transformer.d.ts +1 -1
  227. package/dist/types-ts4.5/utils/color-detection.d.ts +1 -6
  228. package/dist/types-ts4.5/utils/color-utils.d.ts +5 -9
  229. package/dist/types-ts4.5/utils/custom-theme-loading-utils.d.ts +1 -2
  230. package/dist/types-ts4.5/utils/generate-custom-color-ramp.d.ts +1 -2
  231. package/dist/types-ts4.5/utils/get-alpha.d.ts +1 -0
  232. package/dist/types-ts4.5/utils/get-closest-color-index.d.ts +2 -0
  233. package/dist/types-ts4.5/utils/get-css-custom-property.d.ts +15 -0
  234. package/dist/types-ts4.5/utils/get-fully-qualified-token-id.d.ts +11 -0
  235. package/dist/types-ts4.5/utils/get-theme-override-preferences.d.ts +2 -0
  236. package/dist/types-ts4.5/utils/get-theme-preferences.d.ts +1 -1
  237. package/dist/types-ts4.5/utils/get-token-id.d.ts +15 -0
  238. package/dist/types-ts4.5/utils/hct-color-utils/argb-from-rgb.d.ts +4 -0
  239. package/dist/types-ts4.5/utils/hct-color-utils/clamp-double.d.ts +7 -0
  240. package/dist/types-ts4.5/utils/hct-color-utils/clamp-int.d.ts +7 -0
  241. package/dist/types-ts4.5/utils/hct-color-utils/color-utils.d.ts +3 -23
  242. package/dist/types-ts4.5/utils/hct-color-utils/delinearized.d.ts +9 -0
  243. package/dist/types-ts4.5/utils/hct-color-utils/hct.d.ts +3 -48
  244. package/dist/types-ts4.5/utils/hct-color-utils/lerp.d.ts +6 -0
  245. package/dist/types-ts4.5/utils/hct-color-utils/linearized.d.ts +9 -0
  246. package/dist/types-ts4.5/utils/hct-color-utils/math-utils.d.ts +6 -60
  247. package/dist/types-ts4.5/utils/hct-color-utils/matrix-multiply.d.ts +4 -0
  248. package/dist/types-ts4.5/utils/hct-color-utils/sanitize-degrees-double.d.ts +7 -0
  249. package/dist/types-ts4.5/utils/hct-color-utils/signum.d.ts +6 -0
  250. package/dist/types-ts4.5/utils/hct-color-utils/viewing-conditions.d.ts +47 -0
  251. package/dist/types-ts4.5/utils/hex-to-rgba-values.d.ts +6 -0
  252. package/dist/types-ts4.5/utils/hsl-to-rgb.d.ts +5 -0
  253. package/dist/types-ts4.5/utils/is-valid-brand-hex.d.ts +1 -0
  254. package/dist/types-ts4.5/utils/limit-size-of-custom-style-elements.d.ts +1 -0
  255. package/dist/types-ts4.5/utils/load-theme-css.d.ts +2 -0
  256. package/dist/types-ts4.5/utils/relative-luminance-w3-c.d.ts +1 -0
  257. package/dist/types-ts4.5/utils/rgb-to-hex.d.ts +1 -0
  258. package/dist/types-ts4.5/utils/theme-loading.d.ts +1 -1
  259. package/dist/types-ts4.5/utils/token-ids.d.ts +3 -41
  260. package/package.json +4 -4
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.matrixMultiply = matrixMultiply;
7
+ /**
8
+ * Multiplies a 1x3 row vector with a 3x3 matrix.
9
+ */
10
+ function matrixMultiply(row, matrix) {
11
+ var a = row[0] * matrix[0][0] + row[1] * matrix[0][1] + row[2] * matrix[0][2];
12
+ var b = row[0] * matrix[1][0] + row[1] * matrix[1][1] + row[2] * matrix[1][2];
13
+ var c = row[0] * matrix[2][0] + row[1] * matrix[2][1] + row[2] * matrix[2][2];
14
+ return [a, b, c];
15
+ }
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.sanitizeDegreesDouble = sanitizeDegreesDouble;
7
+ /**
8
+ * Sanitizes a degree measure as a floating-point number.
9
+ *
10
+ * @return a degree measure between 0.0 (inclusive) and 360.0
11
+ * (exclusive).
12
+ */
13
+ function sanitizeDegreesDouble(degrees) {
14
+ degrees = degrees % 360.0;
15
+ if (degrees < 0) {
16
+ degrees = degrees + 360.0;
17
+ }
18
+ return degrees;
19
+ }
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.signum = signum;
7
+ /**
8
+ * The signum function.
9
+ *
10
+ * @return 1 if num > 0, -1 if num < 0, and 0 if num = 0
11
+ */
12
+ function signum(num) {
13
+ if (num < 0) {
14
+ return -1;
15
+ } else if (num === 0) {
16
+ return 0;
17
+ } else {
18
+ return 1;
19
+ }
20
+ }
@@ -0,0 +1,98 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ var _typeof = require("@babel/runtime/helpers/typeof");
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.ViewingConditions = void 0;
9
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
10
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
11
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
12
+ var utils = _interopRequireWildcard(require("./color-utils"));
13
+ var math = _interopRequireWildcard(require("./math-utils"));
14
+ var _ViewingConditions;
15
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
16
+ var ViewingConditions = exports.ViewingConditions = /*#__PURE__*/function () {
17
+ function ViewingConditions(n, aw, nbb, ncb, c, nc, rgbD, fl, fLRoot, z) {
18
+ (0, _classCallCheck2.default)(this, ViewingConditions);
19
+ this.n = n;
20
+ this.aw = aw;
21
+ this.nbb = nbb;
22
+ this.ncb = ncb;
23
+ this.c = c;
24
+ this.nc = nc;
25
+ this.rgbD = rgbD;
26
+ this.fl = fl;
27
+ this.fLRoot = fLRoot;
28
+ this.z = z;
29
+ }
30
+ return (0, _createClass2.default)(ViewingConditions, null, [{
31
+ key: "make",
32
+ value:
33
+ /**
34
+ * Create ViewingConditions from a simple, physically relevant, set of
35
+ * parameters.
36
+ *
37
+ * @param whitePoint White point, measured in the XYZ color space.
38
+ * default = D65, or sunny day afternoon
39
+ * @param adaptingLuminance The luminance of the adapting field. Informally,
40
+ * how bright it is in the room where the color is viewed. Can be
41
+ * calculated from lux by multiplying lux by 0.0586. default = 11.72,
42
+ * or 200 lux.
43
+ * @param backgroundLstar The lightness of the area surrounding the color.
44
+ * measured by L* in L*a*b*. default = 50.0
45
+ * @param surround A general description of the lighting surrounding the
46
+ * color. 0 is pitch dark, like watching a movie in a theater. 1.0 is a
47
+ * dimly light room, like watching TV at home at night. 2.0 means there
48
+ * is no difference between the lighting on the color and around it.
49
+ * default = 2.0
50
+ * @param discountingIlluminant Whether the eye accounts for the tint of the
51
+ * ambient lighting, such as knowing an apple is still red in green light.
52
+ * default = false, the eye does not perform this process on
53
+ * self-luminous objects like displays.
54
+ */
55
+ function make() {
56
+ var whitePoint = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : utils.whitePointD65();
57
+ var adaptingLuminance = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 200.0 / Math.PI * utils.yFromLstar(50.0) / 100.0;
58
+ var backgroundLstar = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 50.0;
59
+ var surround = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 2.0;
60
+ var discountingIlluminant = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
61
+ var xyz = whitePoint;
62
+ var rW = xyz[0] * 0.401288 + xyz[1] * 0.650173 + xyz[2] * -0.051461;
63
+ var gW = xyz[0] * -0.250268 + xyz[1] * 1.204414 + xyz[2] * 0.045854;
64
+ var bW = xyz[0] * -0.002079 + xyz[1] * 0.048952 + xyz[2] * 0.953127;
65
+ var f = 0.8 + surround / 10.0;
66
+ var c = f >= 0.9 ? math.lerp(0.59, 0.69, (f - 0.9) * 10.0) : math.lerp(0.525, 0.59, (f - 0.8) * 10.0);
67
+ var d = discountingIlluminant ? 1.0 : f * (1.0 - 1.0 / 3.6 * Math.exp((-adaptingLuminance - 42.0) / 92.0));
68
+ d = d > 1.0 ? 1.0 : d < 0.0 ? 0.0 : d;
69
+ var nc = f;
70
+ var rgbD = [d * (100.0 / rW) + 1.0 - d, d * (100.0 / gW) + 1.0 - d, d * (100.0 / bW) + 1.0 - d];
71
+ var k = 1.0 / (5.0 * adaptingLuminance + 1.0);
72
+ var k4 = k * k * k * k;
73
+ var k4F = 1.0 - k4;
74
+ var fl = k4 * adaptingLuminance + 0.1 * k4F * k4F * Math.cbrt(5.0 * adaptingLuminance);
75
+ var n = utils.yFromLstar(backgroundLstar) / whitePoint[1];
76
+ var z = 1.48 + Math.sqrt(n);
77
+ var nbb = 0.725 / Math.pow(n, 0.2);
78
+ var ncb = nbb;
79
+ var rgbAFactors = [Math.pow(fl * rgbD[0] * rW / 100.0, 0.42), Math.pow(fl * rgbD[1] * gW / 100.0, 0.42), Math.pow(fl * rgbD[2] * bW / 100.0, 0.42)];
80
+ var rgbA = [400.0 * rgbAFactors[0] / (rgbAFactors[0] + 27.13), 400.0 * rgbAFactors[1] / (rgbAFactors[1] + 27.13), 400.0 * rgbAFactors[2] / (rgbAFactors[2] + 27.13)];
81
+ var aw = (2.0 * rgbA[0] + rgbA[1] + 0.05 * rgbA[2]) * nbb;
82
+ return new ViewingConditions(n, aw, nbb, ncb, c, nc, rgbD, fl, Math.pow(fl, 0.25), z);
83
+ }
84
+
85
+ /**
86
+ * Parameters are intermediate values of the CAM16 conversion process. Their
87
+ * names are shorthand for technical color science terminology, this class
88
+ * would not benefit from documenting them individually. A brief overview
89
+ * is available in the CAM16 specification, and a complete overview requires
90
+ * a color science textbook, such as Fairchild's Color Appearance Models.
91
+ */
92
+ }]);
93
+ }();
94
+ _ViewingConditions = ViewingConditions;
95
+ /**
96
+ * sRGB-like viewing conditions.
97
+ */
98
+ (0, _defineProperty2.default)(ViewingConditions, "DEFAULT", _ViewingConditions.make());
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.hexToRGBAValues = void 0;
7
+ var hexToRGBAValues = exports.hexToRGBAValues = function hexToRGBAValues(hex) {
8
+ var hexColor = hex.replace('#', '');
9
+ return {
10
+ r: parseInt(hexColor.slice(0, 2), 16),
11
+ g: parseInt(hexColor.slice(2, 4), 16),
12
+ b: parseInt(hexColor.slice(4, 6), 16),
13
+ a: parseFloat((parseInt(hexColor.slice(6, 8), 16) / 255).toFixed(2))
14
+ };
15
+ };
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.HSLToRGB = HSLToRGB;
7
+ function HSLToRGB(h, s, l) {
8
+ s /= 100;
9
+ l /= 100;
10
+ var k = function k(n) {
11
+ return (n + h / 30) % 12;
12
+ };
13
+ var a = s * Math.min(l, 1 - l);
14
+ var f = function f(n) {
15
+ return l - a * Math.max(-1, Math.min(k(n) - 3, Math.min(9 - k(n), 1)));
16
+ };
17
+ return [255 * f(0), 255 * f(8), 255 * f(4)];
18
+ }
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.isValidBrandHex = void 0;
7
+ var isValidBrandHex = exports.isValidBrandHex = function isValidBrandHex(hex) {
8
+ return /^#[0-9A-F]{6}$/i.test(hex);
9
+ };
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.limitSizeOfCustomStyleElements = limitSizeOfCustomStyleElements;
7
+ var _constants = require("../constants");
8
+ function limitSizeOfCustomStyleElements(sizeThreshold) {
9
+ var styleTags = Array.from(document.head.querySelectorAll("style[".concat(_constants.CUSTOM_THEME_ATTRIBUTE, "][").concat(_constants.THEME_DATA_ATTRIBUTE, "]")));
10
+ if (styleTags.length < sizeThreshold) {
11
+ return;
12
+ }
13
+ styleTags.slice(0, styleTags.length - (sizeThreshold - 1)).forEach(function (element) {
14
+ return element.remove();
15
+ });
16
+ }
@@ -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.loadThemeCss = void 0;
8
+ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
9
+ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
10
+ var _themeImportMap = _interopRequireDefault(require("../artifacts/theme-import-map"));
11
+ var loadThemeCss = exports.loadThemeCss = /*#__PURE__*/function () {
12
+ var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(themeId) {
13
+ var _yield$themeImportMap, themeCss;
14
+ return _regenerator.default.wrap(function _callee$(_context) {
15
+ while (1) switch (_context.prev = _context.next) {
16
+ case 0:
17
+ _context.next = 2;
18
+ return _themeImportMap.default[themeId]();
19
+ case 2:
20
+ _yield$themeImportMap = _context.sent;
21
+ themeCss = _yield$themeImportMap.default;
22
+ return _context.abrupt("return", themeCss);
23
+ case 5:
24
+ case "end":
25
+ return _context.stop();
26
+ }
27
+ }, _callee);
28
+ }));
29
+ return function loadThemeCss(_x) {
30
+ return _ref.apply(this, arguments);
31
+ };
32
+ }();
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.relativeLuminanceW3C = relativeLuminanceW3C;
7
+ function relativeLuminanceW3C(r, g, b) {
8
+ var RsRGB = r / 255;
9
+ var GsRGB = g / 255;
10
+ var BsRGB = b / 255;
11
+ var R = RsRGB <= 0.03928 ? RsRGB / 12.92 : Math.pow((RsRGB + 0.055) / 1.055, 2.4);
12
+ var G = GsRGB <= 0.03928 ? GsRGB / 12.92 : Math.pow((GsRGB + 0.055) / 1.055, 2.4);
13
+ var B = BsRGB <= 0.03928 ? BsRGB / 12.92 : Math.pow((BsRGB + 0.055) / 1.055, 2.4);
14
+
15
+ // For the sRGB colorspace, the relative luminance of a color is defined as:
16
+ var L = 0.2126 * R + 0.7152 * G + 0.0722 * B;
17
+ return L;
18
+ }
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.rgbToHex = rgbToHex;
7
+ function rgbToHex(r, g, b) {
8
+ return '#' + ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1);
9
+ }
@@ -4,11 +4,18 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.moreContrastMediaQuery = exports.loadThemeCss = exports.loadAndAppendThemeCss = exports.darkModeMediaQuery = void 0;
7
+ exports.loadAndAppendThemeCss = exports.darkModeMediaQuery = void 0;
8
+ Object.defineProperty(exports, "loadThemeCss", {
9
+ enumerable: true,
10
+ get: function get() {
11
+ return _loadThemeCss.loadThemeCss;
12
+ }
13
+ });
14
+ exports.moreContrastMediaQuery = void 0;
8
15
  var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
9
16
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
10
- var _themeImportMap = _interopRequireDefault(require("../artifacts/theme-import-map"));
11
17
  var _constants = require("../constants");
18
+ var _loadThemeCss = require("./load-theme-css");
12
19
  var loadAndAppendThemeCss = exports.loadAndAppendThemeCss = /*#__PURE__*/function () {
13
20
  var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(themeId) {
14
21
  var themeCss, style;
@@ -28,7 +35,7 @@ var loadAndAppendThemeCss = exports.loadAndAppendThemeCss = /*#__PURE__*/functio
28
35
  return _context.abrupt("return");
29
36
  case 4:
30
37
  _context.next = 6;
31
- return loadThemeCss(themeId);
38
+ return (0, _loadThemeCss.loadThemeCss)(themeId);
32
39
  case 6:
33
40
  themeCss = _context.sent;
34
41
  style = document.createElement('style');
@@ -45,27 +52,5 @@ var loadAndAppendThemeCss = exports.loadAndAppendThemeCss = /*#__PURE__*/functio
45
52
  return _ref.apply(this, arguments);
46
53
  };
47
54
  }();
48
- var loadThemeCss = exports.loadThemeCss = /*#__PURE__*/function () {
49
- var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(themeId) {
50
- var _yield$themeImportMap, themeCss;
51
- return _regenerator.default.wrap(function _callee2$(_context2) {
52
- while (1) switch (_context2.prev = _context2.next) {
53
- case 0:
54
- _context2.next = 2;
55
- return _themeImportMap.default[themeId]();
56
- case 2:
57
- _yield$themeImportMap = _context2.sent;
58
- themeCss = _yield$themeImportMap.default;
59
- return _context2.abrupt("return", themeCss);
60
- case 5:
61
- case "end":
62
- return _context2.stop();
63
- }
64
- }, _callee2);
65
- }));
66
- return function loadThemeCss(_x2) {
67
- return _ref2.apply(this, arguments);
68
- };
69
- }();
70
55
  var darkModeMediaQuery = exports.darkModeMediaQuery = '(prefers-color-scheme: dark)';
71
56
  var moreContrastMediaQuery = exports.moreContrastMediaQuery = '(prefers-contrast: more)';
@@ -1,67 +1,26 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
3
  Object.defineProperty(exports, "__esModule", {
5
4
  value: true
6
5
  });
7
- exports.getTokenId = exports.getFullyQualifiedTokenId = 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
- };
33
-
34
- /**
35
- * Transforms a style dictionary token path to a shorthand token id
36
- * These ids will be typically be how tokens are interacted with via typescript and css
37
- *
38
- * All [default] key words will be omitted from the path
39
- *
40
- * @example <caption>Passing a path as an array</caption>
41
- * // Returns color.background.bold
42
- * getTokenId(['color', 'background', 'bold', '[default]'])
43
- *
44
- * @example <caption>Passing a path as a string</caption>
45
- * // Returns color.background.bold
46
- * getTokenId('color.background.bold.[default]')
47
- */
48
- var getTokenId = exports.getTokenId = function getTokenId(path) {
49
- var normalizedPath = typeof path === 'string' ? path.split('.') : path;
50
- return normalizedPath.filter(function (el) {
51
- return el !== '[default]';
52
- }).join('.');
53
- };
54
-
55
- /**
56
- * Transforms a style dictionary token path to a fully qualified token id
57
- * These Ids are intended to be used internal to this package by style-dictionary
58
- *
59
- * [default] key words will NOT be omitted from the path
60
- *
61
- * @example <caption>Passing a path as a string</caption>
62
- * // Returns color.background.bold.[default]
63
- * getFullyQualifiedTokenId(['color', 'background', 'bold', '[default]'])
64
- */
65
- var getFullyQualifiedTokenId = exports.getFullyQualifiedTokenId = function getFullyQualifiedTokenId(path) {
66
- return path.join('.');
67
- };
6
+ Object.defineProperty(exports, "getCSSCustomProperty", {
7
+ enumerable: true,
8
+ get: function get() {
9
+ return _getCssCustomProperty.getCSSCustomProperty;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "getFullyQualifiedTokenId", {
13
+ enumerable: true,
14
+ get: function get() {
15
+ return _getFullyQualifiedTokenId.getFullyQualifiedTokenId;
16
+ }
17
+ });
18
+ Object.defineProperty(exports, "getTokenId", {
19
+ enumerable: true,
20
+ get: function get() {
21
+ return _getTokenId.getTokenId;
22
+ }
23
+ });
24
+ var _getCssCustomProperty = require("./get-css-custom-property");
25
+ var _getTokenId = require("./get-token-id");
26
+ var _getFullyQualifiedTokenId = require("./get-fully-qualified-token-id");
@@ -12,9 +12,12 @@
12
12
  * These changes will then be picked up by our tooling which will attempt to
13
13
  * migrate as many of these renames as possible.
14
14
  *
15
- * @codegen <<SignedSource::c779b40628532228cae2ec34977f1f8e>>
15
+ * @codegen <<SignedSource::047b57f2d22a7675431a9f6acb147bf6>>
16
16
  * @codegenCommand yarn build tokens
17
17
  */
18
18
 
19
- const replacementMapper = [];
19
+ const replacementMapper = [{
20
+ "path": "motion.easing.spring",
21
+ "state": "experimental"
22
+ }];
20
23
  export default replacementMapper;
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
3
- * @codegen <<SignedSource::f86ddd91a5d48fe256274c50f5d73493>>
3
+ * @codegen <<SignedSource::33ce7f44e704e6b32332ffdfac5776e4>>
4
4
  * @codegenCommand yarn build tokens
5
5
  */
6
6
 
@@ -421,7 +421,7 @@ const tokens = [{
421
421
  }, {
422
422
  "attributes": {
423
423
  "group": "motionEasing",
424
- "state": "active",
424
+ "state": "experimental",
425
425
  "introduced": "11.5.0",
426
426
  "description": "A spring curve that overshoots slightly before settling. Use for playful, tactile feedback on small branded elements such as avatar hover, where the slight overshoot reinforces a sense of life."
427
427
  },
@@ -431,7 +431,7 @@ const tokens = [{
431
431
  "original": {
432
432
  "attributes": {
433
433
  "group": "motionEasing",
434
- "state": "active",
434
+ "state": "experimental",
435
435
  "introduced": "11.5.0",
436
436
  "description": "A spring curve that overshoots slightly before settling. Use for playful, tactile feedback on small branded elements such as avatar hover, where the slight overshoot reinforces a sense of life."
437
437
  },
@@ -1,69 +1,6 @@
1
- import { COLOR_MODE_ATTRIBUTE, CUSTOM_THEME_ATTRIBUTE } from './constants';
2
- import { themeStateDefaults } from './theme-config';
3
- import { limitSizeOfCustomStyleElements, reduceTokenMap } from './utils/custom-theme-loading-utils';
4
- import { generateColors, generateTokenMapWithContrastCheck } from './utils/generate-custom-color-ramp';
5
- import { hash } from './utils/hash';
1
+ import { getCustomThemeStyles } from './get-custom-theme-styles';
2
+ import { limitSizeOfCustomStyleElements } from './utils/limit-size-of-custom-style-elements';
6
3
  export const CUSTOM_STYLE_ELEMENTS_SIZE_THRESHOLD = 10;
7
-
8
- /**
9
- *
10
- * @param themeSchema The schema of available themes
11
- * @returns a string with the CSS for the custom theme
12
- */
13
- /**
14
- * Takes a color mode and custom branding options, and returns an array of objects for use in applying custom styles to the document head.
15
- * Only supplies the color themes necessary for initial render, based on the current themeState. I.e. if in light mode, dark mode themes are not returned.
16
- *
17
- * @param {Object<string, string>} themeState The themes and color mode that should be applied.
18
- * @param {string} themeState.colorMode Determines which color theme is applied
19
- * @param {Object} themeState.UNSAFE_themeOptions The custom branding options to be used for custom theme generation
20
- *
21
- * @returns An object array, containing theme IDs, data-attributes to attach to the theme, and the theme CSS.
22
- * If an error is encountered while loading themes, the themes array will be empty.
23
- */
24
- export function getCustomThemeStyles(themeState) {
25
- var _themeState$UNSAFE_th;
26
- const brandColor = themeState === null || themeState === void 0 ? void 0 : (_themeState$UNSAFE_th = themeState.UNSAFE_themeOptions) === null || _themeState$UNSAFE_th === void 0 ? void 0 : _themeState$UNSAFE_th.brandColor;
27
- const mode = (themeState === null || themeState === void 0 ? void 0 : themeState.colorMode) || themeStateDefaults['colorMode'];
28
- const optionString = JSON.stringify(themeState === null || themeState === void 0 ? void 0 : themeState.UNSAFE_themeOptions);
29
- const uniqueId = hash(optionString);
30
- const themeRamp = generateColors(brandColor).ramp;
31
-
32
- // outputs object to generate to CSS from
33
- const themes = [];
34
- const tokenMaps = generateTokenMapWithContrastCheck(brandColor, mode, themeRamp);
35
- if ((mode === 'light' || mode === 'auto') && tokenMaps.light) {
36
- // Light mode theming
37
- themes.push({
38
- id: 'light',
39
- attrs: {
40
- 'data-theme': 'light',
41
- 'data-custom-theme': uniqueId
42
- },
43
- css: `
44
- html[${CUSTOM_THEME_ATTRIBUTE}="${uniqueId}"][${COLOR_MODE_ATTRIBUTE}="light"][data-theme~="light:light"] {
45
- /* Branded tokens */
46
- ${reduceTokenMap(tokenMaps.light, themeRamp)}
47
- }`
48
- });
49
- }
50
- if ((mode === 'dark' || mode === 'auto') && tokenMaps.dark) {
51
- // Dark mode theming
52
- themes.push({
53
- id: 'dark',
54
- attrs: {
55
- 'data-theme': 'dark',
56
- 'data-custom-theme': uniqueId
57
- },
58
- css: `
59
- html[${CUSTOM_THEME_ATTRIBUTE}="${uniqueId}"][${COLOR_MODE_ATTRIBUTE}="dark"][data-theme~="dark:dark"] {
60
- /* Branded tokens */
61
- ${reduceTokenMap(tokenMaps.dark, themeRamp)}
62
- }`
63
- });
64
- }
65
- return themes;
66
- }
67
4
  export function loadAndAppendCustomThemeCss(themeState) {
68
5
  const themes = getCustomThemeStyles(themeState);
69
6
  limitSizeOfCustomStyleElements(CUSTOM_STYLE_ELEMENTS_SIZE_THRESHOLD);
@@ -74,4 +11,5 @@ export function loadAndAppendCustomThemeCss(themeState) {
74
11
  styleTag.dataset.customTheme = theme.attrs['data-custom-theme'];
75
12
  styleTag.textContent = theme.css;
76
13
  });
77
- }
14
+ }
15
+ export { getCustomThemeStyles } from './get-custom-theme-styles';
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * Metadata for generation of `@atlaskit/ads-mcp` and https://atlassian.design/llms-tokens.txt.
5
5
  *
6
- * @codegen <<SignedSource::84f21045f3136acc13a56a289840c82a>>
6
+ * @codegen <<SignedSource::8a97395137b2eee0fedb0ac95a7a2528>>
7
7
  * @codegenCommand yarn build tokens
8
8
  */
9
9
 
@@ -160,15 +160,6 @@ export const tokens = [{
160
160
  usage: '',
161
161
  cssProperties: []
162
162
  }
163
- }, {
164
- name: 'motion.easing.spring',
165
- path: ['motion', 'easing', 'spring'],
166
- description: 'A spring curve that overshoots slightly before settling. Use for playful, tactile feedback on small branded elements such as avatar hover, where the slight overshoot reinforces a sense of life.',
167
- exampleValue: 'linear(0, 0.021, 0.058, 0.107, 0.164, 0.227, 0.292, 0.359, 0.425, 0.49, 0.552, 0.61, 0.664, 0.714, 0.759, 0.8, 0.837, 0.869, 0.898, 0.922, 0.943, 0.961, 0.976, 0.988, 0.998, 1.006, 1.013, 1.017, 1.02, 1.023, 1.024, 1.024, 1.024, 1.024, 1.023, 1.022, 1.02, 1.019, 1.017, 1.015, 1.014, 1.012, 1.011, 1.009, 1.008, 1.007, 1.006, 1.005, 1.004, 1.003, 1.002, 1.002, 1.001, 1.001, 1.001, 1, 1, 1, 1, 1, 0.999, 0.999, 0.999, 0.999, 1)',
168
- usageGuidelines: {
169
- usage: '',
170
- cssProperties: []
171
- }
172
163
  }, {
173
164
  name: 'motion.flag.enter',
174
165
  path: ['motion', 'flag', 'enter'],
@@ -0,0 +1,60 @@
1
+ import { COLOR_MODE_ATTRIBUTE, CUSTOM_THEME_ATTRIBUTE } from './constants';
2
+ import { themeStateDefaults } from './theme-config';
3
+ import { reduceTokenMap } from './utils/custom-theme-loading-utils';
4
+ import { generateColors, generateTokenMapWithContrastCheck } from './utils/generate-custom-color-ramp';
5
+ import { hash } from './utils/hash';
6
+
7
+ /**
8
+ * Takes a color mode and custom branding options, and returns an array of objects for use in applying custom styles to the document head.
9
+ * Only supplies the color themes necessary for initial render, based on the current themeState. I.e. if in light mode, dark mode themes are not returned.
10
+ *
11
+ * @param {Object<string, string>} themeState The themes and color mode that should be applied.
12
+ * @param {string} themeState.colorMode Determines which color theme is applied
13
+ * @param {Object} themeState.UNSAFE_themeOptions The custom branding options to be used for custom theme generation
14
+ *
15
+ * @returns An object array, containing theme IDs, data-attributes to attach to the theme, and the theme CSS.
16
+ * If an error is encountered while loading themes, the themes array will be empty.
17
+ */
18
+ export function getCustomThemeStyles(themeState) {
19
+ var _themeState$UNSAFE_th;
20
+ const brandColor = themeState === null || themeState === void 0 ? void 0 : (_themeState$UNSAFE_th = themeState.UNSAFE_themeOptions) === null || _themeState$UNSAFE_th === void 0 ? void 0 : _themeState$UNSAFE_th.brandColor;
21
+ const mode = (themeState === null || themeState === void 0 ? void 0 : themeState.colorMode) || themeStateDefaults['colorMode'];
22
+ const optionString = JSON.stringify(themeState === null || themeState === void 0 ? void 0 : themeState.UNSAFE_themeOptions);
23
+ const uniqueId = hash(optionString);
24
+ const themeRamp = generateColors(brandColor).ramp;
25
+
26
+ // outputs object to generate to CSS from
27
+ const themes = [];
28
+ const tokenMaps = generateTokenMapWithContrastCheck(brandColor, mode, themeRamp);
29
+ if ((mode === 'light' || mode === 'auto') && tokenMaps.light) {
30
+ // Light mode theming
31
+ themes.push({
32
+ id: 'light',
33
+ attrs: {
34
+ 'data-theme': 'light',
35
+ 'data-custom-theme': uniqueId
36
+ },
37
+ css: `
38
+ html[${CUSTOM_THEME_ATTRIBUTE}="${uniqueId}"][${COLOR_MODE_ATTRIBUTE}="light"][data-theme~="light:light"] {
39
+ /* Branded tokens */
40
+ ${reduceTokenMap(tokenMaps.light, themeRamp)}
41
+ }`
42
+ });
43
+ }
44
+ if ((mode === 'dark' || mode === 'auto') && tokenMaps.dark) {
45
+ // Dark mode theming
46
+ themes.push({
47
+ id: 'dark',
48
+ attrs: {
49
+ 'data-theme': 'dark',
50
+ 'data-custom-theme': uniqueId
51
+ },
52
+ css: `
53
+ html[${CUSTOM_THEME_ATTRIBUTE}="${uniqueId}"][${COLOR_MODE_ATTRIBUTE}="dark"][data-theme~="dark:dark"] {
54
+ /* Branded tokens */
55
+ ${reduceTokenMap(tokenMaps.dark, themeRamp)}
56
+ }`
57
+ });
58
+ }
59
+ return themes;
60
+ }
@@ -1,5 +1,5 @@
1
1
  import { COLOR_MODE_ATTRIBUTE, THEME_DATA_ATTRIBUTE } from './constants';
2
- import { themeColorModes } from './theme-config';
2
+ import { themeColorModes } from './theme-color-modes';
3
3
  import { themeStringToObject } from './theme-state-transformer';
4
4
  const isThemeColorMode = colorMode => {
5
5
  return themeColorModes.find(mode => mode === colorMode) !== undefined;
@@ -2,8 +2,8 @@ import { fg } from '@atlaskit/platform-feature-flags';
2
2
  import { COLOR_MODE_ATTRIBUTE, CONTRAST_MODE_ATTRIBUTE, CUSTOM_THEME_ATTRIBUTE, THEME_DATA_ATTRIBUTE } from './constants';
3
3
  import { themeStateDefaults } from './theme-config';
4
4
  import { themeObjectToString } from './theme-state-transformer';
5
- import { isValidBrandHex } from './utils/color-utils';
6
5
  import { hash } from './utils/hash';
6
+ import { isValidBrandHex } from './utils/is-valid-brand-hex';
7
7
  const defaultColorMode = 'light';
8
8
  const defaultContrastMode = 'no-preference';
9
9