@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,7 +0,0 @@
1
- import StyleDictionary from 'style-dictionary';
2
- /**
3
- * @description Converts `StyleDictionary.dictionary.tokens` to css with @custom-media
4
- * @param arguments [FormatterArguments](https://github.com/amzn/style-dictionary/blob/main/types/Format.d.ts)
5
- * @returns formatted `string`
6
- */
7
- export declare const cssCustomMedia: StyleDictionary.Formatter;
@@ -1,25 +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.cssCustomMedia = void 0;
7
- const style_dictionary_1 = __importDefault(require("style-dictionary"));
8
- const sync_1 = __importDefault(require("@prettier/sync"));
9
- const { fileHeader } = style_dictionary_1.default.formatHelpers;
10
- /**
11
- * @description Converts `StyleDictionary.dictionary.tokens` to css with @custom-media
12
- * @param arguments [FormatterArguments](https://github.com/amzn/style-dictionary/blob/main/types/Format.d.ts)
13
- * @returns formatted `string`
14
- */
15
- const cssCustomMedia = ({ dictionary, options: _options, file, }) => {
16
- // add file header
17
- const output = [fileHeader({ file })];
18
- // add single theme css
19
- dictionary.allTokens.map(({ name, value }) => {
20
- output.push(`@custom-media --${name} ${value};`);
21
- });
22
- // return prettified
23
- return sync_1.default.format(output.join('\n'), { parser: 'css', printWidth: 500 });
24
- };
25
- exports.cssCustomMedia = cssCustomMedia;
@@ -1,9 +0,0 @@
1
- export { cssCustomMedia } from './cssCustomMedia';
2
- export { cssAdvanced } from './cssAdvanced';
3
- export { jsonFigma } from './jsonFigma';
4
- export { javascriptCommonJs } from './javascriptCommonJs';
5
- export { javascriptEsm } from './javascriptEsm';
6
- export { jsonNestedPrefixed } from './jsonNestedPrefixed';
7
- export { jsonOneDimensional } from './jsonOneDimensional';
8
- export { jsonPostCssFallback } from './jsonPostCssFallback';
9
- export { typescriptExportDefinition } from './typescriptExportDefinition';
@@ -1,21 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.typescriptExportDefinition = exports.jsonPostCssFallback = exports.jsonOneDimensional = exports.jsonNestedPrefixed = exports.javascriptEsm = exports.javascriptCommonJs = exports.jsonFigma = exports.cssAdvanced = exports.cssCustomMedia = void 0;
4
- var cssCustomMedia_1 = require("./cssCustomMedia");
5
- Object.defineProperty(exports, "cssCustomMedia", { enumerable: true, get: function () { return cssCustomMedia_1.cssCustomMedia; } });
6
- var cssAdvanced_1 = require("./cssAdvanced");
7
- Object.defineProperty(exports, "cssAdvanced", { enumerable: true, get: function () { return cssAdvanced_1.cssAdvanced; } });
8
- var jsonFigma_1 = require("./jsonFigma");
9
- Object.defineProperty(exports, "jsonFigma", { enumerable: true, get: function () { return jsonFigma_1.jsonFigma; } });
10
- var javascriptCommonJs_1 = require("./javascriptCommonJs");
11
- Object.defineProperty(exports, "javascriptCommonJs", { enumerable: true, get: function () { return javascriptCommonJs_1.javascriptCommonJs; } });
12
- var javascriptEsm_1 = require("./javascriptEsm");
13
- Object.defineProperty(exports, "javascriptEsm", { enumerable: true, get: function () { return javascriptEsm_1.javascriptEsm; } });
14
- var jsonNestedPrefixed_1 = require("./jsonNestedPrefixed");
15
- Object.defineProperty(exports, "jsonNestedPrefixed", { enumerable: true, get: function () { return jsonNestedPrefixed_1.jsonNestedPrefixed; } });
16
- var jsonOneDimensional_1 = require("./jsonOneDimensional");
17
- Object.defineProperty(exports, "jsonOneDimensional", { enumerable: true, get: function () { return jsonOneDimensional_1.jsonOneDimensional; } });
18
- var jsonPostCssFallback_1 = require("./jsonPostCssFallback");
19
- Object.defineProperty(exports, "jsonPostCssFallback", { enumerable: true, get: function () { return jsonPostCssFallback_1.jsonPostCssFallback; } });
20
- var typescriptExportDefinition_1 = require("./typescriptExportDefinition");
21
- Object.defineProperty(exports, "typescriptExportDefinition", { enumerable: true, get: function () { return typescriptExportDefinition_1.typescriptExportDefinition; } });
@@ -1,7 +0,0 @@
1
- import StyleDictionary from 'style-dictionary';
2
- /**
3
- * @description Converts `StyleDictionary.dictionary.tokens` to javascript commonJS module
4
- * @param arguments [FormatterArguments](https://github.com/amzn/style-dictionary/blob/main/types/Format.d.ts)
5
- * @returns formatted `string`
6
- */
7
- export declare const javascriptCommonJs: StyleDictionary.Formatter;
@@ -1,25 +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.javascriptCommonJs = void 0;
7
- const sync_1 = __importDefault(require("@prettier/sync"));
8
- const jsonToNestedValue_1 = require("./utilities/jsonToNestedValue");
9
- const prefixTokens_1 = require("./utilities/prefixTokens");
10
- const style_dictionary_1 = __importDefault(require("style-dictionary"));
11
- const { fileHeader } = style_dictionary_1.default.formatHelpers;
12
- /**
13
- * @description Converts `StyleDictionary.dictionary.tokens` to javascript commonJS module
14
- * @param arguments [FormatterArguments](https://github.com/amzn/style-dictionary/blob/main/types/Format.d.ts)
15
- * @returns formatted `string`
16
- */
17
- const javascriptCommonJs = ({ dictionary, file, platform }) => {
18
- // add prefix if defined
19
- const tokens = (0, prefixTokens_1.prefixTokens)(dictionary.tokens, platform);
20
- // add file header and convert output
21
- const output = `${fileHeader({ file })}module.exports = ${JSON.stringify((0, jsonToNestedValue_1.jsonToNestedValue)(tokens), null, 2)}\n`;
22
- // return prettified
23
- return sync_1.default.format(output, { parser: 'typescript', printWidth: 500 });
24
- };
25
- exports.javascriptCommonJs = javascriptCommonJs;
@@ -1,7 +0,0 @@
1
- import StyleDictionary from 'style-dictionary';
2
- /**
3
- * @description Converts `StyleDictionary.dictionary.tokens` to javascript esm (javascript export statement)
4
- * @param arguments [FormatterArguments](https://github.com/amzn/style-dictionary/blob/main/types/Format.d.ts)
5
- * @returns formatted `string`
6
- */
7
- export declare const javascriptEsm: StyleDictionary.Formatter;
@@ -1,25 +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.javascriptEsm = void 0;
7
- const style_dictionary_1 = __importDefault(require("style-dictionary"));
8
- const sync_1 = __importDefault(require("@prettier/sync"));
9
- const jsonToNestedValue_1 = require("./utilities/jsonToNestedValue");
10
- const prefixTokens_1 = require("./utilities/prefixTokens");
11
- const { fileHeader } = style_dictionary_1.default.formatHelpers;
12
- /**
13
- * @description Converts `StyleDictionary.dictionary.tokens` to javascript esm (javascript export statement)
14
- * @param arguments [FormatterArguments](https://github.com/amzn/style-dictionary/blob/main/types/Format.d.ts)
15
- * @returns formatted `string`
16
- */
17
- const javascriptEsm = ({ dictionary, file, platform }) => {
18
- // add prefix if defined
19
- const tokens = (0, prefixTokens_1.prefixTokens)(dictionary.tokens, platform);
20
- // add file header and convert output
21
- const output = `${fileHeader({ file })}export default \n${JSON.stringify((0, jsonToNestedValue_1.jsonToNestedValue)(tokens), null, 2)}\n`;
22
- // return prettified
23
- return sync_1.default.format(output, { parser: 'typescript', printWidth: 500 });
24
- };
25
- exports.javascriptEsm = javascriptEsm;
@@ -1,7 +0,0 @@
1
- import StyleDictionary from 'style-dictionary';
2
- /**
3
- * @description Converts `StyleDictionary.dictionary.tokens` to javascript esm (javascript export statement)
4
- * @param arguments [FormatterArguments](https://github.com/amzn/style-dictionary/blob/main/types/Format.d.ts)
5
- * @returns formatted `string`
6
- */
7
- export declare const jsonFigma: StyleDictionary.Formatter;
@@ -1,116 +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.jsonFigma = void 0;
7
- const style_dictionary_1 = __importDefault(require("style-dictionary"));
8
- const sync_1 = __importDefault(require("@prettier/sync"));
9
- const namePathToFigma_1 = require("../transformers/namePathToFigma");
10
- const hexToRgbaFloat_1 = require("../transformers/utilities/hexToRgbaFloat");
11
- const isRgbaFloat_1 = require("../transformers/utilities/isRgbaFloat");
12
- const { sortByReference } = style_dictionary_1.default.formatHelpers;
13
- const isReference = (string) => /^\{([^\\]*)\}$/g.test(string);
14
- const getReference = (dictionary, refString, platform) => {
15
- var _a;
16
- if (isReference(refString)) {
17
- // retrieve reference token
18
- const refToken = dictionary.getReferences(refString)[0];
19
- // return full reference
20
- return [(_a = refToken.attributes) === null || _a === void 0 ? void 0 : _a.collection, (0, namePathToFigma_1.transformNamePathToFigma)(refToken, platform)].filter(Boolean).join('/');
21
- }
22
- };
23
- const getFigmaType = (type) => {
24
- const validTypes = {
25
- color: 'COLOR',
26
- dimension: 'FLOAT',
27
- fontWeight: 'FLOAT',
28
- number: 'FLOAT',
29
- fontFamily: 'STRING',
30
- };
31
- if (type in validTypes)
32
- return validTypes[type];
33
- throw new Error(`Invalid type: ${type}`);
34
- };
35
- const shadowToVariables = (name, values, token) => {
36
- // floatValue
37
- const floatValue = (property) => ({
38
- name: `${name}/${property}`,
39
- value: parseInt(values[property].replace('px', '')),
40
- type: 'FLOAT',
41
- scopes: ['EFFECT_FLOAT'],
42
- mode,
43
- collection,
44
- group,
45
- });
46
- const { attributes } = token;
47
- const { mode, collection, group } = attributes || {};
48
- return [
49
- floatValue('offsetX'),
50
- floatValue('offsetY'),
51
- floatValue('blur'),
52
- floatValue('spread'),
53
- {
54
- name: `${name}/color`,
55
- value: (0, isRgbaFloat_1.isRgbaFloat)(values.color)
56
- ? Object.assign(Object.assign({}, values.color), (values.alpha ? { a: values.alpha } : {})) : (0, hexToRgbaFloat_1.hexToRgbaFloat)(values.color, values.alpha),
57
- type: 'COLOR',
58
- scopes: ['EFFECT_COLOR'],
59
- mode,
60
- collection,
61
- group,
62
- },
63
- ];
64
- };
65
- /**
66
- * @description Converts `StyleDictionary.dictionary.tokens` to javascript esm (javascript export statement)
67
- * @param arguments [FormatterArguments](https://github.com/amzn/style-dictionary/blob/main/types/Format.d.ts)
68
- * @returns formatted `string`
69
- */
70
- const jsonFigma = ({ dictionary, file: _file, platform }) => {
71
- // array to store tokens in
72
- const tokens = [];
73
- // loop through tokens sorted by reference
74
- for (const token of dictionary.allTokens.sort(sortByReference(dictionary))) {
75
- // deconstruct token
76
- const { attributes, value, $type, comment: description, original, alpha, mix } = token;
77
- const { mode, collection, scopes, group, codeSyntax } = attributes || {};
78
- // shadows need to be specifically dealt with
79
- if ($type === 'shadow') {
80
- const shadowValues = !Array.isArray(value) ? [value] : value;
81
- // if only one set of shadow values is present
82
- if (shadowValues.length === 1) {
83
- tokens.push(...shadowToVariables(token.name, shadowValues[0], Object.assign(Object.assign({}, token), (platform.mode ? { mode: platform.mode } : {}))));
84
- }
85
- else {
86
- // if multiple shadow sets values are present we need loop through them and add the index to the name
87
- for (const [index, stepValue] of shadowValues.entries()) {
88
- tokens.push(...shadowToVariables(`${token.name}/${index + 1}`, stepValue, Object.assign(Object.assign({}, token), (platform.mode ? { mode: platform.mode } : {}))));
89
- }
90
- }
91
- // other tokens just get added to tokens array
92
- }
93
- else {
94
- tokens.push({
95
- name: token.name,
96
- value,
97
- type: getFigmaType($type),
98
- alpha,
99
- isMix: mix ? true : undefined,
100
- description,
101
- refId: [collection, token.name].filter(Boolean).join('/'),
102
- reference: getReference(dictionary, original.value, platform),
103
- collection,
104
- mode,
105
- group,
106
- scopes,
107
- codeSyntax,
108
- });
109
- }
110
- }
111
- // add file header and convert output
112
- const output = JSON.stringify(tokens, null, 2);
113
- // return prettified
114
- return sync_1.default.format(output, { parser: 'json', printWidth: 500 });
115
- };
116
- exports.jsonFigma = jsonFigma;
@@ -1,8 +0,0 @@
1
- import type StyleDictionary from 'style-dictionary';
2
- /**
3
- * @description Takes a style dictionary token dictionary and converts it to a nested json string.
4
- * In contrast to the `json/nested` this formatter does add a prefix if provided
5
- * @param StyleDictionary.FormatterArguments
6
- * @returns formatted json `string`
7
- */
8
- export declare const jsonNestedPrefixed: StyleDictionary.Formatter;
@@ -1,28 +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.jsonNestedPrefixed = void 0;
7
- const sync_1 = __importDefault(require("@prettier/sync"));
8
- const prefixTokens_1 = require("./utilities/prefixTokens");
9
- const jsonToNestedValue_1 = require("./utilities/jsonToNestedValue");
10
- /**
11
- * @description Takes a style dictionary token dictionary and converts it to a nested json string.
12
- * In contrast to the `json/nested` this formatter does add a prefix if provided
13
- * @param StyleDictionary.FormatterArguments
14
- * @returns formatted json `string`
15
- */
16
- const jsonNestedPrefixed = ({ dictionary, file: _file, options, platform }) => {
17
- const { outputVerbose } = options;
18
- // add prefix if defined
19
- let tokens = (0, prefixTokens_1.prefixTokens)(dictionary.tokens, platform);
20
- if (!outputVerbose) {
21
- tokens = (0, jsonToNestedValue_1.jsonToNestedValue)(tokens);
22
- }
23
- // add file header and convert output
24
- const output = JSON.stringify(tokens, null, 2);
25
- // return prettified
26
- return sync_1.default.format(output, { parser: 'json', printWidth: 500 });
27
- };
28
- exports.jsonNestedPrefixed = jsonNestedPrefixed;
@@ -1,8 +0,0 @@
1
- import type StyleDictionary from 'style-dictionary';
2
- /**
3
- * @description Takes a style dictionary token dictionary and converts it to a one dimensional json object.
4
- * @param StyleDictionary.FormatterArguments
5
- * @param options.nameSeparator - separator to use for nested token name
6
- * @returns formatted json `string`
7
- */
8
- export declare const jsonOneDimensional: StyleDictionary.Formatter;
@@ -1,24 +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.jsonOneDimensional = void 0;
7
- const sync_1 = __importDefault(require("@prettier/sync"));
8
- const jsonToFlat_1 = require("./utilities/jsonToFlat");
9
- /**
10
- * @description Takes a style dictionary token dictionary and converts it to a one dimensional json object.
11
- * @param StyleDictionary.FormatterArguments
12
- * @param options.nameSeparator - separator to use for nested token name
13
- * @returns formatted json `string`
14
- */
15
- const jsonOneDimensional = ({ dictionary, file: _file, options }) => {
16
- // option to allow verbose output (object) or just the value
17
- const { outputVerbose } = options;
18
- const tokens = (0, jsonToFlat_1.jsonToFlat)(dictionary.allTokens, outputVerbose);
19
- // add file header and convert output
20
- const output = JSON.stringify(tokens, null, 2);
21
- // return prettified
22
- return sync_1.default.format(output, { parser: 'json', printWidth: 500 });
23
- };
24
- exports.jsonOneDimensional = jsonOneDimensional;
@@ -1,8 +0,0 @@
1
- import type StyleDictionary from 'style-dictionary';
2
- /**
3
- * @description Takes a style dictionary token dictionary and converts it to a one dimensional json object.
4
- * @param StyleDictionary.FormatterArguments
5
- * @param options.nameSeparator - separator to use for nested token name
6
- * @returns formatted json `string`
7
- */
8
- export declare const jsonPostCssFallback: StyleDictionary.Formatter;
@@ -1,21 +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.jsonPostCssFallback = void 0;
7
- const sync_1 = __importDefault(require("@prettier/sync"));
8
- /**
9
- * @description Takes a style dictionary token dictionary and converts it to a one dimensional json object.
10
- * @param StyleDictionary.FormatterArguments
11
- * @param options.nameSeparator - separator to use for nested token name
12
- * @returns formatted json `string`
13
- */
14
- const jsonPostCssFallback = ({ dictionary, file: _file }) => {
15
- const tokens = Object.fromEntries(dictionary.allTokens.map(token => [`--${token.name}`, token.value]));
16
- // add file header and convert output
17
- const output = JSON.stringify(tokens, null, 2);
18
- // return prettified
19
- return sync_1.default.format(output, { parser: 'json', printWidth: 500 });
20
- };
21
- exports.jsonPostCssFallback = jsonPostCssFallback;
@@ -1,7 +0,0 @@
1
- import StyleDictionary from 'style-dictionary';
2
- /**
3
- * @description Converts `StyleDictionary.dictionary.tokens` to typescript definition
4
- * @param arguments [FormatterArguments](https://github.com/amzn/style-dictionary/blob/main/types/Format.d.ts)
5
- * @returns formatted `string`
6
- */
7
- export declare const typescriptExportDefinition: StyleDictionary.Formatter;
@@ -1,166 +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.typescriptExportDefinition = void 0;
7
- const style_dictionary_1 = __importDefault(require("style-dictionary"));
8
- const sync_1 = __importDefault(require("@prettier/sync"));
9
- const fs = require("fs");
10
- const path = require("path");
11
- const treeWalker_1 = require("../utilities/treeWalker");
12
- const prefixTokens_1 = require("./utilities/prefixTokens");
13
- const { fileHeader } = style_dictionary_1.default.formatHelpers;
14
- /**
15
- * unquoteTypes
16
- * @description extract types from designTokenTypes (string with type definitions from file) and replace quoted types "Color" with unquoted Color
17
- * @param output
18
- * @param designTokenTypes
19
- * @returns string with unquoted types
20
- */
21
- const unquoteTypes = (output, designTokenTypes) => {
22
- // join types for replacement
23
- const regex = `"(${['number', 'string', 'any', ...designTokenTypes].join('|')})"`;
24
- // remove strings
25
- return output.replace(new RegExp(regex, 'g'), '$1');
26
- };
27
- /**
28
- * getTokenType
29
- * @description extract content from token files
30
- * @param path string
31
- */
32
- const getTokenType = (tokenTypesPath) => {
33
- try {
34
- const designTokenType = fs.readFileSync(path.resolve(tokenTypesPath), { encoding: 'utf-8' });
35
- return designTokenType;
36
- }
37
- catch (e) {
38
- // eslint-disable-next-line no-console
39
- throw new Error(`Error trying to load design token type from file "${tokenTypesPath}".`);
40
- }
41
- };
42
- /**
43
- * @description throws an error stating the token name, type and invalid value
44
- * @param token w3cTransformedToken
45
- */
46
- const invalidTokenValueError = (token) => {
47
- throw new Error(`Invalid token: "${token.name}" with type "${token.$type}" can not have a value of "${token.value}"`);
48
- };
49
- /**
50
- * convertPropToType
51
- * @description return take type attribute and return correct typescript type as string
52
- * @param type
53
- * @returns
54
- */
55
- const convertPropToType = (tree) => {
56
- if (!Object.prototype.hasOwnProperty.call(tree, 'value')) {
57
- throw new Error(`Invalid token: ${tree}`);
58
- }
59
- switch (tree.$type) {
60
- case 'color':
61
- if (typeof tree.value === 'string' && tree.value[0] === '#') {
62
- return 'ColorHex';
63
- }
64
- return invalidTokenValueError(tree);
65
- case 'dimension':
66
- if (typeof tree.value === 'string' && tree.value.substring(tree.value.length - 3) === 'rem')
67
- return 'SizeRem';
68
- if (typeof tree.value === 'string' && tree.value.substring(tree.value.length - 2) === 'em')
69
- return 'SizeEm';
70
- if (typeof tree.value === 'string' && tree.value.substring(tree.value.length - 2) === 'px')
71
- return 'SizePx';
72
- return invalidTokenValueError(tree);
73
- case 'shadow':
74
- return 'Shadow';
75
- case 'border':
76
- return 'Border';
77
- default:
78
- if (typeof tree.value === 'number')
79
- return 'number';
80
- if (typeof tree.value === 'string')
81
- return 'string';
82
- if (typeof tree.value === 'boolean')
83
- return 'boolean';
84
- return 'any';
85
- }
86
- };
87
- /**
88
- * a valid token node has a `value` property
89
- * @param item object
90
- * @returns boolean
91
- */
92
- const validTokenNode = (item) => {
93
- return typeof item === 'object' && item !== null && 'value' in item;
94
- };
95
- /**
96
- * returns a set with every used token type
97
- * @param item object
98
- * @param validTypes array, all other types will be removed
99
- * @returns set of all used token types
100
- */
101
- const getUsedTokenTypes = (tokens, validTypes) => {
102
- // using a set to assure every value only exists once
103
- const usedTypes = new Set();
104
- // adds type to set
105
- const callback = (tree) => usedTypes.add(convertPropToType(tree));
106
- // tree walker adds to usedTypes
107
- (0, treeWalker_1.treeWalker)(tokens, callback, validTokenNode);
108
- // clean up types
109
- for (const type of usedTypes) {
110
- if (!validTypes.includes(type)) {
111
- usedTypes.delete(type);
112
- }
113
- }
114
- return usedTypes;
115
- };
116
- /**
117
- * returns the entire token object structure but instead of token values each token just has a typescript type
118
- * @param item object
119
- * @returns object
120
- */
121
- const getTokenObjectWithTypes = (tokens) => {
122
- // TODO: FIX typescript issues
123
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
124
- // @ts-ignore
125
- return (0, treeWalker_1.treeWalker)(tokens, convertPropToType, validTokenNode);
126
- };
127
- /**
128
- * getTypeDefinition
129
- * @description returns type definitions as string
130
- * @param tokens
131
- * @param moduleName
132
- * @param tokenTypesPath
133
- * @returns string
134
- */
135
- const getTypeDefinition = (tokens, moduleName, tokenTypesPath) => {
136
- const usedTypes = getUsedTokenTypes(tokens, ['ColorHex', 'Shadow', 'Border', 'SizeEm', 'SizeRem', 'SizePx']);
137
- const tokenObjectWithTypes = getTokenObjectWithTypes(tokens);
138
- // get token type declaration from file
139
- const designTokenTypes = [];
140
- for (const type of usedTypes) {
141
- // path to type files without trailing slash
142
- const typePath = tokenTypesPath.replace(new RegExp(/\/$/, 'g'), '');
143
- designTokenTypes.push(getTokenType(`${typePath}/${type}.d.ts`));
144
- }
145
- // build output
146
- const output = `${designTokenTypes.join('\n')}
147
- export type ${moduleName} = ${JSON.stringify(tokenObjectWithTypes, null, 2)}`;
148
- // JSON stringify will quote strings, because this is a type we need it unquoted.
149
- return unquoteTypes(output, [...usedTypes]);
150
- };
151
- /**
152
- * @description Converts `StyleDictionary.dictionary.tokens` to typescript definition
153
- * @param arguments [FormatterArguments](https://github.com/amzn/style-dictionary/blob/main/types/Format.d.ts)
154
- * @returns formatted `string`
155
- */
156
- const typescriptExportDefinition = ({ dictionary, file, options = {}, platform, }) => {
157
- // extract options
158
- const { moduleName = `tokens`, tokenTypesPath = `./src/types/` } = options;
159
- // add prefix if defined
160
- const tokens = (0, prefixTokens_1.prefixTokens)(dictionary.tokens, platform);
161
- // add file header and convert output
162
- const output = `${fileHeader({ file })}\n${getTypeDefinition(tokens, moduleName, tokenTypesPath)}\n`;
163
- // return prettified
164
- return sync_1.default.format(output, { parser: 'typescript', printWidth: 500 });
165
- };
166
- exports.typescriptExportDefinition = typescriptExportDefinition;
@@ -1,11 +0,0 @@
1
- import type StyleDictionary from 'style-dictionary';
2
- /**
3
- * jsonToFlat
4
- * @description creates a one dimensional json structure with either a single value or an token object as the value
5
- * @param token StyleDictionary.DesignToken
6
- * @param returnObject - boolean
7
- * @returns flat json three
8
- */
9
- export declare const jsonToFlat: (tokens: StyleDictionary.TransformedToken[], returnObject?: boolean) => {
10
- [k: string]: any;
11
- };
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.jsonToFlat = void 0;
4
- /**
5
- * jsonToFlat
6
- * @description creates a one dimensional json structure with either a single value or an token object as the value
7
- * @param token StyleDictionary.DesignToken
8
- * @param returnObject - boolean
9
- * @returns flat json three
10
- */
11
- const jsonToFlat = (tokens, returnObject = false) => Object.fromEntries(tokens.map(token => [token.name, returnObject ? token : token.value]));
12
- exports.jsonToFlat = jsonToFlat;
@@ -1,8 +0,0 @@
1
- import type StyleDictionary from 'style-dictionary';
2
- /**
3
- * jsonToNestedValue
4
- * @description creates a nested json tree where every final value is the `.value` prop
5
- * @param token StyleDictionary.DesignToken
6
- * @returns nested json three
7
- */
8
- export declare const jsonToNestedValue: (token: StyleDictionary.DesignToken | Record<string, unknown>) => any;
@@ -1,25 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.jsonToNestedValue = void 0;
4
- /**
5
- * jsonToNestedValue
6
- * @description creates a nested json tree where every final value is the `.value` prop
7
- * @param token StyleDictionary.DesignToken
8
- * @returns nested json three
9
- */
10
- const jsonToNestedValue = (token) => {
11
- // is non-object value
12
- if (typeof token !== 'object')
13
- return token;
14
- // is design token
15
- if ('value' in token)
16
- return token.value;
17
- // is obj
18
- const nextObj = {};
19
- for (const [prop, value] of Object.entries(token)) {
20
- // @ts-expect-error: can't predict type
21
- nextObj[prop] = (0, exports.jsonToNestedValue)(value);
22
- }
23
- return nextObj;
24
- };
25
- exports.jsonToNestedValue = jsonToNestedValue;
@@ -1,8 +0,0 @@
1
- import type StyleDictionary from 'style-dictionary';
2
- /**
3
- * @description extract prefix from platform and add to tokens array if defined
4
- * @param tokens StyleDictionary.TransformedTokens
5
- * @param platform StyleDictionary.Platform
6
- * @return StyleDictionary.TransformedTokens
7
- */
8
- export declare const prefixTokens: (tokens: StyleDictionary.TransformedTokens, platform?: StyleDictionary.Platform) => StyleDictionary.TransformedTokens;
@@ -1,17 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.prefixTokens = void 0;
4
- /**
5
- * @description extract prefix from platform and add to tokens array if defined
6
- * @param tokens StyleDictionary.TransformedTokens
7
- * @param platform StyleDictionary.Platform
8
- * @return StyleDictionary.TransformedTokens
9
- */
10
- const prefixTokens = (tokens, platform = {}) => {
11
- const { prefix } = platform;
12
- if (typeof prefix === 'string') {
13
- tokens = { [prefix]: tokens };
14
- }
15
- return tokens;
16
- };
17
- exports.prefixTokens = prefixTokens;
@@ -1 +0,0 @@
1
- export { w3cJsonParser } from './w3cJsonParser';
@@ -1,5 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.w3cJsonParser = void 0;
4
- var w3cJsonParser_1 = require("./w3cJsonParser");
5
- Object.defineProperty(exports, "w3cJsonParser", { enumerable: true, get: function () { return w3cJsonParser_1.w3cJsonParser; } });