@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
|
@@ -1,45 +1,61 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Config as SDConfig } from 'style-dictionary/types';
|
|
2
|
+
import type { ThemeConfig } from '../config.js';
|
|
3
|
+
import type { GetStyleDictionaryConfig } from './process/configs/shared.js';
|
|
2
4
|
export type Token = {
|
|
3
|
-
$value: string;
|
|
5
|
+
$value: string | Record<string, string>[];
|
|
4
6
|
$type: string;
|
|
5
7
|
};
|
|
6
|
-
export type
|
|
7
|
-
[key: string]: Token |
|
|
8
|
-
};
|
|
9
|
-
export type
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
};
|
|
13
|
-
export type TypographyTokens = TokensSet;
|
|
14
|
-
export type Tokens = {
|
|
15
|
-
colors: {
|
|
16
|
-
light: ColorModeTokens;
|
|
17
|
-
dark: ColorModeTokens;
|
|
18
|
-
contrast?: ColorModeTokens;
|
|
19
|
-
};
|
|
20
|
-
typography: {
|
|
21
|
-
primary: TokensSet;
|
|
22
|
-
};
|
|
23
|
-
};
|
|
24
|
-
export type Colors = {
|
|
25
|
-
main: Record<string, CssColor>;
|
|
26
|
-
support: Record<string, CssColor>;
|
|
27
|
-
neutral: CssColor;
|
|
28
|
-
};
|
|
29
|
-
export type Typography = {
|
|
30
|
-
fontFamily?: string;
|
|
31
|
-
};
|
|
32
|
-
export type TypographyModes = 'primary' | 'secondary';
|
|
33
|
-
export type File = {
|
|
34
|
-
data: string;
|
|
35
|
-
path: string;
|
|
36
|
-
filePath: string;
|
|
37
|
-
};
|
|
38
|
-
export type Collection = string | 'global';
|
|
8
|
+
export type TokenSet = {
|
|
9
|
+
[key: string]: Token | TokenSet;
|
|
10
|
+
};
|
|
11
|
+
export type TokenSets = Map<string, TokenSet>;
|
|
12
|
+
export type Colors = Theme['colors'];
|
|
13
|
+
export type Typography = Theme['typography'];
|
|
39
14
|
export type Theme = {
|
|
40
15
|
name: string;
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
16
|
+
} & Required<ThemeConfig>;
|
|
17
|
+
export declare const colorCategories: {
|
|
18
|
+
readonly main: "main";
|
|
19
|
+
readonly support: "support";
|
|
20
|
+
};
|
|
21
|
+
export type ColorCategories = keyof typeof colorCategories;
|
|
22
|
+
export type BuiltInColors = 'neutral' | 'success' | 'warning' | 'danger' | 'info';
|
|
23
|
+
/**
|
|
24
|
+
* A multi-dimensional theme is a concrete permutation of the possible theme dimensions
|
|
25
|
+
*/
|
|
26
|
+
export type ThemePermutation = {
|
|
27
|
+
'color-scheme': string;
|
|
28
|
+
'main-color': string;
|
|
29
|
+
'support-color'?: string;
|
|
30
|
+
semantic: string;
|
|
31
|
+
size: string;
|
|
32
|
+
theme: string;
|
|
33
|
+
typography: string;
|
|
34
|
+
};
|
|
35
|
+
export type ThemeDimension = keyof ThemePermutation;
|
|
36
|
+
export type GetSDConfigOptions = {
|
|
37
|
+
tokensDir?: string;
|
|
38
|
+
dry?: boolean;
|
|
39
|
+
tokenSets?: TokenSets;
|
|
40
|
+
};
|
|
41
|
+
export type BuildConfig = {
|
|
42
|
+
/** Optional name of the build config - only used in the console output */
|
|
43
|
+
name?: string;
|
|
44
|
+
/** Style Dictionary configuration creator */
|
|
45
|
+
getConfig: GetStyleDictionaryConfig;
|
|
46
|
+
/** Which theme dimensions to include. `theme` (e.g. digdir/altinn) is always included. */
|
|
47
|
+
dimensions: ThemeDimension[];
|
|
48
|
+
/** Whether the build config is enabled. @default () => true */
|
|
49
|
+
enabled?: () => boolean;
|
|
50
|
+
/** Custom log message. */
|
|
51
|
+
log?: (config: SDConfigForThemePermutation) => string;
|
|
52
|
+
};
|
|
53
|
+
export type SDConfigForThemePermutation = {
|
|
54
|
+
permutation: ThemePermutation;
|
|
55
|
+
config: SDConfig;
|
|
56
|
+
};
|
|
57
|
+
export type OutputFile = {
|
|
58
|
+
output: string;
|
|
59
|
+
destination: string | undefined;
|
|
44
60
|
};
|
|
45
61
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/tokens/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/tokens/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAC;AAE5E,MAAM,MAAM,KAAK,GAAG;IAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AACjF,MAAM,MAAM,QAAQ,GAAG;IACrB,CAAC,GAAG,EAAE,MAAM,GAAG,KAAK,GAAG,QAAQ,CAAC;CACjC,CAAC;AACF,MAAM,MAAM,SAAS,GAAG,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;AAE9C,MAAM,MAAM,MAAM,GAAG,KAAK,CAAC,QAAQ,CAAC,CAAC;AACrC,MAAM,MAAM,UAAU,GAAG,KAAK,CAAC,YAAY,CAAC,CAAC;AAE7C,MAAM,MAAM,KAAK,GAAG;IAClB,IAAI,EAAE,MAAM,CAAC;CACd,GAAG,QAAQ,CAAC,WAAW,CAAC,CAAC;AAE1B,eAAO,MAAM,eAAe;;;CAGlB,CAAC;AAEX,MAAM,MAAM,eAAe,GAAG,MAAM,OAAO,eAAe,CAAC;AAE3D,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,GAAG,MAAM,CAAC;AAElF;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,MAAM,gBAAgB,CAAC;AAEpD,MAAM,MAAM,kBAAkB,GAAG;IAC/B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,SAAS,CAAC,EAAE,SAAS,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,0EAA0E;IAC1E,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,6CAA6C;IAC7C,SAAS,EAAE,wBAAwB,CAAC;IACpC,0FAA0F;IAC1F,UAAU,EAAE,cAAc,EAAE,CAAC;IAC7B,+DAA+D;IAC/D,OAAO,CAAC,EAAE,MAAM,OAAO,CAAC;IACxB,0BAA0B;IAC1B,GAAG,CAAC,EAAE,CAAC,MAAM,EAAE,2BAA2B,KAAK,MAAM,CAAC;CACvD,CAAC;AAEF,MAAM,MAAM,2BAA2B,GAAG;IAAE,WAAW,EAAE,gBAAgB,CAAC;IAAC,MAAM,EAAE,QAAQ,CAAA;CAAE,CAAC;AAE9F,MAAM,MAAM,UAAU,GAAG;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;CACjC,CAAC"}
|
package/dist/src/tokens/types.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import type { Tokens } from 'style-dictionary';
|
|
1
2
|
import type { DesignToken, TransformedToken } from 'style-dictionary/types';
|
|
3
|
+
import type { TokenSet } from './types.js';
|
|
2
4
|
/**
|
|
3
5
|
* Returns type based on design token format used. Read more:https://v4.styledictionary.com/info/dtcg/
|
|
4
6
|
* @param token Transformed token
|
|
@@ -26,10 +28,33 @@ export declare function isSemanticToken(token: TransformedToken): boolean;
|
|
|
26
28
|
export declare function isSemanticColorToken(token: TransformedToken, color: string): boolean;
|
|
27
29
|
export declare function isGlobalColorToken(token: TransformedToken): boolean;
|
|
28
30
|
export declare function isColorCategoryToken(token: TransformedToken, category?: 'main' | 'support'): boolean;
|
|
29
|
-
export declare const mkdir: (dir: string, dry?: boolean) => Promise<string | void>;
|
|
30
|
-
export declare const writeFile: (path: string, data: string, dry?: boolean) => Promise<void>;
|
|
31
|
-
export declare const cp: (src: string, dest: string, dry?: boolean) => Promise<void>;
|
|
32
|
-
export declare const copyFile: (src: string, dest: string, dry?: boolean) => Promise<void>;
|
|
33
31
|
export declare const isDigit: (s: string) => boolean;
|
|
34
|
-
|
|
32
|
+
/** Copied from Style Dictionary and added types
|
|
33
|
+
@see https://github.com/amzn/style-dictionary/blob/31c29df0382a61b085f6392dc3225c5009fbffc5/lib/utils/combineJSON.js#L33 */
|
|
34
|
+
export declare function traverseObj(obj: Tokens | TokenSet, fn: (obj: TokenSet | Tokens | DesignToken, key: keyof Tokens | string, slice: Tokens | DesignToken | string) => void): import("style-dictionary/types").DesignTokens | TokenSet;
|
|
35
|
+
/**
|
|
36
|
+
* In the given tokens array, inline and remove tokens that match the predicate
|
|
37
|
+
*
|
|
38
|
+
* Example: In pseudo-code, given the predicate `(token) => token.path === ['size', '1']` and the following tokens
|
|
39
|
+
* ```js
|
|
40
|
+
* [
|
|
41
|
+
* { path: ['size', 'base'], original: { $value: '8px' } },
|
|
42
|
+
* { path: ['size', '1'], original: { $value: '{size.base} * 2' } },
|
|
43
|
+
* { path: ['size', 'sm']: original: { $value: 'min({size.1}, 12px)' } }
|
|
44
|
+
* ]
|
|
45
|
+
* ```
|
|
46
|
+
* would return
|
|
47
|
+
* ```js
|
|
48
|
+
* [
|
|
49
|
+
* { path: ['size', 'base'], original: { $value: '8px' } },
|
|
50
|
+
* { path: ['size', 'sm']: original: { $value: 'min({size.base} * 2, 12px)' } }
|
|
51
|
+
* ]
|
|
52
|
+
* ```
|
|
53
|
+
*
|
|
54
|
+
* @param shouldInline - predicate to determine if token should be inlined
|
|
55
|
+
* @param tokens - array of tokens to transform
|
|
56
|
+
* @returns copy of `tokens` without those that matched the predicate,
|
|
57
|
+
* where references to the matching tokens have been inlined
|
|
58
|
+
*/
|
|
59
|
+
export declare function inlineTokens(shouldInline: (t: TransformedToken) => boolean, tokens: TransformedToken[]): TransformedToken[];
|
|
35
60
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/tokens/utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/tokens/utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC5E,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAM3C;;;;GAIG;AACH,eAAO,MAAM,OAAO,GAAI,OAAO,gBAAgB,WAAkD,CAAC;AAElG;;;;;;GAMG;AACH,eAAO,MAAM,QAAQ,GAAI,CAAC,EAAE,OAAO,gBAAgB,GAAG,WAAW,KAAG,CAAuC,CAAC;AAE5G;;;;;;GAMG;AACH,eAAO,MAAM,UAAU,4DAAmB,MAAM,EAAE,GAAG,MAAM,SAAS,gBAAgB,aAMlF,CAAC;AAEH,eAAO,MAAM,mBAAmB,4DAAmB,MAAM,EAAE,SAAS,gBAAgB,aASlF,CAAC;AAEH,wBAAgB,eAAe,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAEhE;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAEpF;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAEnE;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,gBAAgB,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAKpG;AAED,eAAO,MAAM,OAAO,GAAI,GAAG,MAAM,YAAoB,CAAC;AAEtD;2HAC2H;AAC3H,wBAAgB,WAAW,CACzB,GAAG,EAAE,MAAM,GAAG,QAAQ,EACtB,EAAE,EAAE,CAAC,GAAG,EAAE,QAAQ,GAAG,MAAM,GAAG,WAAW,EAAE,GAAG,EAAE,MAAM,MAAM,GAAG,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,WAAW,GAAG,MAAM,KAAK,IAAI,4DAYrH;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,YAAY,CAAC,YAAY,EAAE,CAAC,CAAC,EAAE,gBAAgB,KAAK,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,sBAetG"}
|
package/dist/src/tokens/utils.js
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
import chalk from "chalk";
|
|
1
|
+
// src/tokens/utils.ts
|
|
3
2
|
import * as R from "ramda";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
var mapToLowerCase = R.map(R.toLower);
|
|
4
|
+
var hasAnyTruth = R.any(R.equals(true));
|
|
5
|
+
var getType = (token) => (token.$type ?? token.type) || "";
|
|
6
|
+
var getValue = (token) => token.$value ?? token.value;
|
|
7
|
+
var typeEquals = R.curry((types, token) => {
|
|
9
8
|
if (R.isNil(token)) {
|
|
10
9
|
return false;
|
|
11
10
|
}
|
|
12
11
|
return R.includes(R.toLower(getType(token)), R.map(R.toLower, Array.isArray(types) ? types : [types]));
|
|
13
12
|
});
|
|
14
|
-
|
|
13
|
+
var pathStartsWithOneOf = R.curry((paths, token) => {
|
|
15
14
|
if (R.isNil(token)) {
|
|
16
15
|
return false;
|
|
17
16
|
}
|
|
@@ -34,56 +33,43 @@ function isColorCategoryToken(token, category) {
|
|
|
34
33
|
}
|
|
35
34
|
return R.startsWith(["color", category], token.path);
|
|
36
35
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
36
|
+
var isDigit = (s) => /^\d+$/.test(s);
|
|
37
|
+
function traverseObj(obj, fn) {
|
|
38
|
+
for (const key in obj) {
|
|
39
|
+
const prop = obj[key];
|
|
40
|
+
if (prop != null) {
|
|
41
|
+
fn.apply(null, [obj, key, prop]);
|
|
42
|
+
if (typeof prop === "object") {
|
|
43
|
+
traverseObj(prop, fn);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
41
46
|
}
|
|
42
|
-
return
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
const copyFile = async (src, dest, dry) => {
|
|
59
|
-
if (dry) {
|
|
60
|
-
console.log(`${chalk.blue("copyFile")} ${src} to ${dest}`);
|
|
61
|
-
return Promise.resolve();
|
|
62
|
-
}
|
|
63
|
-
return await fs.copyFile(src, dest);
|
|
64
|
-
};
|
|
65
|
-
const isDigit = (s) => /^\d+$/.test(s);
|
|
66
|
-
const cleanDir = async (dir, dry) => {
|
|
67
|
-
if (dry) {
|
|
68
|
-
console.log(`${chalk.blue("cleanDir")} ${dir}`);
|
|
69
|
-
return Promise.resolve();
|
|
70
|
-
}
|
|
71
|
-
console.log(`${chalk.red(`Cleaning outputDir: ${dir.trim()}`)} `);
|
|
72
|
-
return await fs.rm(dir, { recursive: true, force: true });
|
|
73
|
-
};
|
|
47
|
+
return obj;
|
|
48
|
+
}
|
|
49
|
+
function inlineTokens(shouldInline, tokens) {
|
|
50
|
+
const [inlineableTokens, otherTokens] = R.partition(shouldInline, tokens);
|
|
51
|
+
return otherTokens.map((token) => {
|
|
52
|
+
let transformed = getValue(token.original);
|
|
53
|
+
for (const ref of inlineableTokens) {
|
|
54
|
+
const refName = ref.path.join(".");
|
|
55
|
+
if (typeof transformed === "string") {
|
|
56
|
+
transformed = transformed.replaceAll(`{${refName}}`, getValue(ref.original));
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
const tokenWithInlinedRefs = R.set(R.lensPath(["original", "$value"]), transformed, token);
|
|
60
|
+
return tokenWithInlinedRefs;
|
|
61
|
+
});
|
|
62
|
+
}
|
|
74
63
|
export {
|
|
75
|
-
cleanDir,
|
|
76
|
-
copyFile,
|
|
77
|
-
cp,
|
|
78
64
|
getType,
|
|
79
65
|
getValue,
|
|
66
|
+
inlineTokens,
|
|
80
67
|
isColorCategoryToken,
|
|
81
68
|
isDigit,
|
|
82
69
|
isGlobalColorToken,
|
|
83
70
|
isSemanticColorToken,
|
|
84
71
|
isSemanticToken,
|
|
85
|
-
mkdir,
|
|
86
72
|
pathStartsWithOneOf,
|
|
87
|
-
|
|
88
|
-
|
|
73
|
+
traverseObj,
|
|
74
|
+
typeEquals
|
|
89
75
|
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { CopyOptions } from 'node:fs';
|
|
2
|
+
/**
|
|
3
|
+
* Creates a directory if it does not already exist.
|
|
4
|
+
*
|
|
5
|
+
* @param dir - The path of the directory to create.
|
|
6
|
+
* @param dry - Optional. If `true`, the function will log the operation
|
|
7
|
+
* without actually creating the directory.
|
|
8
|
+
*
|
|
9
|
+
* @returns A promise that resolves when the operation is complete.
|
|
10
|
+
* If the directory already exists or `dry` is `true`, the promise resolves immediately.
|
|
11
|
+
*/
|
|
12
|
+
export declare const mkdir: (dir: string, dry?: boolean) => Promise<string | void>;
|
|
13
|
+
export declare const writeFile: (path: string, data: string, dry?: boolean) => Promise<void>;
|
|
14
|
+
export declare const cp: (src: string, dest: string, dry?: boolean, filter?: CopyOptions["filter"]) => Promise<void>;
|
|
15
|
+
export declare const copyFile: (src: string, dest: string, dry?: boolean) => Promise<void>;
|
|
16
|
+
export declare const cleanDir: (dir: string, dry?: boolean) => Promise<void>;
|
|
17
|
+
export declare const readFile: (path: string, dry?: boolean) => Promise<string>;
|
|
18
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAI3C;;;;;;;;;GASG;AACH,eAAO,MAAM,KAAK,GAAU,KAAK,MAAM,EAAE,MAAM,OAAO,2BAgBrD,CAAC;AAEF,eAAO,MAAM,SAAS,GAAU,MAAM,MAAM,EAAE,MAAM,MAAM,EAAE,MAAM,OAAO,kBAWxE,CAAC;AAEF,eAAO,MAAM,EAAE,GAAU,KAAK,MAAM,EAAE,MAAM,MAAM,EAAE,MAAM,OAAO,EAAE,SAAS,WAAW,CAAC,QAAQ,CAAC,kBAOhG,CAAC;AAEF,eAAO,MAAM,QAAQ,GAAU,KAAK,MAAM,EAAE,MAAM,MAAM,EAAE,MAAM,OAAO,kBAOtE,CAAC;AAEF,eAAO,MAAM,QAAQ,GAAU,KAAK,MAAM,EAAE,MAAM,OAAO,kBASxD,CAAC;AAEF,eAAO,MAAM,QAAQ,GAAU,MAAM,MAAM,EAAE,MAAM,OAAO,oBAOzD,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
// src/utils.ts
|
|
2
|
+
import fs from "node:fs/promises";
|
|
3
|
+
import chalk from "chalk";
|
|
4
|
+
var mkdir = async (dir, dry) => {
|
|
5
|
+
if (dry) {
|
|
6
|
+
console.log(`${chalk.blue("mkdir")} ${dir}`);
|
|
7
|
+
return Promise.resolve();
|
|
8
|
+
}
|
|
9
|
+
const exists = await fs.access(dir, fs.constants.F_OK).then(() => true).catch(() => false);
|
|
10
|
+
if (exists) {
|
|
11
|
+
return Promise.resolve();
|
|
12
|
+
}
|
|
13
|
+
return fs.mkdir(dir, { recursive: true });
|
|
14
|
+
};
|
|
15
|
+
var writeFile = async (path, data, dry) => {
|
|
16
|
+
if (dry) {
|
|
17
|
+
console.log(`${chalk.blue("writeFile")} ${path}`);
|
|
18
|
+
return Promise.resolve();
|
|
19
|
+
}
|
|
20
|
+
return fs.writeFile(path, data, { encoding: "utf-8" }).catch((error) => {
|
|
21
|
+
console.error(chalk.red(`Error writing file: ${path}`));
|
|
22
|
+
console.error(chalk.red(error));
|
|
23
|
+
throw error;
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
var cp = async (src, dest, dry, filter) => {
|
|
27
|
+
if (dry) {
|
|
28
|
+
console.log(`${chalk.blue("cp")} ${src} ${dest}`);
|
|
29
|
+
return Promise.resolve();
|
|
30
|
+
}
|
|
31
|
+
return fs.cp(src, dest, { recursive: true, filter });
|
|
32
|
+
};
|
|
33
|
+
var copyFile = async (src, dest, dry) => {
|
|
34
|
+
if (dry) {
|
|
35
|
+
console.log(`${chalk.blue("copyFile")} ${src} to ${dest}`);
|
|
36
|
+
return Promise.resolve();
|
|
37
|
+
}
|
|
38
|
+
return fs.copyFile(src, dest);
|
|
39
|
+
};
|
|
40
|
+
var cleanDir = async (dir, dry) => {
|
|
41
|
+
if (dry) {
|
|
42
|
+
console.log(`${chalk.blue("cleanDir")} ${dir}`);
|
|
43
|
+
return Promise.resolve();
|
|
44
|
+
}
|
|
45
|
+
console.log(`
|
|
46
|
+
\u{1F525} Cleaning dir ${chalk.red(`${dir.trim()}`)} `);
|
|
47
|
+
return fs.rm(dir, { recursive: true, force: true });
|
|
48
|
+
};
|
|
49
|
+
var readFile = async (path, dry) => {
|
|
50
|
+
if (dry) {
|
|
51
|
+
console.log(`${chalk.blue("readFile")} ${path}`);
|
|
52
|
+
return Promise.resolve("");
|
|
53
|
+
}
|
|
54
|
+
return fs.readFile(path, "utf-8");
|
|
55
|
+
};
|
|
56
|
+
export {
|
|
57
|
+
cleanDir,
|
|
58
|
+
copyFile,
|
|
59
|
+
cp,
|
|
60
|
+
mkdir,
|
|
61
|
+
readFile,
|
|
62
|
+
writeFile
|
|
63
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"<theme>": {
|
|
3
|
+
"font-family": {
|
|
4
|
+
"$type": "fontFamilies",
|
|
5
|
+
"$value": "<font-family>"
|
|
6
|
+
},
|
|
7
|
+
"font-weight": {
|
|
8
|
+
"medium": {
|
|
9
|
+
"$type": "fontWeights",
|
|
10
|
+
"$value": "Medium"
|
|
11
|
+
},
|
|
12
|
+
"semibold": {
|
|
13
|
+
"$type": "fontWeights",
|
|
14
|
+
"$value": "Semi bold"
|
|
15
|
+
},
|
|
16
|
+
"regular": {
|
|
17
|
+
"$type": "fontWeights",
|
|
18
|
+
"$value": "Regular"
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@digdir/designsystemet",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "CLI for Designsystemet",
|
|
5
5
|
"author": "Designsystemet team",
|
|
6
6
|
"engines": {
|
|
7
|
-
"node": ">=22"
|
|
7
|
+
"node": ">=22.14.0"
|
|
8
8
|
},
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
@@ -47,12 +47,13 @@
|
|
|
47
47
|
"test:tokens-create-and-build-config": "yarn test:tokens-create-config && yarn test:tokens-build",
|
|
48
48
|
"test": "yarn test:tokens-create-and-build-options && yarn test:tokens-create-and-build-config",
|
|
49
49
|
"internal:tokens-create": "yarn designsystemet tokens create --config ./internal.config.json",
|
|
50
|
-
"update:template": "tsx ./src/
|
|
51
|
-
"update:design-tokens": "yarn internal:tokens-create && tsx ./src/scripts/
|
|
50
|
+
"update:template": "tsx ./src/scripts/update-template.ts",
|
|
51
|
+
"update:design-tokens": "yarn internal:tokens-create && tsx ./src/scripts/update-design-tokens.ts",
|
|
52
|
+
"verify": "yarn test && yarn update:template && yarn update:design-tokens"
|
|
52
53
|
},
|
|
53
54
|
"dependencies": {
|
|
54
|
-
"@commander-js/extra-typings": "^13.
|
|
55
|
-
"@tokens-studio/sd-transforms": "1.2.
|
|
55
|
+
"@commander-js/extra-typings": "^13.1.0",
|
|
56
|
+
"@tokens-studio/sd-transforms": "1.2.12",
|
|
56
57
|
"apca-w3": "^0.1.9",
|
|
57
58
|
"chalk": "^5.4.1",
|
|
58
59
|
"change-case": "^5.4.4",
|
|
@@ -60,28 +61,28 @@
|
|
|
60
61
|
"commander": "^13.1.0",
|
|
61
62
|
"fast-glob": "^3.3.3",
|
|
62
63
|
"hsluv": "^1.0.1",
|
|
63
|
-
"jscodeshift": "^17.1.2",
|
|
64
64
|
"object-hash": "^3.0.0",
|
|
65
|
-
"postcss": "^8.5.
|
|
65
|
+
"postcss": "^8.5.3",
|
|
66
66
|
"ramda": "^0.30.1",
|
|
67
|
-
"style-dictionary": "^4.3.
|
|
68
|
-
"zod": "^3.24.
|
|
67
|
+
"style-dictionary": "^4.3.3",
|
|
68
|
+
"zod": "^3.24.2",
|
|
69
69
|
"zod-validation-error": "^3.4.0"
|
|
70
70
|
},
|
|
71
71
|
"devDependencies": {
|
|
72
72
|
"@types/apca-w3": "^0.1.3",
|
|
73
|
-
"@types/chroma-js": "^3.1.
|
|
73
|
+
"@types/chroma-js": "^3.1.1",
|
|
74
74
|
"@types/fs-extra": "^11.0.4",
|
|
75
75
|
"@types/glob": "^8.1.0",
|
|
76
76
|
"@types/jscodeshift": "^0.12.0",
|
|
77
|
-
"@types/node": "^22.
|
|
77
|
+
"@types/node": "^22.14.0",
|
|
78
78
|
"@types/object-hash": "^3.0.6",
|
|
79
79
|
"@types/ramda": "^0.30.2",
|
|
80
80
|
"fs-extra": "^11.3.0",
|
|
81
|
+
"ts-toolbelt": "^9.6.0",
|
|
81
82
|
"tslib": "^2.8.1",
|
|
82
|
-
"tsup": "^8.
|
|
83
|
-
"tsx": "^4.19.
|
|
84
|
-
"typescript": "^5.
|
|
85
|
-
"zod-to-json-schema": "^3.24.
|
|
83
|
+
"tsup": "^8.4.0",
|
|
84
|
+
"tsx": "^4.19.3",
|
|
85
|
+
"typescript": "^5.8.2",
|
|
86
|
+
"zod-to-json-schema": "^3.24.5"
|
|
86
87
|
}
|
|
87
88
|
}
|
package/dist/bin/config.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../bin/config.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,sBAQ5D;AAWD,eAAO,MAAM,UAAU,QAA2C,CAAC;AA+CnE;;GAEG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAO3B,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAA8B,CAAC;AAChE,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC"}
|