@nxds/core 0.12.0 → 0.14.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.
@@ -1,5 +1,42 @@
1
1
  import { N as NxdsSurfaceTone } from './palette-BKTIQ0WC.cjs';
2
2
 
3
+ /**
4
+ * Each UI scale, as factors of the Default scale. `spacing` multiplies every
5
+ * density and radius step and the page widths, `text` every type size, and
6
+ * `icon` every icon glyph. `text: 12 / 14` turns 14px label text into 12px.
7
+ */
8
+ declare const UI_SCALES: {
9
+ readonly small: {
10
+ readonly spacing: 0.9;
11
+ readonly text: number;
12
+ readonly icon: number;
13
+ };
14
+ readonly default: {
15
+ readonly spacing: 1;
16
+ readonly text: 1;
17
+ readonly icon: 1;
18
+ };
19
+ readonly large: {
20
+ readonly spacing: 1.1;
21
+ readonly text: number;
22
+ readonly icon: number;
23
+ };
24
+ readonly larger: {
25
+ readonly spacing: 1.25;
26
+ readonly text: number;
27
+ readonly icon: number;
28
+ };
29
+ };
30
+ type UiScale = keyof typeof UI_SCALES;
31
+ /**
32
+ * The label text sizes a person can pick, in px at the Default scale. 14 is
33
+ * the Default label size, and writes no block of its own.
34
+ */
35
+ declare const TEXT_SIZES: readonly [12, 13, 14, 15, 16];
36
+ type TextSize = (typeof TEXT_SIZES)[number];
37
+ /** The label text size, in px, that `textSize` shows at `scale`. */
38
+ declare function textSizePx(textSize: TextSize, scale: UiScale): number;
39
+
3
40
  interface ThemeSeeds {
4
41
  /** Drives the primary family ramp. */
5
42
  accent: string;
@@ -43,6 +80,9 @@ declare function themeToCss(derived: DerivedTheme): string;
43
80
 
44
81
  type ModeSeeds = Pick<ThemeSeeds, 'background' | 'foreground'>;
45
82
  type NxdsAppearanceMode = 'light' | 'dark' | 'system';
83
+ type NxdsUiScale = UiScale;
84
+ /** The label text size, in px at the Default UI scale. */
85
+ type NxdsTextSize = TextSize;
46
86
  type NxdsDensity = 'tight' | 'compact' | 'default' | 'comfortable' | 'relaxed' | 'spacious';
47
87
  type NxdsCorners = 'square' | 'subtle' | 'smooth' | 'round' | 'extra-round';
48
88
  type NxdsElevation = 'flat' | 'quiet' | 'soft' | 'standard' | 'strong';
@@ -52,7 +92,6 @@ interface NxdsAppearancePrefs {
52
92
  /** The heading `font-family` stack. `null` follows `uiFont`. */
53
93
  headingFont: string | null;
54
94
  codeFont: string;
55
- uiFontSize: number;
56
95
  codeFontSize: number;
57
96
  reduceMotion: boolean;
58
97
  pointerCursors: boolean;
@@ -64,6 +103,8 @@ interface NxdsAppearanceState {
64
103
  surfaceTone: NxdsSurfaceTone;
65
104
  lightContrast: number;
66
105
  darkContrast: number;
106
+ uiScale: NxdsUiScale;
107
+ textSize: NxdsTextSize;
67
108
  density: NxdsDensity;
68
109
  corners: NxdsCorners;
69
110
  elevation: NxdsElevation;
@@ -98,6 +139,24 @@ declare const BASE_TONE_SEEDS: Record<NxdsSurfaceTone, {
98
139
  light: ModeSeeds;
99
140
  dark: ModeSeeds;
100
141
  }>;
142
+ declare const UI_SCALE_OPTIONS: readonly [{
143
+ readonly value: "small";
144
+ readonly label: "Small";
145
+ }, {
146
+ readonly value: "default";
147
+ readonly label: "Default";
148
+ }, {
149
+ readonly value: "large";
150
+ readonly label: "Large";
151
+ }, {
152
+ readonly value: "larger";
153
+ readonly label: "Larger";
154
+ }];
155
+ /** The text sizes, each labelled with its label size at the Default UI scale. */
156
+ declare const TEXT_SIZE_OPTIONS: readonly {
157
+ readonly value: NxdsTextSize;
158
+ readonly label: string;
159
+ }[];
101
160
  declare const DENSITY_OPTIONS: readonly [{
102
161
  readonly value: "tight";
103
162
  readonly label: "Tight";
@@ -166,7 +225,9 @@ declare const FONT_SIZE_PX_MAX = 32;
166
225
  declare function normalizeAppearanceModeIds(raw: unknown): unknown;
167
226
  declare function sanitizeNxdsAppearancePrefs(raw: unknown): NxdsAppearancePrefs;
168
227
  declare function sanitizeNxdsAppearance(rawInput: unknown): NxdsAppearanceState;
169
- declare function createNxdsThemeContract(state: NxdsAppearanceState): ThemeDerivationInput;
228
+ /** The appearance fields runtime colours derive from. */
229
+ type NxdsColorAppearance = Pick<NxdsAppearanceState, 'brandColor' | 'surfaceTone' | 'lightContrast' | 'darkContrast'>;
230
+ declare function createNxdsThemeContract(state: NxdsColorAppearance): ThemeDerivationInput;
170
231
  declare function appearancePrefsToCss(prefs: NxdsAppearancePrefs): string;
171
232
 
172
233
  /**
@@ -259,4 +320,4 @@ declare const DARK_SURFACE_LADDER: {
259
320
  };
260
321
  };
261
322
 
262
- export { BASE_TONE_OPTIONS as B, CORNER_OPTIONS as C, DARK_SURFACE_LADDER as D, ELEVATION_OPTIONS as E, FONT_SIZE_PX_MAX as F, LIGHT_SURFACE_LADDER as L, type NxdsPresetField as N, SURFACE_TOKENS as S, type ThemeDerivationInput as T, type NxdsAppearancePrefs as a, type NxdsAppearanceState as b, type ShadeAnchor as c, type DerivedTheme as d, BASE_TONE_SEEDS as e, DEFAULT_BRAND_COLOR as f, DEFAULT_NXDS_APPEARANCE as g, DENSITY_OPTIONS as h, FONT_SIZE_PX_MIN as i, type NxdsAppearanceMode as j, type NxdsCorners as k, type NxdsDensity as l, type NxdsElevation as m, type NxdsStroke as n, type NxdsThemeContract as o, STROKE_OPTIONS as p, type SurfaceToken as q, type ThemeSeeds as r, type TokenMap as s, appearancePrefsToCss as t, createNxdsThemeContract as u, deriveTheme as v, normalizeAppearanceModeIds as w, sanitizeNxdsAppearance as x, sanitizeNxdsAppearancePrefs as y, themeToCss as z };
323
+ export { normalizeAppearanceModeIds as A, BASE_TONE_OPTIONS as B, CORNER_OPTIONS as C, DARK_SURFACE_LADDER as D, ELEVATION_OPTIONS as E, FONT_SIZE_PX_MAX as F, sanitizeNxdsAppearance as G, sanitizeNxdsAppearancePrefs as H, textSizePx as I, themeToCss as J, LIGHT_SURFACE_LADDER as L, type NxdsColorAppearance as N, SURFACE_TOKENS as S, TEXT_SIZE_OPTIONS as T, UI_SCALE_OPTIONS as U, type NxdsUiScale as a, type NxdsTextSize as b, type NxdsAppearancePrefs as c, type NxdsPresetField as d, type ShadeAnchor as e, type NxdsAppearanceState as f, type DerivedTheme as g, BASE_TONE_SEEDS as h, DEFAULT_BRAND_COLOR as i, DEFAULT_NXDS_APPEARANCE as j, DENSITY_OPTIONS as k, FONT_SIZE_PX_MIN as l, type NxdsAppearanceMode as m, type NxdsCorners as n, type NxdsDensity as o, type NxdsElevation as p, type NxdsStroke as q, type NxdsThemeContract as r, STROKE_OPTIONS as s, type SurfaceToken as t, type ThemeDerivationInput as u, type ThemeSeeds as v, type TokenMap as w, appearancePrefsToCss as x, createNxdsThemeContract as y, deriveTheme as z };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxds/core",
3
- "version": "0.12.0",
3
+ "version": "0.14.0",
4
4
  "type": "module",
5
5
  "description": "nxds theme engine: a framework-agnostic appearance model, runtime theme derivation and first-paint snapshots.",
6
6
  "keywords": [