@azx-pbc/axiom-web 0.0.0-stage → 0.0.6

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 (141) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +161 -2
  3. package/dist/address.d.ts +32 -0
  4. package/dist/address.d.ts.map +1 -0
  5. package/dist/address.js +146 -0
  6. package/dist/address.js.map +1 -0
  7. package/dist/capture/MediaCapture.d.ts +45 -0
  8. package/dist/capture/MediaCapture.d.ts.map +1 -0
  9. package/dist/capture/MediaCapture.js +669 -0
  10. package/dist/capture/MediaCapture.js.map +1 -0
  11. package/dist/capture/SignatureCapture.d.ts +31 -0
  12. package/dist/capture/SignatureCapture.d.ts.map +1 -0
  13. package/dist/capture/SignatureCapture.js +329 -0
  14. package/dist/capture/SignatureCapture.js.map +1 -0
  15. package/dist/capture/copy.d.ts +101 -0
  16. package/dist/capture/copy.d.ts.map +1 -0
  17. package/dist/capture/copy.js +1369 -0
  18. package/dist/capture/copy.js.map +1 -0
  19. package/dist/capture/index.d.ts +19 -0
  20. package/dist/capture/index.d.ts.map +1 -0
  21. package/dist/capture/index.js +14 -0
  22. package/dist/capture/index.js.map +1 -0
  23. package/dist/capture/media-kind.d.ts +16 -0
  24. package/dist/capture/media-kind.d.ts.map +1 -0
  25. package/dist/capture/media-kind.js +64 -0
  26. package/dist/capture/media-kind.js.map +1 -0
  27. package/dist/capture/permissions.d.ts +109 -0
  28. package/dist/capture/permissions.d.ts.map +1 -0
  29. package/dist/capture/permissions.js +172 -0
  30. package/dist/capture/permissions.js.map +1 -0
  31. package/dist/capture/refusal.d.ts +13 -0
  32. package/dist/capture/refusal.d.ts.map +1 -0
  33. package/dist/capture/refusal.js +16 -0
  34. package/dist/capture/refusal.js.map +1 -0
  35. package/dist/controls.d.ts +64 -0
  36. package/dist/controls.d.ts.map +1 -0
  37. package/dist/controls.js +2524 -0
  38. package/dist/controls.js.map +1 -0
  39. package/dist/coordinate.d.ts +38 -0
  40. package/dist/coordinate.d.ts.map +1 -0
  41. package/dist/coordinate.js +220 -0
  42. package/dist/coordinate.js.map +1 -0
  43. package/dist/copy.d.ts +313 -0
  44. package/dist/copy.d.ts.map +1 -0
  45. package/dist/copy.js +2602 -0
  46. package/dist/copy.js.map +1 -0
  47. package/dist/countries.d.ts +14 -0
  48. package/dist/countries.d.ts.map +1 -0
  49. package/dist/countries.js +264 -0
  50. package/dist/countries.js.map +1 -0
  51. package/dist/format/calendar-locale.d.ts +19 -0
  52. package/dist/format/calendar-locale.d.ts.map +1 -0
  53. package/dist/format/calendar-locale.js +38 -0
  54. package/dist/format/calendar-locale.js.map +1 -0
  55. package/dist/format/country-names.d.ts +21 -0
  56. package/dist/format/country-names.d.ts.map +1 -0
  57. package/dist/format/country-names.js +2277 -0
  58. package/dist/format/country-names.js.map +1 -0
  59. package/dist/format/date.d.ts +58 -0
  60. package/dist/format/date.d.ts.map +1 -0
  61. package/dist/format/date.js +155 -0
  62. package/dist/format/date.js.map +1 -0
  63. package/dist/format/digits.d.ts +23 -0
  64. package/dist/format/digits.d.ts.map +1 -0
  65. package/dist/format/digits.js +46 -0
  66. package/dist/format/digits.js.map +1 -0
  67. package/dist/format/index.d.ts +28 -0
  68. package/dist/format/index.d.ts.map +1 -0
  69. package/dist/format/index.js +24 -0
  70. package/dist/format/index.js.map +1 -0
  71. package/dist/format/locale.d.ts +33 -0
  72. package/dist/format/locale.d.ts.map +1 -0
  73. package/dist/format/locale.js +39 -0
  74. package/dist/format/locale.js.map +1 -0
  75. package/dist/format/media-type.d.ts +8 -0
  76. package/dist/format/media-type.d.ts.map +1 -0
  77. package/dist/format/media-type.js +302 -0
  78. package/dist/format/media-type.js.map +1 -0
  79. package/dist/format/money.d.ts +52 -0
  80. package/dist/format/money.d.ts.map +1 -0
  81. package/dist/format/money.js +36 -0
  82. package/dist/format/money.js.map +1 -0
  83. package/dist/format/number.d.ts +28 -0
  84. package/dist/format/number.d.ts.map +1 -0
  85. package/dist/format/number.js +91 -0
  86. package/dist/format/number.js.map +1 -0
  87. package/dist/host.d.ts +122 -0
  88. package/dist/host.d.ts.map +1 -0
  89. package/dist/host.js +20 -0
  90. package/dist/host.js.map +1 -0
  91. package/dist/index.d.ts +57 -0
  92. package/dist/index.d.ts.map +1 -0
  93. package/dist/index.js +49 -0
  94. package/dist/index.js.map +1 -0
  95. package/dist/media.d.ts +42 -0
  96. package/dist/media.d.ts.map +1 -0
  97. package/dist/media.js +151 -0
  98. package/dist/media.js.map +1 -0
  99. package/dist/pickers/DatePicker.d.ts +35 -0
  100. package/dist/pickers/DatePicker.d.ts.map +1 -0
  101. package/dist/pickers/DatePicker.js +212 -0
  102. package/dist/pickers/DatePicker.js.map +1 -0
  103. package/dist/pickers/TimeSegments.d.ts +27 -0
  104. package/dist/pickers/TimeSegments.d.ts.map +1 -0
  105. package/dist/pickers/TimeSegments.js +82 -0
  106. package/dist/pickers/TimeSegments.js.map +1 -0
  107. package/dist/pickers/day-picker-locale.d.ts +15 -0
  108. package/dist/pickers/day-picker-locale.d.ts.map +1 -0
  109. package/dist/pickers/day-picker-locale.js +46 -0
  110. package/dist/pickers/day-picker-locale.js.map +1 -0
  111. package/dist/render/dom.d.ts +100 -0
  112. package/dist/render/dom.d.ts.map +1 -0
  113. package/dist/render/dom.js +882 -0
  114. package/dist/render/dom.js.map +1 -0
  115. package/dist/render/layout.d.ts +45 -0
  116. package/dist/render/layout.d.ts.map +1 -0
  117. package/dist/render/layout.js +8 -0
  118. package/dist/render/layout.js.map +1 -0
  119. package/dist/schedule/SchedulePicker.d.ts +46 -0
  120. package/dist/schedule/SchedulePicker.d.ts.map +1 -0
  121. package/dist/schedule/SchedulePicker.js +160 -0
  122. package/dist/schedule/SchedulePicker.js.map +1 -0
  123. package/dist/schedule/timeslot.d.ts +52 -0
  124. package/dist/schedule/timeslot.d.ts.map +1 -0
  125. package/dist/schedule/timeslot.js +265 -0
  126. package/dist/schedule/timeslot.js.map +1 -0
  127. package/dist/styles.css +2151 -0
  128. package/dist/theme/index.d.ts +12 -0
  129. package/dist/theme/index.d.ts.map +1 -0
  130. package/dist/theme/index.js +11 -0
  131. package/dist/theme/index.js.map +1 -0
  132. package/dist/theme/presets.d.ts +93 -0
  133. package/dist/theme/presets.d.ts.map +1 -0
  134. package/dist/theme/presets.js +200 -0
  135. package/dist/theme/presets.js.map +1 -0
  136. package/dist/tokens.css +234 -0
  137. package/dist/wizard-checkpoints.d.ts +18 -0
  138. package/dist/wizard-checkpoints.d.ts.map +1 -0
  139. package/dist/wizard-checkpoints.js +56 -0
  140. package/dist/wizard-checkpoints.js.map +1 -0
  141. package/package.json +76 -3
@@ -0,0 +1,12 @@
1
+ /**
2
+ * The reference theme's typed API.
3
+ *
4
+ * The two sheets are separate doors on purpose: a host with its own design system can import the
5
+ * class hooks without importing any CSS, and a host that wants the reference look imports
6
+ * `@azx-pbc/axiom-web/tokens.css` (tokens) plus `@azx-pbc/axiom-web/styles.css` (components).
7
+ * Importing every sheet through this module would make one code import load two stylesheets a
8
+ * bundler cannot tree-shake.
9
+ */
10
+ export { THEME_ATTRIBUTES, THEME_DENSITIES, THEME_SCHEMES, applyBrandAccent, applyTheme, } from './presets.js';
11
+ export type { AccentBrand, ApplyBrandResult, ThemeDensity, ThemeOptions, ThemeScheme, } from './presets.js';
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/theme/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,aAAa,EACb,gBAAgB,EAChB,UAAU,GACX,MAAM,cAAc,CAAC;AACtB,YAAY,EACV,WAAW,EACX,gBAAgB,EAChB,YAAY,EACZ,YAAY,EACZ,WAAW,GACZ,MAAM,cAAc,CAAC"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * The reference theme's typed API.
3
+ *
4
+ * The two sheets are separate doors on purpose: a host with its own design system can import the
5
+ * class hooks without importing any CSS, and a host that wants the reference look imports
6
+ * `@azx-pbc/axiom-web/tokens.css` (tokens) plus `@azx-pbc/axiom-web/styles.css` (components).
7
+ * Importing every sheet through this module would make one code import load two stylesheets a
8
+ * bundler cannot tree-shake.
9
+ */
10
+ export { THEME_ATTRIBUTES, THEME_DENSITIES, THEME_SCHEMES, applyBrandAccent, applyTheme, } from './presets.js';
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/theme/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,aAAa,EACb,gBAAgB,EAChB,UAAU,GACX,MAAM,cAAc,CAAC","sourcesContent":["/**\n * The reference theme's typed API.\n *\n * The two sheets are separate doors on purpose: a host with its own design system can import the\n * class hooks without importing any CSS, and a host that wants the reference look imports\n * `@azx-pbc/axiom-web/tokens.css` (tokens) plus `@azx-pbc/axiom-web/styles.css` (components).\n * Importing every sheet through this module would make one code import load two stylesheets a\n * bundler cannot tree-shake.\n */\nexport {\n THEME_ATTRIBUTES,\n THEME_DENSITIES,\n THEME_SCHEMES,\n applyBrandAccent,\n applyTheme,\n} from './presets.js';\nexport type {\n AccentBrand,\n ApplyBrandResult,\n ThemeDensity,\n ThemeOptions,\n ThemeScheme,\n} from './presets.js';\n"]}
@@ -0,0 +1,93 @@
1
+ /**
2
+ * The typed front door to the token contract.
3
+ *
4
+ * The renderer is deliberately headless: it emits class hooks and state attributes and never
5
+ * imports CSS. This module is the small, framework-free bridge a host calls once — from an
6
+ * effect, a route loader or a server-rendered layout's inline script — to choose which token
7
+ * block the subtree reads.
8
+ *
9
+ * There are two axes: the colour scheme and the density. Type is fixed by design: density
10
+ * re-scales spacing only, never type. The accent role is an explicit third option rather than
11
+ * a second axis: `applyBrandAccent` restates the one accent as scoped custom-property
12
+ * overrides on the target subtree and refuses a pair below the AA threshold, so a host can
13
+ * rebrand without forking the sheet and without breaking the contrast the sheet guarantees.
14
+ * The square shape and the two weights stay the system and have no call.
15
+ *
16
+ * Nothing here reads or writes a global other than the target element. A server render has no
17
+ * `document`, so `applyTheme()` with no root is a no-op rather than a crash; pass a root when
18
+ * one exists and the same call works in the browser and under SSR.
19
+ */
20
+ /** The three colour schemes `tokens.css` declares. `auto` follows `prefers-color-scheme`. */
21
+ export declare const THEME_SCHEMES: readonly ['light', 'dark', 'auto'];
22
+ /** The density a form paints with. Compact tightens the rhythm, not the control height. */
23
+ export declare const THEME_DENSITIES: readonly ['comfortable', 'compact'];
24
+ export type ThemeScheme = (typeof THEME_SCHEMES)[number];
25
+ export type ThemeDensity = (typeof THEME_DENSITIES)[number];
26
+ /** What a caller chooses. Every member is optional; an omitted member states the default. */
27
+ export interface ThemeOptions {
28
+ /** Colour scheme; defaults to `auto`. */
29
+ readonly scheme?: ThemeScheme;
30
+ /** Density; defaults to `comfortable`. */
31
+ readonly density?: ThemeDensity;
32
+ }
33
+ /** The attributes the theme owns, so a test and a host can name them once. */
34
+ export declare const THEME_ATTRIBUTES: {
35
+ readonly scheme: 'data-ax-scheme';
36
+ readonly density: 'data-ax-density';
37
+ /** Mirrors `density` for host CSS that wants the renderer's own spelling. */
38
+ readonly densityMirror: 'data-density';
39
+ };
40
+ /**
41
+ * Select the scheme and density a subtree paints with.
42
+ *
43
+ * `root` is the element that owns the form — usually `document.documentElement`, but a scoped
44
+ * panel may pass its own container. Omitted, it is the document root; during SSR there is none
45
+ * and the call returns without touching a global.
46
+ */
47
+ export declare function applyTheme(root?: HTMLElement | null, options?: ThemeOptions): void;
48
+ /**
49
+ * The accent role a host restates, as hex spellings.
50
+ *
51
+ * The brand is one accent, so the success and information roles follow it: they are the
52
+ * accent under another name in the sheet, and a brand that left the reference blue behind
53
+ * in notices would paint two accents. The shape, the type and the danger role are not
54
+ * members; they stay the system.
55
+ */
56
+ export interface AccentBrand {
57
+ /** The one accent: text, borders and fills on the surface. */
58
+ readonly accent: string;
59
+ /** The accent at hover. */
60
+ readonly accentHover: string;
61
+ /** The tinted fill behind accent-contrast text. */
62
+ readonly accentSoft: string;
63
+ /** Text on the soft fill. */
64
+ readonly accentContrast: string;
65
+ /** Text on a filled accent. */
66
+ readonly onAccent: string;
67
+ /** The focus outline; defaults to the accent. */
68
+ readonly focusRing?: string;
69
+ }
70
+ /**
71
+ * How a brand request ended.
72
+ *
73
+ * A refusal is an expected outcome, not a programmer error, so it is a value: the reason
74
+ * names the failing pair and the ratio it measured, and the target is left untouched.
75
+ */
76
+ export type ApplyBrandResult = {
77
+ readonly kind: 'applied';
78
+ } | {
79
+ readonly kind: 'refused';
80
+ readonly reason: string;
81
+ readonly ratio?: number;
82
+ };
83
+ /**
84
+ * Restate the accent role on one subtree, or refuse with the measured ratio.
85
+ *
86
+ * The overrides are scoped custom properties on `root`, so two forms on one page can carry
87
+ * two brands and a later `applyTheme` call leaves them alone. Every text-carrying pair is
88
+ * measured before anything is written: a pair below the AA minimum refuses the whole brand
89
+ * and the target is left exactly as it was. Call this after `applyTheme`, so the scheme the
90
+ * surface is read under is the one the subtree paints.
91
+ */
92
+ export declare function applyBrandAccent(root: HTMLElement, brand: AccentBrand): ApplyBrandResult;
93
+ //# sourceMappingURL=presets.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"presets.d.ts","sourceRoot":"","sources":["../../src/theme/presets.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,6FAA6F;AAC7F,eAAO,MAAM,aAAa,YAAI,OAAO,EAAE,MAAM,EAAE,MAAM,CAAU,CAAC;AAEhE,2FAA2F;AAC3F,eAAO,MAAM,eAAe,YAAI,aAAa,EAAE,SAAS,CAAU,CAAC;AAEnE,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,CAAC,CAAC;AACzD,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC;AA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,0 +1,200 @@
1
+ /**
2
+ * The typed front door to the token contract.
3
+ *
4
+ * The renderer is deliberately headless: it emits class hooks and state attributes and never
5
+ * imports CSS. This module is the small, framework-free bridge a host calls once — from an
6
+ * effect, a route loader or a server-rendered layout's inline script — to choose which token
7
+ * block the subtree reads.
8
+ *
9
+ * There are two axes: the colour scheme and the density. Type is fixed by design: density
10
+ * re-scales spacing only, never type. The accent role is an explicit third option rather than
11
+ * a second axis: `applyBrandAccent` restates the one accent as scoped custom-property
12
+ * overrides on the target subtree and refuses a pair below the AA threshold, so a host can
13
+ * rebrand without forking the sheet and without breaking the contrast the sheet guarantees.
14
+ * The square shape and the two weights stay the system and have no call.
15
+ *
16
+ * Nothing here reads or writes a global other than the target element. A server render has no
17
+ * `document`, so `applyTheme()` with no root is a no-op rather than a crash; pass a root when
18
+ * one exists and the same call works in the browser and under SSR.
19
+ */
20
+ /** The three colour schemes `tokens.css` declares. `auto` follows `prefers-color-scheme`. */
21
+ export const THEME_SCHEMES = ['light', 'dark', 'auto'];
22
+ /** The density a form paints with. Compact tightens the rhythm, not the control height. */
23
+ export const THEME_DENSITIES = ['comfortable', 'compact'];
24
+ /** The attributes the theme owns, so a test and a host can name them once. */
25
+ export const THEME_ATTRIBUTES = {
26
+ scheme: 'data-ax-scheme',
27
+ density: 'data-ax-density',
28
+ /** Mirrors `density` for host CSS that wants the renderer's own spelling. */
29
+ densityMirror: 'data-density',
30
+ };
31
+ /**
32
+ * Inline values an earlier build left behind that no supported call writes any more.
33
+ *
34
+ * The system is square, so a page upgraded from a themed build drops the old per-page radius
35
+ * instead of layering the system under it. The accent entries used to live here; they no
36
+ * longer do, because `applyBrandAccent` is the supported way to restate the accent and
37
+ * `applyTheme` must not wipe a brand it did not write.
38
+ */
39
+ const RETIRED_PROPERTIES = ['--ax-radius-sm', '--ax-radius-md', '--ax-radius-lg'];
40
+ /**
41
+ * Select the scheme and density a subtree paints with.
42
+ *
43
+ * `root` is the element that owns the form — usually `document.documentElement`, but a scoped
44
+ * panel may pass its own container. Omitted, it is the document root; during SSR there is none
45
+ * and the call returns without touching a global.
46
+ */
47
+ export function applyTheme(root, options = {}) {
48
+ const target = root ?? (typeof document === 'undefined' ? undefined : document.documentElement);
49
+ if (target === undefined || target === null)
50
+ return;
51
+ const scheme = options.scheme ?? 'auto';
52
+ const density = options.density ?? 'comfortable';
53
+ target.setAttribute(THEME_ATTRIBUTES.scheme, scheme);
54
+ target.setAttribute(THEME_ATTRIBUTES.density, density);
55
+ target.setAttribute(THEME_ATTRIBUTES.densityMirror, density);
56
+ for (const property of RETIRED_PROPERTIES)
57
+ target.style.removeProperty(property);
58
+ }
59
+ /** The AA minimum every text-carrying brand pair must meet. */
60
+ const BRAND_MINIMUM_RATIO = 4.5;
61
+ /**
62
+ * The surfaces a brand is measured against when no stylesheet is loaded.
63
+ *
64
+ * The primary path reads the live `--ax-surface` value from the target, so the pair under
65
+ * test is the one the subtree actually paints. These two hexes are the fallback for a host
66
+ * without CSS (tests, SSR snapshots); they mirror `tokens.css`, and the brand test pins
67
+ * them to the sheet so the fallback cannot drift.
68
+ */
69
+ const BRAND_SURFACE_FALLBACK = {
70
+ light: '#ffffff',
71
+ dark: '#161618',
72
+ };
73
+ const HEX_COLOR_PATTERN = /^#(?:[0-9a-f]{3}|[0-9a-f]{6})$/i;
74
+ function isHexColor(value) {
75
+ return typeof value === 'string' && HEX_COLOR_PATTERN.test(value);
76
+ }
77
+ function normalizeHex(hex) {
78
+ const digits = hex.slice(1).toLowerCase();
79
+ const full = digits.length === 3
80
+ ? digits
81
+ .split('')
82
+ .map((digit) => digit + digit)
83
+ .join('')
84
+ : digits;
85
+ return `#${full}`;
86
+ }
87
+ function brandChannel(value) {
88
+ return value <= 0.04045 ? value / 12.92 : ((value + 0.055) / 1.055) ** 2.4;
89
+ }
90
+ function brandLuminance(hex) {
91
+ const digits = normalizeHex(hex).slice(1);
92
+ const red = brandChannel(Number.parseInt(digits.slice(0, 2), 16) / 255);
93
+ const green = brandChannel(Number.parseInt(digits.slice(2, 4), 16) / 255);
94
+ const blue = brandChannel(Number.parseInt(digits.slice(4, 6), 16) / 255);
95
+ return 0.2126 * red + 0.7152 * green + 0.0722 * blue;
96
+ }
97
+ function brandContrast(foreground, background) {
98
+ const ordered = [brandLuminance(foreground), brandLuminance(background)].sort((left, right) => right - left);
99
+ const lighter = ordered[0] ?? 0;
100
+ const darker = ordered[1] ?? 0;
101
+ return (lighter + 0.05) / (darker + 0.05);
102
+ }
103
+ function fallbackSurface(target) {
104
+ return target.getAttribute(THEME_ATTRIBUTES.scheme) === 'dark'
105
+ ? BRAND_SURFACE_FALLBACK.dark
106
+ : BRAND_SURFACE_FALLBACK.light;
107
+ }
108
+ /**
109
+ * The surface the brand is measured against: the live `--ax-surface` value when a
110
+ * stylesheet is loaded, otherwise the scheme fallback for a host without CSS.
111
+ */
112
+ function brandSurface(target) {
113
+ if (typeof getComputedStyle !== 'function')
114
+ return fallbackSurface(target);
115
+ const computed = getComputedStyle(target).getPropertyValue('--ax-surface').trim().toLowerCase();
116
+ if (isHexColor(computed))
117
+ return normalizeHex(computed);
118
+ return fallbackSurface(target);
119
+ }
120
+ /**
121
+ * Restate the accent role on one subtree, or refuse with the measured ratio.
122
+ *
123
+ * The overrides are scoped custom properties on `root`, so two forms on one page can carry
124
+ * two brands and a later `applyTheme` call leaves them alone. Every text-carrying pair is
125
+ * measured before anything is written: a pair below the AA minimum refuses the whole brand
126
+ * and the target is left exactly as it was. Call this after `applyTheme`, so the scheme the
127
+ * surface is read under is the one the subtree paints.
128
+ */
129
+ export function applyBrandAccent(root, brand) {
130
+ // The brand crosses from host code, so the spellings are read as unknown and the guard
131
+ // below is the runtime check, not a formality: a non-string here is a refused brand, and
132
+ // String states exactly what was passed rather than what the types promised.
133
+ const spellings = [
134
+ brand.accent,
135
+ brand.accentHover,
136
+ brand.accentSoft,
137
+ brand.accentContrast,
138
+ brand.onAccent,
139
+ brand.focusRing ?? brand.accent,
140
+ ];
141
+ for (const spelling of spellings) {
142
+ if (!isHexColor(spelling)) {
143
+ return {
144
+ kind: 'refused',
145
+ reason: `Brand accent refused: ${String(spelling)} is not a #rgb or #rrggbb spelling, so no ratio can be measured.`,
146
+ };
147
+ }
148
+ }
149
+ const accent = normalizeHex(brand.accent);
150
+ const pairs = [
151
+ { foreground: accent, background: brandSurface(root), use: 'accent text on the surface' },
152
+ {
153
+ foreground: normalizeHex(brand.accentHover),
154
+ background: brandSurface(root),
155
+ use: 'accent hover on the surface',
156
+ },
157
+ {
158
+ foreground: normalizeHex(brand.onAccent),
159
+ background: accent,
160
+ use: 'text on a filled accent',
161
+ },
162
+ {
163
+ foreground: normalizeHex(brand.accentContrast),
164
+ background: normalizeHex(brand.accentSoft),
165
+ use: 'accent text on the soft fill',
166
+ },
167
+ ];
168
+ for (const pair of pairs) {
169
+ const ratio = brandContrast(pair.foreground, pair.background);
170
+ if (ratio < BRAND_MINIMUM_RATIO) {
171
+ const text = (Math.round(ratio * 100) / 100).toFixed(2);
172
+ return {
173
+ kind: 'refused',
174
+ reason: `Brand accent refused: ${pair.foreground} on ${pair.background} measures ${text}:1, below the 4.5:1 AA minimum for ${pair.use}.`,
175
+ ratio: Math.round(ratio * 100) / 100,
176
+ };
177
+ }
178
+ }
179
+ const focusRing = normalizeHex(brand.focusRing ?? brand.accent);
180
+ const soft = normalizeHex(brand.accentSoft);
181
+ const properties = {
182
+ '--ax-accent': accent,
183
+ '--ax-accent-hover': normalizeHex(brand.accentHover),
184
+ '--ax-accent-soft': soft,
185
+ '--ax-accent-contrast': normalizeHex(brand.accentContrast),
186
+ '--ax-fg-on-accent': normalizeHex(brand.onAccent),
187
+ '--ax-focus-ring': focusRing,
188
+ '--ax-ok': accent,
189
+ '--ax-ok-soft': soft,
190
+ '--ax-info': accent,
191
+ '--ax-info-soft': soft,
192
+ };
193
+ for (const name of Object.keys(properties)) {
194
+ const value = properties[name];
195
+ if (value !== undefined)
196
+ root.style.setProperty(name, value);
197
+ }
198
+ return { kind: 'applied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AAE,SAAS;QAC5B,SAAS,EAAE,MAAM;QACjB,cAAc,EAAE,IAAI;QACpB,WAAW,EAAE,MAAM;QACnB,gBAAgB,EAAE,IAAI;KACvB,CAAC;IACF,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;QAC3C,MAAM,KAAK,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC;QAC/B,IAAI,KAAK,KAAK,SAAS;YAAE,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAC/D,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;AAC7B,CAAC","sourcesContent":["/**\n * The typed front door to the token contract.\n *\n * The renderer is deliberately headless: it emits class hooks and state attributes and never\n * imports CSS. This module is the small, framework-free bridge a host calls once — from an\n * effect, a route loader or a server-rendered layout's inline script — to choose which token\n * block the subtree reads.\n *\n * There are two axes: the colour scheme and the density. Type is fixed by design: density\n * re-scales spacing only, never type. The accent role is an explicit third option rather than\n * a second axis: `applyBrandAccent` restates the one accent as scoped custom-property\n * overrides on the target subtree and refuses a pair below the AA threshold, so a host can\n * rebrand without forking the sheet and without breaking the contrast the sheet guarantees.\n * The square shape and the two weights stay the system and have no call.\n *\n * Nothing here reads or writes a global other than the target element. A server render has no\n * `document`, so `applyTheme()` with no root is a no-op rather than a crash; pass a root when\n * one exists and the same call works in the browser and under SSR.\n */\n\n/** The three colour schemes `tokens.css` declares. `auto` follows `prefers-color-scheme`. */\nexport const THEME_SCHEMES = ['light', 'dark', 'auto'] as const;\n\n/** The density a form paints with. Compact tightens the rhythm, not the control height. */\nexport const THEME_DENSITIES = ['comfortable', 'compact'] as const;\n\nexport type ThemeScheme = (typeof THEME_SCHEMES)[number];\nexport type ThemeDensity = (typeof THEME_DENSITIES)[number];\n\n/** What a caller chooses. Every member is optional; an omitted member states the default. */\nexport interface ThemeOptions {\n /** Colour scheme; defaults to `auto`. */\n readonly scheme?: ThemeScheme;\n /** Density; defaults to `comfortable`. */\n readonly density?: ThemeDensity;\n}\n\n/** The attributes the theme owns, so a test and a host can name them once. */\nexport const THEME_ATTRIBUTES = {\n scheme: 'data-ax-scheme',\n density: 'data-ax-density',\n /** Mirrors `density` for host CSS that wants the renderer's own spelling. */\n densityMirror: 'data-density',\n} as const;\n\n/**\n * Inline values an earlier build left behind that no supported call writes any more.\n *\n * The system is square, so a page upgraded from a themed build drops the old per-page radius\n * instead of layering the system under it. The accent entries used to live here; they no\n * longer do, because `applyBrandAccent` is the supported way to restate the accent and\n * `applyTheme` must not wipe a brand it did not write.\n */\nconst RETIRED_PROPERTIES = ['--ax-radius-sm', '--ax-radius-md', '--ax-radius-lg'] as const;\n\n/**\n * Select the scheme and density a subtree paints with.\n *\n * `root` is the element that owns the form — usually `document.documentElement`, but a scoped\n * panel may pass its own container. Omitted, it is the document root; during SSR there is none\n * and the call returns without touching a global.\n */\nexport function applyTheme(root?: HTMLElement | null, options: ThemeOptions = {}): void {\n const target = root ?? (typeof document === 'undefined' ? undefined : document.documentElement);\n if (target === undefined || target === null) return;\n const scheme = options.scheme ?? 'auto';\n const density = options.density ?? 'comfortable';\n target.setAttribute(THEME_ATTRIBUTES.scheme, scheme);\n target.setAttribute(THEME_ATTRIBUTES.density, density);\n target.setAttribute(THEME_ATTRIBUTES.densityMirror, density);\n for (const property of RETIRED_PROPERTIES) target.style.removeProperty(property);\n}\n\n/**\n * The accent role a host restates, as hex spellings.\n *\n * The brand is one accent, so the success and information roles follow it: they are the\n * accent under another name in the sheet, and a brand that left the reference blue behind\n * in notices would paint two accents. The shape, the type and the danger role are not\n * members; they stay the system.\n */\nexport interface AccentBrand {\n /** The one accent: text, borders and fills on the surface. */\n readonly accent: string;\n /** The accent at hover. */\n readonly accentHover: string;\n /** The tinted fill behind accent-contrast text. */\n readonly accentSoft: string;\n /** Text on the soft fill. */\n readonly accentContrast: string;\n /** Text on a filled accent. */\n readonly onAccent: string;\n /** The focus outline; defaults to the accent. */\n readonly focusRing?: string;\n}\n\n/**\n * How a brand request ended.\n *\n * A refusal is an expected outcome, not a programmer error, so it is a value: the reason\n * names the failing pair and the ratio it measured, and the target is left untouched.\n */\nexport type ApplyBrandResult =\n | { readonly kind: 'applied' }\n | { readonly kind: 'refused'; readonly reason: string; readonly ratio?: number };\n\n/** The AA minimum every text-carrying brand pair must meet. */\nconst BRAND_MINIMUM_RATIO = 4.5;\n\n/**\n * The surfaces a brand is measured against when no stylesheet is loaded.\n *\n * The primary path reads the live `--ax-surface` value from the target, so the pair under\n * test is the one the subtree actually paints. These two hexes are the fallback for a host\n * without CSS (tests, SSR snapshots); they mirror `tokens.css`, and the brand test pins\n * them to the sheet so the fallback cannot drift.\n */\nconst BRAND_SURFACE_FALLBACK = {\n light: '#ffffff',\n dark: '#161618',\n} as const;\n\nconst HEX_COLOR_PATTERN = /^#(?:[0-9a-f]{3}|[0-9a-f]{6})$/i;\n\nfunction isHexColor(value: unknown): value is string {\n return typeof value === 'string' && HEX_COLOR_PATTERN.test(value);\n}\n\nfunction normalizeHex(hex: string): string {\n const digits = hex.slice(1).toLowerCase();\n const full =\n digits.length === 3\n ? digits\n .split('')\n .map((digit) => digit + digit)\n .join('')\n : digits;\n return `#${full}`;\n}\n\nfunction brandChannel(value: number): number {\n return value <= 0.04045 ? value / 12.92 : ((value + 0.055) / 1.055) ** 2.4;\n}\n\nfunction brandLuminance(hex: string): number {\n const digits = normalizeHex(hex).slice(1);\n const red = brandChannel(Number.parseInt(digits.slice(0, 2), 16) / 255);\n const green = brandChannel(Number.parseInt(digits.slice(2, 4), 16) / 255);\n const blue = brandChannel(Number.parseInt(digits.slice(4, 6), 16) / 255);\n return 0.2126 * red + 0.7152 * green + 0.0722 * blue;\n}\n\nfunction brandContrast(foreground: string, background: string): number {\n const ordered = [brandLuminance(foreground), brandLuminance(background)].sort(\n (left, right) => right - left,\n );\n const lighter = ordered[0] ?? 0;\n const darker = ordered[1] ?? 0;\n return (lighter + 0.05) / (darker + 0.05);\n}\n\nfunction fallbackSurface(target: HTMLElement): string {\n return target.getAttribute(THEME_ATTRIBUTES.scheme) === 'dark'\n ? BRAND_SURFACE_FALLBACK.dark\n : BRAND_SURFACE_FALLBACK.light;\n}\n\n/**\n * The surface the brand is measured against: the live `--ax-surface` value when a\n * stylesheet is loaded, otherwise the scheme fallback for a host without CSS.\n */\nfunction brandSurface(target: HTMLElement): string {\n if (typeof getComputedStyle !== 'function') return fallbackSurface(target);\n const computed = getComputedStyle(target).getPropertyValue('--ax-surface').trim().toLowerCase();\n if (isHexColor(computed)) return normalizeHex(computed);\n return fallbackSurface(target);\n}\n\n/** One text-carrying pair the brand must keep readable, and the use the refusal names. */\ninterface BrandPair {\n readonly foreground: string;\n readonly background: string;\n readonly use: string;\n}\n\n/**\n * Restate the accent role on one subtree, or refuse with the measured ratio.\n *\n * The overrides are scoped custom properties on `root`, so two forms on one page can carry\n * two brands and a later `applyTheme` call leaves them alone. Every text-carrying pair is\n * measured before anything is written: a pair below the AA minimum refuses the whole brand\n * and the target is left exactly as it was. Call this after `applyTheme`, so the scheme the\n * surface is read under is the one the subtree paints.\n */\nexport function applyBrandAccent(root: HTMLElement, brand: AccentBrand): ApplyBrandResult {\n // The brand crosses from host code, so the spellings are read as unknown and the guard\n // below is the runtime check, not a formality: a non-string here is a refused brand, and\n // String states exactly what was passed rather than what the types promised.\n const spellings: readonly unknown[] = [\n brand.accent,\n brand.accentHover,\n brand.accentSoft,\n brand.accentContrast,\n brand.onAccent,\n brand.focusRing ?? brand.accent,\n ];\n for (const spelling of spellings) {\n if (!isHexColor(spelling)) {\n return {\n kind: 'refused',\n reason: `Brand accent refused: ${String(spelling)} is not a #rgb or #rrggbb spelling, so no ratio can be measured.`,\n };\n }\n }\n const accent = normalizeHex(brand.accent);\n const pairs: readonly BrandPair[] = [\n { foreground: accent, background: brandSurface(root), use: 'accent text on the surface' },\n {\n foreground: normalizeHex(brand.accentHover),\n background: brandSurface(root),\n use: 'accent hover on the surface',\n },\n {\n foreground: normalizeHex(brand.onAccent),\n background: accent,\n use: 'text on a filled accent',\n },\n {\n foreground: normalizeHex(brand.accentContrast),\n background: normalizeHex(brand.accentSoft),\n use: 'accent text on the soft fill',\n },\n ];\n for (const pair of pairs) {\n const ratio = brandContrast(pair.foreground, pair.background);\n if (ratio < BRAND_MINIMUM_RATIO) {\n const text = (Math.round(ratio * 100) / 100).toFixed(2);\n return {\n kind: 'refused',\n reason: `Brand accent refused: ${pair.foreground} on ${pair.background} measures ${text}:1, below the 4.5:1 AA minimum for ${pair.use}.`,\n ratio: Math.round(ratio * 100) / 100,\n };\n }\n }\n const focusRing = normalizeHex(brand.focusRing ?? brand.accent);\n const soft = normalizeHex(brand.accentSoft);\n const properties: Readonly<Record<string, string>> = {\n '--ax-accent': accent,\n '--ax-accent-hover': normalizeHex(brand.accentHover),\n '--ax-accent-soft': soft,\n '--ax-accent-contrast': normalizeHex(brand.accentContrast),\n '--ax-fg-on-accent': normalizeHex(brand.onAccent),\n '--ax-focus-ring': focusRing,\n '--ax-ok': accent,\n '--ax-ok-soft': soft,\n '--ax-info': accent,\n '--ax-info-soft': soft,\n };\n for (const name of Object.keys(properties)) {\n const value = properties[name];\n if (value !== undefined) root.style.setProperty(name, value);\n }\n return { kind: 'applied' };\n}\n"]}
@@ -0,0 +1,234 @@
1
+ /*
2
+ * The Axiom reference theme — the token contract.
3
+ *
4
+ * One flat, editorial system: square corners, hairline separators, one accent and two weights.
5
+ * This file carries no component rules (see `base.css`), and `base.css` names no colour, size or
6
+ * duration that is not declared here. An adopter may replace this file or override a token in
7
+ * place; the class hooks and the state attributes stay the same either way.
8
+ *
9
+ * Axes, each an attribute on the element that owns the subtree:
10
+ * - scheme: [data-ax-scheme="light" | "dark" | "auto"]
11
+ * - density: [data-ax-density="comfortable" | "compact"]
12
+ * Radius is not an axis. The shape is square. The accent is one colour, and a host restates
13
+ * it through `applyBrandAccent` rather than by replacing this sheet: the call writes the
14
+ * accent role as scoped overrides and refuses a pair below the AA threshold, so the contrast
15
+ * below keeps holding after a brand lands.
16
+ *
17
+ * The colour set is five roles plus a step: background, surface, hairline, text, secondary text,
18
+ * the one accent and the one danger. `--ax-border` is the darker boundary because WCAG 1.4.11
19
+ * asks an input's edge to be distinguishable (3:1); it is a neutral, not a component shade.
20
+ * Every body and secondary pairing below is AA on its surface, and `theme-contract.test.ts`
21
+ * recomputes the matrix from this text.
22
+ */
23
+
24
+ :root {
25
+ /* Shape. Square everywhere; a 2px radius is permitted only for a tick/focus chip. */
26
+ --ax-radius-0: 0px;
27
+ --ax-radius-xs: 2px;
28
+ --ax-radius-sm: 0px;
29
+ --ax-radius-md: 0px;
30
+ --ax-radius-lg: 0px;
31
+ --ax-radius-full: 0px;
32
+
33
+ /* Spacing: the 4px scale. 4 / 8 / 12 / 16 / 24 / 32 / 48 / 64. */
34
+ --ax-space-0: 0px;
35
+ --ax-space-1: 4px;
36
+ --ax-space-2: 8px;
37
+ --ax-space-3: 12px;
38
+ --ax-space-4: 16px;
39
+ --ax-space-5: 24px;
40
+ --ax-space-6: 32px;
41
+ --ax-space-7: 48px;
42
+ --ax-space-8: 64px;
43
+
44
+ /* Type: one stack, two weights. */
45
+ --ax-font-sans:
46
+ ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial,
47
+ "Noto Sans", sans-serif;
48
+ --ax-font-mono: var(--ax-font-sans);
49
+ --ax-text-xs: 11px;
50
+ --ax-text-sm: 12px;
51
+ --ax-text-base: 13px;
52
+ --ax-text-lg: 15px;
53
+ --ax-text-xl: 24px;
54
+ --ax-text-2xl: 24px;
55
+
56
+ /* The named roles a form actually uses. */
57
+ --ax-text-label: 11px;
58
+ --ax-text-hint: 12px;
59
+ --ax-text-error: 12px;
60
+ --ax-text-body: 13px;
61
+ --ax-text-control: 16px;
62
+ --ax-text-question: 16px;
63
+ --ax-text-group: 13px;
64
+ --ax-text-section: 15px;
65
+ --ax-text-page: 24px;
66
+ --ax-leading-body: 1.45;
67
+ --ax-leading-tight: 1.25;
68
+ --ax-letter-label: 0.06em;
69
+
70
+ --ax-weight-regular: 400;
71
+ --ax-weight-medium: 600;
72
+ --ax-weight-semibold: 600;
73
+ --ax-weight-bold: 700;
74
+
75
+ /* The checkpoint circle's diameter: one endpoint of the hairline between two steps. */
76
+ --ax-checkpoint-size: 28px;
77
+
78
+ /* Widths a host can ask for without inventing a class. `custom` comes from a host number. */
79
+ --ax-measure: 46rem;
80
+ --ax-width-fill: 72rem;
81
+ --ax-width-narrow: 390px;
82
+
83
+ /* Dialog, overlay and scrim: reserved for the configurator's choice list and dialogs.
84
+ * The names below are the contract before the markup exists; `base.css` gives each its
85
+ * first paint so a surface built on them is born themed. The scrim is the one
86
+ * translucent fill in the system; everything else stays flat. */
87
+ --ax-overlay-scrim: rgb(17 17 19 / 0.5);
88
+ --ax-dialog-surface: #ffffff;
89
+ --ax-dialog-width: 32rem;
90
+
91
+ /* Rhythm. A row is 36px, a form control 40px, a touch target 44px, editor chrome 32px. */
92
+ --ax-row-height: 36px;
93
+ --ax-control-height: 40px;
94
+ --ax-touch-height: 44px;
95
+ --ax-chrome-height: 32px;
96
+ --ax-control-mark: 18px;
97
+ --ax-control-switch-inline: 36px;
98
+ --ax-control-switch-block: 20px;
99
+ --ax-control-switch-thumb: 18px;
100
+ --ax-duration-fast: 120ms;
101
+ --ax-duration-base: 200ms;
102
+ --ax-ease: cubic-bezier(0.2, 0, 0, 1);
103
+
104
+ color-scheme: light;
105
+
106
+ /* Light scheme. */
107
+ --ax-bg: #f7f7f8;
108
+ --ax-surface: #ffffff;
109
+ --ax-surface-2: #f2f2f4;
110
+ --ax-surface-3: #f2f2f4;
111
+ --ax-fg: #111113;
112
+ --ax-fg-muted: #6c6c74;
113
+ --ax-fg-subtle: #6c6c74;
114
+ --ax-fg-on-accent: #ffffff;
115
+ --ax-border: #767680;
116
+ --ax-border-strong: #111113;
117
+ --ax-divider: #e4e4e7;
118
+ --ax-accent: #2b5cff;
119
+ --ax-accent-hover: #1f46cc;
120
+ --ax-accent-soft: #eef2ff;
121
+ --ax-accent-contrast: #1b3575;
122
+ --ax-ok: #2b5cff;
123
+ --ax-ok-soft: #eef2ff;
124
+ --ax-warn: #111113;
125
+ --ax-warn-soft: #f2f2f4;
126
+ --ax-danger: #b42318;
127
+ --ax-danger-soft: #fdf1f0;
128
+ --ax-info: #2b5cff;
129
+ --ax-info-soft: #eef2ff;
130
+ --ax-focus-ring: #2b5cff;
131
+ }
132
+
133
+ [data-ax-scheme="light"] {
134
+ color-scheme: light;
135
+ }
136
+
137
+ [data-ax-scheme="dark"] {
138
+ color-scheme: dark;
139
+
140
+ --ax-bg: #0f0f11;
141
+ --ax-surface: #161618;
142
+ --ax-surface-2: #1d1d20;
143
+ --ax-surface-3: #1d1d20;
144
+ --ax-fg: #f4f4f5;
145
+ --ax-fg-muted: #a1a1aa;
146
+ --ax-fg-subtle: #a1a1aa;
147
+ --ax-fg-on-accent: #0b1020;
148
+ --ax-border: #8b8b93;
149
+ --ax-border-strong: #f4f4f5;
150
+ --ax-divider: #2a2a2e;
151
+ --ax-accent: #6d8bff;
152
+ --ax-accent-hover: #8ca4ff;
153
+ --ax-accent-soft: #1a2240;
154
+ --ax-accent-contrast: #cfe0ff;
155
+ --ax-ok: #6d8bff;
156
+ --ax-ok-soft: #1a2240;
157
+ --ax-warn: #f4f4f5;
158
+ --ax-warn-soft: #1d1d20;
159
+ --ax-danger: #ff8a80;
160
+ --ax-danger-soft: #2b1715;
161
+ --ax-info: #6d8bff;
162
+ --ax-info-soft: #1a2240;
163
+ --ax-focus-ring: #6d8bff;
164
+ --ax-overlay-scrim: rgb(0 0 0 / 0.6);
165
+ --ax-dialog-surface: #161618;
166
+ --ax-dialog-width: 32rem;
167
+ }
168
+
169
+ /*
170
+ * `auto` takes the light values declared on `:root` and the dark values below when the operating
171
+ * system asks for dark. The two blocks are kept identical to `[data-ax-scheme="dark"]`; a test
172
+ * compares them so the copy cannot drift.
173
+ */
174
+ [data-ax-scheme="auto"] {
175
+ color-scheme: light dark;
176
+ }
177
+
178
+ @media (prefers-color-scheme: dark) {
179
+ [data-ax-scheme="auto"] {
180
+ --ax-bg: #0f0f11;
181
+ --ax-surface: #161618;
182
+ --ax-surface-2: #1d1d20;
183
+ --ax-surface-3: #1d1d20;
184
+ --ax-fg: #f4f4f5;
185
+ --ax-fg-muted: #a1a1aa;
186
+ --ax-fg-subtle: #a1a1aa;
187
+ --ax-fg-on-accent: #0b1020;
188
+ --ax-border: #8b8b93;
189
+ --ax-border-strong: #f4f4f5;
190
+ --ax-divider: #2a2a2e;
191
+ --ax-accent: #6d8bff;
192
+ --ax-accent-hover: #8ca4ff;
193
+ --ax-accent-soft: #1a2240;
194
+ --ax-accent-contrast: #cfe0ff;
195
+ --ax-ok: #6d8bff;
196
+ --ax-ok-soft: #1a2240;
197
+ --ax-warn: #f4f4f5;
198
+ --ax-warn-soft: #1d1d20;
199
+ --ax-danger: #ff8a80;
200
+ --ax-danger-soft: #2b1715;
201
+ --ax-info: #6d8bff;
202
+ --ax-info-soft: #1a2240;
203
+ --ax-focus-ring: #6d8bff;
204
+ --ax-overlay-scrim: rgb(0 0 0 / 0.6);
205
+ --ax-dialog-surface: #161618;
206
+ --ax-dialog-width: 32rem;
207
+ }
208
+ }
209
+
210
+ [data-ax-density="comfortable"] {
211
+ --ax-space-1: 4px;
212
+ --ax-space-2: 8px;
213
+ --ax-space-3: 12px;
214
+ --ax-space-4: 16px;
215
+ --ax-space-5: 24px;
216
+ --ax-space-6: 32px;
217
+ --ax-space-7: 48px;
218
+ --ax-space-8: 64px;
219
+ }
220
+
221
+ /*
222
+ * Compact tightens the rhythm one 4px step between blocks. It deliberately keeps the control,
223
+ * touch and chrome heights: a dense form on a touch device still needs its 44px target.
224
+ */
225
+ [data-ax-density="compact"] {
226
+ --ax-space-1: 4px;
227
+ --ax-space-2: 8px;
228
+ --ax-space-3: 12px;
229
+ --ax-space-4: 12px;
230
+ --ax-space-5: 16px;
231
+ --ax-space-6: 24px;
232
+ --ax-space-7: 32px;
233
+ --ax-space-8: 48px;
234
+ }
@@ -0,0 +1,18 @@
1
+ import type { Wizard } from '@azx-pbc/axiom-react';
2
+ import type { ReactElement } from 'react';
3
+ /**
4
+ * The wizard's checkpoints, as a sequence rather than a tab bar.
5
+ *
6
+ * The bar is one `nav` holding an ordered list, so a reader hears "step 1 of 4" from the list
7
+ * itself. Each checkpoint carries its own number, its title and — in text, never colour alone —
8
+ * whether it is complete, current, blocked or not yet visited. A completed page is a button that
9
+ * goes back; the cursor's page states `aria-current="step"` and is not interactive; a page the
10
+ * reader has not reached is a plain label and never a control. The facts are the wizard's own
11
+ * (`Wizard.steps`), so this component invents no readiness rule.
12
+ */
13
+ export declare function WizardCheckpoints({ wizard, titles, }: {
14
+ readonly wizard: Wizard;
15
+ /** Resolved step titles by id, from the render tree's own translated chrome. */
16
+ readonly titles: ReadonlyMap<string, string>;
17
+ }): ReactElement | null;
18
+ //# sourceMappingURL=wizard-checkpoints.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wizard-checkpoints.d.ts","sourceRoot":"","sources":["../src/wizard-checkpoints.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAc,MAAM,sBAAsB,CAAC;AAC/D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAG1C;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAAC,EAChC,MAAM,EACN,MAAM,GACP,EAAE;IACD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,gFAAgF;IAChF,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC9C,GAAG,YAAY,GAAG,IAAI,CAwBtB"}