@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.
- package/dist/runtime/catalogue.cjs +85 -3
- package/dist/runtime/catalogue.cjs.map +1 -1
- package/dist/runtime/catalogue.d.cts +2 -2
- package/dist/runtime/catalogue.d.ts +2 -2
- package/dist/runtime/catalogue.js +85 -3
- package/dist/runtime/catalogue.js.map +1 -1
- package/dist/runtime/index.cjs +396 -5
- package/dist/runtime/index.cjs.map +1 -1
- package/dist/runtime/index.d.cts +195 -5
- package/dist/runtime/index.d.ts +195 -5
- package/dist/runtime/index.js +385 -5
- package/dist/runtime/index.js.map +1 -1
- package/dist/runtime/{surface-ladder-B950TU4_.d.ts → surface-ladder-CAjRqzCx.d.ts} +6 -1
- package/dist/runtime/{surface-ladder-C8HTwT7z.d.cts → surface-ladder-tv7B_RKy.d.cts} +6 -1
- package/package.json +1 -1
package/dist/runtime/index.js
CHANGED
|
@@ -2231,6 +2231,13 @@ var CHART_PALETTE_REFERENCES = [
|
|
|
2231
2231
|
{ palette: "rose", light: "600", dark: "200" },
|
|
2232
2232
|
{ palette: "indigo", light: "600", dark: "200" }
|
|
2233
2233
|
];
|
|
2234
|
+
var SYNTAX_PALETTE_REFERENCES = {
|
|
2235
|
+
keyword: CHART_PALETTE_REFERENCES[3],
|
|
2236
|
+
string: CHART_PALETTE_REFERENCES[1],
|
|
2237
|
+
function: CHART_PALETTE_REFERENCES[4],
|
|
2238
|
+
type: CHART_PALETTE_REFERENCES[0],
|
|
2239
|
+
constant: CHART_PALETTE_REFERENCES[2]
|
|
2240
|
+
};
|
|
2234
2241
|
|
|
2235
2242
|
// src/lib/apca-pairs.ts
|
|
2236
2243
|
var COLOR_FAMILIES = [
|
|
@@ -2245,6 +2252,8 @@ var CATEGORICAL_INDICES = CHART_PALETTE_REFERENCES.map(
|
|
|
2245
2252
|
(_, index) => index + 1
|
|
2246
2253
|
);
|
|
2247
2254
|
var CHART_STAGGER_LC = 4.5;
|
|
2255
|
+
var DIFF_SURFACES = ["success-subtle", "error-subtle"];
|
|
2256
|
+
var CODE_SURFACES = ["container", "container-hover", ...DIFF_SURFACES];
|
|
2248
2257
|
var FOCUS_SURFACES = [
|
|
2249
2258
|
"background",
|
|
2250
2259
|
"container",
|
|
@@ -2304,11 +2313,23 @@ var APCA_PAIRS = [
|
|
|
2304
2313
|
ink(`${family}-subtle-foreground`, `${family}-subtle-active`, "ui")
|
|
2305
2314
|
]),
|
|
2306
2315
|
...CATEGORICAL_INDICES.flatMap(
|
|
2307
|
-
(index) => ["container", "background"].map((bg) => ({
|
|
2316
|
+
(index) => ["container", "container-hover", "background"].map((bg) => ({
|
|
2308
2317
|
...ink(`chart-categorical-${index}`, bg, "ui"),
|
|
2309
2318
|
offset: (index - 1) * CHART_STAGGER_LC
|
|
2310
2319
|
}))
|
|
2311
2320
|
),
|
|
2321
|
+
...CODE_SURFACES.flatMap(
|
|
2322
|
+
(bg) => Object.keys(SYNTAX_PALETTE_REFERENCES).map(
|
|
2323
|
+
(role) => ink(`syntax-${role}`, bg, "ui")
|
|
2324
|
+
)
|
|
2325
|
+
),
|
|
2326
|
+
// codeBlockTheme also colours code with the text tokens, which already read
|
|
2327
|
+
// on container and container-hover.
|
|
2328
|
+
...DIFF_SURFACES.flatMap((bg) => [
|
|
2329
|
+
text("foreground", bg, "ui"),
|
|
2330
|
+
text("muted-foreground", bg, "ui"),
|
|
2331
|
+
text("muted-foreground-subtle", bg, "incidental")
|
|
2332
|
+
]),
|
|
2312
2333
|
// Focus is the primary accent (components.md § Focus States), so it shares
|
|
2313
2334
|
// one solved color with primary-subtle-foreground.
|
|
2314
2335
|
...FOCUS_SURFACES.flatMap((surface) => [
|
|
@@ -2382,8 +2403,10 @@ function rampFromSeed(seedHex, options = {}) {
|
|
|
2382
2403
|
}
|
|
2383
2404
|
|
|
2384
2405
|
// src/lib/contrast.ts
|
|
2406
|
+
var CONTRAST_MIN = 0;
|
|
2407
|
+
var CONTRAST_MAX = 100;
|
|
2385
2408
|
function normalizeContrast(value, fallback = 50) {
|
|
2386
|
-
return typeof value === "number" && Number.isFinite(value) ? Math.round(Math.max(
|
|
2409
|
+
return typeof value === "number" && Number.isFinite(value) ? Math.round(Math.max(CONTRAST_MIN, Math.min(CONTRAST_MAX, value))) : fallback;
|
|
2387
2410
|
}
|
|
2388
2411
|
function contrastTarget(tier, contrast) {
|
|
2389
2412
|
return TIER_THRESHOLDS[tier] + 15 * contrast / 100;
|
|
@@ -2575,6 +2598,7 @@ var DEFAULT_NXDS_APPEARANCE = {
|
|
|
2575
2598
|
stroke: "normal",
|
|
2576
2599
|
prefs: {
|
|
2577
2600
|
uiFont: '-apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif',
|
|
2601
|
+
headingFont: null,
|
|
2578
2602
|
codeFont: 'ui-monospace, "SF Mono", Menlo, monospace',
|
|
2579
2603
|
uiFontSize: 14,
|
|
2580
2604
|
codeFontSize: 12,
|
|
@@ -2583,8 +2607,8 @@ var DEFAULT_NXDS_APPEARANCE = {
|
|
|
2583
2607
|
fontSmoothing: false
|
|
2584
2608
|
}
|
|
2585
2609
|
};
|
|
2586
|
-
var
|
|
2587
|
-
var
|
|
2610
|
+
var FONT_SIZE_PX_MIN = 8;
|
|
2611
|
+
var FONT_SIZE_PX_MAX = 32;
|
|
2588
2612
|
var APPEARANCE_MODES = /* @__PURE__ */ new Set([
|
|
2589
2613
|
"light",
|
|
2590
2614
|
"dark",
|
|
@@ -2610,7 +2634,7 @@ var FONT_FAMILY_UNSAFE = /[;{}<]/;
|
|
|
2610
2634
|
var fontFamilyOr = (value, fallback) => typeof value === "string" && value.length > 0 && !FONT_FAMILY_UNSAFE.test(value) ? value : fallback;
|
|
2611
2635
|
var boolOr = (value, fallback) => typeof value === "boolean" ? value : fallback;
|
|
2612
2636
|
var enumOr = (value, values, fallback) => typeof value === "string" && values.has(value) ? value : fallback;
|
|
2613
|
-
var clampFontSize = (value, fallback) => typeof value === "number" && Number.isFinite(value) && value > 0 ? Math.min(
|
|
2637
|
+
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;
|
|
2614
2638
|
function formatPx(value) {
|
|
2615
2639
|
return `${Number(value.toFixed(4))}px`;
|
|
2616
2640
|
}
|
|
@@ -2661,6 +2685,7 @@ function sanitizeNxdsAppearancePrefs(raw) {
|
|
|
2661
2685
|
const d = DEFAULT_NXDS_APPEARANCE.prefs;
|
|
2662
2686
|
return {
|
|
2663
2687
|
uiFont: fontFamilyOr(o.uiFont, d.uiFont),
|
|
2688
|
+
headingFont: fontFamilyOr(o.headingFont, d.headingFont),
|
|
2664
2689
|
codeFont: fontFamilyOr(o.codeFont, d.codeFont),
|
|
2665
2690
|
uiFontSize: clampFontSize(o.uiFontSize, d.uiFontSize),
|
|
2666
2691
|
codeFontSize: clampFontSize(o.codeFontSize, d.codeFontSize),
|
|
@@ -2707,6 +2732,7 @@ function appearancePrefsToCss(prefs) {
|
|
|
2707
2732
|
const blocks = [
|
|
2708
2733
|
inRuntimeLayer(`:root {
|
|
2709
2734
|
--nx-typography-family-font-sans: ${prefs.uiFont};
|
|
2735
|
+
--nx-typography-family-font-heading: ${prefs.headingFont ?? "var(--nx-typography-family-font-sans)"};
|
|
2710
2736
|
--nx-typography-family-font-mono: ${prefs.codeFont};
|
|
2711
2737
|
${typographyScaleVariables(uiPx)}
|
|
2712
2738
|
}`),
|
|
@@ -4389,6 +4415,14 @@ function deriveChart(mode) {
|
|
|
4389
4415
|
])
|
|
4390
4416
|
);
|
|
4391
4417
|
}
|
|
4418
|
+
function deriveSyntax(mode) {
|
|
4419
|
+
return Object.fromEntries(
|
|
4420
|
+
Object.entries(SYNTAX_PALETTE_REFERENCES).map(([role, reference]) => [
|
|
4421
|
+
`--nx-color-syntax-${role}`,
|
|
4422
|
+
getPaletteShade(reference.palette, reference[mode])
|
|
4423
|
+
])
|
|
4424
|
+
);
|
|
4425
|
+
}
|
|
4392
4426
|
function deriveAlpha(surfaceTone, mode, profile) {
|
|
4393
4427
|
const tone = SURFACE_TONE[surfaceTone];
|
|
4394
4428
|
const dark = mode === "dark";
|
|
@@ -4504,6 +4538,7 @@ function deriveThemeMode(input, mode) {
|
|
|
4504
4538
|
...deriveSecondary(mode),
|
|
4505
4539
|
...deriveStatus(mode),
|
|
4506
4540
|
...deriveChart(mode),
|
|
4541
|
+
...deriveSyntax(mode),
|
|
4507
4542
|
...deriveAlpha(surfaceTone, mode, profile),
|
|
4508
4543
|
"--nx-color-focus-error": getPaletteShade(
|
|
4509
4544
|
STATUS_PALETTE_FAMILIES.error,
|
|
@@ -4798,6 +4833,127 @@ function findBrandColorPreset(color) {
|
|
|
4798
4833
|
return BRAND_COLOR_PRESETS.find((preset) => preset.color === hex);
|
|
4799
4834
|
}
|
|
4800
4835
|
|
|
4836
|
+
// src/lib/font-options.ts
|
|
4837
|
+
var SANS_FALLBACK = '-apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif';
|
|
4838
|
+
var SERIF_FALLBACK = "Georgia, serif";
|
|
4839
|
+
var MONO_FALLBACK = 'ui-monospace, "SF Mono", Menlo, monospace';
|
|
4840
|
+
var FONT_OPTIONS = [
|
|
4841
|
+
{
|
|
4842
|
+
value: "geist",
|
|
4843
|
+
label: "Geist",
|
|
4844
|
+
category: "sans",
|
|
4845
|
+
family: `"Geist Variable", ${SANS_FALLBACK}`,
|
|
4846
|
+
package: "@fontsource-variable/geist"
|
|
4847
|
+
},
|
|
4848
|
+
{
|
|
4849
|
+
value: "inter",
|
|
4850
|
+
label: "Inter",
|
|
4851
|
+
category: "sans",
|
|
4852
|
+
family: `"Inter Variable", ${SANS_FALLBACK}`,
|
|
4853
|
+
package: "@fontsource-variable/inter"
|
|
4854
|
+
},
|
|
4855
|
+
{
|
|
4856
|
+
value: "figtree",
|
|
4857
|
+
label: "Figtree",
|
|
4858
|
+
category: "sans",
|
|
4859
|
+
family: `"Figtree Variable", ${SANS_FALLBACK}`,
|
|
4860
|
+
package: "@fontsource-variable/figtree"
|
|
4861
|
+
},
|
|
4862
|
+
{
|
|
4863
|
+
value: "dm-sans",
|
|
4864
|
+
label: "DM Sans",
|
|
4865
|
+
category: "sans",
|
|
4866
|
+
family: `"DM Sans Variable", ${SANS_FALLBACK}`,
|
|
4867
|
+
package: "@fontsource-variable/dm-sans"
|
|
4868
|
+
},
|
|
4869
|
+
{
|
|
4870
|
+
value: "manrope",
|
|
4871
|
+
label: "Manrope",
|
|
4872
|
+
category: "sans",
|
|
4873
|
+
family: `"Manrope Variable", ${SANS_FALLBACK}`,
|
|
4874
|
+
package: "@fontsource-variable/manrope"
|
|
4875
|
+
},
|
|
4876
|
+
{
|
|
4877
|
+
value: "ibm-plex-sans",
|
|
4878
|
+
label: "IBM Plex Sans",
|
|
4879
|
+
category: "sans",
|
|
4880
|
+
family: `"IBM Plex Sans Variable", ${SANS_FALLBACK}`,
|
|
4881
|
+
package: "@fontsource-variable/ibm-plex-sans"
|
|
4882
|
+
},
|
|
4883
|
+
{
|
|
4884
|
+
value: "lora",
|
|
4885
|
+
label: "Lora",
|
|
4886
|
+
category: "serif",
|
|
4887
|
+
family: `"Lora Variable", ${SERIF_FALLBACK}`,
|
|
4888
|
+
package: "@fontsource-variable/lora"
|
|
4889
|
+
},
|
|
4890
|
+
{
|
|
4891
|
+
value: "playfair-display",
|
|
4892
|
+
label: "Playfair Display",
|
|
4893
|
+
category: "serif",
|
|
4894
|
+
family: `"Playfair Display Variable", ${SERIF_FALLBACK}`,
|
|
4895
|
+
package: "@fontsource-variable/playfair-display"
|
|
4896
|
+
},
|
|
4897
|
+
{
|
|
4898
|
+
value: "geist-mono",
|
|
4899
|
+
label: "Geist Mono",
|
|
4900
|
+
category: "mono",
|
|
4901
|
+
family: `"Geist Mono Variable", ${MONO_FALLBACK}`,
|
|
4902
|
+
package: "@fontsource-variable/geist-mono"
|
|
4903
|
+
},
|
|
4904
|
+
{
|
|
4905
|
+
value: "jetbrains-mono",
|
|
4906
|
+
label: "JetBrains Mono",
|
|
4907
|
+
category: "mono",
|
|
4908
|
+
family: `"JetBrains Mono Variable", ${MONO_FALLBACK}`,
|
|
4909
|
+
package: "@fontsource-variable/jetbrains-mono"
|
|
4910
|
+
}
|
|
4911
|
+
];
|
|
4912
|
+
|
|
4913
|
+
// src/lib/icon-libraries.ts
|
|
4914
|
+
var ICON_LIBRARY_OPTIONS = [
|
|
4915
|
+
{ value: "phosphor", label: "Phosphor" },
|
|
4916
|
+
{ value: "lucide", label: "Lucide" },
|
|
4917
|
+
{ value: "tabler", label: "Tabler Icons" },
|
|
4918
|
+
{ value: "hugeicons", label: "HugeIcons" },
|
|
4919
|
+
{ value: "remix", label: "Remix Icon" }
|
|
4920
|
+
];
|
|
4921
|
+
var DEFAULT_ICON_LIBRARY = "phosphor";
|
|
4922
|
+
|
|
4923
|
+
// src/lib/appearance-shuffle.ts
|
|
4924
|
+
function pick(options, random) {
|
|
4925
|
+
const option = options[Math.floor(random() * options.length)];
|
|
4926
|
+
if (option === void 0) throw new Error("No option to pick from.");
|
|
4927
|
+
return option;
|
|
4928
|
+
}
|
|
4929
|
+
function shuffleNxdsAppearance(state, { fonts = FONT_OPTIONS, random = Math.random } = {}) {
|
|
4930
|
+
const textFonts = fonts.filter((font) => font.category !== "mono").map((font) => font.family);
|
|
4931
|
+
if (textFonts.length === 0) {
|
|
4932
|
+
throw new Error(
|
|
4933
|
+
"shuffleNxdsAppearance: `fonts` needs at least one sans or serif font."
|
|
4934
|
+
);
|
|
4935
|
+
}
|
|
4936
|
+
return {
|
|
4937
|
+
...state,
|
|
4938
|
+
brandColor: pick(BRAND_COLOR_PRESETS, random).color,
|
|
4939
|
+
surfaceTone: pick(BASE_TONE_OPTIONS, random).value,
|
|
4940
|
+
density: pick(DENSITY_OPTIONS, random).value,
|
|
4941
|
+
corners: pick(CORNER_OPTIONS, random).value,
|
|
4942
|
+
elevation: pick(ELEVATION_OPTIONS, random).value,
|
|
4943
|
+
stroke: pick(STROKE_OPTIONS, random).value,
|
|
4944
|
+
prefs: {
|
|
4945
|
+
...state.prefs,
|
|
4946
|
+
uiFont: pick(textFonts, random),
|
|
4947
|
+
headingFont: pick([null, ...textFonts], random)
|
|
4948
|
+
}
|
|
4949
|
+
};
|
|
4950
|
+
}
|
|
4951
|
+
function shuffleNxdsIconLibrary({
|
|
4952
|
+
random = Math.random
|
|
4953
|
+
} = {}) {
|
|
4954
|
+
return pick(ICON_LIBRARY_OPTIONS, random).value;
|
|
4955
|
+
}
|
|
4956
|
+
|
|
4801
4957
|
// src/lib/theme-contrast.ts
|
|
4802
4958
|
var MODES = ["light", "dark"];
|
|
4803
4959
|
var cssVar = (name) => `--nx-color-${name}`;
|
|
@@ -4823,6 +4979,211 @@ function measureThemeContrast(theme) {
|
|
|
4823
4979
|
);
|
|
4824
4980
|
}
|
|
4825
4981
|
|
|
4982
|
+
// src/lib/theme-fields.ts
|
|
4983
|
+
var DEFAULT_NXDS_THEME = {
|
|
4984
|
+
appearance: DEFAULT_NXDS_APPEARANCE,
|
|
4985
|
+
iconLibrary: DEFAULT_ICON_LIBRARY
|
|
4986
|
+
};
|
|
4987
|
+
function invalid(flag, value, accepted) {
|
|
4988
|
+
return new Error(`--${flag} "${value}" isn't ${accepted}.`);
|
|
4989
|
+
}
|
|
4990
|
+
function withAppearance(theme, patch) {
|
|
4991
|
+
return { ...theme, appearance: { ...theme.appearance, ...patch } };
|
|
4992
|
+
}
|
|
4993
|
+
function withPrefs(theme, patch) {
|
|
4994
|
+
return withAppearance(theme, {
|
|
4995
|
+
prefs: { ...theme.appearance.prefs, ...patch }
|
|
4996
|
+
});
|
|
4997
|
+
}
|
|
4998
|
+
function oneOf(flag, values, value) {
|
|
4999
|
+
const match = values.find((candidate) => candidate === value);
|
|
5000
|
+
if (match === void 0) {
|
|
5001
|
+
throw invalid(flag, value, `one of ${values.join(", ")}`);
|
|
5002
|
+
}
|
|
5003
|
+
return match;
|
|
5004
|
+
}
|
|
5005
|
+
function enumField(flag, key, description, values) {
|
|
5006
|
+
return {
|
|
5007
|
+
kind: "choice",
|
|
5008
|
+
flag,
|
|
5009
|
+
key,
|
|
5010
|
+
description,
|
|
5011
|
+
values,
|
|
5012
|
+
read: (theme) => theme.appearance[key],
|
|
5013
|
+
write: (theme, value) => withAppearance(theme, {
|
|
5014
|
+
[key]: oneOf(flag, values, value)
|
|
5015
|
+
})
|
|
5016
|
+
};
|
|
5017
|
+
}
|
|
5018
|
+
function integer(flag, value, min, max) {
|
|
5019
|
+
const parsed = Number(value);
|
|
5020
|
+
if (!/^\d+$/.test(value) || parsed < min || parsed > max) {
|
|
5021
|
+
throw invalid(flag, value, `a whole number from ${min} to ${max}`);
|
|
5022
|
+
}
|
|
5023
|
+
return parsed;
|
|
5024
|
+
}
|
|
5025
|
+
function contrastField(flag, key, description) {
|
|
5026
|
+
return {
|
|
5027
|
+
kind: "integer",
|
|
5028
|
+
flag,
|
|
5029
|
+
key,
|
|
5030
|
+
description,
|
|
5031
|
+
min: CONTRAST_MIN,
|
|
5032
|
+
max: CONTRAST_MAX,
|
|
5033
|
+
read: (theme) => String(theme.appearance[key]),
|
|
5034
|
+
write: (theme, value) => withAppearance(theme, {
|
|
5035
|
+
[key]: integer(flag, value, CONTRAST_MIN, CONTRAST_MAX)
|
|
5036
|
+
})
|
|
5037
|
+
};
|
|
5038
|
+
}
|
|
5039
|
+
function fontSizeField(flag, key, description) {
|
|
5040
|
+
return {
|
|
5041
|
+
kind: "integer",
|
|
5042
|
+
flag,
|
|
5043
|
+
key: `prefs.${key}`,
|
|
5044
|
+
description,
|
|
5045
|
+
min: FONT_SIZE_PX_MIN,
|
|
5046
|
+
max: FONT_SIZE_PX_MAX,
|
|
5047
|
+
read: (theme) => String(theme.appearance.prefs[key]),
|
|
5048
|
+
write: (theme, value) => withPrefs(theme, {
|
|
5049
|
+
[key]: integer(flag, value, FONT_SIZE_PX_MIN, FONT_SIZE_PX_MAX)
|
|
5050
|
+
})
|
|
5051
|
+
};
|
|
5052
|
+
}
|
|
5053
|
+
function fontField(flag, key, description, categories, fallback) {
|
|
5054
|
+
const fonts = FONT_OPTIONS.filter(
|
|
5055
|
+
(font) => categories.includes(font.category)
|
|
5056
|
+
);
|
|
5057
|
+
return {
|
|
5058
|
+
kind: "font",
|
|
5059
|
+
flag,
|
|
5060
|
+
key: `prefs.${key}`,
|
|
5061
|
+
description,
|
|
5062
|
+
values: [fallback.value, ...fonts.map((font) => font.value)],
|
|
5063
|
+
categories,
|
|
5064
|
+
fallback,
|
|
5065
|
+
read: (theme) => {
|
|
5066
|
+
const family = theme.appearance.prefs[key];
|
|
5067
|
+
if (family === fallback.family) return fallback.value;
|
|
5068
|
+
return fonts.find((font) => font.family === family)?.value;
|
|
5069
|
+
},
|
|
5070
|
+
write: (theme, value) => {
|
|
5071
|
+
const family = value === fallback.value ? fallback.family : fonts.find((font) => font.value === value)?.family;
|
|
5072
|
+
if (family === void 0) {
|
|
5073
|
+
throw invalid(
|
|
5074
|
+
flag,
|
|
5075
|
+
value,
|
|
5076
|
+
`one of ${[fallback.value, ...fonts.map((font) => font.value)].join(", ")}`
|
|
5077
|
+
);
|
|
5078
|
+
}
|
|
5079
|
+
return withPrefs(theme, { [key]: family });
|
|
5080
|
+
}
|
|
5081
|
+
};
|
|
5082
|
+
}
|
|
5083
|
+
var DEFAULT_PREFS = DEFAULT_NXDS_APPEARANCE.prefs;
|
|
5084
|
+
var TEXT_FONTS = ["sans", "serif"];
|
|
5085
|
+
var NXDS_THEME_FIELDS = [
|
|
5086
|
+
{
|
|
5087
|
+
kind: "color",
|
|
5088
|
+
flag: "brand-color",
|
|
5089
|
+
key: "brandColor",
|
|
5090
|
+
description: 'brand color, as any CSS color, such as "#4f46e5"',
|
|
5091
|
+
read: (theme) => theme.appearance.brandColor,
|
|
5092
|
+
write: (theme, value) => {
|
|
5093
|
+
if (!isColor(value)) throw invalid("brand-color", value, "a CSS color");
|
|
5094
|
+
return withAppearance(theme, { brandColor: value });
|
|
5095
|
+
}
|
|
5096
|
+
},
|
|
5097
|
+
enumField(
|
|
5098
|
+
"surface-tone",
|
|
5099
|
+
"surfaceTone",
|
|
5100
|
+
"neutral tone of backgrounds and borders",
|
|
5101
|
+
BASE_TONE_OPTIONS.map((option) => option.value)
|
|
5102
|
+
),
|
|
5103
|
+
enumField(
|
|
5104
|
+
"density",
|
|
5105
|
+
"density",
|
|
5106
|
+
"spacing and control size",
|
|
5107
|
+
DENSITY_OPTIONS.map((option) => option.value)
|
|
5108
|
+
),
|
|
5109
|
+
enumField(
|
|
5110
|
+
"corners",
|
|
5111
|
+
"corners",
|
|
5112
|
+
"corner radius",
|
|
5113
|
+
CORNER_OPTIONS.map((option) => option.value)
|
|
5114
|
+
),
|
|
5115
|
+
enumField(
|
|
5116
|
+
"elevation",
|
|
5117
|
+
"elevation",
|
|
5118
|
+
"shadow depth",
|
|
5119
|
+
ELEVATION_OPTIONS.map((option) => option.value)
|
|
5120
|
+
),
|
|
5121
|
+
enumField(
|
|
5122
|
+
"stroke",
|
|
5123
|
+
"stroke",
|
|
5124
|
+
"border width",
|
|
5125
|
+
STROKE_OPTIONS.map((option) => option.value)
|
|
5126
|
+
),
|
|
5127
|
+
enumField("mode", "mode", "color scheme", ["light", "dark", "system"]),
|
|
5128
|
+
contrastField(
|
|
5129
|
+
"light-contrast",
|
|
5130
|
+
"lightContrast",
|
|
5131
|
+
"light mode contrast, 0 to 100"
|
|
5132
|
+
),
|
|
5133
|
+
contrastField(
|
|
5134
|
+
"dark-contrast",
|
|
5135
|
+
"darkContrast",
|
|
5136
|
+
"dark mode contrast, 0 to 100"
|
|
5137
|
+
),
|
|
5138
|
+
fontField("font", "uiFont", "font for UI text", TEXT_FONTS, {
|
|
5139
|
+
value: "system",
|
|
5140
|
+
family: DEFAULT_PREFS.uiFont
|
|
5141
|
+
}),
|
|
5142
|
+
fontField(
|
|
5143
|
+
"heading-font",
|
|
5144
|
+
"headingFont",
|
|
5145
|
+
'font for headings, or "ui" for the UI font',
|
|
5146
|
+
TEXT_FONTS,
|
|
5147
|
+
{ value: "ui", family: null }
|
|
5148
|
+
),
|
|
5149
|
+
fontField("code-font", "codeFont", "font for code", ["mono"], {
|
|
5150
|
+
value: "system",
|
|
5151
|
+
family: DEFAULT_PREFS.codeFont
|
|
5152
|
+
}),
|
|
5153
|
+
fontSizeField("font-size", "uiFontSize", "UI text size in px"),
|
|
5154
|
+
fontSizeField("code-font-size", "codeFontSize", "code text size in px"),
|
|
5155
|
+
{
|
|
5156
|
+
kind: "choice",
|
|
5157
|
+
flag: "icons",
|
|
5158
|
+
description: "icon library nxds components draw",
|
|
5159
|
+
values: ICON_LIBRARY_OPTIONS.map((option) => option.value),
|
|
5160
|
+
read: (theme) => theme.iconLibrary,
|
|
5161
|
+
write: (theme, value) => ({
|
|
5162
|
+
...theme,
|
|
5163
|
+
iconLibrary: oneOf(
|
|
5164
|
+
"icons",
|
|
5165
|
+
ICON_LIBRARY_OPTIONS.map((option) => option.value),
|
|
5166
|
+
value
|
|
5167
|
+
)
|
|
5168
|
+
})
|
|
5169
|
+
}
|
|
5170
|
+
];
|
|
5171
|
+
function nxdsThemeFlags(theme) {
|
|
5172
|
+
return NXDS_THEME_FIELDS.flatMap((field) => {
|
|
5173
|
+
const value = field.read(theme);
|
|
5174
|
+
if (value === void 0 || value === field.read(DEFAULT_NXDS_THEME)) {
|
|
5175
|
+
return [];
|
|
5176
|
+
}
|
|
5177
|
+
return [{ flag: field.flag, value }];
|
|
5178
|
+
});
|
|
5179
|
+
}
|
|
5180
|
+
function applyNxdsThemeFlags(theme, values) {
|
|
5181
|
+
return NXDS_THEME_FIELDS.reduce((current, field) => {
|
|
5182
|
+
const value = values[field.flag];
|
|
5183
|
+
return value === void 0 ? current : field.write(current, value);
|
|
5184
|
+
}, theme);
|
|
5185
|
+
}
|
|
5186
|
+
|
|
4826
5187
|
// src/lib/token-registry.ts
|
|
4827
5188
|
var SURFACE_TOKEN_NAMES = [
|
|
4828
5189
|
"background",
|
|
@@ -4936,6 +5297,13 @@ var CHART_TOKEN_NAMES = [
|
|
|
4936
5297
|
"chart-categorical-4",
|
|
4937
5298
|
"chart-categorical-5"
|
|
4938
5299
|
];
|
|
5300
|
+
var SYNTAX_TOKEN_NAMES = [
|
|
5301
|
+
"syntax-keyword",
|
|
5302
|
+
"syntax-string",
|
|
5303
|
+
"syntax-function",
|
|
5304
|
+
"syntax-type",
|
|
5305
|
+
"syntax-constant"
|
|
5306
|
+
];
|
|
4939
5307
|
var FOCUS_TOKEN_NAMES = ["focus-default", "focus-error"];
|
|
4940
5308
|
var ALPHA_TOKEN_NAMES = [
|
|
4941
5309
|
"background-hover-alpha",
|
|
@@ -4954,6 +5322,7 @@ var SEMANTIC_TOKEN_REGISTRY = [
|
|
|
4954
5322
|
...metas("brand", BRAND_TOKEN_NAMES),
|
|
4955
5323
|
...metas("status", STATUS_TOKEN_NAMES),
|
|
4956
5324
|
...metas("chart", CHART_TOKEN_NAMES),
|
|
5325
|
+
...metas("syntax", SYNTAX_TOKEN_NAMES),
|
|
4957
5326
|
...metas("focus", FOCUS_TOKEN_NAMES),
|
|
4958
5327
|
...metas("alpha", ALPHA_TOKEN_NAMES)
|
|
4959
5328
|
];
|
|
@@ -4964,12 +5333,19 @@ export {
|
|
|
4964
5333
|
CORNER_OPTIONS,
|
|
4965
5334
|
DEFAULT_BRAND_COLOR,
|
|
4966
5335
|
DEFAULT_COOKIE_KEY,
|
|
5336
|
+
DEFAULT_ICON_LIBRARY,
|
|
4967
5337
|
DEFAULT_NXDS_APPEARANCE,
|
|
5338
|
+
DEFAULT_NXDS_THEME,
|
|
4968
5339
|
DEFAULT_STORAGE_KEY,
|
|
4969
5340
|
DENSITY_OPTIONS,
|
|
4970
5341
|
ELEVATION_OPTIONS,
|
|
5342
|
+
FONT_OPTIONS,
|
|
5343
|
+
FONT_SIZE_PX_MAX,
|
|
5344
|
+
FONT_SIZE_PX_MIN,
|
|
5345
|
+
ICON_LIBRARY_OPTIONS,
|
|
4971
5346
|
NXDS_APPEARANCE_COOKIE_MAX_AGE_SECONDS,
|
|
4972
5347
|
NXDS_APPEARANCE_DATA_ATTRS,
|
|
5348
|
+
NXDS_THEME_FIELDS,
|
|
4973
5349
|
PALETTE_KEYS,
|
|
4974
5350
|
RUNTIME_LAYER_ORDER,
|
|
4975
5351
|
SEMANTIC_TOKEN_REGISTRY,
|
|
@@ -4980,6 +5356,7 @@ export {
|
|
|
4980
5356
|
apcaLc,
|
|
4981
5357
|
appearancePrefsToCss,
|
|
4982
5358
|
applyNxdsAppearance,
|
|
5359
|
+
applyNxdsThemeFlags,
|
|
4983
5360
|
createDefaultNxdsAppearanceSnapshot,
|
|
4984
5361
|
createNxdsAppearanceBootstrapScript,
|
|
4985
5362
|
createNxdsAppearanceSnapshot,
|
|
@@ -4992,6 +5369,7 @@ export {
|
|
|
4992
5369
|
isColor,
|
|
4993
5370
|
measureThemeContrast,
|
|
4994
5371
|
normalizeAppearanceModeIds,
|
|
5372
|
+
nxdsThemeFlags,
|
|
4995
5373
|
parseNxdsAppearanceStateCookie,
|
|
4996
5374
|
persistNxdsAppearance,
|
|
4997
5375
|
prefersDarkColorScheme,
|
|
@@ -5003,6 +5381,8 @@ export {
|
|
|
5003
5381
|
sanitizeNxdsAppearancePrefs,
|
|
5004
5382
|
sanitizeNxdsAppearanceSnapshot,
|
|
5005
5383
|
serializeNxdsAppearanceStateCookie,
|
|
5384
|
+
shuffleNxdsAppearance,
|
|
5385
|
+
shuffleNxdsIconLibrary,
|
|
5006
5386
|
themeToCss,
|
|
5007
5387
|
watchColorScheme
|
|
5008
5388
|
};
|