style-dictionary 5.3.0 → 5.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -12,6 +12,6 @@
12
12
  "author": "",
13
13
  "license": "Apache-2.0",
14
14
  "devDependencies": {
15
- "style-dictionary": "^5.3.0"
15
+ "style-dictionary": "^5.3.1"
16
16
  }
17
17
  }
@@ -12,7 +12,7 @@
12
12
  },
13
13
  "devDependencies": {
14
14
  "eslint-config-react-app": "^7.0.1",
15
- "style-dictionary": "^5.3.0"
15
+ "style-dictionary": "^5.3.1"
16
16
  },
17
17
  "resolutions": {
18
18
  "immer": "8.0.1",
@@ -29,7 +29,7 @@
29
29
  "eslint-config-react-app": "^7.0.1",
30
30
  "jest": "~25.2.6",
31
31
  "react-test-renderer": "~16.13.1",
32
- "style-dictionary": "^5.3.0"
32
+ "style-dictionary": "^5.3.1"
33
33
  },
34
34
  "jest": {
35
35
  "preset": "react-native"
@@ -10,6 +10,6 @@
10
10
  "author": "",
11
11
  "license": "Apache-2.0",
12
12
  "devDependencies": {
13
- "style-dictionary": "^5.3.0"
13
+ "style-dictionary": "^5.3.1"
14
14
  }
15
15
  }
@@ -16,6 +16,6 @@
16
16
  "author": "",
17
17
  "license": "Apache-2.0",
18
18
  "devDependencies": {
19
- "style-dictionary": "^5.3.0"
19
+ "style-dictionary": "^5.3.1"
20
20
  }
21
21
  }
@@ -9,6 +9,6 @@
9
9
  },
10
10
  "license": "Apache-2.0",
11
11
  "devDependencies": {
12
- "style-dictionary": "^5.3.0"
12
+ "style-dictionary": "^5.3.1"
13
13
  }
14
14
  }
@@ -11,6 +11,6 @@
11
11
  "author": "",
12
12
  "license": "Apache-2.0",
13
13
  "devDependencies": {
14
- "style-dictionary": "^5.3.0"
14
+ "style-dictionary": "^5.3.1"
15
15
  }
16
16
  }
@@ -17,6 +17,6 @@
17
17
  "author": "Kelly Harrop <kn.harrop@gmail.com>",
18
18
  "license": "Apache-2.0",
19
19
  "devDependencies": {
20
- "style-dictionary": "^5.3.0"
20
+ "style-dictionary": "^5.3.1"
21
21
  }
22
22
  }
@@ -16,6 +16,6 @@
16
16
  "author": "",
17
17
  "license": "Apache-2.0",
18
18
  "devDependencies": {
19
- "style-dictionary": "^5.3.0"
19
+ "style-dictionary": "^5.3.1"
20
20
  }
21
21
  }
@@ -1125,9 +1125,9 @@
1125
1125
  "license": "MIT"
1126
1126
  },
1127
1127
  "node_modules/qs": {
1128
- "version": "6.14.0",
1129
- "resolved": "https://registry.npmjs.org/qs/-/qs-6.14.0.tgz",
1130
- "integrity": "sha512-YWWTjgABSKcvs/nWBi9PycY/JiPJqOD4JA6o9Sej2AtvSGarXxKC3OQSk4pAarbdQlKAh5D4FCQkJNkW+GAn3w==",
1128
+ "version": "6.14.2",
1129
+ "resolved": "https://registry.npmjs.org/qs/-/qs-6.14.2.tgz",
1130
+ "integrity": "sha512-V/yCWTTF7VJ9hIh18Ugr2zhJMP01MY7c5kh4J870L7imm6/DIzBsNLTXzMwUA3yZ5b/KBqLx8Kp3uRvd7xSe3Q==",
1131
1131
  "dev": true,
1132
1132
  "license": "BSD-3-Clause",
1133
1133
  "dependencies": {
@@ -20,7 +20,7 @@
20
20
  },
21
21
  "homepage": "https://github.com/dbanksdesign/style-dictionary-node#readme",
22
22
  "devDependencies": {
23
- "style-dictionary": "^5.3.0",
23
+ "style-dictionary": "^5.3.1",
24
24
  "tinycolor2": "^1.4.1"
25
25
  }
26
26
  }
@@ -17,6 +17,6 @@
17
17
  "author": "",
18
18
  "license": "Apache-2.0",
19
19
  "devDependencies": {
20
- "style-dictionary": "^5.3.0"
20
+ "style-dictionary": "^5.3.1"
21
21
  }
22
22
  }
@@ -16,6 +16,6 @@
16
16
  "author": "",
17
17
  "license": "Apache-2.0",
18
18
  "devDependencies": {
19
- "style-dictionary": "^5.3.0"
19
+ "style-dictionary": "^5.3.1"
20
20
  }
21
21
  }
@@ -16,6 +16,6 @@
16
16
  "devDependencies": {
17
17
  "aws-sdk": "^2.7.21",
18
18
  "fs-extra": "^1.0.0",
19
- "style-dictionary": "^5.3.0"
19
+ "style-dictionary": "^5.3.1"
20
20
  }
21
21
  }
@@ -10,7 +10,7 @@
10
10
  },
11
11
  "license": "Apache-2.0",
12
12
  "devDependencies": {
13
- "style-dictionary": "^5.3.0",
13
+ "style-dictionary": "^5.3.1",
14
14
  "tailwindcss": "^3.4.15",
15
15
  "mocha": "^10.2.0",
16
16
  "chai": "^5.1.1"
@@ -16,6 +16,6 @@
16
16
  "author": "",
17
17
  "license": "Apache-2.0",
18
18
  "devDependencies": {
19
- "style-dictionary": "^5.3.0"
19
+ "style-dictionary": "^5.3.1"
20
20
  }
21
21
  }
@@ -12,6 +12,6 @@
12
12
  "license": "ISC",
13
13
  "devDependencies": {
14
14
  "colorjs.io": "^0.5.2",
15
- "style-dictionary": "^5.3.0"
15
+ "style-dictionary": "^5.3.1"
16
16
  }
17
17
  }
@@ -11,6 +11,6 @@
11
11
  "author": "",
12
12
  "license": "MIT",
13
13
  "devDependencies": {
14
- "style-dictionary": "^5.3.0"
14
+ "style-dictionary": "^5.3.1"
15
15
  }
16
16
  }
@@ -10,7 +10,7 @@
10
10
  "author": "",
11
11
  "license": "Apache-2.0",
12
12
  "devDependencies": {
13
- "style-dictionary": "^5.3.0",
13
+ "style-dictionary": "^5.3.1",
14
14
  "yaml": "^1.10.0"
15
15
  }
16
16
  }
@@ -67,7 +67,7 @@ export default class StyleDictionary extends Register {
67
67
  // Placeholder is transformed on prepublish -> see scripts/inject-version.js
68
68
  // Another option might be import pkg from './package.json' with { "type": "json" } which would work in both browser and node, but support is not there yet.
69
69
  // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import#browser_compatibility
70
- static VERSION = '5.3.0';
70
+ static VERSION = '5.3.1';
71
71
 
72
72
  /** @returns {Config} */
73
73
  get options() {
@@ -5,17 +5,12 @@
5
5
  */
6
6
  export function isDTCGColorObject(val: unknown): val is DTCGColorValue;
7
7
  /**
8
- * Get color RGB values from either legacy string format or DTCG object format
9
- * @param {Token} token
10
- * @param {Config} options
11
- * @returns {{ r: number, g: number, b: number, a: number }}
8
+ * Get a CSS compatible color string from a token value that contains a color property
9
+ * Used in CSS shorthand transforms for token types that can have color poperties, like border, gradient, shadow.
10
+ * @param {unknown} tokenValue
11
+ * @returns {string | undefined}
12
12
  */
13
- export function getColorRgb(token: Token, options: Config): {
14
- r: number;
15
- g: number;
16
- b: number;
17
- a: number;
18
- };
13
+ export function getColorStringFromTokenObjectValue(tokenValue: unknown): string | undefined;
19
14
  /**
20
15
  * Get a tinycolor2 Color instance from either legacy string format or DTCG object format
21
16
  * This provides backward compatibility for transformers that use tinycolor2 methods
@@ -26,11 +21,10 @@ export function getColorRgb(token: Token, options: Config): {
26
21
  export function getColor(token: Token, options: Config): ReturnType<typeof Color>;
27
22
  /**
28
23
  * Get a ColorJS Color instance from either legacy string format or DTCG object format
29
- * @param {Token} token
30
- * @param {Config} options
24
+ * @param {DTCGColorValue | string} val
31
25
  * @returns {ColorJS}
32
26
  */
33
- export function getColorJS(token: Token, options: Config): ColorJS;
27
+ export function getColorJS(val: DTCGColorValue | string): ColorJS;
34
28
  /**
35
29
  * @param {Token} token
36
30
  * @param {Config} options
@@ -130,20 +130,23 @@ function dtcgColorToRgb(dtcgColor) {
130
130
  }
131
131
 
132
132
  /**
133
- * Get color RGB values from either legacy string format or DTCG object format
134
- * @param {Token} token
135
- * @param {Config} options
136
- * @returns {{ r: number, g: number, b: number, a: number }}
133
+ * Get a CSS compatible color string from a token value that contains a color property
134
+ * Used in CSS shorthand transforms for token types that can have color poperties, like border, gradient, shadow.
135
+ * @param {unknown} tokenValue
136
+ * @returns {string | undefined}
137
137
  */
138
- export function getColorRgb(token, options) {
139
- const val = options.usesDtcg ? token.$value : token.value;
140
-
141
- if (isDTCGColorObject(val)) {
142
- return dtcgColorToRgb(val);
138
+ export function getColorStringFromTokenObjectValue(tokenValue) {
139
+ /** @type {string | undefined} */
140
+ let hex;
141
+ if (typeof tokenValue === 'object' && tokenValue !== null && 'color' in tokenValue) {
142
+ if (typeof tokenValue.color === 'string') {
143
+ return tokenValue.color;
144
+ }
145
+ let color = /** @type {DTCGColorValue} */ (tokenValue.color);
146
+ let colorJS = getColorJS(color);
147
+ hex = colorJS.toString();
143
148
  }
144
-
145
- // Legacy format - use tinycolor2
146
- return Color(val).toRgb();
149
+ return hex;
147
150
  }
148
151
 
149
152
  /**
@@ -166,13 +169,10 @@ export function getColor(token, options) {
166
169
 
167
170
  /**
168
171
  * Get a ColorJS Color instance from either legacy string format or DTCG object format
169
- * @param {Token} token
170
- * @param {Config} options
172
+ * @param {DTCGColorValue | string} val
171
173
  * @returns {ColorJS}
172
174
  */
173
- export function getColorJS(token, options) {
174
- const val = options.usesDtcg ? token.$value : token.value;
175
-
175
+ export function getColorJS(val) {
176
176
  if (isDTCGColorObject(val)) {
177
177
  return dtcgToColorJS(val);
178
178
  }
@@ -858,7 +858,8 @@ export default {
858
858
  type: value,
859
859
  filter: isColor,
860
860
  transform: function (token, _, options) {
861
- const color = getColorJS(token, options).to('oklch');
861
+ const val = options.usesDtcg ? token.$value : token.value;
862
+ const color = getColorJS(val).to('oklch');
862
863
  const [l, c, h] = color.coords;
863
864
  const alpha = isNaN(color.alpha) ? 1 : color.alpha;
864
865
  // Format: oklch(L C H) or oklch(L C H / alpha)
@@ -889,7 +890,8 @@ export default {
889
890
  type: value,
890
891
  filter: isColor,
891
892
  transform: function (token, _, options) {
892
- const color = getColorJS(token, options).to('oklab');
893
+ const val = options.usesDtcg ? token.$value : token.value;
894
+ const color = getColorJS(val).to('oklab');
893
895
  const [l, a, b] = color.coords;
894
896
  const alpha = isNaN(color.alpha) ? 1 : color.alpha;
895
897
  // Format: oklab(L a b) or oklab(L a b / alpha)
@@ -920,7 +922,8 @@ export default {
920
922
  type: value,
921
923
  filter: isColor,
922
924
  transform: function (token, _, options) {
923
- const color = getColorJS(token, options).to('p3');
925
+ const val = options.usesDtcg ? token.$value : token.value;
926
+ const color = getColorJS(val).to('p3');
924
927
  const [r, g, b] = color.coords;
925
928
  const alpha = isNaN(color.alpha) ? 1 : color.alpha;
926
929
  // Format: color(display-p3 r g b) or color(display-p3 r g b / alpha)
@@ -951,7 +954,8 @@ export default {
951
954
  type: value,
952
955
  filter: isColor,
953
956
  transform: function (token, _, options) {
954
- const color = getColorJS(token, options).to('lch');
957
+ const val = options.usesDtcg ? token.$value : token.value;
958
+ const color = getColorJS(val).to('lch');
955
959
  const [l, c, h] = color.coords;
956
960
  const alpha = isNaN(color.alpha) ? 1 : color.alpha;
957
961
  // Format: lch(L% C H) or lch(L% C H / alpha)
@@ -1561,16 +1565,18 @@ export default {
1561
1565
  // already transformed to string
1562
1566
  return val;
1563
1567
  }
1564
- const { color, width } = val;
1565
- let { style } = val;
1568
+ const colorStr = getColorStringFromTokenObjectValue(val);
1569
+ const { width } = val;
1566
1570
 
1567
1571
  // use fallback for style object value, since CSS does not allow
1568
1572
  // detailed control of the dash pattern or line caps on dashed borders
1569
1573
  // https://design-tokens.github.io/community-group/format/#example-fallback-for-object-stroke-style
1574
+ let { style } = val;
1570
1575
  if (typeof style === 'object') {
1571
1576
  style = 'dashed';
1572
1577
  }
1573
- return `${width ? `${width} ` : ''}${style ? `${style}` : 'none'}${color ? ` ${color}` : ''}`;
1578
+
1579
+ return `${width ? `${width} ` : ''}${style ? `${style}` : 'none'}${colorStr ? ` ${colorStr}` : ''}`;
1574
1580
  },
1575
1581
  },
1576
1582
 
@@ -1693,10 +1699,11 @@ export default {
1693
1699
  if (typeof val !== 'object') {
1694
1700
  return val;
1695
1701
  }
1696
- const { type, color, offsetX, offsetY, blur, spread } = val;
1702
+ const { type, offsetX, offsetY, blur, spread } = val;
1703
+ const colorStr = getColorStringFromTokenObjectValue(val);
1697
1704
  return `${type ? `${type} ` : ''}${offsetX ?? 0} ${offsetY ?? 0} ${blur ?? 0} ${
1698
1705
  spread ? `${spread} ` : ''
1699
- }${color ?? `#000000`}`;
1706
+ }${colorStr ?? `#000000`}`;
1700
1707
  };
1701
1708
 
1702
1709
  if (Array.isArray(val)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "style-dictionary",
3
- "version": "5.3.0",
3
+ "version": "5.3.1",
4
4
  "description": "Style once, use everywhere. A build system for creating cross-platform styles.",
5
5
  "keywords": [
6
6
  "style dictionary",
@@ -117,7 +117,7 @@
117
117
  },
118
118
  "dependencies": {
119
119
  "@bundled-es-modules/deepmerge": "^4.3.1",
120
- "@bundled-es-modules/glob": "^13.0.1",
120
+ "@bundled-es-modules/glob": "^13.0.3",
121
121
  "@bundled-es-modules/memfs": "^4.17.0",
122
122
  "@zip.js/zip.js": "^2.7.44",
123
123
  "chalk": "^5.3.0",