@primer/primitives 7.16.0 → 7.17.0-rc.1685583f

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 (259) hide show
  1. package/dist/styleLint/base/size/size.json +427 -0
  2. package/dist/styleLint/base/typography/typography.json +54 -0
  3. package/dist/styleLint/functional/motion/motion.json +47 -0
  4. package/dist/styleLint/functional/size/border.json +234 -0
  5. package/dist/styleLint/functional/size/breakpoints.json +152 -0
  6. package/dist/styleLint/functional/size/size-coarse.json +41 -0
  7. package/dist/styleLint/functional/size/size-fine.json +41 -0
  8. package/dist/styleLint/functional/size/size.json +1838 -0
  9. package/dist/styleLint/functional/size/viewport.json +80 -0
  10. package/dist/styleLint/functional/themes/dark-colorblind.json +16155 -0
  11. package/dist/styleLint/functional/themes/dark-dimmed.json +16159 -0
  12. package/dist/styleLint/functional/themes/dark-high-contrast.json +16175 -0
  13. package/dist/styleLint/functional/themes/dark-tritanopia.json +16161 -0
  14. package/dist/styleLint/functional/themes/dark.json +16159 -0
  15. package/dist/styleLint/functional/themes/light-colorblind.json +16123 -0
  16. package/dist/styleLint/functional/themes/light-high-contrast.json +16125 -0
  17. package/dist/styleLint/functional/themes/light-tritanopia.json +16115 -0
  18. package/dist/styleLint/functional/themes/light.json +16113 -0
  19. package/dist/styleLint/functional/typography/typography.json +663 -0
  20. package/package.json +11 -9
  21. package/src/PrimerStyleDictionary.ts +226 -0
  22. package/src/filters/index.ts +12 -0
  23. package/src/filters/isBorder.ts +10 -0
  24. package/src/filters/isColor.ts +10 -0
  25. package/src/filters/isColorWithAlpha.ts +11 -0
  26. package/src/filters/isColorWithMix.ts +33 -0
  27. package/src/filters/isDeprecated.ts +10 -0
  28. package/src/filters/isDimension.ts +10 -0
  29. package/src/filters/isDuration.ts +10 -0
  30. package/src/filters/isFontFamily.ts +10 -0
  31. package/src/filters/isFontWeight.ts +10 -0
  32. package/src/filters/isFromFile.ts +12 -0
  33. package/src/filters/isShadow.ts +10 -0
  34. package/src/filters/isSource.ts +10 -0
  35. package/src/filters/isTypography.ts +10 -0
  36. package/src/formats/cssCustomMedia.ts +24 -0
  37. package/src/formats/cssThemed.ts +35 -0
  38. package/src/formats/cssVariables.ts +25 -0
  39. package/src/formats/cssWrapMediaQuery.ts +29 -0
  40. package/src/formats/index.ts +11 -0
  41. package/src/formats/javascriptCommonJs.ts +21 -0
  42. package/src/formats/javascriptEsm.ts +21 -0
  43. package/src/formats/jsonFigma.ts +131 -0
  44. package/src/formats/jsonNestedPrefixed.ts +23 -0
  45. package/src/formats/jsonOneDimensional.ts +18 -0
  46. package/src/formats/jsonPostCssFallback.ts +16 -0
  47. package/src/formats/typescriptExportDefinition.ts +170 -0
  48. package/src/formats/utilities/jsonToFlat.ts +10 -0
  49. package/src/formats/utilities/jsonToNestedValue.ts +20 -0
  50. package/src/formats/utilities/prefixTokens.ts +17 -0
  51. package/src/parsers/index.ts +1 -0
  52. package/src/parsers/w3cJsonParser.ts +25 -0
  53. package/src/platforms/css.ts +93 -0
  54. package/src/platforms/deprecatedJson.ts +16 -0
  55. package/src/platforms/docJson.ts +34 -0
  56. package/src/platforms/fallbacks.ts +34 -0
  57. package/src/platforms/figma.ts +48 -0
  58. package/src/platforms/index.ts +10 -0
  59. package/src/platforms/javascript.ts +30 -0
  60. package/src/platforms/json.ts +32 -0
  61. package/src/platforms/styleLint.ts +34 -0
  62. package/src/platforms/typeDefinitions.ts +30 -0
  63. package/src/platforms/typescript.ts +30 -0
  64. package/src/schemas/alphaValue.ts +12 -0
  65. package/src/schemas/baseToken.ts +7 -0
  66. package/src/schemas/borderToken.ts +19 -0
  67. package/src/schemas/collections.ts +47 -0
  68. package/src/schemas/colorHexValue.ts +18 -0
  69. package/src/schemas/colorToken.ts +50 -0
  70. package/src/schemas/designToken.ts +38 -0
  71. package/src/schemas/dimensionToken.ts +22 -0
  72. package/src/schemas/dimensionValue.ts +16 -0
  73. package/src/schemas/durationToken.ts +12 -0
  74. package/src/schemas/durationValue.ts +9 -0
  75. package/src/schemas/fontFamilyToken.ts +11 -0
  76. package/src/schemas/fontWeightToken.ts +12 -0
  77. package/src/schemas/fontWeightValue.ts +14 -0
  78. package/src/schemas/numberToken.ts +11 -0
  79. package/src/schemas/referenceValue.ts +12 -0
  80. package/src/schemas/scopes.ts +16 -0
  81. package/src/schemas/shadowToken.ts +45 -0
  82. package/src/schemas/stringToken.ts +11 -0
  83. package/src/schemas/tokenName.ts +12 -0
  84. package/src/schemas/tokenType.ts +4 -0
  85. package/src/schemas/typographyToken.ts +20 -0
  86. package/src/schemas/validTokenType.ts +44 -0
  87. package/src/schemas/viewportRangeToken.ts +11 -0
  88. package/src/test-utilities/getMockDictionary.ts +22 -0
  89. package/src/test-utilities/getMockFormatterArguments.ts +21 -0
  90. package/src/test-utilities/getMockParserInput.ts +72 -0
  91. package/src/test-utilities/getMockToken.ts +25 -0
  92. package/src/test-utilities/index.ts +4 -0
  93. package/src/tokens/base/color/dark/dark.dimmed.json5 +1326 -0
  94. package/src/tokens/base/color/dark/dark.high-contrast.json5 +856 -0
  95. package/src/tokens/base/color/dark/dark.json5 +866 -0
  96. package/src/tokens/base/color/dark/display-dark.json5 +1774 -0
  97. package/src/tokens/base/color/light/display-light.json5 +1774 -0
  98. package/src/tokens/base/color/light/light.high-contrast.json5 +847 -0
  99. package/src/tokens/base/color/light/light.json5 +866 -0
  100. package/src/tokens/base/size/size.json +176 -0
  101. package/src/tokens/base/typography/typography.json +24 -0
  102. package/src/tokens/fallback/color-fallbacks.json +260 -0
  103. package/src/tokens/functional/border/dark.json5 +12 -0
  104. package/src/tokens/functional/border/light.json5 +12 -0
  105. package/src/tokens/functional/color/dark/app-dark.json5 +554 -0
  106. package/src/tokens/functional/color/dark/data-vis-dark.json5 +144 -0
  107. package/src/tokens/functional/color/dark/display-dark.json5 +1060 -0
  108. package/src/tokens/functional/color/dark/overrides/dark.dimmed.json5 +57 -0
  109. package/src/tokens/functional/color/dark/overrides/dark.high-contrast.json5 +390 -0
  110. package/src/tokens/functional/color/dark/overrides/dark.protanopia-deuteranopia.json5 +314 -0
  111. package/src/tokens/functional/color/dark/overrides/dark.tritanopia.json5 +229 -0
  112. package/src/tokens/functional/color/dark/patterns-dark.json5 +3073 -0
  113. package/src/tokens/functional/color/dark/primitives-dark.json5 +1206 -0
  114. package/src/tokens/functional/color/dark/syntax-dark.json5 +559 -0
  115. package/src/tokens/functional/color/light/app-light.json5 +551 -0
  116. package/src/tokens/functional/color/light/data-vis-light.json5 +144 -0
  117. package/src/tokens/functional/color/light/display-light.json5 +1060 -0
  118. package/src/tokens/functional/color/light/overrides/light.high-contrast.json5 +440 -0
  119. package/src/tokens/functional/color/light/overrides/light.protanopia-deuteranopia.json5 +340 -0
  120. package/src/tokens/functional/color/light/overrides/light.tritanopia.json5 +249 -0
  121. package/src/tokens/functional/color/light/patterns-light.json5 +3070 -0
  122. package/src/tokens/functional/color/light/primitives-light.json5 +1196 -0
  123. package/src/tokens/functional/color/light/syntax-light.json5 +559 -0
  124. package/src/tokens/functional/motion/loading.json5 +17 -0
  125. package/src/tokens/functional/motion/patterns.json5 +28 -0
  126. package/src/tokens/functional/shadow/dark.json5 +383 -0
  127. package/src/tokens/functional/shadow/light.json5 +376 -0
  128. package/src/tokens/functional/size/border.json +98 -0
  129. package/src/tokens/functional/size/breakpoints.json +64 -0
  130. package/src/tokens/functional/size/size-coarse.json +28 -0
  131. package/src/tokens/functional/size/size-fine.json +28 -0
  132. package/src/tokens/functional/size/size.json +802 -0
  133. package/src/tokens/functional/size/viewport.json +28 -0
  134. package/src/tokens/functional/typography/typography.json +279 -0
  135. package/src/tokens/removed/color.json +421 -0
  136. package/src/transformers/borderToCss.ts +38 -0
  137. package/src/transformers/colorToHex.ts +16 -0
  138. package/src/transformers/colorToHexAlpha.ts +23 -0
  139. package/src/transformers/colorToHexMix.ts +19 -0
  140. package/src/transformers/colorToRgbAlpha.ts +19 -0
  141. package/src/transformers/colorToRgbaFloat.ts +45 -0
  142. package/src/transformers/dimensionToPixelUnitless.ts +60 -0
  143. package/src/transformers/dimensionToRem.ts +56 -0
  144. package/src/transformers/dimensionToRemPxArray.ts +60 -0
  145. package/src/transformers/durationToCss.ts +29 -0
  146. package/src/transformers/figmaAttributes.ts +55 -0
  147. package/src/transformers/fontFamilyToCss.ts +38 -0
  148. package/src/transformers/fontWeightToNumber.ts +53 -0
  149. package/src/transformers/index.ts +21 -0
  150. package/src/transformers/jsonDeprecated.ts +15 -0
  151. package/src/transformers/namePathToCamelCase.ts +14 -0
  152. package/src/transformers/namePathToDotNotation.ts +34 -0
  153. package/src/transformers/namePathToFigma.ts +28 -0
  154. package/src/transformers/namePathToKebabCase.ts +19 -0
  155. package/src/transformers/namePathToSlashNotation.ts +19 -0
  156. package/src/transformers/shadowToCss.ts +37 -0
  157. package/src/transformers/typographyToCss.ts +31 -0
  158. package/src/transformers/utilities/alpha.ts +23 -0
  159. package/src/transformers/utilities/checkRequiredTokenProperties.ts +16 -0
  160. package/src/transformers/utilities/getTokenValue.ts +18 -0
  161. package/src/transformers/utilities/hexToRgbaFloat.ts +31 -0
  162. package/src/transformers/utilities/invalidTokenError.ts +34 -0
  163. package/src/transformers/utilities/isRgbaFloat.ts +29 -0
  164. package/src/transformers/utilities/mix.ts +46 -0
  165. package/src/transformers/utilities/rgbaFloatToHex.ts +15 -0
  166. package/src/types/Border.d.ts +5 -0
  167. package/src/types/BorderTokenValue.d.ts +10 -0
  168. package/src/types/ColorHex.d.ts +4 -0
  169. package/src/types/PlatformInitializer.d.ts +11 -0
  170. package/src/types/Shadow.d.ts +5 -0
  171. package/src/types/ShadowTokenValue.d.ts +14 -0
  172. package/src/types/SizeEm.d.ts +4 -0
  173. package/src/types/SizePx.d.ts +4 -0
  174. package/src/types/SizeRem.d.ts +4 -0
  175. package/src/types/StyleDictionaryConfigGenerator.d.ts +15 -0
  176. package/src/types/TokenBuildInput.d.ts +8 -0
  177. package/src/types/TypographyTokenValue.d.ts +12 -0
  178. package/src/types/w3cTransformedToken.d.ts +8 -0
  179. package/src/utilities/copyFromDir.ts +21 -0
  180. package/src/utilities/getFlag.ts +12 -0
  181. package/src/utilities/index.ts +3 -0
  182. package/src/utilities/joinFriendly.ts +2 -0
  183. package/src/utilities/schemaErrorMessage.ts +2 -0
  184. package/src/utilities/toCamelCase.ts +29 -0
  185. package/src/utilities/treeWalker.ts +27 -0
  186. package/src/utilities/upperCaseFirstCharacter.ts +10 -0
  187. package/src/utils-v1.ts +36 -0
  188. package/tokens-next-private/styleLint/base/size/size.json +427 -0
  189. package/tokens-next-private/styleLint/base/typography/typography.json +54 -0
  190. package/tokens-next-private/styleLint/functional/motion/motion.json +47 -0
  191. package/tokens-next-private/styleLint/functional/size/border.json +234 -0
  192. package/tokens-next-private/styleLint/functional/size/breakpoints.json +152 -0
  193. package/tokens-next-private/styleLint/functional/size/size-coarse.json +41 -0
  194. package/tokens-next-private/styleLint/functional/size/size-fine.json +41 -0
  195. package/tokens-next-private/styleLint/functional/size/size.json +1838 -0
  196. package/tokens-next-private/styleLint/functional/size/viewport.json +80 -0
  197. package/tokens-next-private/styleLint/functional/themes/dark-colorblind.json +16155 -0
  198. package/tokens-next-private/styleLint/functional/themes/dark-dimmed.json +16159 -0
  199. package/tokens-next-private/styleLint/functional/themes/dark-high-contrast.json +16175 -0
  200. package/tokens-next-private/styleLint/functional/themes/dark-tritanopia.json +16161 -0
  201. package/tokens-next-private/styleLint/functional/themes/dark.json +16159 -0
  202. package/tokens-next-private/styleLint/functional/themes/light-colorblind.json +16123 -0
  203. package/tokens-next-private/styleLint/functional/themes/light-high-contrast.json +16125 -0
  204. package/tokens-next-private/styleLint/functional/themes/light-tritanopia.json +16115 -0
  205. package/tokens-next-private/styleLint/functional/themes/light.json +16113 -0
  206. package/tokens-next-private/styleLint/functional/typography/typography.json +663 -0
  207. package/tokens-v2-private/css/tokens/base/size/size.css +1 -1
  208. package/tokens-v2-private/css/tokens/base/typography/typography.css +1 -1
  209. package/tokens-v2-private/css/tokens/functional/size/border.css +1 -1
  210. package/tokens-v2-private/css/tokens/functional/size/breakpoints.css +1 -1
  211. package/tokens-v2-private/css/tokens/functional/size/size-coarse.css +1 -1
  212. package/tokens-v2-private/css/tokens/functional/size/size-fine.css +1 -1
  213. package/tokens-v2-private/css/tokens/functional/size/size.css +1 -1
  214. package/tokens-v2-private/css/tokens/functional/typography/typography.css +1 -1
  215. package/tokens-v2-private/js/module/tokens/base/size/size.js +1 -1
  216. package/tokens-v2-private/js/module/tokens/base/typography/typography.js +1 -1
  217. package/tokens-v2-private/js/module/tokens/functional/size/border.js +1 -1
  218. package/tokens-v2-private/js/module/tokens/functional/size/breakpoints.js +1 -1
  219. package/tokens-v2-private/js/module/tokens/functional/size/size-coarse.js +1 -1
  220. package/tokens-v2-private/js/module/tokens/functional/size/size-fine.js +1 -1
  221. package/tokens-v2-private/js/module/tokens/functional/size/size.js +1 -1
  222. package/tokens-v2-private/js/module/tokens/functional/size/viewport.js +1 -1
  223. package/tokens-v2-private/js/module/tokens/functional/typography/typography.js +1 -1
  224. package/tokens-v2-private/js/tokens/base/size/size.js +1 -1
  225. package/tokens-v2-private/js/tokens/base/typography/typography.js +1 -1
  226. package/tokens-v2-private/js/tokens/functional/size/border.js +1 -1
  227. package/tokens-v2-private/js/tokens/functional/size/breakpoints.js +1 -1
  228. package/tokens-v2-private/js/tokens/functional/size/size-coarse.js +1 -1
  229. package/tokens-v2-private/js/tokens/functional/size/size-fine.js +1 -1
  230. package/tokens-v2-private/js/tokens/functional/size/size.js +1 -1
  231. package/tokens-v2-private/js/tokens/functional/size/viewport.js +1 -1
  232. package/tokens-v2-private/js/tokens/functional/typography/typography.js +1 -1
  233. package/tokens-v2-private/scss/tokens/base/size/size.scss +1 -1
  234. package/tokens-v2-private/scss/tokens/base/typography/typography.scss +1 -1
  235. package/tokens-v2-private/scss/tokens/functional/size/border.scss +1 -1
  236. package/tokens-v2-private/scss/tokens/functional/size/breakpoints.scss +1 -1
  237. package/tokens-v2-private/scss/tokens/functional/size/size-coarse.scss +1 -1
  238. package/tokens-v2-private/scss/tokens/functional/size/size-fine.scss +1 -1
  239. package/tokens-v2-private/scss/tokens/functional/size/size.scss +1 -1
  240. package/tokens-v2-private/scss/tokens/functional/size/viewport.scss +1 -1
  241. package/tokens-v2-private/scss/tokens/functional/typography/typography.scss +1 -1
  242. package/tokens-v2-private/ts/tokens/base/size/size.d.ts +1 -1
  243. package/tokens-v2-private/ts/tokens/base/size/size.js +1 -1
  244. package/tokens-v2-private/ts/tokens/base/typography/typography.d.ts +1 -1
  245. package/tokens-v2-private/ts/tokens/base/typography/typography.js +1 -1
  246. package/tokens-v2-private/ts/tokens/functional/size/border.d.ts +1 -1
  247. package/tokens-v2-private/ts/tokens/functional/size/border.js +1 -1
  248. package/tokens-v2-private/ts/tokens/functional/size/breakpoints.d.ts +1 -1
  249. package/tokens-v2-private/ts/tokens/functional/size/breakpoints.js +1 -1
  250. package/tokens-v2-private/ts/tokens/functional/size/size-coarse.d.ts +1 -1
  251. package/tokens-v2-private/ts/tokens/functional/size/size-coarse.js +1 -1
  252. package/tokens-v2-private/ts/tokens/functional/size/size-fine.d.ts +1 -1
  253. package/tokens-v2-private/ts/tokens/functional/size/size-fine.js +1 -1
  254. package/tokens-v2-private/ts/tokens/functional/size/size.d.ts +1 -1
  255. package/tokens-v2-private/ts/tokens/functional/size/size.js +1 -1
  256. package/tokens-v2-private/ts/tokens/functional/size/viewport.d.ts +1 -1
  257. package/tokens-v2-private/ts/tokens/functional/size/viewport.js +1 -1
  258. package/tokens-v2-private/ts/tokens/functional/typography/typography.d.ts +1 -1
  259. package/tokens-v2-private/ts/tokens/functional/typography/typography.js +1 -1
@@ -0,0 +1,56 @@
1
+ import {isDimension} from '../filters'
2
+ import type StyleDictionary from 'style-dictionary'
3
+ import type {Platform} from 'style-dictionary'
4
+
5
+ /**
6
+ * @description base font size from options or 16
7
+ * @param options
8
+ * @returns number
9
+ */
10
+ const getBasePxFontSize = (options?: Platform): number => (options && options.basePxFontSize) || 16
11
+
12
+ /**
13
+ * @description checks if token value has a specific unit
14
+ * @param value token value
15
+ * @param unit unit string like px or value
16
+ * @returns boolean
17
+ */
18
+ const hasUnit = (value: string | number, unit: string): boolean => {
19
+ if (typeof value === 'number') {
20
+ return false
21
+ }
22
+
23
+ return value.indexOf(unit) > -1
24
+ }
25
+
26
+ /**
27
+ * @description converts dimension tokens value to `rem`, ignores `em` as they are relative to the font size of the parent element
28
+ * @type value transformer — [StyleDictionary.ValueTransform](https://github.com/amzn/style-dictionary/blob/main/types/Transform.d.ts)
29
+ * @matcher matches all tokens of $type `dimension`
30
+ * @transformer returns a `rem` string
31
+ */
32
+ export const dimensionToRem: StyleDictionary.Transform = {
33
+ type: `value`,
34
+ transitive: true,
35
+ matcher: isDimension,
36
+ transformer: (token: StyleDictionary.TransformedToken, options?: Platform) => {
37
+ const baseFont = getBasePxFontSize(options)
38
+ const floatVal = parseFloat(token.value)
39
+
40
+ if (isNaN(floatVal)) {
41
+ throw new Error(
42
+ `Invalid dimension token: '${token.name}: ${token.value}' is not valid and cannot be transform to 'rem' \n`,
43
+ )
44
+ }
45
+
46
+ if (floatVal === 0) {
47
+ return '0'
48
+ }
49
+
50
+ if (hasUnit(token.value, 'rem') || hasUnit(token.value, 'em')) {
51
+ return token.value
52
+ }
53
+
54
+ return `${floatVal / baseFont}rem`
55
+ },
56
+ }
@@ -0,0 +1,60 @@
1
+ import {isDimension} from '../filters'
2
+ import type StyleDictionary from 'style-dictionary'
3
+ import type {Platform} from 'style-dictionary'
4
+
5
+ type SizePx = '0' | `${number}px`
6
+ type SizeRem = '0' | `${number}rem`
7
+ type SizeEm = '0' | `${number}em`
8
+
9
+ /**
10
+ * @description base font size from options or 16
11
+ * @param options
12
+ * @returns number
13
+ */
14
+ const getBasePxFontSize = (options?: Platform): number => (options && options.basePxFontSize) || 16
15
+
16
+ /**
17
+ * @description checks if token value has a specific unit
18
+ * @param value token value
19
+ * @param unit unit string like px or value
20
+ * @returns boolean
21
+ */
22
+ const hasUnit = (value: string | number, unit: string): boolean => {
23
+ if (typeof value === 'number') {
24
+ return false
25
+ }
26
+
27
+ return value.indexOf(unit) > -1
28
+ }
29
+
30
+ /**
31
+ * @description converts dimension tokens value to `rem`, ignores `em` as they are relative to the font size of the parent element
32
+ * @type value transformer — [StyleDictionary.ValueTransform](https://github.com/amzn/style-dictionary/blob/main/types/Transform.d.ts)
33
+ * @matcher matches all tokens of $type `dimension`
34
+ * @transformer returns an array with the `rem` and `pixel` string
35
+ */
36
+ export const dimensionToRemPxArray: StyleDictionary.Transform = {
37
+ type: `value`,
38
+ transitive: true,
39
+ matcher: isDimension,
40
+ transformer: (token: StyleDictionary.TransformedToken, options?: Platform): [SizeRem | SizeEm, SizePx] => {
41
+ const baseFont = getBasePxFontSize(options)
42
+ const floatVal = parseFloat(token.value)
43
+
44
+ if (isNaN(floatVal)) {
45
+ throw new Error(
46
+ `Invalid dimension token: '${token.name}: ${token.value}' is not valid and cannot be transform to 'rem' \n`,
47
+ )
48
+ }
49
+
50
+ if (floatVal === 0) {
51
+ return ['0', '0']
52
+ }
53
+
54
+ if (hasUnit(token.value, 'rem') || hasUnit(token.value, 'em')) {
55
+ return [token.value, `${floatVal * baseFont}px`]
56
+ }
57
+
58
+ return [`${floatVal / baseFont}rem`, `${floatVal}px`]
59
+ },
60
+ }
@@ -0,0 +1,29 @@
1
+ import type StyleDictionary from 'style-dictionary'
2
+ import {isDuration} from '../filters/isDuration'
3
+
4
+ /**
5
+ * @description converts duration tokens string value to number with `ms` unit
6
+ * @type value transformer — [StyleDictionary.ValueTransform](https://github.com/amzn/style-dictionary/blob/main/types/Transform.d.ts)
7
+ * @matcher matches all tokens of $type `duration`
8
+ * @transformer returns a css duration
9
+ */
10
+ export const durationToCss: StyleDictionary.Transform = {
11
+ type: `value`,
12
+ transitive: true,
13
+ matcher: isDuration,
14
+ transformer: (token: StyleDictionary.TransformedToken, _options?: StyleDictionary.Platform) => {
15
+ // throw an error if token value is not a string or does not end with `ms`
16
+ if (typeof token.value !== `string` || !token.value.endsWith(`ms`)) {
17
+ throw new Error(`duration token value must be a string with an "ms" unit`)
18
+ }
19
+ // get value
20
+ let value = parseInt(token.value.replace('ms', ''))
21
+ let unit = `ms`
22
+ if (value >= 1000) {
23
+ value = value / 1000
24
+ unit = `s`
25
+ }
26
+ // return value
27
+ return `${value}${unit}`
28
+ },
29
+ }
@@ -0,0 +1,55 @@
1
+ import type StyleDictionary from 'style-dictionary'
2
+
3
+ type FigmaVariableScope =
4
+ | 'ALL_SCOPES'
5
+ | 'TEXT_CONTENT'
6
+ | 'CORNER_RADIUS'
7
+ | 'WIDTH_HEIGHT'
8
+ | 'GAP'
9
+ | 'ALL_FILLS'
10
+ | 'FRAME_FILL'
11
+ | 'SHAPE_FILL'
12
+ | 'TEXT_FILL'
13
+ | 'STROKE_COLOR'
14
+
15
+ const figmaScopes: Record<string, FigmaVariableScope[]> = {
16
+ all: ['ALL_SCOPES'],
17
+ radius: ['CORNER_RADIUS'],
18
+ size: ['WIDTH_HEIGHT'],
19
+ gap: ['GAP'],
20
+ bgColor: ['FRAME_FILL', 'SHAPE_FILL'],
21
+ fgColor: ['TEXT_FILL', 'SHAPE_FILL'],
22
+ borderColor: ['STROKE_COLOR'],
23
+ }
24
+
25
+ const getScopes = (scopes: string[] | string | undefined): FigmaVariableScope[] => {
26
+ if (typeof scopes === 'string') scopes = [scopes]
27
+ if (Array.isArray(scopes))
28
+ return scopes
29
+ .map(scope => {
30
+ if (scope in figmaScopes) return figmaScopes[scope]
31
+ throw new Error(`Invalid scope: ${scope}`)
32
+ })
33
+ .flat() as FigmaVariableScope[]
34
+
35
+ return ['ALL_SCOPES']
36
+ }
37
+ /**
38
+ * @description retrieves figma attributes from token and adds them to attributes
39
+ * @type attribute transformer — [StyleDictionary.AttributeTransform](https://github.com/amzn/style-dictionary/blob/main/types/Transform.d.ts)
40
+ * @matcher matches all tokens
41
+ * @transformer returns ab object of figma attributes
42
+ */
43
+ export const figmaAttributes: StyleDictionary.Transform = {
44
+ type: `attribute`,
45
+ transformer: (token: StyleDictionary.TransformedToken, platform: StyleDictionary.Platform = {}) => {
46
+ const {mode, collection, scopes, group, codeSyntax} = token.$extensions?.['org.primer.figma'] || {}
47
+ return {
48
+ mode: platform.options?.mode || mode || 'default',
49
+ collection,
50
+ group: group || collection,
51
+ scopes: getScopes(scopes),
52
+ codeSyntax,
53
+ }
54
+ },
55
+ }
@@ -0,0 +1,38 @@
1
+ import type StyleDictionary from 'style-dictionary'
2
+ import {isFontFamily} from '../filters'
3
+ import {getTokenValue} from './utilities/getTokenValue'
4
+
5
+ const hasSpaceInName = (string: string) => /\s/g.test(string)
6
+ /**
7
+ * takes a value and returns it if its a string or concats strings in an array quoting strings with spaces
8
+ * @param value
9
+ * @returns string
10
+ */
11
+ export const parseFontFamily = (value: unknown): string => {
12
+ if (typeof value === 'string') {
13
+ return value
14
+ }
15
+ if (Array.isArray(value)) {
16
+ return value
17
+ .map((string: string) => {
18
+ if (typeof string !== 'string') {
19
+ throw new Error(`Invalid value in array ${string}, must be a string`)
20
+ }
21
+ return hasSpaceInName(string) ? `'${string}'` : string
22
+ })
23
+ .join(', ')
24
+ }
25
+ throw new Error(`Invalid value ${value}, should be a string or array of strings`)
26
+ }
27
+ /**
28
+ * @description converts fontFamily tokens value to string
29
+ * @type value transformer — [StyleDictionary.ValueTransform](https://github.com/amzn/style-dictionary/blob/main/types/Transform.d.ts)
30
+ * @matcher matches all tokens of $type `fontFamily`
31
+ * @transformer returns a number
32
+ */
33
+ export const fontFamilyToCss: StyleDictionary.Transform = {
34
+ type: `value`,
35
+ transitive: true,
36
+ matcher: isFontFamily,
37
+ transformer: (token: StyleDictionary.TransformedToken): string => parseFontFamily(getTokenValue(token)),
38
+ }
@@ -0,0 +1,53 @@
1
+ import type StyleDictionary from 'style-dictionary'
2
+ import {isFontWeight} from '../filters'
3
+ import {getTokenValue} from './utilities/getTokenValue'
4
+
5
+ const fontWeightMatrix: Record<string, string[]> = {
6
+ '100': ['thin', 'hairline'],
7
+ '200': ['extra-light', 'ultra-light'],
8
+ '300': ['light'],
9
+ '400': ['normal', 'regular', 'book'],
10
+ '500': ['medium'],
11
+ '600': ['semi-bold', 'demi-bold'],
12
+ '700': ['bold'],
13
+ '800': ['extra-bold', 'ultra-bold'],
14
+ '900': ['black', 'heavy'],
15
+ '950': ['extra-black', 'ultra-black'],
16
+ }
17
+
18
+ export const parseFontWeight = (value: unknown): number => {
19
+ // throw on anything but string and number
20
+ if (typeof value !== 'string' && typeof value !== 'number') {
21
+ throw new Error(`Invalid value ${value}, should be a number or fontWeight string`)
22
+ }
23
+ // valid string
24
+ if (typeof value === 'string') {
25
+ const key = Object.keys(fontWeightMatrix).find((k: string) => fontWeightMatrix[k].includes(value as string))
26
+ if (key !== undefined) {
27
+ return parseInt(key)
28
+ }
29
+ }
30
+ // if number as string
31
+ if (typeof value === 'string' && typeof parseInt(value) === 'number' && !isNaN(parseInt(value))) {
32
+ value = parseInt(value)
33
+ }
34
+ // return if valid numver
35
+ if (typeof value === 'number' && value > 0 && value <= 1000) {
36
+ return value
37
+ }
38
+ // invalid value
39
+ throw new Error(`Invalid value ${value}, should be a number or fontWeight string`)
40
+ }
41
+
42
+ /**
43
+ * @description converts fontWeight tokens value to numeric value
44
+ * @type value transformer — [StyleDictionary.ValueTransform](https://github.com/amzn/style-dictionary/blob/main/types/Transform.d.ts)
45
+ * @matcher matches all tokens of $type `fontWeight`
46
+ * @transformer returns a number
47
+ */
48
+ export const fontWeightToNumber: StyleDictionary.Transform = {
49
+ type: `value`,
50
+ transitive: true,
51
+ matcher: isFontWeight,
52
+ transformer: (token: StyleDictionary.TransformedToken): number => parseFontWeight(getTokenValue(token)),
53
+ }
@@ -0,0 +1,21 @@
1
+ export {borderToCss} from './borderToCss'
2
+ export {colorToHex} from './colorToHex'
3
+ export {colorToHexAlpha} from './colorToHexAlpha'
4
+ export {colorToHexMix} from './colorToHexMix'
5
+ export {colorToRgbAlpha} from './colorToRgbAlpha'
6
+ export {colorToRgbaFloat} from './colorToRgbaFloat'
7
+ export {dimensionToRem} from './dimensionToRem'
8
+ export {dimensionToRemPxArray} from './dimensionToRemPxArray'
9
+ export {dimensionToPixelUnitless} from './dimensionToPixelUnitless'
10
+ export {durationToCss} from './durationToCss'
11
+ export {figmaAttributes} from './figmaAttributes'
12
+ export {fontFamilyToCss} from './fontFamilyToCss'
13
+ export {fontWeightToNumber} from './fontWeightToNumber'
14
+ export {jsonDeprecated} from './jsonDeprecated'
15
+ export {namePathToCamelCase} from './namePathToCamelCase'
16
+ export {namePathToDotNotation} from './namePathToDotNotation'
17
+ export {namePathToFigma} from './namePathToFigma'
18
+ export {namePathToKebabCase} from './namePathToKebabCase'
19
+ export {namePathToSlashNotation} from './namePathToSlashNotation'
20
+ export {shadowToCss} from './shadowToCss'
21
+ export {typographyToCss} from './typographyToCss'
@@ -0,0 +1,15 @@
1
+ import {isDeprecated} from '../filters'
2
+ import type StyleDictionary from 'style-dictionary'
3
+ /**
4
+ * @description replaces tokens value with content of tokens `deprecated` property
5
+ * @type value transformer — [StyleDictionary.ValueTransform](https://github.com/amzn/style-dictionary/blob/main/types/Transform.d.ts)
6
+ * @matcher matches all tokens with a `deprecated` property
7
+ * @transformer returns `string` specified in `token.deprecated` or `null`
8
+ */
9
+ export const jsonDeprecated: StyleDictionary.Transform = {
10
+ type: `value`,
11
+ transitive: true,
12
+ matcher: isDeprecated,
13
+ transformer: (token: StyleDictionary.TransformedToken) =>
14
+ typeof token.deprecated === 'string' ? token.deprecated.replace(/[{}]/g, '') : null,
15
+ }
@@ -0,0 +1,14 @@
1
+ import type StyleDictionary from 'style-dictionary'
2
+ import {toCamelCase} from '../utilities'
3
+
4
+ /**
5
+ * @description converts the [TransformedToken's](https://github.com/amzn/style-dictionary/blob/main/types/TransformedToken.d.ts) `.path` array to a camelCase string, preserves casing of parts
6
+ * @type name transformer — [StyleDictionary.NameTransform](https://github.com/amzn/style-dictionary/blob/main/types/Transform.d.ts)
7
+ * @matcher omitted to match all tokens
8
+ * @transformer returns `string` camelCase
9
+ */
10
+ export const namePathToCamelCase: StyleDictionary.Transform = {
11
+ type: `name`,
12
+ transformer: (token: StyleDictionary.TransformedToken, options?: StyleDictionary.Platform): string =>
13
+ toCamelCase([options?.prefix || '', ...token.path]),
14
+ }
@@ -0,0 +1,34 @@
1
+ import {upperCaseFirstCharacter} from '../utilities'
2
+ import type StyleDictionary from 'style-dictionary'
3
+
4
+ /**
5
+ * camelCase
6
+ * @scope custom camelCase implementation should only be used within `name path to dot notation` transformer
7
+ * @description replaces space ` `, dash `-`, underscore `_` and plus `+` by camelCasing e.g. `camel-case` -> `camelCase`
8
+ * @param string
9
+ * @returns string
10
+ */
11
+ const camelCase = (string: string): string => {
12
+ return string
13
+ .split(/[\s-_+]+/g)
14
+ .map((stringPart: string, index: number) => (index === 0 ? stringPart : upperCaseFirstCharacter(stringPart)))
15
+ .join('')
16
+ }
17
+ /**
18
+ * @description converts the [TransformedToken's](https://github.com/amzn/style-dictionary/blob/main/types/TransformedToken.d.ts) `.path` array to a dot.notation string
19
+ * @type name transformer — [StyleDictionary.NameTransform](https://github.com/amzn/style-dictionary/blob/main/types/Transform.d.ts)
20
+ * @matcher omitted to match all tokens
21
+ * @transformer returns `string` in dot.notation
22
+ */
23
+ export const namePathToDotNotation: StyleDictionary.Transform = {
24
+ type: `name`,
25
+ transformer: (token: StyleDictionary.TransformedToken, options?: StyleDictionary.Platform): string => {
26
+ return (
27
+ [options?.prefix, ...token.path]
28
+ // remove undefined if exists
29
+ .filter((part: unknown): part is string => typeof part === 'string' && part !== '@')
30
+ .map((part: string) => camelCase(part))
31
+ .join('.')
32
+ )
33
+ },
34
+ }
@@ -0,0 +1,28 @@
1
+ import type StyleDictionary from 'style-dictionary'
2
+
3
+ export const transformNamePathToFigma = (
4
+ token: StyleDictionary.TransformedToken,
5
+ options?: StyleDictionary.Platform,
6
+ ): string => {
7
+ let pathArray = token.path.filter((part: unknown): part is string => part !== '@')
8
+ if (['fgColor', 'borderColor', 'bgColor'].includes(pathArray[0]) && pathArray.length === 3) {
9
+ pathArray = [pathArray[0], `${pathArray[1]}-${pathArray[2]}`]
10
+ }
11
+ return (
12
+ [options?.prefix, ...pathArray]
13
+ // remove undefined if exists
14
+ .filter((part: unknown): part is string => typeof part === 'string' && part !== '@')
15
+ .join('/')
16
+ )
17
+ }
18
+
19
+ /**
20
+ * @description converts the [TransformedToken's](https://github.com/amzn/style-dictionary/blob/main/types/TransformedToken.d.ts) `.path` array to a specific figma name
21
+ * @type name transformer — [StyleDictionary.NameTransform](https://github.com/amzn/style-dictionary/blob/main/types/Transform.d.ts)
22
+ * @matcher omitted to match all tokens
23
+ * @transformer returns `string`
24
+ */
25
+ export const namePathToFigma: StyleDictionary.Transform = {
26
+ type: `name`,
27
+ transformer: transformNamePathToFigma,
28
+ }
@@ -0,0 +1,19 @@
1
+ import type StyleDictionary from 'style-dictionary'
2
+
3
+ /**
4
+ * @description converts the [TransformedToken's](https://github.com/amzn/style-dictionary/blob/main/types/TransformedToken.d.ts) `.path` array to a kebab-case string, preserves casing of parts
5
+ * @type name transformer — [StyleDictionary.NameTransform](https://github.com/amzn/style-dictionary/blob/main/types/Transform.d.ts)
6
+ * @matcher omitted to match all tokens
7
+ * @transformer returns `string` kebab-case
8
+ */
9
+ export const namePathToKebabCase: StyleDictionary.Transform = {
10
+ type: `name`,
11
+ transformer: (token: StyleDictionary.TransformedToken, options?: StyleDictionary.Platform): string => {
12
+ return (
13
+ [options?.prefix, ...token.path]
14
+ // remove undefined if exists
15
+ .filter((part: unknown): part is string => typeof part === 'string' && part !== '@')
16
+ .join('-')
17
+ )
18
+ },
19
+ }
@@ -0,0 +1,19 @@
1
+ import type StyleDictionary from 'style-dictionary'
2
+
3
+ /**
4
+ * @description converts the [TransformedToken's](https://github.com/amzn/style-dictionary/blob/main/types/TransformedToken.d.ts) `.path` array to a slash/notation string
5
+ * @type name transformer — [StyleDictionary.NameTransform](https://github.com/amzn/style-dictionary/blob/main/types/Transform.d.ts)
6
+ * @matcher omitted to match all tokens
7
+ * @transformer returns `string` on slash/notation
8
+ */
9
+ export const namePathToSlashNotation: StyleDictionary.Transform = {
10
+ type: `name`,
11
+ transformer: (token: StyleDictionary.TransformedToken, options?: StyleDictionary.Platform): string => {
12
+ return (
13
+ [options?.prefix, ...token.path]
14
+ // remove undefined if exists
15
+ .filter((part: unknown): part is string => typeof part === 'string' && part !== '@')
16
+ .join('/')
17
+ )
18
+ },
19
+ }
@@ -0,0 +1,37 @@
1
+ import {toHex} from 'color2k'
2
+ import {isShadow} from '../filters'
3
+ import {alpha} from './utilities/alpha'
4
+ import {checkRequiredTokenProperties} from './utilities/checkRequiredTokenProperties'
5
+ import type {ShadowTokenValue} from '../types/ShadowTokenValue'
6
+ import type StyleDictionary from 'style-dictionary'
7
+ import {getTokenValue} from './utilities/getTokenValue'
8
+
9
+ /**
10
+ * @description converts w3c shadow tokens in css shadow string
11
+ * @type value transformer — [StyleDictionary.ValueTransform](https://github.com/amzn/style-dictionary/blob/main/types/Transform.d.ts)
12
+ * @matcher matches all tokens of $type `shadow`
13
+ * @transformer returns css shadow `string`
14
+ */
15
+ export const shadowToCss: StyleDictionary.Transform = {
16
+ type: `value`,
17
+ transitive: true,
18
+ matcher: isShadow,
19
+ transformer: (token: StyleDictionary.TransformedToken) => {
20
+ // extract value
21
+ const {value}: {value: ShadowTokenValue | ShadowTokenValue[]} = token
22
+ // turn value into array
23
+ const shadowValues = !Array.isArray(value) ? [value] : value
24
+
25
+ return shadowValues
26
+ .map((shadow: ShadowTokenValue) => {
27
+ // if value === string it was probably already transformed
28
+ if (typeof shadow === 'string') return shadow
29
+ checkRequiredTokenProperties(shadow, ['color', 'offsetX', 'offsetY', 'blur', 'spread'])
30
+ /*css box shadow: inset? | offset-x | offset-y | blur-radius | spread-radius | color */
31
+ return `${shadow.inset === true ? 'inset ' : ''}${shadow.offsetX} ${shadow.offsetY} ${shadow.blur} ${
32
+ shadow.spread
33
+ } ${toHex(alpha(getTokenValue({...token, ...{value: shadow}}, 'color'), shadow.alpha || 1, token))}`
34
+ })
35
+ .join(', ')
36
+ },
37
+ }
@@ -0,0 +1,31 @@
1
+ import type StyleDictionary from 'style-dictionary'
2
+ import {isTypography} from '../filters'
3
+ import type {TypographyTokenValue} from '../types/TypographyTokenValue'
4
+ import {checkRequiredTokenProperties} from './utilities/checkRequiredTokenProperties'
5
+ import {parseFontFamily} from './fontFamilyToCss'
6
+ import {parseFontWeight} from './fontWeightToNumber'
7
+ import {getTokenValue} from './utilities/getTokenValue'
8
+
9
+ /**
10
+ * @description converts typograhy token value to css font shorthand
11
+ * @type value transformer — [StyleDictionary.ValueTransform](https://github.com/amzn/style-dictionary/blob/main/types/Transform.d.ts)
12
+ * @matcher matches all tokens of $type `typography`
13
+ * @transformer returns a css font string
14
+ */
15
+ export const typographyToCss: StyleDictionary.Transform = {
16
+ type: `value`,
17
+ transitive: true,
18
+ matcher: isTypography,
19
+ transformer: (token: StyleDictionary.TransformedToken) => {
20
+ // extract value
21
+ const value: TypographyTokenValue = getTokenValue(token)
22
+ // validate token properties
23
+ checkRequiredTokenProperties(value, ['fontWeight', 'fontSize', 'fontFamily'])
24
+ // format output
25
+ return `${value.fontStyle || ''} ${parseFontWeight(getTokenValue(token, 'fontWeight'))} ${value.fontSize}${
26
+ value.lineHeight ? `/${value.lineHeight}` : ''
27
+ } ${parseFontFamily(getTokenValue(token, 'fontFamily'))}`
28
+ .trim()
29
+ .replace(/\s\s+/g, ' ')
30
+ },
31
+ }
@@ -0,0 +1,23 @@
1
+ import {rgba, parseToRgba} from 'color2k'
2
+ import type {TransformedToken} from 'style-dictionary'
3
+ /**
4
+ * alpha
5
+ * @description takes a colors string like hex or rgba and returns an rgba color with the specified alpha value
6
+ * @param color color string like a `#334455` or `rgb(255,200,100)`
7
+ * @param desiredAlpha number
8
+ * @returns rgba value
9
+ */
10
+ export const alpha = (color: string, desiredAlpha: number, token?: TransformedToken): string => {
11
+ const [r, g, b, a] = parseToRgba(color)
12
+
13
+ if (a < 1 && desiredAlpha < 1) {
14
+ // eslint-disable-next-line no-console
15
+ console.warn(
16
+ `🚨 You are setting an alpha value of "${desiredAlpha}" for a color with an alpha value (${color}). The previous alpha value will be disregarded as if the color would have been 100% opaque.${
17
+ token !== undefined ? `\n ↳ Token: "${token.name}" in file: "${token.filePath}"` : ''
18
+ }`,
19
+ )
20
+ }
21
+
22
+ return rgba(r, g, b, desiredAlpha)
23
+ }
@@ -0,0 +1,16 @@
1
+ /**
2
+ * checks if all required properties exist on token
3
+ * @param object - tokenValue
4
+ * @param array - property names
5
+ * @returns void or throws error
6
+ */
7
+ export const checkRequiredTokenProperties = (
8
+ tokenValue: Record<string, unknown>,
9
+ requiredProperties: readonly string[],
10
+ ) => {
11
+ for (const prop of requiredProperties) {
12
+ if (prop in tokenValue === false) {
13
+ throw new Error(`Missing property: ${prop} on token with value ${JSON.stringify(tokenValue)}`)
14
+ }
15
+ }
16
+ }
@@ -0,0 +1,18 @@
1
+ import type StyleDictionary from 'style-dictionary'
2
+ import {invalidTokenValueError, invalidTokenValuePropertyError} from './invalidTokenError'
3
+
4
+ export const getTokenValue = (token: StyleDictionary.TransformedToken, property?: string) => {
5
+ if (token.value === undefined) {
6
+ throw new invalidTokenValueError(token)
7
+ }
8
+ // for composite token if subproperty is needed
9
+ if (typeof property === 'string' && token.value[property] === undefined) {
10
+ throw new invalidTokenValuePropertyError(token, property)
11
+ }
12
+
13
+ if (typeof property === 'string') {
14
+ return token.value[property]
15
+ }
16
+
17
+ return token.value
18
+ }
@@ -0,0 +1,31 @@
1
+ import type {RgbaFloat} from './isRgbaFloat'
2
+
3
+ export const hexToRgbaFloat = (hex: string, alpha?: number): RgbaFloat => {
4
+ // retrieve spots from hex value (hex 3, hex 4, hex 6 or hex 8)
5
+ let result
6
+ if (hex.length > 5) {
7
+ result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})?$/i.exec(hex)
8
+ } else {
9
+ result = /^#?([a-f\d]{1})([a-f\d]{1})([a-f\d]{1})([a-f\d]{1})?$/i.exec(hex)
10
+ }
11
+
12
+ if (result === null) {
13
+ throw new Error('Invalid hex value in "hexToRgbaFloat". Please provide a valid hex3, hex4, hex6 or hex8 value.')
14
+ }
15
+ // doule characters if hex 3 or hex 4
16
+ if (hex.length < 6) {
17
+ result[1] = `${result[1]}${result[1]}` // double the character
18
+ result[2] = `${result[2]}${result[2]}` // double the character
19
+ result[3] = `${result[3]}${result[3]}` // double the character
20
+ if (result[4]) {
21
+ result[4] = `${result[4]}${result[4]}` // double the character
22
+ }
23
+ }
24
+ // return parsed rgba float object using alpha value from token, from hex code or defaults to 1
25
+ return {
26
+ r: parseInt(result[1], 16) / 255,
27
+ g: parseInt(result[2], 16) / 255,
28
+ b: parseInt(result[3], 16) / 255,
29
+ a: alpha !== undefined ? alpha : result[4] ? parseInt(result[4], 16) / 255 : 1,
30
+ }
31
+ }
@@ -0,0 +1,34 @@
1
+ import type {TransformedToken} from 'style-dictionary'
2
+ import {namePathToDotNotation} from '../namePathToDotNotation'
3
+
4
+ const composeValueErrorMessage = (token: TransformedToken) => {
5
+ // eslint-disable-next-line i18n-text/no-en
6
+ return `Invalid token "${namePathToDotNotation.transformer(token, {})}" in file "${
7
+ token.filePath
8
+ }". Transformed value: "${JSON.stringify(token.value)}". ${
9
+ token.original.value ? `Original value: "${JSON.stringify(token.original.value)}" ` : ''
10
+ }This may be due to referencing a token that does not exists.`
11
+ }
12
+
13
+ const composeValuePropertyErrorMessage = (token: TransformedToken, property: string) => {
14
+ // eslint-disable-next-line i18n-text/no-en
15
+ return `Invalid property "${property}" of token "${namePathToDotNotation.transformer(token, {})}" in file "${
16
+ token.filePath
17
+ }". Transformed property value: "${token.value[property]}". ${
18
+ token.original.value ? `Original value: "${token.original.value[property]}" ` : ''
19
+ }This may be due to referencing a token that does not exists.`
20
+ }
21
+
22
+ export class invalidTokenValueError extends Error {
23
+ constructor(token: TransformedToken) {
24
+ super(composeValueErrorMessage(token))
25
+ Error.captureStackTrace(this, invalidTokenValueError)
26
+ }
27
+ }
28
+
29
+ export class invalidTokenValuePropertyError extends Error {
30
+ constructor(token: TransformedToken, property: string) {
31
+ super(composeValuePropertyErrorMessage(token, property))
32
+ Error.captureStackTrace(this, invalidTokenValuePropertyError)
33
+ }
34
+ }