@digdir/designsystemet 0.1.0-alpha.10 → 0.1.0-alpha.12
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/bin/designsystemet.js +3388 -0
- package/dist/bin/designsystemet.js.map +1 -0
- package/dist/src/colors/colorUtils.js +210 -0
- package/dist/src/colors/colorUtils.js.map +1 -0
- package/dist/src/colors/index.js +451 -0
- package/dist/src/colors/index.js.map +1 -0
- package/dist/src/colors/themeUtils.js +311 -0
- package/dist/src/colors/themeUtils.js.map +1 -0
- package/dist/src/colors/types.js +1 -0
- package/dist/src/colors/types.js.map +1 -0
- package/dist/src/migrations/beta-to-v1.js +407 -0
- package/dist/src/migrations/beta-to-v1.js.map +1 -0
- package/dist/src/migrations/codemods/css/plugins.js +49 -0
- package/dist/src/migrations/codemods/css/plugins.js.map +1 -0
- package/dist/src/migrations/codemods/css/run.js +21 -0
- package/dist/src/migrations/codemods/css/run.js.map +1 -0
- package/dist/src/migrations/codemods/jsx/classname-prefix.js +65 -0
- package/dist/src/migrations/codemods/jsx/classname-prefix.js.map +1 -0
- package/dist/src/migrations/codemods/jsx/run.js +24 -0
- package/dist/src/migrations/codemods/jsx/run.js.map +1 -0
- package/dist/src/migrations/index.js +437 -0
- package/dist/src/migrations/index.js.map +1 -0
- package/dist/src/migrations/react-beta-to-v1.js +27 -0
- package/dist/src/migrations/react-beta-to-v1.js.map +1 -0
- package/dist/src/tokens/actions.js +2174 -0
- package/dist/src/tokens/actions.js.map +1 -0
- package/dist/src/tokens/build.js +2923 -0
- package/dist/src/tokens/build.js.map +1 -0
- package/dist/src/tokens/configs.js +2837 -0
- package/dist/src/tokens/configs.js.map +1 -0
- package/dist/src/tokens/formats/css-classes.js +2622 -0
- package/dist/src/tokens/formats/css-classes.js.map +1 -0
- package/dist/src/tokens/formats/css-variables.js +50 -0
- package/dist/src/tokens/formats/css-variables.js.map +1 -0
- package/dist/src/tokens/formats/js-tokens.js +38 -0
- package/dist/src/tokens/formats/js-tokens.js.map +1 -0
- package/dist/src/tokens/transformers.js +87 -0
- package/dist/src/tokens/transformers.js.map +1 -0
- package/dist/src/tokens/utils/noCase.js +30 -0
- package/dist/src/tokens/utils/noCase.js.map +1 -0
- package/dist/src/tokens/utils/permutateThemes.js +217 -0
- package/dist/src/tokens/utils/permutateThemes.js.map +1 -0
- package/dist/src/tokens/utils/utils.js +16 -0
- package/dist/src/tokens/utils/utils.js.map +1 -0
- package/package.json +23 -10
- package/LICENSE +0 -7
- package/dist/build/bin/designsystemet.js +0 -50
- package/dist/build/src/colors/colorUtils.js +0 -314
- package/dist/build/src/colors/index.js +0 -3
- package/dist/build/src/colors/themeUtils.js +0 -293
- package/dist/build/src/colors/types.js +0 -1
- package/dist/build/src/migrations/beta-to-v1.js +0 -341
- package/dist/build/src/migrations/codemods/css/plugins.js +0 -45
- package/dist/build/src/migrations/codemods/css/run.js +0 -17
- package/dist/build/src/migrations/codemods/jsx/classname-prefix.js +0 -80
- package/dist/build/src/migrations/codemods/jsx/run.js +0 -19
- package/dist/build/src/migrations/index.js +0 -6
- package/dist/build/src/migrations/react-beta-to-v1.js +0 -2
- package/dist/build/src/test/jsx-test.js +0 -10
- package/dist/build/src/tokens/actions.js +0 -20
- package/dist/build/src/tokens/build.js +0 -63
- package/dist/build/src/tokens/configs.js +0 -229
- package/dist/build/src/tokens/formats/css-classes.js +0 -50
- package/dist/build/src/tokens/formats/css-variables.js +0 -39
- package/dist/build/src/tokens/formats/js-tokens.js +0 -29
- package/dist/build/src/tokens/transformers.js +0 -42
- package/dist/build/src/tokens/utils/noCase.js +0 -30
- package/dist/build/src/tokens/utils/permutateThemes.js +0 -56
- package/dist/build/src/tokens/utils/utils.js +0 -21
- package/dist/build/tsconfig.tsbuildinfo +0 -1
- package/dist/types/bin/designsystemet.d.ts +0 -3
- package/dist/types/bin/designsystemet.d.ts.map +0 -1
- package/dist/types/src/colors/colorUtils.d.ts +0 -118
- package/dist/types/src/colors/colorUtils.d.ts.map +0 -1
- package/dist/types/src/colors/index.d.ts +0 -4
- package/dist/types/src/colors/index.d.ts.map +0 -1
- package/dist/types/src/colors/themeUtils.d.ts +0 -102
- package/dist/types/src/colors/themeUtils.d.ts.map +0 -1
- package/dist/types/src/colors/types.d.ts +0 -16
- package/dist/types/src/colors/types.d.ts.map +0 -1
- package/dist/types/src/migrations/beta-to-v1.d.ts +0 -3
- package/dist/types/src/migrations/beta-to-v1.d.ts.map +0 -1
- package/dist/types/src/migrations/codemods/css/plugins.d.ts +0 -6
- package/dist/types/src/migrations/codemods/css/plugins.d.ts.map +0 -1
- package/dist/types/src/migrations/codemods/css/run.d.ts +0 -8
- package/dist/types/src/migrations/codemods/css/run.d.ts.map +0 -1
- package/dist/types/src/migrations/codemods/jsx/classname-prefix.d.ts +0 -10
- package/dist/types/src/migrations/codemods/jsx/classname-prefix.d.ts.map +0 -1
- package/dist/types/src/migrations/codemods/jsx/run.d.ts +0 -7
- package/dist/types/src/migrations/codemods/jsx/run.d.ts.map +0 -1
- package/dist/types/src/migrations/index.d.ts +0 -6
- package/dist/types/src/migrations/index.d.ts.map +0 -1
- package/dist/types/src/migrations/react-beta-to-v1.d.ts +0 -3
- package/dist/types/src/migrations/react-beta-to-v1.d.ts.map +0 -1
- package/dist/types/src/test/jsx-test.d.ts +0 -4
- package/dist/types/src/test/jsx-test.d.ts.map +0 -1
- package/dist/types/src/tokens/actions.d.ts +0 -3
- package/dist/types/src/tokens/actions.d.ts.map +0 -1
- package/dist/types/src/tokens/build.d.ts +0 -11
- package/dist/types/src/tokens/build.d.ts.map +0 -1
- package/dist/types/src/tokens/configs.d.ts +0 -23
- package/dist/types/src/tokens/configs.d.ts.map +0 -1
- package/dist/types/src/tokens/formats/css-classes.d.ts +0 -6
- package/dist/types/src/tokens/formats/css-classes.d.ts.map +0 -1
- package/dist/types/src/tokens/formats/css-variables.d.ts +0 -3
- package/dist/types/src/tokens/formats/css-variables.d.ts.map +0 -1
- package/dist/types/src/tokens/formats/js-tokens.d.ts +0 -6
- package/dist/types/src/tokens/formats/js-tokens.d.ts.map +0 -1
- package/dist/types/src/tokens/transformers.d.ts +0 -5
- package/dist/types/src/tokens/transformers.d.ts.map +0 -1
- package/dist/types/src/tokens/utils/noCase.d.ts +0 -11
- package/dist/types/src/tokens/utils/noCase.d.ts.map +0 -1
- package/dist/types/src/tokens/utils/permutateThemes.d.ts +0 -7
- package/dist/types/src/tokens/utils/permutateThemes.d.ts.map +0 -1
- package/dist/types/src/tokens/utils/utils.d.ts +0 -17
- package/dist/types/src/tokens/utils/utils.d.ts.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/tokens/transformers.ts","../../../src/tokens/utils/noCase.ts","../../../src/tokens/utils/utils.ts"],"sourcesContent":["import * as R from 'ramda';\nimport type { Transform } from 'style-dictionary/types';\n\nimport { noCase } from './utils/noCase.js';\nimport { getValue, typeEquals } from './utils/utils.js';\n\nconst isPx = R.test(/\\b\\d+px\\b/g);\n\nexport const sizeRem: Transform = {\n name: 'ds/size/toRem',\n type: 'value',\n transitive: true,\n filter: (token) => typeEquals(['sizing', 'spacing', 'borderRadius', 'fontsizes'], token),\n transform: (token, config) => {\n const value = getValue<string>(token);\n\n if (isPx(value)) {\n const baseFont = (config.basePxFontSize as unknown as number) || 16;\n const size = parseInt(value);\n\n if (size === 0) {\n return '0';\n }\n\n return `${size / baseFont}rem`;\n }\n return value;\n },\n};\n\nexport const nameKebab: Transform = {\n name: 'name/cti/hierarchical-kebab',\n type: 'name',\n transform: (token, options) => {\n return noCase([options?.prefix].concat(token.path).join('-'), {\n delimiter: '-',\n stripRegexp: /[^A-Z0-9_]+/gi,\n });\n },\n};\n\ntype Typgraphy = {\n fontWeight: string;\n fontSize: string;\n lineHeight: number;\n fontFamily: string;\n};\n\nexport const typographyShorthand: Transform = {\n name: 'typography/shorthand',\n type: 'value',\n transitive: true,\n filter: (token) => token.type === 'typography',\n transform: (token) => {\n const typography = getValue<Typgraphy>(token);\n return `${typography.fontWeight} ${typography.fontSize}/${typography.lineHeight} '${typography.fontFamily}'`;\n },\n};\n","// Copied from https://github.com/blakeembrey/change-case/blob/change-case%404.1.2/packages/no-case/src/index.ts\nconst lowerCase = (text = '') => text.toLowerCase();\n\nexport interface Options {\n splitRegexp?: RegExp | RegExp[];\n stripRegexp?: RegExp | RegExp[];\n delimiter?: string;\n transform?: (part: string, index: number, parts: string[]) => string;\n}\n\n// Support camel case (\"camelCase\" -> \"camel Case\" and \"CAMELCase\" -> \"CAMEL Case\").\nconst DEFAULT_SPLIT_REGEXP = [/([a-z0-9])([A-Z])/g, /([A-Z])([A-Z][a-z])/g];\n\n// Remove all non-word characters.\nconst DEFAULT_STRIP_REGEXP = /[^A-Z0-9]+/gi;\n\n/**\n * Normalize the string into something other libraries can manipulate easier.\n */\nexport function noCase(input: string, options: Options = {}) {\n const {\n splitRegexp = DEFAULT_SPLIT_REGEXP,\n stripRegexp = DEFAULT_STRIP_REGEXP,\n transform = lowerCase,\n delimiter = ' ',\n } = options;\n\n const result = replace(\n replace(input, splitRegexp, '$1\\0$2'),\n stripRegexp,\n '\\0',\n );\n let start = 0;\n let end = result.length;\n\n // Trim the delimiter from around the output string.\n while (result.charAt(start) === '\\0') start++;\n while (result.charAt(end - 1) === '\\0') end--;\n\n // Transform each token independently.\n return result.slice(start, end).split('\\0').map(transform).join(delimiter);\n}\n\n/**\n * Replace `re` in the input string with the replacement value.\n */\nfunction replace(input: string, re: RegExp | RegExp[], value: string) {\n if (re instanceof RegExp) return input.replace(re, value);\n return re.reduce((input, re) => input.replace(re, value), input);\n}\n","import * as R from 'ramda';\nimport type { TransformedToken, DesignToken } from 'style-dictionary/types';\n\n/**\n * Returns type based on design token format used. Read more:https://v4.styledictionary.com/info/dtcg/\n * @param token Transformed token\n * @returns type\n */\nexport const getType = (token: TransformedToken) => ((token.$type ?? token.type) as string) || '';\n\n/**\n * Returns value based on design token format used. Read more:https://v4.styledictionary.com/info/dtcg/\n *\n * Use generic (`<T>`) to define return value type\n * @param token Transformed or Design token\n * @returns value\n */\nexport const getValue = <T>(token: TransformedToken | DesignToken): T => (token.$value ?? token.value) as T;\n\nexport const typeEquals = (types: string[] | string, token: TransformedToken) => {\n if (R.isNil(token)) {\n return false;\n }\n\n return R.includes(R.toLower(getType(token)), R.map(R.toLower, Array.isArray(types) ? types : [types]));\n};\n"],"mappings":";AAAA,YAAYA,QAAO;;;ACCnB,IAAM,YAAY,CAAC,OAAO,OAAO,KAAK,YAAY;AAUlD,IAAM,uBAAuB,CAAC,sBAAsB,sBAAsB;AAG1E,IAAM,uBAAuB;AAKtB,SAAS,OAAO,OAAe,UAAmB,CAAC,GAAG;AAC3D,QAAM;AAAA,IACJ,cAAc;AAAA,IACd,cAAc;AAAA,IACd,YAAY;AAAA,IACZ,YAAY;AAAA,EACd,IAAI;AAEJ,QAAM,SAAS;AAAA,IACb,QAAQ,OAAO,aAAa,QAAQ;AAAA,IACpC;AAAA,IACA;AAAA,EACF;AACA,MAAI,QAAQ;AACZ,MAAI,MAAM,OAAO;AAGjB,SAAO,OAAO,OAAO,KAAK,MAAM,KAAM;AACtC,SAAO,OAAO,OAAO,MAAM,CAAC,MAAM,KAAM;AAGxC,SAAO,OAAO,MAAM,OAAO,GAAG,EAAE,MAAM,IAAI,EAAE,IAAI,SAAS,EAAE,KAAK,SAAS;AAC3E;AAKA,SAAS,QAAQ,OAAe,IAAuB,OAAe;AACpE,MAAI,cAAc,OAAQ,QAAO,MAAM,QAAQ,IAAI,KAAK;AACxD,SAAO,GAAG,OAAO,CAACC,QAAOC,QAAOD,OAAM,QAAQC,KAAI,KAAK,GAAG,KAAK;AACjE;;;ACjDA,YAAY,OAAO;AAQZ,IAAM,UAAU,CAAC,WAA8B,MAAM,SAAS,MAAM,SAAoB;AASxF,IAAM,WAAW,CAAI,UAA8C,MAAM,UAAU,MAAM;AAEzF,IAAM,aAAa,CAAC,OAA0B,UAA4B;AAC/E,MAAM,QAAM,KAAK,GAA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owerCase = (text = "") => text.toLowerCase();
|
|
3
|
+
var DEFAULT_SPLIT_REGEXP = [/([a-z0-9])([A-Z])/g, /([A-Z])([A-Z][a-z])/g];
|
|
4
|
+
var DEFAULT_STRIP_REGEXP = /[^A-Z0-9]+/gi;
|
|
5
|
+
function noCase(input, options = {}) {
|
|
6
|
+
const {
|
|
7
|
+
splitRegexp = DEFAULT_SPLIT_REGEXP,
|
|
8
|
+
stripRegexp = DEFAULT_STRIP_REGEXP,
|
|
9
|
+
transform = lowerCase,
|
|
10
|
+
delimiter = " "
|
|
11
|
+
} = options;
|
|
12
|
+
const result = replace(
|
|
13
|
+
replace(input, splitRegexp, "$1\0$2"),
|
|
14
|
+
stripRegexp,
|
|
15
|
+
"\0"
|
|
16
|
+
);
|
|
17
|
+
let start = 0;
|
|
18
|
+
let end = result.length;
|
|
19
|
+
while (result.charAt(start) === "\0") start++;
|
|
20
|
+
while (result.charAt(end - 1) === "\0") end--;
|
|
21
|
+
return result.slice(start, end).split("\0").map(transform).join(delimiter);
|
|
22
|
+
}
|
|
23
|
+
function replace(input, re, value) {
|
|
24
|
+
if (re instanceof RegExp) return input.replace(re, value);
|
|
25
|
+
return re.reduce((input2, re2) => input2.replace(re2, value), input);
|
|
26
|
+
}
|
|
27
|
+
export {
|
|
28
|
+
noCase
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=noCase.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/tokens/utils/noCase.ts"],"sourcesContent":["// Copied from https://github.com/blakeembrey/change-case/blob/change-case%404.1.2/packages/no-case/src/index.ts\nconst lowerCase = (text = '') => text.toLowerCase();\n\nexport interface Options {\n splitRegexp?: RegExp | RegExp[];\n stripRegexp?: RegExp | RegExp[];\n delimiter?: string;\n transform?: (part: string, index: number, parts: string[]) => string;\n}\n\n// Support camel case (\"camelCase\" -> \"camel Case\" and \"CAMELCase\" -> \"CAMEL Case\").\nconst DEFAULT_SPLIT_REGEXP = [/([a-z0-9])([A-Z])/g, /([A-Z])([A-Z][a-z])/g];\n\n// Remove all non-word characters.\nconst DEFAULT_STRIP_REGEXP = /[^A-Z0-9]+/gi;\n\n/**\n * Normalize the string into something other libraries can manipulate easier.\n */\nexport function noCase(input: string, options: Options = {}) {\n const {\n splitRegexp = DEFAULT_SPLIT_REGEXP,\n stripRegexp = DEFAULT_STRIP_REGEXP,\n transform = lowerCase,\n delimiter = ' ',\n } = options;\n\n const result = replace(\n replace(input, splitRegexp, '$1\\0$2'),\n stripRegexp,\n '\\0',\n );\n let start = 0;\n let end = result.length;\n\n // Trim the delimiter from around the output string.\n while (result.charAt(start) === '\\0') start++;\n while (result.charAt(end - 1) === '\\0') end--;\n\n // Transform each token independently.\n return result.slice(start, end).split('\\0').map(transform).join(delimiter);\n}\n\n/**\n * Replace `re` in the input string with the replacement value.\n */\nfunction replace(input: string, re: RegExp | RegExp[], value: string) {\n if (re instanceof RegExp) return input.replace(re, value);\n return re.reduce((input, re) => input.replace(re, value), input);\n}\n"],"mappings":";AACA,IAAM,YAAY,CAAC,OAAO,OAAO,KAAK,YAAY;AAUlD,IAAM,uBAAuB,CAAC,sBAAsB,sBAAsB;AAG1E,IAAM,uBAAuB;AAKtB,SAAS,OAAO,OAAe,UAAmB,CAAC,GAAG;AAC3D,QAAM;AAAA,IACJ,cAAc;AAAA,IACd,cAAc;AAAA,IACd,YAAY;AAAA,IACZ,YAAY;AAAA,EACd,IAAI;AAEJ,QAAM,SAAS;AAAA,IACb,QAAQ,OAAO,aAAa,QAAQ;AAAA,IACpC;AAAA,IACA;AAAA,EACF;AACA,MAAI,QAAQ;AACZ,MAAI,MAAM,OAAO;AAGjB,SAAO,OAAO,OAAO,KAAK,MAAM,KAAM;AACtC,SAAO,OAAO,OAAO,MAAM,CAAC,MAAM,KAAM;AAGxC,SAAO,OAAO,MAAM,OAAO,GAAG,EAAE,MAAM,IAAI,EAAE,IAAI,SAAS,EAAE,KAAK,SAAS;AAC3E;AAKA,SAAS,QAAQ,OAAe,IAAuB,OAAe;AACpE,MAAI,cAAc,OAAQ,QAAO,MAAM,QAAQ,IAAI,KAAK;AACxD,SAAO,GAAG,OAAO,CAACA,QAAOC,QAAOD,OAAM,QAAQC,KAAI,KAAK,GAAG,KAAK;AACjE;","names":["input","re"]}
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
// ../../node_modules/@tokens-studio/types/dist/constants/BoxShadowTypes.js
|
|
2
|
+
var BoxShadowTypes;
|
|
3
|
+
(function(BoxShadowTypes2) {
|
|
4
|
+
BoxShadowTypes2["DROP_SHADOW"] = "dropShadow";
|
|
5
|
+
BoxShadowTypes2["INNER_SHADOW"] = "innerShadow";
|
|
6
|
+
})(BoxShadowTypes || (BoxShadowTypes = {}));
|
|
7
|
+
|
|
8
|
+
// ../../node_modules/@tokens-studio/types/dist/constants/ColorModifierTypes.js
|
|
9
|
+
var ColorModifierTypes;
|
|
10
|
+
(function(ColorModifierTypes2) {
|
|
11
|
+
ColorModifierTypes2["LIGHTEN"] = "lighten";
|
|
12
|
+
ColorModifierTypes2["DARKEN"] = "darken";
|
|
13
|
+
ColorModifierTypes2["MIX"] = "mix";
|
|
14
|
+
ColorModifierTypes2["ALPHA"] = "alpha";
|
|
15
|
+
})(ColorModifierTypes || (ColorModifierTypes = {}));
|
|
16
|
+
|
|
17
|
+
// ../../node_modules/@tokens-studio/types/dist/constants/ColorSpaceTypes.js
|
|
18
|
+
var ColorSpaceTypes;
|
|
19
|
+
(function(ColorSpaceTypes2) {
|
|
20
|
+
ColorSpaceTypes2["LCH"] = "lch";
|
|
21
|
+
ColorSpaceTypes2["SRGB"] = "srgb";
|
|
22
|
+
ColorSpaceTypes2["P3"] = "p3";
|
|
23
|
+
ColorSpaceTypes2["HSL"] = "hsl";
|
|
24
|
+
})(ColorSpaceTypes || (ColorSpaceTypes = {}));
|
|
25
|
+
|
|
26
|
+
// ../../node_modules/@tokens-studio/types/dist/constants/Properties.js
|
|
27
|
+
var Properties;
|
|
28
|
+
(function(Properties2) {
|
|
29
|
+
Properties2["sizing"] = "sizing";
|
|
30
|
+
Properties2["height"] = "height";
|
|
31
|
+
Properties2["width"] = "width";
|
|
32
|
+
Properties2["spacing"] = "spacing";
|
|
33
|
+
Properties2["verticalPadding"] = "verticalPadding";
|
|
34
|
+
Properties2["horizontalPadding"] = "horizontalPadding";
|
|
35
|
+
Properties2["paddingTop"] = "paddingTop";
|
|
36
|
+
Properties2["paddingRight"] = "paddingRight";
|
|
37
|
+
Properties2["paddingBottom"] = "paddingBottom";
|
|
38
|
+
Properties2["paddingLeft"] = "paddingLeft";
|
|
39
|
+
Properties2["itemSpacing"] = "itemSpacing";
|
|
40
|
+
Properties2["fill"] = "fill";
|
|
41
|
+
Properties2["backgroundBlur"] = "backgroundBlur";
|
|
42
|
+
Properties2["border"] = "border";
|
|
43
|
+
Properties2["borderTop"] = "borderTop";
|
|
44
|
+
Properties2["borderRight"] = "borderRight";
|
|
45
|
+
Properties2["borderBottom"] = "borderBottom";
|
|
46
|
+
Properties2["borderLeft"] = "borderLeft";
|
|
47
|
+
Properties2["borderColor"] = "borderColor";
|
|
48
|
+
Properties2["borderRadius"] = "borderRadius";
|
|
49
|
+
Properties2["borderRadiusTopLeft"] = "borderRadiusTopLeft";
|
|
50
|
+
Properties2["borderRadiusTopRight"] = "borderRadiusTopRight";
|
|
51
|
+
Properties2["borderRadiusBottomRight"] = "borderRadiusBottomRight";
|
|
52
|
+
Properties2["borderRadiusBottomLeft"] = "borderRadiusBottomLeft";
|
|
53
|
+
Properties2["borderWidth"] = "borderWidth";
|
|
54
|
+
Properties2["borderWidthTop"] = "borderWidthTop";
|
|
55
|
+
Properties2["borderWidthRight"] = "borderWidthRight";
|
|
56
|
+
Properties2["borderWidthBottom"] = "borderWidthBottom";
|
|
57
|
+
Properties2["borderWidthLeft"] = "borderWidthLeft";
|
|
58
|
+
Properties2["boxShadow"] = "boxShadow";
|
|
59
|
+
Properties2["opacity"] = "opacity";
|
|
60
|
+
Properties2["fontFamilies"] = "fontFamilies";
|
|
61
|
+
Properties2["fontWeights"] = "fontWeights";
|
|
62
|
+
Properties2["fontSizes"] = "fontSizes";
|
|
63
|
+
Properties2["lineHeights"] = "lineHeights";
|
|
64
|
+
Properties2["typography"] = "typography";
|
|
65
|
+
Properties2["composition"] = "composition";
|
|
66
|
+
Properties2["letterSpacing"] = "letterSpacing";
|
|
67
|
+
Properties2["paragraphSpacing"] = "paragraphSpacing";
|
|
68
|
+
Properties2["textCase"] = "textCase";
|
|
69
|
+
Properties2["dimension"] = "dimension";
|
|
70
|
+
Properties2["textDecoration"] = "textDecoration";
|
|
71
|
+
Properties2["asset"] = "asset";
|
|
72
|
+
Properties2["tokenValue"] = "tokenValue";
|
|
73
|
+
Properties2["value"] = "value";
|
|
74
|
+
Properties2["tokenName"] = "tokenName";
|
|
75
|
+
Properties2["description"] = "description";
|
|
76
|
+
})(Properties || (Properties = {}));
|
|
77
|
+
|
|
78
|
+
// ../../node_modules/@tokens-studio/types/dist/constants/TokenSetStatus.js
|
|
79
|
+
var TokenSetStatus;
|
|
80
|
+
(function(TokenSetStatus2) {
|
|
81
|
+
TokenSetStatus2["DISABLED"] = "disabled";
|
|
82
|
+
TokenSetStatus2["SOURCE"] = "source";
|
|
83
|
+
TokenSetStatus2["ENABLED"] = "enabled";
|
|
84
|
+
})(TokenSetStatus || (TokenSetStatus = {}));
|
|
85
|
+
|
|
86
|
+
// ../../node_modules/@tokens-studio/types/dist/constants/TokenTypes.js
|
|
87
|
+
var TokenTypes;
|
|
88
|
+
(function(TokenTypes2) {
|
|
89
|
+
TokenTypes2["OTHER"] = "other";
|
|
90
|
+
TokenTypes2["COLOR"] = "color";
|
|
91
|
+
TokenTypes2["BORDER_RADIUS"] = "borderRadius";
|
|
92
|
+
TokenTypes2["SIZING"] = "sizing";
|
|
93
|
+
TokenTypes2["SPACING"] = "spacing";
|
|
94
|
+
TokenTypes2["TEXT"] = "text";
|
|
95
|
+
TokenTypes2["TYPOGRAPHY"] = "typography";
|
|
96
|
+
TokenTypes2["OPACITY"] = "opacity";
|
|
97
|
+
TokenTypes2["BORDER_WIDTH"] = "borderWidth";
|
|
98
|
+
TokenTypes2["STROKE_STYLE"] = "strokeStyle";
|
|
99
|
+
TokenTypes2["BOX_SHADOW"] = "boxShadow";
|
|
100
|
+
TokenTypes2["FONT_FAMILIES"] = "fontFamilies";
|
|
101
|
+
TokenTypes2["FONT_WEIGHTS"] = "fontWeights";
|
|
102
|
+
TokenTypes2["LINE_HEIGHTS"] = "lineHeights";
|
|
103
|
+
TokenTypes2["FONT_SIZES"] = "fontSizes";
|
|
104
|
+
TokenTypes2["LETTER_SPACING"] = "letterSpacing";
|
|
105
|
+
TokenTypes2["PARAGRAPH_SPACING"] = "paragraphSpacing";
|
|
106
|
+
TokenTypes2["PARAGRAPH_INDENT"] = "paragraphIndent";
|
|
107
|
+
TokenTypes2["TEXT_DECORATION"] = "textDecoration";
|
|
108
|
+
TokenTypes2["TEXT_CASE"] = "textCase";
|
|
109
|
+
TokenTypes2["COMPOSITION"] = "composition";
|
|
110
|
+
TokenTypes2["DIMENSION"] = "dimension";
|
|
111
|
+
TokenTypes2["BORDER"] = "border";
|
|
112
|
+
TokenTypes2["ASSET"] = "asset";
|
|
113
|
+
TokenTypes2["BOOLEAN"] = "boolean";
|
|
114
|
+
TokenTypes2["NUMBER"] = "number";
|
|
115
|
+
})(TokenTypes || (TokenTypes = {}));
|
|
116
|
+
|
|
117
|
+
// ../../node_modules/@tokens-studio/types/dist/constants/BorderValues.js
|
|
118
|
+
var BorderValues;
|
|
119
|
+
(function(BorderValues2) {
|
|
120
|
+
BorderValues2["BORDER_COLOR"] = "color";
|
|
121
|
+
BorderValues2["BORDER_WIDTH"] = "width";
|
|
122
|
+
BorderValues2["BORDER_STYLE"] = "style";
|
|
123
|
+
})(BorderValues || (BorderValues = {}));
|
|
124
|
+
|
|
125
|
+
// ../../node_modules/@tokens-studio/types/dist/constants/StrokeStyleValues.js
|
|
126
|
+
var StrokeStyleValues;
|
|
127
|
+
(function(StrokeStyleValues2) {
|
|
128
|
+
StrokeStyleValues2["SOLID"] = "solid";
|
|
129
|
+
StrokeStyleValues2["DASHED"] = "dashed";
|
|
130
|
+
StrokeStyleValues2["DOTTED"] = "dotted";
|
|
131
|
+
StrokeStyleValues2["DOUBLE"] = "double";
|
|
132
|
+
StrokeStyleValues2["GROOVE"] = "groove";
|
|
133
|
+
StrokeStyleValues2["RIDGE"] = "ridge";
|
|
134
|
+
StrokeStyleValues2["OUTSET"] = "outset";
|
|
135
|
+
StrokeStyleValues2["INSET"] = "inset";
|
|
136
|
+
})(StrokeStyleValues || (StrokeStyleValues = {}));
|
|
137
|
+
|
|
138
|
+
// ../../node_modules/@tokens-studio/types/dist/constants/BoxShadowValues.js
|
|
139
|
+
var BoxShadowValues;
|
|
140
|
+
(function(BoxShadowValues2) {
|
|
141
|
+
BoxShadowValues2["TYPE"] = "type";
|
|
142
|
+
BoxShadowValues2["COLOR"] = "color";
|
|
143
|
+
BoxShadowValues2["X"] = "x";
|
|
144
|
+
BoxShadowValues2["Y"] = "y";
|
|
145
|
+
BoxShadowValues2["BLUR"] = "blur";
|
|
146
|
+
BoxShadowValues2["SPREAD"] = "spread";
|
|
147
|
+
BoxShadowValues2["BLEND_MODE"] = "blendMode";
|
|
148
|
+
})(BoxShadowValues || (BoxShadowValues = {}));
|
|
149
|
+
|
|
150
|
+
// ../../node_modules/@tokens-studio/types/dist/constants/TypographyValues.js
|
|
151
|
+
var TypographyValues;
|
|
152
|
+
(function(TypographyValues2) {
|
|
153
|
+
TypographyValues2["FONT_FAMILY"] = "fontFamily";
|
|
154
|
+
TypographyValues2["FONT_WEIGHT"] = "fontWeight";
|
|
155
|
+
TypographyValues2["LINE_HEIGHT"] = "lineHeight";
|
|
156
|
+
TypographyValues2["FONT_SIZE"] = "fontSize";
|
|
157
|
+
TypographyValues2["LETTER_SPACING"] = "letterSpacing";
|
|
158
|
+
TypographyValues2["PARAGRAPH_SPACING"] = "paragraphSpacing";
|
|
159
|
+
TypographyValues2["PARAGRAPH_INDENT"] = "paragraphIndent";
|
|
160
|
+
TypographyValues2["TEXT_DECORATION"] = "textDecoration";
|
|
161
|
+
TypographyValues2["TEXT_CASE"] = "textCase";
|
|
162
|
+
})(TypographyValues || (TypographyValues = {}));
|
|
163
|
+
|
|
164
|
+
// src/tokens/utils/permutateThemes.ts
|
|
165
|
+
function mapThemesToSetsObject(themes) {
|
|
166
|
+
return Object.fromEntries(themes.map((theme) => [theme.name, filterTokenSets(theme.selectedTokenSets)]));
|
|
167
|
+
}
|
|
168
|
+
function permutateThemes(themes, { separator = "-" } = {}) {
|
|
169
|
+
if (themes.some((theme) => theme.group)) {
|
|
170
|
+
const groups = {};
|
|
171
|
+
themes.forEach((theme) => {
|
|
172
|
+
if (theme.group) {
|
|
173
|
+
groups[theme.group] = [...groups[theme.group] ?? [], theme];
|
|
174
|
+
} else {
|
|
175
|
+
throw new Error(
|
|
176
|
+
`Theme ${theme.name} does not have a group property, which is required for multi-dimensional theming.`
|
|
177
|
+
);
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
if (Object.keys(groups).length <= 1) {
|
|
181
|
+
return mapThemesToSetsObject(themes);
|
|
182
|
+
}
|
|
183
|
+
const permutations = cartesian(Object.values(groups));
|
|
184
|
+
return Object.fromEntries(
|
|
185
|
+
permutations.map((perm) => {
|
|
186
|
+
const reduced = perm.reduce(
|
|
187
|
+
(acc, curr) => [
|
|
188
|
+
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
|
189
|
+
`${acc[0]}${acc[0] ? separator : ""}${curr.name}`,
|
|
190
|
+
[...acc[1], ...filterTokenSets(curr.selectedTokenSets)]
|
|
191
|
+
],
|
|
192
|
+
["", []]
|
|
193
|
+
);
|
|
194
|
+
return [reduced[0], [...new Set(reduced[1])]];
|
|
195
|
+
})
|
|
196
|
+
);
|
|
197
|
+
} else {
|
|
198
|
+
return mapThemesToSetsObject(themes);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
function filterTokenSets(tokensets) {
|
|
202
|
+
return Object.entries(tokensets).filter(([, val]) => val !== TokenSetStatus.DISABLED).sort((a, b) => {
|
|
203
|
+
if (a[1] === TokenSetStatus.SOURCE && b[1] === TokenSetStatus.ENABLED) {
|
|
204
|
+
return -1;
|
|
205
|
+
} else if (a[1] === TokenSetStatus.ENABLED && b[1] === TokenSetStatus.SOURCE) {
|
|
206
|
+
return 1;
|
|
207
|
+
}
|
|
208
|
+
return 0;
|
|
209
|
+
}).map((entry) => entry[0]);
|
|
210
|
+
}
|
|
211
|
+
function cartesian(a) {
|
|
212
|
+
return a.reduce((a2, b) => a2.flatMap((d) => b.map((e) => [d, e].flat())));
|
|
213
|
+
}
|
|
214
|
+
export {
|
|
215
|
+
permutateThemes
|
|
216
|
+
};
|
|
217
|
+
//# sourceMappingURL=permutateThemes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../node_modules/@tokens-studio/types/dist/constants/BoxShadowTypes.js","../../../../../../node_modules/@tokens-studio/types/dist/constants/ColorModifierTypes.js","../../../../../../node_modules/@tokens-studio/types/dist/constants/ColorSpaceTypes.js","../../../../../../node_modules/@tokens-studio/types/dist/constants/Properties.js","../../../../../../node_modules/@tokens-studio/types/dist/constants/TokenSetStatus.js","../../../../../../node_modules/@tokens-studio/types/dist/constants/TokenTypes.js","../../../../../../node_modules/@tokens-studio/types/dist/constants/BorderValues.js","../../../../../../node_modules/@tokens-studio/types/dist/constants/StrokeStyleValues.js","../../../../../../node_modules/@tokens-studio/types/dist/constants/BoxShadowValues.js","../../../../../../node_modules/@tokens-studio/types/dist/constants/TypographyValues.js","../../../../src/tokens/utils/permutateThemes.ts"],"sourcesContent":["var BoxShadowTypes;\n(function (BoxShadowTypes) {\n BoxShadowTypes[\"DROP_SHADOW\"] = \"dropShadow\";\n BoxShadowTypes[\"INNER_SHADOW\"] = \"innerShadow\";\n})(BoxShadowTypes || (BoxShadowTypes = {}));\n\nexport { BoxShadowTypes };\n","var ColorModifierTypes;\n(function (ColorModifierTypes) {\n ColorModifierTypes[\"LIGHTEN\"] = \"lighten\";\n ColorModifierTypes[\"DARKEN\"] = \"darken\";\n ColorModifierTypes[\"MIX\"] = \"mix\";\n ColorModifierTypes[\"ALPHA\"] = \"alpha\";\n})(ColorModifierTypes || (ColorModifierTypes = {}));\n\nexport { ColorModifierTypes };\n","var ColorSpaceTypes;\n(function (ColorSpaceTypes) {\n ColorSpaceTypes[\"LCH\"] = \"lch\";\n ColorSpaceTypes[\"SRGB\"] = \"srgb\";\n ColorSpaceTypes[\"P3\"] = \"p3\";\n ColorSpaceTypes[\"HSL\"] = \"hsl\";\n})(ColorSpaceTypes || (ColorSpaceTypes = {}));\n\nexport { ColorSpaceTypes };\n","var Properties;\n(function (Properties) {\n Properties[\"sizing\"] = \"sizing\";\n Properties[\"height\"] = \"height\";\n Properties[\"width\"] = \"width\";\n Properties[\"spacing\"] = \"spacing\";\n Properties[\"verticalPadding\"] = \"verticalPadding\";\n Properties[\"horizontalPadding\"] = \"horizontalPadding\";\n Properties[\"paddingTop\"] = \"paddingTop\";\n Properties[\"paddingRight\"] = \"paddingRight\";\n Properties[\"paddingBottom\"] = \"paddingBottom\";\n Properties[\"paddingLeft\"] = \"paddingLeft\";\n Properties[\"itemSpacing\"] = \"itemSpacing\";\n Properties[\"fill\"] = \"fill\";\n Properties[\"backgroundBlur\"] = \"backgroundBlur\";\n Properties[\"border\"] = \"border\";\n Properties[\"borderTop\"] = \"borderTop\";\n Properties[\"borderRight\"] = \"borderRight\";\n Properties[\"borderBottom\"] = \"borderBottom\";\n Properties[\"borderLeft\"] = \"borderLeft\";\n Properties[\"borderColor\"] = \"borderColor\";\n Properties[\"borderRadius\"] = \"borderRadius\";\n Properties[\"borderRadiusTopLeft\"] = \"borderRadiusTopLeft\";\n Properties[\"borderRadiusTopRight\"] = \"borderRadiusTopRight\";\n Properties[\"borderRadiusBottomRight\"] = \"borderRadiusBottomRight\";\n Properties[\"borderRadiusBottomLeft\"] = \"borderRadiusBottomLeft\";\n Properties[\"borderWidth\"] = \"borderWidth\";\n Properties[\"borderWidthTop\"] = \"borderWidthTop\";\n Properties[\"borderWidthRight\"] = \"borderWidthRight\";\n Properties[\"borderWidthBottom\"] = \"borderWidthBottom\";\n Properties[\"borderWidthLeft\"] = \"borderWidthLeft\";\n Properties[\"boxShadow\"] = \"boxShadow\";\n Properties[\"opacity\"] = \"opacity\";\n Properties[\"fontFamilies\"] = \"fontFamilies\";\n Properties[\"fontWeights\"] = \"fontWeights\";\n Properties[\"fontSizes\"] = \"fontSizes\";\n Properties[\"lineHeights\"] = \"lineHeights\";\n Properties[\"typography\"] = \"typography\";\n Properties[\"composition\"] = \"composition\";\n Properties[\"letterSpacing\"] = \"letterSpacing\";\n Properties[\"paragraphSpacing\"] = \"paragraphSpacing\";\n Properties[\"textCase\"] = \"textCase\";\n Properties[\"dimension\"] = \"dimension\";\n Properties[\"textDecoration\"] = \"textDecoration\";\n Properties[\"asset\"] = \"asset\";\n Properties[\"tokenValue\"] = \"tokenValue\";\n Properties[\"value\"] = \"value\";\n Properties[\"tokenName\"] = \"tokenName\";\n Properties[\"description\"] = \"description\";\n})(Properties || (Properties = {}));\n\nexport { Properties };\n","var TokenSetStatus;\n(function (TokenSetStatus) {\n TokenSetStatus[\"DISABLED\"] = \"disabled\";\n TokenSetStatus[\"SOURCE\"] = \"source\";\n TokenSetStatus[\"ENABLED\"] = \"enabled\";\n})(TokenSetStatus || (TokenSetStatus = {}));\n\nexport { TokenSetStatus };\n","var TokenTypes;\n(function (TokenTypes) {\n TokenTypes[\"OTHER\"] = \"other\";\n TokenTypes[\"COLOR\"] = \"color\";\n TokenTypes[\"BORDER_RADIUS\"] = \"borderRadius\";\n TokenTypes[\"SIZING\"] = \"sizing\";\n TokenTypes[\"SPACING\"] = \"spacing\";\n TokenTypes[\"TEXT\"] = \"text\";\n TokenTypes[\"TYPOGRAPHY\"] = \"typography\";\n TokenTypes[\"OPACITY\"] = \"opacity\";\n TokenTypes[\"BORDER_WIDTH\"] = \"borderWidth\";\n TokenTypes[\"STROKE_STYLE\"] = \"strokeStyle\";\n TokenTypes[\"BOX_SHADOW\"] = \"boxShadow\";\n TokenTypes[\"FONT_FAMILIES\"] = \"fontFamilies\";\n TokenTypes[\"FONT_WEIGHTS\"] = \"fontWeights\";\n TokenTypes[\"LINE_HEIGHTS\"] = \"lineHeights\";\n TokenTypes[\"FONT_SIZES\"] = \"fontSizes\";\n TokenTypes[\"LETTER_SPACING\"] = \"letterSpacing\";\n TokenTypes[\"PARAGRAPH_SPACING\"] = \"paragraphSpacing\";\n TokenTypes[\"PARAGRAPH_INDENT\"] = \"paragraphIndent\";\n TokenTypes[\"TEXT_DECORATION\"] = \"textDecoration\";\n TokenTypes[\"TEXT_CASE\"] = \"textCase\";\n TokenTypes[\"COMPOSITION\"] = \"composition\";\n TokenTypes[\"DIMENSION\"] = \"dimension\";\n TokenTypes[\"BORDER\"] = \"border\";\n TokenTypes[\"ASSET\"] = \"asset\";\n TokenTypes[\"BOOLEAN\"] = \"boolean\";\n TokenTypes[\"NUMBER\"] = \"number\";\n})(TokenTypes || (TokenTypes = {}));\n\nexport { TokenTypes };\n","var BorderValues;\n(function (BorderValues) {\n BorderValues[\"BORDER_COLOR\"] = \"color\";\n BorderValues[\"BORDER_WIDTH\"] = \"width\";\n BorderValues[\"BORDER_STYLE\"] = \"style\";\n})(BorderValues || (BorderValues = {}));\n\nexport { BorderValues };\n","var StrokeStyleValues;\n(function (StrokeStyleValues) {\n StrokeStyleValues[\"SOLID\"] = \"solid\";\n StrokeStyleValues[\"DASHED\"] = \"dashed\";\n StrokeStyleValues[\"DOTTED\"] = \"dotted\";\n StrokeStyleValues[\"DOUBLE\"] = \"double\";\n StrokeStyleValues[\"GROOVE\"] = \"groove\";\n StrokeStyleValues[\"RIDGE\"] = \"ridge\";\n StrokeStyleValues[\"OUTSET\"] = \"outset\";\n StrokeStyleValues[\"INSET\"] = \"inset\";\n})(StrokeStyleValues || (StrokeStyleValues = {}));\n\nexport { StrokeStyleValues };\n","var BoxShadowValues;\n(function (BoxShadowValues) {\n BoxShadowValues[\"TYPE\"] = \"type\";\n BoxShadowValues[\"COLOR\"] = \"color\";\n BoxShadowValues[\"X\"] = \"x\";\n BoxShadowValues[\"Y\"] = \"y\";\n BoxShadowValues[\"BLUR\"] = \"blur\";\n BoxShadowValues[\"SPREAD\"] = \"spread\";\n BoxShadowValues[\"BLEND_MODE\"] = \"blendMode\";\n})(BoxShadowValues || (BoxShadowValues = {}));\n\nexport { BoxShadowValues };\n","var TypographyValues;\n(function (TypographyValues) {\n TypographyValues[\"FONT_FAMILY\"] = \"fontFamily\";\n TypographyValues[\"FONT_WEIGHT\"] = \"fontWeight\";\n TypographyValues[\"LINE_HEIGHT\"] = \"lineHeight\";\n TypographyValues[\"FONT_SIZE\"] = \"fontSize\";\n TypographyValues[\"LETTER_SPACING\"] = \"letterSpacing\";\n TypographyValues[\"PARAGRAPH_SPACING\"] = \"paragraphSpacing\";\n TypographyValues[\"PARAGRAPH_INDENT\"] = \"paragraphIndent\";\n TypographyValues[\"TEXT_DECORATION\"] = \"textDecoration\";\n TypographyValues[\"TEXT_CASE\"] = \"textCase\";\n})(TypographyValues || (TypographyValues = {}));\n\nexport { TypographyValues };\n","import type { ThemeObject } from '@tokens-studio/types';\nimport { TokenSetStatus } from '@tokens-studio/types';\n\ndeclare interface Options {\n separator?: string;\n}\n\nfunction mapThemesToSetsObject(themes: ThemeObject[]) {\n return Object.fromEntries(themes.map((theme) => [theme.name, filterTokenSets(theme.selectedTokenSets)]));\n}\n\nexport function permutateThemes(themes: ThemeObject[], { separator = '-' } = {} as Options): Record<string, string[]> {\n if (themes.some((theme) => theme.group)) {\n // Sort themes by groups\n const groups: Record<string, ThemeObject[]> = {};\n themes.forEach((theme) => {\n if (theme.group) {\n groups[theme.group] = [...(groups[theme.group] ?? []), theme];\n } else {\n throw new Error(\n `Theme ${theme.name} does not have a group property, which is required for multi-dimensional theming.`,\n );\n }\n });\n\n if (Object.keys(groups).length <= 1) {\n return mapThemesToSetsObject(themes);\n }\n\n // Create theme permutations\n const permutations = cartesian(Object.values(groups)) as Array<ThemeObject[]>;\n\n return Object.fromEntries(\n permutations.map((perm) => {\n // 1) concat the names of the theme groups to create the permutation theme name\n // 2) merge the selectedTokenSets together from the different theme group parts\n const reduced = perm.reduce(\n (acc, curr) => [\n // eslint-disable-next-line @typescript-eslint/restrict-template-expressions\n `${acc[0]}${acc[0] ? separator : ''}${curr.name}`,\n [...acc[1], ...filterTokenSets(curr.selectedTokenSets)],\n ],\n ['', [] as string[]],\n );\n\n // Dedupe the tokensets, return as entries [name, sets]\n return [reduced[0], [...new Set(reduced[1])]];\n }),\n ) as Record<string, string[]>;\n } else {\n return mapThemesToSetsObject(themes);\n }\n}\n\nfunction filterTokenSets(tokensets: Record<string, TokenSetStatus>) {\n return (\n Object.entries(tokensets)\n .filter(([, val]) => val !== TokenSetStatus.DISABLED)\n // ensure source type sets are always ordered before enabled type sets\n .sort((a, b) => {\n if (a[1] === TokenSetStatus.SOURCE && b[1] === TokenSetStatus.ENABLED) {\n return -1;\n } else if (a[1] === TokenSetStatus.ENABLED && b[1] === TokenSetStatus.SOURCE) {\n return 1;\n }\n return 0;\n })\n .map((entry) => entry[0])\n );\n}\n\n// cartesian permutations: [[1,2], [3,4]] -> [[1,3], [1,4], [2,3], [2,4]]\nfunction cartesian(a: Array<unknown[]>) {\n return a.reduce((a, b) => a.flatMap((d) => b.map((e) => [d, e].flat())));\n}\n"],"mappings":";AAAA,IAAI;AAAA,CACH,SAAUA,iBAAgB;AACvB,EAAAA,gBAAe,aAAa,IAAI;AAChC,EAAAA,gBAAe,cAAc,IAAI;AACrC,GAAG,mBAAmB,iBAAiB,CAAC,EAAE;;;ACJ1C,IAAI;AAAA,CACH,SAAUC,qBAAoB;AAC3B,EAAAA,oBAAmB,SAAS,IAAI;AAChC,EAAAA,oBAAmB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atus","TokenTypes","BorderValues","StrokeStyleValues","BoxShadowValues","TypographyValues","a"]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// src/tokens/utils/utils.ts
|
|
2
|
+
import * as R from "ramda";
|
|
3
|
+
var getType = (token) => (token.$type ?? token.type) || "";
|
|
4
|
+
var getValue = (token) => token.$value ?? token.value;
|
|
5
|
+
var typeEquals = (types, token) => {
|
|
6
|
+
if (R.isNil(token)) {
|
|
7
|
+
return false;
|
|
8
|
+
}
|
|
9
|
+
return R.includes(R.toLower(getType(token)), R.map(R.toLower, Array.isArray(types) ? types : [types]));
|
|
10
|
+
};
|
|
11
|
+
export {
|
|
12
|
+
getType,
|
|
13
|
+
getValue,
|
|
14
|
+
typeEquals
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/tokens/utils/utils.ts"],"sourcesContent":["import * as R from 'ramda';\nimport type { TransformedToken, DesignToken } from 'style-dictionary/types';\n\n/**\n * Returns type based on design token format used. Read more:https://v4.styledictionary.com/info/dtcg/\n * @param token Transformed token\n * @returns type\n */\nexport const getType = (token: TransformedToken) => ((token.$type ?? token.type) as string) || '';\n\n/**\n * Returns value based on design token format used. Read more:https://v4.styledictionary.com/info/dtcg/\n *\n * Use generic (`<T>`) to define return value type\n * @param token Transformed or Design token\n * @returns value\n */\nexport const getValue = <T>(token: TransformedToken | DesignToken): T => (token.$value ?? token.value) as T;\n\nexport const typeEquals = (types: string[] | string, token: TransformedToken) => {\n if (R.isNil(token)) {\n return false;\n }\n\n return R.includes(R.toLower(getType(token)), R.map(R.toLower, Array.isArray(types) ? types : [types]));\n};\n"],"mappings":";AAAA,YAAY,OAAO;AAQZ,IAAM,UAAU,CAAC,WAA8B,MAAM,SAAS,MAAM,SAAoB;AASxF,IAAM,WAAW,CAAI,UAA8C,MAAM,UAAU,MAAM;AAEzF,IAAM,aAAa,CAAC,OAA0B,UAA4B;AAC/E,MAAM,QAAM,KAAK,GAAG;AAClB,WAAO;AAAA,EACT;AAEA,SAAS,WAAW,UAAQ,QAAQ,KAAK,CAAC,GAAK,MAAM,WAAS,MAAM,QAAQ,KAAK,IAAI,QAAQ,CAAC,KAAK,CAAC,CAAC;AACvG;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@digdir/designsystemet",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.12",
|
|
4
4
|
"description": "CLI for Designsystemet",
|
|
5
5
|
"author": "Designsystemet team",
|
|
6
6
|
"repository": {
|
|
@@ -14,21 +14,35 @@
|
|
|
14
14
|
"./color": "./src/colors/index.ts"
|
|
15
15
|
},
|
|
16
16
|
"publishConfig": {
|
|
17
|
-
"access": "public"
|
|
17
|
+
"access": "public",
|
|
18
|
+
"bin": "dist/bin/designsystemet.js",
|
|
19
|
+
"exports": {
|
|
20
|
+
"./color": "./dist/src/colors/index.js"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"tsup": {
|
|
24
|
+
"entry": [
|
|
25
|
+
"bin/designsystemet.ts",
|
|
26
|
+
"src/**/*.ts"
|
|
27
|
+
],
|
|
28
|
+
"splitting": false,
|
|
29
|
+
"sourcemap": true,
|
|
30
|
+
"clean": true,
|
|
31
|
+
"format": [
|
|
32
|
+
"esm"
|
|
33
|
+
]
|
|
18
34
|
},
|
|
19
35
|
"scripts": {
|
|
20
36
|
"designsystemet": "tsx ./bin/designsystemet.ts",
|
|
21
37
|
"build:tokens": "yarn clean:theme && yarn designsystemet tokens -p -t ../../design-tokens -o ../../packages/theme/brand",
|
|
22
38
|
"build:tokens:debug": "yarn clean:theme && tsx --inspect-brk ./bin/designsystemet.ts tokens -p -t ../../design-tokens -o ../../packages/theme/brand",
|
|
23
|
-
"build": "
|
|
24
|
-
"prepublish:tsup": "yarn clean && tsup src/**/*.ts bin/designsystemet.ts --cjsInterop --shims --format esm",
|
|
25
|
-
"clean": "rimraf dist",
|
|
39
|
+
"build": "tsup",
|
|
26
40
|
"clean:theme": "yarn workspace @digdir/designsystemet-theme clean"
|
|
27
41
|
},
|
|
28
42
|
"files": [
|
|
29
43
|
"./dist/**"
|
|
30
44
|
],
|
|
31
|
-
"bin": "
|
|
45
|
+
"bin": "bin/designsystemet.js",
|
|
32
46
|
"dependencies": {
|
|
33
47
|
"@adobe/leonardo-contrast-colors": "^1.0.0",
|
|
34
48
|
"@commander-js/extra-typings": "^12.0.1",
|
|
@@ -43,8 +57,7 @@
|
|
|
43
57
|
"postcss": "^8.4.38",
|
|
44
58
|
"ramda": "^0.29.1",
|
|
45
59
|
"rimraf": "^5.0.5",
|
|
46
|
-
"style-dictionary": "^4.0.0-prerelease.34"
|
|
47
|
-
"tsup": "^8.0.2"
|
|
60
|
+
"style-dictionary": "^4.0.0-prerelease.34"
|
|
48
61
|
},
|
|
49
62
|
"devDependencies": {
|
|
50
63
|
"@types/fs-extra": "^11.0.4",
|
|
@@ -54,8 +67,8 @@
|
|
|
54
67
|
"@types/object-hash": "^3",
|
|
55
68
|
"@types/ramda": "^0.29.9",
|
|
56
69
|
"fs-extra": "^11.2.0",
|
|
70
|
+
"tsup": "^8.1.0",
|
|
57
71
|
"tsx": "^4.11.2",
|
|
58
72
|
"typescript": "^5.4.5"
|
|
59
|
-
}
|
|
60
|
-
"gitHead": "be57fec5efe257a06e072ad68713670c9511a119"
|
|
73
|
+
}
|
|
61
74
|
}
|
package/LICENSE
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
Copyright 2024 Digitaliseringsdirektoratet (Digdir)
|
|
2
|
-
|
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
|
-
|
|
5
|
-
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
|
-
|
|
7
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { Argument, program } from '@commander-js/extra-typings';
|
|
3
|
-
import chalk from 'chalk';
|
|
4
|
-
import migrations from './../src/migrations/index.js';
|
|
5
|
-
import { run } from './../src/tokens/build.js';
|
|
6
|
-
program.name('Designsystemet').description('CLI for working with Designsystemet');
|
|
7
|
-
program
|
|
8
|
-
.command('tokens')
|
|
9
|
-
.showHelpAfterError()
|
|
10
|
-
.description('run Designsystemet token builder')
|
|
11
|
-
.option('-t, --tokens [string]', `Path to ${chalk.blue('design-tokens')}`, './design-tokens')
|
|
12
|
-
.option('-o, --out [string]', `Output directory for built ${chalk.blue('design-tokens')}`, './dist/tokens')
|
|
13
|
-
.option('-p, --preview', 'Generate preview token.ts files', false)
|
|
14
|
-
.action((opts) => {
|
|
15
|
-
const tokens = typeof opts.tokens === 'string' ? opts.tokens : './design-tokens';
|
|
16
|
-
const out = typeof opts.out === 'string' ? opts.out : './dist/tokens';
|
|
17
|
-
const preview = opts.preview;
|
|
18
|
-
console.log(`Bulding tokens in ${chalk.green(tokens)}`);
|
|
19
|
-
return run({ tokens, out, preview });
|
|
20
|
-
});
|
|
21
|
-
program
|
|
22
|
-
.command('migrate')
|
|
23
|
-
.showHelpAfterError()
|
|
24
|
-
.description('run a Designsystemet migration')
|
|
25
|
-
.addArgument(new Argument('[migration]', 'Available migrations').choices(Object.keys(migrations)))
|
|
26
|
-
.option('-l --list', 'List available migrations')
|
|
27
|
-
.option('-g --glob <glob>', 'Glob for files upon which to apply the migration', './**/*.(tsx|css)')
|
|
28
|
-
.action((migrationKey, opts) => {
|
|
29
|
-
const { glob, list } = opts;
|
|
30
|
-
if (list) {
|
|
31
|
-
Object.keys(migrations).forEach((key) => {
|
|
32
|
-
console.log(key);
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
else if (migrationKey) {
|
|
36
|
-
const migration = migrations[migrationKey];
|
|
37
|
-
if (!migration) {
|
|
38
|
-
console.error('Migration not found!');
|
|
39
|
-
throw 'Aborting';
|
|
40
|
-
}
|
|
41
|
-
console.log(`Applying migration ${chalk.blue(migrationKey)} with glob: ${chalk.green(glob)}`);
|
|
42
|
-
migration?.(glob)
|
|
43
|
-
.then(() => console.log(`Migration ${chalk.blue(migrationKey)} finished`))
|
|
44
|
-
.catch((error) => console.log(error));
|
|
45
|
-
}
|
|
46
|
-
else {
|
|
47
|
-
console.log('Migrate: please specify a migration name or --list');
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
await program.parseAsync(process.argv);
|