@nxds/core 0.10.0 → 0.12.0

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.
@@ -26,12 +26,19 @@ __export(src_exports, {
26
26
  CORNER_OPTIONS: () => CORNER_OPTIONS,
27
27
  DEFAULT_BRAND_COLOR: () => DEFAULT_BRAND_COLOR,
28
28
  DEFAULT_COOKIE_KEY: () => DEFAULT_COOKIE_KEY,
29
+ DEFAULT_ICON_LIBRARY: () => DEFAULT_ICON_LIBRARY,
29
30
  DEFAULT_NXDS_APPEARANCE: () => DEFAULT_NXDS_APPEARANCE,
31
+ DEFAULT_NXDS_THEME: () => DEFAULT_NXDS_THEME,
30
32
  DEFAULT_STORAGE_KEY: () => DEFAULT_STORAGE_KEY,
31
33
  DENSITY_OPTIONS: () => DENSITY_OPTIONS,
32
34
  ELEVATION_OPTIONS: () => ELEVATION_OPTIONS,
35
+ FONT_OPTIONS: () => FONT_OPTIONS,
36
+ FONT_SIZE_PX_MAX: () => FONT_SIZE_PX_MAX,
37
+ FONT_SIZE_PX_MIN: () => FONT_SIZE_PX_MIN,
38
+ ICON_LIBRARY_OPTIONS: () => ICON_LIBRARY_OPTIONS,
33
39
  NXDS_APPEARANCE_COOKIE_MAX_AGE_SECONDS: () => NXDS_APPEARANCE_COOKIE_MAX_AGE_SECONDS,
34
40
  NXDS_APPEARANCE_DATA_ATTRS: () => NXDS_APPEARANCE_DATA_ATTRS,
41
+ NXDS_THEME_FIELDS: () => NXDS_THEME_FIELDS,
35
42
  PALETTE_KEYS: () => PALETTE_KEYS,
36
43
  RUNTIME_LAYER_ORDER: () => RUNTIME_LAYER_ORDER,
37
44
  SEMANTIC_TOKEN_REGISTRY: () => SEMANTIC_TOKEN_REGISTRY,
@@ -42,6 +49,7 @@ __export(src_exports, {
42
49
  apcaLc: () => apcaLc,
43
50
  appearancePrefsToCss: () => appearancePrefsToCss,
44
51
  applyNxdsAppearance: () => applyNxdsAppearance,
52
+ applyNxdsThemeFlags: () => applyNxdsThemeFlags,
45
53
  createDefaultNxdsAppearanceSnapshot: () => createDefaultNxdsAppearanceSnapshot,
46
54
  createNxdsAppearanceBootstrapScript: () => createNxdsAppearanceBootstrapScript,
47
55
  createNxdsAppearanceSnapshot: () => createNxdsAppearanceSnapshot,
@@ -54,6 +62,7 @@ __export(src_exports, {
54
62
  isColor: () => isColor,
55
63
  measureThemeContrast: () => measureThemeContrast,
56
64
  normalizeAppearanceModeIds: () => normalizeAppearanceModeIds,
65
+ nxdsThemeFlags: () => nxdsThemeFlags,
57
66
  parseNxdsAppearanceStateCookie: () => parseNxdsAppearanceStateCookie,
58
67
  persistNxdsAppearance: () => persistNxdsAppearance,
59
68
  prefersDarkColorScheme: () => prefersDarkColorScheme,
@@ -65,6 +74,8 @@ __export(src_exports, {
65
74
  sanitizeNxdsAppearancePrefs: () => sanitizeNxdsAppearancePrefs,
66
75
  sanitizeNxdsAppearanceSnapshot: () => sanitizeNxdsAppearanceSnapshot,
67
76
  serializeNxdsAppearanceStateCookie: () => serializeNxdsAppearanceStateCookie,
77
+ shuffleNxdsAppearance: () => shuffleNxdsAppearance,
78
+ shuffleNxdsIconLibrary: () => shuffleNxdsIconLibrary,
68
79
  themeToCss: () => themeToCss,
69
80
  watchColorScheme: () => watchColorScheme
70
81
  });
@@ -2303,6 +2314,13 @@ var CHART_PALETTE_REFERENCES = [
2303
2314
  { palette: "rose", light: "600", dark: "200" },
2304
2315
  { palette: "indigo", light: "600", dark: "200" }
2305
2316
  ];
2317
+ var SYNTAX_PALETTE_REFERENCES = {
2318
+ keyword: CHART_PALETTE_REFERENCES[3],
2319
+ string: CHART_PALETTE_REFERENCES[1],
2320
+ function: CHART_PALETTE_REFERENCES[4],
2321
+ type: CHART_PALETTE_REFERENCES[0],
2322
+ constant: CHART_PALETTE_REFERENCES[2]
2323
+ };
2306
2324
 
2307
2325
  // src/lib/apca-pairs.ts
2308
2326
  var COLOR_FAMILIES = [
@@ -2317,6 +2335,8 @@ var CATEGORICAL_INDICES = CHART_PALETTE_REFERENCES.map(
2317
2335
  (_, index) => index + 1
2318
2336
  );
2319
2337
  var CHART_STAGGER_LC = 4.5;
2338
+ var DIFF_SURFACES = ["success-subtle", "error-subtle"];
2339
+ var CODE_SURFACES = ["container", "container-hover", ...DIFF_SURFACES];
2320
2340
  var FOCUS_SURFACES = [
2321
2341
  "background",
2322
2342
  "container",
@@ -2376,11 +2396,23 @@ var APCA_PAIRS = [
2376
2396
  ink(`${family}-subtle-foreground`, `${family}-subtle-active`, "ui")
2377
2397
  ]),
2378
2398
  ...CATEGORICAL_INDICES.flatMap(
2379
- (index) => ["container", "background"].map((bg) => ({
2399
+ (index) => ["container", "container-hover", "background"].map((bg) => ({
2380
2400
  ...ink(`chart-categorical-${index}`, bg, "ui"),
2381
2401
  offset: (index - 1) * CHART_STAGGER_LC
2382
2402
  }))
2383
2403
  ),
2404
+ ...CODE_SURFACES.flatMap(
2405
+ (bg) => Object.keys(SYNTAX_PALETTE_REFERENCES).map(
2406
+ (role) => ink(`syntax-${role}`, bg, "ui")
2407
+ )
2408
+ ),
2409
+ // codeBlockTheme also colours code with the text tokens, which already read
2410
+ // on container and container-hover.
2411
+ ...DIFF_SURFACES.flatMap((bg) => [
2412
+ text("foreground", bg, "ui"),
2413
+ text("muted-foreground", bg, "ui"),
2414
+ text("muted-foreground-subtle", bg, "incidental")
2415
+ ]),
2384
2416
  // Focus is the primary accent (components.md § Focus States), so it shares
2385
2417
  // one solved color with primary-subtle-foreground.
2386
2418
  ...FOCUS_SURFACES.flatMap((surface) => [
@@ -2454,8 +2486,10 @@ function rampFromSeed(seedHex, options = {}) {
2454
2486
  }
2455
2487
 
2456
2488
  // src/lib/contrast.ts
2489
+ var CONTRAST_MIN = 0;
2490
+ var CONTRAST_MAX = 100;
2457
2491
  function normalizeContrast(value, fallback = 50) {
2458
- return typeof value === "number" && Number.isFinite(value) ? Math.round(Math.max(0, Math.min(100, value))) : fallback;
2492
+ return typeof value === "number" && Number.isFinite(value) ? Math.round(Math.max(CONTRAST_MIN, Math.min(CONTRAST_MAX, value))) : fallback;
2459
2493
  }
2460
2494
  function contrastTarget(tier, contrast) {
2461
2495
  return TIER_THRESHOLDS[tier] + 15 * contrast / 100;
@@ -2647,6 +2681,7 @@ var DEFAULT_NXDS_APPEARANCE = {
2647
2681
  stroke: "normal",
2648
2682
  prefs: {
2649
2683
  uiFont: '-apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif',
2684
+ headingFont: null,
2650
2685
  codeFont: 'ui-monospace, "SF Mono", Menlo, monospace',
2651
2686
  uiFontSize: 14,
2652
2687
  codeFontSize: 12,
@@ -2655,8 +2690,8 @@ var DEFAULT_NXDS_APPEARANCE = {
2655
2690
  fontSmoothing: false
2656
2691
  }
2657
2692
  };
2658
- var FONT_PX_MIN = 8;
2659
- var FONT_PX_MAX = 32;
2693
+ var FONT_SIZE_PX_MIN = 8;
2694
+ var FONT_SIZE_PX_MAX = 32;
2660
2695
  var APPEARANCE_MODES = /* @__PURE__ */ new Set([
2661
2696
  "light",
2662
2697
  "dark",
@@ -2682,7 +2717,7 @@ var FONT_FAMILY_UNSAFE = /[;{}<]/;
2682
2717
  var fontFamilyOr = (value, fallback) => typeof value === "string" && value.length > 0 && !FONT_FAMILY_UNSAFE.test(value) ? value : fallback;
2683
2718
  var boolOr = (value, fallback) => typeof value === "boolean" ? value : fallback;
2684
2719
  var enumOr = (value, values, fallback) => typeof value === "string" && values.has(value) ? value : fallback;
2685
- var clampFontSize = (value, fallback) => typeof value === "number" && Number.isFinite(value) && value > 0 ? Math.min(FONT_PX_MAX, Math.max(FONT_PX_MIN, value)) : fallback;
2720
+ var clampFontSize = (value, fallback) => typeof value === "number" && Number.isFinite(value) && value > 0 ? Math.min(FONT_SIZE_PX_MAX, Math.max(FONT_SIZE_PX_MIN, value)) : fallback;
2686
2721
  function formatPx(value) {
2687
2722
  return `${Number(value.toFixed(4))}px`;
2688
2723
  }
@@ -2733,6 +2768,7 @@ function sanitizeNxdsAppearancePrefs(raw) {
2733
2768
  const d = DEFAULT_NXDS_APPEARANCE.prefs;
2734
2769
  return {
2735
2770
  uiFont: fontFamilyOr(o.uiFont, d.uiFont),
2771
+ headingFont: fontFamilyOr(o.headingFont, d.headingFont),
2736
2772
  codeFont: fontFamilyOr(o.codeFont, d.codeFont),
2737
2773
  uiFontSize: clampFontSize(o.uiFontSize, d.uiFontSize),
2738
2774
  codeFontSize: clampFontSize(o.codeFontSize, d.codeFontSize),
@@ -2779,6 +2815,7 @@ function appearancePrefsToCss(prefs) {
2779
2815
  const blocks = [
2780
2816
  inRuntimeLayer(`:root {
2781
2817
  --nx-typography-family-font-sans: ${prefs.uiFont};
2818
+ --nx-typography-family-font-heading: ${prefs.headingFont ?? "var(--nx-typography-family-font-sans)"};
2782
2819
  --nx-typography-family-font-mono: ${prefs.codeFont};
2783
2820
  ${typographyScaleVariables(uiPx)}
2784
2821
  }`),
@@ -4461,6 +4498,14 @@ function deriveChart(mode) {
4461
4498
  ])
4462
4499
  );
4463
4500
  }
4501
+ function deriveSyntax(mode) {
4502
+ return Object.fromEntries(
4503
+ Object.entries(SYNTAX_PALETTE_REFERENCES).map(([role, reference]) => [
4504
+ `--nx-color-syntax-${role}`,
4505
+ getPaletteShade(reference.palette, reference[mode])
4506
+ ])
4507
+ );
4508
+ }
4464
4509
  function deriveAlpha(surfaceTone, mode, profile) {
4465
4510
  const tone = SURFACE_TONE[surfaceTone];
4466
4511
  const dark = mode === "dark";
@@ -4576,6 +4621,7 @@ function deriveThemeMode(input, mode) {
4576
4621
  ...deriveSecondary(mode),
4577
4622
  ...deriveStatus(mode),
4578
4623
  ...deriveChart(mode),
4624
+ ...deriveSyntax(mode),
4579
4625
  ...deriveAlpha(surfaceTone, mode, profile),
4580
4626
  "--nx-color-focus-error": getPaletteShade(
4581
4627
  STATUS_PALETTE_FAMILIES.error,
@@ -4870,6 +4916,127 @@ function findBrandColorPreset(color) {
4870
4916
  return BRAND_COLOR_PRESETS.find((preset) => preset.color === hex);
4871
4917
  }
4872
4918
 
4919
+ // src/lib/font-options.ts
4920
+ var SANS_FALLBACK = '-apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif';
4921
+ var SERIF_FALLBACK = "Georgia, serif";
4922
+ var MONO_FALLBACK = 'ui-monospace, "SF Mono", Menlo, monospace';
4923
+ var FONT_OPTIONS = [
4924
+ {
4925
+ value: "geist",
4926
+ label: "Geist",
4927
+ category: "sans",
4928
+ family: `"Geist Variable", ${SANS_FALLBACK}`,
4929
+ package: "@fontsource-variable/geist"
4930
+ },
4931
+ {
4932
+ value: "inter",
4933
+ label: "Inter",
4934
+ category: "sans",
4935
+ family: `"Inter Variable", ${SANS_FALLBACK}`,
4936
+ package: "@fontsource-variable/inter"
4937
+ },
4938
+ {
4939
+ value: "figtree",
4940
+ label: "Figtree",
4941
+ category: "sans",
4942
+ family: `"Figtree Variable", ${SANS_FALLBACK}`,
4943
+ package: "@fontsource-variable/figtree"
4944
+ },
4945
+ {
4946
+ value: "dm-sans",
4947
+ label: "DM Sans",
4948
+ category: "sans",
4949
+ family: `"DM Sans Variable", ${SANS_FALLBACK}`,
4950
+ package: "@fontsource-variable/dm-sans"
4951
+ },
4952
+ {
4953
+ value: "manrope",
4954
+ label: "Manrope",
4955
+ category: "sans",
4956
+ family: `"Manrope Variable", ${SANS_FALLBACK}`,
4957
+ package: "@fontsource-variable/manrope"
4958
+ },
4959
+ {
4960
+ value: "ibm-plex-sans",
4961
+ label: "IBM Plex Sans",
4962
+ category: "sans",
4963
+ family: `"IBM Plex Sans Variable", ${SANS_FALLBACK}`,
4964
+ package: "@fontsource-variable/ibm-plex-sans"
4965
+ },
4966
+ {
4967
+ value: "lora",
4968
+ label: "Lora",
4969
+ category: "serif",
4970
+ family: `"Lora Variable", ${SERIF_FALLBACK}`,
4971
+ package: "@fontsource-variable/lora"
4972
+ },
4973
+ {
4974
+ value: "playfair-display",
4975
+ label: "Playfair Display",
4976
+ category: "serif",
4977
+ family: `"Playfair Display Variable", ${SERIF_FALLBACK}`,
4978
+ package: "@fontsource-variable/playfair-display"
4979
+ },
4980
+ {
4981
+ value: "geist-mono",
4982
+ label: "Geist Mono",
4983
+ category: "mono",
4984
+ family: `"Geist Mono Variable", ${MONO_FALLBACK}`,
4985
+ package: "@fontsource-variable/geist-mono"
4986
+ },
4987
+ {
4988
+ value: "jetbrains-mono",
4989
+ label: "JetBrains Mono",
4990
+ category: "mono",
4991
+ family: `"JetBrains Mono Variable", ${MONO_FALLBACK}`,
4992
+ package: "@fontsource-variable/jetbrains-mono"
4993
+ }
4994
+ ];
4995
+
4996
+ // src/lib/icon-libraries.ts
4997
+ var ICON_LIBRARY_OPTIONS = [
4998
+ { value: "phosphor", label: "Phosphor" },
4999
+ { value: "lucide", label: "Lucide" },
5000
+ { value: "tabler", label: "Tabler Icons" },
5001
+ { value: "hugeicons", label: "HugeIcons" },
5002
+ { value: "remix", label: "Remix Icon" }
5003
+ ];
5004
+ var DEFAULT_ICON_LIBRARY = "phosphor";
5005
+
5006
+ // src/lib/appearance-shuffle.ts
5007
+ function pick(options, random) {
5008
+ const option = options[Math.floor(random() * options.length)];
5009
+ if (option === void 0) throw new Error("No option to pick from.");
5010
+ return option;
5011
+ }
5012
+ function shuffleNxdsAppearance(state, { fonts = FONT_OPTIONS, random = Math.random } = {}) {
5013
+ const textFonts = fonts.filter((font) => font.category !== "mono").map((font) => font.family);
5014
+ if (textFonts.length === 0) {
5015
+ throw new Error(
5016
+ "shuffleNxdsAppearance: `fonts` needs at least one sans or serif font."
5017
+ );
5018
+ }
5019
+ return {
5020
+ ...state,
5021
+ brandColor: pick(BRAND_COLOR_PRESETS, random).color,
5022
+ surfaceTone: pick(BASE_TONE_OPTIONS, random).value,
5023
+ density: pick(DENSITY_OPTIONS, random).value,
5024
+ corners: pick(CORNER_OPTIONS, random).value,
5025
+ elevation: pick(ELEVATION_OPTIONS, random).value,
5026
+ stroke: pick(STROKE_OPTIONS, random).value,
5027
+ prefs: {
5028
+ ...state.prefs,
5029
+ uiFont: pick(textFonts, random),
5030
+ headingFont: pick([null, ...textFonts], random)
5031
+ }
5032
+ };
5033
+ }
5034
+ function shuffleNxdsIconLibrary({
5035
+ random = Math.random
5036
+ } = {}) {
5037
+ return pick(ICON_LIBRARY_OPTIONS, random).value;
5038
+ }
5039
+
4873
5040
  // src/lib/theme-contrast.ts
4874
5041
  var MODES = ["light", "dark"];
4875
5042
  var cssVar = (name) => `--nx-color-${name}`;
@@ -4895,6 +5062,211 @@ function measureThemeContrast(theme) {
4895
5062
  );
4896
5063
  }
4897
5064
 
5065
+ // src/lib/theme-fields.ts
5066
+ var DEFAULT_NXDS_THEME = {
5067
+ appearance: DEFAULT_NXDS_APPEARANCE,
5068
+ iconLibrary: DEFAULT_ICON_LIBRARY
5069
+ };
5070
+ function invalid(flag, value, accepted) {
5071
+ return new Error(`--${flag} "${value}" isn't ${accepted}.`);
5072
+ }
5073
+ function withAppearance(theme, patch) {
5074
+ return { ...theme, appearance: { ...theme.appearance, ...patch } };
5075
+ }
5076
+ function withPrefs(theme, patch) {
5077
+ return withAppearance(theme, {
5078
+ prefs: { ...theme.appearance.prefs, ...patch }
5079
+ });
5080
+ }
5081
+ function oneOf(flag, values, value) {
5082
+ const match = values.find((candidate) => candidate === value);
5083
+ if (match === void 0) {
5084
+ throw invalid(flag, value, `one of ${values.join(", ")}`);
5085
+ }
5086
+ return match;
5087
+ }
5088
+ function enumField(flag, key, description, values) {
5089
+ return {
5090
+ kind: "choice",
5091
+ flag,
5092
+ key,
5093
+ description,
5094
+ values,
5095
+ read: (theme) => theme.appearance[key],
5096
+ write: (theme, value) => withAppearance(theme, {
5097
+ [key]: oneOf(flag, values, value)
5098
+ })
5099
+ };
5100
+ }
5101
+ function integer(flag, value, min, max) {
5102
+ const parsed = Number(value);
5103
+ if (!/^\d+$/.test(value) || parsed < min || parsed > max) {
5104
+ throw invalid(flag, value, `a whole number from ${min} to ${max}`);
5105
+ }
5106
+ return parsed;
5107
+ }
5108
+ function contrastField(flag, key, description) {
5109
+ return {
5110
+ kind: "integer",
5111
+ flag,
5112
+ key,
5113
+ description,
5114
+ min: CONTRAST_MIN,
5115
+ max: CONTRAST_MAX,
5116
+ read: (theme) => String(theme.appearance[key]),
5117
+ write: (theme, value) => withAppearance(theme, {
5118
+ [key]: integer(flag, value, CONTRAST_MIN, CONTRAST_MAX)
5119
+ })
5120
+ };
5121
+ }
5122
+ function fontSizeField(flag, key, description) {
5123
+ return {
5124
+ kind: "integer",
5125
+ flag,
5126
+ key: `prefs.${key}`,
5127
+ description,
5128
+ min: FONT_SIZE_PX_MIN,
5129
+ max: FONT_SIZE_PX_MAX,
5130
+ read: (theme) => String(theme.appearance.prefs[key]),
5131
+ write: (theme, value) => withPrefs(theme, {
5132
+ [key]: integer(flag, value, FONT_SIZE_PX_MIN, FONT_SIZE_PX_MAX)
5133
+ })
5134
+ };
5135
+ }
5136
+ function fontField(flag, key, description, categories, fallback) {
5137
+ const fonts = FONT_OPTIONS.filter(
5138
+ (font) => categories.includes(font.category)
5139
+ );
5140
+ return {
5141
+ kind: "font",
5142
+ flag,
5143
+ key: `prefs.${key}`,
5144
+ description,
5145
+ values: [fallback.value, ...fonts.map((font) => font.value)],
5146
+ categories,
5147
+ fallback,
5148
+ read: (theme) => {
5149
+ const family = theme.appearance.prefs[key];
5150
+ if (family === fallback.family) return fallback.value;
5151
+ return fonts.find((font) => font.family === family)?.value;
5152
+ },
5153
+ write: (theme, value) => {
5154
+ const family = value === fallback.value ? fallback.family : fonts.find((font) => font.value === value)?.family;
5155
+ if (family === void 0) {
5156
+ throw invalid(
5157
+ flag,
5158
+ value,
5159
+ `one of ${[fallback.value, ...fonts.map((font) => font.value)].join(", ")}`
5160
+ );
5161
+ }
5162
+ return withPrefs(theme, { [key]: family });
5163
+ }
5164
+ };
5165
+ }
5166
+ var DEFAULT_PREFS = DEFAULT_NXDS_APPEARANCE.prefs;
5167
+ var TEXT_FONTS = ["sans", "serif"];
5168
+ var NXDS_THEME_FIELDS = [
5169
+ {
5170
+ kind: "color",
5171
+ flag: "brand-color",
5172
+ key: "brandColor",
5173
+ description: 'brand color, as any CSS color, such as "#4f46e5"',
5174
+ read: (theme) => theme.appearance.brandColor,
5175
+ write: (theme, value) => {
5176
+ if (!isColor(value)) throw invalid("brand-color", value, "a CSS color");
5177
+ return withAppearance(theme, { brandColor: value });
5178
+ }
5179
+ },
5180
+ enumField(
5181
+ "surface-tone",
5182
+ "surfaceTone",
5183
+ "neutral tone of backgrounds and borders",
5184
+ BASE_TONE_OPTIONS.map((option) => option.value)
5185
+ ),
5186
+ enumField(
5187
+ "density",
5188
+ "density",
5189
+ "spacing and control size",
5190
+ DENSITY_OPTIONS.map((option) => option.value)
5191
+ ),
5192
+ enumField(
5193
+ "corners",
5194
+ "corners",
5195
+ "corner radius",
5196
+ CORNER_OPTIONS.map((option) => option.value)
5197
+ ),
5198
+ enumField(
5199
+ "elevation",
5200
+ "elevation",
5201
+ "shadow depth",
5202
+ ELEVATION_OPTIONS.map((option) => option.value)
5203
+ ),
5204
+ enumField(
5205
+ "stroke",
5206
+ "stroke",
5207
+ "border width",
5208
+ STROKE_OPTIONS.map((option) => option.value)
5209
+ ),
5210
+ enumField("mode", "mode", "color scheme", ["light", "dark", "system"]),
5211
+ contrastField(
5212
+ "light-contrast",
5213
+ "lightContrast",
5214
+ "light mode contrast, 0 to 100"
5215
+ ),
5216
+ contrastField(
5217
+ "dark-contrast",
5218
+ "darkContrast",
5219
+ "dark mode contrast, 0 to 100"
5220
+ ),
5221
+ fontField("font", "uiFont", "font for UI text", TEXT_FONTS, {
5222
+ value: "system",
5223
+ family: DEFAULT_PREFS.uiFont
5224
+ }),
5225
+ fontField(
5226
+ "heading-font",
5227
+ "headingFont",
5228
+ 'font for headings, or "ui" for the UI font',
5229
+ TEXT_FONTS,
5230
+ { value: "ui", family: null }
5231
+ ),
5232
+ fontField("code-font", "codeFont", "font for code", ["mono"], {
5233
+ value: "system",
5234
+ family: DEFAULT_PREFS.codeFont
5235
+ }),
5236
+ fontSizeField("font-size", "uiFontSize", "UI text size in px"),
5237
+ fontSizeField("code-font-size", "codeFontSize", "code text size in px"),
5238
+ {
5239
+ kind: "choice",
5240
+ flag: "icons",
5241
+ description: "icon library nxds components draw",
5242
+ values: ICON_LIBRARY_OPTIONS.map((option) => option.value),
5243
+ read: (theme) => theme.iconLibrary,
5244
+ write: (theme, value) => ({
5245
+ ...theme,
5246
+ iconLibrary: oneOf(
5247
+ "icons",
5248
+ ICON_LIBRARY_OPTIONS.map((option) => option.value),
5249
+ value
5250
+ )
5251
+ })
5252
+ }
5253
+ ];
5254
+ function nxdsThemeFlags(theme) {
5255
+ return NXDS_THEME_FIELDS.flatMap((field) => {
5256
+ const value = field.read(theme);
5257
+ if (value === void 0 || value === field.read(DEFAULT_NXDS_THEME)) {
5258
+ return [];
5259
+ }
5260
+ return [{ flag: field.flag, value }];
5261
+ });
5262
+ }
5263
+ function applyNxdsThemeFlags(theme, values) {
5264
+ return NXDS_THEME_FIELDS.reduce((current, field) => {
5265
+ const value = values[field.flag];
5266
+ return value === void 0 ? current : field.write(current, value);
5267
+ }, theme);
5268
+ }
5269
+
4898
5270
  // src/lib/token-registry.ts
4899
5271
  var SURFACE_TOKEN_NAMES = [
4900
5272
  "background",
@@ -5008,6 +5380,13 @@ var CHART_TOKEN_NAMES = [
5008
5380
  "chart-categorical-4",
5009
5381
  "chart-categorical-5"
5010
5382
  ];
5383
+ var SYNTAX_TOKEN_NAMES = [
5384
+ "syntax-keyword",
5385
+ "syntax-string",
5386
+ "syntax-function",
5387
+ "syntax-type",
5388
+ "syntax-constant"
5389
+ ];
5011
5390
  var FOCUS_TOKEN_NAMES = ["focus-default", "focus-error"];
5012
5391
  var ALPHA_TOKEN_NAMES = [
5013
5392
  "background-hover-alpha",
@@ -5026,6 +5405,7 @@ var SEMANTIC_TOKEN_REGISTRY = [
5026
5405
  ...metas("brand", BRAND_TOKEN_NAMES),
5027
5406
  ...metas("status", STATUS_TOKEN_NAMES),
5028
5407
  ...metas("chart", CHART_TOKEN_NAMES),
5408
+ ...metas("syntax", SYNTAX_TOKEN_NAMES),
5029
5409
  ...metas("focus", FOCUS_TOKEN_NAMES),
5030
5410
  ...metas("alpha", ALPHA_TOKEN_NAMES)
5031
5411
  ];
@@ -5037,12 +5417,19 @@ var SEMANTIC_TOKEN_REGISTRY = [
5037
5417
  CORNER_OPTIONS,
5038
5418
  DEFAULT_BRAND_COLOR,
5039
5419
  DEFAULT_COOKIE_KEY,
5420
+ DEFAULT_ICON_LIBRARY,
5040
5421
  DEFAULT_NXDS_APPEARANCE,
5422
+ DEFAULT_NXDS_THEME,
5041
5423
  DEFAULT_STORAGE_KEY,
5042
5424
  DENSITY_OPTIONS,
5043
5425
  ELEVATION_OPTIONS,
5426
+ FONT_OPTIONS,
5427
+ FONT_SIZE_PX_MAX,
5428
+ FONT_SIZE_PX_MIN,
5429
+ ICON_LIBRARY_OPTIONS,
5044
5430
  NXDS_APPEARANCE_COOKIE_MAX_AGE_SECONDS,
5045
5431
  NXDS_APPEARANCE_DATA_ATTRS,
5432
+ NXDS_THEME_FIELDS,
5046
5433
  PALETTE_KEYS,
5047
5434
  RUNTIME_LAYER_ORDER,
5048
5435
  SEMANTIC_TOKEN_REGISTRY,
@@ -5053,6 +5440,7 @@ var SEMANTIC_TOKEN_REGISTRY = [
5053
5440
  apcaLc,
5054
5441
  appearancePrefsToCss,
5055
5442
  applyNxdsAppearance,
5443
+ applyNxdsThemeFlags,
5056
5444
  createDefaultNxdsAppearanceSnapshot,
5057
5445
  createNxdsAppearanceBootstrapScript,
5058
5446
  createNxdsAppearanceSnapshot,
@@ -5065,6 +5453,7 @@ var SEMANTIC_TOKEN_REGISTRY = [
5065
5453
  isColor,
5066
5454
  measureThemeContrast,
5067
5455
  normalizeAppearanceModeIds,
5456
+ nxdsThemeFlags,
5068
5457
  parseNxdsAppearanceStateCookie,
5069
5458
  persistNxdsAppearance,
5070
5459
  prefersDarkColorScheme,
@@ -5076,6 +5465,8 @@ var SEMANTIC_TOKEN_REGISTRY = [
5076
5465
  sanitizeNxdsAppearancePrefs,
5077
5466
  sanitizeNxdsAppearanceSnapshot,
5078
5467
  serializeNxdsAppearanceStateCookie,
5468
+ shuffleNxdsAppearance,
5469
+ shuffleNxdsIconLibrary,
5079
5470
  themeToCss,
5080
5471
  watchColorScheme
5081
5472
  });