@primer/primitives 10.0.0-rc.fd912e08 → 10.0.0
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 +2 -2
- package/dist/build/PrimerStyleDictionary.d.ts +8 -0
- package/dist/build/PrimerStyleDictionary.js +80 -0
- package/dist/build/filters/index.d.ts +14 -0
- package/dist/build/filters/index.js +14 -0
- package/dist/build/filters/isBorder.d.ts +7 -0
- package/dist/build/filters/isBorder.js +8 -0
- package/dist/build/filters/isColor.d.ts +7 -0
- package/dist/build/filters/isColor.js +13 -0
- package/dist/build/filters/isColorWithAlpha.d.ts +7 -0
- package/dist/build/filters/isColorWithAlpha.js +9 -0
- package/dist/build/filters/isColorWithMix.d.ts +7 -0
- package/dist/build/filters/isColorWithMix.js +24 -0
- package/dist/build/filters/isCubicBezier.d.ts +7 -0
- package/dist/build/filters/isCubicBezier.js +10 -0
- package/dist/build/filters/isDeprecated.d.ts +7 -0
- package/dist/build/filters/isDeprecated.js +8 -0
- package/dist/build/filters/isDimension.d.ts +7 -0
- package/dist/build/filters/isDimension.js +8 -0
- package/dist/build/filters/isDuration.d.ts +7 -0
- package/dist/build/filters/isDuration.js +8 -0
- package/dist/build/filters/isFontFamily.d.ts +7 -0
- package/dist/build/filters/isFontFamily.js +8 -0
- package/dist/build/filters/isFontWeight.d.ts +7 -0
- package/dist/build/filters/isFontWeight.js +8 -0
- package/dist/build/filters/isFromFile.d.ts +8 -0
- package/dist/build/filters/isFromFile.js +10 -0
- package/dist/build/filters/isNumber.d.ts +7 -0
- package/dist/build/filters/isNumber.js +8 -0
- package/dist/build/filters/isShadow.d.ts +7 -0
- package/dist/build/filters/isShadow.js +8 -0
- package/dist/build/filters/isSource.d.ts +7 -0
- package/dist/build/filters/isSource.js +8 -0
- package/dist/build/filters/isTypography.d.ts +7 -0
- package/dist/build/filters/isTypography.js +8 -0
- package/dist/build/formats/cssAdvanced.d.ts +2 -0
- package/dist/build/formats/cssAdvanced.js +86 -0
- package/dist/build/formats/cssCustomMedia.d.ts +7 -0
- package/dist/build/formats/cssCustomMedia.js +26 -0
- package/dist/build/formats/index.d.ts +9 -0
- package/dist/build/formats/index.js +9 -0
- package/dist/build/formats/javascriptCommonJs.d.ts +7 -0
- package/dist/build/formats/javascriptCommonJs.js +26 -0
- package/dist/build/formats/javascriptEsm.d.ts +7 -0
- package/dist/build/formats/javascriptEsm.js +26 -0
- package/dist/build/formats/jsonFigma.d.ts +7 -0
- package/dist/build/formats/jsonFigma.js +121 -0
- package/dist/build/formats/jsonNestedPrefixed.d.ts +8 -0
- package/dist/build/formats/jsonNestedPrefixed.js +30 -0
- package/dist/build/formats/jsonOneDimensional.d.ts +8 -0
- package/dist/build/formats/jsonOneDimensional.js +32 -0
- package/dist/build/formats/jsonPostCssFallback.d.ts +8 -0
- package/dist/build/formats/jsonPostCssFallback.js +14 -0
- package/dist/build/formats/typescriptExportDefinition.d.ts +7 -0
- package/dist/build/formats/typescriptExportDefinition.js +170 -0
- 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 +11 -0
- package/dist/build/formats/utilities/jsonToFlat.js +8 -0
- package/dist/build/formats/utilities/jsonToNestedValue.d.ts +8 -0
- package/dist/build/formats/utilities/jsonToNestedValue.js +23 -0
- package/dist/build/formats/utilities/prefixTokens.d.ts +8 -0
- package/dist/build/formats/utilities/prefixTokens.js +13 -0
- package/dist/build/parsers/index.d.ts +1 -0
- package/dist/build/parsers/index.js +1 -0
- package/dist/build/parsers/w3cJsonParser.d.ts +6 -0
- package/dist/build/parsers/w3cJsonParser.js +25 -0
- package/dist/build/platforms/css.d.ts +2 -0
- package/dist/build/platforms/css.js +96 -0
- package/dist/build/platforms/deprecatedJson.d.ts +2 -0
- package/dist/build/platforms/deprecatedJson.js +13 -0
- package/dist/build/platforms/docJson.d.ts +2 -0
- package/dist/build/platforms/docJson.js +35 -0
- package/dist/build/platforms/fallbacks.d.ts +2 -0
- package/dist/build/platforms/fallbacks.js +30 -0
- package/dist/build/platforms/figma.d.ts +2 -0
- package/dist/build/platforms/figma.js +60 -0
- package/dist/build/platforms/index.d.ts +10 -0
- package/dist/build/platforms/index.js +10 -0
- package/dist/build/platforms/javascript.d.ts +2 -0
- package/dist/build/platforms/javascript.js +26 -0
- package/dist/build/platforms/json.d.ts +2 -0
- package/dist/build/platforms/json.js +28 -0
- package/dist/build/platforms/styleLint.d.ts +2 -0
- package/dist/build/platforms/styleLint.js +30 -0
- package/dist/build/platforms/typeDefinitions.d.ts +2 -0
- package/dist/build/platforms/typeDefinitions.js +26 -0
- package/dist/build/platforms/typescript.d.ts +2 -0
- package/dist/build/platforms/typescript.js +26 -0
- package/dist/build/schemas/alphaValue.d.ts +2 -0
- package/dist/build/schemas/alphaValue.js +5 -0
- package/dist/build/schemas/baseToken.d.ts +11 -0
- package/dist/build/schemas/baseToken.js +7 -0
- package/dist/build/schemas/borderToken.d.ts +51 -0
- package/dist/build/schemas/borderToken.js +17 -0
- package/dist/build/schemas/collections.d.ts +6 -0
- package/dist/build/schemas/collections.js +12 -0
- package/dist/build/schemas/colorHexValue.d.ts +2 -0
- package/dist/build/schemas/colorHexValue.js +9 -0
- package/dist/build/schemas/colorToken.d.ts +92 -0
- package/dist/build/schemas/colorToken.js +53 -0
- package/dist/build/schemas/cubicBezierToken.d.ts +18 -0
- package/dist/build/schemas/cubicBezierToken.js +8 -0
- package/dist/build/schemas/designToken.d.ts +2 -0
- package/dist/build/schemas/designToken.js +35 -0
- package/dist/build/schemas/dimensionToken.d.ts +59 -0
- package/dist/build/schemas/dimensionToken.js +34 -0
- package/dist/build/schemas/dimensionValue.d.ts +2 -0
- package/dist/build/schemas/dimensionValue.js +9 -0
- package/dist/build/schemas/durationToken.d.ts +18 -0
- package/dist/build/schemas/durationToken.js +11 -0
- package/dist/build/schemas/durationValue.d.ts +2 -0
- package/dist/build/schemas/durationValue.js +5 -0
- package/dist/build/schemas/fontFamilyToken.d.ts +52 -0
- package/dist/build/schemas/fontFamilyToken.js +20 -0
- package/dist/build/schemas/fontWeightToken.d.ts +52 -0
- package/dist/build/schemas/fontWeightToken.js +21 -0
- package/dist/build/schemas/fontWeightValue.d.ts +2 -0
- package/dist/build/schemas/fontWeightValue.js +6 -0
- package/dist/build/schemas/numberToken.d.ts +71 -0
- package/dist/build/schemas/numberToken.js +27 -0
- package/dist/build/schemas/referenceValue.d.ts +2 -0
- package/dist/build/schemas/referenceValue.js +5 -0
- package/dist/build/schemas/scopes.d.ts +5 -0
- package/dist/build/schemas/scopes.js +29 -0
- package/dist/build/schemas/shadowToken.d.ts +164 -0
- package/dist/build/schemas/shadowToken.js +46 -0
- package/dist/build/schemas/stringToken.d.ts +18 -0
- package/dist/build/schemas/stringToken.js +10 -0
- package/dist/build/schemas/tokenName.d.ts +2 -0
- package/dist/build/schemas/tokenName.js +5 -0
- package/dist/build/schemas/tokenType.d.ts +3 -0
- package/dist/build/schemas/tokenType.js +2 -0
- package/dist/build/schemas/typographyToken.d.ts +59 -0
- package/dist/build/schemas/typographyToken.js +18 -0
- package/dist/build/schemas/validTokenType.d.ts +5 -0
- package/dist/build/schemas/validTokenType.js +31 -0
- package/dist/build/schemas/viewportRangeToken.d.ts +18 -0
- package/dist/build/schemas/viewportRangeToken.js +10 -0
- package/dist/build/transformers/borderToCss.d.ts +8 -0
- package/dist/build/transformers/borderToCss.js +38 -0
- package/dist/build/transformers/colorToHex.d.ts +8 -0
- package/dist/build/transformers/colorToHex.js +24 -0
- package/dist/build/transformers/colorToHexMix.d.ts +8 -0
- package/dist/build/transformers/colorToHexMix.js +20 -0
- package/dist/build/transformers/colorToRgbAlpha.d.ts +8 -0
- package/dist/build/transformers/colorToRgbAlpha.js +20 -0
- package/dist/build/transformers/colorToRgbaFloat.d.ts +8 -0
- package/dist/build/transformers/colorToRgbaFloat.js +46 -0
- package/dist/build/transformers/cubicBezierToCss.d.ts +8 -0
- package/dist/build/transformers/cubicBezierToCss.js +23 -0
- package/dist/build/transformers/dimensionToPixelUnitless.d.ts +8 -0
- package/dist/build/transformers/dimensionToPixelUnitless.js +49 -0
- package/dist/build/transformers/dimensionToRem.d.ts +8 -0
- package/dist/build/transformers/dimensionToRem.js +46 -0
- package/dist/build/transformers/dimensionToRemPxArray.d.ts +8 -0
- package/dist/build/transformers/dimensionToRemPxArray.js +46 -0
- package/dist/build/transformers/durationToCss.d.ts +8 -0
- package/dist/build/transformers/durationToCss.js +29 -0
- package/dist/build/transformers/figmaAttributes.d.ts +8 -0
- package/dist/build/transformers/figmaAttributes.js +55 -0
- package/dist/build/transformers/floatToPixel.d.ts +15 -0
- package/dist/build/transformers/floatToPixel.js +39 -0
- package/dist/build/transformers/fontFamilyToCss.d.ts +14 -0
- package/dist/build/transformers/fontFamilyToCss.js +37 -0
- package/dist/build/transformers/fontFamilyToFigma.d.ts +14 -0
- package/dist/build/transformers/fontFamilyToFigma.js +44 -0
- package/dist/build/transformers/fontWeightToNumber.d.ts +9 -0
- package/dist/build/transformers/fontWeightToNumber.js +50 -0
- package/dist/build/transformers/index.d.ts +25 -0
- package/dist/build/transformers/index.js +25 -0
- package/dist/build/transformers/jsonDeprecated.d.ts +8 -0
- package/dist/build/transformers/jsonDeprecated.js +14 -0
- package/dist/build/transformers/namePathToCamelCase.d.ts +8 -0
- package/dist/build/transformers/namePathToCamelCase.js +12 -0
- package/dist/build/transformers/namePathToDotNotation.d.ts +8 -0
- package/dist/build/transformers/namePathToDotNotation.js +31 -0
- package/dist/build/transformers/namePathToFigma.d.ts +9 -0
- package/dist/build/transformers/namePathToFigma.js +21 -0
- package/dist/build/transformers/namePathToKebabCase.d.ts +8 -0
- package/dist/build/transformers/namePathToKebabCase.js +16 -0
- package/dist/build/transformers/namePathToPascalCase.d.ts +8 -0
- package/dist/build/transformers/namePathToPascalCase.js +12 -0
- package/dist/build/transformers/namePathToSlashNotation.d.ts +8 -0
- package/dist/build/transformers/namePathToSlashNotation.js +16 -0
- package/dist/build/transformers/shadowToCss.d.ts +8 -0
- package/dist/build/transformers/shadowToCss.js +34 -0
- package/dist/build/transformers/typographyToCss.d.ts +8 -0
- package/dist/build/transformers/typographyToCss.js +27 -0
- package/dist/build/transformers/utilities/alpha.d.ts +9 -0
- package/dist/build/transformers/utilities/alpha.js +16 -0
- package/dist/build/transformers/utilities/checkRequiredTokenProperties.d.ts +7 -0
- package/dist/build/transformers/utilities/checkRequiredTokenProperties.js +13 -0
- package/dist/build/transformers/utilities/getTokenValue.d.ts +2 -0
- package/dist/build/transformers/utilities/getTokenValue.js +16 -0
- package/dist/build/transformers/utilities/hasSpaceInString.d.ts +1 -0
- package/dist/build/transformers/utilities/hasSpaceInString.js +6 -0
- package/dist/build/transformers/utilities/hexToRgbaFloat.d.ts +2 -0
- package/dist/build/transformers/utilities/hexToRgbaFloat.js +29 -0
- package/dist/build/transformers/utilities/invalidTokenError.d.ts +7 -0
- package/dist/build/transformers/utilities/invalidTokenError.js +27 -0
- package/dist/build/transformers/utilities/isRgbaFloat.d.ts +7 -0
- package/dist/build/transformers/utilities/isRgbaFloat.js +20 -0
- package/dist/build/transformers/utilities/mix.d.ts +5 -0
- package/dist/build/transformers/utilities/mix.js +38 -0
- package/dist/build/transformers/utilities/rgbaFloatToHex.d.ts +6 -0
- package/dist/build/transformers/utilities/rgbaFloatToHex.js +11 -0
- 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 +8 -0
- package/dist/build/utilities/copyFromDir.js +31 -0
- package/dist/build/utilities/filterStringArray.d.ts +1 -0
- package/dist/build/utilities/filterStringArray.js +13 -0
- package/dist/build/utilities/getFlag.d.ts +8 -0
- package/dist/build/utilities/getFlag.js +12 -0
- package/dist/build/utilities/index.d.ts +9 -0
- package/dist/build/utilities/index.js +9 -0
- package/dist/build/utilities/joinFriendly.d.ts +1 -0
- package/dist/build/utilities/joinFriendly.js +1 -0
- package/dist/build/utilities/schemaErrorMessage.d.ts +1 -0
- package/dist/build/utilities/schemaErrorMessage.js +1 -0
- package/dist/build/utilities/toCamelCase.d.ts +1 -0
- package/dist/build/utilities/toCamelCase.js +16 -0
- package/dist/build/utilities/toPascalCase.d.ts +1 -0
- package/dist/build/utilities/toPascalCase.js +13 -0
- package/dist/build/utilities/treeWalker.d.ts +8 -0
- package/dist/build/utilities/treeWalker.js +23 -0
- package/dist/build/utilities/upperCaseFirstCharacter.d.ts +8 -0
- package/dist/build/utilities/upperCaseFirstCharacter.js +10 -0
- package/dist/css/base/motion/motion.css +17 -0
- package/dist/css/functional/motion/motion.css +4 -3
- package/dist/css/functional/themes/dark-colorblind.css +58 -38
- package/dist/css/functional/themes/dark-dimmed.css +44 -24
- package/dist/css/functional/themes/dark-high-contrast.css +42 -22
- package/dist/css/functional/themes/dark-tritanopia.css +44 -24
- package/dist/css/functional/themes/dark.css +42 -22
- package/dist/css/functional/themes/light-colorblind.css +60 -40
- package/dist/css/functional/themes/light-high-contrast.css +44 -24
- package/dist/css/functional/themes/light-tritanopia.css +42 -22
- package/dist/css/functional/themes/light.css +42 -22
- package/dist/css/functional/typography/typography.css +43 -43
- package/dist/css/primitives.css +64 -46
- package/dist/docs/base/motion/motion.json +205 -0
- package/dist/docs/functional/motion/motion.json +18 -3
- package/dist/docs/functional/themes/dark-colorblind.json +350 -1114
- package/dist/docs/functional/themes/dark-dimmed.json +364 -1152
- package/dist/docs/functional/themes/dark-high-contrast.json +312 -922
- package/dist/docs/functional/themes/dark-tritanopia.json +344 -1138
- package/dist/docs/functional/themes/dark.json +346 -1206
- package/dist/docs/functional/themes/light-colorblind.json +366 -1140
- package/dist/docs/functional/themes/light-high-contrast.json +335 -949
- package/dist/docs/functional/themes/light-tritanopia.json +311 -1135
- package/dist/docs/functional/themes/light.json +336 -1202
- package/dist/fallbacks/base/motion/motion.json +17 -0
- package/dist/fallbacks/functional/motion/motion.json +1 -0
- package/dist/figma/dimension/dimension.json +518 -518
- package/dist/figma/figma.json +19 -19
- package/dist/figma/scales/dark-dimmed.json +3536 -656
- package/dist/figma/scales/dark-high-constrast.json +3535 -655
- package/dist/figma/scales/dark.json +3371 -491
- package/dist/figma/scales/light-high-constrast.json +3533 -653
- package/dist/figma/scales/light.json +3370 -490
- package/dist/figma/shadows/dark-colorblind.json +285 -285
- package/dist/figma/shadows/dark-dimmed.json +285 -285
- package/dist/figma/shadows/dark-high-contrast.json +285 -285
- package/dist/figma/shadows/dark-tritanopia.json +285 -285
- package/dist/figma/shadows/dark.json +285 -285
- package/dist/figma/shadows/light-colorblind.json +254 -254
- package/dist/figma/shadows/light-high-contrast.json +254 -254
- package/dist/figma/shadows/light-tritanopia.json +254 -254
- package/dist/figma/shadows/light.json +254 -254
- package/dist/figma/themes/dark-colorblind.json +5197 -5068
- package/dist/figma/themes/dark-dimmed.json +5526 -5351
- package/dist/figma/themes/dark-high-contrast.json +4361 -4251
- package/dist/figma/themes/dark-tritanopia.json +5315 -5187
- package/dist/figma/themes/dark.json +5740 -5581
- package/dist/figma/themes/light-colorblind.json +5104 -4929
- package/dist/figma/themes/light-high-contrast.json +4462 -4319
- package/dist/figma/themes/light-tritanopia.json +5176 -5050
- package/dist/figma/themes/light.json +5657 -5500
- package/dist/figma/typography/typography.json +162 -162
- package/dist/internalCss/dark-colorblind.css +58 -38
- package/dist/internalCss/dark-dimmed.css +44 -24
- package/dist/internalCss/dark-high-contrast.css +42 -22
- package/dist/internalCss/dark-tritanopia.css +44 -24
- package/dist/internalCss/dark.css +42 -22
- package/dist/internalCss/light-colorblind.css +60 -40
- package/dist/internalCss/light-high-contrast.css +44 -24
- package/dist/internalCss/light-tritanopia.css +42 -22
- package/dist/internalCss/light.css +42 -22
- package/dist/styleLint/base/motion/motion.json +205 -0
- package/dist/styleLint/functional/motion/motion.json +18 -3
- package/dist/styleLint/functional/themes/dark-colorblind.json +350 -1114
- package/dist/styleLint/functional/themes/dark-dimmed.json +364 -1152
- package/dist/styleLint/functional/themes/dark-high-contrast.json +311 -921
- package/dist/styleLint/functional/themes/dark-tritanopia.json +344 -1138
- package/dist/styleLint/functional/themes/dark.json +346 -1206
- package/dist/styleLint/functional/themes/light-colorblind.json +366 -1140
- package/dist/styleLint/functional/themes/light-high-contrast.json +335 -949
- package/dist/styleLint/functional/themes/light-tritanopia.json +311 -1135
- package/dist/styleLint/functional/themes/light.json +336 -1202
- package/package.json +23 -30
- package/src/tokens/base/motion/easing.json5 +26 -0
- package/src/tokens/base/motion/timing.json5 +50 -0
- package/src/tokens/functional/color/dark/app-dark.json5 +236 -121
- package/src/tokens/functional/color/dark/data-vis-dark.json5 +40 -40
- package/src/tokens/functional/color/dark/display-dark.json5 +95 -95
- package/src/tokens/functional/color/dark/overrides/dark.dimmed.json5 +1 -9
- package/src/tokens/functional/color/dark/overrides/dark.high-contrast.json5 +40 -27
- package/src/tokens/functional/color/dark/overrides/dark.protanopia-deuteranopia.json5 +56 -30
- package/src/tokens/functional/color/dark/overrides/dark.tritanopia.json5 +37 -14
- package/src/tokens/functional/color/dark/patterns-dark.json +3963 -0
- package/src/tokens/functional/color/dark/patterns-dark.json5 +126 -277
- package/src/tokens/functional/color/dark/primitives-dark.json5 +78 -78
- package/src/tokens/functional/color/dark/syntax-dark.json5 +47 -47
- package/src/tokens/functional/color/light/app-light.json5 +179 -118
- package/src/tokens/functional/color/light/data-vis-light.json5 +40 -40
- package/src/tokens/functional/color/light/display-light.json5 +0 -95
- package/src/tokens/functional/color/light/overrides/light.high-contrast.json5 +25 -27
- package/src/tokens/functional/color/light/overrides/light.protanopia-deuteranopia.json5 +58 -33
- package/src/tokens/functional/color/light/overrides/light.tritanopia.json5 +59 -10
- package/src/tokens/functional/color/light/patterns-light.json5 +126 -276
- package/src/tokens/functional/color/light/primitives-light.json5 +0 -78
- package/src/tokens/functional/color/light/syntax-light.json5 +0 -47
- package/src/tokens/functional/motion/loading.json5 +1 -1
- package/src/tokens/functional/motion/patterns.json5 +9 -2
- package/src/tokens/functional/shadow/dark.json5 +0 -14
- package/src/tokens/functional/shadow/light.json5 +0 -13
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { joinFriendly, schemaErrorMessage } from '../utilities/index.js';
|
|
3
|
+
const validScopes = [
|
|
4
|
+
'all',
|
|
5
|
+
'bgColor',
|
|
6
|
+
'fgColor',
|
|
7
|
+
'borderColor',
|
|
8
|
+
'borderWidth',
|
|
9
|
+
'size',
|
|
10
|
+
'gap',
|
|
11
|
+
'radius',
|
|
12
|
+
'effectColor',
|
|
13
|
+
'effectFloat',
|
|
14
|
+
'opacity',
|
|
15
|
+
'fontFamily',
|
|
16
|
+
'fontStyle',
|
|
17
|
+
'fontWeight',
|
|
18
|
+
'fontSize',
|
|
19
|
+
'lineHeight',
|
|
20
|
+
'letterSpacing',
|
|
21
|
+
'paragraphSpacing',
|
|
22
|
+
'paragraphIndent',
|
|
23
|
+
];
|
|
24
|
+
export const scopes = (scopeSubset) => {
|
|
25
|
+
const scopeArray = scopeSubset !== null && scopeSubset !== void 0 ? scopeSubset : validScopes;
|
|
26
|
+
return z.array(z.string()).refine(value => value.every(item => scopeArray.includes(item)), value => ({
|
|
27
|
+
message: schemaErrorMessage(`Invalid scope: "${value}"`, `Valid scopes are: ${joinFriendly(scopeArray)}`),
|
|
28
|
+
}));
|
|
29
|
+
};
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const shadowValue: z.ZodObject<{
|
|
3
|
+
color: z.ZodUnion<[z.ZodEffects<z.ZodString, string, string>, z.ZodEffects<z.ZodString, string, string>]>;
|
|
4
|
+
alpha: z.ZodUnion<[z.ZodEffects<z.ZodAny, any, any>, z.ZodEffects<z.ZodString, string, string>]>;
|
|
5
|
+
offsetX: z.ZodUnion<[z.ZodUnion<[z.ZodEffects<z.ZodString, string, string>, z.ZodLiteral<"0">, z.ZodLiteral<0>]>, z.ZodEffects<z.ZodString, string, string>]>;
|
|
6
|
+
offsetY: z.ZodUnion<[z.ZodUnion<[z.ZodEffects<z.ZodString, string, string>, z.ZodLiteral<"0">, z.ZodLiteral<0>]>, z.ZodEffects<z.ZodString, string, string>]>;
|
|
7
|
+
blur: z.ZodUnion<[z.ZodUnion<[z.ZodEffects<z.ZodString, string, string>, z.ZodLiteral<"0">, z.ZodLiteral<0>]>, z.ZodEffects<z.ZodString, string, string>]>;
|
|
8
|
+
spread: z.ZodUnion<[z.ZodUnion<[z.ZodEffects<z.ZodString, string, string>, z.ZodLiteral<"0">, z.ZodLiteral<0>]>, z.ZodEffects<z.ZodString, string, string>]>;
|
|
9
|
+
inset: z.ZodOptional<z.ZodBoolean>;
|
|
10
|
+
}, "strict", z.ZodTypeAny, {
|
|
11
|
+
color: string;
|
|
12
|
+
blur: string | 0;
|
|
13
|
+
offsetX: string | 0;
|
|
14
|
+
offsetY: string | 0;
|
|
15
|
+
spread: string | 0;
|
|
16
|
+
alpha?: any;
|
|
17
|
+
inset?: boolean | undefined;
|
|
18
|
+
}, {
|
|
19
|
+
color: string;
|
|
20
|
+
blur: string | 0;
|
|
21
|
+
offsetX: string | 0;
|
|
22
|
+
offsetY: string | 0;
|
|
23
|
+
spread: string | 0;
|
|
24
|
+
alpha?: any;
|
|
25
|
+
inset?: boolean | undefined;
|
|
26
|
+
}>;
|
|
27
|
+
export declare const shadowToken: z.ZodObject<z.objectUtil.extendShape<{
|
|
28
|
+
$description: z.ZodOptional<z.ZodString>;
|
|
29
|
+
$deprecated: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodBoolean]>>;
|
|
30
|
+
}, {
|
|
31
|
+
$value: z.ZodUnion<[z.ZodObject<{
|
|
32
|
+
color: z.ZodUnion<[z.ZodEffects<z.ZodString, string, string>, z.ZodEffects<z.ZodString, string, string>]>;
|
|
33
|
+
alpha: z.ZodUnion<[z.ZodEffects<z.ZodAny, any, any>, z.ZodEffects<z.ZodString, string, string>]>;
|
|
34
|
+
offsetX: z.ZodUnion<[z.ZodUnion<[z.ZodEffects<z.ZodString, string, string>, z.ZodLiteral<"0">, z.ZodLiteral<0>]>, z.ZodEffects<z.ZodString, string, string>]>;
|
|
35
|
+
offsetY: z.ZodUnion<[z.ZodUnion<[z.ZodEffects<z.ZodString, string, string>, z.ZodLiteral<"0">, z.ZodLiteral<0>]>, z.ZodEffects<z.ZodString, string, string>]>;
|
|
36
|
+
blur: z.ZodUnion<[z.ZodUnion<[z.ZodEffects<z.ZodString, string, string>, z.ZodLiteral<"0">, z.ZodLiteral<0>]>, z.ZodEffects<z.ZodString, string, string>]>;
|
|
37
|
+
spread: z.ZodUnion<[z.ZodUnion<[z.ZodEffects<z.ZodString, string, string>, z.ZodLiteral<"0">, z.ZodLiteral<0>]>, z.ZodEffects<z.ZodString, string, string>]>;
|
|
38
|
+
inset: z.ZodOptional<z.ZodBoolean>;
|
|
39
|
+
}, "strict", z.ZodTypeAny, {
|
|
40
|
+
color: string;
|
|
41
|
+
blur: string | 0;
|
|
42
|
+
offsetX: string | 0;
|
|
43
|
+
offsetY: string | 0;
|
|
44
|
+
spread: string | 0;
|
|
45
|
+
alpha?: any;
|
|
46
|
+
inset?: boolean | undefined;
|
|
47
|
+
}, {
|
|
48
|
+
color: string;
|
|
49
|
+
blur: string | 0;
|
|
50
|
+
offsetX: string | 0;
|
|
51
|
+
offsetY: string | 0;
|
|
52
|
+
spread: string | 0;
|
|
53
|
+
alpha?: any;
|
|
54
|
+
inset?: boolean | undefined;
|
|
55
|
+
}>, z.ZodArray<z.ZodObject<{
|
|
56
|
+
color: z.ZodUnion<[z.ZodEffects<z.ZodString, string, string>, z.ZodEffects<z.ZodString, string, string>]>;
|
|
57
|
+
alpha: z.ZodUnion<[z.ZodEffects<z.ZodAny, any, any>, z.ZodEffects<z.ZodString, string, string>]>;
|
|
58
|
+
offsetX: z.ZodUnion<[z.ZodUnion<[z.ZodEffects<z.ZodString, string, string>, z.ZodLiteral<"0">, z.ZodLiteral<0>]>, z.ZodEffects<z.ZodString, string, string>]>;
|
|
59
|
+
offsetY: z.ZodUnion<[z.ZodUnion<[z.ZodEffects<z.ZodString, string, string>, z.ZodLiteral<"0">, z.ZodLiteral<0>]>, z.ZodEffects<z.ZodString, string, string>]>;
|
|
60
|
+
blur: z.ZodUnion<[z.ZodUnion<[z.ZodEffects<z.ZodString, string, string>, z.ZodLiteral<"0">, z.ZodLiteral<0>]>, z.ZodEffects<z.ZodString, string, string>]>;
|
|
61
|
+
spread: z.ZodUnion<[z.ZodUnion<[z.ZodEffects<z.ZodString, string, string>, z.ZodLiteral<"0">, z.ZodLiteral<0>]>, z.ZodEffects<z.ZodString, string, string>]>;
|
|
62
|
+
inset: z.ZodOptional<z.ZodBoolean>;
|
|
63
|
+
}, "strict", z.ZodTypeAny, {
|
|
64
|
+
color: string;
|
|
65
|
+
blur: string | 0;
|
|
66
|
+
offsetX: string | 0;
|
|
67
|
+
offsetY: string | 0;
|
|
68
|
+
spread: string | 0;
|
|
69
|
+
alpha?: any;
|
|
70
|
+
inset?: boolean | undefined;
|
|
71
|
+
}, {
|
|
72
|
+
color: string;
|
|
73
|
+
blur: string | 0;
|
|
74
|
+
offsetX: string | 0;
|
|
75
|
+
offsetY: string | 0;
|
|
76
|
+
spread: string | 0;
|
|
77
|
+
alpha?: any;
|
|
78
|
+
inset?: boolean | undefined;
|
|
79
|
+
}>, "many">, z.ZodEffects<z.ZodString, string, string>]>;
|
|
80
|
+
$type: z.ZodLiteral<"string" | "number" | "border" | "color" | "fontFamily" | "fontWeight" | "dimension" | "duration" | "shadow" | "typography" | "cubicBezier" | "custom-viewportRange">;
|
|
81
|
+
$extensions: z.ZodOptional<z.ZodObject<{
|
|
82
|
+
'org.primer.figma': z.ZodObject<{
|
|
83
|
+
collection: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
84
|
+
modeOverride: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
85
|
+
group: z.ZodOptional<z.ZodString>;
|
|
86
|
+
}, "strict", z.ZodTypeAny, {
|
|
87
|
+
group?: string | undefined;
|
|
88
|
+
collection?: string | undefined;
|
|
89
|
+
modeOverride?: string | undefined;
|
|
90
|
+
}, {
|
|
91
|
+
group?: string | undefined;
|
|
92
|
+
collection?: string | undefined;
|
|
93
|
+
modeOverride?: string | undefined;
|
|
94
|
+
}>;
|
|
95
|
+
}, "strip", z.ZodTypeAny, {
|
|
96
|
+
'org.primer.figma': {
|
|
97
|
+
group?: string | undefined;
|
|
98
|
+
collection?: string | undefined;
|
|
99
|
+
modeOverride?: string | undefined;
|
|
100
|
+
};
|
|
101
|
+
}, {
|
|
102
|
+
'org.primer.figma': {
|
|
103
|
+
group?: string | undefined;
|
|
104
|
+
collection?: string | undefined;
|
|
105
|
+
modeOverride?: string | undefined;
|
|
106
|
+
};
|
|
107
|
+
}>>;
|
|
108
|
+
}>, "strict", z.ZodTypeAny, {
|
|
109
|
+
$value: string | {
|
|
110
|
+
color: string;
|
|
111
|
+
blur: string | 0;
|
|
112
|
+
offsetX: string | 0;
|
|
113
|
+
offsetY: string | 0;
|
|
114
|
+
spread: string | 0;
|
|
115
|
+
alpha?: any;
|
|
116
|
+
inset?: boolean | undefined;
|
|
117
|
+
} | {
|
|
118
|
+
color: string;
|
|
119
|
+
blur: string | 0;
|
|
120
|
+
offsetX: string | 0;
|
|
121
|
+
offsetY: string | 0;
|
|
122
|
+
spread: string | 0;
|
|
123
|
+
alpha?: any;
|
|
124
|
+
inset?: boolean | undefined;
|
|
125
|
+
}[];
|
|
126
|
+
$type: "string" | "number" | "border" | "color" | "fontFamily" | "fontWeight" | "dimension" | "duration" | "shadow" | "typography" | "cubicBezier" | "custom-viewportRange";
|
|
127
|
+
$description?: string | undefined;
|
|
128
|
+
$deprecated?: string | boolean | undefined;
|
|
129
|
+
$extensions?: {
|
|
130
|
+
'org.primer.figma': {
|
|
131
|
+
group?: string | undefined;
|
|
132
|
+
collection?: string | undefined;
|
|
133
|
+
modeOverride?: string | undefined;
|
|
134
|
+
};
|
|
135
|
+
} | undefined;
|
|
136
|
+
}, {
|
|
137
|
+
$value: string | {
|
|
138
|
+
color: string;
|
|
139
|
+
blur: string | 0;
|
|
140
|
+
offsetX: string | 0;
|
|
141
|
+
offsetY: string | 0;
|
|
142
|
+
spread: string | 0;
|
|
143
|
+
alpha?: any;
|
|
144
|
+
inset?: boolean | undefined;
|
|
145
|
+
} | {
|
|
146
|
+
color: string;
|
|
147
|
+
blur: string | 0;
|
|
148
|
+
offsetX: string | 0;
|
|
149
|
+
offsetY: string | 0;
|
|
150
|
+
spread: string | 0;
|
|
151
|
+
alpha?: any;
|
|
152
|
+
inset?: boolean | undefined;
|
|
153
|
+
}[];
|
|
154
|
+
$type: "string" | "number" | "border" | "color" | "fontFamily" | "fontWeight" | "dimension" | "duration" | "shadow" | "typography" | "cubicBezier" | "custom-viewportRange";
|
|
155
|
+
$description?: string | undefined;
|
|
156
|
+
$deprecated?: string | boolean | undefined;
|
|
157
|
+
$extensions?: {
|
|
158
|
+
'org.primer.figma': {
|
|
159
|
+
group?: string | undefined;
|
|
160
|
+
collection?: string | undefined;
|
|
161
|
+
modeOverride?: string | undefined;
|
|
162
|
+
};
|
|
163
|
+
} | undefined;
|
|
164
|
+
}>;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { baseToken } from './baseToken.js';
|
|
3
|
+
import { referenceValue } from './referenceValue.js';
|
|
4
|
+
import { colorHexValue } from './colorHexValue.js';
|
|
5
|
+
import { alphaValue } from './alphaValue.js';
|
|
6
|
+
import { dimensionValue } from './dimensionValue.js';
|
|
7
|
+
import { tokenType } from './tokenType.js';
|
|
8
|
+
import { collection, mode } from './collections.js';
|
|
9
|
+
export const shadowValue = z
|
|
10
|
+
.object({
|
|
11
|
+
color: z.union([colorHexValue, referenceValue]),
|
|
12
|
+
alpha: z.union([alphaValue, referenceValue]),
|
|
13
|
+
offsetX: z.union([dimensionValue, referenceValue]),
|
|
14
|
+
offsetY: z.union([dimensionValue, referenceValue]),
|
|
15
|
+
blur: z.union([dimensionValue, referenceValue]),
|
|
16
|
+
spread: z.union([dimensionValue, referenceValue]),
|
|
17
|
+
inset: z.boolean().optional(),
|
|
18
|
+
})
|
|
19
|
+
.strict();
|
|
20
|
+
export const shadowToken = baseToken
|
|
21
|
+
.extend({
|
|
22
|
+
$value: z.union([shadowValue, z.array(shadowValue), referenceValue]),
|
|
23
|
+
$type: tokenType('shadow'),
|
|
24
|
+
$extensions: z
|
|
25
|
+
.object({
|
|
26
|
+
'org.primer.figma': z
|
|
27
|
+
.object({
|
|
28
|
+
collection: collection(['mode']).optional(),
|
|
29
|
+
modeOverride: mode([
|
|
30
|
+
'light',
|
|
31
|
+
'dark',
|
|
32
|
+
'dark dimmed',
|
|
33
|
+
'light high contrast',
|
|
34
|
+
'dark high contrast',
|
|
35
|
+
'light colorblind',
|
|
36
|
+
'dark colorblind',
|
|
37
|
+
'light tritanopia',
|
|
38
|
+
'dark tritanopia',
|
|
39
|
+
]).optional(),
|
|
40
|
+
group: z.string().optional(),
|
|
41
|
+
})
|
|
42
|
+
.strict(),
|
|
43
|
+
})
|
|
44
|
+
.optional(),
|
|
45
|
+
})
|
|
46
|
+
.strict();
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const stringToken: z.ZodObject<z.objectUtil.extendShape<{
|
|
3
|
+
$description: z.ZodOptional<z.ZodString>;
|
|
4
|
+
$deprecated: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodBoolean]>>;
|
|
5
|
+
}, {
|
|
6
|
+
$value: z.ZodUnion<[z.ZodString, z.ZodEffects<z.ZodString, string, string>]>;
|
|
7
|
+
$type: z.ZodLiteral<"string" | "number" | "border" | "color" | "fontFamily" | "fontWeight" | "dimension" | "duration" | "shadow" | "typography" | "cubicBezier" | "custom-viewportRange">;
|
|
8
|
+
}>, "strict", z.ZodTypeAny, {
|
|
9
|
+
$value: string;
|
|
10
|
+
$type: "string" | "number" | "border" | "color" | "fontFamily" | "fontWeight" | "dimension" | "duration" | "shadow" | "typography" | "cubicBezier" | "custom-viewportRange";
|
|
11
|
+
$description?: string | undefined;
|
|
12
|
+
$deprecated?: string | boolean | undefined;
|
|
13
|
+
}, {
|
|
14
|
+
$value: string;
|
|
15
|
+
$type: "string" | "number" | "border" | "color" | "fontFamily" | "fontWeight" | "dimension" | "duration" | "shadow" | "typography" | "cubicBezier" | "custom-viewportRange";
|
|
16
|
+
$description?: string | undefined;
|
|
17
|
+
$deprecated?: string | boolean | undefined;
|
|
18
|
+
}>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { baseToken } from './baseToken.js';
|
|
3
|
+
import { referenceValue } from './referenceValue.js';
|
|
4
|
+
import { tokenType } from './tokenType.js';
|
|
5
|
+
export const stringToken = baseToken
|
|
6
|
+
.extend({
|
|
7
|
+
$value: z.union([z.string(), referenceValue]),
|
|
8
|
+
$type: tokenType('string'),
|
|
9
|
+
})
|
|
10
|
+
.strict();
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { schemaErrorMessage } from '../utilities/index.js';
|
|
3
|
+
export const tokenName = z.string().refine(name => /(^[a-z0-9][A-Za-z0-9-]*$|^@$)/.test(name), name => ({
|
|
4
|
+
message: schemaErrorMessage(`Invalid token name: "${name}"`, 'Token name must be kebab-case or camelCase, and start with a lowercase letter or number and consist only of letters, numbers, and hyphens.'),
|
|
5
|
+
}));
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { TokenType } from './validTokenType.js';
|
|
3
|
+
export declare const tokenType: ($type: TokenType) => z.ZodLiteral<"string" | "number" | "border" | "color" | "fontFamily" | "fontWeight" | "dimension" | "duration" | "shadow" | "typography" | "cubicBezier" | "custom-viewportRange">;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const typographyValue: z.ZodObject<{
|
|
3
|
+
fontSize: z.ZodUnion<[z.ZodUnion<[z.ZodEffects<z.ZodString, string, string>, z.ZodLiteral<"0">, z.ZodLiteral<0>]>, z.ZodEffects<z.ZodString, string, string>]>;
|
|
4
|
+
lineHeight: z.ZodOptional<z.ZodUnion<[z.ZodUnion<[z.ZodEffects<z.ZodString, string, string>, z.ZodLiteral<"0">, z.ZodLiteral<0>]>, z.ZodEffects<z.ZodString, string, string>]>>;
|
|
5
|
+
fontWeight: z.ZodUnion<[z.ZodEffects<z.ZodNumber, number, number>, z.ZodEffects<z.ZodString, string, string>]>;
|
|
6
|
+
fontFamily: z.ZodUnion<[z.ZodString, z.ZodEffects<z.ZodString, string, string>]>;
|
|
7
|
+
}, "strip", z.ZodTypeAny, {
|
|
8
|
+
fontFamily: string;
|
|
9
|
+
fontSize: string | 0;
|
|
10
|
+
fontWeight: string | number;
|
|
11
|
+
lineHeight?: string | 0 | undefined;
|
|
12
|
+
}, {
|
|
13
|
+
fontFamily: string;
|
|
14
|
+
fontSize: string | 0;
|
|
15
|
+
fontWeight: string | number;
|
|
16
|
+
lineHeight?: string | 0 | undefined;
|
|
17
|
+
}>;
|
|
18
|
+
export declare const typographyToken: z.ZodObject<z.objectUtil.extendShape<{
|
|
19
|
+
$description: z.ZodOptional<z.ZodString>;
|
|
20
|
+
$deprecated: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodBoolean]>>;
|
|
21
|
+
}, {
|
|
22
|
+
$value: z.ZodUnion<[z.ZodObject<{
|
|
23
|
+
fontSize: z.ZodUnion<[z.ZodUnion<[z.ZodEffects<z.ZodString, string, string>, z.ZodLiteral<"0">, z.ZodLiteral<0>]>, z.ZodEffects<z.ZodString, string, string>]>;
|
|
24
|
+
lineHeight: z.ZodOptional<z.ZodUnion<[z.ZodUnion<[z.ZodEffects<z.ZodString, string, string>, z.ZodLiteral<"0">, z.ZodLiteral<0>]>, z.ZodEffects<z.ZodString, string, string>]>>;
|
|
25
|
+
fontWeight: z.ZodUnion<[z.ZodEffects<z.ZodNumber, number, number>, z.ZodEffects<z.ZodString, string, string>]>;
|
|
26
|
+
fontFamily: z.ZodUnion<[z.ZodString, z.ZodEffects<z.ZodString, string, string>]>;
|
|
27
|
+
}, "strip", z.ZodTypeAny, {
|
|
28
|
+
fontFamily: string;
|
|
29
|
+
fontSize: string | 0;
|
|
30
|
+
fontWeight: string | number;
|
|
31
|
+
lineHeight?: string | 0 | undefined;
|
|
32
|
+
}, {
|
|
33
|
+
fontFamily: string;
|
|
34
|
+
fontSize: string | 0;
|
|
35
|
+
fontWeight: string | number;
|
|
36
|
+
lineHeight?: string | 0 | undefined;
|
|
37
|
+
}>, z.ZodEffects<z.ZodString, string, string>]>;
|
|
38
|
+
$type: z.ZodLiteral<"string" | "number" | "border" | "color" | "fontFamily" | "fontWeight" | "dimension" | "duration" | "shadow" | "typography" | "cubicBezier" | "custom-viewportRange">;
|
|
39
|
+
}>, "strict", z.ZodTypeAny, {
|
|
40
|
+
$value: string | {
|
|
41
|
+
fontFamily: string;
|
|
42
|
+
fontSize: string | 0;
|
|
43
|
+
fontWeight: string | number;
|
|
44
|
+
lineHeight?: string | 0 | undefined;
|
|
45
|
+
};
|
|
46
|
+
$type: "string" | "number" | "border" | "color" | "fontFamily" | "fontWeight" | "dimension" | "duration" | "shadow" | "typography" | "cubicBezier" | "custom-viewportRange";
|
|
47
|
+
$description?: string | undefined;
|
|
48
|
+
$deprecated?: string | boolean | undefined;
|
|
49
|
+
}, {
|
|
50
|
+
$value: string | {
|
|
51
|
+
fontFamily: string;
|
|
52
|
+
fontSize: string | 0;
|
|
53
|
+
fontWeight: string | number;
|
|
54
|
+
lineHeight?: string | 0 | undefined;
|
|
55
|
+
};
|
|
56
|
+
$type: "string" | "number" | "border" | "color" | "fontFamily" | "fontWeight" | "dimension" | "duration" | "shadow" | "typography" | "cubicBezier" | "custom-viewportRange";
|
|
57
|
+
$description?: string | undefined;
|
|
58
|
+
$deprecated?: string | boolean | undefined;
|
|
59
|
+
}>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { referenceValue } from './referenceValue.js';
|
|
3
|
+
import { dimensionValue } from './dimensionValue.js';
|
|
4
|
+
import { baseToken } from './baseToken.js';
|
|
5
|
+
import { fontWeightValue } from './fontWeightValue.js';
|
|
6
|
+
import { tokenType } from './tokenType.js';
|
|
7
|
+
export const typographyValue = z.object({
|
|
8
|
+
fontSize: z.union([dimensionValue, referenceValue]),
|
|
9
|
+
lineHeight: z.union([dimensionValue, referenceValue]).optional(),
|
|
10
|
+
fontWeight: z.union([fontWeightValue, referenceValue]),
|
|
11
|
+
fontFamily: z.union([z.string().min(1), referenceValue]),
|
|
12
|
+
});
|
|
13
|
+
export const typographyToken = baseToken
|
|
14
|
+
.extend({
|
|
15
|
+
$value: z.union([typographyValue, referenceValue]),
|
|
16
|
+
$type: tokenType('typography'),
|
|
17
|
+
})
|
|
18
|
+
.strict();
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
declare const validTypes: readonly ["color", "cubicBezier", "typography", "dimension", "duration", "border", "shadow", "fontFamily", "fontWeight", "number", "string", "custom-viewportRange"];
|
|
3
|
+
export type TokenType = (typeof validTypes)[number];
|
|
4
|
+
export declare const validateType: z.ZodRecord<z.ZodString, z.ZodLazy<z.ZodTypeAny>>;
|
|
5
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { joinFriendly, schemaErrorMessage } from '../utilities/index.js';
|
|
3
|
+
const validTypes = [
|
|
4
|
+
'color',
|
|
5
|
+
'cubicBezier',
|
|
6
|
+
'typography',
|
|
7
|
+
'dimension',
|
|
8
|
+
'duration',
|
|
9
|
+
'border',
|
|
10
|
+
'shadow',
|
|
11
|
+
'fontFamily',
|
|
12
|
+
'fontWeight',
|
|
13
|
+
'number',
|
|
14
|
+
'string',
|
|
15
|
+
'custom-viewportRange',
|
|
16
|
+
];
|
|
17
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
18
|
+
// @ts-ignore: TODO: fix this
|
|
19
|
+
export const validateType = z.record(z.string(), z.lazy(() => {
|
|
20
|
+
return z.union([
|
|
21
|
+
z
|
|
22
|
+
.object({
|
|
23
|
+
$value: z.any(),
|
|
24
|
+
$type: z.string().refine(type => validTypes.includes(type), val => ({
|
|
25
|
+
message: schemaErrorMessage(`Invalid token $type: "${val}"`, `Must be one of the following: ${joinFriendly([...validTypes], 'or')}`),
|
|
26
|
+
})),
|
|
27
|
+
})
|
|
28
|
+
.required(),
|
|
29
|
+
validateType,
|
|
30
|
+
]);
|
|
31
|
+
}));
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const viewportRangeToken: z.ZodObject<z.objectUtil.extendShape<{
|
|
3
|
+
$description: z.ZodOptional<z.ZodString>;
|
|
4
|
+
$deprecated: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodBoolean]>>;
|
|
5
|
+
}, {
|
|
6
|
+
$value: z.ZodUnion<[z.ZodString, z.ZodEffects<z.ZodString, string, string>]>;
|
|
7
|
+
$type: z.ZodLiteral<"string" | "number" | "border" | "color" | "fontFamily" | "fontWeight" | "dimension" | "duration" | "shadow" | "typography" | "cubicBezier" | "custom-viewportRange">;
|
|
8
|
+
}>, "strict", z.ZodTypeAny, {
|
|
9
|
+
$value: string;
|
|
10
|
+
$type: "string" | "number" | "border" | "color" | "fontFamily" | "fontWeight" | "dimension" | "duration" | "shadow" | "typography" | "cubicBezier" | "custom-viewportRange";
|
|
11
|
+
$description?: string | undefined;
|
|
12
|
+
$deprecated?: string | boolean | undefined;
|
|
13
|
+
}, {
|
|
14
|
+
$value: string;
|
|
15
|
+
$type: "string" | "number" | "border" | "color" | "fontFamily" | "fontWeight" | "dimension" | "duration" | "shadow" | "typography" | "cubicBezier" | "custom-viewportRange";
|
|
16
|
+
$description?: string | undefined;
|
|
17
|
+
$deprecated?: string | boolean | undefined;
|
|
18
|
+
}>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { baseToken } from './baseToken.js';
|
|
3
|
+
import { referenceValue } from './referenceValue.js';
|
|
4
|
+
import { tokenType } from './tokenType.js';
|
|
5
|
+
export const viewportRangeToken = baseToken
|
|
6
|
+
.extend({
|
|
7
|
+
$value: z.union([z.string(), referenceValue]),
|
|
8
|
+
$type: tokenType('custom-viewportRange'),
|
|
9
|
+
})
|
|
10
|
+
.strict();
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Transform } from 'style-dictionary/types';
|
|
2
|
+
/**
|
|
3
|
+
* @description converts w3c border tokens in css border string
|
|
4
|
+
* @type valueTransformer — [StyleDictionary.ValueTransform](https://github.com/amzn/style-dictionary/blob/main/types/Transform.d.ts)
|
|
5
|
+
* @matcher matches all tokens of $type `border`
|
|
6
|
+
* @transformer returns css border `string`
|
|
7
|
+
*/
|
|
8
|
+
export declare const borderToCss: Transform;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { isBorder } from '../filters/isBorder.js';
|
|
2
|
+
/**
|
|
3
|
+
* checks if all required properties exist on shadow token
|
|
4
|
+
* @param object - BorderTokenValue
|
|
5
|
+
* @returns void or throws error
|
|
6
|
+
*/
|
|
7
|
+
const checkForBorderTokenProperties = (border) => {
|
|
8
|
+
if ('color' in border && 'width' in border && 'style' in border) {
|
|
9
|
+
return true;
|
|
10
|
+
}
|
|
11
|
+
return false;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* @description converts w3c border tokens in css border string
|
|
15
|
+
* @type valueTransformer — [StyleDictionary.ValueTransform](https://github.com/amzn/style-dictionary/blob/main/types/Transform.d.ts)
|
|
16
|
+
* @matcher matches all tokens of $type `border`
|
|
17
|
+
* @transformer returns css border `string`
|
|
18
|
+
*/
|
|
19
|
+
export const borderToCss = {
|
|
20
|
+
name: 'border/css',
|
|
21
|
+
type: 'value',
|
|
22
|
+
transitive: true,
|
|
23
|
+
filter: isBorder,
|
|
24
|
+
transform: (token) => {
|
|
25
|
+
var _a;
|
|
26
|
+
const value = (_a = token.$value) !== null && _a !== void 0 ? _a : token.value;
|
|
27
|
+
// if value === string it was probably already transformed
|
|
28
|
+
if (typeof value === 'string') {
|
|
29
|
+
return value;
|
|
30
|
+
}
|
|
31
|
+
//
|
|
32
|
+
if (!checkForBorderTokenProperties(value)) {
|
|
33
|
+
throw new Error(`Invalid border token property ${JSON.stringify(value)}. Must be an object with color, width and style properties.`);
|
|
34
|
+
}
|
|
35
|
+
/* color | style | width */
|
|
36
|
+
return `${value.color} ${value.style} ${value.width}`;
|
|
37
|
+
},
|
|
38
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Transform } from 'style-dictionary/types';
|
|
2
|
+
/**
|
|
3
|
+
* @description converts color tokens value to `hex6` or `hex8`
|
|
4
|
+
* @type value transformer — [StyleDictionary.ValueTransform](https://github.com/amzn/style-dictionary/blob/main/types/Transform.d.ts)
|
|
5
|
+
* @matcher matches all tokens of $type `color`
|
|
6
|
+
* @transformer returns a `hex` string
|
|
7
|
+
*/
|
|
8
|
+
export declare const colorToHex: Transform;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { toHex } from 'color2k';
|
|
2
|
+
import { isColor } from '../filters/index.js';
|
|
3
|
+
import { getTokenValue } from './utilities/getTokenValue.js';
|
|
4
|
+
import { alpha } from './utilities/alpha.js';
|
|
5
|
+
/**
|
|
6
|
+
* @description converts color tokens value to `hex6` or `hex8`
|
|
7
|
+
* @type value transformer — [StyleDictionary.ValueTransform](https://github.com/amzn/style-dictionary/blob/main/types/Transform.d.ts)
|
|
8
|
+
* @matcher matches all tokens of $type `color`
|
|
9
|
+
* @transformer returns a `hex` string
|
|
10
|
+
*/
|
|
11
|
+
export const colorToHex = {
|
|
12
|
+
name: 'color/hex',
|
|
13
|
+
type: 'value',
|
|
14
|
+
transitive: true,
|
|
15
|
+
filter: isColor,
|
|
16
|
+
transform: (token) => {
|
|
17
|
+
var _a, _b;
|
|
18
|
+
const alphaValue = (_a = token.alpha) !== null && _a !== void 0 ? _a : (_b = token.$extensions) === null || _b === void 0 ? void 0 : _b.alpha;
|
|
19
|
+
if (alphaValue === null || alphaValue === undefined) {
|
|
20
|
+
return toHex(getTokenValue(token));
|
|
21
|
+
}
|
|
22
|
+
return toHex(alpha(getTokenValue(token), alphaValue, token));
|
|
23
|
+
},
|
|
24
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Transform } from 'style-dictionary/types';
|
|
2
|
+
/**
|
|
3
|
+
* @description replaces tokens value with `hex8` color using the tokens `alpha` property to specify the value used for alpha
|
|
4
|
+
* @type value transformer — [StyleDictionary.ValueTransform](https://github.com/amzn/style-dictionary/blob/main/types/Transform.d.ts)
|
|
5
|
+
* @matcher matches all tokens of $type `color` with an `alpha` property
|
|
6
|
+
* @transformer returns `hex8` string
|
|
7
|
+
*/
|
|
8
|
+
export declare const colorToHexMix: Transform;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { toHex } from 'color2k';
|
|
2
|
+
import { isColorWithMix } from '../filters/index.js';
|
|
3
|
+
import { getTokenValue } from './utilities/getTokenValue.js';
|
|
4
|
+
import mix from './utilities/mix.js';
|
|
5
|
+
/**
|
|
6
|
+
* @description replaces tokens value with `hex8` color using the tokens `alpha` property to specify the value used for alpha
|
|
7
|
+
* @type value transformer — [StyleDictionary.ValueTransform](https://github.com/amzn/style-dictionary/blob/main/types/Transform.d.ts)
|
|
8
|
+
* @matcher matches all tokens of $type `color` with an `alpha` property
|
|
9
|
+
* @transformer returns `hex8` string
|
|
10
|
+
*/
|
|
11
|
+
export const colorToHexMix = {
|
|
12
|
+
name: 'color/hexMix',
|
|
13
|
+
type: 'value',
|
|
14
|
+
transitive: true,
|
|
15
|
+
filter: isColorWithMix,
|
|
16
|
+
transform: (token) => {
|
|
17
|
+
var _a, _b;
|
|
18
|
+
return toHex(mix(getTokenValue(token), ((_a = token.mix) === null || _a === void 0 ? void 0 : _a.color) || getTokenValue(token), ((_b = token.mix) === null || _b === void 0 ? void 0 : _b.weight) || 0));
|
|
19
|
+
},
|
|
20
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Transform } from 'style-dictionary/types';
|
|
2
|
+
/**
|
|
3
|
+
* @description replaces tokens value with `rgba` color using the tokens `alpha` property to specify the value used for alpha
|
|
4
|
+
* @type value transformer — [StyleDictionary.ValueTransform](https://github.com/amzn/style-dictionary/blob/main/types/Transform.d.ts)
|
|
5
|
+
* @matcher matches all tokens of $type `color` with an `alpha` property
|
|
6
|
+
* @transformer returns `rgba` string
|
|
7
|
+
*/
|
|
8
|
+
export declare const colorToRgbAlpha: Transform;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { isColorWithAlpha } from '../filters/index.js';
|
|
2
|
+
import { alpha } from './utilities/alpha.js';
|
|
3
|
+
import { getTokenValue } from './utilities/getTokenValue.js';
|
|
4
|
+
/**
|
|
5
|
+
* @description replaces tokens value with `rgba` color using the tokens `alpha` property to specify the value used for alpha
|
|
6
|
+
* @type value transformer — [StyleDictionary.ValueTransform](https://github.com/amzn/style-dictionary/blob/main/types/Transform.d.ts)
|
|
7
|
+
* @matcher matches all tokens of $type `color` with an `alpha` property
|
|
8
|
+
* @transformer returns `rgba` string
|
|
9
|
+
*/
|
|
10
|
+
export const colorToRgbAlpha = {
|
|
11
|
+
name: 'color/rgbAlpha',
|
|
12
|
+
type: 'value',
|
|
13
|
+
transitive: true,
|
|
14
|
+
filter: isColorWithAlpha,
|
|
15
|
+
transform: (token) => {
|
|
16
|
+
if (token.alpha === null)
|
|
17
|
+
return getTokenValue(token);
|
|
18
|
+
return alpha(getTokenValue(token), token.alpha, token);
|
|
19
|
+
},
|
|
20
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Transform } from 'style-dictionary/types';
|
|
2
|
+
/**
|
|
3
|
+
* @description converts color tokens rgba float with values from 0 - 1
|
|
4
|
+
* @type value transformer — [StyleDictionary.ValueTransform](https://github.com/amzn/style-dictionary/blob/main/types/Transform.d.ts)
|
|
5
|
+
* @matcher matches all tokens of $type `color`
|
|
6
|
+
* @transformer returns a `rgb` float object
|
|
7
|
+
*/
|
|
8
|
+
export declare const colorToRgbaFloat: Transform;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { toHex } from 'color2k';
|
|
2
|
+
import { isColor } from '../filters/index.js';
|
|
3
|
+
import { getTokenValue } from './utilities/getTokenValue.js';
|
|
4
|
+
import { rgbaFloatToHex } from './utilities/rgbaFloatToHex.js';
|
|
5
|
+
import mix from './utilities/mix.js';
|
|
6
|
+
import { hexToRgbaFloat } from './utilities/hexToRgbaFloat.js';
|
|
7
|
+
import { isRgbaFloat } from './utilities/isRgbaFloat.js';
|
|
8
|
+
const toRgbaFloat = (token, alpha = undefined) => {
|
|
9
|
+
var _a;
|
|
10
|
+
let tokenValue = getTokenValue(token);
|
|
11
|
+
let tokenMixColor = (_a = token.mix) === null || _a === void 0 ? void 0 : _a.color;
|
|
12
|
+
// get hex value from color string
|
|
13
|
+
if (isRgbaFloat(tokenValue)) {
|
|
14
|
+
tokenValue = rgbaFloatToHex(tokenValue, false);
|
|
15
|
+
}
|
|
16
|
+
if (tokenMixColor && isRgbaFloat(tokenMixColor)) {
|
|
17
|
+
tokenMixColor = rgbaFloatToHex(tokenMixColor, false);
|
|
18
|
+
}
|
|
19
|
+
let hex = toHex(tokenValue);
|
|
20
|
+
// mix color with mix color and weight
|
|
21
|
+
if (token.mix && token.mix.color && token.mix.weight) {
|
|
22
|
+
hex = toHex(mix(tokenValue, tokenMixColor, token.mix.weight));
|
|
23
|
+
}
|
|
24
|
+
// return color as RgbaFloat
|
|
25
|
+
return hexToRgbaFloat(hex, alpha);
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* @description converts color tokens rgba float with values from 0 - 1
|
|
29
|
+
* @type value transformer — [StyleDictionary.ValueTransform](https://github.com/amzn/style-dictionary/blob/main/types/Transform.d.ts)
|
|
30
|
+
* @matcher matches all tokens of $type `color`
|
|
31
|
+
* @transformer returns a `rgb` float object
|
|
32
|
+
*/
|
|
33
|
+
export const colorToRgbaFloat = {
|
|
34
|
+
name: 'color/rgbaFloat',
|
|
35
|
+
type: 'value',
|
|
36
|
+
transitive: true,
|
|
37
|
+
filter: isColor,
|
|
38
|
+
transform: (token) => {
|
|
39
|
+
const value = getTokenValue(token);
|
|
40
|
+
// skip if value is already rgb float
|
|
41
|
+
if (isRgbaFloat(value) && !('mix' in token) && !('alpha' in token))
|
|
42
|
+
return value;
|
|
43
|
+
// convert hex or rgb values to rgba float
|
|
44
|
+
return toRgbaFloat(token, token.alpha);
|
|
45
|
+
},
|
|
46
|
+
};
|