@primer/primitives 9.1.2 → 10.0.0-rc.367a0502

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 (219) hide show
  1. package/package.json +9 -8
  2. package/dist/build/PrimerStyleDictionary.d.ts +0 -9
  3. package/dist/build/PrimerStyleDictionary.js +0 -92
  4. package/dist/build/filters/index.d.ts +0 -13
  5. package/dist/build/filters/index.js +0 -29
  6. package/dist/build/filters/isBorder.d.ts +0 -7
  7. package/dist/build/filters/isBorder.js +0 -12
  8. package/dist/build/filters/isColor.d.ts +0 -7
  9. package/dist/build/filters/isColor.js +0 -12
  10. package/dist/build/filters/isColorWithAlpha.d.ts +0 -7
  11. package/dist/build/filters/isColorWithAlpha.js +0 -13
  12. package/dist/build/filters/isColorWithMix.d.ts +0 -7
  13. package/dist/build/filters/isColorWithMix.js +0 -28
  14. package/dist/build/filters/isDeprecated.d.ts +0 -7
  15. package/dist/build/filters/isDeprecated.js +0 -12
  16. package/dist/build/filters/isDimension.d.ts +0 -7
  17. package/dist/build/filters/isDimension.js +0 -12
  18. package/dist/build/filters/isDuration.d.ts +0 -7
  19. package/dist/build/filters/isDuration.js +0 -12
  20. package/dist/build/filters/isFontFamily.d.ts +0 -7
  21. package/dist/build/filters/isFontFamily.js +0 -12
  22. package/dist/build/filters/isFontWeight.d.ts +0 -7
  23. package/dist/build/filters/isFontWeight.js +0 -12
  24. package/dist/build/filters/isFromFile.d.ts +0 -8
  25. package/dist/build/filters/isFromFile.js +0 -14
  26. package/dist/build/filters/isNumber.d.ts +0 -7
  27. package/dist/build/filters/isNumber.js +0 -10
  28. package/dist/build/filters/isShadow.d.ts +0 -7
  29. package/dist/build/filters/isShadow.js +0 -12
  30. package/dist/build/filters/isSource.d.ts +0 -7
  31. package/dist/build/filters/isSource.js +0 -12
  32. package/dist/build/filters/isTypography.d.ts +0 -7
  33. package/dist/build/filters/isTypography.js +0 -12
  34. package/dist/build/formats/cssAdvanced.d.ts +0 -2
  35. package/dist/build/formats/cssAdvanced.js +0 -84
  36. package/dist/build/formats/cssCustomMedia.d.ts +0 -7
  37. package/dist/build/formats/cssCustomMedia.js +0 -25
  38. package/dist/build/formats/index.d.ts +0 -9
  39. package/dist/build/formats/index.js +0 -21
  40. package/dist/build/formats/javascriptCommonJs.d.ts +0 -7
  41. package/dist/build/formats/javascriptCommonJs.js +0 -25
  42. package/dist/build/formats/javascriptEsm.d.ts +0 -7
  43. package/dist/build/formats/javascriptEsm.js +0 -25
  44. package/dist/build/formats/jsonFigma.d.ts +0 -7
  45. package/dist/build/formats/jsonFigma.js +0 -116
  46. package/dist/build/formats/jsonNestedPrefixed.d.ts +0 -8
  47. package/dist/build/formats/jsonNestedPrefixed.js +0 -28
  48. package/dist/build/formats/jsonOneDimensional.d.ts +0 -8
  49. package/dist/build/formats/jsonOneDimensional.js +0 -24
  50. package/dist/build/formats/jsonPostCssFallback.d.ts +0 -8
  51. package/dist/build/formats/jsonPostCssFallback.js +0 -21
  52. package/dist/build/formats/typescriptExportDefinition.d.ts +0 -7
  53. package/dist/build/formats/typescriptExportDefinition.js +0 -166
  54. package/dist/build/formats/utilities/jsonToFlat.d.ts +0 -11
  55. package/dist/build/formats/utilities/jsonToFlat.js +0 -12
  56. package/dist/build/formats/utilities/jsonToNestedValue.d.ts +0 -8
  57. package/dist/build/formats/utilities/jsonToNestedValue.js +0 -25
  58. package/dist/build/formats/utilities/prefixTokens.d.ts +0 -8
  59. package/dist/build/formats/utilities/prefixTokens.js +0 -17
  60. package/dist/build/parsers/index.d.ts +0 -1
  61. package/dist/build/parsers/index.js +0 -5
  62. package/dist/build/parsers/w3cJsonParser.d.ts +0 -6
  63. package/dist/build/parsers/w3cJsonParser.js +0 -27
  64. package/dist/build/platforms/css.d.ts +0 -2
  65. package/dist/build/platforms/css.js +0 -87
  66. package/dist/build/platforms/deprecatedJson.d.ts +0 -2
  67. package/dist/build/platforms/deprecatedJson.js +0 -17
  68. package/dist/build/platforms/docJson.d.ts +0 -2
  69. package/dist/build/platforms/docJson.js +0 -34
  70. package/dist/build/platforms/fallbacks.d.ts +0 -2
  71. package/dist/build/platforms/fallbacks.js +0 -34
  72. package/dist/build/platforms/figma.d.ts +0 -2
  73. package/dist/build/platforms/figma.js +0 -53
  74. package/dist/build/platforms/index.d.ts +0 -10
  75. package/dist/build/platforms/index.js +0 -23
  76. package/dist/build/platforms/javascript.d.ts +0 -2
  77. package/dist/build/platforms/javascript.js +0 -30
  78. package/dist/build/platforms/json.d.ts +0 -2
  79. package/dist/build/platforms/json.js +0 -32
  80. package/dist/build/platforms/styleLint.d.ts +0 -2
  81. package/dist/build/platforms/styleLint.js +0 -34
  82. package/dist/build/platforms/typeDefinitions.d.ts +0 -2
  83. package/dist/build/platforms/typeDefinitions.js +0 -30
  84. package/dist/build/platforms/typescript.d.ts +0 -2
  85. package/dist/build/platforms/typescript.js +0 -30
  86. package/dist/build/schemas/alphaValue.d.ts +0 -2
  87. package/dist/build/schemas/alphaValue.js +0 -8
  88. package/dist/build/schemas/baseToken.d.ts +0 -11
  89. package/dist/build/schemas/baseToken.js +0 -10
  90. package/dist/build/schemas/borderToken.d.ts +0 -51
  91. package/dist/build/schemas/borderToken.js +0 -20
  92. package/dist/build/schemas/collections.d.ts +0 -6
  93. package/dist/build/schemas/collections.js +0 -18
  94. package/dist/build/schemas/colorHexValue.d.ts +0 -2
  95. package/dist/build/schemas/colorHexValue.js +0 -12
  96. package/dist/build/schemas/colorToken.d.ts +0 -80
  97. package/dist/build/schemas/colorToken.js +0 -52
  98. package/dist/build/schemas/designToken.d.ts +0 -2
  99. package/dist/build/schemas/designToken.js +0 -37
  100. package/dist/build/schemas/dimensionToken.d.ts +0 -52
  101. package/dist/build/schemas/dimensionToken.js +0 -36
  102. package/dist/build/schemas/dimensionValue.d.ts +0 -2
  103. package/dist/build/schemas/dimensionValue.js +0 -12
  104. package/dist/build/schemas/durationToken.d.ts +0 -18
  105. package/dist/build/schemas/durationToken.js +0 -14
  106. package/dist/build/schemas/durationValue.d.ts +0 -2
  107. package/dist/build/schemas/durationValue.js +0 -8
  108. package/dist/build/schemas/fontFamilyToken.d.ts +0 -52
  109. package/dist/build/schemas/fontFamilyToken.js +0 -23
  110. package/dist/build/schemas/fontWeightToken.d.ts +0 -52
  111. package/dist/build/schemas/fontWeightToken.js +0 -24
  112. package/dist/build/schemas/fontWeightValue.d.ts +0 -2
  113. package/dist/build/schemas/fontWeightValue.js +0 -9
  114. package/dist/build/schemas/numberToken.d.ts +0 -71
  115. package/dist/build/schemas/numberToken.js +0 -30
  116. package/dist/build/schemas/referenceValue.d.ts +0 -2
  117. package/dist/build/schemas/referenceValue.js +0 -8
  118. package/dist/build/schemas/scopes.d.ts +0 -5
  119. package/dist/build/schemas/scopes.js +0 -34
  120. package/dist/build/schemas/shadowToken.d.ts +0 -157
  121. package/dist/build/schemas/shadowToken.js +0 -46
  122. package/dist/build/schemas/stringToken.d.ts +0 -18
  123. package/dist/build/schemas/stringToken.js +0 -13
  124. package/dist/build/schemas/tokenName.d.ts +0 -2
  125. package/dist/build/schemas/tokenName.js +0 -8
  126. package/dist/build/schemas/tokenType.d.ts +0 -3
  127. package/dist/build/schemas/tokenType.js +0 -6
  128. package/dist/build/schemas/typographyToken.d.ts +0 -59
  129. package/dist/build/schemas/typographyToken.js +0 -21
  130. package/dist/build/schemas/validTokenType.d.ts +0 -5
  131. package/dist/build/schemas/validTokenType.js +0 -34
  132. package/dist/build/schemas/viewportRangeToken.d.ts +0 -18
  133. package/dist/build/schemas/viewportRangeToken.js +0 -13
  134. package/dist/build/transformers/borderToCss.d.ts +0 -8
  135. package/dist/build/transformers/borderToCss.js +0 -38
  136. package/dist/build/transformers/colorToHex.d.ts +0 -8
  137. package/dist/build/transformers/colorToHex.js +0 -26
  138. package/dist/build/transformers/colorToHexMix.d.ts +0 -8
  139. package/dist/build/transformers/colorToHexMix.js +0 -25
  140. package/dist/build/transformers/colorToRgbAlpha.d.ts +0 -8
  141. package/dist/build/transformers/colorToRgbAlpha.js +0 -22
  142. package/dist/build/transformers/colorToRgbaFloat.d.ts +0 -8
  143. package/dist/build/transformers/colorToRgbaFloat.js +0 -50
  144. package/dist/build/transformers/dimensionToPixelUnitless.d.ts +0 -8
  145. package/dist/build/transformers/dimensionToPixelUnitless.js +0 -50
  146. package/dist/build/transformers/dimensionToRem.d.ts +0 -8
  147. package/dist/build/transformers/dimensionToRem.js +0 -47
  148. package/dist/build/transformers/dimensionToRemPxArray.d.ts +0 -8
  149. package/dist/build/transformers/dimensionToRemPxArray.js +0 -47
  150. package/dist/build/transformers/durationToCss.d.ts +0 -8
  151. package/dist/build/transformers/durationToCss.js +0 -30
  152. package/dist/build/transformers/figmaAttributes.d.ts +0 -8
  153. package/dist/build/transformers/figmaAttributes.js +0 -57
  154. package/dist/build/transformers/floatToPixel.d.ts +0 -15
  155. package/dist/build/transformers/floatToPixel.js +0 -41
  156. package/dist/build/transformers/fontFamilyToCss.d.ts +0 -14
  157. package/dist/build/transformers/fontFamilyToCss.js +0 -40
  158. package/dist/build/transformers/fontFamilyToFigma.d.ts +0 -14
  159. package/dist/build/transformers/fontFamilyToFigma.js +0 -46
  160. package/dist/build/transformers/fontWeightToNumber.d.ts +0 -9
  161. package/dist/build/transformers/fontWeightToNumber.js +0 -53
  162. package/dist/build/transformers/index.d.ts +0 -24
  163. package/dist/build/transformers/index.js +0 -51
  164. package/dist/build/transformers/jsonDeprecated.d.ts +0 -8
  165. package/dist/build/transformers/jsonDeprecated.js +0 -16
  166. package/dist/build/transformers/namePathToCamelCase.d.ts +0 -8
  167. package/dist/build/transformers/namePathToCamelCase.js +0 -14
  168. package/dist/build/transformers/namePathToDotNotation.d.ts +0 -8
  169. package/dist/build/transformers/namePathToDotNotation.js +0 -33
  170. package/dist/build/transformers/namePathToFigma.d.ts +0 -9
  171. package/dist/build/transformers/namePathToFigma.js +0 -24
  172. package/dist/build/transformers/namePathToKebabCase.d.ts +0 -8
  173. package/dist/build/transformers/namePathToKebabCase.js +0 -18
  174. package/dist/build/transformers/namePathToPascalCase.d.ts +0 -8
  175. package/dist/build/transformers/namePathToPascalCase.js +0 -14
  176. package/dist/build/transformers/namePathToSlashNotation.d.ts +0 -8
  177. package/dist/build/transformers/namePathToSlashNotation.js +0 -18
  178. package/dist/build/transformers/shadowToCss.d.ts +0 -8
  179. package/dist/build/transformers/shadowToCss.js +0 -35
  180. package/dist/build/transformers/typographyToCss.d.ts +0 -8
  181. package/dist/build/transformers/typographyToCss.js +0 -29
  182. package/dist/build/transformers/utilities/alpha.d.ts +0 -9
  183. package/dist/build/transformers/utilities/alpha.js +0 -20
  184. package/dist/build/transformers/utilities/checkRequiredTokenProperties.d.ts +0 -7
  185. package/dist/build/transformers/utilities/checkRequiredTokenProperties.js +0 -17
  186. package/dist/build/transformers/utilities/getTokenValue.d.ts +0 -2
  187. package/dist/build/transformers/utilities/getTokenValue.js +0 -18
  188. package/dist/build/transformers/utilities/hasSpaceInString.d.ts +0 -1
  189. package/dist/build/transformers/utilities/hasSpaceInString.js +0 -10
  190. package/dist/build/transformers/utilities/hexToRgbaFloat.d.ts +0 -2
  191. package/dist/build/transformers/utilities/hexToRgbaFloat.js +0 -33
  192. package/dist/build/transformers/utilities/invalidTokenError.d.ts +0 -7
  193. package/dist/build/transformers/utilities/invalidTokenError.js +0 -26
  194. package/dist/build/transformers/utilities/isRgbaFloat.d.ts +0 -7
  195. package/dist/build/transformers/utilities/isRgbaFloat.js +0 -24
  196. package/dist/build/transformers/utilities/mix.d.ts +0 -5
  197. package/dist/build/transformers/utilities/mix.js +0 -40
  198. package/dist/build/transformers/utilities/rgbaFloatToHex.d.ts +0 -6
  199. package/dist/build/transformers/utilities/rgbaFloatToHex.js +0 -15
  200. package/dist/build/utilities/copyFromDir.d.ts +0 -8
  201. package/dist/build/utilities/copyFromDir.js +0 -34
  202. package/dist/build/utilities/filterStringArray.d.ts +0 -1
  203. package/dist/build/utilities/filterStringArray.js +0 -17
  204. package/dist/build/utilities/getFlag.d.ts +0 -8
  205. package/dist/build/utilities/getFlag.js +0 -16
  206. package/dist/build/utilities/index.d.ts +0 -3
  207. package/dist/build/utilities/index.js +0 -9
  208. package/dist/build/utilities/joinFriendly.d.ts +0 -1
  209. package/dist/build/utilities/joinFriendly.js +0 -5
  210. package/dist/build/utilities/schemaErrorMessage.d.ts +0 -1
  211. package/dist/build/utilities/schemaErrorMessage.js +0 -5
  212. package/dist/build/utilities/toCamelCase.d.ts +0 -1
  213. package/dist/build/utilities/toCamelCase.js +0 -20
  214. package/dist/build/utilities/toPascalCase.d.ts +0 -1
  215. package/dist/build/utilities/toPascalCase.js +0 -17
  216. package/dist/build/utilities/treeWalker.d.ts +0 -8
  217. package/dist/build/utilities/treeWalker.js +0 -27
  218. package/dist/build/utilities/upperCaseFirstCharacter.d.ts +0 -8
  219. package/dist/build/utilities/upperCaseFirstCharacter.js +0 -14
@@ -1,50 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.colorToRgbaFloat = void 0;
7
- const color2k_1 = require("color2k");
8
- const filters_1 = require("../filters");
9
- const getTokenValue_1 = require("./utilities/getTokenValue");
10
- const rgbaFloatToHex_1 = require("./utilities/rgbaFloatToHex");
11
- const mix_1 = __importDefault(require("./utilities/mix"));
12
- const hexToRgbaFloat_1 = require("./utilities/hexToRgbaFloat");
13
- const isRgbaFloat_1 = require("./utilities/isRgbaFloat");
14
- const toRgbaFloat = (token, alpha) => {
15
- var _a;
16
- let tokenValue = (0, getTokenValue_1.getTokenValue)(token);
17
- let tokenMixColor = (_a = token.mix) === null || _a === void 0 ? void 0 : _a.color;
18
- // get hex value from color string
19
- if ((0, isRgbaFloat_1.isRgbaFloat)(tokenValue)) {
20
- tokenValue = (0, rgbaFloatToHex_1.rgbaFloatToHex)(tokenValue, false);
21
- }
22
- if (tokenMixColor && (0, isRgbaFloat_1.isRgbaFloat)(tokenMixColor)) {
23
- tokenMixColor = (0, rgbaFloatToHex_1.rgbaFloatToHex)(tokenMixColor, false);
24
- }
25
- let hex = (0, color2k_1.toHex)(tokenValue);
26
- // mix color with mix color and weight
27
- if (token.mix && token.mix.color && token.mix.weight) {
28
- hex = (0, color2k_1.toHex)((0, mix_1.default)(tokenValue, tokenMixColor, token.mix.weight));
29
- }
30
- // return color as RgbaFloat
31
- return (0, hexToRgbaFloat_1.hexToRgbaFloat)(hex, alpha);
32
- };
33
- /**
34
- * @description converts color tokens rgba float with values from 0 - 1
35
- * @type value transformer — [StyleDictionary.ValueTransform](https://github.com/amzn/style-dictionary/blob/main/types/Transform.d.ts)
36
- * @matcher matches all tokens of $type `color`
37
- * @transformer returns a `rgb` float object
38
- */
39
- exports.colorToRgbaFloat = {
40
- type: `value`,
41
- transitive: true,
42
- matcher: filters_1.isColor,
43
- transformer: (token) => {
44
- // skip if value is already rgb float
45
- if ((0, isRgbaFloat_1.isRgbaFloat)(token.value) && !('mix' in token) && !('alpha' in token))
46
- return token.value;
47
- // convert hex or rgb values to rgba float
48
- return toRgbaFloat(token, token.alpha);
49
- },
50
- };
@@ -1,8 +0,0 @@
1
- import type StyleDictionary from 'style-dictionary';
2
- /**
3
- * @description converts dimension tokens value to pixel value without unit, ignores `em` as they are relative to the font size of the parent element
4
- * @type value transformer — [StyleDictionary.ValueTransform](https://github.com/amzn/style-dictionary/blob/main/types/Transform.d.ts)
5
- * @matcher matches all tokens of $type `dimension`
6
- * @transformer returns a float number
7
- */
8
- export declare const dimensionToPixelUnitless: StyleDictionary.Transform;
@@ -1,50 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.dimensionToPixelUnitless = void 0;
4
- const filters_1 = require("../filters");
5
- /**
6
- * @description base font size from options or 16
7
- * @param options
8
- * @returns number
9
- */
10
- const getBasePxFontSize = (options) => (options && options.basePxFontSize) || 16;
11
- /**
12
- * @description checks if token value has a specific unit
13
- * @param value token value
14
- * @param unit unit string like px or value
15
- * @returns boolean
16
- */
17
- const hasUnit = (value, unit) => {
18
- if (typeof value === 'number') {
19
- return false;
20
- }
21
- return value.indexOf(unit) > -1;
22
- };
23
- /**
24
- * @description converts dimension tokens value to pixel value without unit, ignores `em` as they are relative to the font size of the parent element
25
- * @type value transformer — [StyleDictionary.ValueTransform](https://github.com/amzn/style-dictionary/blob/main/types/Transform.d.ts)
26
- * @matcher matches all tokens of $type `dimension`
27
- * @transformer returns a float number
28
- */
29
- exports.dimensionToPixelUnitless = {
30
- type: `value`,
31
- transitive: true,
32
- matcher: filters_1.isDimension,
33
- transformer: (token, options) => {
34
- const baseFont = getBasePxFontSize(options);
35
- const floatVal = parseFloat(token.value);
36
- if (isNaN(floatVal)) {
37
- throw new Error(`Invalid dimension token: '${token.name}: ${token.value}' is not valid and cannot be transform to 'float' \n`);
38
- }
39
- if (floatVal === 0) {
40
- return 0;
41
- }
42
- if (hasUnit(token.value, 'rem')) {
43
- return floatVal * baseFont;
44
- }
45
- if (hasUnit(token.value, 'px')) {
46
- return floatVal;
47
- }
48
- return token.value;
49
- },
50
- };
@@ -1,8 +0,0 @@
1
- import type StyleDictionary from 'style-dictionary';
2
- /**
3
- * @description converts dimension tokens value to `rem`, ignores `em` as they are relative to the font size of the parent element
4
- * @type value transformer — [StyleDictionary.ValueTransform](https://github.com/amzn/style-dictionary/blob/main/types/Transform.d.ts)
5
- * @matcher matches all tokens of $type `dimension`
6
- * @transformer returns a `rem` string
7
- */
8
- export declare const dimensionToRem: StyleDictionary.Transform;
@@ -1,47 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.dimensionToRem = void 0;
4
- const filters_1 = require("../filters");
5
- /**
6
- * @description base font size from options or 16
7
- * @param options
8
- * @returns number
9
- */
10
- const getBasePxFontSize = (options) => (options && options.basePxFontSize) || 16;
11
- /**
12
- * @description checks if token value has a specific unit
13
- * @param value token value
14
- * @param unit unit string like px or value
15
- * @returns boolean
16
- */
17
- const hasUnit = (value, unit) => {
18
- if (typeof value === 'number') {
19
- return false;
20
- }
21
- return value.indexOf(unit) > -1;
22
- };
23
- /**
24
- * @description converts dimension tokens value to `rem`, ignores `em` as they are relative to the font size of the parent element
25
- * @type value transformer — [StyleDictionary.ValueTransform](https://github.com/amzn/style-dictionary/blob/main/types/Transform.d.ts)
26
- * @matcher matches all tokens of $type `dimension`
27
- * @transformer returns a `rem` string
28
- */
29
- exports.dimensionToRem = {
30
- type: `value`,
31
- transitive: true,
32
- matcher: filters_1.isDimension,
33
- transformer: (token, options) => {
34
- const baseFont = getBasePxFontSize(options);
35
- const floatVal = parseFloat(token.value);
36
- if (isNaN(floatVal)) {
37
- throw new Error(`Invalid dimension token: '${token.name}: ${token.value}' is not valid and cannot be transform to 'rem' \n`);
38
- }
39
- if (floatVal === 0) {
40
- return '0';
41
- }
42
- if (hasUnit(token.value, 'rem') || hasUnit(token.value, 'em')) {
43
- return token.value;
44
- }
45
- return `${floatVal / baseFont}rem`;
46
- },
47
- };
@@ -1,8 +0,0 @@
1
- import type StyleDictionary from 'style-dictionary';
2
- /**
3
- * @description converts dimension tokens value to `rem`, ignores `em` as they are relative to the font size of the parent element
4
- * @type value transformer — [StyleDictionary.ValueTransform](https://github.com/amzn/style-dictionary/blob/main/types/Transform.d.ts)
5
- * @matcher matches all tokens of $type `dimension`
6
- * @transformer returns an array with the `rem` and `pixel` string
7
- */
8
- export declare const dimensionToRemPxArray: StyleDictionary.Transform;
@@ -1,47 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.dimensionToRemPxArray = void 0;
4
- const filters_1 = require("../filters");
5
- /**
6
- * @description base font size from options or 16
7
- * @param options
8
- * @returns number
9
- */
10
- const getBasePxFontSize = (options) => (options && options.basePxFontSize) || 16;
11
- /**
12
- * @description checks if token value has a specific unit
13
- * @param value token value
14
- * @param unit unit string like px or value
15
- * @returns boolean
16
- */
17
- const hasUnit = (value, unit) => {
18
- if (typeof value === 'number') {
19
- return false;
20
- }
21
- return value.indexOf(unit) > -1;
22
- };
23
- /**
24
- * @description converts dimension tokens value to `rem`, ignores `em` as they are relative to the font size of the parent element
25
- * @type value transformer — [StyleDictionary.ValueTransform](https://github.com/amzn/style-dictionary/blob/main/types/Transform.d.ts)
26
- * @matcher matches all tokens of $type `dimension`
27
- * @transformer returns an array with the `rem` and `pixel` string
28
- */
29
- exports.dimensionToRemPxArray = {
30
- type: `value`,
31
- transitive: true,
32
- matcher: filters_1.isDimension,
33
- transformer: (token, options) => {
34
- const baseFont = getBasePxFontSize(options);
35
- const floatVal = parseFloat(token.value);
36
- if (isNaN(floatVal)) {
37
- throw new Error(`Invalid dimension token: '${token.name}: ${token.value}' is not valid and cannot be transform to 'rem' \n`);
38
- }
39
- if (floatVal === 0) {
40
- return ['0', '0'];
41
- }
42
- if (hasUnit(token.value, 'rem') || hasUnit(token.value, 'em')) {
43
- return [token.value, `${floatVal * baseFont}px`];
44
- }
45
- return [`${floatVal / baseFont}rem`, `${floatVal}px`];
46
- },
47
- };
@@ -1,8 +0,0 @@
1
- import type StyleDictionary from 'style-dictionary';
2
- /**
3
- * @description converts duration tokens string value to number with `ms` unit
4
- * @type value transformer — [StyleDictionary.ValueTransform](https://github.com/amzn/style-dictionary/blob/main/types/Transform.d.ts)
5
- * @matcher matches all tokens of $type `duration`
6
- * @transformer returns a css duration
7
- */
8
- export declare const durationToCss: StyleDictionary.Transform;
@@ -1,30 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.durationToCss = void 0;
4
- const isDuration_1 = require("../filters/isDuration");
5
- /**
6
- * @description converts duration tokens string value to number with `ms` unit
7
- * @type value transformer — [StyleDictionary.ValueTransform](https://github.com/amzn/style-dictionary/blob/main/types/Transform.d.ts)
8
- * @matcher matches all tokens of $type `duration`
9
- * @transformer returns a css duration
10
- */
11
- exports.durationToCss = {
12
- type: `value`,
13
- transitive: true,
14
- matcher: isDuration_1.isDuration,
15
- transformer: (token, _options) => {
16
- // throw an error if token value is not a string or does not end with `ms`
17
- if (typeof token.value !== `string` || !token.value.endsWith(`ms`)) {
18
- throw new Error(`duration token value must be a string with an "ms" unit`);
19
- }
20
- // get value
21
- let value = parseInt(token.value.replace('ms', ''));
22
- let unit = `ms`;
23
- if (value >= 1000) {
24
- value = value / 1000;
25
- unit = `s`;
26
- }
27
- // return value
28
- return `${value}${unit}`;
29
- },
30
- };
@@ -1,8 +0,0 @@
1
- import type StyleDictionary from 'style-dictionary';
2
- /**
3
- * @description retrieves figma attributes from token and adds them to attributes
4
- * @type attribute transformer — [StyleDictionary.AttributeTransform](https://github.com/amzn/style-dictionary/blob/main/types/Transform.d.ts)
5
- * @matcher matches all tokens
6
- * @transformer returns ab object of figma attributes
7
- */
8
- export declare const figmaAttributes: StyleDictionary.Transform;
@@ -1,57 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.figmaAttributes = void 0;
4
- const figmaScopes = {
5
- all: ['ALL_SCOPES'],
6
- radius: ['CORNER_RADIUS'],
7
- size: ['WIDTH_HEIGHT'],
8
- gap: ['GAP'],
9
- bgColor: ['FRAME_FILL', 'SHAPE_FILL'],
10
- fgColor: ['TEXT_FILL', 'SHAPE_FILL'],
11
- effectColor: ['EFFECT_COLOR'],
12
- effectFloat: ['EFFECT_FLOAT'],
13
- borderColor: ['STROKE_COLOR'],
14
- borderWidth: ['STROKE_FLOAT'],
15
- opacity: ['OPACITY'],
16
- fontFamily: ['FONT_FAMILY'],
17
- fontStyle: ['FONT_STYLE'],
18
- fontWeight: ['FONT_WEIGHT'],
19
- fontSize: ['FONT_SIZE'],
20
- lineHeight: ['LINE_HEIGHT'],
21
- letterSpacing: ['LETTER_SPACING'],
22
- paragraphSpacing: ['PARAGRAPH_SPACING'],
23
- paragraphIndent: ['PARAGRAPH_INDENT'],
24
- };
25
- const getScopes = (scopes) => {
26
- if (typeof scopes === 'string')
27
- scopes = [scopes];
28
- if (Array.isArray(scopes))
29
- return scopes
30
- .map(scope => {
31
- if (scope in figmaScopes)
32
- return figmaScopes[scope];
33
- throw new Error(`Invalid scope: ${scope}`);
34
- })
35
- .flat();
36
- return ['ALL_SCOPES'];
37
- };
38
- /**
39
- * @description retrieves figma attributes from token and adds them to attributes
40
- * @type attribute transformer — [StyleDictionary.AttributeTransform](https://github.com/amzn/style-dictionary/blob/main/types/Transform.d.ts)
41
- * @matcher matches all tokens
42
- * @transformer returns ab object of figma attributes
43
- */
44
- exports.figmaAttributes = {
45
- type: `attribute`,
46
- transformer: (token, platform = {}) => {
47
- var _a, _b;
48
- const { mode, collection, scopes, group, codeSyntax } = ((_a = token.$extensions) === null || _a === void 0 ? void 0 : _a['org.primer.figma']) || {};
49
- return {
50
- mode: ((_b = platform.options) === null || _b === void 0 ? void 0 : _b.mode) || mode || 'default',
51
- collection,
52
- group: group || collection,
53
- scopes: getScopes(scopes),
54
- codeSyntax,
55
- };
56
- },
57
- };
@@ -1,15 +0,0 @@
1
- import type StyleDictionary from 'style-dictionary';
2
- /**
3
- * takes a value and returns it if its a px string if it is a float and the token has a fontSize value in extensions['org.primer.data']
4
- * @param value
5
- * @returns string
6
- */
7
- export declare const convertFloatToPixel: (token: StyleDictionary.TransformedToken, unitless?: boolean) => any;
8
- /**
9
- * @description converts a float value to a pixel value based on the provided fontSize on the tokersn extension
10
- * @type value transformer — [StyleDictionary.ValueTransform](https://github.com/amzn/style-dictionary/blob/main/types/Transform.d.ts)
11
- * @matcher matches all tokens of $type `isNumber`
12
- * @transformer returns a pixel string
13
- */
14
- export declare const floatToPixel: StyleDictionary.Transform;
15
- export declare const floatToPixelUnitless: StyleDictionary.Transform;
@@ -1,41 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.floatToPixelUnitless = exports.floatToPixel = exports.convertFloatToPixel = void 0;
4
- const filters_1 = require("../filters");
5
- /**
6
- * takes a value and returns it if its a px string if it is a float and the token has a fontSize value in extensions['org.primer.data']
7
- * @param value
8
- * @returns string
9
- */
10
- const convertFloatToPixel = (token, unitless = false) => {
11
- var _a, _b, _c, _d, _e, _f;
12
- // short circut if value is not a number
13
- if (typeof token.value !== 'number' ||
14
- !((_b = (_a = token.$extensions) === null || _a === void 0 ? void 0 : _a['org.primer.data']) === null || _b === void 0 ? void 0 : _b.fontSize) ||
15
- typeof ((_d = (_c = token.$extensions) === null || _c === void 0 ? void 0 : _c['org.primer.data']) === null || _d === void 0 ? void 0 : _d.fontSize) !== 'number') {
16
- return token.value;
17
- }
18
- // convert value
19
- const convertedValue = ((_f = (_e = token.$extensions) === null || _e === void 0 ? void 0 : _e['org.primer.data']) === null || _f === void 0 ? void 0 : _f.fontSize) * token.value;
20
- // return converted value
21
- return convertedValue === 0 ? 0 : unitless ? Math.round(convertedValue) : `${Math.round(convertedValue)}px`;
22
- };
23
- exports.convertFloatToPixel = convertFloatToPixel;
24
- /**
25
- * @description converts a float value to a pixel value based on the provided fontSize on the tokersn extension
26
- * @type value transformer — [StyleDictionary.ValueTransform](https://github.com/amzn/style-dictionary/blob/main/types/Transform.d.ts)
27
- * @matcher matches all tokens of $type `isNumber`
28
- * @transformer returns a pixel string
29
- */
30
- exports.floatToPixel = {
31
- type: `value`,
32
- transitive: true,
33
- matcher: filters_1.isNumber,
34
- transformer: (token) => (0, exports.convertFloatToPixel)(token),
35
- };
36
- exports.floatToPixelUnitless = {
37
- type: `value`,
38
- transitive: true,
39
- matcher: filters_1.isNumber,
40
- transformer: (token) => (0, exports.convertFloatToPixel)(token, true),
41
- };
@@ -1,14 +0,0 @@
1
- import type StyleDictionary from 'style-dictionary';
2
- /**
3
- * takes a value and returns it if its a string or concats strings in an array quoting strings with spaces
4
- * @param value
5
- * @returns string
6
- */
7
- export declare const parseFontFamily: (value: unknown) => string;
8
- /**
9
- * @description converts fontFamily tokens value to string
10
- * @type value transformer — [StyleDictionary.ValueTransform](https://github.com/amzn/style-dictionary/blob/main/types/Transform.d.ts)
11
- * @matcher matches all tokens of $type `fontFamily`
12
- * @transformer returns a string
13
- */
14
- export declare const fontFamilyToCss: StyleDictionary.Transform;
@@ -1,40 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.fontFamilyToCss = exports.parseFontFamily = void 0;
4
- const filters_1 = require("../filters");
5
- const getTokenValue_1 = require("./utilities/getTokenValue");
6
- const hasSpaceInString_1 = require("./utilities/hasSpaceInString");
7
- /**
8
- * takes a value and returns it if its a string or concats strings in an array quoting strings with spaces
9
- * @param value
10
- * @returns string
11
- */
12
- const parseFontFamily = (value) => {
13
- if (typeof value === 'string') {
14
- return value;
15
- }
16
- if (Array.isArray(value)) {
17
- return value
18
- .map((string) => {
19
- if (typeof string !== 'string') {
20
- throw new Error(`Invalid value in array ${string}, must be a string`);
21
- }
22
- return (0, hasSpaceInString_1.hasSpaceInString)(string) ? `'${string}'` : string;
23
- })
24
- .join(', ');
25
- }
26
- throw new Error(`Invalid value ${value}, should be a string or array of strings`);
27
- };
28
- exports.parseFontFamily = parseFontFamily;
29
- /**
30
- * @description converts fontFamily tokens value to string
31
- * @type value transformer — [StyleDictionary.ValueTransform](https://github.com/amzn/style-dictionary/blob/main/types/Transform.d.ts)
32
- * @matcher matches all tokens of $type `fontFamily`
33
- * @transformer returns a string
34
- */
35
- exports.fontFamilyToCss = {
36
- type: `value`,
37
- transitive: true,
38
- matcher: filters_1.isFontFamily,
39
- transformer: (token) => (0, exports.parseFontFamily)((0, getTokenValue_1.getTokenValue)(token)),
40
- };
@@ -1,14 +0,0 @@
1
- import type StyleDictionary from 'style-dictionary';
2
- /**
3
- * takes a value and returns it if its a string or concats strings in an array quoting strings with spaces
4
- * @param value
5
- * @returns string
6
- */
7
- export declare const parseFontFamily: (token: StyleDictionary.TransformedToken, fontFamilies?: Record<string, string>) => string;
8
- /**
9
- * @description converts fontFamily tokens value to string
10
- * @type value transformer — [StyleDictionary.ValueTransform](https://github.com/amzn/style-dictionary/blob/main/types/Transform.d.ts)
11
- * @matcher matches all tokens of $type `fontFamily`
12
- * @transformer returns a string
13
- */
14
- export declare const fontFamilyToFigma: StyleDictionary.Transform;
@@ -1,46 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.fontFamilyToFigma = exports.parseFontFamily = void 0;
4
- const filters_1 = require("../filters");
5
- const hasSpaceInString_1 = require("./utilities/hasSpaceInString");
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
- const parseFontFamily = (token, fontFamilies = {}) => {
12
- // return value from fontFamilies
13
- if (token.name in fontFamilies) {
14
- return fontFamilies[token.name];
15
- }
16
- // return string
17
- if (typeof token.value === 'string') {
18
- return token.value;
19
- }
20
- // return stringified array
21
- if (Array.isArray(token.value)) {
22
- return token.value
23
- .map((string) => {
24
- if (typeof string !== 'string') {
25
- throw new Error(`Invalid value in array ${string}, must be a string`);
26
- }
27
- return (0, hasSpaceInString_1.hasSpaceInString)(string) ? `'${string}'` : string;
28
- })
29
- .join(', ');
30
- }
31
- // invalid value
32
- throw new Error(`Invalid value ${token.value}, should be a string or array of strings`);
33
- };
34
- exports.parseFontFamily = parseFontFamily;
35
- /**
36
- * @description converts fontFamily tokens value to string
37
- * @type value transformer — [StyleDictionary.ValueTransform](https://github.com/amzn/style-dictionary/blob/main/types/Transform.d.ts)
38
- * @matcher matches all tokens of $type `fontFamily`
39
- * @transformer returns a string
40
- */
41
- exports.fontFamilyToFigma = {
42
- type: `value`,
43
- transitive: true,
44
- matcher: filters_1.isFontFamily,
45
- transformer: (token, platform) => { var _a; return (0, exports.parseFontFamily)(token, (_a = platform.options) === null || _a === void 0 ? void 0 : _a.fontFamilies); },
46
- };
@@ -1,9 +0,0 @@
1
- import type StyleDictionary from 'style-dictionary';
2
- export declare const parseFontWeight: (value: unknown) => number;
3
- /**
4
- * @description converts fontWeight tokens value to numeric value
5
- * @type value transformer — [StyleDictionary.ValueTransform](https://github.com/amzn/style-dictionary/blob/main/types/Transform.d.ts)
6
- * @matcher matches all tokens of $type `fontWeight`
7
- * @transformer returns a number
8
- */
9
- export declare const fontWeightToNumber: StyleDictionary.Transform;
@@ -1,53 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.fontWeightToNumber = exports.parseFontWeight = void 0;
4
- const filters_1 = require("../filters");
5
- const getTokenValue_1 = require("./utilities/getTokenValue");
6
- const fontWeightMatrix = {
7
- '100': ['thin', 'hairline'],
8
- '200': ['extra-light', 'ultra-light'],
9
- '300': ['light'],
10
- '400': ['normal', 'regular', 'book'],
11
- '500': ['medium'],
12
- '600': ['semi-bold', 'demi-bold'],
13
- '700': ['bold'],
14
- '800': ['extra-bold', 'ultra-bold'],
15
- '900': ['black', 'heavy'],
16
- '950': ['extra-black', 'ultra-black'],
17
- };
18
- const parseFontWeight = (value) => {
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) => fontWeightMatrix[k].includes(value));
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
- exports.parseFontWeight = parseFontWeight;
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
- exports.fontWeightToNumber = {
49
- type: `value`,
50
- transitive: true,
51
- matcher: filters_1.isFontWeight,
52
- transformer: (token) => (0, exports.parseFontWeight)((0, getTokenValue_1.getTokenValue)(token)),
53
- };
@@ -1,24 +0,0 @@
1
- export { borderToCss } from './borderToCss';
2
- export { colorToHex } from './colorToHex';
3
- export { colorToHexMix } from './colorToHexMix';
4
- export { colorToRgbAlpha } from './colorToRgbAlpha';
5
- export { colorToRgbaFloat } from './colorToRgbaFloat';
6
- export { floatToPixel } from './floatToPixel';
7
- export { floatToPixelUnitless } from './floatToPixel';
8
- export { dimensionToRem } from './dimensionToRem';
9
- export { dimensionToRemPxArray } from './dimensionToRemPxArray';
10
- export { dimensionToPixelUnitless } from './dimensionToPixelUnitless';
11
- export { durationToCss } from './durationToCss';
12
- export { figmaAttributes } from './figmaAttributes';
13
- export { fontFamilyToCss } from './fontFamilyToCss';
14
- export { fontFamilyToFigma } from './fontFamilyToFigma';
15
- export { fontWeightToNumber } from './fontWeightToNumber';
16
- export { jsonDeprecated } from './jsonDeprecated';
17
- export { namePathToCamelCase } from './namePathToCamelCase';
18
- export { namePathToPascalCase } from './namePathToPascalCase';
19
- export { namePathToDotNotation } from './namePathToDotNotation';
20
- export { namePathToFigma } from './namePathToFigma';
21
- export { namePathToKebabCase } from './namePathToKebabCase';
22
- export { namePathToSlashNotation } from './namePathToSlashNotation';
23
- export { shadowToCss } from './shadowToCss';
24
- export { typographyToCss } from './typographyToCss';