@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
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @atlaskit/tokens
2
2
 
3
+ ## 13.1.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [`e92deb020eae0`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/e92deb020eae0) -
8
+ Add `Neutral1200` and `DarkNeutral1200` base palette tokens and update generated raw palette
9
+ artifacts.
10
+
3
11
  ## 13.1.0
4
12
 
5
13
  ### Minor Changes
@@ -1,4 +1,4 @@
1
- import { knownNamedColors, knownVariables } from './legacy-colors';
1
+ import { knownNamedColors } from './known-named-colors';
2
2
 
3
3
  const NAMED_COLORS = Object.keys(knownNamedColors);
4
4
  const GRADIENT_TYPES = ['linear', 'radial', 'conic'] as const;
@@ -48,9 +48,6 @@ const REGEXES = {
48
48
  /^\s*(#([0-9a-f]{3}){1,2}|(rgba|hsla)\(\s*\d{1,3}%?\s*(,\s*\d{1,3}%?\s*){2},\s*-?\d*\.?\d+\s*\)|(rgb|hsl)\(\s*\d{1,3}%?\s*(,\s*\d{1,3}%?\s*){2}\)\s*|(lab|lch)\(\s*\d{1,3}%?\s+\d{1,3}%?\s+\d{1,3}%?\s*\)|hwb\(\s*\d{1,3}\s+\d{1,3}%?\s+\d{1,3}%?\s*\))\s*$/i,
49
49
  };
50
50
 
51
- export function isKnownCssVariable(value: string): boolean {
52
- return value in knownVariables;
53
- }
54
51
  export function isRawColor(value: string): boolean {
55
52
  return REGEXES.RAW_COLOR.test(value);
56
53
  }
@@ -60,10 +57,8 @@ export function isNamedColor(value: string): boolean {
60
57
  export function isGradient(value: string): boolean {
61
58
  return GRADIENT_TYPES.some((gradient) => value.startsWith(`${gradient}-gradient(`));
62
59
  }
63
- export function extractBetweenParentheses(value: string): string {
64
- const match = value.match(/\((.*?)\)/);
65
- return match ? match[1] : '';
66
- }
67
60
  export function isLessFunction(value: string): boolean {
68
61
  return LESS_COLOR_FUNCTIONS.some((func) => value.startsWith(`${func}(`));
69
62
  }
63
+ export { isKnownCssVariable } from './is-known-css-variable';
64
+ export { extractBetweenParentheses } from './extract-between-parentheses';
@@ -25,19 +25,9 @@ export function isColorRelatedProperty(prop: string): boolean {
25
25
  return COLOR_PROPERTIES.some((property) => property === prop);
26
26
  }
27
27
 
28
- export function isCssDeclaration(prop: string): boolean {
29
- return prop.startsWith('--');
30
- }
31
-
32
28
  export function extractCssVarName(prop: string): string {
33
29
  return prop.substring(prop.indexOf('(') + 1).split(/\,|\)/)[0];
34
30
  }
35
-
36
- export function extractLessVarName(prop: string): string {
37
- return prop.substring(1);
38
- }
39
-
40
- export function splitCssValue(value: string): RegExpMatchArray | null {
41
- const regex = /(?:[^\s()]+|\((?:[^()]+|\([^()]*\))*\))+/g;
42
- return value.match(regex);
43
- }
31
+ export { isCssDeclaration } from './is-css-declaration';
32
+ export { extractLessVarName } from './extract-less-var-name';
33
+ export { splitCssValue } from './split-css-value';
@@ -0,0 +1,4 @@
1
+ export function extractBetweenParentheses(value: string): string {
2
+ const match = value.match(/\((.*?)\)/);
3
+ return match ? match[1] : '';
4
+ }
@@ -0,0 +1,3 @@
1
+ export function extractLessVarName(prop: string): string {
2
+ return prop.substring(1);
3
+ }
@@ -0,0 +1,13 @@
1
+ import { extractCssVarName } from './declaration';
2
+ import { knownVariables } from './known-variables';
3
+
4
+ export function getCssVarMeta(cssVariable: string): string[] {
5
+ const tokenName = extractCssVarName(cssVariable);
6
+ const meta = knownVariables[tokenName];
7
+
8
+ if (!meta || meta.length === 0) {
9
+ return tokenName.split('-');
10
+ }
11
+
12
+ return meta;
13
+ }
@@ -0,0 +1,5 @@
1
+ import { knownNamedColors } from './known-named-colors';
2
+
3
+ export function getNamedColorMeta(namedColor: string): string[] {
4
+ return knownNamedColors[namedColor] ?? [];
5
+ }
@@ -0,0 +1,11 @@
1
+ import { knownRawColors } from './known-raw-colors';
2
+
3
+ export function getRawColorMeta(rawColor: string): string[] {
4
+ let cleanColor = rawColor.toLowerCase();
5
+
6
+ if (cleanColor.length === 4) {
7
+ cleanColor = cleanColor + cleanColor.substring(cleanColor.indexOf('#') + 1);
8
+ }
9
+
10
+ return knownRawColors[cleanColor] ?? [];
11
+ }
@@ -0,0 +1,3 @@
1
+ export function isCssDeclaration(prop: string): boolean {
2
+ return prop.startsWith('--');
3
+ }
@@ -0,0 +1,5 @@
1
+ import { knownVariables } from './known-variables';
2
+
3
+ export function isKnownCssVariable(value: string): boolean {
4
+ return value in knownVariables;
5
+ }
@@ -0,0 +1,150 @@
1
+ export const knownNamedColors: Record<string, string[]> = {
2
+ aliceblue: ['blue'],
3
+ antiquewhite: [],
4
+ aqua: ['teal'],
5
+ aquamarine: ['teal'],
6
+ azure: ['teal', 'subtlest'],
7
+ beige: [],
8
+ bisque: [],
9
+ black: [],
10
+ blanchedalmond: [],
11
+ blue: ['blue'],
12
+ blueviolet: ['blue'],
13
+ brown: [],
14
+ burlywood: [],
15
+ cadetblue: ['blue'],
16
+ chartreuse: [],
17
+ chocolate: [],
18
+ coral: [],
19
+ cornflowerblue: ['blue'],
20
+ cornsilk: [],
21
+ crimson: ['red'],
22
+ cyan: ['accent', 'teal', 'subtle'],
23
+ darkblue: ['accent', 'blue', 'bold'],
24
+ darkcyan: ['accent', 'teal', 'bold'],
25
+ darkgoldenrod: [],
26
+ darkgray: [],
27
+ darkgrey: [],
28
+ darkgreen: ['green'],
29
+ darkkhaki: [],
30
+ darkmagenta: ['magenta', 'bold'],
31
+ darkolivegreen: ['green'],
32
+ darkorange: [],
33
+ darkorchid: [],
34
+ darkred: ['accent', 'red', 'bold'],
35
+ darksalmon: [],
36
+ darkseagreen: ['green'],
37
+ darkslateblue: [],
38
+ darkslategray: [],
39
+ darkslategrey: [],
40
+ darkturquoise: ['teal', 'bold'],
41
+ darkviolet: ['purple', 'bold'],
42
+ deeppink: ['magenta'],
43
+ deepskyblue: ['blue'],
44
+ dimgray: [],
45
+ dimgrey: [],
46
+ dodgerblue: [],
47
+ firebrick: ['red', 'bold'],
48
+ floralwhite: [],
49
+ forestgreen: ['green'],
50
+ fuchsia: ['magenta', 'subtle'],
51
+ gainsboro: [],
52
+ ghostwhite: [],
53
+ gold: ['yellow'],
54
+ goldenrod: [],
55
+ gray: [],
56
+ grey: [],
57
+ green: ['green'],
58
+ greenyellow: [],
59
+ honeydew: [],
60
+ hotpink: ['magenta'],
61
+ indianred: [],
62
+ indigo: ['purple'],
63
+ ivory: [],
64
+ khaki: [],
65
+ lavender: ['purple'],
66
+ lavenderblush: ['purple'],
67
+ lawngreen: ['green'],
68
+ lemonchiffon: [],
69
+ lightblue: [],
70
+ lightcoral: [],
71
+ lightcyan: [],
72
+ lightgoldenrodyellow: [],
73
+ lightgray: [],
74
+ lightgrey: [],
75
+ lightgreen: ['green', 'accent'],
76
+ lightpink: ['magenta'],
77
+ lightsalmon: ['pink', 'subtler'],
78
+ lightseagreen: ['green'],
79
+ lightskyblue: ['blue', 'accent'],
80
+ lightslategray: [],
81
+ lightslategrey: [],
82
+ lightsteelblue: ['blue'],
83
+ lightyellow: [],
84
+ lime: ['green', 'subtler'],
85
+ limegreen: ['green'],
86
+ linen: [],
87
+ magenta: ['magenta'],
88
+ maroon: [],
89
+ mediumaquamarine: [],
90
+ mediumblue: [],
91
+ mediumorchid: [],
92
+ mediumpurple: [],
93
+ mediumseagreen: ['green'],
94
+ mediumslateblue: [],
95
+ mediumspringgreen: ['green'],
96
+ mediumturquoise: [],
97
+ mediumvioletred: [],
98
+ midnightblue: [],
99
+ mintcream: [],
100
+ mistyrose: [],
101
+ moccasin: [],
102
+ navajowhite: [],
103
+ navy: ['blue', 'bold'],
104
+ oldlace: [],
105
+ olive: [],
106
+ olivedrab: [],
107
+ orange: [],
108
+ orangered: [],
109
+ orchid: ['purple'],
110
+ palegoldenrod: [],
111
+ palegreen: ['green'],
112
+ paleturquoise: [],
113
+ palevioletred: [],
114
+ papayawhip: [],
115
+ peachpuff: [],
116
+ peru: [],
117
+ pink: ['magenta'],
118
+ plum: [],
119
+ powderblue: ['blue', 'subtle'],
120
+ purple: ['purple'],
121
+ rebeccapurple: ['purple', 'accent'],
122
+ red: ['red', 'accent'],
123
+ rosybrown: [],
124
+ royalblue: [],
125
+ saddlebrown: [],
126
+ salmon: [],
127
+ sandybrown: [],
128
+ seagreen: ['green'],
129
+ seashell: [],
130
+ sienna: [],
131
+ silver: [],
132
+ skyblue: ['blue', 'subtlest'],
133
+ slateblue: [],
134
+ slategray: [],
135
+ slategrey: [],
136
+ snow: [],
137
+ springgreen: ['green'],
138
+ steelblue: ['blue'],
139
+ tan: [],
140
+ teal: ['accent', 'teal'],
141
+ thistle: [],
142
+ tomato: ['red'],
143
+ turquoise: [],
144
+ violet: ['purple'],
145
+ wheat: [],
146
+ white: ['elevation', 'surface'],
147
+ whitesmoke: [],
148
+ yellow: ['yellow'],
149
+ yellowgreen: ['yellow'],
150
+ };
@@ -0,0 +1,17 @@
1
+ export const knownRawColors: Record<string, string[]> = {
2
+ '#cccccc': ['gray'],
3
+ '#aaaaaa': ['gray', 'subtlest'],
4
+ '#bbbbbb': ['gray', 'subtle'],
5
+ '#ffffff': ['elevation', 'surface'],
6
+ '#f0f0f0': ['elevation', 'surface'],
7
+ '#eeeeee': ['elevation', 'surface', 'sunken'],
8
+ '#ff0000': ['danger'],
9
+ '#d04437': ['danger'],
10
+ '#c00c00': ['danger'],
11
+ '#5243aa': ['discovery'],
12
+ '#ffc712': ['warning'],
13
+ '#00f00f': ['brand'],
14
+ '#3b73af': ['brand'],
15
+ '#326ca6': ['brand'],
16
+ '#0052cc': ['brand'],
17
+ };
@@ -0,0 +1,167 @@
1
+ export const knownVariables: Record<string, string[]> = {
2
+ '--adg3-color-R50': ['danger'],
3
+ '--adg3-color-R75': ['danger'],
4
+ '--adg3-color-R100': ['danger'],
5
+ '--adg3-color-R200': ['danger'],
6
+ '--adg3-color-R300': ['danger'],
7
+ '--adg3-color-R400': ['danger'],
8
+ '--adg3-color-R500': ['danger'],
9
+ '--adg3-color-Y50': ['warning'],
10
+ '--adg3-color-Y75': ['warning'],
11
+ '--adg3-color-Y100': ['warning'],
12
+ '--adg3-color-Y200': ['warning'],
13
+ '--adg3-color-Y300': ['warning'],
14
+ '--adg3-color-Y400': ['warning'],
15
+ '--adg3-color-Y500': ['warning'],
16
+ '--adg3-color-G50': ['success'],
17
+ '--adg3-color-G75': ['success'],
18
+ '--adg3-color-G100': ['success'],
19
+ '--adg3-color-G200': ['success'],
20
+ '--adg3-color-G300': ['success'],
21
+ '--adg3-color-G400': ['success'],
22
+ '--adg3-color-G500': ['success'],
23
+ '--adg3-color-B50': ['brand'],
24
+ '--adg3-color-B75': ['brand'],
25
+ '--adg3-color-B100': ['brand'],
26
+ '--adg3-color-B200': ['brand'],
27
+ '--adg3-color-B300': ['brand'],
28
+ '--adg3-color-B400': ['brand'],
29
+ '--adg3-color-B500': ['brand'],
30
+ '--adg3-color-P50': ['discovery'],
31
+ '--adg3-color-P75': ['discovery'],
32
+ '--adg3-color-P100': ['discovery'],
33
+ '--adg3-color-P200': ['discovery'],
34
+ '--adg3-color-P300': ['discovery'],
35
+ '--adg3-color-P400': ['discovery'],
36
+ '--adg3-color-P500': ['discovery'],
37
+ '--adg3-color-T50': ['accent', 'teal'],
38
+ '--adg3-color-T75': ['accent', 'teal'],
39
+ '--adg3-color-T100': ['accent', 'teal'],
40
+ '--adg3-color-T200': ['accent', 'teal'],
41
+ '--adg3-color-T300': ['accent', 'teal'],
42
+ '--adg3-color-T400': ['accent', 'teal'],
43
+ '--adg3-color-T500': ['accent', 'teal'],
44
+ '--adg3-color-N0': ['inverse'],
45
+ '--adg3-color-N10': [],
46
+ '--adg3-color-N20': [],
47
+ '--adg3-color-N30': [],
48
+ '--adg3-color-N40': [],
49
+ '--adg3-color-N50': [],
50
+ '--adg3-color-N60': [],
51
+ '--adg3-color-N70': [],
52
+ '--adg3-color-N80': [],
53
+ '--adg3-color-N90': [],
54
+ '--adg3-color-N100': [],
55
+ '--adg3-color-N200': ['text', 'subtlest'],
56
+ '--adg3-color-N300': [],
57
+ '--adg3-color-N400': ['text', 'subtle'],
58
+ '--adg3-color-N500': [],
59
+ '--adg3-color-N600': [],
60
+ '--adg3-color-N700': ['text'],
61
+ '--adg3-color-N800': ['text'],
62
+ '--adg3-color-N900': ['text'],
63
+ '--adg3-color-N10A': [],
64
+ '--adg3-color-N20A': [],
65
+ '--adg3-color-N30A': [],
66
+ '--adg3-color-N40A': [],
67
+ '--adg3-color-N50A': [],
68
+ '--adg3-color-N60A': [],
69
+ '--adg3-color-N70A': [],
70
+ '--adg3-color-N80A': [],
71
+ '--adg3-color-N90A': [],
72
+ '--adg3-color-N100A': [],
73
+ '--adg3-color-N200A': [],
74
+ '--adg3-color-N300A': [],
75
+ '--adg3-color-N400A': [],
76
+ '--adg3-color-N500A': [],
77
+ '--adg3-color-N600A': [],
78
+ '--adg3-color-N700A': [],
79
+ '--adg3-color-N800A': [],
80
+ '--adg3-color-DN900': [],
81
+ '--adg3-color-DN800': [],
82
+ '--adg3-color-DN700': [],
83
+ '--adg3-color-DN600': [],
84
+ '--adg3-color-DN500': [],
85
+ '--adg3-color-DN400': [],
86
+ '--adg3-color-DN300': [],
87
+ '--adg3-color-DN200': [],
88
+ '--adg3-color-DN100': [],
89
+ '--adg3-color-DN90': [],
90
+ '--adg3-color-DN80': [],
91
+ '--adg3-color-DN70': [],
92
+ '--adg3-color-DN60': [],
93
+ '--adg3-color-DN50': [],
94
+ '--adg3-color-DN40': [],
95
+ '--adg3-color-DN30': [],
96
+ '--adg3-color-DN20': [],
97
+ '--adg3-color-DN10': [],
98
+ '--adg3-color-DN0': [],
99
+ '--adg3-color-DN800A': [],
100
+ '--adg3-color-DN700A': [],
101
+ '--adg3-color-DN600A': [],
102
+ '--adg3-color-DN500A': [],
103
+ '--adg3-color-DN400A': [],
104
+ '--adg3-color-DN300A': [],
105
+ '--adg3-color-DN200A': [],
106
+ '--adg3-color-DN100A': [],
107
+ '--adg3-color-DN90A': [],
108
+ '--adg3-color-DN80A': [],
109
+ '--adg3-color-DN70A': [],
110
+ '--adg3-color-DN60A': [],
111
+ '--adg3-color-DN50A': [],
112
+ '--adg3-color-DN40A': [],
113
+ '--adg3-color-DN30A': [],
114
+ '--adg3-color-DN20A': [],
115
+ '--adg3-color-DN10A': [],
116
+
117
+ '--adg3-color-background-light': ['elevation', 'surface'],
118
+ '--adg3-color-background-dark': ['elevation', 'surface'],
119
+ '--adg3-color-text-light': ['text'],
120
+ '--adg3-color-text-dark': ['text'],
121
+ '--adg3-color-subtleText-light': ['text', 'subtle'],
122
+ '--adg3-color-subtleText-dark': ['text', 'subtle'],
123
+ '--adg3-color-placeholderText-light': ['text', 'subtlest'],
124
+ '--adg3-color-placeholderText-dark': ['text', 'subtlest'],
125
+ '--adg3-color-heading-light': ['text'],
126
+ '--adg3-color-heading-dark': ['text'],
127
+ '--adg3-color-subtleHeading-light': ['text', 'subtle'],
128
+ '--adg3-color-subtleHeading-dark': ['text', 'subtle'],
129
+ '--adg3-color-codeBlock-light': ['elevation', 'surface', 'sunken'],
130
+ '--adg3-color-codeBlock-dark': ['elevation', 'surface', 'sunken'],
131
+ '--adg3-color-link-light': ['link'],
132
+ '--adg3-color-link-dark': ['link'],
133
+ '--adg3-color-linkHover-light': ['link'],
134
+ '--adg3-color-linkHover-dark': ['link'],
135
+ '--adg3-color-linkActive-light': ['link', 'pressed'],
136
+ '--adg3-color-linkActive-dark': ['link', 'pressed'],
137
+ '--adg3-color-linkOutline-light': ['link', 'focused'],
138
+ '--adg3-color-linkOutline-dark': ['link', 'focused'],
139
+ '--adg3-color-primary-light': ['brand'],
140
+ '--adg3-color-primary-dark': ['brand'],
141
+ '--adg3-color-blue-light': ['accent', 'subtler', 'blue'],
142
+ '--adg3-color-blue-dark': ['accent', 'bolder', 'blue'],
143
+ '--adg3-color-teal-light': ['accent', 'subtler', 'teal'],
144
+ '--adg3-color-teal-dark': ['accent', 'bolder', 'teal'],
145
+ '--adg3-color-purple-light': ['accent', 'subtler', 'purple'],
146
+ '--adg3-color-purple-dark': ['accent', 'bolder', 'purple'],
147
+ '--adg3-color-red-light': ['accent', 'subtler', 'red'],
148
+ '--adg3-color-red-dark': ['accent', 'bolder', 'red'],
149
+ '--adg3-color-yellow-light': ['accent', 'subtler', 'yellow'],
150
+ '--adg3-color-yellow-dark': ['accent', 'bolder', 'yellow'],
151
+ '--adg3-color-green-light': ['accent', 'subtler', 'green'],
152
+ '--adg3-color-green-dark': ['accent', 'bolder', 'green'],
153
+ '--adg3-color-N20-transparent': [],
154
+
155
+ /* Alias variables */
156
+ '--jpo-theme-color': ['brand'],
157
+ '--jpo-text-default-color': ['text'],
158
+ '--jpo-text-secondary-color': ['text', 'subtle'],
159
+ '--jpo-text-muted-color': ['text', 'disabled'],
160
+ '--jpo-text-error-color': ['text', 'danger'],
161
+ '--jpo-bg-default-color': ['elevation', 'surface'],
162
+ '--jpo-bg-reverse-color': ['background', 'inverse'],
163
+ '--jpo-bg-warning-color': ['background', 'warning', 'subtle'],
164
+ '--jpo-bg-dark-color': ['background', 'netural', 'bold'],
165
+ '--jpo-border-default-color': ['border'],
166
+ '--jpo-border-secondary-color': ['border', 'subtle'],
167
+ };