@atlaskit/tokens 13.1.0 → 13.1.1

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 (277) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/codemods/css-to-design-tokens/lib/colors.tsx +3 -8
  3. package/codemods/css-to-design-tokens/lib/declaration.tsx +3 -13
  4. package/codemods/css-to-design-tokens/lib/extract-between-parentheses.tsx +4 -0
  5. package/codemods/css-to-design-tokens/lib/extract-less-var-name.tsx +3 -0
  6. package/codemods/css-to-design-tokens/lib/get-css-var-meta.tsx +13 -0
  7. package/codemods/css-to-design-tokens/lib/get-named-color-meta.tsx +5 -0
  8. package/codemods/css-to-design-tokens/lib/get-raw-color-meta.tsx +11 -0
  9. package/codemods/css-to-design-tokens/lib/is-css-declaration.tsx +3 -0
  10. package/codemods/css-to-design-tokens/lib/is-known-css-variable.tsx +5 -0
  11. package/codemods/css-to-design-tokens/lib/known-named-colors.tsx +150 -0
  12. package/codemods/css-to-design-tokens/lib/known-raw-colors.tsx +17 -0
  13. package/codemods/css-to-design-tokens/lib/known-variables.tsx +167 -0
  14. package/codemods/css-to-design-tokens/lib/legacy-colors.tsx +3 -335
  15. package/codemods/css-to-design-tokens/lib/meta.tsx +3 -28
  16. package/codemods/css-to-design-tokens/lib/split-css-value.tsx +4 -0
  17. package/codemods/css-to-design-tokens/lib/value.tsx +6 -9
  18. package/codemods/css-to-design-tokens/transform.tsx +3 -1
  19. package/dist/cjs/artifacts/palettes-raw/palette.js +35 -1
  20. package/dist/cjs/entry-points/theme-state-transformer.js +4 -3
  21. package/dist/cjs/get-custom-theme-styles.js +7 -6
  22. package/dist/cjs/get-global-theme.js +2 -2
  23. package/dist/cjs/get-theme-html-attrs.js +2 -2
  24. package/dist/cjs/index.js +4 -3
  25. package/dist/cjs/is-color-mode.js +9 -0
  26. package/dist/cjs/is-theme-ids.js +12 -0
  27. package/dist/cjs/is-theme-kind.js +12 -0
  28. package/dist/cjs/theme-config.js +8 -44
  29. package/dist/cjs/theme-object-to-string.js +42 -0
  30. package/dist/cjs/theme-options-schema.js +1 -0
  31. package/dist/cjs/theme-state-defaults.js +39 -0
  32. package/dist/cjs/theme-state.js +5 -0
  33. package/dist/cjs/theme-string-to-object.js +51 -0
  34. package/dist/cjs/utils/additional-contrast-checker.js +43 -0
  35. package/dist/cjs/utils/custom-theme-loading-utils.js +0 -22
  36. package/dist/cjs/utils/custom-theme-token-contrast-check.js +2 -40
  37. package/dist/cjs/utils/delta-e.js +26 -0
  38. package/dist/cjs/utils/generate-colors.js +47 -0
  39. package/dist/cjs/utils/generate-token-map-with-contrast-check.js +32 -0
  40. package/dist/cjs/utils/{generate-custom-color-ramp.js → generate-token-map.js} +6 -75
  41. package/dist/cjs/utils/get-closest-color-index.js +3 -2
  42. package/dist/cjs/utils/get-contrast-ratio.js +22 -0
  43. package/dist/cjs/utils/hct-color-utils/alpha-from-argb.js +12 -0
  44. package/dist/cjs/utils/hct-color-utils/argb-from-linrgb.js +17 -0
  45. package/dist/cjs/utils/hct-color-utils/argb-from-lstar.js +21 -0
  46. package/dist/cjs/utils/hct-color-utils/argb-from-rgba.js +24 -0
  47. package/dist/cjs/utils/hct-color-utils/argb-from-xyz.js +29 -0
  48. package/dist/cjs/utils/hct-color-utils/blue-from-argb.js +12 -0
  49. package/dist/cjs/utils/hct-color-utils/clamp-component.js +15 -0
  50. package/dist/cjs/utils/hct-color-utils/contrast.js +10 -11
  51. package/dist/cjs/utils/hct-color-utils/green-from-argb.js +12 -0
  52. package/dist/cjs/utils/hct-color-utils/hct.js +18 -12
  53. package/dist/cjs/utils/hct-color-utils/index.js +4 -3
  54. package/dist/cjs/utils/hct-color-utils/lab-f.js +15 -0
  55. package/dist/cjs/utils/hct-color-utils/lab-invf.js +16 -0
  56. package/dist/cjs/utils/hct-color-utils/lstar-from-argb.js +34 -0
  57. package/dist/cjs/utils/hct-color-utils/lstar-from-y.js +21 -0
  58. package/dist/cjs/utils/hct-color-utils/red-from-argb.js +12 -0
  59. package/dist/cjs/utils/hct-color-utils/rgba-from-argb.js +28 -0
  60. package/dist/cjs/utils/hct-color-utils/rgba.js +1 -0
  61. package/dist/cjs/utils/hct-color-utils/viewing-conditions.js +5 -4
  62. package/dist/cjs/utils/hct-color-utils/white-point-d65.js +14 -0
  63. package/dist/cjs/utils/hct-color-utils/y-from-lstar.js +21 -0
  64. package/dist/cjs/utils/hex-to-hsl.js +52 -0
  65. package/dist/cjs/utils/hex-to-rgb-a.js +20 -0
  66. package/dist/cjs/utils/hex-to-rgb.js +19 -0
  67. package/dist/cjs/utils/is-valid-hex.js +10 -0
  68. package/dist/cjs/utils/reduce-token-map.js +18 -0
  69. package/dist/cjs/utils/rgb-to-lab.js +24 -0
  70. package/dist/es2019/artifacts/palettes-raw/palette.js +35 -1
  71. package/dist/es2019/entry-points/theme-state-transformer.js +2 -1
  72. package/dist/es2019/get-custom-theme-styles.js +3 -2
  73. package/dist/es2019/get-global-theme.js +1 -1
  74. package/dist/es2019/get-theme-html-attrs.js +1 -1
  75. package/dist/es2019/index.js +2 -1
  76. package/dist/es2019/is-color-mode.js +3 -0
  77. package/dist/es2019/is-theme-ids.js +4 -0
  78. package/dist/es2019/is-theme-kind.js +4 -0
  79. package/dist/es2019/theme-config.js +4 -45
  80. package/dist/es2019/theme-object-to-string.js +28 -0
  81. package/dist/es2019/theme-options-schema.js +0 -0
  82. package/dist/es2019/theme-state-defaults.js +34 -0
  83. package/dist/es2019/theme-state.js +1 -0
  84. package/dist/es2019/theme-string-to-object.js +38 -0
  85. package/dist/es2019/utils/additional-contrast-checker.js +39 -0
  86. package/dist/es2019/utils/custom-theme-loading-utils.js +1 -11
  87. package/dist/es2019/utils/custom-theme-token-contrast-check.js +1 -41
  88. package/dist/es2019/utils/delta-e.js +20 -0
  89. package/dist/es2019/utils/generate-colors.js +39 -0
  90. package/dist/es2019/utils/generate-token-map-with-contrast-check.js +21 -0
  91. package/dist/es2019/utils/{generate-custom-color-ramp.js → generate-token-map.js} +3 -63
  92. package/dist/es2019/utils/get-closest-color-index.js +2 -1
  93. package/dist/es2019/utils/get-contrast-ratio.js +16 -0
  94. package/dist/es2019/utils/hct-color-utils/alpha-from-argb.js +6 -0
  95. package/dist/es2019/utils/hct-color-utils/argb-from-linrgb.js +12 -0
  96. package/dist/es2019/utils/hct-color-utils/argb-from-lstar.js +16 -0
  97. package/dist/es2019/utils/hct-color-utils/argb-from-rgba.js +19 -0
  98. package/dist/es2019/utils/hct-color-utils/argb-from-xyz.js +24 -0
  99. package/dist/es2019/utils/hct-color-utils/blue-from-argb.js +6 -0
  100. package/dist/es2019/utils/hct-color-utils/clamp-component.js +9 -0
  101. package/dist/es2019/utils/hct-color-utils/contrast.js +10 -10
  102. package/dist/es2019/utils/hct-color-utils/green-from-argb.js +6 -0
  103. package/dist/es2019/utils/hct-color-utils/hct.js +19 -12
  104. package/dist/es2019/utils/hct-color-utils/index.js +2 -1
  105. package/dist/es2019/utils/hct-color-utils/lab-f.js +9 -0
  106. package/dist/es2019/utils/hct-color-utils/lab-invf.js +10 -0
  107. package/dist/es2019/utils/hct-color-utils/lstar-from-argb.js +28 -0
  108. package/dist/es2019/utils/hct-color-utils/lstar-from-y.js +16 -0
  109. package/dist/es2019/utils/hct-color-utils/red-from-argb.js +6 -0
  110. package/dist/es2019/utils/hct-color-utils/rgba-from-argb.js +22 -0
  111. package/dist/es2019/utils/hct-color-utils/rgba.js +0 -0
  112. package/dist/es2019/utils/hct-color-utils/viewing-conditions.js +4 -3
  113. package/dist/es2019/utils/hct-color-utils/white-point-d65.js +8 -0
  114. package/dist/es2019/utils/hct-color-utils/y-from-lstar.js +16 -0
  115. package/dist/es2019/utils/hex-to-hsl.js +46 -0
  116. package/dist/es2019/utils/hex-to-rgb-a.js +14 -0
  117. package/dist/es2019/utils/hex-to-rgb.js +13 -0
  118. package/dist/es2019/utils/is-valid-hex.js +2 -0
  119. package/dist/es2019/utils/reduce-token-map.js +7 -0
  120. package/dist/es2019/utils/rgb-to-lab.js +18 -0
  121. package/dist/esm/artifacts/palettes-raw/palette.js +35 -1
  122. package/dist/esm/entry-points/theme-state-transformer.js +2 -1
  123. package/dist/esm/get-custom-theme-styles.js +3 -2
  124. package/dist/esm/get-global-theme.js +1 -1
  125. package/dist/esm/get-theme-html-attrs.js +1 -1
  126. package/dist/esm/index.js +2 -1
  127. package/dist/esm/is-color-mode.js +3 -0
  128. package/dist/esm/is-theme-ids.js +6 -0
  129. package/dist/esm/is-theme-kind.js +6 -0
  130. package/dist/esm/theme-config.js +4 -45
  131. package/dist/esm/theme-object-to-string.js +35 -0
  132. package/dist/esm/theme-options-schema.js +0 -0
  133. package/dist/esm/theme-state-defaults.js +34 -0
  134. package/dist/esm/theme-state.js +1 -0
  135. package/dist/esm/theme-string-to-object.js +44 -0
  136. package/dist/esm/utils/additional-contrast-checker.js +36 -0
  137. package/dist/esm/utils/custom-theme-loading-utils.js +1 -15
  138. package/dist/esm/utils/custom-theme-token-contrast-check.js +1 -38
  139. package/dist/esm/utils/delta-e.js +20 -0
  140. package/dist/esm/utils/generate-colors.js +40 -0
  141. package/dist/esm/utils/generate-token-map-with-contrast-check.js +25 -0
  142. package/dist/esm/utils/{generate-custom-color-ramp.js → generate-token-map.js} +3 -67
  143. package/dist/esm/utils/get-closest-color-index.js +2 -1
  144. package/dist/esm/utils/get-contrast-ratio.js +16 -0
  145. package/dist/esm/utils/hct-color-utils/alpha-from-argb.js +6 -0
  146. package/dist/esm/utils/hct-color-utils/argb-from-linrgb.js +12 -0
  147. package/dist/esm/utils/hct-color-utils/argb-from-lstar.js +16 -0
  148. package/dist/esm/utils/hct-color-utils/argb-from-rgba.js +18 -0
  149. package/dist/esm/utils/hct-color-utils/argb-from-xyz.js +24 -0
  150. package/dist/esm/utils/hct-color-utils/blue-from-argb.js +6 -0
  151. package/dist/esm/utils/hct-color-utils/clamp-component.js +9 -0
  152. package/dist/esm/utils/hct-color-utils/contrast.js +10 -10
  153. package/dist/esm/utils/hct-color-utils/green-from-argb.js +6 -0
  154. package/dist/esm/utils/hct-color-utils/hct.js +19 -12
  155. package/dist/esm/utils/hct-color-utils/index.js +2 -1
  156. package/dist/esm/utils/hct-color-utils/lab-f.js +9 -0
  157. package/dist/esm/utils/hct-color-utils/lab-invf.js +10 -0
  158. package/dist/esm/utils/hct-color-utils/lstar-from-argb.js +28 -0
  159. package/dist/esm/utils/hct-color-utils/lstar-from-y.js +16 -0
  160. package/dist/esm/utils/hct-color-utils/red-from-argb.js +6 -0
  161. package/dist/esm/utils/hct-color-utils/rgba-from-argb.js +22 -0
  162. package/dist/esm/utils/hct-color-utils/rgba.js +0 -0
  163. package/dist/esm/utils/hct-color-utils/viewing-conditions.js +5 -4
  164. package/dist/esm/utils/hct-color-utils/white-point-d65.js +8 -0
  165. package/dist/esm/utils/hct-color-utils/y-from-lstar.js +16 -0
  166. package/dist/esm/utils/hex-to-hsl.js +46 -0
  167. package/dist/esm/utils/hex-to-rgb-a.js +14 -0
  168. package/dist/esm/utils/hex-to-rgb.js +13 -0
  169. package/dist/esm/utils/is-valid-hex.js +4 -0
  170. package/dist/esm/utils/reduce-token-map.js +11 -0
  171. package/dist/esm/utils/rgb-to-lab.js +18 -0
  172. package/dist/types/artifacts/palettes-raw/palette.d.ts +1 -1
  173. package/dist/types/entry-points/theme-state-transformer.d.ts +2 -1
  174. package/dist/types/index.d.ts +2 -1
  175. package/dist/types/is-color-mode.d.ts +2 -0
  176. package/dist/types/is-theme-ids.d.ts +2 -0
  177. package/dist/types/is-theme-kind.d.ts +4 -0
  178. package/dist/types/theme-color-modes.d.ts +1 -0
  179. package/dist/types/theme-config.d.ts +8 -40
  180. package/dist/types/theme-ids.d.ts +1 -0
  181. package/dist/types/theme-object-to-string.d.ts +13 -0
  182. package/dist/types/theme-options-schema.d.ts +7 -0
  183. package/dist/types/theme-state-defaults.d.ts +14 -0
  184. package/dist/types/theme-state.d.ts +17 -0
  185. package/dist/types/{theme-state-transformer.d.ts → theme-string-to-object.d.ts} +0 -12
  186. package/dist/types/utils/additional-contrast-checker.d.ts +9 -0
  187. package/dist/types/utils/custom-theme-loading-utils.d.ts +1 -6
  188. package/dist/types/utils/custom-theme-token-contrast-check.d.ts +0 -9
  189. package/dist/types/utils/delta-e.d.ts +1 -0
  190. package/dist/types/utils/generate-colors.d.ts +5 -0
  191. package/dist/types/utils/{generate-custom-color-ramp.d.ts → generate-token-map-with-contrast-check.d.ts} +1 -6
  192. package/dist/types/utils/generate-token-map.d.ts +9 -0
  193. package/dist/types/utils/get-contrast-ratio.d.ts +1 -0
  194. package/dist/types/utils/hct-color-utils/alpha-from-argb.d.ts +4 -0
  195. package/dist/types/utils/hct-color-utils/argb-from-linrgb.d.ts +4 -0
  196. package/dist/types/utils/hct-color-utils/argb-from-lstar.d.ts +8 -0
  197. package/dist/types/utils/hct-color-utils/argb-from-rgba.d.ts +8 -0
  198. package/dist/types/utils/hct-color-utils/argb-from-xyz.d.ts +4 -0
  199. package/dist/types/utils/hct-color-utils/blue-from-argb.d.ts +4 -0
  200. package/dist/types/utils/hct-color-utils/clamp-component.d.ts +1 -0
  201. package/dist/types/utils/hct-color-utils/green-from-argb.d.ts +4 -0
  202. package/dist/types/utils/hct-color-utils/index.d.ts +2 -1
  203. package/dist/types/utils/hct-color-utils/lab-f.d.ts +1 -0
  204. package/dist/types/utils/hct-color-utils/lab-invf.d.ts +1 -0
  205. package/dist/types/utils/hct-color-utils/lstar-from-argb.d.ts +7 -0
  206. package/dist/types/utils/hct-color-utils/lstar-from-y.d.ts +12 -0
  207. package/dist/types/utils/hct-color-utils/red-from-argb.d.ts +4 -0
  208. package/dist/types/utils/hct-color-utils/rgba-from-argb.d.ts +8 -0
  209. package/dist/types/utils/hct-color-utils/rgba.d.ts +14 -0
  210. package/dist/types/utils/hct-color-utils/white-point-d65.d.ts +6 -0
  211. package/dist/types/utils/hct-color-utils/y-from-lstar.d.ts +12 -0
  212. package/dist/types/utils/hex-to-hsl.d.ts +1 -0
  213. package/dist/types/utils/hex-to-rgb-a.d.ts +1 -0
  214. package/dist/types/utils/hex-to-rgb.d.ts +1 -0
  215. package/dist/types/utils/is-valid-hex.d.ts +1 -0
  216. package/dist/types/utils/reduce-token-map.d.ts +6 -0
  217. package/dist/types/utils/rgb-to-lab.d.ts +1 -0
  218. package/dist/types-ts4.5/artifacts/palettes-raw/palette.d.ts +1 -1
  219. package/dist/types-ts4.5/entry-points/theme-state-transformer.d.ts +2 -1
  220. package/dist/types-ts4.5/index.d.ts +2 -1
  221. package/dist/types-ts4.5/is-color-mode.d.ts +2 -0
  222. package/dist/types-ts4.5/is-theme-ids.d.ts +2 -0
  223. package/dist/types-ts4.5/is-theme-kind.d.ts +11 -0
  224. package/dist/types-ts4.5/theme-color-modes.d.ts +1 -0
  225. package/dist/types-ts4.5/theme-config.d.ts +8 -40
  226. package/dist/types-ts4.5/theme-ids.d.ts +1 -0
  227. package/dist/types-ts4.5/theme-object-to-string.d.ts +13 -0
  228. package/dist/types-ts4.5/theme-options-schema.d.ts +7 -0
  229. package/dist/types-ts4.5/theme-state-defaults.d.ts +14 -0
  230. package/dist/types-ts4.5/theme-state.d.ts +17 -0
  231. package/dist/types-ts4.5/{theme-state-transformer.d.ts → theme-string-to-object.d.ts} +0 -12
  232. package/dist/types-ts4.5/utils/additional-contrast-checker.d.ts +9 -0
  233. package/dist/types-ts4.5/utils/custom-theme-loading-utils.d.ts +1 -6
  234. package/dist/types-ts4.5/utils/custom-theme-token-contrast-check.d.ts +0 -9
  235. package/dist/types-ts4.5/utils/delta-e.d.ts +1 -0
  236. package/dist/types-ts4.5/utils/generate-colors.d.ts +5 -0
  237. package/dist/types-ts4.5/utils/{generate-custom-color-ramp.d.ts → generate-token-map-with-contrast-check.d.ts} +1 -8
  238. package/dist/types-ts4.5/utils/generate-token-map.d.ts +11 -0
  239. package/dist/types-ts4.5/utils/get-contrast-ratio.d.ts +1 -0
  240. package/dist/types-ts4.5/utils/hct-color-utils/alpha-from-argb.d.ts +4 -0
  241. package/dist/types-ts4.5/utils/hct-color-utils/argb-from-linrgb.d.ts +4 -0
  242. package/dist/types-ts4.5/utils/hct-color-utils/argb-from-lstar.d.ts +8 -0
  243. package/dist/types-ts4.5/utils/hct-color-utils/argb-from-rgba.d.ts +8 -0
  244. package/dist/types-ts4.5/utils/hct-color-utils/argb-from-xyz.d.ts +4 -0
  245. package/dist/types-ts4.5/utils/hct-color-utils/blue-from-argb.d.ts +4 -0
  246. package/dist/types-ts4.5/utils/hct-color-utils/clamp-component.d.ts +1 -0
  247. package/dist/types-ts4.5/utils/hct-color-utils/green-from-argb.d.ts +4 -0
  248. package/dist/types-ts4.5/utils/hct-color-utils/index.d.ts +2 -1
  249. package/dist/types-ts4.5/utils/hct-color-utils/lab-f.d.ts +1 -0
  250. package/dist/types-ts4.5/utils/hct-color-utils/lab-invf.d.ts +1 -0
  251. package/dist/types-ts4.5/utils/hct-color-utils/lstar-from-argb.d.ts +7 -0
  252. package/dist/types-ts4.5/utils/hct-color-utils/lstar-from-y.d.ts +12 -0
  253. package/dist/types-ts4.5/utils/hct-color-utils/red-from-argb.d.ts +4 -0
  254. package/dist/types-ts4.5/utils/hct-color-utils/rgba-from-argb.d.ts +8 -0
  255. package/dist/types-ts4.5/utils/hct-color-utils/rgba.d.ts +14 -0
  256. package/dist/types-ts4.5/utils/hct-color-utils/white-point-d65.d.ts +6 -0
  257. package/dist/types-ts4.5/utils/hct-color-utils/y-from-lstar.d.ts +12 -0
  258. package/dist/types-ts4.5/utils/hex-to-hsl.d.ts +5 -0
  259. package/dist/types-ts4.5/utils/hex-to-rgb-a.d.ts +6 -0
  260. package/dist/types-ts4.5/utils/hex-to-rgb.d.ts +5 -0
  261. package/dist/types-ts4.5/utils/is-valid-hex.d.ts +1 -0
  262. package/dist/types-ts4.5/utils/reduce-token-map.d.ts +6 -0
  263. package/dist/types-ts4.5/utils/rgb-to-lab.d.ts +5 -0
  264. package/package.json +5 -5
  265. package/dist/cjs/theme-state-transformer.js +0 -93
  266. package/dist/cjs/utils/color-utils.js +0 -176
  267. package/dist/cjs/utils/hct-color-utils/color-utils.js +0 -279
  268. package/dist/es2019/theme-state-transformer.js +0 -70
  269. package/dist/es2019/utils/color-utils.js +0 -136
  270. package/dist/es2019/utils/hct-color-utils/color-utils.js +0 -249
  271. package/dist/esm/theme-state-transformer.js +0 -86
  272. package/dist/esm/utils/color-utils.js +0 -138
  273. package/dist/esm/utils/hct-color-utils/color-utils.js +0 -248
  274. package/dist/types/utils/color-utils.d.ts +0 -10
  275. package/dist/types/utils/hct-color-utils/color-utils.d.ts +0 -88
  276. package/dist/types-ts4.5/utils/color-utils.d.ts +0 -23
  277. package/dist/types-ts4.5/utils/hct-color-utils/color-utils.d.ts +0 -88
@@ -0,0 +1,24 @@
1
+ import { argbFromRgb } from './argb-from-rgb';
2
+ import { delinearized } from './delinearized';
3
+
4
+ /**
5
+ * Color science utilities.
6
+ *
7
+ * Utility methods for color science constants and color space
8
+ * conversions that aren't HCT or CAM16.
9
+ */
10
+ const XYZ_TO_SRGB = [[3.2413774792388685, -1.5376652402851851, -0.49885366846268053], [-0.9691452513005321, 1.8758853451067872, 0.04156585616912061], [0.05562093689691305, -0.20395524564742123, 1.0571799111220335]];
11
+
12
+ /**
13
+ * Converts a color from ARGB to XYZ.
14
+ */
15
+ export function argbFromXyz(x, y, z) {
16
+ const matrix = XYZ_TO_SRGB;
17
+ const linearR = matrix[0][0] * x + matrix[0][1] * y + matrix[0][2] * z;
18
+ const linearG = matrix[1][0] * x + matrix[1][1] * y + matrix[1][2] * z;
19
+ const linearB = matrix[2][0] * x + matrix[2][1] * y + matrix[2][2] * z;
20
+ const r = delinearized(linearR);
21
+ const g = delinearized(linearG);
22
+ const b = delinearized(linearB);
23
+ return argbFromRgb(r, g, b);
24
+ }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Returns the blue component of a color in ARGB format.
3
+ */
4
+ export function blueFromArgb(argb) {
5
+ return argb & 255;
6
+ }
@@ -0,0 +1,9 @@
1
+ export function clampComponent(value) {
2
+ if (value < 0) {
3
+ return 0;
4
+ }
5
+ if (value > 255) {
6
+ return 255;
7
+ }
8
+ return value;
9
+ }
@@ -26,9 +26,9 @@
26
26
  //
27
27
  // tslint:disable:class-as-namespace
28
28
 
29
- import * as utils from './color-utils';
30
- import * as math from './math-utils';
31
-
29
+ import { clampDouble } from './clamp-double';
30
+ import { lstarFromY } from './lstar-from-y';
31
+ import { yFromLstar } from './y-from-lstar';
32
32
  /**
33
33
  * Utility methods for calculating contrast given two colors, or calculating a
34
34
  * color given one color and a contrast ratio.
@@ -49,9 +49,9 @@ export class Contrast {
49
49
  * @param toneB Tone between 0 and 100. Values outside will be clamped.
50
50
  */
51
51
  static ratioOfTones(toneA, toneB) {
52
- toneA = math.clampDouble(0.0, 100.0, toneA);
53
- toneB = math.clampDouble(0.0, 100.0, toneB);
54
- return Contrast.ratioOfYs(utils.yFromLstar(toneA), utils.yFromLstar(toneB));
52
+ toneA = clampDouble(0.0, 100.0, toneA);
53
+ toneB = clampDouble(0.0, 100.0, toneB);
54
+ return Contrast.ratioOfYs(yFromLstar(toneA), yFromLstar(toneB));
55
55
  }
56
56
  static ratioOfYs(y1, y2) {
57
57
  const lighter = y1 > y2 ? y1 : y2;
@@ -73,7 +73,7 @@ export class Contrast {
73
73
  if (tone < 0.0 || tone > 100.0) {
74
74
  return -1.0;
75
75
  }
76
- const darkY = utils.yFromLstar(tone);
76
+ const darkY = yFromLstar(tone);
77
77
  const lightY = ratio * (darkY + 5.0) - 5.0;
78
78
  const realContrast = Contrast.ratioOfYs(lightY, darkY);
79
79
  const delta = Math.abs(realContrast - ratio);
@@ -83,7 +83,7 @@ export class Contrast {
83
83
 
84
84
  // Ensure gamut mapping, which requires a 'range' on tone, will still result
85
85
  // the correct ratio by darkening slightly.
86
- const returnValue = utils.lstarFromY(lightY) + 0.4;
86
+ const returnValue = lstarFromY(lightY) + 0.4;
87
87
  if (returnValue < 0 || returnValue > 100) {
88
88
  return -1;
89
89
  }
@@ -104,7 +104,7 @@ export class Contrast {
104
104
  if (tone < 0.0 || tone > 100.0) {
105
105
  return -1.0;
106
106
  }
107
- const lightY = utils.yFromLstar(tone);
107
+ const lightY = yFromLstar(tone);
108
108
  const darkY = (lightY + 5.0) / ratio - 5.0;
109
109
  const realContrast = Contrast.ratioOfYs(lightY, darkY);
110
110
  const delta = Math.abs(realContrast - ratio);
@@ -114,7 +114,7 @@ export class Contrast {
114
114
 
115
115
  // Ensure gamut mapping, which requires a 'range' on tone, will still result
116
116
  // the correct ratio by darkening slightly.
117
- const returnValue = utils.lstarFromY(darkY) - 0.4;
117
+ const returnValue = lstarFromY(darkY) - 0.4;
118
118
  if (returnValue < 0 || returnValue > 100) {
119
119
  return -1;
120
120
  }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Returns the green component of a color in ARGB format.
3
+ */
4
+ export function greenFromArgb(argb) {
5
+ return argb >> 8 & 255;
6
+ }
@@ -21,9 +21,16 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
21
21
  * limitations under the License.
22
22
  */
23
23
 
24
- import * as utils from './color-utils';
24
+ import { argbFromLinrgb } from './argb-from-linrgb';
25
+ import { argbFromLstar } from './argb-from-lstar';
26
+ import { argbFromXyz } from './argb-from-xyz';
27
+ import { linearized } from './linearized';
28
+ import { lstarFromArgb } from './lstar-from-argb';
29
+ import { lstarFromY } from './lstar-from-y';
25
30
  import * as math from './math-utils';
26
31
  import { ViewingConditions } from './viewing-conditions';
32
+ import { yFromLstar } from './y-from-lstar';
33
+
27
34
  /**
28
35
  * A color system built using CAM16 hue and chroma, and L* from
29
36
  * L*a*b*.
@@ -119,13 +126,13 @@ export class Hct {
119
126
  const cam = Cam16.fromInt(argb);
120
127
  this.internalHue = cam.hue;
121
128
  this.internalChroma = cam.chroma;
122
- this.internalTone = utils.lstarFromArgb(argb);
129
+ this.internalTone = lstarFromArgb(argb);
123
130
  }
124
131
  setInternalState(argb) {
125
132
  const cam = Cam16.fromInt(argb);
126
133
  this.internalHue = cam.hue;
127
134
  this.internalChroma = cam.chroma;
128
- this.internalTone = utils.lstarFromArgb(argb);
135
+ this.internalTone = lstarFromArgb(argb);
129
136
  this.argb = argb;
130
137
  }
131
138
 
@@ -154,7 +161,7 @@ export class Hct {
154
161
  // 3. Create HCT from:
155
162
  // - CAM16 using default VC with XYZ coordinates in specified VC.
156
163
  // - L* converted from Y in XYZ coordinates in specified VC.
157
- const recastHct = Hct.from(recastInVc.hue, recastInVc.chroma, utils.lstarFromY(viewedInVc[1]));
164
+ const recastHct = Hct.from(recastInVc.hue, recastInVc.chroma, lstarFromY(viewedInVc[1]));
158
165
  return recastHct;
159
166
  }
160
167
  }
@@ -243,9 +250,9 @@ class Cam16 {
243
250
  const red = (argb & 0x00ff0000) >> 16;
244
251
  const green = (argb & 0x0000ff00) >> 8;
245
252
  const blue = argb & 0x000000ff;
246
- const redL = utils.linearized(red);
247
- const greenL = utils.linearized(green);
248
- const blueL = utils.linearized(blue);
253
+ const redL = linearized(red);
254
+ const greenL = linearized(green);
255
+ const blueL = linearized(blue);
249
256
  const x = 0.41233895 * redL + 0.35762064 * greenL + 0.18051042 * blueL;
250
257
  const y = 0.2126 * redL + 0.7152 * greenL + 0.0722 * blueL;
251
258
  const z = 0.01932141 * redL + 0.11916382 * greenL + 0.95034478 * blueL;
@@ -392,7 +399,7 @@ class Cam16 {
392
399
  const x = 1.86206786 * rF - 1.01125463 * gF + 0.14918677 * bF;
393
400
  const y = 0.38752654 * rF + 0.62144744 * gF - 0.00897398 * bF;
394
401
  const z = -0.0158415 * rF - 0.03412294 * gF + 1.04996444 * bF;
395
- const argb = utils.argbFromXyz(x, y, z);
402
+ const argb = argbFromXyz(x, y, z);
396
403
  return argb;
397
404
  }
398
405
 
@@ -801,7 +808,7 @@ class HctSolver {
801
808
  if (linrgb[0] > 100.01 || linrgb[1] > 100.01 || linrgb[2] > 100.01) {
802
809
  return 0;
803
810
  }
804
- return utils.argbFromLinrgb(linrgb);
811
+ return argbFromLinrgb(linrgb);
805
812
  }
806
813
  // Iterates with Newton method,
807
814
  // Using 2 * fn(j) / j as the approximation of fn'(j)
@@ -824,17 +831,17 @@ class HctSolver {
824
831
  */
825
832
  static solveToInt(hueDegrees, chroma, lstar) {
826
833
  if (chroma < 0.0001 || lstar < 0.0001 || lstar > 99.9999) {
827
- return utils.argbFromLstar(lstar);
834
+ return argbFromLstar(lstar);
828
835
  }
829
836
  hueDegrees = math.sanitizeDegreesDouble(hueDegrees);
830
837
  const hueRadians = hueDegrees / 180 * Math.PI;
831
- const y = utils.yFromLstar(lstar);
838
+ const y = yFromLstar(lstar);
832
839
  const exactAnswer = HctSolver.findResultByJ(hueRadians, chroma, y);
833
840
  if (exactAnswer !== 0) {
834
841
  return exactAnswer;
835
842
  }
836
843
  const linrgb = HctSolver.bisectToLimit(y, hueRadians);
837
- return utils.argbFromLinrgb(linrgb);
844
+ return argbFromLinrgb(linrgb);
838
845
  }
839
846
 
840
847
  /**
@@ -1,3 +1,4 @@
1
1
  export { Hct } from './hct';
2
2
  export { Contrast } from './contrast';
3
- export { argbFromRgba, rgbaFromArgb } from './color-utils';
3
+ export { argbFromRgba } from './argb-from-rgba';
4
+ export { rgbaFromArgb } from './rgba-from-argb';
@@ -0,0 +1,9 @@
1
+ export function labF(t) {
2
+ const e = 216.0 / 24389.0;
3
+ const kappa = 24389.0 / 27.0;
4
+ if (t > e) {
5
+ return Math.pow(t, 1.0 / 3.0);
6
+ } else {
7
+ return (kappa * t + 16) / 116;
8
+ }
9
+ }
@@ -0,0 +1,10 @@
1
+ export function labInvf(ft) {
2
+ const e = 216.0 / 24389.0;
3
+ const kappa = 24389.0 / 27.0;
4
+ const ft3 = ft * ft * ft;
5
+ if (ft3 > e) {
6
+ return ft3;
7
+ } else {
8
+ return (116 * ft - 16) / kappa;
9
+ }
10
+ }
@@ -0,0 +1,28 @@
1
+ import { blueFromArgb } from './blue-from-argb';
2
+ import { greenFromArgb } from './green-from-argb';
3
+ import { labF } from './lab-f';
4
+ import { linearized } from './linearized';
5
+ import { matrixMultiply } from './matrix-multiply';
6
+ import { redFromArgb } from './red-from-argb';
7
+ const SRGB_TO_XYZ = [[0.41233895, 0.35762064, 0.18051042], [0.2126, 0.7152, 0.0722], [0.01932141, 0.11916382, 0.95034478]];
8
+
9
+ /**
10
+ * Converts a color from XYZ to ARGB.
11
+ */
12
+ function xyzFromArgb(argb) {
13
+ const r = linearized(redFromArgb(argb));
14
+ const g = linearized(greenFromArgb(argb));
15
+ const b = linearized(blueFromArgb(argb));
16
+ return matrixMultiply([r, g, b], SRGB_TO_XYZ);
17
+ }
18
+
19
+ /**
20
+ * Computes the L* value of a color in ARGB representation.
21
+ *
22
+ * @param argb ARGB representation of a color
23
+ * @return L*, from L*a*b*, coordinate of the color
24
+ */
25
+ export function lstarFromArgb(argb) {
26
+ const y = xyzFromArgb(argb)[1];
27
+ return 116.0 * labF(y / 100.0) - 16.0;
28
+ }
@@ -0,0 +1,16 @@
1
+ import { labF } from './lab-f';
2
+
3
+ /**
4
+ * Converts a Y value to an L* value.
5
+ *
6
+ * L* in L*a*b* and Y in XYZ measure the same quantity, luminance.
7
+ *
8
+ * L* measures perceptual luminance, a linear scale. Y in XYZ
9
+ * measures relative luminance, a logarithmic scale.
10
+ *
11
+ * @param y Y in XYZ
12
+ * @return L* in L*a*b*
13
+ */
14
+ export function lstarFromY(y) {
15
+ return labF(y / 100.0) * 116.0 - 16.0;
16
+ }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Returns the red component of a color in ARGB format.
3
+ */
4
+ export function redFromArgb(argb) {
5
+ return argb >> 16 & 255;
6
+ }
@@ -0,0 +1,22 @@
1
+ import { alphaFromArgb } from './alpha-from-argb';
2
+ import { blueFromArgb } from './blue-from-argb';
3
+ import { greenFromArgb } from './green-from-argb';
4
+ import { redFromArgb } from './red-from-argb';
5
+ /**
6
+ * Return RGBA from a given int32 color
7
+ *
8
+ * @param argb ARGB representation of a int32 color.
9
+ * @return RGBA representation of a int32 color.
10
+ */
11
+ export function rgbaFromArgb(argb) {
12
+ const r = redFromArgb(argb);
13
+ const g = greenFromArgb(argb);
14
+ const b = blueFromArgb(argb);
15
+ const a = alphaFromArgb(argb);
16
+ return {
17
+ r,
18
+ g,
19
+ b,
20
+ a
21
+ };
22
+ }
File without changes
@@ -1,7 +1,8 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  var _ViewingConditions;
3
- import * as utils from './color-utils';
4
3
  import * as math from './math-utils';
4
+ import { whitePointD65 } from './white-point-d65';
5
+ import { yFromLstar } from './y-from-lstar';
5
6
  export class ViewingConditions {
6
7
  /**
7
8
  * Create ViewingConditions from a simple, physically relevant, set of
@@ -25,7 +26,7 @@ export class ViewingConditions {
25
26
  * default = false, the eye does not perform this process on
26
27
  * self-luminous objects like displays.
27
28
  */
28
- static make(whitePoint = utils.whitePointD65(), adaptingLuminance = 200.0 / Math.PI * utils.yFromLstar(50.0) / 100.0, backgroundLstar = 50.0, surround = 2.0, discountingIlluminant = false) {
29
+ static make(whitePoint = whitePointD65(), adaptingLuminance = 200.0 / Math.PI * yFromLstar(50.0) / 100.0, backgroundLstar = 50.0, surround = 2.0, discountingIlluminant = false) {
29
30
  const xyz = whitePoint;
30
31
  const rW = xyz[0] * 0.401288 + xyz[1] * 0.650173 + xyz[2] * -0.051461;
31
32
  const gW = xyz[0] * -0.250268 + xyz[1] * 1.204414 + xyz[2] * 0.045854;
@@ -40,7 +41,7 @@ export class ViewingConditions {
40
41
  const k4 = k * k * k * k;
41
42
  const k4F = 1.0 - k4;
42
43
  const fl = k4 * adaptingLuminance + 0.1 * k4F * k4F * Math.cbrt(5.0 * adaptingLuminance);
43
- const n = utils.yFromLstar(backgroundLstar) / whitePoint[1];
44
+ const n = yFromLstar(backgroundLstar) / whitePoint[1];
44
45
  const z = 1.48 + Math.sqrt(n);
45
46
  const nbb = 0.725 / Math.pow(n, 0.2);
46
47
  const ncb = nbb;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Returns the standard white point; white on a sunny day.
3
+ *
4
+ * @return The white point
5
+ */
6
+ export function whitePointD65() {
7
+ return [95.047, 100.0, 108.883];
8
+ }
@@ -0,0 +1,16 @@
1
+ import { labInvf } from './lab-invf';
2
+
3
+ /**
4
+ * Converts an L* value to a Y value.
5
+ *
6
+ * L* in L*a*b* and Y in XYZ measure the same quantity, luminance.
7
+ *
8
+ * L* measures perceptual luminance, a linear scale. Y in XYZ
9
+ * measures relative luminance, a logarithmic scale.
10
+ *
11
+ * @param lstar L* in L*a*b*
12
+ * @return Y in XYZ
13
+ */
14
+ export function yFromLstar(lstar) {
15
+ return 100.0 * labInvf((lstar + 16.0) / 116.0);
16
+ }
@@ -0,0 +1,46 @@
1
+ import { isValidHex } from './is-valid-hex';
2
+ export function hexToHSL(hex) {
3
+ if (!isValidHex(hex)) {
4
+ throw new Error('Invalid HEX');
5
+ }
6
+ let r = 0,
7
+ g = 0,
8
+ b = 0;
9
+ if (hex.length === 4) {
10
+ r = '0x' + hex[1] + hex[1];
11
+ g = '0x' + hex[2] + hex[2];
12
+ b = '0x' + hex[3] + hex[3];
13
+ } else if (hex.length === 7) {
14
+ r = '0x' + hex[1] + hex[2];
15
+ g = '0x' + hex[3] + hex[4];
16
+ b = '0x' + hex[5] + hex[6];
17
+ }
18
+ // Then to HSL
19
+ r /= 255;
20
+ g /= 255;
21
+ b /= 255;
22
+ let cmin = Math.min(r, g, b),
23
+ cmax = Math.max(r, g, b),
24
+ delta = cmax - cmin,
25
+ h = 0,
26
+ s = 0,
27
+ l = 0;
28
+ if (delta === 0) {
29
+ h = 0;
30
+ } else if (cmax === r) {
31
+ h = (g - b) / delta % 6;
32
+ } else if (cmax === g) {
33
+ h = (b - r) / delta + 2;
34
+ } else {
35
+ h = (r - g) / delta + 4;
36
+ }
37
+ h = Math.round(h * 60);
38
+ if (h < 0) {
39
+ h += 360;
40
+ }
41
+ l = (cmax + cmin) / 2;
42
+ s = delta === 0 ? 0 : delta / (1 - Math.abs(2 * l - 1));
43
+ s = +(s * 100).toFixed(1);
44
+ l = +(l * 100).toFixed(1);
45
+ return [h, s, l];
46
+ }
@@ -0,0 +1,14 @@
1
+ import { getAlpha } from './get-alpha';
2
+ import { isValidHex } from './is-valid-hex';
3
+ export function hexToRgbA(hex) {
4
+ if (!isValidHex(hex)) {
5
+ throw new Error('Invalid HEX');
6
+ }
7
+ let c;
8
+ c = hex.substring(1).split('');
9
+ if (c.length === 3) {
10
+ c = [c[0], c[0], c[1], c[1], c[2], c[2]];
11
+ }
12
+ c = '0x' + c.join('');
13
+ return [c >> 16 & 255, c >> 8 & 255, c & 255, getAlpha(hex)];
14
+ }
@@ -0,0 +1,13 @@
1
+ import { isValidHex } from './is-valid-hex';
2
+ export function hexToRgb(hex) {
3
+ if (!isValidHex(hex)) {
4
+ throw new Error('Invalid HEX');
5
+ }
6
+ let c;
7
+ c = hex.substring(1).split('');
8
+ if (c.length === 3) {
9
+ c = [c[0], c[0], c[1], c[1], c[2], c[2]];
10
+ }
11
+ c = '0x' + c.join('');
12
+ return [c >> 16 & 255, c >> 8 & 255, c & 255];
13
+ }
@@ -0,0 +1,2 @@
1
+ // valid hex color with 4, 6 or 8 digits
2
+ export const isValidHex = hex => /^#([A-Fa-f0-9]{3,4}){1,2}$/.test(hex);
@@ -0,0 +1,7 @@
1
+ import tokens from '../artifacts/token-names';
2
+ export function reduceTokenMap(tokenMap, themeRamp) {
3
+ return Object.entries(tokenMap).reduce((acc, [key, value]) => {
4
+ const cssVar = tokens[key];
5
+ return cssVar ? `${acc}\n ${cssVar}: ${typeof value === 'string' ? value : themeRamp[value]};` : acc;
6
+ }, '');
7
+ }
@@ -0,0 +1,18 @@
1
+ export function rgbToLab(rgb) {
2
+ let r = rgb[0] / 255,
3
+ g = rgb[1] / 255,
4
+ b = rgb[2] / 255,
5
+ x,
6
+ y,
7
+ z;
8
+ r = r > 0.04045 ? Math.pow((r + 0.055) / 1.055, 2.4) : r / 12.92;
9
+ g = g > 0.04045 ? Math.pow((g + 0.055) / 1.055, 2.4) : g / 12.92;
10
+ b = b > 0.04045 ? Math.pow((b + 0.055) / 1.055, 2.4) : b / 12.92;
11
+ x = (r * 0.4124 + g * 0.3576 + b * 0.1805) / 0.95047;
12
+ y = (r * 0.2126 + g * 0.7152 + b * 0.0722) / 1.0;
13
+ z = (r * 0.0193 + g * 0.1192 + b * 0.9505) / 1.08883;
14
+ x = x > 0.008856 ? Math.pow(x, 1 / 3) : 7.787 * x + 16 / 116;
15
+ y = y > 0.008856 ? Math.pow(y, 1 / 3) : 7.787 * y + 16 / 116;
16
+ z = z > 0.008856 ? Math.pow(z, 1 / 3) : 7.787 * z + 16 / 116;
17
+ return [116 * y - 16, 500 * (x - y), 200 * (y - z)];
18
+ }
@@ -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::3ab6d06ceee07a33f01831ba39d1781a>>
3
+ * @codegen <<SignedSource::53794f446833e9543b9fc09809fc6844>>
4
4
  * @codegenCommand yarn build tokens
5
5
  */
6
6
 
@@ -2044,6 +2044,23 @@ var tokens = [{
2044
2044
  },
2045
2045
  "name": "color.palette.Neutral1100",
2046
2046
  "path": ["color", "palette", "Neutral1100"]
2047
+ }, {
2048
+ "value": "#000000",
2049
+ "attributes": {
2050
+ "group": "palette",
2051
+ "category": "light mode neutral"
2052
+ },
2053
+ "filePath": "schema/palettes/palette.tsx",
2054
+ "isSource": true,
2055
+ "original": {
2056
+ "value": "#000000",
2057
+ "attributes": {
2058
+ "group": "palette",
2059
+ "category": "light mode neutral"
2060
+ }
2061
+ },
2062
+ "name": "color.palette.Neutral1200",
2063
+ "path": ["color", "palette", "Neutral1200"]
2047
2064
  }, {
2048
2065
  "value": "#17171708",
2049
2066
  "attributes": {
@@ -2384,6 +2401,23 @@ var tokens = [{
2384
2401
  },
2385
2402
  "name": "color.palette.DarkNeutral1100",
2386
2403
  "path": ["color", "palette", "DarkNeutral1100"]
2404
+ }, {
2405
+ "value": "#FFFFFF",
2406
+ "attributes": {
2407
+ "group": "palette",
2408
+ "category": "dark mode neutral"
2409
+ },
2410
+ "filePath": "schema/palettes/palette.tsx",
2411
+ "isSource": true,
2412
+ "original": {
2413
+ "value": "#FFFFFF",
2414
+ "attributes": {
2415
+ "group": "palette",
2416
+ "category": "dark mode neutral"
2417
+ }
2418
+ },
2419
+ "name": "color.palette.DarkNeutral1200",
2420
+ "path": ["color", "palette", "DarkNeutral1200"]
2387
2421
  }, {
2388
2422
  "value": "#01040475",
2389
2423
  "attributes": {
@@ -1 +1,2 @@
1
- export { themeStringToObject, themeObjectToString } from '../theme-state-transformer';
1
+ export { themeStringToObject } from '../theme-string-to-object';
2
+ export { themeObjectToString } from '../theme-object-to-string';
@@ -1,8 +1,9 @@
1
1
  import { COLOR_MODE_ATTRIBUTE, CUSTOM_THEME_ATTRIBUTE } from './constants';
2
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';
3
+ import { generateColors } from './utils/generate-colors';
4
+ import { generateTokenMapWithContrastCheck } from './utils/generate-token-map-with-contrast-check';
5
5
  import { hash } from './utils/hash';
6
+ import { reduceTokenMap } from './utils/reduce-token-map';
6
7
 
7
8
  /**
8
9
  * Takes a color mode and custom branding options, and returns an array of objects for use in applying custom styles to the document head.
@@ -3,7 +3,7 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
3
3
  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) { _defineProperty(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; }
4
4
  import { COLOR_MODE_ATTRIBUTE, THEME_DATA_ATTRIBUTE } from './constants';
5
5
  import { themeColorModes } from './theme-color-modes';
6
- import { themeStringToObject } from './theme-state-transformer';
6
+ import { themeStringToObject } from './theme-string-to-object';
7
7
  var isThemeColorMode = function isThemeColorMode(colorMode) {
8
8
  return themeColorModes.find(function (mode) {
9
9
  return mode === colorMode;
@@ -4,7 +4,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
4
4
  import { fg } from '@atlaskit/platform-feature-flags';
5
5
  import { COLOR_MODE_ATTRIBUTE, CONTRAST_MODE_ATTRIBUTE, CUSTOM_THEME_ATTRIBUTE, THEME_DATA_ATTRIBUTE } from './constants';
6
6
  import { themeStateDefaults } from './theme-config';
7
- import { themeObjectToString } from './theme-state-transformer';
7
+ import { themeObjectToString } from './theme-object-to-string';
8
8
  import { hash } from './utils/hash';
9
9
  import { isValidBrandHex } from './utils/is-valid-brand-hex';
10
10
  var defaultColorMode = 'light';
package/dist/esm/index.js CHANGED
@@ -9,6 +9,7 @@ export { default as getSSRAutoScript } from './get-ssr-auto-script';
9
9
  export { default as useThemeObserver } from './use-theme-observer';
10
10
  export { default as ThemeMutationObserver } from './theme-mutation-observer';
11
11
  export { default as getGlobalTheme } from './get-global-theme';
12
- export { themeStringToObject, themeObjectToString } from './theme-state-transformer';
12
+ export { themeStringToObject } from './theme-string-to-object';
13
+ export { themeObjectToString } from './theme-object-to-string';
13
14
  export { default as themeImportMap } from './artifacts/theme-import-map';
14
15
  export { COLOR_MODE_ATTRIBUTE, CURRENT_SURFACE_CSS_VAR, SUBTREE_THEME_ATTRIBUTE, THEME_DATA_ATTRIBUTE } from './constants';
@@ -0,0 +1,3 @@
1
+ export var isColorMode = function isColorMode(modeId) {
2
+ return ['light', 'dark', 'auto'].includes(modeId);
3
+ };
@@ -0,0 +1,6 @@
1
+ import { themeIds } from './theme-ids';
2
+ export var isThemeIds = function isThemeIds(themeId) {
3
+ return themeIds.find(function (id) {
4
+ return id === themeId;
5
+ }) !== undefined;
6
+ };
@@ -0,0 +1,6 @@
1
+ var themeKinds = ['light', 'dark', 'spacing', 'typography', 'shape', 'motion'];
2
+ export var isThemeKind = function isThemeKind(themeKind) {
3
+ return themeKinds.find(function (kind) {
4
+ return kind === themeKind;
5
+ }) !== undefined;
6
+ };