@primer/primitives 9.0.3 → 9.1.0-rc.c6c17c46
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/build/PrimerStyleDictionary.d.ts +9 -0
- package/dist/build/PrimerStyleDictionary.js +92 -0
- package/dist/build/filters/index.d.ts +13 -0
- package/dist/build/filters/index.js +29 -0
- package/{src/filters/isBorder.ts → dist/build/filters/isBorder.d.ts} +2 -5
- package/dist/build/filters/isBorder.js +12 -0
- package/{src/filters/isColor.ts → dist/build/filters/isColor.d.ts} +2 -5
- package/dist/build/filters/isColor.js +12 -0
- package/dist/build/filters/isColorWithAlpha.d.ts +7 -0
- package/dist/build/filters/isColorWithAlpha.js +13 -0
- package/dist/build/filters/isColorWithMix.d.ts +7 -0
- package/dist/build/filters/isColorWithMix.js +28 -0
- package/{src/filters/isDeprecated.ts → dist/build/filters/isDeprecated.d.ts} +2 -5
- package/dist/build/filters/isDeprecated.js +12 -0
- package/{src/filters/isDimension.ts → dist/build/filters/isDimension.d.ts} +2 -5
- package/dist/build/filters/isDimension.js +12 -0
- package/{src/filters/isDuration.ts → dist/build/filters/isDuration.d.ts} +2 -5
- package/dist/build/filters/isDuration.js +12 -0
- package/{src/filters/isFontFamily.ts → dist/build/filters/isFontFamily.d.ts} +2 -5
- package/dist/build/filters/isFontFamily.js +12 -0
- package/{src/filters/isFontWeight.ts → dist/build/filters/isFontWeight.d.ts} +2 -5
- package/dist/build/filters/isFontWeight.js +12 -0
- package/dist/build/filters/isFromFile.d.ts +8 -0
- package/dist/build/filters/isFromFile.js +14 -0
- package/{src/filters/isNumber.ts → dist/build/filters/isNumber.d.ts} +2 -3
- package/dist/build/filters/isNumber.js +10 -0
- package/{src/filters/isShadow.ts → dist/build/filters/isShadow.d.ts} +2 -5
- package/dist/build/filters/isShadow.js +12 -0
- package/{src/filters/isSource.ts → dist/build/filters/isSource.d.ts} +2 -5
- package/dist/build/filters/isSource.js +12 -0
- package/{src/filters/isTypography.ts → dist/build/filters/isTypography.d.ts} +2 -5
- package/dist/build/filters/isTypography.js +12 -0
- package/dist/build/formats/cssAdvanced.d.ts +2 -0
- package/dist/build/formats/cssAdvanced.js +85 -0
- package/dist/build/formats/cssCustomMedia.d.ts +7 -0
- package/dist/build/formats/cssCustomMedia.js +25 -0
- package/dist/build/formats/index.d.ts +9 -0
- package/dist/build/formats/index.js +21 -0
- package/dist/build/formats/javascriptCommonJs.d.ts +7 -0
- package/dist/build/formats/javascriptCommonJs.js +25 -0
- package/dist/build/formats/javascriptEsm.d.ts +7 -0
- package/dist/build/formats/javascriptEsm.js +25 -0
- package/dist/build/formats/jsonFigma.d.ts +7 -0
- package/dist/build/formats/jsonFigma.js +116 -0
- package/dist/build/formats/jsonNestedPrefixed.d.ts +8 -0
- package/dist/build/formats/jsonNestedPrefixed.js +28 -0
- package/dist/build/formats/jsonOneDimensional.d.ts +8 -0
- package/dist/build/formats/jsonOneDimensional.js +24 -0
- package/dist/build/formats/jsonPostCssFallback.d.ts +8 -0
- package/dist/build/formats/jsonPostCssFallback.js +21 -0
- package/dist/build/formats/typescriptExportDefinition.d.ts +7 -0
- package/dist/build/formats/typescriptExportDefinition.js +166 -0
- package/{src/formats/utilities/jsonToFlat.ts → dist/build/formats/utilities/jsonToFlat.d.ts} +4 -3
- package/dist/build/formats/utilities/jsonToFlat.js +12 -0
- package/dist/build/formats/utilities/jsonToNestedValue.d.ts +8 -0
- package/dist/build/formats/utilities/jsonToNestedValue.js +25 -0
- package/dist/build/formats/utilities/prefixTokens.d.ts +8 -0
- package/dist/build/formats/utilities/prefixTokens.js +17 -0
- package/dist/build/parsers/index.d.ts +1 -0
- package/dist/build/parsers/index.js +5 -0
- package/dist/build/parsers/w3cJsonParser.d.ts +6 -0
- package/dist/build/parsers/w3cJsonParser.js +27 -0
- package/dist/build/platforms/css.d.ts +2 -0
- package/dist/build/platforms/css.js +88 -0
- package/dist/build/platforms/deprecatedJson.d.ts +2 -0
- package/dist/build/platforms/deprecatedJson.js +17 -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 +35 -0
- package/dist/build/platforms/figma.d.ts +2 -0
- package/dist/build/platforms/figma.js +53 -0
- package/dist/build/platforms/index.d.ts +10 -0
- package/dist/build/platforms/index.js +23 -0
- package/dist/build/platforms/javascript.d.ts +2 -0
- package/dist/build/platforms/javascript.js +31 -0
- package/dist/build/platforms/json.d.ts +2 -0
- package/dist/build/platforms/json.js +33 -0
- package/dist/build/platforms/styleLint.d.ts +2 -0
- package/dist/build/platforms/styleLint.js +35 -0
- package/dist/build/platforms/typeDefinitions.d.ts +2 -0
- package/dist/build/platforms/typeDefinitions.js +31 -0
- package/dist/build/platforms/typescript.d.ts +2 -0
- package/dist/build/platforms/typescript.js +31 -0
- package/dist/build/schemas/alphaValue.d.ts +2 -0
- package/dist/build/schemas/alphaValue.js +8 -0
- package/dist/build/schemas/baseToken.d.ts +11 -0
- package/dist/build/schemas/baseToken.js +10 -0
- package/dist/build/schemas/borderToken.d.ts +51 -0
- package/dist/build/schemas/borderToken.js +20 -0
- package/dist/build/schemas/collections.d.ts +6 -0
- package/dist/build/schemas/collections.js +18 -0
- package/dist/build/schemas/colorHexValue.d.ts +2 -0
- package/dist/build/schemas/colorHexValue.js +12 -0
- package/dist/build/schemas/colorToken.d.ts +80 -0
- package/dist/build/schemas/colorToken.js +52 -0
- package/dist/build/schemas/designToken.d.ts +2 -0
- package/dist/build/schemas/designToken.js +37 -0
- package/dist/build/schemas/dimensionToken.d.ts +52 -0
- package/dist/build/schemas/dimensionToken.js +36 -0
- package/dist/build/schemas/dimensionValue.d.ts +2 -0
- package/dist/build/schemas/dimensionValue.js +12 -0
- package/dist/build/schemas/durationToken.d.ts +18 -0
- package/dist/build/schemas/durationToken.js +14 -0
- package/dist/build/schemas/durationValue.d.ts +2 -0
- package/dist/build/schemas/durationValue.js +8 -0
- package/dist/build/schemas/fontFamilyToken.d.ts +52 -0
- package/dist/build/schemas/fontFamilyToken.js +23 -0
- package/dist/build/schemas/fontWeightToken.d.ts +52 -0
- package/dist/build/schemas/fontWeightToken.js +24 -0
- package/dist/build/schemas/fontWeightValue.d.ts +2 -0
- package/dist/build/schemas/fontWeightValue.js +9 -0
- package/dist/build/schemas/numberToken.d.ts +71 -0
- package/dist/build/schemas/numberToken.js +30 -0
- package/dist/build/schemas/referenceValue.d.ts +2 -0
- package/dist/build/schemas/referenceValue.js +8 -0
- package/dist/build/schemas/scopes.d.ts +5 -0
- package/dist/build/schemas/scopes.js +34 -0
- package/dist/build/schemas/shadowToken.d.ts +157 -0
- package/dist/build/schemas/shadowToken.js +46 -0
- package/dist/build/schemas/stringToken.d.ts +18 -0
- package/dist/build/schemas/stringToken.js +13 -0
- package/dist/build/schemas/tokenName.d.ts +2 -0
- package/dist/build/schemas/tokenName.js +8 -0
- package/dist/build/schemas/tokenType.d.ts +3 -0
- package/dist/build/schemas/tokenType.js +6 -0
- package/dist/build/schemas/typographyToken.d.ts +59 -0
- package/dist/build/schemas/typographyToken.js +21 -0
- package/dist/build/schemas/validTokenType.d.ts +5 -0
- package/dist/build/schemas/validTokenType.js +34 -0
- package/dist/build/schemas/viewportRangeToken.d.ts +18 -0
- package/dist/build/schemas/viewportRangeToken.js +13 -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 +18 -0
- package/dist/build/transformers/colorToHexAlpha.d.ts +8 -0
- package/dist/build/transformers/colorToHexAlpha.js +25 -0
- package/dist/build/transformers/colorToHexMix.d.ts +8 -0
- package/dist/build/transformers/colorToHexMix.js +25 -0
- package/dist/build/transformers/colorToRgbAlpha.d.ts +8 -0
- package/dist/build/transformers/colorToRgbAlpha.js +22 -0
- package/dist/build/transformers/colorToRgbaFloat.d.ts +8 -0
- package/dist/build/transformers/colorToRgbaFloat.js +50 -0
- package/dist/build/transformers/dimensionToPixelUnitless.d.ts +8 -0
- package/dist/build/transformers/dimensionToPixelUnitless.js +50 -0
- package/dist/build/transformers/dimensionToRem.d.ts +8 -0
- package/dist/build/transformers/dimensionToRem.js +47 -0
- package/dist/build/transformers/dimensionToRemPxArray.d.ts +8 -0
- package/dist/build/transformers/dimensionToRemPxArray.js +47 -0
- package/dist/build/transformers/durationToCss.d.ts +8 -0
- package/dist/build/transformers/durationToCss.js +30 -0
- package/dist/build/transformers/figmaAttributes.d.ts +8 -0
- package/dist/build/transformers/figmaAttributes.js +57 -0
- package/dist/build/transformers/floatToPixel.d.ts +15 -0
- package/dist/build/transformers/floatToPixel.js +41 -0
- package/dist/build/transformers/fontFamilyToCss.d.ts +14 -0
- package/dist/build/transformers/fontFamilyToCss.js +40 -0
- package/dist/build/transformers/fontFamilyToFigma.d.ts +14 -0
- package/dist/build/transformers/fontFamilyToFigma.js +46 -0
- package/dist/build/transformers/fontWeightToNumber.d.ts +9 -0
- package/dist/build/transformers/fontWeightToNumber.js +53 -0
- package/dist/build/transformers/index.d.ts +24 -0
- package/dist/build/transformers/index.js +51 -0
- package/dist/build/transformers/jsonDeprecated.d.ts +8 -0
- package/dist/build/transformers/jsonDeprecated.js +16 -0
- package/{src/transformers/namePathToCamelCase.ts → dist/build/transformers/namePathToCamelCase.d.ts} +2 -8
- package/dist/build/transformers/namePathToCamelCase.js +14 -0
- package/dist/build/transformers/namePathToDotNotation.d.ts +8 -0
- package/dist/build/transformers/namePathToDotNotation.js +33 -0
- package/dist/build/transformers/namePathToFigma.d.ts +9 -0
- package/dist/build/transformers/namePathToFigma.js +24 -0
- package/dist/build/transformers/namePathToKebabCase.d.ts +8 -0
- package/dist/build/transformers/namePathToKebabCase.js +18 -0
- package/dist/build/transformers/namePathToPascalCase.d.ts +8 -0
- package/dist/build/transformers/namePathToPascalCase.js +14 -0
- package/dist/build/transformers/namePathToSlashNotation.d.ts +8 -0
- package/dist/build/transformers/namePathToSlashNotation.js +18 -0
- package/dist/build/transformers/shadowToCss.d.ts +8 -0
- package/dist/build/transformers/shadowToCss.js +35 -0
- package/dist/build/transformers/typographyToCss.d.ts +8 -0
- package/dist/build/transformers/typographyToCss.js +29 -0
- package/dist/build/transformers/utilities/alpha.d.ts +9 -0
- package/dist/build/transformers/utilities/alpha.js +20 -0
- package/dist/build/transformers/utilities/checkRequiredTokenProperties.d.ts +7 -0
- package/dist/build/transformers/utilities/checkRequiredTokenProperties.js +17 -0
- package/dist/build/transformers/utilities/getTokenValue.d.ts +2 -0
- package/dist/build/transformers/utilities/getTokenValue.js +18 -0
- package/dist/build/transformers/utilities/hasSpaceInString.d.ts +1 -0
- package/dist/build/transformers/utilities/hasSpaceInString.js +10 -0
- package/dist/build/transformers/utilities/hexToRgbaFloat.d.ts +2 -0
- package/dist/build/transformers/utilities/hexToRgbaFloat.js +33 -0
- package/dist/build/transformers/utilities/invalidTokenError.d.ts +7 -0
- package/dist/build/transformers/utilities/invalidTokenError.js +26 -0
- package/dist/build/transformers/utilities/isRgbaFloat.d.ts +7 -0
- package/dist/build/transformers/utilities/isRgbaFloat.js +24 -0
- package/dist/build/transformers/utilities/mix.d.ts +5 -0
- package/dist/build/transformers/utilities/mix.js +40 -0
- package/dist/build/transformers/utilities/rgbaFloatToHex.d.ts +6 -0
- package/dist/build/transformers/utilities/rgbaFloatToHex.js +15 -0
- package/dist/build/utilities/copyFromDir.d.ts +8 -0
- package/dist/build/utilities/copyFromDir.js +34 -0
- package/dist/build/utilities/filterStringArray.d.ts +1 -0
- package/dist/build/utilities/filterStringArray.js +17 -0
- package/{src/utilities/getFlag.ts → dist/build/utilities/getFlag.d.ts} +1 -5
- package/dist/build/utilities/getFlag.js +16 -0
- package/dist/build/utilities/index.d.ts +3 -0
- package/dist/build/utilities/index.js +9 -0
- package/dist/build/utilities/joinFriendly.d.ts +1 -0
- package/dist/build/utilities/joinFriendly.js +5 -0
- package/dist/build/utilities/schemaErrorMessage.d.ts +1 -0
- package/dist/build/utilities/schemaErrorMessage.js +5 -0
- package/dist/build/utilities/toCamelCase.d.ts +1 -0
- package/dist/build/utilities/toCamelCase.js +20 -0
- package/dist/build/utilities/toPascalCase.d.ts +1 -0
- package/dist/build/utilities/toPascalCase.js +17 -0
- package/dist/build/utilities/treeWalker.d.ts +8 -0
- package/dist/build/utilities/treeWalker.js +27 -0
- package/{src/utilities/upperCaseFirstCharacter.ts → dist/build/utilities/upperCaseFirstCharacter.d.ts} +1 -3
- package/dist/build/utilities/upperCaseFirstCharacter.js +14 -0
- package/package.json +4 -5
- package/src/PrimerStyleDictionary.ts +0 -232
- package/src/filters/index.ts +0 -13
- package/src/filters/isColorWithAlpha.ts +0 -11
- package/src/filters/isColorWithMix.ts +0 -33
- package/src/filters/isFromFile.ts +0 -12
- package/src/formats/cssAdvanced.ts +0 -99
- package/src/formats/cssCustomMedia.ts +0 -24
- package/src/formats/index.ts +0 -9
- package/src/formats/javascriptCommonJs.ts +0 -21
- package/src/formats/javascriptEsm.ts +0 -21
- package/src/formats/jsonFigma.ts +0 -134
- package/src/formats/jsonNestedPrefixed.ts +0 -23
- package/src/formats/jsonOneDimensional.ts +0 -18
- package/src/formats/jsonPostCssFallback.ts +0 -16
- package/src/formats/typescriptExportDefinition.ts +0 -170
- package/src/formats/utilities/jsonToNestedValue.ts +0 -20
- package/src/formats/utilities/prefixTokens.ts +0 -17
- package/src/parsers/index.ts +0 -1
- package/src/parsers/w3cJsonParser.ts +0 -25
- package/src/platforms/css.ts +0 -101
- package/src/platforms/deprecatedJson.ts +0 -16
- package/src/platforms/docJson.ts +0 -34
- package/src/platforms/fallbacks.ts +0 -34
- package/src/platforms/figma.ts +0 -58
- package/src/platforms/index.ts +0 -10
- package/src/platforms/javascript.ts +0 -30
- package/src/platforms/json.ts +0 -32
- package/src/platforms/styleLint.ts +0 -34
- package/src/platforms/typeDefinitions.ts +0 -30
- package/src/platforms/typescript.ts +0 -30
- package/src/schemas/alphaValue.ts +0 -12
- package/src/schemas/baseToken.ts +0 -8
- package/src/schemas/borderToken.ts +0 -19
- package/src/schemas/collections.ts +0 -49
- package/src/schemas/colorHexValue.ts +0 -18
- package/src/schemas/colorToken.ts +0 -50
- package/src/schemas/designToken.ts +0 -38
- package/src/schemas/dimensionToken.ts +0 -34
- package/src/schemas/dimensionValue.ts +0 -16
- package/src/schemas/durationToken.ts +0 -12
- package/src/schemas/durationValue.ts +0 -9
- package/src/schemas/fontFamilyToken.ts +0 -21
- package/src/schemas/fontWeightToken.ts +0 -22
- package/src/schemas/fontWeightValue.ts +0 -14
- package/src/schemas/numberToken.ts +0 -28
- package/src/schemas/referenceValue.ts +0 -12
- package/src/schemas/scopes.ts +0 -40
- package/src/schemas/shadowToken.ts +0 -45
- package/src/schemas/stringToken.ts +0 -11
- package/src/schemas/tokenName.ts +0 -12
- package/src/schemas/tokenType.ts +0 -4
- package/src/schemas/typographyToken.ts +0 -20
- package/src/schemas/validTokenType.ts +0 -44
- package/src/schemas/viewportRangeToken.ts +0 -11
- package/src/test-utilities/getMockDictionary.ts +0 -22
- package/src/test-utilities/getMockFormatterArguments.ts +0 -21
- package/src/test-utilities/getMockParserInput.ts +0 -72
- package/src/test-utilities/getMockToken.ts +0 -25
- package/src/test-utilities/index.ts +0 -4
- package/src/tokens/base/color/dark/dark.dimmed.json5 +0 -1164
- package/src/tokens/base/color/dark/dark.high-contrast.json5 +0 -764
- package/src/tokens/base/color/dark/dark.json5 +0 -911
- package/src/tokens/base/color/dark/display-dark.json5 +0 -1774
- package/src/tokens/base/color/light/display-light.json5 +0 -1774
- package/src/tokens/base/color/light/light.high-contrast.json5 +0 -755
- package/src/tokens/base/color/light/light.json5 +0 -911
- package/src/tokens/base/size/size.json +0 -196
- package/src/tokens/base/typography/typography.json +0 -48
- package/src/tokens/fallback/color-fallbacks.json +0 -270
- package/src/tokens/functional/border/dark.json5 +0 -12
- package/src/tokens/functional/border/light.json5 +0 -12
- package/src/tokens/functional/color/dark/app-dark.json5 +0 -554
- package/src/tokens/functional/color/dark/data-vis-dark.json5 +0 -284
- package/src/tokens/functional/color/dark/display-dark.json5 +0 -1258
- package/src/tokens/functional/color/dark/overrides/dark.dimmed.json5 +0 -194
- package/src/tokens/functional/color/dark/overrides/dark.high-contrast.json5 +0 -935
- package/src/tokens/functional/color/dark/overrides/dark.protanopia-deuteranopia.json5 +0 -310
- package/src/tokens/functional/color/dark/overrides/dark.tritanopia.json5 +0 -224
- package/src/tokens/functional/color/dark/patterns-dark.json5 +0 -3097
- package/src/tokens/functional/color/dark/primitives-dark.json5 +0 -1200
- package/src/tokens/functional/color/dark/syntax-dark.json5 +0 -559
- package/src/tokens/functional/color/light/app-light.json5 +0 -551
- package/src/tokens/functional/color/light/data-vis-light.json5 +0 -284
- package/src/tokens/functional/color/light/display-light.json5 +0 -1258
- package/src/tokens/functional/color/light/overrides/light.high-contrast.json5 +0 -819
- package/src/tokens/functional/color/light/overrides/light.protanopia-deuteranopia.json5 +0 -327
- package/src/tokens/functional/color/light/overrides/light.tritanopia.json5 +0 -237
- package/src/tokens/functional/color/light/patterns-light.json5 +0 -3091
- package/src/tokens/functional/color/light/primitives-light.json5 +0 -1193
- package/src/tokens/functional/color/light/syntax-light.json5 +0 -559
- package/src/tokens/functional/motion/loading.json5 +0 -17
- package/src/tokens/functional/motion/patterns.json5 +0 -28
- package/src/tokens/functional/shadow/dark.json5 +0 -383
- package/src/tokens/functional/shadow/light.json5 +0 -376
- package/src/tokens/functional/size/border.json +0 -111
- package/src/tokens/functional/size/breakpoints.json +0 -64
- package/src/tokens/functional/size/size-coarse.json +0 -28
- package/src/tokens/functional/size/size-fine.json +0 -28
- package/src/tokens/functional/size/size.json +0 -740
- package/src/tokens/functional/size/viewport.json +0 -28
- package/src/tokens/functional/typography/typography.json +0 -527
- package/src/tokens/removed/color.json +0 -421
- package/src/tokens/removed/testing.json5 +0 -4
- package/src/transformers/borderToCss.ts +0 -38
- package/src/transformers/colorToHex.ts +0 -16
- package/src/transformers/colorToHexAlpha.ts +0 -23
- package/src/transformers/colorToHexMix.ts +0 -19
- package/src/transformers/colorToRgbAlpha.ts +0 -19
- package/src/transformers/colorToRgbaFloat.ts +0 -45
- package/src/transformers/dimensionToPixelUnitless.ts +0 -60
- package/src/transformers/dimensionToRem.ts +0 -56
- package/src/transformers/dimensionToRemPxArray.ts +0 -60
- package/src/transformers/durationToCss.ts +0 -29
- package/src/transformers/figmaAttributes.ts +0 -79
- package/src/transformers/floatToPixel.ts +0 -40
- package/src/transformers/fontFamilyToCss.ts +0 -37
- package/src/transformers/fontFamilyToFigma.ts +0 -47
- package/src/transformers/fontWeightToNumber.ts +0 -53
- package/src/transformers/index.ts +0 -24
- package/src/transformers/jsonDeprecated.ts +0 -15
- package/src/transformers/namePathToDotNotation.ts +0 -34
- package/src/transformers/namePathToFigma.ts +0 -28
- package/src/transformers/namePathToKebabCase.ts +0 -19
- package/src/transformers/namePathToSlashNotation.ts +0 -19
- package/src/transformers/shadowToCss.ts +0 -37
- package/src/transformers/typographyToCss.ts +0 -31
- package/src/transformers/utilities/alpha.ts +0 -23
- package/src/transformers/utilities/checkRequiredTokenProperties.ts +0 -16
- package/src/transformers/utilities/getTokenValue.ts +0 -18
- package/src/transformers/utilities/hasSpaceInString.ts +0 -6
- package/src/transformers/utilities/hexToRgbaFloat.ts +0 -31
- package/src/transformers/utilities/invalidTokenError.ts +0 -34
- package/src/transformers/utilities/isRgbaFloat.ts +0 -29
- package/src/transformers/utilities/mix.ts +0 -46
- package/src/transformers/utilities/rgbaFloatToHex.ts +0 -15
- package/src/types/Border.d.ts +0 -5
- package/src/types/BorderTokenValue.d.ts +0 -10
- package/src/types/ColorHex.d.ts +0 -4
- package/src/types/PlatformInitializer.d.ts +0 -11
- package/src/types/Shadow.d.ts +0 -5
- package/src/types/ShadowTokenValue.d.ts +0 -14
- package/src/types/SizeEm.d.ts +0 -4
- package/src/types/SizePx.d.ts +0 -4
- package/src/types/SizeRem.d.ts +0 -4
- package/src/types/StyleDictionaryConfigGenerator.d.ts +0 -15
- package/src/types/TokenBuildInput.d.ts +0 -8
- package/src/types/TypographyTokenValue.d.ts +0 -12
- package/src/types/w3cTransformedToken.d.ts +0 -8
- package/src/utilities/copyFromDir.ts +0 -21
- package/src/utilities/index.ts +0 -3
- package/src/utilities/joinFriendly.ts +0 -2
- package/src/utilities/schemaErrorMessage.ts +0 -2
- package/src/utilities/toCamelCase.ts +0 -29
- package/src/utilities/treeWalker.ts +0 -27
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.rgbaFloatToHex = void 0;
|
|
4
|
+
const rgbaFloatToHex = ({ r, g, b, a }, alpha = true) => {
|
|
5
|
+
const values = [r, g, b, alpha === true && a && a < 1 ? a : undefined].filter(item => item !== undefined);
|
|
6
|
+
if (r > 1 || r < 0 || g > 1 || g < 0 || b > 1 || b < 0) {
|
|
7
|
+
throw new Error('Invalid RgbaFloat value. R, G and B values must be between 0 and 1.');
|
|
8
|
+
}
|
|
9
|
+
return `#${values
|
|
10
|
+
.map(v => Number(parseInt(`${v * 255}`, 10))
|
|
11
|
+
.toString(16)
|
|
12
|
+
.padStart(2, '0'))
|
|
13
|
+
.join('')}`;
|
|
14
|
+
};
|
|
15
|
+
exports.rgbaFloatToHex = rgbaFloatToHex;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.copyFromDir = void 0;
|
|
13
|
+
/* istanbul ignore file */
|
|
14
|
+
const promises_1 = require("fs/promises");
|
|
15
|
+
/**
|
|
16
|
+
* copyFromDir
|
|
17
|
+
* @description Copies all files from source folder to destination
|
|
18
|
+
* @param source path
|
|
19
|
+
* @param destination path
|
|
20
|
+
* @returns promise
|
|
21
|
+
*/
|
|
22
|
+
const copyFromDir = (source, destination) => __awaiter(void 0, void 0, void 0, function* () {
|
|
23
|
+
// adjust trailing slash
|
|
24
|
+
const src = `${source.replace(/\/$/, '')}`;
|
|
25
|
+
const dest = `${destination.replace(/\/$/, '')}`;
|
|
26
|
+
// create dest if it does not exists
|
|
27
|
+
yield (0, promises_1.mkdir)(dest, { recursive: true });
|
|
28
|
+
// read files from source
|
|
29
|
+
const files = yield (0, promises_1.readdir)(src);
|
|
30
|
+
for (const file of files) {
|
|
31
|
+
(0, promises_1.copyFile)(`${src}/${file}`, `${dest}/${file}`);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
exports.copyFromDir = copyFromDir;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const filterStringArray: (string: string[]) => string[];
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.filterStringArray = void 0;
|
|
4
|
+
const filterStringArray = (string) => {
|
|
5
|
+
// match unsupported characters
|
|
6
|
+
const regex = /[^a-zA-Z0-9]+/g;
|
|
7
|
+
// replace any non-letter and non-number character and split into word array
|
|
8
|
+
const stringArray = string
|
|
9
|
+
.filter(Boolean)
|
|
10
|
+
.join(' ')
|
|
11
|
+
.replace(regex, ' ')
|
|
12
|
+
.split(' ')
|
|
13
|
+
// remove undefined if exists
|
|
14
|
+
.filter((part) => Boolean(part) && typeof part === 'string');
|
|
15
|
+
return stringArray;
|
|
16
|
+
};
|
|
17
|
+
exports.filterStringArray = filterStringArray;
|
|
@@ -5,8 +5,4 @@
|
|
|
5
5
|
* @returns null if flag is not found, otherwise the value of the flag or the flag name if the flag has no value
|
|
6
6
|
* @example `getFlag('--silent')` returns `null` if `--silent` is not found, `--silent` if `--silent` is found with no value, and `true` if `--silent=true` is found
|
|
7
7
|
*/
|
|
8
|
-
export const getFlag
|
|
9
|
-
flag = `${prefix}${flag.replace(prefix, '')}`
|
|
10
|
-
const index = process.argv.findIndex(arg => arg === flag || arg.startsWith(`${flag}=`))
|
|
11
|
-
return index === -1 ? null : process.argv[index].replace(`${flag}=`, '')
|
|
12
|
-
}
|
|
8
|
+
export declare const getFlag: (flag: string, prefix?: string) => string | null;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getFlag = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Get the value of a flag from the command line
|
|
6
|
+
* @param flag name of the flag to get
|
|
7
|
+
* @param prefix default `--` but can be changed to `-` the part to the left of the flag name
|
|
8
|
+
* @returns null if flag is not found, otherwise the value of the flag or the flag name if the flag has no value
|
|
9
|
+
* @example `getFlag('--silent')` returns `null` if `--silent` is not found, `--silent` if `--silent` is found with no value, and `true` if `--silent=true` is found
|
|
10
|
+
*/
|
|
11
|
+
const getFlag = (flag, prefix = '--') => {
|
|
12
|
+
flag = `${prefix}${flag.replace(prefix, '')}`;
|
|
13
|
+
const index = process.argv.findIndex(arg => arg === flag || arg.startsWith(`${flag}=`));
|
|
14
|
+
return index === -1 ? null : process.argv[index].replace(`${flag}=`, '');
|
|
15
|
+
};
|
|
16
|
+
exports.getFlag = getFlag;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toCamelCase = exports.upperCaseFirstCharacter = exports.copyFromDir = void 0;
|
|
4
|
+
var copyFromDir_1 = require("./copyFromDir");
|
|
5
|
+
Object.defineProperty(exports, "copyFromDir", { enumerable: true, get: function () { return copyFromDir_1.copyFromDir; } });
|
|
6
|
+
var upperCaseFirstCharacter_1 = require("./upperCaseFirstCharacter");
|
|
7
|
+
Object.defineProperty(exports, "upperCaseFirstCharacter", { enumerable: true, get: function () { return upperCaseFirstCharacter_1.upperCaseFirstCharacter; } });
|
|
8
|
+
var toCamelCase_1 = require("./toCamelCase");
|
|
9
|
+
Object.defineProperty(exports, "toCamelCase", { enumerable: true, get: function () { return toCamelCase_1.toCamelCase; } });
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const joinFriendly: (array: string[], lastJoin?: string) => string;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.joinFriendly = void 0;
|
|
4
|
+
const joinFriendly = (array, lastJoin = 'and') => array.length > 1 ? `${array.slice(0, -1).join(', ')} ${lastJoin} ${array.slice(-1)}` : `${array[0]}`;
|
|
5
|
+
exports.joinFriendly = joinFriendly;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const schemaErrorMessage: (title: string, description?: string) => string;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.schemaErrorMessage = void 0;
|
|
4
|
+
const schemaErrorMessage = (title, description) => `**${title}**${description ? `\n${description}` : ``}`;
|
|
5
|
+
exports.schemaErrorMessage = schemaErrorMessage;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const toCamelCase: (string: string | string[]) => string;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toCamelCase = void 0;
|
|
4
|
+
const filterStringArray_1 = require("./filterStringArray");
|
|
5
|
+
const upperCaseFirstCharacter_1 = require("./upperCaseFirstCharacter");
|
|
6
|
+
const toCamelCase = (string) => {
|
|
7
|
+
if (!Array.isArray(string)) {
|
|
8
|
+
string = [string];
|
|
9
|
+
}
|
|
10
|
+
return ((0, filterStringArray_1.filterStringArray)(string)
|
|
11
|
+
// ucFirst all but first part
|
|
12
|
+
.map((part, index) => {
|
|
13
|
+
if (index > 0) {
|
|
14
|
+
return (0, upperCaseFirstCharacter_1.upperCaseFirstCharacter)(part);
|
|
15
|
+
}
|
|
16
|
+
return part;
|
|
17
|
+
})
|
|
18
|
+
.join(''));
|
|
19
|
+
};
|
|
20
|
+
exports.toCamelCase = toCamelCase;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const toPascalCase: (string: string | string[]) => string;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toPascalCase = void 0;
|
|
4
|
+
const filterStringArray_1 = require("./filterStringArray");
|
|
5
|
+
const upperCaseFirstCharacter_1 = require("./upperCaseFirstCharacter");
|
|
6
|
+
const toPascalCase = (string) => {
|
|
7
|
+
if (!Array.isArray(string)) {
|
|
8
|
+
string = [string];
|
|
9
|
+
}
|
|
10
|
+
return ((0, filterStringArray_1.filterStringArray)(string)
|
|
11
|
+
// ucFirst all but first part
|
|
12
|
+
.map((part) => {
|
|
13
|
+
return (0, upperCaseFirstCharacter_1.upperCaseFirstCharacter)(part);
|
|
14
|
+
})
|
|
15
|
+
.join(''));
|
|
16
|
+
};
|
|
17
|
+
exports.toPascalCase = toPascalCase;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description converts tokens to type and returns array with used type
|
|
3
|
+
* @param tree object
|
|
4
|
+
* @param callback function to be run on valid items
|
|
5
|
+
* @param validItem function to test if a node is a validItem to be transformed
|
|
6
|
+
* @returns object
|
|
7
|
+
*/
|
|
8
|
+
export declare const treeWalker: (tree: unknown, callback: <T>(argument: T) => unknown, isValidItem: (argument: unknown) => boolean) => unknown;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.treeWalker = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* @description converts tokens to type and returns array with used type
|
|
6
|
+
* @param tree object
|
|
7
|
+
* @param callback function to be run on valid items
|
|
8
|
+
* @param validItem function to test if a node is a validItem to be transformed
|
|
9
|
+
* @returns object
|
|
10
|
+
*/
|
|
11
|
+
const treeWalker = (tree, callback, isValidItem) => {
|
|
12
|
+
// is a valid item -> pass through callback
|
|
13
|
+
if (isValidItem(tree)) {
|
|
14
|
+
return callback(tree);
|
|
15
|
+
}
|
|
16
|
+
// is non-object value -> ignore
|
|
17
|
+
if (typeof tree !== 'object' || tree === null) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
// is obj -> continue
|
|
21
|
+
const nextObj = {};
|
|
22
|
+
for (const [prop, value] of Object.entries(tree)) {
|
|
23
|
+
nextObj[prop] = (0, exports.treeWalker)(value, callback, isValidItem);
|
|
24
|
+
}
|
|
25
|
+
return nextObj;
|
|
26
|
+
};
|
|
27
|
+
exports.treeWalker = treeWalker;
|
|
@@ -5,6 +5,4 @@
|
|
|
5
5
|
* @param string
|
|
6
6
|
* @returns string
|
|
7
7
|
*/
|
|
8
|
-
export const upperCaseFirstCharacter
|
|
9
|
-
return firstLetter.toUpperCase() + restOfWord.join('')
|
|
10
|
-
}
|
|
8
|
+
export declare const upperCaseFirstCharacter: ([firstLetter, ...restOfWord]: string) => string;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.upperCaseFirstCharacter = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* upperCaseFirstCharacter
|
|
6
|
+
* @scope custom implementation should only be used within `name path to ...` transformer
|
|
7
|
+
* @description changes first letter to uppercase but keeps the rest of the word as is
|
|
8
|
+
* @param string
|
|
9
|
+
* @returns string
|
|
10
|
+
*/
|
|
11
|
+
const upperCaseFirstCharacter = ([firstLetter, ...restOfWord]) => {
|
|
12
|
+
return firstLetter.toUpperCase() + restOfWord.join('');
|
|
13
|
+
};
|
|
14
|
+
exports.upperCaseFirstCharacter = upperCaseFirstCharacter;
|
package/package.json
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@primer/primitives",
|
|
3
|
-
"version": "9.0.
|
|
3
|
+
"version": "9.1.0-rc.c6c17c46",
|
|
4
4
|
"description": "Typography, spacing, and color primitives for Primer design system",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=18.18.0 <18.19.0"
|
|
7
7
|
},
|
|
8
8
|
"files": [
|
|
9
|
-
"dist"
|
|
10
|
-
"src/**/*",
|
|
11
|
-
"!src/**/*.test.ts"
|
|
9
|
+
"dist"
|
|
12
10
|
],
|
|
13
11
|
"repository": "https://github.com/primer/primitives",
|
|
14
12
|
"keywords": [
|
|
@@ -26,11 +24,12 @@
|
|
|
26
24
|
},
|
|
27
25
|
"homepage": "https://github.com/primer/primitives#readme",
|
|
28
26
|
"scripts": {
|
|
29
|
-
"build": "npm run build:v8 && npm run build:fallbacks && npm run build:figma",
|
|
27
|
+
"build": "npm run build:v8 && npm run build:fallbacks && npm run build:figma && npm run build:config",
|
|
30
28
|
"build:next": "echo '\\033[31m 🛑 Use npm run build instead of npm run build:next\\033[0m'",
|
|
31
29
|
"build:v8": "tsx ./scripts/buildTokens.ts",
|
|
32
30
|
"build:fallbacks": "tsx ./scripts/buildFallbacks.ts",
|
|
33
31
|
"build:figma": "tsx scripts/buildFigma.ts",
|
|
32
|
+
"build:config": "tsc -p buildConfig.tsconfig.jsonc",
|
|
34
33
|
"tokenJson:check": "tsx scripts/diffThemes.ts && tsx scripts/diffTokenProps.ts",
|
|
35
34
|
"contrast:check": "tsx scripts/color-contrast.ts",
|
|
36
35
|
"format": "prettier --write '**/*.{js,jsx,ts,tsx,md,mdx,css}'",
|
|
@@ -1,232 +0,0 @@
|
|
|
1
|
-
import StyleDictionary from 'style-dictionary'
|
|
2
|
-
import {w3cJsonParser} from './parsers'
|
|
3
|
-
import {
|
|
4
|
-
borderToCss,
|
|
5
|
-
colorToHexAlpha,
|
|
6
|
-
colorToRgbAlpha,
|
|
7
|
-
colorToHex,
|
|
8
|
-
colorToHexMix,
|
|
9
|
-
colorToRgbaFloat,
|
|
10
|
-
dimensionToRem,
|
|
11
|
-
dimensionToPixelUnitless,
|
|
12
|
-
durationToCss,
|
|
13
|
-
figmaAttributes,
|
|
14
|
-
fontFamilyToCss,
|
|
15
|
-
fontFamilyToFigma,
|
|
16
|
-
fontWeightToNumber,
|
|
17
|
-
jsonDeprecated,
|
|
18
|
-
namePathToDotNotation,
|
|
19
|
-
namePathToCamelCase,
|
|
20
|
-
namePathToKebabCase,
|
|
21
|
-
namePathToSlashNotation,
|
|
22
|
-
namePathToFigma,
|
|
23
|
-
shadowToCss,
|
|
24
|
-
typographyToCss,
|
|
25
|
-
dimensionToRemPxArray,
|
|
26
|
-
floatToPixel,
|
|
27
|
-
floatToPixelUnitless,
|
|
28
|
-
} from './transformers'
|
|
29
|
-
import {
|
|
30
|
-
javascriptCommonJs,
|
|
31
|
-
javascriptEsm,
|
|
32
|
-
typescriptExportDefinition,
|
|
33
|
-
jsonNestedPrefixed,
|
|
34
|
-
cssCustomMedia,
|
|
35
|
-
jsonOneDimensional,
|
|
36
|
-
jsonPostCssFallback,
|
|
37
|
-
cssAdvanced,
|
|
38
|
-
jsonFigma,
|
|
39
|
-
} from './formats'
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Parsers
|
|
43
|
-
*
|
|
44
|
-
*/
|
|
45
|
-
StyleDictionary.registerParser(w3cJsonParser)
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Formats
|
|
49
|
-
*
|
|
50
|
-
*/
|
|
51
|
-
StyleDictionary.registerFormat({
|
|
52
|
-
name: 'css/advanced',
|
|
53
|
-
formatter: cssAdvanced,
|
|
54
|
-
})
|
|
55
|
-
|
|
56
|
-
StyleDictionary.registerFormat({
|
|
57
|
-
name: 'css/customMedia',
|
|
58
|
-
formatter: cssCustomMedia,
|
|
59
|
-
})
|
|
60
|
-
|
|
61
|
-
StyleDictionary.registerFormat({
|
|
62
|
-
name: 'javascript/esm',
|
|
63
|
-
formatter: javascriptEsm,
|
|
64
|
-
})
|
|
65
|
-
|
|
66
|
-
StyleDictionary.registerFormat({
|
|
67
|
-
name: 'javascript/commonJs',
|
|
68
|
-
formatter: javascriptCommonJs,
|
|
69
|
-
})
|
|
70
|
-
|
|
71
|
-
StyleDictionary.registerFormat({
|
|
72
|
-
name: 'typescript/export-definition',
|
|
73
|
-
formatter: typescriptExportDefinition,
|
|
74
|
-
})
|
|
75
|
-
|
|
76
|
-
StyleDictionary.registerFormat({
|
|
77
|
-
name: 'json/nested-prefixed',
|
|
78
|
-
formatter: jsonNestedPrefixed,
|
|
79
|
-
})
|
|
80
|
-
|
|
81
|
-
StyleDictionary.registerFormat({
|
|
82
|
-
name: 'json/one-dimensional',
|
|
83
|
-
formatter: jsonOneDimensional,
|
|
84
|
-
})
|
|
85
|
-
|
|
86
|
-
StyleDictionary.registerFormat({
|
|
87
|
-
name: 'json/postCss-fallback',
|
|
88
|
-
formatter: jsonPostCssFallback,
|
|
89
|
-
})
|
|
90
|
-
|
|
91
|
-
StyleDictionary.registerFormat({
|
|
92
|
-
name: 'json/figma',
|
|
93
|
-
formatter: jsonFigma,
|
|
94
|
-
})
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* Transformers
|
|
98
|
-
*
|
|
99
|
-
*/
|
|
100
|
-
StyleDictionary.registerTransform({
|
|
101
|
-
name: 'color/rgbAlpha',
|
|
102
|
-
...colorToRgbAlpha,
|
|
103
|
-
})
|
|
104
|
-
|
|
105
|
-
StyleDictionary.registerTransform({
|
|
106
|
-
name: 'color/rgbaFloat',
|
|
107
|
-
...colorToRgbaFloat,
|
|
108
|
-
})
|
|
109
|
-
|
|
110
|
-
StyleDictionary.registerTransform({
|
|
111
|
-
name: 'color/hexAlpha',
|
|
112
|
-
...colorToHexAlpha,
|
|
113
|
-
})
|
|
114
|
-
|
|
115
|
-
StyleDictionary.registerTransform({
|
|
116
|
-
name: 'color/hexMix',
|
|
117
|
-
...colorToHexMix,
|
|
118
|
-
})
|
|
119
|
-
|
|
120
|
-
StyleDictionary.registerTransform({
|
|
121
|
-
name: 'color/hex',
|
|
122
|
-
...colorToHex,
|
|
123
|
-
})
|
|
124
|
-
|
|
125
|
-
StyleDictionary.registerTransform({
|
|
126
|
-
name: 'float/pixel',
|
|
127
|
-
...floatToPixel,
|
|
128
|
-
})
|
|
129
|
-
|
|
130
|
-
StyleDictionary.registerTransform({
|
|
131
|
-
name: 'float/pixelUnitless',
|
|
132
|
-
...floatToPixelUnitless,
|
|
133
|
-
})
|
|
134
|
-
|
|
135
|
-
StyleDictionary.registerTransform({
|
|
136
|
-
name: 'dimension/rem',
|
|
137
|
-
...dimensionToRem,
|
|
138
|
-
})
|
|
139
|
-
|
|
140
|
-
StyleDictionary.registerTransform({
|
|
141
|
-
name: 'dimension/remPxArray',
|
|
142
|
-
...dimensionToRemPxArray,
|
|
143
|
-
})
|
|
144
|
-
|
|
145
|
-
StyleDictionary.registerTransform({
|
|
146
|
-
name: 'dimension/pixelUnitless',
|
|
147
|
-
...dimensionToPixelUnitless,
|
|
148
|
-
})
|
|
149
|
-
|
|
150
|
-
StyleDictionary.registerTransform({
|
|
151
|
-
name: 'duration/css',
|
|
152
|
-
...durationToCss,
|
|
153
|
-
})
|
|
154
|
-
|
|
155
|
-
StyleDictionary.registerTransform({
|
|
156
|
-
name: 'figma/attributes',
|
|
157
|
-
...figmaAttributes,
|
|
158
|
-
})
|
|
159
|
-
|
|
160
|
-
StyleDictionary.registerTransform({
|
|
161
|
-
name: 'json/deprecated',
|
|
162
|
-
...jsonDeprecated,
|
|
163
|
-
})
|
|
164
|
-
|
|
165
|
-
StyleDictionary.registerTransform({
|
|
166
|
-
name: 'name/pathToCamelCase',
|
|
167
|
-
...namePathToCamelCase,
|
|
168
|
-
})
|
|
169
|
-
|
|
170
|
-
StyleDictionary.registerTransform({
|
|
171
|
-
name: 'name/pathToDotNotation',
|
|
172
|
-
...namePathToDotNotation,
|
|
173
|
-
})
|
|
174
|
-
|
|
175
|
-
StyleDictionary.registerTransform({
|
|
176
|
-
name: 'name/pathToFigma',
|
|
177
|
-
...namePathToFigma,
|
|
178
|
-
})
|
|
179
|
-
|
|
180
|
-
StyleDictionary.registerTransform({
|
|
181
|
-
name: 'name/pathToCamelCase',
|
|
182
|
-
...namePathToCamelCase,
|
|
183
|
-
})
|
|
184
|
-
|
|
185
|
-
StyleDictionary.registerTransform({
|
|
186
|
-
name: 'name/pathToKebabCase',
|
|
187
|
-
...namePathToKebabCase,
|
|
188
|
-
})
|
|
189
|
-
|
|
190
|
-
StyleDictionary.registerTransform({
|
|
191
|
-
name: 'name/pathToSlashNotation',
|
|
192
|
-
...namePathToSlashNotation,
|
|
193
|
-
})
|
|
194
|
-
|
|
195
|
-
StyleDictionary.registerTransform({
|
|
196
|
-
name: 'shadow/css',
|
|
197
|
-
...shadowToCss,
|
|
198
|
-
})
|
|
199
|
-
|
|
200
|
-
StyleDictionary.registerTransform({
|
|
201
|
-
name: 'border/css',
|
|
202
|
-
...borderToCss,
|
|
203
|
-
})
|
|
204
|
-
|
|
205
|
-
StyleDictionary.registerTransform({
|
|
206
|
-
name: 'typography/css',
|
|
207
|
-
...typographyToCss,
|
|
208
|
-
})
|
|
209
|
-
|
|
210
|
-
StyleDictionary.registerTransform({
|
|
211
|
-
name: 'fontWeight/number',
|
|
212
|
-
...fontWeightToNumber,
|
|
213
|
-
})
|
|
214
|
-
|
|
215
|
-
StyleDictionary.registerTransform({
|
|
216
|
-
name: 'fontFamily/css',
|
|
217
|
-
...fontFamilyToCss,
|
|
218
|
-
})
|
|
219
|
-
|
|
220
|
-
StyleDictionary.registerTransform({
|
|
221
|
-
name: 'fontFamily/figma',
|
|
222
|
-
...fontFamilyToFigma,
|
|
223
|
-
})
|
|
224
|
-
|
|
225
|
-
/**
|
|
226
|
-
* @name {@link PrimerStyleDictionary}
|
|
227
|
-
* @description Returns style dictionary object with primer preset that includes parsers, formats and transformers
|
|
228
|
-
* @parsers [w3cJsonParser](https://github.com/primer/primitives/blob/main/config//parsers/w3c-json-parser.ts)
|
|
229
|
-
* @formats [javascript/esm](https://github.com/primer/primitives/blob/main/config/formats/javascript-esm.ts), [javascript/commonJs](https://github.com/primer/primitives/blob/main/config/formats/javascript-commonJs.ts), [typescript/export-definition](https://github.com/primer/primitives/blob/main/config/formats/typescript-export-defition.ts)
|
|
230
|
-
* @transformers [color/rgbAlpha](https://github.com/primer/primitives/blob/main/config/tranformers/color-to-rgb-alpha.ts), [color/hexAlpha](https://github.com/primer/primitives/blob/main/config/tranformers/color-to-hex-alpha.ts), [color/hex](https://github.com/primer/primitives/blob/main/config/tranformers/color-to-hex6.ts), [json/deprecated](https://github.com/primer/primitives/blob/main/config/tranformers/json-deprecated.ts), [name/pathToDotNotation](https://github.com/primer/primitives/blob/main/config/tranformers/name-path-to-dot-notation.ts)
|
|
231
|
-
*/
|
|
232
|
-
export const PrimerStyleDictionary: StyleDictionary.Core = StyleDictionary
|
package/src/filters/index.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export {isBorder} from './isBorder'
|
|
2
|
-
export {isColor} from './isColor'
|
|
3
|
-
export {isColorWithAlpha} from './isColorWithAlpha'
|
|
4
|
-
export {isColorWithMix} from './isColorWithMix'
|
|
5
|
-
export {isDimension} from './isDimension'
|
|
6
|
-
export {isDeprecated} from './isDeprecated'
|
|
7
|
-
export {isFromFile} from './isFromFile'
|
|
8
|
-
export {isFontFamily} from './isFontFamily'
|
|
9
|
-
export {isFontWeight} from './isFontWeight'
|
|
10
|
-
export {isNumber} from './isNumber'
|
|
11
|
-
export {isShadow} from './isShadow'
|
|
12
|
-
export {isSource} from './isSource'
|
|
13
|
-
export {isTypography} from './isTypography'
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type StyleDictionary from 'style-dictionary'
|
|
2
|
-
import {isColor} from './isColor'
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* @description Checks if token is color with an alpha value
|
|
6
|
-
* @param arguments [StyleDictionary.TransformedToken](https://github.com/amzn/style-dictionary/blob/main/types/TransformedToken.d.ts)
|
|
7
|
-
* @returns boolean
|
|
8
|
-
*/
|
|
9
|
-
export const isColorWithAlpha = (token: StyleDictionary.TransformedToken): boolean => {
|
|
10
|
-
return isColor(token) && token.alpha !== undefined && typeof token.alpha === 'number'
|
|
11
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import type StyleDictionary from 'style-dictionary'
|
|
2
|
-
import {isColor} from './isColor'
|
|
3
|
-
|
|
4
|
-
const throwError = (token: StyleDictionary.TransformedToken) => {
|
|
5
|
-
throw new Error(
|
|
6
|
-
`Invalid mix property on token: ${token.name}. "mix.color": ${token.mix.color}, "mix.weight": ${
|
|
7
|
-
typeof token.mix.weight === 'string' ? `"${token.mix.weight}" (string)` : token.mix.weight
|
|
8
|
-
} must be a number between 0 and 1. In file: "${token.filePath}".`,
|
|
9
|
-
)
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* @description Checks if token is color and has a mix property
|
|
14
|
-
* @param arguments [StyleDictionary.TransformedToken](https://github.com/amzn/style-dictionary/blob/main/types/TransformedToken.d.ts)
|
|
15
|
-
* @returns boolean
|
|
16
|
-
*/
|
|
17
|
-
export const isColorWithMix = (token: StyleDictionary.TransformedToken): boolean => {
|
|
18
|
-
// no color or no mix property
|
|
19
|
-
if (!isColor(token) || token.mix === undefined || token.mix === null) {
|
|
20
|
-
return false
|
|
21
|
-
}
|
|
22
|
-
// invalid mix property
|
|
23
|
-
if (
|
|
24
|
-
typeof token.mix.color !== 'string' ||
|
|
25
|
-
typeof token.mix.weight !== 'number' ||
|
|
26
|
-
token.mix.weight < 0 ||
|
|
27
|
-
token.mix.weight > 1
|
|
28
|
-
) {
|
|
29
|
-
throwError(token)
|
|
30
|
-
}
|
|
31
|
-
// valid mix property
|
|
32
|
-
return true
|
|
33
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type StyleDictionary from 'style-dictionary'
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @description Checks if token comes from a specific file
|
|
5
|
-
* @param token [StyleDictionary.TransformedToken](https://github.com/amzn/style-dictionary/blob/main/types/TransformedToken.d.ts)
|
|
6
|
-
* @param files - array of file paths
|
|
7
|
-
* @returns boolean
|
|
8
|
-
*/
|
|
9
|
-
export const isFromFile = (token: StyleDictionary.TransformedToken, files: string[]): boolean => {
|
|
10
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
11
|
-
return files?.includes(token.filePath) === true
|
|
12
|
-
}
|