@nxds/core 0.10.0 → 0.11.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.
@@ -172,7 +172,7 @@ interface ThemeContrastCheck {
172
172
  /** Measure every registered APCA pair of a derived theme in both modes. */
173
173
  declare function measureThemeContrast(theme: DerivedTheme): ThemeContrastCheck[];
174
174
 
175
- type TokenCategory = 'surface' | 'text' | 'border' | 'brand' | 'status' | 'chart' | 'focus' | 'alpha';
175
+ type TokenCategory = 'surface' | 'text' | 'border' | 'brand' | 'status' | 'chart' | 'syntax' | 'focus' | 'alpha';
176
176
  interface SemanticTokenMeta {
177
177
  /** Bare token name, without the --nx-color- prefix. */
178
178
  name: SemanticColorName;
@@ -184,10 +184,11 @@ declare const BORDER_TOKEN_NAMES: readonly ["border-default", "border-disabled",
184
184
  declare const BRAND_TOKEN_NAMES: readonly ["primary-background", "primary-background-hover", "primary-background-active", "primary-foreground", "primary-disabled", "primary-subtle", "primary-subtle-foreground", "primary-subtle-hover", "primary-subtle-active", "primary-border", "primary-border-active", "secondary-background", "secondary-background-hover", "secondary-background-active", "secondary-foreground", "secondary-disabled", "secondary-subtle", "secondary-subtle-foreground", "secondary-subtle-hover", "secondary-subtle-active"];
185
185
  declare const STATUS_TOKEN_NAMES: readonly ["success-background", "success-background-hover", "success-background-active", "success-foreground", "success-disabled", "success-subtle", "success-subtle-foreground", "success-subtle-hover", "success-subtle-active", "success-border", "border-success-active", "warning-background", "warning-background-hover", "warning-background-active", "warning-foreground", "warning-disabled", "warning-subtle", "warning-subtle-foreground", "warning-subtle-hover", "warning-subtle-active", "warning-border", "border-warning-active", "error-background", "error-background-hover", "error-background-active", "error-foreground", "error-disabled", "error-subtle", "error-subtle-foreground", "error-subtle-hover", "error-subtle-active", "error-border", "border-error-active", "information-background", "information-background-hover", "information-background-active", "information-foreground", "information-disabled", "information-subtle", "information-subtle-foreground", "information-subtle-hover", "information-subtle-active", "information-border", "border-information-active"];
186
186
  declare const CHART_TOKEN_NAMES: readonly ["chart-categorical-1", "chart-categorical-2", "chart-categorical-3", "chart-categorical-4", "chart-categorical-5"];
187
+ declare const SYNTAX_TOKEN_NAMES: readonly ["syntax-keyword", "syntax-string", "syntax-function", "syntax-type", "syntax-constant"];
187
188
  declare const FOCUS_TOKEN_NAMES: readonly ["focus-default", "focus-error"];
188
189
  declare const ALPHA_TOKEN_NAMES: readonly ["background-hover-alpha", "border-default-alpha", "overlay", "popover-alpha", "popover-backdrop"];
189
190
  /** Bare name of every semantic colour token, without the --nx-color- prefix. */
190
- type SemanticColorName = (typeof SURFACE_TOKEN_NAMES)[number] | (typeof TEXT_TOKEN_NAMES)[number] | (typeof BORDER_TOKEN_NAMES)[number] | (typeof BRAND_TOKEN_NAMES)[number] | (typeof STATUS_TOKEN_NAMES)[number] | (typeof CHART_TOKEN_NAMES)[number] | (typeof FOCUS_TOKEN_NAMES)[number] | (typeof ALPHA_TOKEN_NAMES)[number];
191
+ type SemanticColorName = (typeof SURFACE_TOKEN_NAMES)[number] | (typeof TEXT_TOKEN_NAMES)[number] | (typeof BORDER_TOKEN_NAMES)[number] | (typeof BRAND_TOKEN_NAMES)[number] | (typeof STATUS_TOKEN_NAMES)[number] | (typeof CHART_TOKEN_NAMES)[number] | (typeof SYNTAX_TOKEN_NAMES)[number] | (typeof FOCUS_TOKEN_NAMES)[number] | (typeof ALPHA_TOKEN_NAMES)[number];
191
192
  declare const SEMANTIC_TOKEN_REGISTRY: readonly SemanticTokenMeta[];
192
193
 
193
194
  export { type AdjustContrastOptions, type AdjustContrastPalette, type AdjustContrastTier, BRAND_COLOR_PRESETS, type BrandColorPreset, DEFAULT_COOKIE_KEY, DEFAULT_STORAGE_KEY, DerivedTheme, Mode, NXDS_APPEARANCE_COOKIE_MAX_AGE_SECONDS, NXDS_APPEARANCE_DATA_ATTRS, type NxdsAppearanceBootstrapScriptOptions, type NxdsAppearanceCookieOptions, type NxdsAppearanceCookieSameSite, type NxdsAppearanceDataAttr, type NxdsAppearancePersistOptions, type NxdsAppearanceSnapshot, NxdsAppearanceState, type NxdsAppearanceStateCookie, type NxdsFirstPaintResolution, type NxdsResolvedAppearanceMode, RUNTIME_LAYER_ORDER, SEMANTIC_TOKEN_REGISTRY, SNAPSHOT_VERSION, type SemanticColorName, type SemanticTokenMeta, type ThemeContrastCheck, Tier, type TokenCategory, adjustContrast, apcaLc, applyNxdsAppearance, createDefaultNxdsAppearanceSnapshot, createNxdsAppearanceBootstrapScript, createNxdsAppearanceSnapshot, createNxdsAppearanceSnapshotFromCookie, createNxdsAppearanceSnapshotFromState, createNxdsAppearanceStateCookie, findBrandColorPreset, isColor, measureThemeContrast, parseNxdsAppearanceStateCookie, persistNxdsAppearance, prefersDarkColorScheme, readStoredNxdsAppearance, removeNxdsAppearance, resolveFirstPaint, resolveNxdsAppearanceMode, sanitizeNxdsAppearanceSnapshot, serializeNxdsAppearanceStateCookie, watchColorScheme };
@@ -172,7 +172,7 @@ interface ThemeContrastCheck {
172
172
  /** Measure every registered APCA pair of a derived theme in both modes. */
173
173
  declare function measureThemeContrast(theme: DerivedTheme): ThemeContrastCheck[];
174
174
 
175
- type TokenCategory = 'surface' | 'text' | 'border' | 'brand' | 'status' | 'chart' | 'focus' | 'alpha';
175
+ type TokenCategory = 'surface' | 'text' | 'border' | 'brand' | 'status' | 'chart' | 'syntax' | 'focus' | 'alpha';
176
176
  interface SemanticTokenMeta {
177
177
  /** Bare token name, without the --nx-color- prefix. */
178
178
  name: SemanticColorName;
@@ -184,10 +184,11 @@ declare const BORDER_TOKEN_NAMES: readonly ["border-default", "border-disabled",
184
184
  declare const BRAND_TOKEN_NAMES: readonly ["primary-background", "primary-background-hover", "primary-background-active", "primary-foreground", "primary-disabled", "primary-subtle", "primary-subtle-foreground", "primary-subtle-hover", "primary-subtle-active", "primary-border", "primary-border-active", "secondary-background", "secondary-background-hover", "secondary-background-active", "secondary-foreground", "secondary-disabled", "secondary-subtle", "secondary-subtle-foreground", "secondary-subtle-hover", "secondary-subtle-active"];
185
185
  declare const STATUS_TOKEN_NAMES: readonly ["success-background", "success-background-hover", "success-background-active", "success-foreground", "success-disabled", "success-subtle", "success-subtle-foreground", "success-subtle-hover", "success-subtle-active", "success-border", "border-success-active", "warning-background", "warning-background-hover", "warning-background-active", "warning-foreground", "warning-disabled", "warning-subtle", "warning-subtle-foreground", "warning-subtle-hover", "warning-subtle-active", "warning-border", "border-warning-active", "error-background", "error-background-hover", "error-background-active", "error-foreground", "error-disabled", "error-subtle", "error-subtle-foreground", "error-subtle-hover", "error-subtle-active", "error-border", "border-error-active", "information-background", "information-background-hover", "information-background-active", "information-foreground", "information-disabled", "information-subtle", "information-subtle-foreground", "information-subtle-hover", "information-subtle-active", "information-border", "border-information-active"];
186
186
  declare const CHART_TOKEN_NAMES: readonly ["chart-categorical-1", "chart-categorical-2", "chart-categorical-3", "chart-categorical-4", "chart-categorical-5"];
187
+ declare const SYNTAX_TOKEN_NAMES: readonly ["syntax-keyword", "syntax-string", "syntax-function", "syntax-type", "syntax-constant"];
187
188
  declare const FOCUS_TOKEN_NAMES: readonly ["focus-default", "focus-error"];
188
189
  declare const ALPHA_TOKEN_NAMES: readonly ["background-hover-alpha", "border-default-alpha", "overlay", "popover-alpha", "popover-backdrop"];
189
190
  /** Bare name of every semantic colour token, without the --nx-color- prefix. */
190
- type SemanticColorName = (typeof SURFACE_TOKEN_NAMES)[number] | (typeof TEXT_TOKEN_NAMES)[number] | (typeof BORDER_TOKEN_NAMES)[number] | (typeof BRAND_TOKEN_NAMES)[number] | (typeof STATUS_TOKEN_NAMES)[number] | (typeof CHART_TOKEN_NAMES)[number] | (typeof FOCUS_TOKEN_NAMES)[number] | (typeof ALPHA_TOKEN_NAMES)[number];
191
+ type SemanticColorName = (typeof SURFACE_TOKEN_NAMES)[number] | (typeof TEXT_TOKEN_NAMES)[number] | (typeof BORDER_TOKEN_NAMES)[number] | (typeof BRAND_TOKEN_NAMES)[number] | (typeof STATUS_TOKEN_NAMES)[number] | (typeof CHART_TOKEN_NAMES)[number] | (typeof SYNTAX_TOKEN_NAMES)[number] | (typeof FOCUS_TOKEN_NAMES)[number] | (typeof ALPHA_TOKEN_NAMES)[number];
191
192
  declare const SEMANTIC_TOKEN_REGISTRY: readonly SemanticTokenMeta[];
192
193
 
193
194
  export { type AdjustContrastOptions, type AdjustContrastPalette, type AdjustContrastTier, BRAND_COLOR_PRESETS, type BrandColorPreset, DEFAULT_COOKIE_KEY, DEFAULT_STORAGE_KEY, DerivedTheme, Mode, NXDS_APPEARANCE_COOKIE_MAX_AGE_SECONDS, NXDS_APPEARANCE_DATA_ATTRS, type NxdsAppearanceBootstrapScriptOptions, type NxdsAppearanceCookieOptions, type NxdsAppearanceCookieSameSite, type NxdsAppearanceDataAttr, type NxdsAppearancePersistOptions, type NxdsAppearanceSnapshot, NxdsAppearanceState, type NxdsAppearanceStateCookie, type NxdsFirstPaintResolution, type NxdsResolvedAppearanceMode, RUNTIME_LAYER_ORDER, SEMANTIC_TOKEN_REGISTRY, SNAPSHOT_VERSION, type SemanticColorName, type SemanticTokenMeta, type ThemeContrastCheck, Tier, type TokenCategory, adjustContrast, apcaLc, applyNxdsAppearance, createDefaultNxdsAppearanceSnapshot, createNxdsAppearanceBootstrapScript, createNxdsAppearanceSnapshot, createNxdsAppearanceSnapshotFromCookie, createNxdsAppearanceSnapshotFromState, createNxdsAppearanceStateCookie, findBrandColorPreset, isColor, measureThemeContrast, parseNxdsAppearanceStateCookie, persistNxdsAppearance, prefersDarkColorScheme, readStoredNxdsAppearance, removeNxdsAppearance, resolveFirstPaint, resolveNxdsAppearanceMode, sanitizeNxdsAppearanceSnapshot, serializeNxdsAppearanceStateCookie, watchColorScheme };
@@ -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) => [
@@ -4389,6 +4410,14 @@ function deriveChart(mode) {
4389
4410
  ])
4390
4411
  );
4391
4412
  }
4413
+ function deriveSyntax(mode) {
4414
+ return Object.fromEntries(
4415
+ Object.entries(SYNTAX_PALETTE_REFERENCES).map(([role, reference]) => [
4416
+ `--nx-color-syntax-${role}`,
4417
+ getPaletteShade(reference.palette, reference[mode])
4418
+ ])
4419
+ );
4420
+ }
4392
4421
  function deriveAlpha(surfaceTone, mode, profile) {
4393
4422
  const tone = SURFACE_TONE[surfaceTone];
4394
4423
  const dark = mode === "dark";
@@ -4504,6 +4533,7 @@ function deriveThemeMode(input, mode) {
4504
4533
  ...deriveSecondary(mode),
4505
4534
  ...deriveStatus(mode),
4506
4535
  ...deriveChart(mode),
4536
+ ...deriveSyntax(mode),
4507
4537
  ...deriveAlpha(surfaceTone, mode, profile),
4508
4538
  "--nx-color-focus-error": getPaletteShade(
4509
4539
  STATUS_PALETTE_FAMILIES.error,
@@ -4936,6 +4966,13 @@ var CHART_TOKEN_NAMES = [
4936
4966
  "chart-categorical-4",
4937
4967
  "chart-categorical-5"
4938
4968
  ];
4969
+ var SYNTAX_TOKEN_NAMES = [
4970
+ "syntax-keyword",
4971
+ "syntax-string",
4972
+ "syntax-function",
4973
+ "syntax-type",
4974
+ "syntax-constant"
4975
+ ];
4939
4976
  var FOCUS_TOKEN_NAMES = ["focus-default", "focus-error"];
4940
4977
  var ALPHA_TOKEN_NAMES = [
4941
4978
  "background-hover-alpha",
@@ -4954,6 +4991,7 @@ var SEMANTIC_TOKEN_REGISTRY = [
4954
4991
  ...metas("brand", BRAND_TOKEN_NAMES),
4955
4992
  ...metas("status", STATUS_TOKEN_NAMES),
4956
4993
  ...metas("chart", CHART_TOKEN_NAMES),
4994
+ ...metas("syntax", SYNTAX_TOKEN_NAMES),
4957
4995
  ...metas("focus", FOCUS_TOKEN_NAMES),
4958
4996
  ...metas("alpha", ALPHA_TOKEN_NAMES)
4959
4997
  ];