@digdir/designsystemet 1.0.6 → 1.0.8

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.
Files changed (50) hide show
  1. package/configs/digdir.config.json +59 -0
  2. package/configs/test-tokens.config.json +45 -0
  3. package/dist/bin/config.d.ts +12 -0
  4. package/dist/bin/config.d.ts.map +1 -0
  5. package/dist/bin/config.js +516 -0
  6. package/dist/bin/designsystemet.js +3389 -3337
  7. package/dist/config.schema.json +39 -27
  8. package/dist/src/config.d.ts +46 -187
  9. package/dist/src/config.d.ts.map +1 -1
  10. package/dist/src/config.js +69 -36
  11. package/dist/src/index.js +60 -36
  12. package/dist/src/migrations/beta-to-v1.js +11 -4
  13. package/dist/src/migrations/codemods/css/run.js +11 -4
  14. package/dist/src/migrations/color-rename-next49.js +11 -4
  15. package/dist/src/migrations/index.js +11 -4
  16. package/dist/src/scripts/createJsonSchema.js +40 -1295
  17. package/dist/src/scripts/update-design-tokens.js +4 -4
  18. package/dist/src/scripts/update-template.js +16 -9
  19. package/dist/src/tokens/build.d.ts +1 -1
  20. package/dist/src/tokens/build.d.ts.map +1 -1
  21. package/dist/src/tokens/build.js +72 -53
  22. package/dist/src/tokens/create/generators/$designsystemet.js +18 -18
  23. package/dist/src/tokens/create/write.js +29 -22
  24. package/dist/src/tokens/format.d.ts +1 -1
  25. package/dist/src/tokens/format.d.ts.map +1 -1
  26. package/dist/src/tokens/format.js +60 -36
  27. package/dist/src/tokens/index.js +60 -36
  28. package/dist/src/tokens/process/configs/color.js +12 -10
  29. package/dist/src/tokens/process/configs/semantic.js +11 -9
  30. package/dist/src/tokens/process/configs/storefront.js +11 -1
  31. package/dist/src/tokens/process/configs/typography.js +11 -9
  32. package/dist/src/tokens/process/configs.js +13 -26
  33. package/dist/src/tokens/process/formats/css/color.js +3 -1
  34. package/dist/src/tokens/process/formats/css.js +3 -1
  35. package/dist/src/tokens/process/formats/js-tokens.js +11 -1
  36. package/dist/src/tokens/process/platform.d.ts +3 -5
  37. package/dist/src/tokens/process/platform.d.ts.map +1 -1
  38. package/dist/src/tokens/process/platform.js +41 -14
  39. package/dist/src/tokens/process/theme.d.ts.map +1 -1
  40. package/dist/src/tokens/process/theme.js +18 -21
  41. package/dist/src/tokens/process/utils/getMultidimensionalThemes.js +5 -4
  42. package/dist/src/tokens/types.d.ts +2 -2
  43. package/dist/src/tokens/types.d.ts.map +1 -1
  44. package/dist/src/tokens/utils.d.ts +2 -2
  45. package/dist/src/tokens/utils.d.ts.map +1 -1
  46. package/dist/src/tokens/utils.js +11 -1
  47. package/dist/src/utils.d.ts +1 -1
  48. package/dist/src/utils.d.ts.map +1 -1
  49. package/dist/src/utils.js +10 -3
  50. package/package.json +18 -18
@@ -2457,7 +2457,9 @@ function isGlobalColorToken(token) {
2457
2457
  }
2458
2458
  function isColorCategoryToken(token, category) {
2459
2459
  if (!category) {
2460
- return ["main", "support"].some((c) => isColorCategoryToken(token, c));
2460
+ return Object.keys(colorCategories).some(
2461
+ (colorCategory2) => isColorCategoryToken(token, colorCategory2)
2462
+ );
2461
2463
  }
2462
2464
  return R7.startsWith(["color", category], token.path);
2463
2465
  }
@@ -2794,7 +2796,7 @@ var colorCategoryVariables = (opts) => ({ "color-scheme": colorScheme2, theme, .
2794
2796
  );
2795
2797
  }
2796
2798
  const layer = `ds.theme.color`;
2797
- const isRootColor = color === buildOptions?.rootColor;
2799
+ const isRootColor = color === buildOptions?.defaultColor;
2798
2800
  const selector = isRootColor ? `:root, [data-color-scheme], [data-color="${color}"]` : `[data-color="${color}"], [data-color-scheme][data-color="${color}"]`;
2799
2801
  const config = {
2800
2802
  preprocessors: ["tokens-studio"],
@@ -3038,8 +3040,7 @@ function processThemeObject(theme) {
3038
3040
  }
3039
3041
  function groupThemes(themes) {
3040
3042
  const groups = {};
3041
- for (const rawTheme of themes) {
3042
- const theme = processThemeObject(rawTheme);
3043
+ for (const theme of themes) {
3043
3044
  if (theme.group) {
3044
3045
  const groupKey = theme.group;
3045
3046
  groups[groupKey] = [...groups[groupKey] ?? [], theme];
@@ -3190,9 +3191,12 @@ var initResult = {
3190
3191
  };
3191
3192
  var buildOptions;
3192
3193
  var sd = new StyleDictionary2();
3193
- var getCustomColors = (processed$themes) => processed$themes.filter(
3194
- (x) => x.group && [colorCategories.main, colorCategories.support].map((c) => `${c}-color`).includes(x.group)
3195
- ).map((x) => x.name);
3194
+ var getCustomColors = (processed$themes, colorGroups) => processed$themes.filter((x) => {
3195
+ if (!x.group) {
3196
+ return false;
3197
+ }
3198
+ return colorGroups.includes(x.group);
3199
+ }).map((x) => x.name);
3196
3200
  var buildConfigs = {
3197
3201
  typography: { getConfig: configs.typographyVariables, dimensions: ["typography"] },
3198
3202
  "color-scheme": { getConfig: configs.colorSchemeVariables, dimensions: ["color-scheme"] },
@@ -3233,17 +3237,40 @@ var buildConfigs = {
3233
3237
  // },
3234
3238
  };
3235
3239
  async function processPlatform(options) {
3236
- const { process, $themes } = options;
3240
+ const { type, $themes } = options;
3237
3241
  const platform = "css";
3238
- const tokenSets = process === "format" ? options.tokenSets : void 0;
3239
- const tokensDir = process === "build" ? options.tokensDir : void 0;
3242
+ const tokenSets = type === "format" ? options.tokenSets : void 0;
3243
+ const tokensDir = type === "build" ? options.tokensDir : void 0;
3244
+ const UNSAFE_DEFAULT_COLOR = process.env.UNSAFE_DEFAULT_COLOR ?? "";
3245
+ if (UNSAFE_DEFAULT_COLOR) {
3246
+ console.warn(
3247
+ chalk2.yellow(
3248
+ `
3249
+ \u26A0\uFE0F UNSAFE_DEFAULT_COLOR is set to ${chalk2.blue(UNSAFE_DEFAULT_COLOR)}. This will override the default color.`
3250
+ )
3251
+ );
3252
+ }
3253
+ const UNSAFE_COLOR_GROUPS = Array.from(process.env.UNSAFE_COLOR_GROUPS?.split(",") ?? []);
3254
+ if (UNSAFE_COLOR_GROUPS.length > 0) {
3255
+ console.warn(
3256
+ chalk2.yellow(
3257
+ `
3258
+ \u26A0\uFE0F UNSAFE_COLOR_GROUPS is set to ${chalk2.blue(`[${UNSAFE_COLOR_GROUPS.join(", ")}]`)}. This will override the default color groups.`
3259
+ )
3260
+ );
3261
+ }
3262
+ const colorGroups = UNSAFE_COLOR_GROUPS.length > 0 ? UNSAFE_COLOR_GROUPS : [colorCategories.main, colorCategories.support].map((c) => `${c}-color`);
3240
3263
  buildOptions = options;
3264
+ buildOptions.defaultColor = UNSAFE_DEFAULT_COLOR;
3241
3265
  const processed$themes = $themes.map(processThemeObject).filter((theme) => R18.not(theme.group === "size" && theme.name !== "medium"));
3242
- const customColors = getCustomColors(processed$themes);
3243
- if (!buildOptions.rootColor) {
3266
+ const customColors = getCustomColors(processed$themes, colorGroups);
3267
+ if (!buildOptions.defaultColor) {
3244
3268
  const firstMainColor = R18.head(customColors);
3245
- buildOptions.rootColor = firstMainColor;
3246
- console.log(`Using first main color; ${chalk2.blue(firstMainColor)}, as ${chalk2.green(`":root"`)} color`);
3269
+ buildOptions.defaultColor = firstMainColor;
3270
+ }
3271
+ if (buildOptions.defaultColor) {
3272
+ console.log(`
3273
+ \u{1F3A8} Using ${chalk2.blue(buildOptions.defaultColor)} as default color`);
3247
3274
  }
3248
3275
  const buildAndSdConfigs = R18.map((buildConfig) => {
3249
3276
  const sdConfigs = getConfigsForThemeDimensions(buildConfig.getConfig, processed$themes, buildConfig.dimensions, {
@@ -3341,11 +3368,11 @@ import chalk3 from "chalk";
3341
3368
  // package.json
3342
3369
  var package_default = {
3343
3370
  name: "@digdir/designsystemet",
3344
- version: "1.0.6",
3371
+ version: "1.0.8",
3345
3372
  description: "CLI for Designsystemet",
3346
3373
  author: "Designsystemet team",
3347
3374
  engines: {
3348
- node: ">=22.15.0"
3375
+ node: ">=22.16.0"
3349
3376
  },
3350
3377
  repository: {
3351
3378
  type: "git",
@@ -3356,7 +3383,8 @@ var package_default = {
3356
3383
  type: "module",
3357
3384
  main: "./dist/src/index.js",
3358
3385
  files: [
3359
- "./dist/**"
3386
+ "./dist/**",
3387
+ "./configs/**"
3360
3388
  ],
3361
3389
  bin: "dist/bin/designsystemet.js",
3362
3390
  exports: {
@@ -3375,23 +3403,23 @@ var package_default = {
3375
3403
  },
3376
3404
  scripts: {
3377
3405
  designsystemet: "tsx ./bin/designsystemet.ts",
3378
- "build:tokens": "pnpm run designsystemet tokens build -p -t ../../design-tokens -o ../../packages/theme/brand --clean",
3379
- "build:tokens:debug": "tsx --inspect-brk ./bin/designsystemet.ts tokens build -p -t ../../design-tokens -o ../../packages/theme/brand --clean",
3406
+ "build:tokens": "pnpm run designsystemet tokens build -p -t ../../internal/design-tokens -o ../../packages/theme/brand --clean",
3407
+ "build:tokens:debug": "tsx --inspect-brk ./bin/designsystemet.ts tokens build -p -t ../../internal/design-tokens -o ../../packages/theme/brand --clean",
3380
3408
  build: "tsup && pnpm build:types && pnpm build:json-schema",
3381
3409
  "build:types": "tsc --emitDeclarationOnly --declaration",
3382
3410
  "build:json-schema": "tsx ./src/scripts/createJsonSchema.ts",
3383
3411
  types: "tsc --noEmit",
3384
- "test:tokens-create-options": 'pnpm run designsystemet tokens create -m dominant:"#007682" -n "#003333" -b 99 -o ./test-tokens/options --theme options --clean',
3385
- "test:tokens-create-config": "pnpm run designsystemet tokens create --config ./test/test-tokens.config.json",
3386
- "test:tokens-build": "pnpm run designsystemet tokens build -t ./test-tokens/options -o ./test-tokens/options-build --clean",
3387
- "test:tokens-build-config": "pnpm run designsystemet tokens build -t ./test-tokens/config -o ./test-tokens/config-build --clean",
3412
+ "test:tokens-create-options": 'pnpm run designsystemet tokens create -m dominant:"#007682" -n "#003333" -b 99 -o ./temp/options/design-tokens --theme options --clean',
3413
+ "test:tokens-create-config": "pnpm run designsystemet tokens create --config ./configs/test-tokens.config.json",
3414
+ "test:tokens-build": "pnpm run designsystemet tokens build -t ./temp/options/design-tokens -o ./temp/options/build --clean",
3415
+ "test:tokens-build-config": "pnpm run designsystemet tokens build -t ./temp/config/design-tokens -o ./temp/config/build --clean",
3388
3416
  "test:tokens-create-and-build-options": "pnpm test:tokens-create-options && pnpm test:tokens-build",
3389
3417
  "test:tokens-create-and-build-config": "pnpm test:tokens-create-config && pnpm test:tokens-build-config",
3390
3418
  test: "pnpm test:tokens-create-and-build-options && pnpm test:tokens-create-and-build-config",
3391
- "internal:tokens-create": "pnpm run designsystemet tokens create --config ./internal.config.json",
3419
+ "digdir:tokens-create": "pnpm run designsystemet tokens create --config ./configs/digdir.config.json",
3392
3420
  "update:template": "tsx ./src/scripts/update-template.ts",
3393
- "update:design-tokens": "pnpm internal:tokens-create && tsx ./src/scripts/update-design-tokens.ts",
3394
- verify: "pnpm test && pnpm update:template && pnpm update:design-tokens"
3421
+ "update:theme-digdir": "pnpm digdir:tokens-create && tsx ./src/scripts/update-design-tokens.ts",
3422
+ verify: "pnpm test && pnpm update:template && pnpm update:theme-digdir && pnpm build:tokens"
3395
3423
  },
3396
3424
  dependencies: {
3397
3425
  "@commander-js/extra-typings": "^13.1.0",
@@ -3408,8 +3436,8 @@ var package_default = {
3408
3436
  postcss: "^8.5.3",
3409
3437
  ramda: "^0.30.1",
3410
3438
  "style-dictionary": "^4.4.0",
3411
- zod: "^3.24.4",
3412
- "zod-validation-error": "^3.4.0"
3439
+ zod: "^3.25.30",
3440
+ "zod-validation-error": "^3.4.1"
3413
3441
  },
3414
3442
  devDependencies: {
3415
3443
  "@tokens-studio/types": "0.5.2",
@@ -3418,16 +3446,15 @@ var package_default = {
3418
3446
  "@types/fs-extra": "^11.0.4",
3419
3447
  "@types/glob": "^8.1.0",
3420
3448
  "@types/jscodeshift": "^0.12.0",
3421
- "@types/node": "^22.15.3",
3449
+ "@types/node": "^22.15.21",
3422
3450
  "@types/object-hash": "^3.0.6",
3423
3451
  "@types/ramda": "^0.30.2",
3424
3452
  "fs-extra": "^11.3.0",
3425
3453
  "ts-toolbelt": "^9.6.0",
3426
3454
  tslib: "^2.8.1",
3427
- tsup: "^8.4.0",
3455
+ tsup: "^8.5.0",
3428
3456
  tsx: "^4.19.4",
3429
- typescript: "^5.8.3",
3430
- "zod-to-json-schema": "^3.24.5"
3457
+ typescript: "^5.8.3"
3431
3458
  }
3432
3459
  };
3433
3460
 
@@ -3481,9 +3508,6 @@ order may change due to nondeterminism.`.trim()
3481
3508
  return sortIndex;
3482
3509
  });
3483
3510
  const header = `@charset "UTF-8";
3484
-
3485
- @layer ds.theme, ds.base, ds.utilities, ds.components;
3486
-
3487
3511
  /*
3488
3512
  ${fileHeader2}
3489
3513
  */
@@ -3508,7 +3532,7 @@ ${fileHeader2}
3508
3532
  // src/tokens/format.ts
3509
3533
  var formatTokens = async (options) => {
3510
3534
  const processedBuilds = await processPlatform({
3511
- process: "format",
3535
+ type: "format",
3512
3536
  ...options
3513
3537
  });
3514
3538
  return processedBuilds;
@@ -2472,7 +2472,9 @@ function isGlobalColorToken(token) {
2472
2472
  }
2473
2473
  function isColorCategoryToken(token, category) {
2474
2474
  if (!category) {
2475
- return ["main", "support"].some((c) => isColorCategoryToken(token, c));
2475
+ return Object.keys(colorCategories).some(
2476
+ (colorCategory2) => isColorCategoryToken(token, colorCategory2)
2477
+ );
2476
2478
  }
2477
2479
  return R7.startsWith(["color", category], token.path);
2478
2480
  }
@@ -2809,7 +2811,7 @@ var colorCategoryVariables = (opts) => ({ "color-scheme": colorScheme2, theme, .
2809
2811
  );
2810
2812
  }
2811
2813
  const layer = `ds.theme.color`;
2812
- const isRootColor = color === buildOptions?.rootColor;
2814
+ const isRootColor = color === buildOptions?.defaultColor;
2813
2815
  const selector = isRootColor ? `:root, [data-color-scheme], [data-color="${color}"]` : `[data-color="${color}"], [data-color-scheme][data-color="${color}"]`;
2814
2816
  const config = {
2815
2817
  preprocessors: ["tokens-studio"],
@@ -3053,8 +3055,7 @@ function processThemeObject(theme) {
3053
3055
  }
3054
3056
  function groupThemes(themes) {
3055
3057
  const groups = {};
3056
- for (const rawTheme of themes) {
3057
- const theme = processThemeObject(rawTheme);
3058
+ for (const theme of themes) {
3058
3059
  if (theme.group) {
3059
3060
  const groupKey = theme.group;
3060
3061
  groups[groupKey] = [...groups[groupKey] ?? [], theme];
@@ -3205,9 +3206,12 @@ var initResult = {
3205
3206
  };
3206
3207
  var buildOptions;
3207
3208
  var sd = new StyleDictionary2();
3208
- var getCustomColors = (processed$themes) => processed$themes.filter(
3209
- (x) => x.group && [colorCategories.main, colorCategories.support].map((c) => `${c}-color`).includes(x.group)
3210
- ).map((x) => x.name);
3209
+ var getCustomColors = (processed$themes, colorGroups) => processed$themes.filter((x) => {
3210
+ if (!x.group) {
3211
+ return false;
3212
+ }
3213
+ return colorGroups.includes(x.group);
3214
+ }).map((x) => x.name);
3211
3215
  var buildConfigs = {
3212
3216
  typography: { getConfig: configs.typographyVariables, dimensions: ["typography"] },
3213
3217
  "color-scheme": { getConfig: configs.colorSchemeVariables, dimensions: ["color-scheme"] },
@@ -3248,17 +3252,40 @@ var buildConfigs = {
3248
3252
  // },
3249
3253
  };
3250
3254
  async function processPlatform(options) {
3251
- const { process, $themes } = options;
3255
+ const { type, $themes } = options;
3252
3256
  const platform = "css";
3253
- const tokenSets = process === "format" ? options.tokenSets : void 0;
3254
- const tokensDir = process === "build" ? options.tokensDir : void 0;
3257
+ const tokenSets = type === "format" ? options.tokenSets : void 0;
3258
+ const tokensDir = type === "build" ? options.tokensDir : void 0;
3259
+ const UNSAFE_DEFAULT_COLOR = process.env.UNSAFE_DEFAULT_COLOR ?? "";
3260
+ if (UNSAFE_DEFAULT_COLOR) {
3261
+ console.warn(
3262
+ chalk2.yellow(
3263
+ `
3264
+ \u26A0\uFE0F UNSAFE_DEFAULT_COLOR is set to ${chalk2.blue(UNSAFE_DEFAULT_COLOR)}. This will override the default color.`
3265
+ )
3266
+ );
3267
+ }
3268
+ const UNSAFE_COLOR_GROUPS = Array.from(process.env.UNSAFE_COLOR_GROUPS?.split(",") ?? []);
3269
+ if (UNSAFE_COLOR_GROUPS.length > 0) {
3270
+ console.warn(
3271
+ chalk2.yellow(
3272
+ `
3273
+ \u26A0\uFE0F UNSAFE_COLOR_GROUPS is set to ${chalk2.blue(`[${UNSAFE_COLOR_GROUPS.join(", ")}]`)}. This will override the default color groups.`
3274
+ )
3275
+ );
3276
+ }
3277
+ const colorGroups = UNSAFE_COLOR_GROUPS.length > 0 ? UNSAFE_COLOR_GROUPS : [colorCategories.main, colorCategories.support].map((c) => `${c}-color`);
3255
3278
  buildOptions = options;
3279
+ buildOptions.defaultColor = UNSAFE_DEFAULT_COLOR;
3256
3280
  const processed$themes = $themes.map(processThemeObject).filter((theme) => R18.not(theme.group === "size" && theme.name !== "medium"));
3257
- const customColors = getCustomColors(processed$themes);
3258
- if (!buildOptions.rootColor) {
3281
+ const customColors = getCustomColors(processed$themes, colorGroups);
3282
+ if (!buildOptions.defaultColor) {
3259
3283
  const firstMainColor = R18.head(customColors);
3260
- buildOptions.rootColor = firstMainColor;
3261
- console.log(`Using first main color; ${chalk2.blue(firstMainColor)}, as ${chalk2.green(`":root"`)} color`);
3284
+ buildOptions.defaultColor = firstMainColor;
3285
+ }
3286
+ if (buildOptions.defaultColor) {
3287
+ console.log(`
3288
+ \u{1F3A8} Using ${chalk2.blue(buildOptions.defaultColor)} as default color`);
3262
3289
  }
3263
3290
  const buildAndSdConfigs = R18.map((buildConfig) => {
3264
3291
  const sdConfigs = getConfigsForThemeDimensions(buildConfig.getConfig, processed$themes, buildConfig.dimensions, {
@@ -3356,11 +3383,11 @@ import chalk3 from "chalk";
3356
3383
  // package.json
3357
3384
  var package_default = {
3358
3385
  name: "@digdir/designsystemet",
3359
- version: "1.0.6",
3386
+ version: "1.0.8",
3360
3387
  description: "CLI for Designsystemet",
3361
3388
  author: "Designsystemet team",
3362
3389
  engines: {
3363
- node: ">=22.15.0"
3390
+ node: ">=22.16.0"
3364
3391
  },
3365
3392
  repository: {
3366
3393
  type: "git",
@@ -3371,7 +3398,8 @@ var package_default = {
3371
3398
  type: "module",
3372
3399
  main: "./dist/src/index.js",
3373
3400
  files: [
3374
- "./dist/**"
3401
+ "./dist/**",
3402
+ "./configs/**"
3375
3403
  ],
3376
3404
  bin: "dist/bin/designsystemet.js",
3377
3405
  exports: {
@@ -3390,23 +3418,23 @@ var package_default = {
3390
3418
  },
3391
3419
  scripts: {
3392
3420
  designsystemet: "tsx ./bin/designsystemet.ts",
3393
- "build:tokens": "pnpm run designsystemet tokens build -p -t ../../design-tokens -o ../../packages/theme/brand --clean",
3394
- "build:tokens:debug": "tsx --inspect-brk ./bin/designsystemet.ts tokens build -p -t ../../design-tokens -o ../../packages/theme/brand --clean",
3421
+ "build:tokens": "pnpm run designsystemet tokens build -p -t ../../internal/design-tokens -o ../../packages/theme/brand --clean",
3422
+ "build:tokens:debug": "tsx --inspect-brk ./bin/designsystemet.ts tokens build -p -t ../../internal/design-tokens -o ../../packages/theme/brand --clean",
3395
3423
  build: "tsup && pnpm build:types && pnpm build:json-schema",
3396
3424
  "build:types": "tsc --emitDeclarationOnly --declaration",
3397
3425
  "build:json-schema": "tsx ./src/scripts/createJsonSchema.ts",
3398
3426
  types: "tsc --noEmit",
3399
- "test:tokens-create-options": 'pnpm run designsystemet tokens create -m dominant:"#007682" -n "#003333" -b 99 -o ./test-tokens/options --theme options --clean',
3400
- "test:tokens-create-config": "pnpm run designsystemet tokens create --config ./test/test-tokens.config.json",
3401
- "test:tokens-build": "pnpm run designsystemet tokens build -t ./test-tokens/options -o ./test-tokens/options-build --clean",
3402
- "test:tokens-build-config": "pnpm run designsystemet tokens build -t ./test-tokens/config -o ./test-tokens/config-build --clean",
3427
+ "test:tokens-create-options": 'pnpm run designsystemet tokens create -m dominant:"#007682" -n "#003333" -b 99 -o ./temp/options/design-tokens --theme options --clean',
3428
+ "test:tokens-create-config": "pnpm run designsystemet tokens create --config ./configs/test-tokens.config.json",
3429
+ "test:tokens-build": "pnpm run designsystemet tokens build -t ./temp/options/design-tokens -o ./temp/options/build --clean",
3430
+ "test:tokens-build-config": "pnpm run designsystemet tokens build -t ./temp/config/design-tokens -o ./temp/config/build --clean",
3403
3431
  "test:tokens-create-and-build-options": "pnpm test:tokens-create-options && pnpm test:tokens-build",
3404
3432
  "test:tokens-create-and-build-config": "pnpm test:tokens-create-config && pnpm test:tokens-build-config",
3405
3433
  test: "pnpm test:tokens-create-and-build-options && pnpm test:tokens-create-and-build-config",
3406
- "internal:tokens-create": "pnpm run designsystemet tokens create --config ./internal.config.json",
3434
+ "digdir:tokens-create": "pnpm run designsystemet tokens create --config ./configs/digdir.config.json",
3407
3435
  "update:template": "tsx ./src/scripts/update-template.ts",
3408
- "update:design-tokens": "pnpm internal:tokens-create && tsx ./src/scripts/update-design-tokens.ts",
3409
- verify: "pnpm test && pnpm update:template && pnpm update:design-tokens"
3436
+ "update:theme-digdir": "pnpm digdir:tokens-create && tsx ./src/scripts/update-design-tokens.ts",
3437
+ verify: "pnpm test && pnpm update:template && pnpm update:theme-digdir && pnpm build:tokens"
3410
3438
  },
3411
3439
  dependencies: {
3412
3440
  "@commander-js/extra-typings": "^13.1.0",
@@ -3423,8 +3451,8 @@ var package_default = {
3423
3451
  postcss: "^8.5.3",
3424
3452
  ramda: "^0.30.1",
3425
3453
  "style-dictionary": "^4.4.0",
3426
- zod: "^3.24.4",
3427
- "zod-validation-error": "^3.4.0"
3454
+ zod: "^3.25.30",
3455
+ "zod-validation-error": "^3.4.1"
3428
3456
  },
3429
3457
  devDependencies: {
3430
3458
  "@tokens-studio/types": "0.5.2",
@@ -3433,16 +3461,15 @@ var package_default = {
3433
3461
  "@types/fs-extra": "^11.0.4",
3434
3462
  "@types/glob": "^8.1.0",
3435
3463
  "@types/jscodeshift": "^0.12.0",
3436
- "@types/node": "^22.15.3",
3464
+ "@types/node": "^22.15.21",
3437
3465
  "@types/object-hash": "^3.0.6",
3438
3466
  "@types/ramda": "^0.30.2",
3439
3467
  "fs-extra": "^11.3.0",
3440
3468
  "ts-toolbelt": "^9.6.0",
3441
3469
  tslib: "^2.8.1",
3442
- tsup: "^8.4.0",
3470
+ tsup: "^8.5.0",
3443
3471
  tsx: "^4.19.4",
3444
- typescript: "^5.8.3",
3445
- "zod-to-json-schema": "^3.24.5"
3472
+ typescript: "^5.8.3"
3446
3473
  }
3447
3474
  };
3448
3475
 
@@ -3496,9 +3523,6 @@ order may change due to nondeterminism.`.trim()
3496
3523
  return sortIndex;
3497
3524
  });
3498
3525
  const header = `@charset "UTF-8";
3499
-
3500
- @layer ds.theme, ds.base, ds.utilities, ds.components;
3501
-
3502
3526
  /*
3503
3527
  ${fileHeader2}
3504
3528
  */
@@ -3523,7 +3547,7 @@ ${fileHeader2}
3523
3547
  // src/tokens/format.ts
3524
3548
  var formatTokens = async (options) => {
3525
3549
  const processedBuilds = await processPlatform({
3526
- process: "format",
3550
+ type: "format",
3527
3551
  ...options
3528
3552
  });
3529
3553
  return processedBuilds;
@@ -3,6 +3,14 @@ import * as R12 from "ramda";
3
3
 
4
4
  // src/tokens/utils.ts
5
5
  import * as R from "ramda";
6
+
7
+ // src/tokens/types.ts
8
+ var colorCategories = {
9
+ main: "main",
10
+ support: "support"
11
+ };
12
+
13
+ // src/tokens/utils.ts
6
14
  var mapToLowerCase = R.map(R.toLower);
7
15
  var hasAnyTruth = R.any(R.equals(true));
8
16
  var getType = (token) => (token.$type ?? token.type) || "";
@@ -36,7 +44,9 @@ function isGlobalColorToken(token) {
36
44
  }
37
45
  function isColorCategoryToken(token, category) {
38
46
  if (!category) {
39
- return ["main", "support"].some((c) => isColorCategoryToken(token, c));
47
+ return Object.keys(colorCategories).some(
48
+ (colorCategory2) => isColorCategoryToken(token, colorCategory2)
49
+ );
40
50
  }
41
51
  return R.startsWith(["color", category], token.path);
42
52
  }
@@ -59,14 +69,6 @@ function inlineTokens(shouldInline, tokens) {
59
69
  // src/tokens/process/formats/css/color.ts
60
70
  import * as R2 from "ramda";
61
71
  import { createPropertyFormatter } from "style-dictionary/utils";
62
-
63
- // src/tokens/types.ts
64
- var colorCategories = {
65
- main: "main",
66
- support: "support"
67
- };
68
-
69
- // src/tokens/process/formats/css/color.ts
70
72
  var prefersColorScheme = (colorScheme2, content) => `
71
73
  @media (prefers-color-scheme: ${colorScheme2}) {
72
74
  [data-color-scheme="auto"] ${content}
@@ -791,7 +793,7 @@ var colorCategoryVariables = (opts) => ({ "color-scheme": colorScheme2, theme, .
791
793
  );
792
794
  }
793
795
  const layer = `ds.theme.color`;
794
- const isRootColor = color === buildOptions?.rootColor;
796
+ const isRootColor = color === buildOptions?.defaultColor;
795
797
  const selector = isRootColor ? `:root, [data-color-scheme], [data-color="${color}"]` : `[data-color="${color}"], [data-color-scheme][data-color="${color}"]`;
796
798
  const config = {
797
799
  preprocessors: ["tokens-studio"],
@@ -4,6 +4,14 @@ import { outputReferencesFilter } from "style-dictionary/utils";
4
4
 
5
5
  // src/tokens/utils.ts
6
6
  import * as R from "ramda";
7
+
8
+ // src/tokens/types.ts
9
+ var colorCategories = {
10
+ main: "main",
11
+ support: "support"
12
+ };
13
+
14
+ // src/tokens/utils.ts
7
15
  var mapToLowerCase = R.map(R.toLower);
8
16
  var hasAnyTruth = R.any(R.equals(true));
9
17
  var getType = (token) => (token.$type ?? token.type) || "";
@@ -34,7 +42,9 @@ function isGlobalColorToken(token) {
34
42
  }
35
43
  function isColorCategoryToken(token, category) {
36
44
  if (!category) {
37
- return ["main", "support"].some((c) => isColorCategoryToken(token, c));
45
+ return Object.keys(colorCategories).some(
46
+ (colorCategory2) => isColorCategoryToken(token, colorCategory2)
47
+ );
38
48
  }
39
49
  return R.startsWith(["color", category], token.path);
40
50
  }
@@ -57,14 +67,6 @@ function inlineTokens(shouldInline, tokens) {
57
67
  // src/tokens/process/formats/css/color.ts
58
68
  import * as R2 from "ramda";
59
69
  import { createPropertyFormatter } from "style-dictionary/utils";
60
-
61
- // src/tokens/types.ts
62
- var colorCategories = {
63
- main: "main",
64
- support: "support"
65
- };
66
-
67
- // src/tokens/process/formats/css/color.ts
68
70
  var prefersColorScheme = (colorScheme2, content) => `
69
71
  @media (prefers-color-scheme: ${colorScheme2}) {
70
72
  [data-color-scheme="auto"] ${content}
@@ -4,6 +4,14 @@ import { outputReferencesFilter } from "style-dictionary/utils";
4
4
 
5
5
  // src/tokens/utils.ts
6
6
  import * as R from "ramda";
7
+
8
+ // src/tokens/types.ts
9
+ var colorCategories = {
10
+ main: "main",
11
+ support: "support"
12
+ };
13
+
14
+ // src/tokens/utils.ts
7
15
  var mapToLowerCase = R.map(R.toLower);
8
16
  var hasAnyTruth = R.any(R.equals(true));
9
17
  var getType = (token) => (token.$type ?? token.type) || "";
@@ -28,7 +36,9 @@ var pathStartsWithOneOf = R.curry(
28
36
  );
29
37
  function isColorCategoryToken(token, category) {
30
38
  if (!category) {
31
- return ["main", "support"].some((c) => isColorCategoryToken(token, c));
39
+ return Object.keys(colorCategories).some(
40
+ (colorCategory) => isColorCategoryToken(token, colorCategory)
41
+ );
32
42
  }
33
43
  return R.startsWith(["color", category], token.path);
34
44
  }
@@ -3,6 +3,14 @@ import { expandTypesMap } from "@tokens-studio/sd-transforms";
3
3
 
4
4
  // src/tokens/utils.ts
5
5
  import * as R from "ramda";
6
+
7
+ // src/tokens/types.ts
8
+ var colorCategories = {
9
+ main: "main",
10
+ support: "support"
11
+ };
12
+
13
+ // src/tokens/utils.ts
6
14
  var mapToLowerCase = R.map(R.toLower);
7
15
  var hasAnyTruth = R.any(R.equals(true));
8
16
  var getType = (token) => (token.$type ?? token.type) || "";
@@ -33,7 +41,9 @@ function isGlobalColorToken(token) {
33
41
  }
34
42
  function isColorCategoryToken(token, category) {
35
43
  if (!category) {
36
- return ["main", "support"].some((c) => isColorCategoryToken(token, c));
44
+ return Object.keys(colorCategories).some(
45
+ (colorCategory2) => isColorCategoryToken(token, colorCategory2)
46
+ );
37
47
  }
38
48
  return R.startsWith(["color", category], token.path);
39
49
  }
@@ -56,14 +66,6 @@ function inlineTokens(shouldInline, tokens) {
56
66
  // src/tokens/process/formats/css/color.ts
57
67
  import * as R2 from "ramda";
58
68
  import { createPropertyFormatter } from "style-dictionary/utils";
59
-
60
- // src/tokens/types.ts
61
- var colorCategories = {
62
- main: "main",
63
- support: "support"
64
- };
65
-
66
- // src/tokens/process/formats/css/color.ts
67
69
  var prefersColorScheme = (colorScheme2, content) => `
68
70
  @media (prefers-color-scheme: ${colorScheme2}) {
69
71
  [data-color-scheme="auto"] ${content}
@@ -5,6 +5,14 @@ import StyleDictionary2 from "style-dictionary";
5
5
 
6
6
  // src/tokens/utils.ts
7
7
  import * as R from "ramda";
8
+
9
+ // src/tokens/types.ts
10
+ var colorCategories = {
11
+ main: "main",
12
+ support: "support"
13
+ };
14
+
15
+ // src/tokens/utils.ts
8
16
  var mapToLowerCase = R.map(R.toLower);
9
17
  var hasAnyTruth = R.any(R.equals(true));
10
18
  var getType = (token) => (token.$type ?? token.type) || "";
@@ -38,7 +46,9 @@ function isGlobalColorToken(token) {
38
46
  }
39
47
  function isColorCategoryToken(token, category) {
40
48
  if (!category) {
41
- return ["main", "support"].some((c) => isColorCategoryToken(token, c));
49
+ return Object.keys(colorCategories).some(
50
+ (colorCategory2) => isColorCategoryToken(token, colorCategory2)
51
+ );
42
52
  }
43
53
  return R.startsWith(["color", category], token.path);
44
54
  }
@@ -76,14 +86,6 @@ import * as R8 from "ramda";
76
86
  // src/tokens/process/formats/css/color.ts
77
87
  import * as R2 from "ramda";
78
88
  import { createPropertyFormatter } from "style-dictionary/utils";
79
-
80
- // src/tokens/types.ts
81
- var colorCategories = {
82
- main: "main",
83
- support: "support"
84
- };
85
-
86
- // src/tokens/process/formats/css/color.ts
87
89
  var prefersColorScheme = (colorScheme2, content) => `
88
90
  @media (prefers-color-scheme: ${colorScheme2}) {
89
91
  [data-color-scheme="auto"] ${content}
@@ -460,24 +462,9 @@ var getMultidimensionalThemes = (processed$themes, dimensions) => {
460
462
  });
461
463
  };
462
464
  var processed = Symbol("Type brand for ProcessedThemeObject");
463
- function isProcessed(theme) {
464
- return Boolean(theme[processed]);
465
- }
466
- function processThemeObject(theme) {
467
- if (isProcessed(theme)) {
468
- return theme;
469
- }
470
- const result = { ...theme, [processed]: true };
471
- if (result.group) {
472
- result.group = kebabCase(result.group);
473
- }
474
- result.name = kebabCase(result.name);
475
- return result;
476
- }
477
465
  function groupThemes(themes) {
478
466
  const groups = {};
479
- for (const rawTheme of themes) {
480
- const theme = processThemeObject(rawTheme);
467
+ for (const theme of themes) {
481
468
  if (theme.group) {
482
469
  const groupKey = theme.group;
483
470
  groups[groupKey] = [...groups[groupKey] ?? [], theme];
@@ -702,7 +689,7 @@ var colorCategoryVariables = (opts) => ({ "color-scheme": colorScheme2, theme, .
702
689
  );
703
690
  }
704
691
  const layer = `ds.theme.color`;
705
- const isRootColor = color === buildOptions?.rootColor;
692
+ const isRootColor = color === buildOptions?.defaultColor;
706
693
  const selector = isRootColor ? `:root, [data-color-scheme], [data-color="${color}"]` : `[data-color="${color}"], [data-color-scheme][data-color="${color}"]`;
707
694
  const config = {
708
695
  preprocessors: ["tokens-studio"],
@@ -39,7 +39,9 @@ function isGlobalColorToken(token) {
39
39
  }
40
40
  function isColorCategoryToken(token, category) {
41
41
  if (!category) {
42
- return ["main", "support"].some((c) => isColorCategoryToken(token, c));
42
+ return Object.keys(colorCategories).some(
43
+ (colorCategory2) => isColorCategoryToken(token, colorCategory2)
44
+ );
43
45
  }
44
46
  return R.startsWith(["color", category], token.path);
45
47
  }
@@ -40,7 +40,9 @@ function isGlobalColorToken(token) {
40
40
  }
41
41
  function isColorCategoryToken(token, category) {
42
42
  if (!category) {
43
- return ["main", "support"].some((c) => isColorCategoryToken(token, c));
43
+ return Object.keys(colorCategories).some(
44
+ (colorCategory2) => isColorCategoryToken(token, colorCategory2)
45
+ );
44
46
  }
45
47
  return R.startsWith(["color", category], token.path);
46
48
  }