@primer/primitives 9.1.2 → 10.0.0-rc.1d2317e6
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/dist/build/PrimerStyleDictionary.d.ts +1 -2
- package/dist/build/PrimerStyleDictionary.js +52 -64
- package/dist/build/filters/index.d.ts +14 -13
- package/dist/build/filters/index.js +14 -29
- package/dist/build/filters/isBorder.d.ts +3 -3
- package/dist/build/filters/isBorder.js +2 -6
- package/dist/build/filters/isColor.d.ts +3 -3
- package/dist/build/filters/isColor.js +8 -7
- package/dist/build/filters/isColorWithAlpha.d.ts +3 -3
- package/dist/build/filters/isColorWithAlpha.js +4 -8
- package/dist/build/filters/isColorWithMix.d.ts +3 -3
- package/dist/build/filters/isColorWithMix.js +4 -8
- package/dist/build/filters/isCubicBezier.d.ts +7 -0
- package/dist/build/filters/isCubicBezier.js +10 -0
- package/dist/build/filters/isDeprecated.d.ts +3 -3
- package/dist/build/filters/isDeprecated.js +2 -6
- package/dist/build/filters/isDimension.d.ts +3 -3
- package/dist/build/filters/isDimension.js +2 -6
- package/dist/build/filters/isDuration.d.ts +3 -3
- package/dist/build/filters/isDuration.js +2 -6
- package/dist/build/filters/isFontFamily.d.ts +3 -3
- package/dist/build/filters/isFontFamily.js +2 -6
- package/dist/build/filters/isFontWeight.d.ts +3 -3
- package/dist/build/filters/isFontWeight.js +2 -6
- package/dist/build/filters/isFromFile.d.ts +3 -3
- package/dist/build/filters/isFromFile.js +2 -6
- package/dist/build/filters/isNumber.d.ts +3 -3
- package/dist/build/filters/isNumber.js +4 -6
- package/dist/build/filters/isShadow.d.ts +3 -3
- package/dist/build/filters/isShadow.js +2 -6
- package/dist/build/filters/isSource.d.ts +3 -3
- package/dist/build/filters/isSource.js +2 -6
- package/dist/build/filters/isTypography.d.ts +3 -3
- package/dist/build/filters/isTypography.js +2 -6
- package/dist/build/formats/cssAdvanced.d.ts +2 -2
- package/dist/build/formats/cssAdvanced.js +22 -20
- package/dist/build/formats/cssCustomMedia.d.ts +2 -2
- package/dist/build/formats/cssCustomMedia.js +16 -15
- package/dist/build/formats/index.d.ts +9 -9
- package/dist/build/formats/index.js +9 -21
- package/dist/build/formats/javascriptCommonJs.d.ts +2 -2
- package/dist/build/formats/javascriptCommonJs.js +17 -16
- package/dist/build/formats/javascriptEsm.d.ts +2 -2
- package/dist/build/formats/javascriptEsm.js +17 -16
- package/dist/build/formats/jsonFigma.d.ts +2 -2
- package/dist/build/formats/jsonFigma.js +27 -22
- package/dist/build/formats/jsonNestedPrefixed.d.ts +3 -3
- package/dist/build/formats/jsonNestedPrefixed.js +17 -15
- package/dist/build/formats/jsonOneDimensional.d.ts +3 -3
- package/dist/build/formats/jsonOneDimensional.js +24 -16
- package/dist/build/formats/jsonPostCssFallback.d.ts +3 -3
- package/dist/build/formats/jsonPostCssFallback.js +5 -12
- package/dist/build/formats/typescriptExportDefinition.d.ts +2 -2
- package/dist/build/formats/typescriptExportDefinition.js +48 -44
- package/dist/build/formats/utilities/getPropName.d.ts +1 -0
- package/dist/build/formats/utilities/getPropName.js +16 -0
- package/dist/build/formats/utilities/jsonToFlat.d.ts +2 -2
- package/dist/build/formats/utilities/jsonToFlat.js +1 -5
- package/dist/build/formats/utilities/jsonToNestedValue.d.ts +2 -2
- package/dist/build/formats/utilities/jsonToNestedValue.js +4 -6
- package/dist/build/formats/utilities/prefixTokens.d.ts +2 -2
- package/dist/build/formats/utilities/prefixTokens.js +1 -5
- package/dist/build/parsers/index.d.ts +1 -1
- package/dist/build/parsers/index.js +1 -5
- package/dist/build/parsers/w3cJsonParser.d.ts +2 -2
- package/dist/build/parsers/w3cJsonParser.js +5 -7
- package/dist/build/platforms/css.d.ts +1 -1
- package/dist/build/platforms/css.js +20 -11
- package/dist/build/platforms/deprecatedJson.d.ts +1 -1
- package/dist/build/platforms/deprecatedJson.js +3 -7
- package/dist/build/platforms/docJson.d.ts +1 -1
- package/dist/build/platforms/docJson.js +8 -7
- package/dist/build/platforms/fallbacks.d.ts +1 -1
- package/dist/build/platforms/fallbacks.js +3 -7
- package/dist/build/platforms/figma.d.ts +1 -1
- package/dist/build/platforms/figma.js +21 -14
- package/dist/build/platforms/index.d.ts +10 -10
- package/dist/build/platforms/index.js +10 -23
- package/dist/build/platforms/javascript.d.ts +1 -1
- package/dist/build/platforms/javascript.js +3 -7
- package/dist/build/platforms/json.d.ts +1 -1
- package/dist/build/platforms/json.js +3 -7
- package/dist/build/platforms/styleLint.d.ts +1 -1
- package/dist/build/platforms/styleLint.js +3 -7
- package/dist/build/platforms/typeDefinitions.d.ts +1 -1
- package/dist/build/platforms/typeDefinitions.js +6 -10
- package/dist/build/platforms/typescript.d.ts +1 -1
- package/dist/build/platforms/typescript.js +3 -7
- package/dist/build/schemas/alphaValue.js +4 -7
- package/dist/build/schemas/baseToken.d.ts +2 -2
- package/dist/build/schemas/baseToken.js +4 -7
- package/dist/build/schemas/borderToken.d.ts +5 -5
- package/dist/build/schemas/borderToken.js +13 -16
- package/dist/build/schemas/collections.js +8 -14
- package/dist/build/schemas/colorHexValue.js +4 -7
- package/dist/build/schemas/colorToken.d.ts +20 -15
- package/dist/build/schemas/colorToken.js +24 -24
- package/dist/build/schemas/cubicBezierToken.d.ts +18 -0
- package/dist/build/schemas/cubicBezierToken.js +8 -0
- package/dist/build/schemas/designToken.js +30 -31
- package/dist/build/schemas/dimensionToken.d.ts +5 -5
- package/dist/build/schemas/dimensionToken.js +14 -17
- package/dist/build/schemas/dimensionValue.js +7 -10
- package/dist/build/schemas/durationToken.d.ts +5 -5
- package/dist/build/schemas/durationToken.js +8 -11
- package/dist/build/schemas/durationValue.js +4 -7
- package/dist/build/schemas/fontFamilyToken.d.ts +5 -5
- package/dist/build/schemas/fontFamilyToken.js +13 -16
- package/dist/build/schemas/fontWeightToken.d.ts +5 -5
- package/dist/build/schemas/fontWeightToken.js +14 -17
- package/dist/build/schemas/fontWeightValue.js +4 -7
- package/dist/build/schemas/numberToken.d.ts +5 -5
- package/dist/build/schemas/numberToken.js +15 -18
- package/dist/build/schemas/referenceValue.js +4 -7
- package/dist/build/schemas/scopes.js +5 -10
- package/dist/build/schemas/shadowToken.d.ts +5 -5
- package/dist/build/schemas/shadowToken.js +23 -26
- package/dist/build/schemas/stringToken.d.ts +5 -5
- package/dist/build/schemas/stringToken.js +7 -10
- package/dist/build/schemas/tokenName.js +4 -7
- package/dist/build/schemas/tokenType.d.ts +2 -2
- package/dist/build/schemas/tokenType.js +2 -6
- package/dist/build/schemas/typographyToken.d.ts +5 -5
- package/dist/build/schemas/typographyToken.js +14 -17
- package/dist/build/schemas/validTokenType.d.ts +1 -1
- package/dist/build/schemas/validTokenType.js +10 -13
- package/dist/build/schemas/viewportRangeToken.d.ts +5 -5
- package/dist/build/schemas/viewportRangeToken.js +7 -10
- package/dist/build/transformers/borderToCss.d.ts +3 -3
- package/dist/build/transformers/borderToCss.js +16 -16
- package/dist/build/transformers/colorToHex.d.ts +2 -2
- package/dist/build/transformers/colorToHex.js +11 -13
- package/dist/build/transformers/colorToHexMix.d.ts +2 -2
- package/dist/build/transformers/colorToHexMix.js +10 -15
- package/dist/build/transformers/colorToRgbAlpha.d.ts +2 -2
- package/dist/build/transformers/colorToRgbAlpha.js +10 -12
- package/dist/build/transformers/colorToRgbaFloat.d.ts +2 -2
- package/dist/build/transformers/colorToRgbaFloat.js +24 -28
- package/dist/build/transformers/cubicBezierToCss.d.ts +8 -0
- package/dist/build/transformers/cubicBezierToCss.js +23 -0
- package/dist/build/transformers/dimensionToPixelUnitless.d.ts +2 -2
- package/dist/build/transformers/dimensionToPixelUnitless.js +13 -14
- package/dist/build/transformers/dimensionToRem.d.ts +2 -2
- package/dist/build/transformers/dimensionToRem.js +12 -13
- package/dist/build/transformers/dimensionToRemPxArray.d.ts +2 -2
- package/dist/build/transformers/dimensionToRemPxArray.js +11 -12
- package/dist/build/transformers/durationToCss.d.ts +2 -2
- package/dist/build/transformers/durationToCss.js +9 -10
- package/dist/build/transformers/figmaAttributes.d.ts +2 -2
- package/dist/build/transformers/figmaAttributes.js +3 -5
- package/dist/build/transformers/floatToPixel.d.ts +4 -4
- package/dist/build/transformers/floatToPixel.js +12 -14
- package/dist/build/transformers/fontFamilyToCss.d.ts +2 -2
- package/dist/build/transformers/fontFamilyToCss.js +10 -13
- package/dist/build/transformers/fontFamilyToFigma.d.ts +3 -3
- package/dist/build/transformers/fontFamilyToFigma.js +15 -17
- package/dist/build/transformers/fontWeightToNumber.d.ts +2 -2
- package/dist/build/transformers/fontWeightToNumber.js +8 -11
- package/dist/build/transformers/index.d.ts +25 -24
- package/dist/build/transformers/index.js +25 -51
- package/dist/build/transformers/jsonDeprecated.d.ts +2 -2
- package/dist/build/transformers/jsonDeprecated.js +6 -8
- package/dist/build/transformers/namePathToCamelCase.d.ts +2 -2
- package/dist/build/transformers/namePathToCamelCase.js +5 -7
- package/dist/build/transformers/namePathToDotNotation.d.ts +2 -2
- package/dist/build/transformers/namePathToDotNotation.js +6 -8
- package/dist/build/transformers/namePathToFigma.d.ts +3 -3
- package/dist/build/transformers/namePathToFigma.js +5 -8
- package/dist/build/transformers/namePathToKebabCase.d.ts +2 -2
- package/dist/build/transformers/namePathToKebabCase.js +4 -6
- package/dist/build/transformers/namePathToPascalCase.d.ts +2 -2
- package/dist/build/transformers/namePathToPascalCase.js +5 -7
- package/dist/build/transformers/namePathToSlashNotation.d.ts +2 -2
- package/dist/build/transformers/namePathToSlashNotation.js +4 -6
- package/dist/build/transformers/shadowToCss.d.ts +2 -2
- package/dist/build/transformers/shadowToCss.js +14 -15
- package/dist/build/transformers/typographyToCss.d.ts +2 -2
- package/dist/build/transformers/typographyToCss.js +13 -15
- package/dist/build/transformers/utilities/alpha.d.ts +1 -1
- package/dist/build/transformers/utilities/alpha.js +4 -8
- package/dist/build/transformers/utilities/checkRequiredTokenProperties.js +1 -5
- package/dist/build/transformers/utilities/getTokenValue.d.ts +2 -2
- package/dist/build/transformers/utilities/getTokenValue.js +10 -12
- package/dist/build/transformers/utilities/hasSpaceInString.js +1 -5
- package/dist/build/transformers/utilities/hexToRgbaFloat.d.ts +1 -1
- package/dist/build/transformers/utilities/hexToRgbaFloat.js +1 -5
- package/dist/build/transformers/utilities/invalidTokenError.d.ts +1 -1
- package/dist/build/transformers/utilities/invalidTokenError.js +11 -10
- package/dist/build/transformers/utilities/isRgbaFloat.js +1 -5
- package/dist/build/transformers/utilities/mix.js +5 -7
- package/dist/build/transformers/utilities/rgbaFloatToHex.js +1 -5
- package/dist/build/types/Border.d.ts +5 -0
- package/dist/build/types/BorderTokenValue.d.ts +10 -0
- package/dist/build/types/ColorHex.d.ts +4 -0
- package/dist/build/types/PlatformInitializer.d.ts +11 -0
- package/dist/build/types/Shadow.d.ts +5 -0
- package/dist/build/types/ShadowTokenValue.d.ts +14 -0
- package/dist/build/types/SizeEm.d.ts +4 -0
- package/dist/build/types/SizePx.d.ts +4 -0
- package/dist/build/types/SizeRem.d.ts +4 -0
- package/dist/build/types/StyleDictionaryConfigGenerator.d.ts +15 -0
- package/dist/build/types/TokenBuildInput.d.ts +8 -0
- package/dist/build/types/TypographyTokenValue.d.ts +12 -0
- package/dist/build/types/w3cTransformedToken.d.ts +8 -0
- package/dist/build/utilities/copyFromDir.d.ts +2 -2
- package/dist/build/utilities/copyFromDir.js +7 -10
- package/dist/build/utilities/filterStringArray.js +1 -5
- package/dist/build/utilities/getFlag.js +1 -5
- package/dist/build/utilities/index.d.ts +9 -3
- package/dist/build/utilities/index.js +9 -9
- package/dist/build/utilities/joinFriendly.js +1 -5
- package/dist/build/utilities/schemaErrorMessage.js +1 -5
- package/dist/build/utilities/toCamelCase.js +5 -9
- package/dist/build/utilities/toPascalCase.js +5 -9
- package/dist/build/utilities/treeWalker.js +2 -6
- package/dist/build/utilities/upperCaseFirstCharacter.js +1 -5
- package/dist/css/functional/themes/dark-colorblind.css +56 -38
- package/dist/css/functional/themes/dark-dimmed.css +42 -24
- package/dist/css/functional/themes/dark-high-contrast.css +60 -42
- package/dist/css/functional/themes/dark-tritanopia.css +42 -24
- package/dist/css/functional/themes/dark.css +40 -22
- package/dist/css/functional/themes/light-colorblind.css +58 -40
- package/dist/css/functional/themes/light-high-contrast.css +56 -38
- package/dist/css/functional/themes/light-tritanopia.css +40 -22
- package/dist/css/functional/themes/light.css +40 -22
- package/dist/docs/base/size/size.json +76 -76
- package/dist/docs/base/typography/typography.json +16 -16
- package/dist/docs/functional/motion/motion.json +18 -18
- package/dist/docs/functional/size/border.json +56 -56
- package/dist/docs/functional/size/breakpoints.json +24 -24
- package/dist/docs/functional/size/size-coarse.json +12 -12
- package/dist/docs/functional/size/size-fine.json +12 -12
- package/dist/docs/functional/size/size.json +264 -264
- package/dist/docs/functional/size/viewport.json +24 -24
- package/dist/docs/functional/themes/dark-colorblind.json +2761 -3384
- package/dist/docs/functional/themes/dark-dimmed.json +2809 -3028
- package/dist/docs/functional/themes/dark-high-contrast.json +2806 -5113
- package/dist/docs/functional/themes/dark-tritanopia.json +2800 -3203
- package/dist/docs/functional/themes/dark.json +2779 -2520
- package/dist/docs/functional/themes/light-colorblind.json +2597 -3172
- package/dist/docs/functional/themes/light-high-contrast.json +2642 -4627
- package/dist/docs/functional/themes/light-tritanopia.json +2517 -2960
- package/dist/docs/functional/themes/light.json +2561 -2312
- package/dist/docs/functional/typography/typography.json +206 -206
- package/dist/figma/dimension/dimension.json +489 -489
- package/dist/figma/figma.json +19 -11
- package/dist/figma/scales/dark-dimmed.json +2918 -38
- package/dist/figma/scales/dark-high-constrast.json +2918 -38
- package/dist/figma/scales/dark.json +2915 -35
- package/dist/figma/scales/light-high-constrast.json +2920 -40
- package/dist/figma/scales/light.json +2920 -40
- package/dist/figma/shadows/dark-colorblind.json +280 -280
- package/dist/figma/shadows/dark-dimmed.json +280 -280
- package/dist/figma/shadows/dark-high-contrast.json +280 -280
- package/dist/figma/shadows/dark-tritanopia.json +280 -280
- package/dist/figma/shadows/dark.json +280 -280
- package/dist/figma/shadows/light-colorblind.json +281 -281
- package/dist/figma/shadows/light-high-contrast.json +281 -281
- package/dist/figma/shadows/light-tritanopia.json +281 -281
- package/dist/figma/shadows/light.json +281 -281
- package/dist/figma/themes/dark-colorblind.json +5054 -5804
- package/dist/figma/themes/dark-dimmed.json +5284 -5610
- package/dist/figma/themes/dark-high-contrast.json +4249 -6624
- package/dist/figma/themes/dark-tritanopia.json +5223 -5763
- package/dist/figma/themes/dark.json +5561 -5421
- package/dist/figma/themes/light-colorblind.json +4986 -5639
- package/dist/figma/themes/light-high-contrast.json +4166 -6213
- package/dist/figma/themes/light-tritanopia.json +5082 -5600
- package/dist/figma/themes/light.json +5418 -5277
- package/dist/figma/typography/typography.json +112 -156
- package/dist/internalCss/dark-colorblind.css +56 -38
- package/dist/internalCss/dark-dimmed.css +42 -24
- package/dist/internalCss/dark-high-contrast.css +60 -42
- package/dist/internalCss/dark-tritanopia.css +42 -24
- package/dist/internalCss/dark.css +40 -22
- package/dist/internalCss/light-colorblind.css +58 -40
- package/dist/internalCss/light-high-contrast.css +56 -38
- package/dist/internalCss/light-tritanopia.css +40 -22
- package/dist/internalCss/light.css +40 -22
- package/dist/styleLint/base/size/size.json +38 -38
- package/dist/styleLint/base/typography/typography.json +8 -8
- package/dist/styleLint/functional/motion/motion.json +12 -12
- package/dist/styleLint/functional/size/border.json +30 -30
- package/dist/styleLint/functional/size/breakpoints.json +12 -12
- package/dist/styleLint/functional/size/size-coarse.json +6 -6
- package/dist/styleLint/functional/size/size-fine.json +6 -6
- package/dist/styleLint/functional/size/size.json +132 -132
- package/dist/styleLint/functional/size/viewport.json +12 -12
- package/dist/styleLint/functional/themes/dark-colorblind.json +1642 -2265
- package/dist/styleLint/functional/themes/dark-dimmed.json +1726 -1945
- package/dist/styleLint/functional/themes/dark-high-contrast.json +1610 -3917
- package/dist/styleLint/functional/themes/dark-tritanopia.json +1673 -2076
- package/dist/styleLint/functional/themes/dark.json +1663 -1404
- package/dist/styleLint/functional/themes/light-colorblind.json +1418 -1993
- package/dist/styleLint/functional/themes/light-high-contrast.json +1504 -3489
- package/dist/styleLint/functional/themes/light-tritanopia.json +1397 -1840
- package/dist/styleLint/functional/themes/light.json +1445 -1196
- package/dist/styleLint/functional/typography/typography.json +114 -114
- package/package.json +16 -13
- package/src/tokens/functional/color/dark/app-dark.json5 +203 -88
- package/src/tokens/functional/color/dark/data-vis-dark.json5 +20 -20
- package/src/tokens/functional/color/dark/display-dark.json5 +95 -95
- package/src/tokens/functional/color/dark/overrides/dark.dimmed.json5 +0 -8
- package/src/tokens/functional/color/dark/overrides/dark.high-contrast.json5 +43 -30
- package/src/tokens/functional/color/dark/overrides/dark.protanopia-deuteranopia.json5 +62 -30
- package/src/tokens/functional/color/dark/overrides/dark.tritanopia.json5 +53 -12
- package/src/tokens/functional/color/dark/patterns-dark.json5 +4 -4
- package/src/tokens/functional/color/dark/primitives-dark.json5 +4 -4
- package/src/tokens/functional/color/light/app-light.json5 +195 -85
- package/src/tokens/functional/color/light/data-vis-light.json5 +20 -20
- package/src/tokens/functional/color/light/overrides/light.high-contrast.json5 +25 -25
- package/src/tokens/functional/color/light/overrides/light.protanopia-deuteranopia.json5 +65 -34
- package/src/tokens/functional/color/light/overrides/light.tritanopia.json5 +66 -11
- package/src/tokens/functional/color/light/primitives-light.json5 +2 -2
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isShadow = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* @description Checks if token is of $type `shadow`
|
|
6
|
-
* @param arguments [
|
|
3
|
+
* @param arguments [TransformedToken](https://github.com/amzn/style-dictionary/blob/main/types/TransformedToken.d.ts)
|
|
7
4
|
* @returns boolean
|
|
8
5
|
*/
|
|
9
|
-
const isShadow = (token) => {
|
|
6
|
+
export const isShadow = (token) => {
|
|
10
7
|
return token.$type === 'shadow';
|
|
11
8
|
};
|
|
12
|
-
exports.isShadow = isShadow;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import type { TransformedToken } from 'style-dictionary/types';
|
|
2
2
|
/**
|
|
3
3
|
* @description Checks if token is source token
|
|
4
|
-
* @param arguments [
|
|
4
|
+
* @param arguments [TransformedToken](https://github.com/amzn/style-dictionary/blob/main/types/TransformedToken.d.ts)
|
|
5
5
|
* @returns boolean
|
|
6
6
|
*/
|
|
7
|
-
export declare const isSource: (token:
|
|
7
|
+
export declare const isSource: (token: TransformedToken) => boolean;
|
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isSource = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* @description Checks if token is source token
|
|
6
|
-
* @param arguments [
|
|
3
|
+
* @param arguments [TransformedToken](https://github.com/amzn/style-dictionary/blob/main/types/TransformedToken.d.ts)
|
|
7
4
|
* @returns boolean
|
|
8
5
|
*/
|
|
9
|
-
const isSource = (token) => {
|
|
6
|
+
export const isSource = (token) => {
|
|
10
7
|
return token.isSource === true;
|
|
11
8
|
};
|
|
12
|
-
exports.isSource = isSource;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import type { TransformedToken } from 'style-dictionary/types';
|
|
2
2
|
/**
|
|
3
3
|
* @description Checks if token is of $type `typography`
|
|
4
|
-
* @param arguments [
|
|
4
|
+
* @param arguments [TransformedToken](https://github.com/amzn/style-dictionary/blob/main/types/TransformedToken.d.ts)
|
|
5
5
|
* @returns boolean
|
|
6
6
|
*/
|
|
7
|
-
export declare const isTypography: (token:
|
|
7
|
+
export declare const isTypography: (token: TransformedToken) => boolean;
|
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isTypography = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* @description Checks if token is of $type `typography`
|
|
6
|
-
* @param arguments [
|
|
3
|
+
* @param arguments [TransformedToken](https://github.com/amzn/style-dictionary/blob/main/types/TransformedToken.d.ts)
|
|
7
4
|
* @returns boolean
|
|
8
5
|
*/
|
|
9
|
-
const isTypography = (token) => {
|
|
6
|
+
export const isTypography = (token) => {
|
|
10
7
|
return token.$type === 'typography';
|
|
11
8
|
};
|
|
12
|
-
exports.isTypography = isTypography;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
export declare const cssAdvanced:
|
|
1
|
+
import type { FormatFn } from 'style-dictionary/types';
|
|
2
|
+
export declare const cssAdvanced: FormatFn;
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
return (
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
4
9
|
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const style_dictionary_1 = __importDefault(require("style-dictionary"));
|
|
8
|
-
const sync_1 = __importDefault(require("@prettier/sync"));
|
|
9
|
-
const { fileHeader, formattedVariables } = style_dictionary_1.default.formatHelpers;
|
|
10
|
+
import { format } from 'prettier';
|
|
11
|
+
import { fileHeader, formattedVariables } from 'style-dictionary/utils';
|
|
10
12
|
const wrapWithSelector = (css, selector) => {
|
|
11
13
|
// return without selector
|
|
12
14
|
if (selector === false || selector.trim().length === 0)
|
|
@@ -14,18 +16,18 @@ const wrapWithSelector = (css, selector) => {
|
|
|
14
16
|
// return with selector
|
|
15
17
|
return `${selector} { ${css} }`;
|
|
16
18
|
};
|
|
17
|
-
const cssAdvanced = ({ dictionary: originalDictionary, options = {
|
|
19
|
+
export const cssAdvanced = (_a) => __awaiter(void 0, [_a], void 0, function* ({ dictionary: originalDictionary, options = {
|
|
18
20
|
queries: [],
|
|
19
|
-
}, file, })
|
|
20
|
-
var
|
|
21
|
+
}, file, }) {
|
|
22
|
+
var _b, _c, _d, _e;
|
|
21
23
|
// get options
|
|
22
|
-
const { outputReferences, formatting } = options;
|
|
24
|
+
const { outputReferences, usesDtcg, formatting } = options;
|
|
23
25
|
// selector
|
|
24
|
-
const selector = ((
|
|
26
|
+
const selector = ((_b = file.options) === null || _b === void 0 ? void 0 : _b.selector) !== undefined ? file.options.selector : ':root';
|
|
25
27
|
// query extension property
|
|
26
|
-
const queryExtProp = ((
|
|
28
|
+
const queryExtProp = ((_c = file.options) === null || _c === void 0 ? void 0 : _c.queryExtensionProperty) || 'mediaQuery';
|
|
27
29
|
// get queries from file options
|
|
28
|
-
const queries = ((
|
|
30
|
+
const queries = ((_d = file.options) === null || _d === void 0 ? void 0 : _d.queries) || [
|
|
29
31
|
{
|
|
30
32
|
query: undefined,
|
|
31
33
|
matcher: () => true,
|
|
@@ -37,7 +39,7 @@ const cssAdvanced = ({ dictionary: originalDictionary, options = {
|
|
|
37
39
|
const dictionary = Object.assign({}, originalDictionary);
|
|
38
40
|
// get queries from tokens
|
|
39
41
|
for (const designToken of dictionary.allTokens) {
|
|
40
|
-
const query = (
|
|
42
|
+
const query = (_e = designToken.$extensions) === null || _e === void 0 ? void 0 : _e[queryExtProp];
|
|
41
43
|
// early abort if query does not exist on token
|
|
42
44
|
if (!query)
|
|
43
45
|
continue;
|
|
@@ -57,7 +59,7 @@ const cssAdvanced = ({ dictionary: originalDictionary, options = {
|
|
|
57
59
|
}
|
|
58
60
|
}
|
|
59
61
|
// add file header
|
|
60
|
-
const output = [fileHeader({ file })];
|
|
62
|
+
const output = [yield fileHeader({ file })];
|
|
61
63
|
// add single theme css
|
|
62
64
|
for (const query of queries) {
|
|
63
65
|
const { query: queryString, matcher } = query;
|
|
@@ -72,6 +74,7 @@ const cssAdvanced = ({ dictionary: originalDictionary, options = {
|
|
|
72
74
|
dictionary: filteredDictionary,
|
|
73
75
|
outputReferences,
|
|
74
76
|
formatting: mergedFormatting,
|
|
77
|
+
usesDtcg,
|
|
75
78
|
});
|
|
76
79
|
// wrap css
|
|
77
80
|
const cssWithSelector = wrapWithSelector(css, query.selector !== undefined ? query.selector : selector);
|
|
@@ -79,6 +82,5 @@ const cssAdvanced = ({ dictionary: originalDictionary, options = {
|
|
|
79
82
|
output.push(queryString ? `${queryString} { ${cssWithSelector} }` : cssWithSelector);
|
|
80
83
|
}
|
|
81
84
|
// return prettified
|
|
82
|
-
return
|
|
83
|
-
};
|
|
84
|
-
exports.cssAdvanced = cssAdvanced;
|
|
85
|
+
return yield format(output.join('\n'), { parser: 'css', printWidth: 500 });
|
|
86
|
+
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type { FormatFn } from 'style-dictionary/types';
|
|
2
2
|
/**
|
|
3
3
|
* @description Converts `StyleDictionary.dictionary.tokens` to css with @custom-media
|
|
4
4
|
* @param arguments [FormatterArguments](https://github.com/amzn/style-dictionary/blob/main/types/Format.d.ts)
|
|
5
5
|
* @returns formatted `string`
|
|
6
6
|
*/
|
|
7
|
-
export declare const cssCustomMedia:
|
|
7
|
+
export declare const cssCustomMedia: FormatFn;
|
|
@@ -1,25 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
return (
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
4
9
|
};
|
|
5
|
-
|
|
6
|
-
|
|
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
|
+
import { format } from 'prettier';
|
|
11
|
+
import { fileHeader } from 'style-dictionary/utils';
|
|
10
12
|
/**
|
|
11
13
|
* @description Converts `StyleDictionary.dictionary.tokens` to css with @custom-media
|
|
12
14
|
* @param arguments [FormatterArguments](https://github.com/amzn/style-dictionary/blob/main/types/Format.d.ts)
|
|
13
15
|
* @returns formatted `string`
|
|
14
16
|
*/
|
|
15
|
-
const cssCustomMedia = ({ dictionary, options: _options, file
|
|
17
|
+
export const cssCustomMedia = (_a) => __awaiter(void 0, [_a], void 0, function* ({ dictionary, options: _options, file }) {
|
|
16
18
|
// add file header
|
|
17
|
-
const output = [fileHeader({ file })];
|
|
19
|
+
const output = [yield fileHeader({ file })];
|
|
18
20
|
// add single theme css
|
|
19
|
-
dictionary.allTokens.map(({ name, value }) => {
|
|
20
|
-
output.push(`@custom-media --${name} ${value};`);
|
|
21
|
+
dictionary.allTokens.map(({ name, $value }) => {
|
|
22
|
+
output.push(`@custom-media --${name} ${$value};`);
|
|
21
23
|
});
|
|
22
24
|
// return prettified
|
|
23
|
-
return
|
|
24
|
-
};
|
|
25
|
-
exports.cssCustomMedia = cssCustomMedia;
|
|
25
|
+
return format(output.join('\n'), { parser: 'css', printWidth: 500 });
|
|
26
|
+
});
|
|
@@ -1,9 +1,9 @@
|
|
|
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
|
+
export { cssCustomMedia } from './cssCustomMedia.js';
|
|
2
|
+
export { cssAdvanced } from './cssAdvanced.js';
|
|
3
|
+
export { jsonFigma } from './jsonFigma.js';
|
|
4
|
+
export { javascriptCommonJs } from './javascriptCommonJs.js';
|
|
5
|
+
export { javascriptEsm } from './javascriptEsm.js';
|
|
6
|
+
export { jsonNestedPrefixed } from './jsonNestedPrefixed.js';
|
|
7
|
+
export { jsonOneDimensional } from './jsonOneDimensional.js';
|
|
8
|
+
export { jsonPostCssFallback } from './jsonPostCssFallback.js';
|
|
9
|
+
export { typescriptExportDefinition } from './typescriptExportDefinition.js';
|
|
@@ -1,21 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
+
export { cssCustomMedia } from './cssCustomMedia.js';
|
|
2
|
+
export { cssAdvanced } from './cssAdvanced.js';
|
|
3
|
+
export { jsonFigma } from './jsonFigma.js';
|
|
4
|
+
export { javascriptCommonJs } from './javascriptCommonJs.js';
|
|
5
|
+
export { javascriptEsm } from './javascriptEsm.js';
|
|
6
|
+
export { jsonNestedPrefixed } from './jsonNestedPrefixed.js';
|
|
7
|
+
export { jsonOneDimensional } from './jsonOneDimensional.js';
|
|
8
|
+
export { jsonPostCssFallback } from './jsonPostCssFallback.js';
|
|
9
|
+
export { typescriptExportDefinition } from './typescriptExportDefinition.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type { FormatFn } from 'style-dictionary/types';
|
|
2
2
|
/**
|
|
3
3
|
* @description Converts `StyleDictionary.dictionary.tokens` to javascript commonJS module
|
|
4
4
|
* @param arguments [FormatterArguments](https://github.com/amzn/style-dictionary/blob/main/types/Format.d.ts)
|
|
5
5
|
* @returns formatted `string`
|
|
6
6
|
*/
|
|
7
|
-
export declare const javascriptCommonJs:
|
|
7
|
+
export declare const javascriptCommonJs: FormatFn;
|
|
@@ -1,25 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
return (
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
4
9
|
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const prefixTokens_1 = require("./utilities/prefixTokens");
|
|
10
|
-
const style_dictionary_1 = __importDefault(require("style-dictionary"));
|
|
11
|
-
const { fileHeader } = style_dictionary_1.default.formatHelpers;
|
|
10
|
+
import { format } from 'prettier';
|
|
11
|
+
import { jsonToNestedValue } from './utilities/jsonToNestedValue.js';
|
|
12
|
+
import { prefixTokens } from './utilities/prefixTokens.js';
|
|
13
|
+
import { fileHeader } from 'style-dictionary/utils';
|
|
12
14
|
/**
|
|
13
15
|
* @description Converts `StyleDictionary.dictionary.tokens` to javascript commonJS module
|
|
14
16
|
* @param arguments [FormatterArguments](https://github.com/amzn/style-dictionary/blob/main/types/Format.d.ts)
|
|
15
17
|
* @returns formatted `string`
|
|
16
18
|
*/
|
|
17
|
-
const javascriptCommonJs = ({ dictionary, file, platform })
|
|
19
|
+
export const javascriptCommonJs = (_a) => __awaiter(void 0, [_a], void 0, function* ({ dictionary, file, platform }) {
|
|
18
20
|
// add prefix if defined
|
|
19
|
-
const tokens =
|
|
21
|
+
const tokens = prefixTokens(dictionary.tokens, platform);
|
|
20
22
|
// add file header and convert output
|
|
21
|
-
const output = `${fileHeader({ file })}module.exports = ${JSON.stringify(
|
|
23
|
+
const output = `${yield fileHeader({ file })}module.exports = ${JSON.stringify(jsonToNestedValue(tokens), null, 2)}\n`;
|
|
22
24
|
// return prettified
|
|
23
|
-
return
|
|
24
|
-
};
|
|
25
|
-
exports.javascriptCommonJs = javascriptCommonJs;
|
|
25
|
+
return format(output, { parser: 'typescript', printWidth: 500 });
|
|
26
|
+
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type { FormatFn } from 'style-dictionary/types';
|
|
2
2
|
/**
|
|
3
3
|
* @description Converts `StyleDictionary.dictionary.tokens` to javascript esm (javascript export statement)
|
|
4
4
|
* @param arguments [FormatterArguments](https://github.com/amzn/style-dictionary/blob/main/types/Format.d.ts)
|
|
5
5
|
* @returns formatted `string`
|
|
6
6
|
*/
|
|
7
|
-
export declare const javascriptEsm:
|
|
7
|
+
export declare const javascriptEsm: FormatFn;
|
|
@@ -1,25 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
return (
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
4
9
|
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const jsonToNestedValue_1 = require("./utilities/jsonToNestedValue");
|
|
10
|
-
const prefixTokens_1 = require("./utilities/prefixTokens");
|
|
11
|
-
const { fileHeader } = style_dictionary_1.default.formatHelpers;
|
|
10
|
+
import { format } from 'prettier';
|
|
11
|
+
import { jsonToNestedValue } from './utilities/jsonToNestedValue.js';
|
|
12
|
+
import { prefixTokens } from './utilities/prefixTokens.js';
|
|
13
|
+
import { fileHeader } from 'style-dictionary/utils';
|
|
12
14
|
/**
|
|
13
15
|
* @description Converts `StyleDictionary.dictionary.tokens` to javascript esm (javascript export statement)
|
|
14
16
|
* @param arguments [FormatterArguments](https://github.com/amzn/style-dictionary/blob/main/types/Format.d.ts)
|
|
15
17
|
* @returns formatted `string`
|
|
16
18
|
*/
|
|
17
|
-
const javascriptEsm = ({ dictionary, file, platform })
|
|
19
|
+
export const javascriptEsm = (_a) => __awaiter(void 0, [_a], void 0, function* ({ dictionary, file, platform }) {
|
|
18
20
|
// add prefix if defined
|
|
19
|
-
const tokens =
|
|
21
|
+
const tokens = prefixTokens(dictionary.tokens, platform);
|
|
20
22
|
// add file header and convert output
|
|
21
|
-
const output = `${fileHeader({ file })}export default \n${JSON.stringify(
|
|
23
|
+
const output = `${yield fileHeader({ file })}export default \n${JSON.stringify(jsonToNestedValue(tokens), null, 2)}\n`;
|
|
22
24
|
// return prettified
|
|
23
|
-
return
|
|
24
|
-
};
|
|
25
|
-
exports.javascriptEsm = javascriptEsm;
|
|
25
|
+
return format(output, { parser: 'typescript', printWidth: 500 });
|
|
26
|
+
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type { FormatFn } from 'style-dictionary/types';
|
|
2
2
|
/**
|
|
3
3
|
* @description Converts `StyleDictionary.dictionary.tokens` to javascript esm (javascript export statement)
|
|
4
4
|
* @param arguments [FormatterArguments](https://github.com/amzn/style-dictionary/blob/main/types/Format.d.ts)
|
|
5
5
|
* @returns formatted `string`
|
|
6
6
|
*/
|
|
7
|
-
export declare const jsonFigma:
|
|
7
|
+
export declare const jsonFigma: FormatFn;
|
|
@@ -1,23 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
return (
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
4
9
|
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const hexToRgbaFloat_1 = require("../transformers/utilities/hexToRgbaFloat");
|
|
11
|
-
const isRgbaFloat_1 = require("../transformers/utilities/isRgbaFloat");
|
|
12
|
-
const { sortByReference } = style_dictionary_1.default.formatHelpers;
|
|
10
|
+
import { format } from 'prettier';
|
|
11
|
+
import { transformNamePathToFigma } from '../transformers/namePathToFigma.js';
|
|
12
|
+
import { hexToRgbaFloat } from '../transformers/utilities/hexToRgbaFloat.js';
|
|
13
|
+
import { isRgbaFloat } from '../transformers/utilities/isRgbaFloat.js';
|
|
14
|
+
import { getReferences, sortByReference } from 'style-dictionary/utils';
|
|
13
15
|
const isReference = (string) => /^\{([^\\]*)\}$/g.test(string);
|
|
14
16
|
const getReference = (dictionary, refString, platform) => {
|
|
15
17
|
var _a;
|
|
16
18
|
if (isReference(refString)) {
|
|
17
19
|
// retrieve reference token
|
|
18
|
-
const refToken =
|
|
20
|
+
const refToken = getReferences(refString, dictionary.tokens, { unfilteredTokens: dictionary.unfilteredTokens })[0];
|
|
19
21
|
// return full reference
|
|
20
|
-
return [(_a = refToken.attributes) === null || _a === void 0 ? void 0 : _a.collection,
|
|
22
|
+
return [(_a = refToken.attributes) === null || _a === void 0 ? void 0 : _a.collection, transformNamePathToFigma(refToken, platform)].filter(Boolean).join('/');
|
|
21
23
|
}
|
|
22
24
|
};
|
|
23
25
|
const getFigmaType = (type) => {
|
|
@@ -52,8 +54,8 @@ const shadowToVariables = (name, values, token) => {
|
|
|
52
54
|
floatValue('spread'),
|
|
53
55
|
{
|
|
54
56
|
name: `${name}/color`,
|
|
55
|
-
value:
|
|
56
|
-
? Object.assign(Object.assign({}, values.color), (values.alpha ? { a: values.alpha } : {})) :
|
|
57
|
+
value: isRgbaFloat(values.color)
|
|
58
|
+
? Object.assign(Object.assign({}, values.color), (values.alpha ? { a: values.alpha } : {})) : hexToRgbaFloat(values.color, values.alpha),
|
|
57
59
|
type: 'COLOR',
|
|
58
60
|
scopes: ['EFFECT_COLOR'],
|
|
59
61
|
mode,
|
|
@@ -67,14 +69,18 @@ const shadowToVariables = (name, values, token) => {
|
|
|
67
69
|
* @param arguments [FormatterArguments](https://github.com/amzn/style-dictionary/blob/main/types/Format.d.ts)
|
|
68
70
|
* @returns formatted `string`
|
|
69
71
|
*/
|
|
70
|
-
const jsonFigma = ({ dictionary, file: _file, platform })
|
|
72
|
+
export const jsonFigma = (_a) => __awaiter(void 0, [_a], void 0, function* ({ dictionary, file: _file, platform }) {
|
|
71
73
|
// array to store tokens in
|
|
72
74
|
const tokens = [];
|
|
75
|
+
const sortedTokens = [...dictionary.allTokens].sort(sortByReference(dictionary.tokens, { unfilteredTokens: dictionary.unfilteredTokens }));
|
|
73
76
|
// loop through tokens sorted by reference
|
|
74
|
-
for (const token of
|
|
77
|
+
for (const token of sortedTokens) {
|
|
75
78
|
// deconstruct token
|
|
76
|
-
const { attributes, value, $type,
|
|
79
|
+
const { attributes, $value: value, $type, $description: description, original, alpha, mix } = token;
|
|
77
80
|
const { mode, collection, scopes, group, codeSyntax } = attributes || {};
|
|
81
|
+
// early escape if no type is present
|
|
82
|
+
if (!$type)
|
|
83
|
+
return;
|
|
78
84
|
// shadows need to be specifically dealt with
|
|
79
85
|
if ($type === 'shadow') {
|
|
80
86
|
const shadowValues = !Array.isArray(value) ? [value] : value;
|
|
@@ -99,7 +105,7 @@ const jsonFigma = ({ dictionary, file: _file, platform }) => {
|
|
|
99
105
|
isMix: mix ? true : undefined,
|
|
100
106
|
description,
|
|
101
107
|
refId: [collection, token.name].filter(Boolean).join('/'),
|
|
102
|
-
reference: getReference(dictionary, original
|
|
108
|
+
reference: getReference(dictionary, original.$value, platform),
|
|
103
109
|
collection,
|
|
104
110
|
mode,
|
|
105
111
|
group,
|
|
@@ -111,6 +117,5 @@ const jsonFigma = ({ dictionary, file: _file, platform }) => {
|
|
|
111
117
|
// add file header and convert output
|
|
112
118
|
const output = JSON.stringify(tokens, null, 2);
|
|
113
119
|
// return prettified
|
|
114
|
-
return
|
|
115
|
-
};
|
|
116
|
-
exports.jsonFigma = jsonFigma;
|
|
120
|
+
return format(output, { parser: 'json', printWidth: 500 });
|
|
121
|
+
});
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import type { FormatFn } from 'style-dictionary/types';
|
|
2
2
|
/**
|
|
3
3
|
* @description Takes a style dictionary token dictionary and converts it to a nested json string.
|
|
4
4
|
* In contrast to the `json/nested` this formatter does add a prefix if provided
|
|
5
|
-
* @param
|
|
5
|
+
* @param FormatFnArguments
|
|
6
6
|
* @returns formatted json `string`
|
|
7
7
|
*/
|
|
8
|
-
export declare const jsonNestedPrefixed:
|
|
8
|
+
export declare const jsonNestedPrefixed: FormatFn;
|
|
@@ -1,28 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
return (
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
4
9
|
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const prefixTokens_1 = require("./utilities/prefixTokens");
|
|
9
|
-
const jsonToNestedValue_1 = require("./utilities/jsonToNestedValue");
|
|
10
|
+
import { format } from 'prettier';
|
|
11
|
+
import { prefixTokens } from './utilities/prefixTokens.js';
|
|
12
|
+
import { jsonToNestedValue } from './utilities/jsonToNestedValue.js';
|
|
10
13
|
/**
|
|
11
14
|
* @description Takes a style dictionary token dictionary and converts it to a nested json string.
|
|
12
15
|
* In contrast to the `json/nested` this formatter does add a prefix if provided
|
|
13
|
-
* @param
|
|
16
|
+
* @param FormatFnArguments
|
|
14
17
|
* @returns formatted json `string`
|
|
15
18
|
*/
|
|
16
|
-
const jsonNestedPrefixed = ({ dictionary, file: _file, options, platform })
|
|
19
|
+
export const jsonNestedPrefixed = (_a) => __awaiter(void 0, [_a], void 0, function* ({ dictionary, file: _file, options, platform }) {
|
|
17
20
|
const { outputVerbose } = options;
|
|
18
21
|
// add prefix if defined
|
|
19
|
-
let tokens =
|
|
22
|
+
let tokens = prefixTokens(dictionary.tokens, platform);
|
|
20
23
|
if (!outputVerbose) {
|
|
21
|
-
tokens =
|
|
24
|
+
tokens = jsonToNestedValue(tokens);
|
|
22
25
|
}
|
|
23
26
|
// add file header and convert output
|
|
24
27
|
const output = JSON.stringify(tokens, null, 2);
|
|
25
28
|
// return prettified
|
|
26
|
-
return
|
|
27
|
-
};
|
|
28
|
-
exports.jsonNestedPrefixed = jsonNestedPrefixed;
|
|
29
|
+
return format(output, { parser: 'json', printWidth: 500 });
|
|
30
|
+
});
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import type { FormatFn } from 'style-dictionary/types';
|
|
2
2
|
/**
|
|
3
3
|
* @description Takes a style dictionary token dictionary and converts it to a one dimensional json object.
|
|
4
|
-
* @param
|
|
4
|
+
* @param FormatFnArguments
|
|
5
5
|
* @param options.nameSeparator - separator to use for nested token name
|
|
6
6
|
* @returns formatted json `string`
|
|
7
7
|
*/
|
|
8
|
-
export declare const jsonOneDimensional:
|
|
8
|
+
export declare const jsonOneDimensional: FormatFn;
|
|
@@ -1,24 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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");
|
|
1
|
+
import { format } from 'prettier';
|
|
2
|
+
import { jsonToFlat } from './utilities/jsonToFlat.js';
|
|
9
3
|
/**
|
|
10
4
|
* @description Takes a style dictionary token dictionary and converts it to a one dimensional json object.
|
|
11
|
-
* @param
|
|
5
|
+
* @param FormatFnArguments
|
|
12
6
|
* @param options.nameSeparator - separator to use for nested token name
|
|
13
7
|
* @returns formatted json `string`
|
|
14
8
|
*/
|
|
15
|
-
const jsonOneDimensional = ({ dictionary, file: _file, options }) => {
|
|
9
|
+
export const jsonOneDimensional = ({ dictionary, file: _file, options }) => {
|
|
16
10
|
// option to allow verbose output (object) or just the value
|
|
17
|
-
const { outputVerbose } = options;
|
|
18
|
-
const tokens =
|
|
19
|
-
|
|
20
|
-
|
|
11
|
+
const { outputVerbose, propertyConversion } = options;
|
|
12
|
+
const tokens = jsonToFlat(dictionary.allTokens, outputVerbose);
|
|
13
|
+
if (propertyConversion === undefined) {
|
|
14
|
+
//
|
|
15
|
+
const output = JSON.stringify(tokens, null, 2);
|
|
16
|
+
// return prettified
|
|
17
|
+
return format(output, { parser: 'json', printWidth: 500 });
|
|
18
|
+
}
|
|
19
|
+
// replace property names
|
|
20
|
+
const convertedTokens = Object.fromEntries(Object.entries(tokens).map(([name, token]) => {
|
|
21
|
+
for (const [from, to] of Object.entries(propertyConversion)) {
|
|
22
|
+
if (from in token) {
|
|
23
|
+
token[to] = token[from];
|
|
24
|
+
delete token[from];
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return [name, token];
|
|
28
|
+
}));
|
|
29
|
+
const output = JSON.stringify(convertedTokens, null, 2);
|
|
21
30
|
// return prettified
|
|
22
|
-
return
|
|
31
|
+
return format(output, { parser: 'json', printWidth: 500 });
|
|
23
32
|
};
|
|
24
|
-
exports.jsonOneDimensional = jsonOneDimensional;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import type { FormatFn } from 'style-dictionary/types';
|
|
2
2
|
/**
|
|
3
3
|
* @description Takes a style dictionary token dictionary and converts it to a one dimensional json object.
|
|
4
|
-
* @param
|
|
4
|
+
* @param FormatFnArguments
|
|
5
5
|
* @param options.nameSeparator - separator to use for nested token name
|
|
6
6
|
* @returns formatted json `string`
|
|
7
7
|
*/
|
|
8
|
-
export declare const jsonPostCssFallback:
|
|
8
|
+
export declare const jsonPostCssFallback: FormatFn;
|