style-dictionary 4.2.0 → 4.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.
- package/README.md +8 -5
- package/bin/style-dictionary.d.ts +8 -0
- package/bin/style-dictionary.js +38 -10
- package/examples/advanced/assets-base64-embed/package.json +1 -1
- package/examples/advanced/create-react-app/package.json +1 -1
- package/examples/advanced/create-react-native-app/package.json +1 -1
- package/examples/advanced/create-react-native-app/src/App.js +0 -1
- package/examples/advanced/custom-parser/package.json +1 -1
- package/examples/advanced/custom-parser/sd.config.js +3 -2
- package/examples/advanced/custom-transforms/README.md +1 -1
- package/examples/advanced/custom-transforms/build.js +11 -8
- package/examples/advanced/custom-transforms/package.json +1 -1
- package/examples/advanced/font-face-rules/package.json +1 -1
- package/examples/advanced/font-face-rules/sd.config.js +2 -1
- package/examples/advanced/format-helpers/package.json +1 -1
- package/examples/advanced/format-helpers/sd.config.js +3 -2
- package/examples/advanced/matching-build-files/config.js +15 -10
- package/examples/advanced/matching-build-files/package.json +1 -1
- package/examples/advanced/multi-brand-multi-platform/build.js +10 -7
- package/examples/advanced/multi-brand-multi-platform/package.json +1 -1
- package/examples/advanced/node-modules-as-config-and-properties/config.js +17 -12
- package/examples/advanced/node-modules-as-config-and-properties/package.json +1 -1
- package/examples/advanced/npm-module/package.json +1 -1
- package/examples/advanced/referencing_aliasing/package.json +1 -1
- package/examples/advanced/s3/package.json +1 -1
- package/examples/advanced/tailwind-preset/README.md +94 -0
- package/examples/advanced/tailwind-preset/config/filter.js +3 -0
- package/examples/advanced/tailwind-preset/config/filter.test.js +12 -0
- package/examples/advanced/tailwind-preset/config/format.js +60 -0
- package/examples/advanced/tailwind-preset/config/transform.js +21 -0
- package/examples/advanced/tailwind-preset/config/transform.test.js +37 -0
- package/examples/advanced/tailwind-preset/config.js +55 -0
- package/examples/advanced/tailwind-preset/demo/index.html +27 -0
- package/examples/advanced/tailwind-preset/demo/input.css +3 -0
- package/examples/advanced/tailwind-preset/package.json +18 -0
- package/examples/advanced/tailwind-preset/tailwind.config.js +11 -0
- package/examples/advanced/tailwind-preset/tokens/tokens.json +49 -0
- package/examples/advanced/tokens-deprecation/build.js +2 -1
- package/examples/advanced/tokens-deprecation/package.json +1 -1
- package/examples/advanced/transitive-transforms/package.json +1 -1
- package/examples/advanced/transitive-transforms/sd.config.js +12 -9
- package/examples/advanced/variables-in-outputs/package.json +1 -1
- package/examples/advanced/variables-in-outputs/sd.config.js +10 -5
- package/examples/advanced/yaml-tokens/package.json +1 -1
- package/examples/advanced/yaml-tokens/sd.config.js +3 -2
- package/lib/Register.d.ts +2 -2
- package/lib/Register.js +6 -3
- package/lib/StyleDictionary.d.ts +20 -18
- package/lib/StyleDictionary.js +89 -71
- package/lib/cleanActions.d.ts +1 -1
- package/lib/cleanDir.d.ts +1 -1
- package/lib/cleanDir.js +2 -1
- package/lib/cleanDirs.d.ts +1 -1
- package/lib/cleanFile.d.ts +1 -6
- package/lib/cleanFile.js +5 -2
- package/lib/cleanFiles.d.ts +1 -1
- package/lib/common/actions.d.ts +20 -1
- package/lib/common/actions.js +8 -4
- package/lib/common/filters.d.ts +7 -1
- package/lib/common/formatHelpers/createPropertyFormatter.d.ts +3 -1
- package/lib/common/formatHelpers/createPropertyFormatter.js +26 -19
- package/lib/common/formatHelpers/fileHeader.d.ts +1 -1
- package/lib/common/formatHelpers/fileHeader.js +4 -2
- package/lib/common/formatHelpers/formattedVariables.d.ts +3 -1
- package/lib/common/formatHelpers/formattedVariables.js +3 -1
- package/lib/common/formatHelpers/getTypeScriptType.d.ts +2 -2
- package/lib/common/formatHelpers/minifyDictionary.d.ts +1 -1
- package/lib/common/formatHelpers/setComposeObjectProperties.d.ts +1 -1
- package/lib/common/formatHelpers/setSwiftFileProperties.d.ts +1 -1
- package/lib/common/formatHelpers/sortByReference.d.ts +1 -1
- package/lib/common/formats.js +235 -162
- package/lib/common/templates/compose/object.kt.template.js +8 -4
- package/lib/common/templates/css/fonts.css.template.js +2 -2
- package/lib/common/templates/scss/map-flat.template.js +4 -3
- package/lib/common/transformGroups.d.ts +209 -1
- package/lib/common/transformGroups.js +139 -93
- package/lib/common/transforms.d.ts +961 -1
- package/lib/common/transforms.js +113 -111
- package/lib/enums/actions.d.ts +4 -0
- package/lib/enums/actions.js +4 -0
- package/lib/enums/commentPositions.d.ts +4 -0
- package/lib/enums/commentPositions.js +4 -0
- package/lib/enums/commentStyles.d.ts +5 -0
- package/lib/enums/commentStyles.js +5 -0
- package/lib/enums/fileHeaderCommentStyles.d.ts +5 -0
- package/lib/enums/fileHeaderCommentStyles.js +5 -0
- package/lib/enums/formats.d.ts +46 -0
- package/lib/enums/formats.js +50 -0
- package/lib/enums/index.d.ts +12 -0
- package/lib/enums/index.js +12 -0
- package/lib/enums/logBrokenReferenceLevels.d.ts +5 -0
- package/lib/enums/logBrokenReferenceLevels.js +4 -0
- package/lib/enums/logVerbosityLevels.d.ts +6 -0
- package/lib/enums/logVerbosityLevels.js +5 -0
- package/lib/enums/logWarningLevels.d.ts +5 -0
- package/lib/enums/logWarningLevels.js +5 -0
- package/lib/enums/propertyFormatNames.d.ts +6 -0
- package/lib/enums/propertyFormatNames.js +6 -0
- package/lib/enums/transformGroups.d.ts +17 -0
- package/lib/enums/transformGroups.js +17 -0
- package/lib/enums/transformTypes.d.ts +5 -0
- package/lib/enums/transformTypes.js +5 -0
- package/lib/enums/transforms.d.ts +57 -0
- package/lib/enums/transforms.js +57 -0
- package/lib/filterTokens.d.ts +1 -1
- package/lib/filterTokens.js +5 -0
- package/lib/fs.d.ts +1 -1
- package/lib/fs.js +1 -1
- package/lib/performActions.d.ts +1 -1
- package/lib/resolve.d.ts +1 -1
- package/lib/resolve.js +4 -3
- package/lib/transform/config.js +3 -2
- package/lib/transform/object.d.ts +1 -1
- package/lib/transform/token.d.ts +1 -9
- package/lib/transform/token.js +10 -3
- package/lib/utils/cleanActions.d.ts +1 -1
- package/lib/utils/combineJSON.d.ts +1 -1
- package/lib/utils/combineJSON.js +12 -32
- package/lib/utils/convertToBase64.d.ts +1 -1
- package/lib/utils/convertToDTCG.d.ts +3 -3
- package/lib/utils/convertTokenData.d.ts +30 -0
- package/lib/utils/convertTokenData.js +123 -0
- package/lib/utils/deepExtend.d.ts +1 -1
- package/lib/utils/deepmerge.d.ts +1 -1
- package/lib/utils/expandObjectTokens.d.ts +2 -2
- package/lib/utils/expandObjectTokens.js +1 -1
- package/lib/utils/flattenTokens.d.ts +9 -5
- package/lib/utils/flattenTokens.js +28 -16
- package/lib/utils/index.d.ts +2 -1
- package/lib/utils/index.js +3 -0
- package/lib/utils/loadFile.d.ts +13 -0
- package/lib/utils/loadFile.js +89 -0
- package/lib/utils/preprocess.d.ts +1 -1
- package/lib/utils/references/defaults.d.ts +5 -1
- package/lib/utils/references/getName.d.ts +1 -1
- package/lib/utils/references/getReferences.d.ts +1 -1
- package/lib/utils/references/outputReferencesTransformed.js +1 -1
- package/lib/utils/references/resolveReferences.d.ts +2 -2
- package/lib/utils/references/usesReferences.d.ts +1 -1
- package/package.json +27 -16
- package/types/Config.d.ts +9 -3
- package/types/DesignToken.d.ts +6 -0
- package/types/File.d.ts +6 -2
- package/types/Format.d.ts +4 -1
- package/types/Transform.d.ts +4 -3
package/lib/common/transforms.js
CHANGED
|
@@ -16,6 +16,7 @@ import { join } from 'path-unified';
|
|
|
16
16
|
import { snakeCase, kebabCase, camelCase } from 'change-case';
|
|
17
17
|
import convertToBase64 from '../utils/convertToBase64.js';
|
|
18
18
|
import GroupMessages from '../utils/groupMessages.js';
|
|
19
|
+
import { transforms, transformTypes } from '../enums/index.js';
|
|
19
20
|
|
|
20
21
|
/**
|
|
21
22
|
* @typedef {import('../../types/Transform.d.ts').Transform} Transform
|
|
@@ -25,6 +26,7 @@ import GroupMessages from '../utils/groupMessages.js';
|
|
|
25
26
|
*/
|
|
26
27
|
|
|
27
28
|
const UNKNOWN_CSS_FONT_PROPS_WARNINGS = GroupMessages.GROUP.UnknownCSSFontProperties;
|
|
29
|
+
const { value, name, attribute } = transformTypes;
|
|
28
30
|
|
|
29
31
|
/**
|
|
30
32
|
* @param {string} str
|
|
@@ -222,8 +224,8 @@ export default {
|
|
|
222
224
|
*
|
|
223
225
|
* @memberof Transforms
|
|
224
226
|
*/
|
|
225
|
-
|
|
226
|
-
type:
|
|
227
|
+
[transforms.attributeCti]: {
|
|
228
|
+
type: attribute,
|
|
227
229
|
transform: function (token) {
|
|
228
230
|
const attrNames = ['category', 'type', 'item', 'subitem', 'state'];
|
|
229
231
|
const originalAttrs = token.attributes || {};
|
|
@@ -254,8 +256,8 @@ export default {
|
|
|
254
256
|
*
|
|
255
257
|
* @memberof Transforms
|
|
256
258
|
*/
|
|
257
|
-
|
|
258
|
-
type:
|
|
259
|
+
[transforms.attributeColor]: {
|
|
260
|
+
type: attribute,
|
|
259
261
|
filter: isColor,
|
|
260
262
|
transform: function (token, _, options) {
|
|
261
263
|
const color = Color(options.usesDtcg ? token.$value : token.value);
|
|
@@ -279,8 +281,8 @@ export default {
|
|
|
279
281
|
*
|
|
280
282
|
* @memberof Transforms
|
|
281
283
|
*/
|
|
282
|
-
|
|
283
|
-
type:
|
|
284
|
+
[transforms.nameHuman]: {
|
|
285
|
+
type: name,
|
|
284
286
|
transform: function (token) {
|
|
285
287
|
return [token.attributes?.item, token.attributes?.subitem].join(' ');
|
|
286
288
|
},
|
|
@@ -298,8 +300,8 @@ export default {
|
|
|
298
300
|
*
|
|
299
301
|
* @memberof Transforms
|
|
300
302
|
*/
|
|
301
|
-
|
|
302
|
-
type:
|
|
303
|
+
[transforms.nameCamel]: {
|
|
304
|
+
type: name,
|
|
303
305
|
transform: function (token, config) {
|
|
304
306
|
return camelCase([config.prefix].concat(token.path).join(' '), camelOpts);
|
|
305
307
|
},
|
|
@@ -317,8 +319,8 @@ export default {
|
|
|
317
319
|
*
|
|
318
320
|
* @memberof Transforms
|
|
319
321
|
*/
|
|
320
|
-
|
|
321
|
-
type:
|
|
322
|
+
[transforms.nameKebab]: {
|
|
323
|
+
type: name,
|
|
322
324
|
transform: function (token, config) {
|
|
323
325
|
return kebabCase([config.prefix].concat(token.path).join(' '));
|
|
324
326
|
},
|
|
@@ -336,8 +338,8 @@ export default {
|
|
|
336
338
|
*
|
|
337
339
|
* @memberof Transforms
|
|
338
340
|
*/
|
|
339
|
-
|
|
340
|
-
type:
|
|
341
|
+
[transforms.nameSnake]: {
|
|
342
|
+
type: name,
|
|
341
343
|
transform: function (token, config) {
|
|
342
344
|
return snakeCase([config.prefix].concat(token.path).join(' '));
|
|
343
345
|
},
|
|
@@ -355,8 +357,8 @@ export default {
|
|
|
355
357
|
*
|
|
356
358
|
* @memberof Transforms
|
|
357
359
|
*/
|
|
358
|
-
|
|
359
|
-
type:
|
|
360
|
+
[transforms.nameConstant]: {
|
|
361
|
+
type: name,
|
|
360
362
|
transform: function (token, config) {
|
|
361
363
|
return snakeCase([config.prefix].concat(token.path).join(' ')).toUpperCase();
|
|
362
364
|
},
|
|
@@ -374,8 +376,8 @@ export default {
|
|
|
374
376
|
*
|
|
375
377
|
* @memberof Transforms
|
|
376
378
|
*/
|
|
377
|
-
|
|
378
|
-
type:
|
|
379
|
+
[transforms.namePascal]: {
|
|
380
|
+
type: name,
|
|
379
381
|
transform: function (token, config) {
|
|
380
382
|
/** @param {string} str */
|
|
381
383
|
const upperFirst = function (str) {
|
|
@@ -396,8 +398,8 @@ export default {
|
|
|
396
398
|
*
|
|
397
399
|
* @memberof Transforms
|
|
398
400
|
*/
|
|
399
|
-
|
|
400
|
-
type:
|
|
401
|
+
[transforms.colorRgb]: {
|
|
402
|
+
type: value,
|
|
401
403
|
filter: isColor,
|
|
402
404
|
transform: function (token, _, options) {
|
|
403
405
|
return Color(options.usesDtcg ? token.$value : token.value).toRgbString();
|
|
@@ -416,8 +418,8 @@ export default {
|
|
|
416
418
|
*
|
|
417
419
|
* @memberof Transforms
|
|
418
420
|
*/
|
|
419
|
-
|
|
420
|
-
type:
|
|
421
|
+
[transforms.colorHsl]: {
|
|
422
|
+
type: value,
|
|
421
423
|
filter: isColor,
|
|
422
424
|
transform: function (token, _, options) {
|
|
423
425
|
return Color(options.usesDtcg ? token.$value : token.value).toHslString();
|
|
@@ -436,8 +438,8 @@ export default {
|
|
|
436
438
|
*
|
|
437
439
|
* @memberof Transforms
|
|
438
440
|
*/
|
|
439
|
-
|
|
440
|
-
type:
|
|
441
|
+
[transforms.colorHsl4]: {
|
|
442
|
+
type: value,
|
|
441
443
|
filter: isColor,
|
|
442
444
|
transform: function (token, _, options) {
|
|
443
445
|
const color = Color(options.usesDtcg ? token.$value : token.value);
|
|
@@ -462,8 +464,8 @@ export default {
|
|
|
462
464
|
*
|
|
463
465
|
* @memberof Transforms
|
|
464
466
|
*/
|
|
465
|
-
|
|
466
|
-
type:
|
|
467
|
+
[transforms.colorHex]: {
|
|
468
|
+
type: value,
|
|
467
469
|
filter: isColor,
|
|
468
470
|
transform: function (token, _, options) {
|
|
469
471
|
return Color(options.usesDtcg ? token.$value : token.value).toHexString();
|
|
@@ -481,8 +483,8 @@ export default {
|
|
|
481
483
|
*
|
|
482
484
|
* @memberof Transforms
|
|
483
485
|
*/
|
|
484
|
-
|
|
485
|
-
type:
|
|
486
|
+
[transforms.colorHex8]: {
|
|
487
|
+
type: value,
|
|
486
488
|
filter: isColor,
|
|
487
489
|
transform: function (token, _, options) {
|
|
488
490
|
return Color(options.usesDtcg ? token.$value : token.value).toHex8String();
|
|
@@ -500,8 +502,8 @@ export default {
|
|
|
500
502
|
*
|
|
501
503
|
* @memberof Transforms
|
|
502
504
|
*/
|
|
503
|
-
|
|
504
|
-
type:
|
|
505
|
+
[transforms.colorHex8android]: {
|
|
506
|
+
type: value,
|
|
505
507
|
filter: isColor,
|
|
506
508
|
transform: function (token, _, options) {
|
|
507
509
|
const str = Color(options.usesDtcg ? token.$value : token.value).toHex8();
|
|
@@ -520,8 +522,8 @@ export default {
|
|
|
520
522
|
*
|
|
521
523
|
* @memberof Transforms
|
|
522
524
|
*/
|
|
523
|
-
|
|
524
|
-
type:
|
|
525
|
+
[transforms.colorComposeColor]: {
|
|
526
|
+
type: value,
|
|
525
527
|
filter: isColor,
|
|
526
528
|
transform: function (token, _, options) {
|
|
527
529
|
const str = Color(options.usesDtcg ? token.$value : token.value).toHex8();
|
|
@@ -540,8 +542,8 @@ export default {
|
|
|
540
542
|
*
|
|
541
543
|
* @memberof Transforms
|
|
542
544
|
*/
|
|
543
|
-
|
|
544
|
-
type:
|
|
545
|
+
[transforms.colorUIColor]: {
|
|
546
|
+
type: value,
|
|
545
547
|
filter: isColor,
|
|
546
548
|
transform: function (token, _, options) {
|
|
547
549
|
const rgb = Color(options.usesDtcg ? token.$value : token.value).toRgb();
|
|
@@ -573,8 +575,8 @@ export default {
|
|
|
573
575
|
*
|
|
574
576
|
* @memberof Transforms
|
|
575
577
|
*/
|
|
576
|
-
|
|
577
|
-
type:
|
|
578
|
+
[transforms.colorUIColorSwift]: {
|
|
579
|
+
type: value,
|
|
578
580
|
filter: isColor,
|
|
579
581
|
transform: function (token, _, options) {
|
|
580
582
|
const { r, g, b, a } = Color(options.usesDtcg ? token.$value : token.value).toRgb();
|
|
@@ -596,8 +598,8 @@ export default {
|
|
|
596
598
|
*
|
|
597
599
|
* @memberof Transforms
|
|
598
600
|
*/
|
|
599
|
-
|
|
600
|
-
type:
|
|
601
|
+
[transforms.colorColorSwiftUI]: {
|
|
602
|
+
type: value,
|
|
601
603
|
filter: isColor,
|
|
602
604
|
transform: function (token, _, options) {
|
|
603
605
|
const { r, g, b, a } = Color(options.usesDtcg ? token.$value : token.value).toRgb();
|
|
@@ -620,8 +622,8 @@ export default {
|
|
|
620
622
|
*
|
|
621
623
|
* @memberof Transforms
|
|
622
624
|
*/
|
|
623
|
-
|
|
624
|
-
type:
|
|
625
|
+
[transforms.colorCss]: {
|
|
626
|
+
type: value,
|
|
625
627
|
filter: isColor,
|
|
626
628
|
transform: function (token, _, options) {
|
|
627
629
|
const color = Color(options.usesDtcg ? token.$value : token.value);
|
|
@@ -651,8 +653,8 @@ export default {
|
|
|
651
653
|
* ```
|
|
652
654
|
* @memberof Transforms
|
|
653
655
|
*/
|
|
654
|
-
|
|
655
|
-
type:
|
|
656
|
+
[transforms.colorSketch]: {
|
|
657
|
+
type: value,
|
|
656
658
|
filter: isColor,
|
|
657
659
|
transform: function (token, _, options) {
|
|
658
660
|
let color = Color(options.usesDtcg ? token.$value : token.value).toRgb();
|
|
@@ -676,8 +678,8 @@ export default {
|
|
|
676
678
|
*
|
|
677
679
|
* @memberof Transforms
|
|
678
680
|
*/
|
|
679
|
-
|
|
680
|
-
type:
|
|
681
|
+
[transforms.sizeSp]: {
|
|
682
|
+
type: value,
|
|
681
683
|
filter: isFontSize,
|
|
682
684
|
transform: function (token, _, options) {
|
|
683
685
|
const nonParsedVal = options.usesDtcg ? token.$value : token.value;
|
|
@@ -698,8 +700,8 @@ export default {
|
|
|
698
700
|
*
|
|
699
701
|
* @memberof Transforms
|
|
700
702
|
*/
|
|
701
|
-
|
|
702
|
-
type:
|
|
703
|
+
[transforms.sizeDp]: {
|
|
704
|
+
type: value,
|
|
703
705
|
filter: isDimension,
|
|
704
706
|
transform: function (token, _, options) {
|
|
705
707
|
const nonParsedVal = options.usesDtcg ? token.$value : token.value;
|
|
@@ -725,8 +727,8 @@ export default {
|
|
|
725
727
|
*
|
|
726
728
|
* @memberof Transforms
|
|
727
729
|
*/
|
|
728
|
-
|
|
729
|
-
type:
|
|
730
|
+
[transforms.sizeObject]: {
|
|
731
|
+
type: value,
|
|
730
732
|
filter: (token, options) => isDimension(token, options) || isFontSize(token, options),
|
|
731
733
|
transform: function (token, config, options) {
|
|
732
734
|
const value = options.usesDtcg ? token.$value : token.value;
|
|
@@ -753,8 +755,8 @@ export default {
|
|
|
753
755
|
*
|
|
754
756
|
* @memberof Transforms
|
|
755
757
|
*/
|
|
756
|
-
|
|
757
|
-
type:
|
|
758
|
+
[transforms.sizeRemToSp]: {
|
|
759
|
+
type: value,
|
|
758
760
|
filter: isFontSize,
|
|
759
761
|
transform: function (token, config, options) {
|
|
760
762
|
const value = options.usesDtcg ? token.$value : token.value;
|
|
@@ -776,8 +778,8 @@ export default {
|
|
|
776
778
|
*
|
|
777
779
|
* @memberof Transforms
|
|
778
780
|
*/
|
|
779
|
-
|
|
780
|
-
type:
|
|
781
|
+
[transforms.sizeRemToDp]: {
|
|
782
|
+
type: value,
|
|
781
783
|
filter: isDimension,
|
|
782
784
|
transform: function (token, config, options) {
|
|
783
785
|
const value = options.usesDtcg ? token.$value : token.value;
|
|
@@ -799,8 +801,8 @@ export default {
|
|
|
799
801
|
*
|
|
800
802
|
* @memberof Transforms
|
|
801
803
|
*/
|
|
802
|
-
|
|
803
|
-
type:
|
|
804
|
+
[transforms.sizePx]: {
|
|
805
|
+
type: value,
|
|
804
806
|
filter: (token, options) => isDimension(token, options) || isFontSize(token, options),
|
|
805
807
|
transform: function (token, _, options) {
|
|
806
808
|
const value = options.usesDtcg ? token.$value : token.value;
|
|
@@ -821,13 +823,13 @@ export default {
|
|
|
821
823
|
*
|
|
822
824
|
* @memberof Transforms
|
|
823
825
|
*/
|
|
824
|
-
|
|
825
|
-
type:
|
|
826
|
+
[transforms.sizeRem]: {
|
|
827
|
+
type: value,
|
|
826
828
|
filter: (token, options) => isDimension(token, options) || isFontSize(token, options),
|
|
827
829
|
transform: function (token, _, options) {
|
|
828
830
|
const nonParsed = options.usesDtcg ? token.$value : token.value;
|
|
829
831
|
// if the dimension already has a unit (non-digit / . period character)
|
|
830
|
-
if (`${nonParsed}`.match(
|
|
832
|
+
if (`${nonParsed}`.match(/^[^0-9.-]+$/)) {
|
|
831
833
|
return nonParsed;
|
|
832
834
|
}
|
|
833
835
|
const parsedVal = parseFloat(nonParsed);
|
|
@@ -848,8 +850,8 @@ export default {
|
|
|
848
850
|
*
|
|
849
851
|
* @memberof Transforms
|
|
850
852
|
*/
|
|
851
|
-
|
|
852
|
-
type:
|
|
853
|
+
[transforms.sizeRemToPt]: {
|
|
854
|
+
type: value,
|
|
853
855
|
filter: (token, options) => isDimension(token, options) || isFontSize(token, options),
|
|
854
856
|
transform: function (token, config, options) {
|
|
855
857
|
const value = options.usesDtcg ? token.$value : token.value;
|
|
@@ -871,8 +873,8 @@ export default {
|
|
|
871
873
|
*
|
|
872
874
|
* @memberof Transforms
|
|
873
875
|
*/
|
|
874
|
-
|
|
875
|
-
type:
|
|
876
|
+
[transforms.sizeComposeRemToSp]: {
|
|
877
|
+
type: value,
|
|
876
878
|
filter: isFontSize,
|
|
877
879
|
transform: function (token, config, options) {
|
|
878
880
|
const value = options.usesDtcg ? token.$value : token.value;
|
|
@@ -894,8 +896,8 @@ export default {
|
|
|
894
896
|
*
|
|
895
897
|
* @memberof Transforms
|
|
896
898
|
*/
|
|
897
|
-
|
|
898
|
-
type:
|
|
899
|
+
[transforms.sizeComposeRemToDp]: {
|
|
900
|
+
type: value,
|
|
899
901
|
filter: isDimension,
|
|
900
902
|
transform: function (token, config, options) {
|
|
901
903
|
const value = options.usesDtcg ? token.$value : token.value;
|
|
@@ -917,8 +919,8 @@ export default {
|
|
|
917
919
|
*
|
|
918
920
|
* @memberof Transforms
|
|
919
921
|
*/
|
|
920
|
-
|
|
921
|
-
type:
|
|
922
|
+
[transforms.sizeComposeEm]: {
|
|
923
|
+
type: value,
|
|
922
924
|
filter: isFontSize,
|
|
923
925
|
transform: function (token, _, options) {
|
|
924
926
|
const value = options.usesDtcg ? token.$value : token.value;
|
|
@@ -938,8 +940,8 @@ export default {
|
|
|
938
940
|
*
|
|
939
941
|
* @memberof Transforms
|
|
940
942
|
*/
|
|
941
|
-
|
|
942
|
-
type:
|
|
943
|
+
[transforms.sizeSwiftRemToCGFloat]: {
|
|
944
|
+
type: value,
|
|
943
945
|
filter: (token, options) => isDimension(token, options) || isFontSize(token, options),
|
|
944
946
|
transform: function (token, config, options) {
|
|
945
947
|
const value = options.usesDtcg ? token.$value : token.value;
|
|
@@ -961,8 +963,8 @@ export default {
|
|
|
961
963
|
*
|
|
962
964
|
* @memberof Transforms
|
|
963
965
|
*/
|
|
964
|
-
|
|
965
|
-
type:
|
|
966
|
+
[transforms.sizeRemToPx]: {
|
|
967
|
+
type: value,
|
|
966
968
|
filter: (token, options) => isDimension(token, options) || isFontSize(token, options),
|
|
967
969
|
transform: function (token, config, options) {
|
|
968
970
|
const value = options.usesDtcg ? token.$value : token.value;
|
|
@@ -985,8 +987,8 @@ export default {
|
|
|
985
987
|
*
|
|
986
988
|
* @memberof Transforms
|
|
987
989
|
*/
|
|
988
|
-
|
|
989
|
-
type:
|
|
990
|
+
[transforms.sizePxToRem]: {
|
|
991
|
+
type: value,
|
|
990
992
|
filter: (token, options) => isDimension(token, options) || isFontSize(token, options),
|
|
991
993
|
transform: (token, config, options) => {
|
|
992
994
|
const value = options.usesDtcg ? token.$value : token.value;
|
|
@@ -1016,8 +1018,8 @@ export default {
|
|
|
1016
1018
|
*
|
|
1017
1019
|
* @memberof Transforms
|
|
1018
1020
|
*/
|
|
1019
|
-
|
|
1020
|
-
type:
|
|
1021
|
+
[transforms.htmlIcon]: {
|
|
1022
|
+
type: value,
|
|
1021
1023
|
filter: function (token, options) {
|
|
1022
1024
|
return (options.usesDtcg ? token.$type : token.type) === 'html';
|
|
1023
1025
|
},
|
|
@@ -1045,8 +1047,8 @@ export default {
|
|
|
1045
1047
|
*
|
|
1046
1048
|
* @memberof Transforms
|
|
1047
1049
|
*/
|
|
1048
|
-
|
|
1049
|
-
type:
|
|
1050
|
+
[transforms.contentQuote]: {
|
|
1051
|
+
type: value,
|
|
1050
1052
|
filter: isContent,
|
|
1051
1053
|
transform: function (token, _, options) {
|
|
1052
1054
|
return wrapValueWith("'", token, options);
|
|
@@ -1064,8 +1066,8 @@ export default {
|
|
|
1064
1066
|
*
|
|
1065
1067
|
* @memberof Transforms
|
|
1066
1068
|
*/
|
|
1067
|
-
|
|
1068
|
-
type:
|
|
1069
|
+
[transforms.contentObjCLiteral]: {
|
|
1070
|
+
type: value,
|
|
1069
1071
|
filter: isContent,
|
|
1070
1072
|
transform: function (token, _, options) {
|
|
1071
1073
|
return '@' + wrapValueWithDoubleQuote(token, options);
|
|
@@ -1083,8 +1085,8 @@ export default {
|
|
|
1083
1085
|
*
|
|
1084
1086
|
* @memberof Transforms
|
|
1085
1087
|
*/
|
|
1086
|
-
|
|
1087
|
-
type:
|
|
1088
|
+
[transforms.contentSwiftLiteral]: {
|
|
1089
|
+
type: value,
|
|
1088
1090
|
filter: isContent,
|
|
1089
1091
|
transform: (token, _, options) => wrapValueWithDoubleQuote(token, options),
|
|
1090
1092
|
},
|
|
@@ -1100,8 +1102,8 @@ export default {
|
|
|
1100
1102
|
*
|
|
1101
1103
|
* @memberof Transforms
|
|
1102
1104
|
*/
|
|
1103
|
-
|
|
1104
|
-
type:
|
|
1105
|
+
[transforms.timeSeconds]: {
|
|
1106
|
+
type: value,
|
|
1105
1107
|
filter: function (token, options) {
|
|
1106
1108
|
return (options.usesDtcg ? token.$type : token.type) === 'time';
|
|
1107
1109
|
},
|
|
@@ -1123,8 +1125,8 @@ export default {
|
|
|
1123
1125
|
*
|
|
1124
1126
|
* @memberof Transforms
|
|
1125
1127
|
*/
|
|
1126
|
-
|
|
1127
|
-
type:
|
|
1128
|
+
[transforms.fontFamilyCss]: {
|
|
1129
|
+
type: value,
|
|
1128
1130
|
// typography properties can be references, while fontFamily prop might not
|
|
1129
1131
|
transitive: true,
|
|
1130
1132
|
filter: (token, options) => {
|
|
@@ -1149,8 +1151,8 @@ export default {
|
|
|
1149
1151
|
*
|
|
1150
1152
|
* @memberof Transforms
|
|
1151
1153
|
*/
|
|
1152
|
-
|
|
1153
|
-
type:
|
|
1154
|
+
[transforms.cubicBezierCss]: {
|
|
1155
|
+
type: value,
|
|
1154
1156
|
// transition properties can be references, while timingFunction might not be
|
|
1155
1157
|
transitive: true,
|
|
1156
1158
|
filter: (token, options) => {
|
|
@@ -1175,8 +1177,8 @@ export default {
|
|
|
1175
1177
|
*
|
|
1176
1178
|
* @memberof Transforms
|
|
1177
1179
|
*/
|
|
1178
|
-
|
|
1179
|
-
type:
|
|
1180
|
+
[transforms.strokeStyleCssShorthand]: {
|
|
1181
|
+
type: value,
|
|
1180
1182
|
// border properties can be references, while style property might not be
|
|
1181
1183
|
transitive: true,
|
|
1182
1184
|
filter: (token, options) => (options.usesDtcg ? token.$type : token.type) === 'strokeStyle',
|
|
@@ -1202,8 +1204,8 @@ export default {
|
|
|
1202
1204
|
*
|
|
1203
1205
|
* @memberof Transforms
|
|
1204
1206
|
*/
|
|
1205
|
-
|
|
1206
|
-
type:
|
|
1207
|
+
[transforms.borderCssShorthand]: {
|
|
1208
|
+
type: value,
|
|
1207
1209
|
// border properties can be references
|
|
1208
1210
|
transitive: true,
|
|
1209
1211
|
filter: (token, options) => (options.usesDtcg ? token.$type : token.type) === 'border',
|
|
@@ -1242,8 +1244,8 @@ export default {
|
|
|
1242
1244
|
*
|
|
1243
1245
|
* @memberof Transforms
|
|
1244
1246
|
*/
|
|
1245
|
-
|
|
1246
|
-
type:
|
|
1247
|
+
[transforms.typographyCssShorthand]: {
|
|
1248
|
+
type: value,
|
|
1247
1249
|
// typography properties can be references
|
|
1248
1250
|
transitive: true,
|
|
1249
1251
|
filter: (token, options) => (options.usesDtcg ? token.$type : token.type) === 'typography',
|
|
@@ -1298,8 +1300,8 @@ export default {
|
|
|
1298
1300
|
*
|
|
1299
1301
|
* @memberof Transforms
|
|
1300
1302
|
*/
|
|
1301
|
-
|
|
1302
|
-
type:
|
|
1303
|
+
[transforms.transitionCssShorthand]: {
|
|
1304
|
+
type: value,
|
|
1303
1305
|
// transition properties can be references
|
|
1304
1306
|
transitive: true,
|
|
1305
1307
|
filter: (token, options) => (options.usesDtcg ? token.$type : token.type) === 'transition',
|
|
@@ -1327,8 +1329,8 @@ export default {
|
|
|
1327
1329
|
*
|
|
1328
1330
|
* @memberof Transforms
|
|
1329
1331
|
*/
|
|
1330
|
-
|
|
1331
|
-
type:
|
|
1332
|
+
[transforms.shadowCssShorthand]: {
|
|
1333
|
+
type: value,
|
|
1332
1334
|
// shadow properties can be references
|
|
1333
1335
|
transitive: true,
|
|
1334
1336
|
filter: (token, options) => (options.usesDtcg ? token.$type : token.type) === 'shadow',
|
|
@@ -1369,8 +1371,8 @@ export default {
|
|
|
1369
1371
|
*
|
|
1370
1372
|
* @memberof Transforms
|
|
1371
1373
|
*/
|
|
1372
|
-
|
|
1373
|
-
type:
|
|
1374
|
+
[transforms.assetUrl]: {
|
|
1375
|
+
type: value,
|
|
1374
1376
|
filter: isAsset,
|
|
1375
1377
|
transform: function (token, _, options) {
|
|
1376
1378
|
return `url("${(options.usesDtcg ? token.$value : token.value).replace(/"/g, `\\"`)}")`;
|
|
@@ -1388,8 +1390,8 @@ export default {
|
|
|
1388
1390
|
*
|
|
1389
1391
|
* @memberof Transforms
|
|
1390
1392
|
*/
|
|
1391
|
-
|
|
1392
|
-
type:
|
|
1393
|
+
[transforms.assetBase64]: {
|
|
1394
|
+
type: value,
|
|
1393
1395
|
filter: isAsset,
|
|
1394
1396
|
transform: function (token, _, options, vol) {
|
|
1395
1397
|
return convertToBase64(options.usesDtcg ? token.$value : token.value, vol);
|
|
@@ -1407,8 +1409,8 @@ export default {
|
|
|
1407
1409
|
*
|
|
1408
1410
|
* @memberof Transforms
|
|
1409
1411
|
*/
|
|
1410
|
-
|
|
1411
|
-
type:
|
|
1412
|
+
[transforms.assetPath]: {
|
|
1413
|
+
type: value,
|
|
1412
1414
|
filter: isAsset,
|
|
1413
1415
|
transform: function (token, _, options) {
|
|
1414
1416
|
return join(process?.cwd() ?? '/', options.usesDtcg ? token.$value : token.value);
|
|
@@ -1425,8 +1427,8 @@ export default {
|
|
|
1425
1427
|
*
|
|
1426
1428
|
* @memberof Transforms
|
|
1427
1429
|
*/
|
|
1428
|
-
|
|
1429
|
-
type:
|
|
1430
|
+
[transforms.assetObjCLiteral]: {
|
|
1431
|
+
type: value,
|
|
1430
1432
|
filter: isAsset,
|
|
1431
1433
|
transform: function (token, _, options) {
|
|
1432
1434
|
return '@' + wrapValueWithDoubleQuote(token, options);
|
|
@@ -1443,8 +1445,8 @@ export default {
|
|
|
1443
1445
|
*
|
|
1444
1446
|
* @memberof Transforms
|
|
1445
1447
|
*/
|
|
1446
|
-
|
|
1447
|
-
type:
|
|
1448
|
+
[transforms.assetSwiftLiteral]: {
|
|
1449
|
+
type: value,
|
|
1448
1450
|
filter: isAsset,
|
|
1449
1451
|
transform: (token, _, options) => wrapValueWithDoubleQuote(token, options),
|
|
1450
1452
|
},
|
|
@@ -1459,8 +1461,8 @@ export default {
|
|
|
1459
1461
|
* @memberof Transforms
|
|
1460
1462
|
*
|
|
1461
1463
|
*/
|
|
1462
|
-
|
|
1463
|
-
type:
|
|
1464
|
+
[transforms.colorHex8flutter]: {
|
|
1465
|
+
type: value,
|
|
1464
1466
|
filter: isColor,
|
|
1465
1467
|
transform: function (token, _, options) {
|
|
1466
1468
|
const str = Color(options.usesDtcg ? token.$value : token.value)
|
|
@@ -1480,8 +1482,8 @@ export default {
|
|
|
1480
1482
|
*
|
|
1481
1483
|
* @memberof Transforms
|
|
1482
1484
|
*/
|
|
1483
|
-
|
|
1484
|
-
type:
|
|
1485
|
+
[transforms.contentFlutterLiteral]: {
|
|
1486
|
+
type: value,
|
|
1485
1487
|
filter: isContent,
|
|
1486
1488
|
transform: (token, _, options) => wrapValueWithDoubleQuote(token, options),
|
|
1487
1489
|
},
|
|
@@ -1496,8 +1498,8 @@ export default {
|
|
|
1496
1498
|
*
|
|
1497
1499
|
* @memberof Transforms
|
|
1498
1500
|
*/
|
|
1499
|
-
|
|
1500
|
-
type:
|
|
1501
|
+
[transforms.assetFlutterLiteral]: {
|
|
1502
|
+
type: value,
|
|
1501
1503
|
filter: isAsset,
|
|
1502
1504
|
transform: (token, _, options) => wrapValueWithDoubleQuote(token, options),
|
|
1503
1505
|
},
|
|
@@ -1512,8 +1514,8 @@ export default {
|
|
|
1512
1514
|
*
|
|
1513
1515
|
* @memberof Transforms
|
|
1514
1516
|
*/
|
|
1515
|
-
|
|
1516
|
-
type:
|
|
1517
|
+
[transforms.sizeFlutterRemToDouble]: {
|
|
1518
|
+
type: value,
|
|
1517
1519
|
filter: (token, options) => isDimension(token, options) || isFontSize(token, options),
|
|
1518
1520
|
transform: function (token, config, options) {
|
|
1519
1521
|
const baseFont = getBasePxFontSize(config);
|