@primer/primitives 10.0.0-rc.fd912e08 → 10.1.0-rc.5ced3fe0
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/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 +10 -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 +100 -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 +39 -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 +63 -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 +30 -0
- package/dist/build/platforms/json.d.ts +2 -0
- package/dist/build/platforms/json.js +32 -0
- package/dist/build/platforms/styleLint.d.ts +2 -0
- package/dist/build/platforms/styleLint.js +34 -0
- package/dist/build/platforms/typeDefinitions.d.ts +2 -0
- package/dist/build/platforms/typeDefinitions.js +30 -0
- package/dist/build/platforms/typescript.d.ts +2 -0
- package/dist/build/platforms/typescript.js +30 -0
- package/dist/build/preprocessor/themeOverrides.d.ts +2 -0
- package/dist/build/preprocessor/themeOverrides.js +22 -0
- package/dist/build/preprocessor/utilities/transformTokens.d.ts +8 -0
- package/dist/build/preprocessor/utilities/transformTokens.js +22 -0
- package/dist/build/primerStyleDictionary.d.ts +8 -0
- package/dist/build/primerStyleDictionary.js +82 -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 +167 -0
- package/dist/build/schemas/colorToken.js +76 -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 +25 -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 +16 -0
- package/dist/build/types/tokenBuildInput.d.ts +10 -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/lowerCaseFirstCharacter.d.ts +8 -0
- package/dist/build/utilities/lowerCaseFirstCharacter.js +10 -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 +15 -23
- 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 +30 -36
- 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,9 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { schemaErrorMessage } from '../utilities/index.js';
|
|
3
|
+
const colorHex3RegEx = '^#[0-9a-f]{3}$';
|
|
4
|
+
const colorHex6RegEx = '^#[0-9a-f]{6}$';
|
|
5
|
+
const colorHex8RegEx = '^#[0-9a-f]{8}$';
|
|
6
|
+
const colorHexRegex = new RegExp(`(${colorHex3RegEx})|(${colorHex6RegEx})|(${colorHex8RegEx})`, 'i');
|
|
7
|
+
export const colorHexValue = z.string().refine(color => colorHexRegex.test(color), color => ({
|
|
8
|
+
message: schemaErrorMessage(`Invalid color: "${color}"`, 'Color must be a hex string or a reference to a color token.'),
|
|
9
|
+
}));
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const colorToken: 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.ZodEffects<z.ZodString, string, string>, z.ZodEffects<z.ZodString, string, string>]>;
|
|
7
|
+
$type: z.ZodLiteral<"string" | "number" | "border" | "color" | "fontFamily" | "fontWeight" | "dimension" | "duration" | "shadow" | "typography" | "cubicBezier" | "custom-viewportRange">;
|
|
8
|
+
alpha: z.ZodNullable<z.ZodOptional<z.ZodEffects<z.ZodAny, any, any>>>;
|
|
9
|
+
mix: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
10
|
+
color: z.ZodString;
|
|
11
|
+
weight: z.ZodNumber;
|
|
12
|
+
}, "strip", z.ZodTypeAny, {
|
|
13
|
+
color: string;
|
|
14
|
+
weight: number;
|
|
15
|
+
}, {
|
|
16
|
+
color: string;
|
|
17
|
+
weight: number;
|
|
18
|
+
}>>>;
|
|
19
|
+
$extensions: z.ZodOptional<z.ZodObject<{
|
|
20
|
+
alpha: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
|
|
21
|
+
'org.primer.figma': z.ZodOptional<z.ZodObject<{
|
|
22
|
+
collection: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
23
|
+
modeOverride: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
24
|
+
scopes: z.ZodOptional<z.ZodEffects<z.ZodArray<z.ZodString, "many">, string[], string[]>>;
|
|
25
|
+
group: z.ZodOptional<z.ZodString>;
|
|
26
|
+
}, "strip", z.ZodTypeAny, {
|
|
27
|
+
group?: string | undefined;
|
|
28
|
+
collection?: string | undefined;
|
|
29
|
+
modeOverride?: string | undefined;
|
|
30
|
+
scopes?: string[] | undefined;
|
|
31
|
+
}, {
|
|
32
|
+
group?: string | undefined;
|
|
33
|
+
collection?: string | undefined;
|
|
34
|
+
modeOverride?: string | undefined;
|
|
35
|
+
scopes?: string[] | undefined;
|
|
36
|
+
}>>;
|
|
37
|
+
'org.primer.overrides': z.ZodOptional<z.ZodObject<{
|
|
38
|
+
light: z.ZodOptional<z.ZodUnion<[z.ZodEffects<z.ZodString, string, string>, z.ZodEffects<z.ZodString, string, string>]>>;
|
|
39
|
+
'light-tritanopia': z.ZodOptional<z.ZodUnion<[z.ZodEffects<z.ZodString, string, string>, z.ZodEffects<z.ZodString, string, string>]>>;
|
|
40
|
+
'light-deutranopia-protanopia': z.ZodOptional<z.ZodUnion<[z.ZodEffects<z.ZodString, string, string>, z.ZodEffects<z.ZodString, string, string>]>>;
|
|
41
|
+
'light-high-contrast': z.ZodOptional<z.ZodUnion<[z.ZodEffects<z.ZodString, string, string>, z.ZodEffects<z.ZodString, string, string>]>>;
|
|
42
|
+
dark: z.ZodOptional<z.ZodUnion<[z.ZodEffects<z.ZodString, string, string>, z.ZodEffects<z.ZodString, string, string>]>>;
|
|
43
|
+
'dark-tritanopia': z.ZodOptional<z.ZodUnion<[z.ZodEffects<z.ZodString, string, string>, z.ZodEffects<z.ZodString, string, string>]>>;
|
|
44
|
+
'dark-deutranopia-protanopia': z.ZodOptional<z.ZodUnion<[z.ZodEffects<z.ZodString, string, string>, z.ZodEffects<z.ZodString, string, string>]>>;
|
|
45
|
+
'dark-high-contrast': z.ZodOptional<z.ZodUnion<[z.ZodEffects<z.ZodString, string, string>, z.ZodEffects<z.ZodString, string, string>]>>;
|
|
46
|
+
'dark-dimmed': z.ZodOptional<z.ZodUnion<[z.ZodEffects<z.ZodString, string, string>, z.ZodEffects<z.ZodString, string, string>]>>;
|
|
47
|
+
}, "strict", z.ZodTypeAny, {
|
|
48
|
+
light?: string | undefined;
|
|
49
|
+
dark?: string | undefined;
|
|
50
|
+
'light-tritanopia'?: string | undefined;
|
|
51
|
+
'light-deutranopia-protanopia'?: string | undefined;
|
|
52
|
+
'light-high-contrast'?: string | undefined;
|
|
53
|
+
'dark-tritanopia'?: string | undefined;
|
|
54
|
+
'dark-deutranopia-protanopia'?: string | undefined;
|
|
55
|
+
'dark-high-contrast'?: string | undefined;
|
|
56
|
+
'dark-dimmed'?: string | undefined;
|
|
57
|
+
}, {
|
|
58
|
+
light?: string | undefined;
|
|
59
|
+
dark?: string | undefined;
|
|
60
|
+
'light-tritanopia'?: string | undefined;
|
|
61
|
+
'light-deutranopia-protanopia'?: string | undefined;
|
|
62
|
+
'light-high-contrast'?: string | undefined;
|
|
63
|
+
'dark-tritanopia'?: string | undefined;
|
|
64
|
+
'dark-deutranopia-protanopia'?: string | undefined;
|
|
65
|
+
'dark-high-contrast'?: string | undefined;
|
|
66
|
+
'dark-dimmed'?: string | undefined;
|
|
67
|
+
}>>;
|
|
68
|
+
}, "strip", z.ZodTypeAny, {
|
|
69
|
+
alpha?: number | null | undefined;
|
|
70
|
+
'org.primer.figma'?: {
|
|
71
|
+
group?: string | undefined;
|
|
72
|
+
collection?: string | undefined;
|
|
73
|
+
modeOverride?: string | undefined;
|
|
74
|
+
scopes?: string[] | undefined;
|
|
75
|
+
} | undefined;
|
|
76
|
+
'org.primer.overrides'?: {
|
|
77
|
+
light?: string | undefined;
|
|
78
|
+
dark?: string | undefined;
|
|
79
|
+
'light-tritanopia'?: string | undefined;
|
|
80
|
+
'light-deutranopia-protanopia'?: string | undefined;
|
|
81
|
+
'light-high-contrast'?: string | undefined;
|
|
82
|
+
'dark-tritanopia'?: string | undefined;
|
|
83
|
+
'dark-deutranopia-protanopia'?: string | undefined;
|
|
84
|
+
'dark-high-contrast'?: string | undefined;
|
|
85
|
+
'dark-dimmed'?: string | undefined;
|
|
86
|
+
} | undefined;
|
|
87
|
+
}, {
|
|
88
|
+
alpha?: number | null | undefined;
|
|
89
|
+
'org.primer.figma'?: {
|
|
90
|
+
group?: string | undefined;
|
|
91
|
+
collection?: string | undefined;
|
|
92
|
+
modeOverride?: string | undefined;
|
|
93
|
+
scopes?: string[] | undefined;
|
|
94
|
+
} | undefined;
|
|
95
|
+
'org.primer.overrides'?: {
|
|
96
|
+
light?: string | undefined;
|
|
97
|
+
dark?: string | undefined;
|
|
98
|
+
'light-tritanopia'?: string | undefined;
|
|
99
|
+
'light-deutranopia-protanopia'?: string | undefined;
|
|
100
|
+
'light-high-contrast'?: string | undefined;
|
|
101
|
+
'dark-tritanopia'?: string | undefined;
|
|
102
|
+
'dark-deutranopia-protanopia'?: string | undefined;
|
|
103
|
+
'dark-high-contrast'?: string | undefined;
|
|
104
|
+
'dark-dimmed'?: string | undefined;
|
|
105
|
+
} | undefined;
|
|
106
|
+
}>>;
|
|
107
|
+
}>, "strict", z.ZodTypeAny, {
|
|
108
|
+
$value: string;
|
|
109
|
+
$type: "string" | "number" | "border" | "color" | "fontFamily" | "fontWeight" | "dimension" | "duration" | "shadow" | "typography" | "cubicBezier" | "custom-viewportRange";
|
|
110
|
+
alpha?: any;
|
|
111
|
+
$description?: string | undefined;
|
|
112
|
+
mix?: {
|
|
113
|
+
color: string;
|
|
114
|
+
weight: number;
|
|
115
|
+
} | null | undefined;
|
|
116
|
+
$deprecated?: string | boolean | undefined;
|
|
117
|
+
$extensions?: {
|
|
118
|
+
alpha?: number | null | undefined;
|
|
119
|
+
'org.primer.figma'?: {
|
|
120
|
+
group?: string | undefined;
|
|
121
|
+
collection?: string | undefined;
|
|
122
|
+
modeOverride?: string | undefined;
|
|
123
|
+
scopes?: string[] | undefined;
|
|
124
|
+
} | undefined;
|
|
125
|
+
'org.primer.overrides'?: {
|
|
126
|
+
light?: string | undefined;
|
|
127
|
+
dark?: string | undefined;
|
|
128
|
+
'light-tritanopia'?: string | undefined;
|
|
129
|
+
'light-deutranopia-protanopia'?: string | undefined;
|
|
130
|
+
'light-high-contrast'?: string | undefined;
|
|
131
|
+
'dark-tritanopia'?: string | undefined;
|
|
132
|
+
'dark-deutranopia-protanopia'?: string | undefined;
|
|
133
|
+
'dark-high-contrast'?: string | undefined;
|
|
134
|
+
'dark-dimmed'?: string | undefined;
|
|
135
|
+
} | undefined;
|
|
136
|
+
} | undefined;
|
|
137
|
+
}, {
|
|
138
|
+
$value: string;
|
|
139
|
+
$type: "string" | "number" | "border" | "color" | "fontFamily" | "fontWeight" | "dimension" | "duration" | "shadow" | "typography" | "cubicBezier" | "custom-viewportRange";
|
|
140
|
+
alpha?: any;
|
|
141
|
+
$description?: string | undefined;
|
|
142
|
+
mix?: {
|
|
143
|
+
color: string;
|
|
144
|
+
weight: number;
|
|
145
|
+
} | null | undefined;
|
|
146
|
+
$deprecated?: string | boolean | undefined;
|
|
147
|
+
$extensions?: {
|
|
148
|
+
alpha?: number | null | undefined;
|
|
149
|
+
'org.primer.figma'?: {
|
|
150
|
+
group?: string | undefined;
|
|
151
|
+
collection?: string | undefined;
|
|
152
|
+
modeOverride?: string | undefined;
|
|
153
|
+
scopes?: string[] | undefined;
|
|
154
|
+
} | undefined;
|
|
155
|
+
'org.primer.overrides'?: {
|
|
156
|
+
light?: string | undefined;
|
|
157
|
+
dark?: string | undefined;
|
|
158
|
+
'light-tritanopia'?: string | undefined;
|
|
159
|
+
'light-deutranopia-protanopia'?: string | undefined;
|
|
160
|
+
'light-high-contrast'?: string | undefined;
|
|
161
|
+
'dark-tritanopia'?: string | undefined;
|
|
162
|
+
'dark-deutranopia-protanopia'?: string | undefined;
|
|
163
|
+
'dark-high-contrast'?: string | undefined;
|
|
164
|
+
'dark-dimmed'?: string | undefined;
|
|
165
|
+
} | undefined;
|
|
166
|
+
} | undefined;
|
|
167
|
+
}>;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { colorHexValue } from './colorHexValue.js';
|
|
3
|
+
import { referenceValue } from './referenceValue.js';
|
|
4
|
+
import { alphaValue } from './alphaValue.js';
|
|
5
|
+
import { baseToken } from './baseToken.js';
|
|
6
|
+
import { collection, mode } from './collections.js';
|
|
7
|
+
import { scopes } from './scopes.js';
|
|
8
|
+
import { tokenType } from './tokenType.js';
|
|
9
|
+
export const colorToken = baseToken
|
|
10
|
+
.extend({
|
|
11
|
+
$value: z.union([colorHexValue, referenceValue]),
|
|
12
|
+
$type: tokenType('color'),
|
|
13
|
+
alpha: alphaValue.optional().nullable(),
|
|
14
|
+
mix: z
|
|
15
|
+
.object({
|
|
16
|
+
color: z.string(),
|
|
17
|
+
weight: z.number().min(0).max(1),
|
|
18
|
+
})
|
|
19
|
+
.nullable()
|
|
20
|
+
.optional(),
|
|
21
|
+
$extensions: z
|
|
22
|
+
.object({
|
|
23
|
+
alpha: z.number().min(0).max(1).optional().nullable(),
|
|
24
|
+
'org.primer.figma': z
|
|
25
|
+
.object({
|
|
26
|
+
collection: collection([
|
|
27
|
+
'base/color/light',
|
|
28
|
+
'base/color/light-high-contrast',
|
|
29
|
+
'base/color/dark',
|
|
30
|
+
'base/color/dark-dimmed',
|
|
31
|
+
'base/color/dark-high-contrast',
|
|
32
|
+
'mode',
|
|
33
|
+
'pattern/mode',
|
|
34
|
+
]).optional(),
|
|
35
|
+
modeOverride: mode([
|
|
36
|
+
'light',
|
|
37
|
+
'dark',
|
|
38
|
+
'dark dimmed',
|
|
39
|
+
'light high contrast',
|
|
40
|
+
'dark high contrast',
|
|
41
|
+
'light colorblind',
|
|
42
|
+
'dark colorblind',
|
|
43
|
+
'light tritanopia',
|
|
44
|
+
'dark tritanopia',
|
|
45
|
+
]).optional(),
|
|
46
|
+
scopes: scopes(['all', 'bgColor', 'fgColor', 'borderColor', 'effectColor']).optional(),
|
|
47
|
+
group: z.string().optional(),
|
|
48
|
+
})
|
|
49
|
+
.optional(),
|
|
50
|
+
'org.primer.overrides': z
|
|
51
|
+
.object({
|
|
52
|
+
light: z.union([colorHexValue, referenceValue]).optional(),
|
|
53
|
+
'light-tritanopia': z.union([colorHexValue, referenceValue]).optional(),
|
|
54
|
+
'light-deutranopia-protanopia': z.union([colorHexValue, referenceValue]).optional(),
|
|
55
|
+
'light-high-contrast': z.union([colorHexValue, referenceValue]).optional(),
|
|
56
|
+
dark: z.union([colorHexValue, referenceValue]).optional(),
|
|
57
|
+
'dark-tritanopia': z.union([colorHexValue, referenceValue]).optional(),
|
|
58
|
+
'dark-deutranopia-protanopia': z.union([colorHexValue, referenceValue]).optional(),
|
|
59
|
+
'dark-high-contrast': z.union([colorHexValue, referenceValue]).optional(),
|
|
60
|
+
'dark-dimmed': z.union([colorHexValue, referenceValue]).optional(),
|
|
61
|
+
}, {
|
|
62
|
+
errorMap: e => {
|
|
63
|
+
if (e.code === 'unrecognized_keys') {
|
|
64
|
+
return {
|
|
65
|
+
message: `Unrecognized key: "${e.keys.join(', ')}", must be one of: light, light-tritanopia, light-deutranopia-protanopia, light-high-contrast, dark, dark-tritanopia, dark-deutranopia-protanopia, dark-high-contrast, dark-dimmed`,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
return { message: `Error: ${e.code}` };
|
|
69
|
+
},
|
|
70
|
+
})
|
|
71
|
+
.strict()
|
|
72
|
+
.optional(),
|
|
73
|
+
})
|
|
74
|
+
.optional(),
|
|
75
|
+
})
|
|
76
|
+
.strict();
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const cubicBezierToken: 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.ZodArray<z.ZodNumber, "many">, 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 | number[];
|
|
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 | number[];
|
|
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,8 @@
|
|
|
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 cubicBezierToken = baseToken.extend({
|
|
6
|
+
$value: z.union([z.array(z.number()).length(4), referenceValue]),
|
|
7
|
+
$type: tokenType('cubicBezier'),
|
|
8
|
+
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { tokenName } from './tokenName.js';
|
|
3
|
+
import { stringToken } from './stringToken.js';
|
|
4
|
+
import { viewportRangeToken } from './viewportRangeToken.js';
|
|
5
|
+
import { numberToken } from './numberToken.js';
|
|
6
|
+
import { fontWeightToken } from './fontWeightToken.js';
|
|
7
|
+
import { typographyToken } from './typographyToken.js';
|
|
8
|
+
import { borderToken } from './borderToken.js';
|
|
9
|
+
import { dimensionToken } from './dimensionToken.js';
|
|
10
|
+
import { colorToken } from './colorToken.js';
|
|
11
|
+
import { fontFamilyToken } from './fontFamilyToken.js';
|
|
12
|
+
import { shadowToken } from './shadowToken.js';
|
|
13
|
+
import { durationToken } from './durationToken.js';
|
|
14
|
+
import { cubicBezierToken } from './cubicBezierToken.js';
|
|
15
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
16
|
+
// @ts-ignore: TODO: fix this
|
|
17
|
+
export const designToken = z.record(tokenName, z.lazy(() => {
|
|
18
|
+
return z.union([
|
|
19
|
+
z.discriminatedUnion('$type', [
|
|
20
|
+
colorToken,
|
|
21
|
+
cubicBezierToken,
|
|
22
|
+
dimensionToken,
|
|
23
|
+
shadowToken,
|
|
24
|
+
borderToken,
|
|
25
|
+
fontFamilyToken,
|
|
26
|
+
fontWeightToken,
|
|
27
|
+
typographyToken,
|
|
28
|
+
viewportRangeToken,
|
|
29
|
+
numberToken,
|
|
30
|
+
durationToken,
|
|
31
|
+
stringToken,
|
|
32
|
+
]),
|
|
33
|
+
designToken,
|
|
34
|
+
]);
|
|
35
|
+
}));
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const dimensionToken: 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.ZodUnion<[z.ZodEffects<z.ZodString, string, string>, z.ZodLiteral<"0">, z.ZodLiteral<0>]>, z.ZodEffects<z.ZodString, string, string>]>;
|
|
7
|
+
$type: z.ZodLiteral<"string" | "number" | "border" | "color" | "fontFamily" | "fontWeight" | "dimension" | "duration" | "shadow" | "typography" | "cubicBezier" | "custom-viewportRange">;
|
|
8
|
+
$extensions: z.ZodOptional<z.ZodObject<{
|
|
9
|
+
'org.primer.figma': z.ZodObject<{
|
|
10
|
+
collection: z.ZodEffects<z.ZodString, string, string>;
|
|
11
|
+
scopes: z.ZodEffects<z.ZodArray<z.ZodString, "many">, string[], string[]>;
|
|
12
|
+
group: z.ZodOptional<z.ZodString>;
|
|
13
|
+
}, "strip", z.ZodTypeAny, {
|
|
14
|
+
collection: string;
|
|
15
|
+
scopes: string[];
|
|
16
|
+
group?: string | undefined;
|
|
17
|
+
}, {
|
|
18
|
+
collection: string;
|
|
19
|
+
scopes: string[];
|
|
20
|
+
group?: string | undefined;
|
|
21
|
+
}>;
|
|
22
|
+
}, "strip", z.ZodTypeAny, {
|
|
23
|
+
'org.primer.figma': {
|
|
24
|
+
collection: string;
|
|
25
|
+
scopes: string[];
|
|
26
|
+
group?: string | undefined;
|
|
27
|
+
};
|
|
28
|
+
}, {
|
|
29
|
+
'org.primer.figma': {
|
|
30
|
+
collection: string;
|
|
31
|
+
scopes: string[];
|
|
32
|
+
group?: string | undefined;
|
|
33
|
+
};
|
|
34
|
+
}>>;
|
|
35
|
+
}>, "strict", z.ZodTypeAny, {
|
|
36
|
+
$value: string | 0;
|
|
37
|
+
$type: "string" | "number" | "border" | "color" | "fontFamily" | "fontWeight" | "dimension" | "duration" | "shadow" | "typography" | "cubicBezier" | "custom-viewportRange";
|
|
38
|
+
$description?: string | undefined;
|
|
39
|
+
$deprecated?: string | boolean | undefined;
|
|
40
|
+
$extensions?: {
|
|
41
|
+
'org.primer.figma': {
|
|
42
|
+
collection: string;
|
|
43
|
+
scopes: string[];
|
|
44
|
+
group?: string | undefined;
|
|
45
|
+
};
|
|
46
|
+
} | undefined;
|
|
47
|
+
}, {
|
|
48
|
+
$value: string | 0;
|
|
49
|
+
$type: "string" | "number" | "border" | "color" | "fontFamily" | "fontWeight" | "dimension" | "duration" | "shadow" | "typography" | "cubicBezier" | "custom-viewportRange";
|
|
50
|
+
$description?: string | undefined;
|
|
51
|
+
$deprecated?: string | boolean | undefined;
|
|
52
|
+
$extensions?: {
|
|
53
|
+
'org.primer.figma': {
|
|
54
|
+
collection: string;
|
|
55
|
+
scopes: string[];
|
|
56
|
+
group?: string | undefined;
|
|
57
|
+
};
|
|
58
|
+
} | undefined;
|
|
59
|
+
}>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { baseToken } from './baseToken.js';
|
|
3
|
+
import { referenceValue } from './referenceValue.js';
|
|
4
|
+
import { collection } from './collections.js';
|
|
5
|
+
import { scopes } from './scopes.js';
|
|
6
|
+
import { dimensionValue } from './dimensionValue.js';
|
|
7
|
+
import { tokenType } from './tokenType.js';
|
|
8
|
+
export const dimensionToken = baseToken
|
|
9
|
+
.extend({
|
|
10
|
+
$value: z.union([dimensionValue, referenceValue]),
|
|
11
|
+
$type: tokenType('dimension'),
|
|
12
|
+
$extensions: z
|
|
13
|
+
.object({
|
|
14
|
+
'org.primer.figma': z.object({
|
|
15
|
+
collection: collection(['base/size', 'functional/size', 'pattern/size', 'typography']),
|
|
16
|
+
scopes: scopes([
|
|
17
|
+
'all',
|
|
18
|
+
'size',
|
|
19
|
+
'gap',
|
|
20
|
+
'radius',
|
|
21
|
+
'borderColor',
|
|
22
|
+
'effectFloat',
|
|
23
|
+
'fontSize',
|
|
24
|
+
'letterSpacing',
|
|
25
|
+
'lineHeight',
|
|
26
|
+
'paragraphSpacing',
|
|
27
|
+
'paragraphIndent',
|
|
28
|
+
]),
|
|
29
|
+
group: z.string().optional(),
|
|
30
|
+
}),
|
|
31
|
+
})
|
|
32
|
+
.optional(),
|
|
33
|
+
})
|
|
34
|
+
.strict();
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { schemaErrorMessage } from '../utilities/index.js';
|
|
3
|
+
export const dimensionValue = z.union([
|
|
4
|
+
z.string().refine(dim => /(^-?[0-9]+(px|rem)$|^-?[0-9]+\.?[0-9]*em$)/.test(dim), val => ({
|
|
5
|
+
message: schemaErrorMessage(`Invalid dimension: "${val}"`, `Dimension must be a string with a unit (px, rem or em) or 0`),
|
|
6
|
+
})),
|
|
7
|
+
z.literal('0'),
|
|
8
|
+
z.literal(0),
|
|
9
|
+
]);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const durationToken: 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.ZodEffects<z.ZodString, string, string>, 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,11 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { baseToken } from './baseToken.js';
|
|
3
|
+
import { referenceValue } from './referenceValue.js';
|
|
4
|
+
import { durationValue } from './durationValue.js';
|
|
5
|
+
import { tokenType } from './tokenType.js';
|
|
6
|
+
export const durationToken = baseToken
|
|
7
|
+
.extend({
|
|
8
|
+
$value: z.union([durationValue, referenceValue]),
|
|
9
|
+
$type: tokenType('duration'),
|
|
10
|
+
})
|
|
11
|
+
.strict();
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { schemaErrorMessage } from '../utilities/index.js';
|
|
3
|
+
export const durationValue = z.string().refine(duration => /(^[0-9]+ms$)/.test(duration), val => ({
|
|
4
|
+
message: schemaErrorMessage(`Invalid duration: "${val}"`, `A duration must be a string with an "ms"`),
|
|
5
|
+
}));
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const fontFamilyToken: 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
|
+
$extensions: z.ZodOptional<z.ZodObject<{
|
|
9
|
+
'org.primer.figma': z.ZodObject<{
|
|
10
|
+
collection: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
11
|
+
scopes: z.ZodOptional<z.ZodEffects<z.ZodArray<z.ZodString, "many">, string[], string[]>>;
|
|
12
|
+
}, "strip", z.ZodTypeAny, {
|
|
13
|
+
collection?: string | undefined;
|
|
14
|
+
scopes?: string[] | undefined;
|
|
15
|
+
}, {
|
|
16
|
+
collection?: string | undefined;
|
|
17
|
+
scopes?: string[] | undefined;
|
|
18
|
+
}>;
|
|
19
|
+
}, "strip", z.ZodTypeAny, {
|
|
20
|
+
'org.primer.figma': {
|
|
21
|
+
collection?: string | undefined;
|
|
22
|
+
scopes?: string[] | undefined;
|
|
23
|
+
};
|
|
24
|
+
}, {
|
|
25
|
+
'org.primer.figma': {
|
|
26
|
+
collection?: string | undefined;
|
|
27
|
+
scopes?: string[] | undefined;
|
|
28
|
+
};
|
|
29
|
+
}>>;
|
|
30
|
+
}>, "strict", z.ZodTypeAny, {
|
|
31
|
+
$value: string;
|
|
32
|
+
$type: "string" | "number" | "border" | "color" | "fontFamily" | "fontWeight" | "dimension" | "duration" | "shadow" | "typography" | "cubicBezier" | "custom-viewportRange";
|
|
33
|
+
$description?: string | undefined;
|
|
34
|
+
$deprecated?: string | boolean | undefined;
|
|
35
|
+
$extensions?: {
|
|
36
|
+
'org.primer.figma': {
|
|
37
|
+
collection?: string | undefined;
|
|
38
|
+
scopes?: string[] | undefined;
|
|
39
|
+
};
|
|
40
|
+
} | undefined;
|
|
41
|
+
}, {
|
|
42
|
+
$value: string;
|
|
43
|
+
$type: "string" | "number" | "border" | "color" | "fontFamily" | "fontWeight" | "dimension" | "duration" | "shadow" | "typography" | "cubicBezier" | "custom-viewportRange";
|
|
44
|
+
$description?: string | undefined;
|
|
45
|
+
$deprecated?: string | boolean | undefined;
|
|
46
|
+
$extensions?: {
|
|
47
|
+
'org.primer.figma': {
|
|
48
|
+
collection?: string | undefined;
|
|
49
|
+
scopes?: string[] | undefined;
|
|
50
|
+
};
|
|
51
|
+
} | undefined;
|
|
52
|
+
}>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { referenceValue } from './referenceValue.js';
|
|
3
|
+
import { baseToken } from './baseToken.js';
|
|
4
|
+
import { tokenType } from './tokenType.js';
|
|
5
|
+
import { collection } from './collections.js';
|
|
6
|
+
import { scopes } from './scopes.js';
|
|
7
|
+
export const fontFamilyToken = baseToken
|
|
8
|
+
.extend({
|
|
9
|
+
$value: z.union([z.string(), referenceValue]),
|
|
10
|
+
$type: tokenType('fontFamily'),
|
|
11
|
+
$extensions: z
|
|
12
|
+
.object({
|
|
13
|
+
'org.primer.figma': z.object({
|
|
14
|
+
collection: collection(['base/typography', 'typography']).optional(),
|
|
15
|
+
scopes: scopes(['fontFamily']).optional(),
|
|
16
|
+
}),
|
|
17
|
+
})
|
|
18
|
+
.optional(),
|
|
19
|
+
})
|
|
20
|
+
.strict();
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const fontWeightToken: z.ZodObject<z.objectUtil.extendShape<{
|
|
3
|
+
$description: z.ZodOptional<z.ZodString>;
|
|
4
|
+
$deprecated: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodBoolean]>>;
|
|
5
|
+
}, {
|
|
6
|
+
$type: z.ZodLiteral<"string" | "number" | "border" | "color" | "fontFamily" | "fontWeight" | "dimension" | "duration" | "shadow" | "typography" | "cubicBezier" | "custom-viewportRange">;
|
|
7
|
+
$value: z.ZodUnion<[z.ZodEffects<z.ZodNumber, number, number>, z.ZodEffects<z.ZodString, string, string>]>;
|
|
8
|
+
$extensions: z.ZodOptional<z.ZodObject<{
|
|
9
|
+
'org.primer.figma': z.ZodObject<{
|
|
10
|
+
collection: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
11
|
+
scopes: z.ZodOptional<z.ZodEffects<z.ZodArray<z.ZodString, "many">, string[], string[]>>;
|
|
12
|
+
}, "strip", z.ZodTypeAny, {
|
|
13
|
+
collection?: string | undefined;
|
|
14
|
+
scopes?: string[] | undefined;
|
|
15
|
+
}, {
|
|
16
|
+
collection?: string | undefined;
|
|
17
|
+
scopes?: string[] | undefined;
|
|
18
|
+
}>;
|
|
19
|
+
}, "strip", z.ZodTypeAny, {
|
|
20
|
+
'org.primer.figma': {
|
|
21
|
+
collection?: string | undefined;
|
|
22
|
+
scopes?: string[] | undefined;
|
|
23
|
+
};
|
|
24
|
+
}, {
|
|
25
|
+
'org.primer.figma': {
|
|
26
|
+
collection?: string | undefined;
|
|
27
|
+
scopes?: string[] | undefined;
|
|
28
|
+
};
|
|
29
|
+
}>>;
|
|
30
|
+
}>, "strict", z.ZodTypeAny, {
|
|
31
|
+
$value: string | number;
|
|
32
|
+
$type: "string" | "number" | "border" | "color" | "fontFamily" | "fontWeight" | "dimension" | "duration" | "shadow" | "typography" | "cubicBezier" | "custom-viewportRange";
|
|
33
|
+
$description?: string | undefined;
|
|
34
|
+
$deprecated?: string | boolean | undefined;
|
|
35
|
+
$extensions?: {
|
|
36
|
+
'org.primer.figma': {
|
|
37
|
+
collection?: string | undefined;
|
|
38
|
+
scopes?: string[] | undefined;
|
|
39
|
+
};
|
|
40
|
+
} | undefined;
|
|
41
|
+
}, {
|
|
42
|
+
$value: string | number;
|
|
43
|
+
$type: "string" | "number" | "border" | "color" | "fontFamily" | "fontWeight" | "dimension" | "duration" | "shadow" | "typography" | "cubicBezier" | "custom-viewportRange";
|
|
44
|
+
$description?: string | undefined;
|
|
45
|
+
$deprecated?: string | boolean | undefined;
|
|
46
|
+
$extensions?: {
|
|
47
|
+
'org.primer.figma': {
|
|
48
|
+
collection?: string | undefined;
|
|
49
|
+
scopes?: string[] | undefined;
|
|
50
|
+
};
|
|
51
|
+
} | undefined;
|
|
52
|
+
}>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { fontWeightValue } from './fontWeightValue.js';
|
|
3
|
+
import { referenceValue } from './referenceValue.js';
|
|
4
|
+
import { baseToken } from './baseToken.js';
|
|
5
|
+
import { tokenType } from './tokenType.js';
|
|
6
|
+
import { collection } from './collections.js';
|
|
7
|
+
import { scopes } from './scopes.js';
|
|
8
|
+
export const fontWeightToken = baseToken
|
|
9
|
+
.extend({
|
|
10
|
+
$type: tokenType('fontWeight'),
|
|
11
|
+
$value: z.union([fontWeightValue, referenceValue]),
|
|
12
|
+
$extensions: z
|
|
13
|
+
.object({
|
|
14
|
+
'org.primer.figma': z.object({
|
|
15
|
+
collection: collection(['base/typography', 'typography']).optional(),
|
|
16
|
+
scopes: scopes(['fontWeight']).optional(),
|
|
17
|
+
}),
|
|
18
|
+
})
|
|
19
|
+
.optional(),
|
|
20
|
+
})
|
|
21
|
+
.strict();
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { schemaErrorMessage } from '../utilities/index.js';
|
|
3
|
+
const allowed = [100, 200, 300, 400, 500, 600, 700, 800, 900, 950];
|
|
4
|
+
export const fontWeightValue = z.number().refine(value => allowed.includes(value), value => ({
|
|
5
|
+
message: schemaErrorMessage(`Invalid font weight value: "${value}"`, `Font weight must be one of ${allowed.join(', ')}`),
|
|
6
|
+
}));
|