@digdir/designsystemet 1.0.2 → 1.0.4
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 +4264 -45
- package/dist/bin/options.js +5 -4
- package/dist/src/colors/colorMetadata.d.ts.map +1 -1
- package/dist/src/colors/colorMetadata.js +84 -35
- package/dist/src/colors/index.js +470 -4
- package/dist/src/colors/theme.d.ts.map +1 -1
- package/dist/src/colors/theme.js +290 -18
- package/dist/src/colors/types.d.ts +4 -1
- package/dist/src/colors/types.d.ts.map +1 -1
- package/dist/src/colors/utils.js +16 -15
- package/dist/{bin → src}/config.d.ts +46 -1
- package/dist/src/config.d.ts.map +1 -0
- package/dist/src/config.js +377 -0
- package/dist/src/index.js +3666 -2
- package/dist/src/migrations/beta-to-v1.js +85 -4
- package/dist/src/migrations/codemods/css/plugins.js +5 -4
- package/dist/src/migrations/codemods/css/run.d.ts.map +1 -1
- package/dist/src/migrations/codemods/css/run.js +18 -4
- package/dist/src/migrations/color-rename-next49.js +77 -6
- package/dist/src/migrations/index.d.ts +0 -1
- package/dist/src/migrations/index.d.ts.map +1 -1
- package/dist/src/migrations/index.js +461 -6
- package/dist/src/scripts/createJsonSchema.js +1608 -4
- package/dist/src/scripts/update-design-tokens.d.ts +2 -0
- package/dist/src/scripts/update-design-tokens.d.ts.map +1 -0
- package/dist/src/scripts/update-design-tokens.js +36 -0
- package/dist/src/{tokens/template.d.ts → scripts/update-template.d.ts} +1 -1
- package/dist/src/scripts/update-template.d.ts.map +1 -0
- package/dist/src/scripts/update-template.js +1200 -0
- package/dist/src/tokens/build.d.ts +2 -19
- package/dist/src/tokens/build.d.ts.map +1 -1
- package/dist/src/tokens/build.js +1511 -70
- package/dist/src/tokens/create/defaults.d.ts +7 -0
- package/dist/src/tokens/create/defaults.d.ts.map +1 -0
- package/dist/src/tokens/create/defaults.js +994 -0
- package/dist/src/tokens/create/generators/$designsystemet.d.ts +5 -0
- package/dist/src/tokens/create/generators/$designsystemet.d.ts.map +1 -0
- package/dist/src/tokens/create/generators/$designsystemet.js +100 -0
- package/dist/src/tokens/create/generators/$metadata.d.ts +8 -0
- package/dist/src/tokens/create/generators/$metadata.d.ts.map +1 -0
- package/dist/src/tokens/{write/generate$metadata.js → create/generators/$metadata.js} +3 -2
- package/dist/src/tokens/create/generators/$themes.d.ts +12 -0
- package/dist/src/tokens/create/generators/$themes.d.ts.map +1 -0
- package/dist/src/tokens/create/generators/$themes.js +333 -0
- package/dist/src/tokens/create/generators/color.d.ts +5 -0
- package/dist/src/tokens/create/generators/color.d.ts.map +1 -0
- package/dist/src/tokens/create/generators/color.js +374 -0
- package/dist/src/tokens/create/generators/semantic.d.ts +296 -0
- package/dist/src/tokens/create/generators/semantic.d.ts.map +1 -0
- package/dist/src/tokens/create/generators/semantic.js +483 -0
- package/dist/src/tokens/create/generators/theme.d.ts +3 -0
- package/dist/src/tokens/create/generators/theme.d.ts.map +1 -0
- package/dist/src/tokens/create/generators/theme.js +168 -0
- package/dist/src/tokens/create/generators/typography.d.ts +3 -0
- package/dist/src/tokens/create/generators/typography.d.ts.map +1 -0
- package/dist/src/tokens/create/generators/typography.js +33 -0
- package/dist/src/tokens/{write.d.ts → create/write.d.ts} +2 -2
- package/dist/src/tokens/create/write.d.ts.map +1 -0
- package/dist/src/tokens/create/write.js +546 -0
- package/dist/src/tokens/create.d.ts +4 -2
- package/dist/src/tokens/create.d.ts.map +1 -1
- package/dist/src/tokens/create.js +2049 -59
- package/dist/src/tokens/format.d.ts +16 -0
- package/dist/src/tokens/format.d.ts.map +1 -0
- package/dist/src/tokens/format.js +3514 -0
- package/dist/src/tokens/index.d.ts +1 -0
- package/dist/src/tokens/index.d.ts.map +1 -1
- package/dist/src/tokens/index.js +3526 -2
- package/dist/src/tokens/process/configs/color.d.ts +12 -0
- package/dist/src/tokens/process/configs/color.d.ts.map +1 -0
- package/dist/src/tokens/process/configs/color.js +823 -0
- package/dist/src/tokens/process/configs/semantic.d.ts +3 -0
- package/dist/src/tokens/process/configs/semantic.d.ts.map +1 -0
- package/dist/src/tokens/process/configs/semantic.js +367 -0
- package/dist/src/tokens/process/configs/shared.d.ts +10 -0
- package/dist/src/tokens/process/configs/shared.d.ts.map +1 -0
- package/dist/src/tokens/process/configs/shared.js +99 -0
- package/dist/src/tokens/process/configs/storefront.d.ts +3 -0
- package/dist/src/tokens/process/configs/storefront.d.ts.map +1 -0
- package/dist/src/tokens/process/configs/storefront.js +220 -0
- package/dist/src/tokens/process/configs/typography.d.ts +3 -0
- package/dist/src/tokens/process/configs/typography.d.ts.map +1 -0
- package/dist/src/tokens/process/configs/typography.js +369 -0
- package/dist/src/tokens/{build → process}/configs.d.ts +3 -11
- package/dist/src/tokens/process/configs.d.ts.map +1 -0
- package/dist/src/tokens/process/configs.js +976 -0
- package/dist/src/tokens/process/formats/css/color.d.ts +4 -0
- package/dist/src/tokens/process/formats/css/color.d.ts.map +1 -0
- package/dist/src/tokens/process/formats/css/color.js +128 -0
- package/dist/src/tokens/process/formats/css/semantic.d.ts +17 -0
- package/dist/src/tokens/process/formats/css/semantic.d.ts.map +1 -0
- package/dist/src/tokens/process/formats/css/semantic.js +109 -0
- package/dist/src/tokens/process/formats/css/typography.d.ts +3 -0
- package/dist/src/tokens/process/formats/css/typography.d.ts.map +1 -0
- package/dist/src/tokens/process/formats/css/typography.js +32 -0
- package/dist/src/tokens/process/formats/css.d.ts +8 -0
- package/dist/src/tokens/process/formats/css.d.ts.map +1 -0
- package/dist/src/tokens/{build → process}/formats/css.js +94 -57
- package/dist/src/tokens/process/formats/js-tokens.d.ts.map +1 -0
- package/dist/src/tokens/process/formats/js-tokens.js +109 -0
- package/dist/src/tokens/process/platform.d.ts +87 -0
- package/dist/src/tokens/process/platform.d.ts.map +1 -0
- package/dist/src/tokens/process/platform.js +1090 -0
- package/dist/src/tokens/process/transformers.d.ts.map +1 -0
- package/dist/src/tokens/{build → process}/transformers.js +29 -6
- package/dist/src/tokens/{build → process}/utils/getMultidimensionalThemes.d.ts +3 -3
- package/dist/src/tokens/process/utils/getMultidimensionalThemes.d.ts.map +1 -0
- package/dist/src/tokens/process/utils/getMultidimensionalThemes.js +922 -0
- package/dist/src/tokens/template/design-tokens/primitives/globals.js +5 -0
- package/dist/src/tokens/template/design-tokens/primitives/modes/size/global.js +5 -0
- package/dist/src/tokens/template/design-tokens/primitives/modes/size/large.js +5 -0
- package/dist/src/tokens/template/design-tokens/primitives/modes/size/medium.js +5 -0
- package/dist/src/tokens/template/design-tokens/primitives/modes/size/small.js +5 -0
- package/dist/src/tokens/template/design-tokens/primitives/modes/typography/size/large.js +5 -0
- package/dist/src/tokens/template/design-tokens/primitives/modes/typography/size/medium.js +5 -0
- package/dist/src/tokens/template/design-tokens/primitives/modes/typography/size/small.js +5 -0
- package/dist/src/tokens/template/design-tokens/primitives/modes/typography/typography.template.js +5 -0
- package/dist/src/tokens/template/design-tokens/semantic/color.base.template.js +5 -0
- package/dist/src/tokens/template/design-tokens/semantic/color.template.js +5 -0
- package/dist/src/tokens/template/design-tokens/semantic/modes/color.template.js +5 -0
- package/dist/src/tokens/template/design-tokens/semantic/style.js +5 -0
- package/dist/src/tokens/template/design-tokens/themes/theme.base.template.js +5 -0
- package/dist/src/tokens/template/design-tokens/themes/theme.template.js +5 -0
- package/dist/src/tokens/types.d.ts +54 -38
- package/dist/src/tokens/types.d.ts.map +1 -1
- package/dist/src/tokens/types.js +8 -0
- package/dist/src/tokens/utils.d.ts +30 -5
- package/dist/src/tokens/utils.d.ts.map +1 -1
- package/dist/src/tokens/utils.js +36 -50
- package/dist/src/utils.d.ts +18 -0
- package/dist/src/utils.d.ts.map +1 -0
- package/dist/src/utils.js +63 -0
- package/dist/typography.template-4N5YLH7F.json +22 -0
- package/package.json +17 -16
- package/dist/bin/config.d.ts.map +0 -1
- package/dist/bin/config.js +0 -71
- package/dist/src/migrations/codemods/jsx/classname-prefix.d.ts +0 -10
- package/dist/src/migrations/codemods/jsx/classname-prefix.d.ts.map +0 -1
- package/dist/src/migrations/codemods/jsx/classname-prefix.js +0 -64
- package/dist/src/migrations/codemods/jsx/run.d.ts +0 -7
- package/dist/src/migrations/codemods/jsx/run.d.ts.map +0 -1
- package/dist/src/migrations/codemods/jsx/run.js +0 -22
- package/dist/src/migrations/react-beta-to-v1.d.ts +0 -3
- package/dist/src/migrations/react-beta-to-v1.d.ts.map +0 -1
- package/dist/src/migrations/react-beta-to-v1.js +0 -5
- package/dist/src/scripts/copy-internal-tokens.d.ts +0 -2
- package/dist/src/scripts/copy-internal-tokens.d.ts.map +0 -1
- package/dist/src/scripts/copy-internal-tokens.js +0 -28
- package/dist/src/tokens/build/configs.d.ts.map +0 -1
- package/dist/src/tokens/build/configs.js +0 -280
- package/dist/src/tokens/build/formats/css.d.ts +0 -53
- package/dist/src/tokens/build/formats/css.d.ts.map +0 -1
- package/dist/src/tokens/build/formats/js-tokens.d.ts.map +0 -1
- package/dist/src/tokens/build/formats/js-tokens.js +0 -48
- package/dist/src/tokens/build/transformers.d.ts.map +0 -1
- package/dist/src/tokens/build/types.d.ts +0 -48
- package/dist/src/tokens/build/types.d.ts.map +0 -1
- package/dist/src/tokens/build/types.js +0 -7
- package/dist/src/tokens/build/utils/entryfile.d.ts +0 -12
- package/dist/src/tokens/build/utils/entryfile.d.ts.map +0 -1
- package/dist/src/tokens/build/utils/entryfile.js +0 -67
- package/dist/src/tokens/build/utils/getMultidimensionalThemes.d.ts.map +0 -1
- package/dist/src/tokens/build/utils/getMultidimensionalThemes.js +0 -112
- package/dist/src/tokens/design-tokens/template/$metadata.json +0 -25
- package/dist/src/tokens/design-tokens/template/$themes.json +0 -1498
- package/dist/src/tokens/template.d.ts.map +0 -1
- package/dist/src/tokens/template.js +0 -99
- package/dist/src/tokens/write/generate$metadata.d.ts +0 -9
- package/dist/src/tokens/write/generate$metadata.d.ts.map +0 -1
- package/dist/src/tokens/write/generate$themes.d.ts +0 -12
- package/dist/src/tokens/write/generate$themes.d.ts.map +0 -1
- package/dist/src/tokens/write/generate$themes.js +0 -161
- package/dist/src/tokens/write.d.ts.map +0 -1
- package/dist/src/tokens/write.js +0 -177
- /package/dist/{src/tokens/design-tokens/template/semantic/color-base-file.json → color.base.template-M7BHS4OV.json} +0 -0
- /package/dist/{src/tokens/design-tokens/template/semantic/modes/category-color/category-color-template.json → color.template-LMPUQ72A.json} +0 -0
- /package/dist/{src/tokens/design-tokens/template/semantic/semantic-color-template.json → color.template-XQNSHLTU.json} +0 -0
- /package/dist/{src/tokens/design-tokens/default/primitives/modes/size/global.json → global-XVXVBKM6.json} +0 -0
- /package/dist/{src/tokens/design-tokens/default/primitives/globals.json → globals-76VAFMDF.json} +0 -0
- /package/dist/{src/tokens/design-tokens/default/primitives/modes/typography/size/large.json → large-CIIHO7AY.json} +0 -0
- /package/dist/{src/tokens/design-tokens/default/primitives/modes/size/large.json → large-UUOZ6DYI.json} +0 -0
- /package/dist/{src/tokens/design-tokens/default/primitives/modes/size/medium.json → medium-OQ7S7P4P.json} +0 -0
- /package/dist/{src/tokens/design-tokens/default/primitives/modes/typography/size/medium.json → medium-VSB2S4X3.json} +0 -0
- /package/dist/{src/tokens/design-tokens/default/primitives/modes/typography/size/small.json → small-AEXJ6U7Z.json} +0 -0
- /package/dist/{src/tokens/design-tokens/default/primitives/modes/size/small.json → small-ZY4KOJWX.json} +0 -0
- /package/dist/src/tokens/{build → process}/formats/js-tokens.d.ts +0 -0
- /package/dist/src/tokens/{build → process}/transformers.d.ts +0 -0
- /package/dist/{src/tokens/design-tokens/default/semantic/style.json → style-FP5XVCUD.json} +0 -0
- /package/dist/{src/tokens/design-tokens/template/themes/theme-base-file.json → theme.base.template-Y4RMFBQY.json} +0 -0
- /package/dist/{src/tokens/design-tokens/template/themes/theme-color-template.json → theme.template-CTQRNOMO.json} +0 -0
package/dist/bin/config.js
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import * as R from "ramda";
|
|
2
|
-
import { z } from "zod";
|
|
3
|
-
import { convertToHex } from "../src/colors/index.js";
|
|
4
|
-
import { RESERVED_COLORS } from "../src/colors/theme.js";
|
|
5
|
-
import { cliOptions } from "../src/tokens/create.js";
|
|
6
|
-
function mapPathToOptionName(path) {
|
|
7
|
-
const normalisedPath = path[0] === "themes" ? ["theme", ...R.drop(2, path)] : path;
|
|
8
|
-
const option = R.path(normalisedPath, cliOptions);
|
|
9
|
-
if (typeof option !== "string") {
|
|
10
|
-
return;
|
|
11
|
-
}
|
|
12
|
-
return option;
|
|
13
|
-
}
|
|
14
|
-
const hexPatterns = [
|
|
15
|
-
// Hex colors: #000, #0000, #000000, #00000000
|
|
16
|
-
`#[0-9a-fA-F]{3}`,
|
|
17
|
-
`#[0-9a-fA-F]{4}`,
|
|
18
|
-
`#[0-9a-fA-F]{6}`,
|
|
19
|
-
`#[0-9a-fA-F]{8}`
|
|
20
|
-
];
|
|
21
|
-
const reservedColorsPattern = `^(?!(?:${RESERVED_COLORS.join("|")})$)`;
|
|
22
|
-
const colorRegex = new RegExp(`^${hexPatterns.join("|")}$`);
|
|
23
|
-
const colorSchema = z.string({
|
|
24
|
-
description: `A hex color, which is used for creating a color scale. Invalid color names: ${RESERVED_COLORS.join(", ")}`
|
|
25
|
-
}).regex(colorRegex).transform(convertToHex);
|
|
26
|
-
const colorCategorySchema = z.record(
|
|
27
|
-
z.string().regex(new RegExp(reservedColorsPattern, "i"), {
|
|
28
|
-
message: `Color names cannot include reserved names: ${RESERVED_COLORS.join(", ")}`
|
|
29
|
-
}),
|
|
30
|
-
colorSchema,
|
|
31
|
-
{
|
|
32
|
-
description: "One or more color definitions",
|
|
33
|
-
invalid_type_error: "Color definitions must be hex color values"
|
|
34
|
-
}
|
|
35
|
-
).refine((colors) => !Object.keys(colors).some((key) => RESERVED_COLORS.includes(key.toLowerCase())), {
|
|
36
|
-
message: `Color names cannot include reserved names: ${RESERVED_COLORS.join(", ")}`
|
|
37
|
-
});
|
|
38
|
-
const themeSchema = z.object(
|
|
39
|
-
{
|
|
40
|
-
colors: z.object(
|
|
41
|
-
{
|
|
42
|
-
main: colorCategorySchema,
|
|
43
|
-
support: colorCategorySchema.optional().default({}),
|
|
44
|
-
neutral: colorSchema
|
|
45
|
-
},
|
|
46
|
-
{ description: "Defines the colors for this theme" }
|
|
47
|
-
),
|
|
48
|
-
typography: z.object(
|
|
49
|
-
{
|
|
50
|
-
fontFamily: z.string({ description: "Sets the font-family for this theme" })
|
|
51
|
-
},
|
|
52
|
-
{ description: "Defines the typography for a given theme" }
|
|
53
|
-
).optional(),
|
|
54
|
-
borderRadius: z.number({ description: "Defines the border-radius for this theme" }).optional()
|
|
55
|
-
},
|
|
56
|
-
{ description: "An object defining a theme. The property name holding the object becomes the theme name." }
|
|
57
|
-
);
|
|
58
|
-
const configFileSchema = z.object({
|
|
59
|
-
outDir: z.string({ description: "Path to the output directory for the created design tokens" }).optional(),
|
|
60
|
-
clean: z.boolean({ description: "Delete the output directory before building or creating tokens" }).optional(),
|
|
61
|
-
themes: z.record(themeSchema, {
|
|
62
|
-
description: "An object with one or more themes. Each property defines a theme, and the property name is used as the theme name."
|
|
63
|
-
})
|
|
64
|
-
});
|
|
65
|
-
const combinedConfigSchema = configFileSchema.required();
|
|
66
|
-
export {
|
|
67
|
-
colorRegex,
|
|
68
|
-
combinedConfigSchema,
|
|
69
|
-
configFileSchema,
|
|
70
|
-
mapPathToOptionName
|
|
71
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { API, FileInfo } from 'jscodeshift';
|
|
2
|
-
/**
|
|
3
|
-
* Replace all class prefixes from 'fds-' to 'ds-'
|
|
4
|
-
* @param file
|
|
5
|
-
* @param api
|
|
6
|
-
* @returns
|
|
7
|
-
*/
|
|
8
|
-
declare function replaceClassNamePrefix(file: FileInfo, api: API): string | undefined;
|
|
9
|
-
export default replaceClassNamePrefix;
|
|
10
|
-
//# sourceMappingURL=classname-prefix.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"classname-prefix.d.ts","sourceRoot":"","sources":["../../../../../src/migrations/codemods/jsx/classname-prefix.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAmB,MAAM,aAAa,CAAC;AAoElE;;;;;GAKG;AACH,iBAAS,sBAAsB,CAAC,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAG,GAAG,MAAM,GAAG,SAAS,CAiB5E;AAED,eAAe,sBAAsB,CAAC"}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
const replaceInLiteral = (node) => {
|
|
2
|
-
if (node.startsWith("fds-")) {
|
|
3
|
-
return node.replace("fds-", "ds-");
|
|
4
|
-
}
|
|
5
|
-
return node;
|
|
6
|
-
};
|
|
7
|
-
const replaceInTemplateLiteral = (node) => {
|
|
8
|
-
for (const element of node) {
|
|
9
|
-
const value = element.value.raw;
|
|
10
|
-
if (typeof value !== "string") continue;
|
|
11
|
-
element.value.raw = replaceInLiteral(value);
|
|
12
|
-
}
|
|
13
|
-
};
|
|
14
|
-
const processNode = (node) => {
|
|
15
|
-
if (!node) return;
|
|
16
|
-
if (node.type === "Literal") {
|
|
17
|
-
const value = node.value;
|
|
18
|
-
if (typeof value !== "string") return;
|
|
19
|
-
node.value = replaceInLiteral(value);
|
|
20
|
-
} else if (node.type === "StringLiteral") {
|
|
21
|
-
const value = node.value;
|
|
22
|
-
if (typeof value !== "string") return;
|
|
23
|
-
node.value = replaceInLiteral(value);
|
|
24
|
-
} else if (node.type === "TemplateLiteral") {
|
|
25
|
-
node.quasis && replaceInTemplateLiteral(node.quasis);
|
|
26
|
-
} else if (node.type === "JSXExpressionContainer") {
|
|
27
|
-
const expression = node.expression;
|
|
28
|
-
if (!expression) return;
|
|
29
|
-
if (expression.type === "CallExpression") {
|
|
30
|
-
expression.arguments?.forEach(processNode);
|
|
31
|
-
} else {
|
|
32
|
-
processNode(expression);
|
|
33
|
-
}
|
|
34
|
-
} else if (node.type === "ConditionalExpression") {
|
|
35
|
-
node.test && processNode(node.test);
|
|
36
|
-
node.consequent && processNode(node.consequent);
|
|
37
|
-
node.alternate && processNode(node.alternate);
|
|
38
|
-
} else if (node.type === "BinaryExpression") {
|
|
39
|
-
node.right && processNode(node.right);
|
|
40
|
-
node.left && processNode(node.left);
|
|
41
|
-
} else if (node.type === "LogicalExpression") {
|
|
42
|
-
node.right && processNode(node.right);
|
|
43
|
-
node.left && processNode(node.left);
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
function replaceClassNamePrefix(file, api) {
|
|
47
|
-
const j = api.jscodeshift;
|
|
48
|
-
const root = j(file.source);
|
|
49
|
-
for (const path of root.find(j.JSXElement).paths()) {
|
|
50
|
-
const nodes = j(path).find(j.JSXAttribute, { name: { name: "className" } });
|
|
51
|
-
for (const nodePath of nodes.paths()) {
|
|
52
|
-
processNode(nodePath.value.value);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
return root.toSource({
|
|
56
|
-
quote: "single",
|
|
57
|
-
reuseWhitespace: true,
|
|
58
|
-
wrapColumn: 100
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
var classname_prefix_default = replaceClassNamePrefix;
|
|
62
|
-
export {
|
|
63
|
-
classname_prefix_default as default
|
|
64
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../../../../src/migrations/codemods/jsx/run.ts"],"names":[],"mappings":"AAKA,KAAK,eAAe,GAAG;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,GAAG,CAAC,EAAE,OAAO,CAAC;CACf,CAAC;AAIF,eAAO,MAAM,aAAa,GAAU,sBAAqC,eAAe,kBAiBvF,CAAC"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import chalk from "chalk";
|
|
2
|
-
import glob from "fast-glob";
|
|
3
|
-
import { run as jscodeshift } from "jscodeshift/src/Runner.js";
|
|
4
|
-
const transformer = `${import.meta.dirname}/classname-prefix.ts`;
|
|
5
|
-
const runJSXCodemod = async ({ globPattern = "./**/*.tsx", dry }) => {
|
|
6
|
-
const options = {
|
|
7
|
-
dry,
|
|
8
|
-
extensions: "tsx",
|
|
9
|
-
parser: "tsx"
|
|
10
|
-
};
|
|
11
|
-
const transform = async () => {
|
|
12
|
-
const files = await glob(globPattern, { ignore: ["node_modules/**", "dist/**"] });
|
|
13
|
-
const result = await jscodeshift(transformer, files, options);
|
|
14
|
-
if (result.ok) {
|
|
15
|
-
console.log(chalk.green("Finished parsing"));
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
return transform();
|
|
19
|
-
};
|
|
20
|
-
export {
|
|
21
|
-
runJSXCodemod
|
|
22
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"react-beta-to-v1.d.ts","sourceRoot":"","sources":["../../../src/migrations/react-beta-to-v1.ts"],"names":[],"mappings":"yBAEgB,OAAO,MAAM;AAA7B,wBAAuE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"copy-internal-tokens.d.ts","sourceRoot":"","sources":["../../../src/scripts/copy-internal-tokens.ts"],"names":[],"mappings":""}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import fs from "node:fs/promises";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
const DIRNAME = import.meta.dirname || __dirname;
|
|
4
|
-
const TARGET = path.join(DIRNAME, "../../../../design-tokens");
|
|
5
|
-
const INTERNAL = path.join(DIRNAME, "../../internal/design-tokens");
|
|
6
|
-
async function copyFiles() {
|
|
7
|
-
console.log("\u{1F4C1} Copying design tokens");
|
|
8
|
-
await fs.cp(
|
|
9
|
-
path.join(INTERNAL, "primitives/modes/color-scheme"),
|
|
10
|
-
path.join(TARGET, "primitives/modes/color-scheme"),
|
|
11
|
-
{ recursive: true }
|
|
12
|
-
);
|
|
13
|
-
await fs.cp(path.join(INTERNAL, "primitives/modes/size"), path.join(TARGET, "primitives/modes/size"), {
|
|
14
|
-
recursive: true
|
|
15
|
-
});
|
|
16
|
-
await fs.cp(
|
|
17
|
-
path.join(INTERNAL, "primitives/modes/typography/size"),
|
|
18
|
-
path.join(TARGET, "primitives/modes/typography/size"),
|
|
19
|
-
{
|
|
20
|
-
recursive: true
|
|
21
|
-
}
|
|
22
|
-
);
|
|
23
|
-
await fs.cp(path.join(INTERNAL, "primitives/globals.json"), path.join(TARGET, "primitives/globals.json"));
|
|
24
|
-
await fs.cp(path.join(INTERNAL, "semantic"), path.join(TARGET, "semantic"), { recursive: true });
|
|
25
|
-
await fs.cp(path.join(INTERNAL, "themes"), path.join(TARGET, "themes"), { recursive: true });
|
|
26
|
-
console.log("\u2705 Finished copying design tokens");
|
|
27
|
-
}
|
|
28
|
-
copyFiles();
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"configs.d.ts","sourceRoot":"","sources":["../../../../src/tokens/build/configs.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,IAAI,qBAAqB,EAAoB,MAAM,wBAAwB,CAAC;AAQhG,OAAO,KAAK,EAGV,kBAAkB,EAClB,2BAA2B,EAC3B,cAAc,EACd,gBAAgB,EACjB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,KAAK,oBAAoB,EAA6B,MAAM,sCAAsC,CAAC;AAO5G,eAAO,MAAM,MAAM,OAAO,CAAC;AAC3B,eAAO,MAAM,cAAc,KAAK,CAAC;AA8BjC,MAAM,MAAM,wBAAwB,GAAG,CACrC,WAAW,EAAE,gBAAgB,EAC7B,OAAO,EAAE;IACP,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,KACE,qBAAqB,GAAG;IAAE,MAAM,EAAE,qBAAqB,CAAC;IAAC,oBAAoB,CAAC,EAAE,OAAO,CAAC,gBAAgB,CAAC,CAAA;CAAE,EAAE,CAAC;AA2OnH,eAAO,MAAM,OAAO;;;;;;;;;;;;CAYnB,CAAC;AAEF,eAAO,MAAM,4BAA4B,GACvC,WAAW,wBAAwB,EACnC,QAAQ,oBAAoB,EAAE,EAC9B,YAAY,cAAc,EAAE,EAC5B,SAAS,kBAAkB,KAC1B,2BAA2B,EA8B7B,CAAC"}
|
|
@@ -1,280 +0,0 @@
|
|
|
1
|
-
import { expandTypesMap, register } from "@tokens-studio/sd-transforms";
|
|
2
|
-
import * as R from "ramda";
|
|
3
|
-
import StyleDictionary from "style-dictionary";
|
|
4
|
-
import { outputReferencesFilter } from "style-dictionary/utils";
|
|
5
|
-
import { buildOptions } from "../build.js";
|
|
6
|
-
import { isColorCategoryToken, isDigit, isSemanticColorToken, pathStartsWithOneOf, typeEquals } from "../utils.js";
|
|
7
|
-
import { formats } from "./formats/css.js";
|
|
8
|
-
import { jsTokens } from "./formats/js-tokens.js";
|
|
9
|
-
import { resolveMath, sizeRem, typographyName, unitless } from "./transformers.js";
|
|
10
|
-
import { getMultidimensionalThemes } from "./utils/getMultidimensionalThemes.js";
|
|
11
|
-
void register(StyleDictionary, { withSDBuiltins: false });
|
|
12
|
-
const usesDtcg = true;
|
|
13
|
-
const prefix = "ds";
|
|
14
|
-
const basePxFontSize = 16;
|
|
15
|
-
const fileHeader = () => [`These files are generated from design tokens defind using Token Studio`];
|
|
16
|
-
StyleDictionary.registerTransform(sizeRem);
|
|
17
|
-
StyleDictionary.registerTransform(typographyName);
|
|
18
|
-
StyleDictionary.registerTransform(resolveMath);
|
|
19
|
-
StyleDictionary.registerTransform(unitless);
|
|
20
|
-
StyleDictionary.registerFormat(jsTokens);
|
|
21
|
-
for (const format of Object.values(formats)) {
|
|
22
|
-
StyleDictionary.registerFormat(format);
|
|
23
|
-
}
|
|
24
|
-
const dsTransformers = [
|
|
25
|
-
"name/kebab",
|
|
26
|
-
resolveMath.name,
|
|
27
|
-
"ts/size/px",
|
|
28
|
-
sizeRem.name,
|
|
29
|
-
unitless.name,
|
|
30
|
-
"ts/typography/fontWeight",
|
|
31
|
-
typographyName.name,
|
|
32
|
-
"ts/color/modifiers",
|
|
33
|
-
"ts/color/css/hexrgba",
|
|
34
|
-
"ts/size/lineheight",
|
|
35
|
-
"shadow/css/shorthand"
|
|
36
|
-
];
|
|
37
|
-
const paritionPrimitives = R.partition(R.test(/(?!.*global\.json).*primitives.*/));
|
|
38
|
-
const colorSchemeVariables = ({ "color-scheme": colorScheme = "light", theme }, { outPath }) => {
|
|
39
|
-
const selector = `${colorScheme === "light" ? ":root, " : ""}[data-color-scheme="${colorScheme}"]`;
|
|
40
|
-
const layer = `ds.theme.color-scheme.${colorScheme}`;
|
|
41
|
-
return {
|
|
42
|
-
usesDtcg,
|
|
43
|
-
preprocessors: ["tokens-studio"],
|
|
44
|
-
platforms: {
|
|
45
|
-
css: {
|
|
46
|
-
// custom
|
|
47
|
-
outPath,
|
|
48
|
-
colorScheme,
|
|
49
|
-
theme,
|
|
50
|
-
selector,
|
|
51
|
-
layer,
|
|
52
|
-
//
|
|
53
|
-
prefix,
|
|
54
|
-
buildPath: `${outPath}/${theme}/`,
|
|
55
|
-
transforms: dsTransformers,
|
|
56
|
-
files: [
|
|
57
|
-
{
|
|
58
|
-
destination: `color-scheme/${colorScheme}.css`,
|
|
59
|
-
format: formats.colorScheme.name,
|
|
60
|
-
filter: (token) => !token.isSource && typeEquals("color", token) && !R.startsWith(["global"], token.path)
|
|
61
|
-
}
|
|
62
|
-
],
|
|
63
|
-
options: {
|
|
64
|
-
fileHeader,
|
|
65
|
-
outputReferences: false
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
};
|
|
71
|
-
const colorCategoryVariables = (opts) => ({ "color-scheme": colorScheme, theme, ...permutation }, { outPath }) => {
|
|
72
|
-
const category = opts.category;
|
|
73
|
-
const color = category === "builtin" ? opts.color : permutation[`${category}-color`];
|
|
74
|
-
if (!color) {
|
|
75
|
-
throw new Error(
|
|
76
|
-
category === "builtin" ? `Missing color for built-in color ${opts.color}` : `Missing color for category ${category}`
|
|
77
|
-
);
|
|
78
|
-
}
|
|
79
|
-
const layer = `ds.theme.color`;
|
|
80
|
-
const isRootColor = color === buildOptions?.rootColor;
|
|
81
|
-
const selector = `${isRootColor ? ":root, [data-color-scheme], " : ""}[data-color="${color}"]`;
|
|
82
|
-
const config = {
|
|
83
|
-
usesDtcg,
|
|
84
|
-
preprocessors: ["tokens-studio"],
|
|
85
|
-
platforms: {
|
|
86
|
-
css: {
|
|
87
|
-
// custom
|
|
88
|
-
outPath,
|
|
89
|
-
colorScheme,
|
|
90
|
-
theme,
|
|
91
|
-
selector,
|
|
92
|
-
layer,
|
|
93
|
-
//
|
|
94
|
-
prefix,
|
|
95
|
-
buildPath: `${outPath}/${theme}/`,
|
|
96
|
-
transforms: dsTransformers,
|
|
97
|
-
files: [
|
|
98
|
-
{
|
|
99
|
-
destination: `color/${color}.css`,
|
|
100
|
-
format: formats.colorCategory.name,
|
|
101
|
-
filter: (token) => category === "builtin" ? isSemanticColorToken(token, color) : isColorCategoryToken(token, category)
|
|
102
|
-
}
|
|
103
|
-
],
|
|
104
|
-
options: {
|
|
105
|
-
fileHeader,
|
|
106
|
-
outputReferences: true
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
};
|
|
111
|
-
return config;
|
|
112
|
-
};
|
|
113
|
-
const semanticVariables = ({ theme }, { outPath }) => {
|
|
114
|
-
const selector = `:root`;
|
|
115
|
-
const layer = `ds.theme.semantic`;
|
|
116
|
-
return {
|
|
117
|
-
usesDtcg,
|
|
118
|
-
preprocessors: ["tokens-studio"],
|
|
119
|
-
platforms: {
|
|
120
|
-
css: {
|
|
121
|
-
// custom
|
|
122
|
-
outPath,
|
|
123
|
-
theme,
|
|
124
|
-
basePxFontSize,
|
|
125
|
-
selector,
|
|
126
|
-
layer,
|
|
127
|
-
//
|
|
128
|
-
prefix,
|
|
129
|
-
buildPath: `${outPath}/${theme}/`,
|
|
130
|
-
transforms: dsTransformers,
|
|
131
|
-
files: [
|
|
132
|
-
{
|
|
133
|
-
destination: `semantic.css`,
|
|
134
|
-
format: formats.semantic.name,
|
|
135
|
-
filter: (token) => {
|
|
136
|
-
const unwantedPaths = pathStartsWithOneOf(["font-size", "line-height", "letter-spacing"], token);
|
|
137
|
-
const unwantedTypes = typeEquals(["color", "fontWeight", "fontFamily", "typography"], token);
|
|
138
|
-
const unwantedTokens = !(unwantedPaths || unwantedTypes);
|
|
139
|
-
return !token.isSource && unwantedTokens;
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
],
|
|
143
|
-
options: {
|
|
144
|
-
fileHeader,
|
|
145
|
-
outputReferences: (token, options) => {
|
|
146
|
-
const include = pathStartsWithOneOf(["border-radius"], token);
|
|
147
|
-
const isWantedSize = pathStartsWithOneOf(["size", "_size"], token) && isDigit(token.path[1]);
|
|
148
|
-
return (include || isWantedSize) && outputReferencesFilter(token, options);
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
};
|
|
154
|
-
};
|
|
155
|
-
const typescriptTokens = ({ "color-scheme": colorScheme, theme }, { outPath }) => {
|
|
156
|
-
return {
|
|
157
|
-
usesDtcg,
|
|
158
|
-
preprocessors: ["tokens-studio"],
|
|
159
|
-
platforms: {
|
|
160
|
-
ts: {
|
|
161
|
-
prefix,
|
|
162
|
-
basePxFontSize,
|
|
163
|
-
transforms: dsTransformers,
|
|
164
|
-
buildPath: `${outPath}/${theme}/`,
|
|
165
|
-
files: [
|
|
166
|
-
{
|
|
167
|
-
destination: `${colorScheme}.ts`,
|
|
168
|
-
format: jsTokens.name,
|
|
169
|
-
filter: (token) => {
|
|
170
|
-
if (pathStartsWithOneOf(["border-width", "letter-spacing", "border-radius"], token) && !R.includes("semantic", token.filePath))
|
|
171
|
-
return false;
|
|
172
|
-
const isSemanticColor = R.includes("semantic", token.filePath) && typeEquals(["color"], token);
|
|
173
|
-
const wantedTypes = typeEquals(["shadow", "dimension", "typography", "opacity"], token);
|
|
174
|
-
return isSemanticColor || wantedTypes;
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
],
|
|
178
|
-
options: {
|
|
179
|
-
fileHeader,
|
|
180
|
-
outputReferences: (token, options) => {
|
|
181
|
-
const include = pathStartsWithOneOf(["border-radius"], token);
|
|
182
|
-
const isWantedSize = pathStartsWithOneOf(["size", "_size"], token) && isDigit(token.path[1]);
|
|
183
|
-
return (include || isWantedSize) && outputReferencesFilter(token, options);
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
};
|
|
189
|
-
};
|
|
190
|
-
const typographyVariables = ({ theme, typography }, { outPath }) => {
|
|
191
|
-
const selector = `${typography === "primary" ? ":root, " : ""}[data-typography="${typography}"]`;
|
|
192
|
-
const layer = `ds.theme.typography.${typography}`;
|
|
193
|
-
return {
|
|
194
|
-
usesDtcg: true,
|
|
195
|
-
preprocessors: ["tokens-studio"],
|
|
196
|
-
expand: {
|
|
197
|
-
include: ["typography"],
|
|
198
|
-
typesMap: { ...expandTypesMap, typography: { ...expandTypesMap.typography, letterSpacing: "dimension" } }
|
|
199
|
-
},
|
|
200
|
-
platforms: {
|
|
201
|
-
css: {
|
|
202
|
-
prefix,
|
|
203
|
-
typography,
|
|
204
|
-
selector,
|
|
205
|
-
layer,
|
|
206
|
-
buildPath: `${outPath}/${theme}/`,
|
|
207
|
-
basePxFontSize,
|
|
208
|
-
transforms: [
|
|
209
|
-
"name/kebab",
|
|
210
|
-
"ts/size/px",
|
|
211
|
-
sizeRem.name,
|
|
212
|
-
"ts/size/lineheight",
|
|
213
|
-
"ts/typography/fontWeight",
|
|
214
|
-
typographyName.name
|
|
215
|
-
],
|
|
216
|
-
files: [
|
|
217
|
-
{
|
|
218
|
-
destination: `typography/${typography}.css`,
|
|
219
|
-
format: formats.typography.name,
|
|
220
|
-
filter: (token) => {
|
|
221
|
-
const included = typeEquals(
|
|
222
|
-
["typography", "fontweight", "fontFamily", "lineHeight", "dimension", "font", "fontsize"],
|
|
223
|
-
token
|
|
224
|
-
);
|
|
225
|
-
if (/primitives\/modes\/typography\/(primary|secondary)/.test(token.filePath)) return false;
|
|
226
|
-
return included && !pathStartsWithOneOf(["spacing", "sizing", "size", "_size", "border-width", "border-radius"], token);
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
],
|
|
230
|
-
options: {
|
|
231
|
-
fileHeader
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
};
|
|
236
|
-
};
|
|
237
|
-
const configs = {
|
|
238
|
-
colorSchemeVariables,
|
|
239
|
-
mainColorVariables: colorCategoryVariables({ category: "main" }),
|
|
240
|
-
supportColorVariables: colorCategoryVariables({ category: "support" }),
|
|
241
|
-
neutralColorVariables: colorCategoryVariables({ category: "builtin", color: "neutral" }),
|
|
242
|
-
successColorVariables: colorCategoryVariables({ category: "builtin", color: "success" }),
|
|
243
|
-
dangerColorVariables: colorCategoryVariables({ category: "builtin", color: "danger" }),
|
|
244
|
-
warningColorVariables: colorCategoryVariables({ category: "builtin", color: "warning" }),
|
|
245
|
-
infoColorVariables: colorCategoryVariables({ category: "builtin", color: "info" }),
|
|
246
|
-
typographyVariables,
|
|
247
|
-
semanticVariables,
|
|
248
|
-
typescriptTokens
|
|
249
|
-
};
|
|
250
|
-
const getConfigsForThemeDimensions = (getConfig, themes, dimensions, options) => {
|
|
251
|
-
const { outPath, tokensDir } = options;
|
|
252
|
-
const permutations = getMultidimensionalThemes(themes, dimensions);
|
|
253
|
-
return permutations.flatMap(({ selectedTokenSets, permutation }) => {
|
|
254
|
-
const setsWithPaths = selectedTokenSets.map((x) => `${tokensDir}/${x}.json`);
|
|
255
|
-
const [source, include] = paritionPrimitives(setsWithPaths);
|
|
256
|
-
const configOrConfigs = getConfig(permutation, { outPath });
|
|
257
|
-
const configs_ = Array.isArray(configOrConfigs) ? configOrConfigs : [{ config: configOrConfigs }];
|
|
258
|
-
const configs2 = configs_.map(({ config, permutationOverrides }) => {
|
|
259
|
-
return {
|
|
260
|
-
permutation: { ...permutation, ...permutationOverrides },
|
|
261
|
-
config: {
|
|
262
|
-
...config,
|
|
263
|
-
log: {
|
|
264
|
-
...config?.log,
|
|
265
|
-
verbosity: buildOptions?.verbose ? "verbose" : "silent"
|
|
266
|
-
},
|
|
267
|
-
source,
|
|
268
|
-
include
|
|
269
|
-
}
|
|
270
|
-
};
|
|
271
|
-
});
|
|
272
|
-
return configs2;
|
|
273
|
-
}).sort();
|
|
274
|
-
};
|
|
275
|
-
export {
|
|
276
|
-
basePxFontSize,
|
|
277
|
-
configs,
|
|
278
|
-
getConfigsForThemeDimensions,
|
|
279
|
-
prefix
|
|
280
|
-
};
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import type { TransformedToken } from 'style-dictionary';
|
|
2
|
-
import type { Format } from 'style-dictionary/types';
|
|
3
|
-
/**
|
|
4
|
-
* In the given tokens array, inline and remove tokens that match the predicate
|
|
5
|
-
*
|
|
6
|
-
* Example: In pseudo-code, given the predicate `(token) => token.path === ['size', '1']` and the following tokens
|
|
7
|
-
* ```js
|
|
8
|
-
* [
|
|
9
|
-
* { path: ['size', 'base'], original: { $value: '8px' } },
|
|
10
|
-
* { path: ['size', '1'], original: { $value: '{size.base} * 2' } },
|
|
11
|
-
* { path: ['size', 'sm']: original: { $value: 'min({size.1}, 12px)' } }
|
|
12
|
-
* ]
|
|
13
|
-
* ```
|
|
14
|
-
* would return
|
|
15
|
-
* ```js
|
|
16
|
-
* [
|
|
17
|
-
* { path: ['size', 'base'], original: { $value: '8px' } },
|
|
18
|
-
* { path: ['size', 'sm']: original: { $value: 'min({size.base} * 2, 12px)' } }
|
|
19
|
-
* ]
|
|
20
|
-
* ```
|
|
21
|
-
*
|
|
22
|
-
* @param shouldSquash - predicate to determine if token should be inlined
|
|
23
|
-
* @param tokens - array of tokens to transform
|
|
24
|
-
* @returns copy of `tokens` without those that matched the predicate,
|
|
25
|
-
* where references to the matching tokens have been inlined
|
|
26
|
-
*/
|
|
27
|
-
export declare function squashTokens(shouldSquash: (t: TransformedToken) => boolean, tokens: TransformedToken[]): import("style-dictionary/types").TransformedToken[];
|
|
28
|
-
declare module 'style-dictionary/types' {
|
|
29
|
-
interface LocalOptions {
|
|
30
|
-
replaceCategoryWith?: string;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
export declare const isNumericSizeToken: (t: TransformedToken) => boolean;
|
|
34
|
-
export declare const isSquashTokens: (t: TransformedToken) => boolean;
|
|
35
|
-
/**
|
|
36
|
-
* Overrides the default sizing formula with a custom one that supports [round()](https://developer.mozilla.org/en-US/docs/Web/CSS/round) if supported.
|
|
37
|
-
*
|
|
38
|
-
* @param format - Function to format a token into a CSS property string.
|
|
39
|
-
* @param tokens - Array of transformed tokens to format.
|
|
40
|
-
* @returns Object with formatted CSS strings for calc and round.
|
|
41
|
-
*/
|
|
42
|
-
export declare const overrideSizingFormula: (format: (t: TransformedToken) => string, token: TransformedToken) => {
|
|
43
|
-
name: string;
|
|
44
|
-
round: string;
|
|
45
|
-
calc: string;
|
|
46
|
-
};
|
|
47
|
-
export declare const formats: {
|
|
48
|
-
colorScheme: Format;
|
|
49
|
-
colorCategory: Format;
|
|
50
|
-
semantic: Format;
|
|
51
|
-
typography: Format;
|
|
52
|
-
};
|
|
53
|
-
//# sourceMappingURL=css.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"css.d.ts","sourceRoot":"","sources":["../../../../../src/tokens/build/formats/css.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAarD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,YAAY,CAAC,YAAY,EAAE,CAAC,CAAC,EAAE,gBAAgB,KAAK,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,uDAetG;AAsDD,OAAO,QAAQ,wBAAwB,CAAC;IACtC,UAAiB,YAAY;QAC3B,mBAAmB,CAAC,EAAE,MAAM,CAAC;KAC9B;CACF;AAsCD,eAAO,MAAM,kBAAkB,GAAI,GAAG,gBAAgB,YAA4D,CAAC;AAEnH,eAAO,MAAM,cAAc,MAHY,gBAAgB,YAGkC,CAAC;AAE1F;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,GAAI,QAAQ,CAAC,CAAC,EAAE,gBAAgB,KAAK,MAAM,EAAE,OAAO,gBAAgB;;;;CAYrG,CAAC;AA4FF,eAAO,MAAM,OAAO;;;;;CAKc,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"js-tokens.d.ts","sourceRoot":"","sources":["../../../../../src/tokens/build/formats/js-tokens.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAoB,MAAM,wBAAwB,CAAC;AAoBvE;;GAEG;AACH,eAAO,MAAM,QAAQ,EAAE,MAuCtB,CAAC"}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import * as R from "ramda";
|
|
2
|
-
import { createPropertyFormatter, fileHeader } from "style-dictionary/utils";
|
|
3
|
-
import { getType, isColorCategoryToken, pathStartsWithOneOf } from "../../utils.js";
|
|
4
|
-
import { isSquashTokens, overrideSizingFormula, squashTokens } from "./css.js";
|
|
5
|
-
const groupByType = R.groupBy((token) => getType(token));
|
|
6
|
-
const removeUnwatedTokens = R.pipe(
|
|
7
|
-
R.reject((token) => isColorCategoryToken(token)),
|
|
8
|
-
R.reject((token) => R.any((path) => path.startsWith("_"))(token.path))
|
|
9
|
-
);
|
|
10
|
-
const dissocExtensions = R.pipe(R.dissoc("$extensions"), R.dissocPath(["original", "$extensions"]));
|
|
11
|
-
const removeUnwatedProps = R.map((token) => dissocExtensions(token));
|
|
12
|
-
const toCssVarName = R.pipe(R.split(":"), R.head, R.trim);
|
|
13
|
-
const jsTokens = {
|
|
14
|
-
name: "ds/js-tokens",
|
|
15
|
-
format: async ({ dictionary, file, options }) => {
|
|
16
|
-
const { usesDtcg, outputReferences } = options;
|
|
17
|
-
const format = createPropertyFormatter({
|
|
18
|
-
outputReferences,
|
|
19
|
-
dictionary,
|
|
20
|
-
format: "css",
|
|
21
|
-
usesDtcg
|
|
22
|
-
});
|
|
23
|
-
const formatTokens = R.map((token) => {
|
|
24
|
-
if (pathStartsWithOneOf(["size", "_size"], token)) {
|
|
25
|
-
const { calc, name } = overrideSizingFormula(format, token);
|
|
26
|
-
return {
|
|
27
|
-
...token,
|
|
28
|
-
name: name.trim(),
|
|
29
|
-
$value: calc.trim()
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
return {
|
|
33
|
-
...token,
|
|
34
|
-
name: toCssVarName(format(token))
|
|
35
|
-
};
|
|
36
|
-
});
|
|
37
|
-
const processTokens = R.pipe(removeUnwatedTokens, removeUnwatedProps, formatTokens, groupByType);
|
|
38
|
-
const tokens = processTokens(squashTokens(isSquashTokens, dictionary.allTokens));
|
|
39
|
-
const content = Object.entries(tokens).map(
|
|
40
|
-
([name, token]) => `export const ${name} = ${JSON.stringify(token, null, 2).replace(/"([^"]+)":/g, "$1:")}
|
|
41
|
-
`
|
|
42
|
-
).join("\n");
|
|
43
|
-
return fileHeader({ file }).then((fileHeaderText) => fileHeaderText + content);
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
export {
|
|
47
|
-
jsTokens
|
|
48
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"transformers.d.ts","sourceRoot":"","sources":["../../../../src/tokens/build/transformers.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAMxD,eAAO,MAAM,OAAO,EAAE,SAyBrB,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,SAS5B,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,SAWzB,CAAC;AAEF,eAAO,MAAM,QAAQ,EAAE,SAMtB,CAAC"}
|