@zazz-ui/core 0.8.4 → 0.9.1

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 (35) hide show
  1. package/AUTHORING.md +1 -1
  2. package/CHANGELOG.md +75 -0
  3. package/README.md +2 -2
  4. package/dist/sri.json +20 -20
  5. package/dist/zazz.css +1 -1
  6. package/dist/zazz.js +1 -1
  7. package/editor/zazz.css-data.json +19 -15
  8. package/editor/zazz.html-data.json +12 -0
  9. package/editor/zazz.language-data.json +227 -85
  10. package/package.json +1 -1
  11. package/src/base/_typography.css +166 -35
  12. package/src/base/_variables.css +47 -38
  13. package/src/base/dialog-lifecycle.d.ts.map +1 -1
  14. package/src/base/dialog-lifecycle.js +4 -1
  15. package/src/base/dialog-lifecycle.ts +4 -1
  16. package/src/primitives/badge/badge.css +3 -6
  17. package/src/primitives/button/button.css +3 -6
  18. package/src/primitives/checkbox/checkbox.css +2 -2
  19. package/src/primitives/combobox/combobox.d.ts +23 -0
  20. package/src/primitives/combobox/combobox.d.ts.map +1 -1
  21. package/src/primitives/combobox/combobox.js +53 -2
  22. package/src/primitives/combobox/combobox.ts +51 -2
  23. package/src/primitives/command/command.css +2 -3
  24. package/src/primitives/debug/debug.d.ts.map +1 -1
  25. package/src/primitives/debug/debug.js +4 -1
  26. package/src/primitives/debug/debug.ts +4 -1
  27. package/src/primitives/fields/fields.css +5 -5
  28. package/src/primitives/input-group/input-group.css +4 -4
  29. package/src/primitives/layout/layout.css +2 -2
  30. package/src/primitives/lightbox/lightbox.css +4 -4
  31. package/src/primitives/mobile-menu/mobile-menu.css +2 -2
  32. package/src/primitives/password-group/password-group.css +4 -4
  33. package/src/primitives/radio/radio.css +3 -3
  34. package/src/primitives/switch/switch.css +5 -5
  35. package/src/primitives/tabs/tabs.css +3 -3
@@ -1,26 +1,83 @@
1
1
  /**
2
- * _typography.css — Prose ([data-ui~="prose"]) and figcaption reset
2
+ * _typography.css — Fluid type scale, prose ([data-ui~="prose"]), and figcaption reset
3
3
  *
4
4
  * @layer variables, reset, components
5
5
  * @requires _layers.css, _variables.css, _reset.css (figcaption baseline)
6
- * @uses Type tokens — consumes --font-family-*, --font-size-*,
7
- * --font-weight-*, --leading-*, --tracking-* from _variables.css;
8
- * exposes the data-ui="text-*" roles; weight, family, style,
6
+ * @uses Type tokens — consumes --font-family-*, --font-weight-*,
7
+ * --leading-*, --tracking-* and the type scale controls
8
+ * (--fluid-*, --typeset-base-*, --typeset-scale-*, --typeset-<sm|xs|2xs>-*)
9
+ * from _variables.css; exposes the data-ui="text-*" roles; weight, family, style,
9
10
  * and decoration are utilities (--font-weight, --font-family, --font-style, --text-decoration)
11
+ * @uses tan(atan2()) — divides two lengths into a plain number (a stand-in for
12
+ * progress() that every engine supports); pow() — the type scale's steps
10
13
  * @uses font-optical-sizing — heading optical size
11
14
  * @uses @scope (prose) to (not-prose): prose rules stop at a not-prose
12
15
  * element; a prose nested inside it starts its own scope
13
- * @tokens --ui-prose-* (@layer variables)
16
+ * @tokens --fluid, --typeset-base, --typeset-scale, --font-size-* (@layer variables);
17
+ * --ui-prose-* (@layer variables); presets data-prose-size="sm" | "lg"
14
18
  */
15
19
 
16
20
  @layer variables {
17
21
  :root {
18
- --ui-prose-figcaption-margin: var(--space-xs) 0 0 0;
19
- /* 0 preserves the figcaption-margin spacing; a length adds flex gap on top */
22
+ /* multiplies the space between prose blocks, on top of
23
+ --paragraph-spacing-multiplier and a data-prose-size preset */
24
+ --ui-prose-flow: 1;
25
+ --ui-prose-figcaption-mt: var(--space-xs);
26
+ /* 0 preserves the figcaption-mt spacing; a length adds flex gap on top */
20
27
  --ui-prose-figcaption-gap: 0px;
21
28
  --ui-prose-img-radius: var(--radius-md);
22
29
  --ui-prose-img-border: none;
23
30
  }
31
+
32
+ /* ===========================================================================
33
+ FLUID TYPE SCALE — calculations, don't touch; tune the controls in
34
+ _variables.css. A sized prose re-runs them, so its preset scales the base
35
+ and a :root control still reaches it.
36
+ =========================================================================== */
37
+
38
+ :where(:root, [data-ui~="prose"][data-prose-size]) {
39
+ /* 0 at --fluid-min, 1 at --fluid-max, linear between, clamped outside:
40
+ (100vi − min) ÷ (max − min). tan(atan2(a, b)) is a ÷ b as a plain number,
41
+ which calc() can't do with two lengths in every engine yet. Same result as
42
+ progress(100vi, var(--fluid-min), var(--fluid-max)). */
43
+ --fluid: clamp(0, tan(atan2(100vi - var(--fluid-min), var(--fluid-max) - var(--fluid-min))), 1);
44
+ --typeset-base: calc(
45
+ (
46
+ var(--typeset-base-min) + var(--fluid) *
47
+ (var(--typeset-base-max) - var(--typeset-base-min))
48
+ ) *
49
+ var(--_prose-size, 1)
50
+ );
51
+ --typeset-scale: calc(
52
+ var(--typeset-scale-min) + var(--fluid) *
53
+ (var(--typeset-scale-max) - var(--typeset-scale-min))
54
+ );
55
+
56
+ --font-size-2xs: calc(
57
+ var(--typeset-base) *
58
+ (var(--typeset-2xs-min) + var(--fluid) * (var(--typeset-2xs-max) - var(--typeset-2xs-min)))
59
+ );
60
+ --font-size-xs: calc(
61
+ var(--typeset-base) *
62
+ (var(--typeset-xs-min) + var(--fluid) * (var(--typeset-xs-max) - var(--typeset-xs-min)))
63
+ );
64
+ --font-size-sm: calc(
65
+ var(--typeset-base) *
66
+ (var(--typeset-sm-min) + var(--fluid) * (var(--typeset-sm-max) - var(--typeset-sm-min)))
67
+ );
68
+ --font-size-eyebrow: var(--font-size-2xs);
69
+ --font-size-md: var(--typeset-base);
70
+ --font-size-lg: calc(var(--typeset-base) * var(--typeset-scale));
71
+ --font-size-xl: calc(var(--typeset-base) * pow(var(--typeset-scale), 2));
72
+ --font-size-2xl: calc(var(--typeset-base) * pow(var(--typeset-scale), 3));
73
+ --font-size-h6: var(--font-size-xl);
74
+ --font-size-h5: var(--font-size-2xl);
75
+ --font-size-h4: calc(var(--typeset-base) * pow(var(--typeset-scale), 4));
76
+ --font-size-h3: calc(var(--typeset-base) * pow(var(--typeset-scale), 5));
77
+ --font-size-h2: calc(var(--typeset-base) * pow(var(--typeset-scale), 6));
78
+ --font-size-h1: calc(var(--typeset-base) * pow(var(--typeset-scale), 7));
79
+ --font-size-display: calc(var(--typeset-base) * pow(var(--typeset-scale), 8));
80
+ }
24
81
  }
25
82
 
26
83
  @layer ui.components {
@@ -33,6 +90,26 @@
33
90
  display: flex;
34
91
  }
35
92
 
93
+ /* a sized prose sets its own body text; a plain one inherits the page's */
94
+ :where([data-ui~="prose"][data-prose-size]) {
95
+ font-size: var(--font-size-md);
96
+ line-height: var(--_prose-leading, var(--leading-md));
97
+ }
98
+
99
+ /* size presets: a multiple of the base, a body leading, and a multiple of
100
+ the space between blocks; each composes with the :root controls and hooks */
101
+ :where([data-ui~="prose"][data-prose-size="sm"]) {
102
+ --_prose-size: 0.875;
103
+ --_prose-leading: 1.5;
104
+ --_prose-flow: 0.75;
105
+ }
106
+
107
+ :where([data-ui~="prose"][data-prose-size="lg"]) {
108
+ --_prose-size: 1.125;
109
+ --_prose-leading: 1.8;
110
+ --_prose-flow: 1.25;
111
+ }
112
+
36
113
  /* Prose styles its descendants up to a not-prose boundary; a prose nested
37
114
  inside not-prose starts its own scope, so the nearest root wins. */
38
115
  @scope ([data-ui~="prose"]) to ([data-ui~="not-prose"]) {
@@ -54,7 +131,7 @@
54
131
 
55
132
  :where(figure:has(img, video) > figcaption) {
56
133
  display: flex;
57
- margin: var(--ui-prose-figcaption-margin);
134
+ margin-block-start: var(--ui-prose-figcaption-mt);
58
135
  font-style: italic;
59
136
  font-family: var(--font-family-body);
60
137
  font-size: var(--font-size-sm);
@@ -111,19 +188,27 @@
111
188
 
112
189
  :where(hgroup:not(:first-child)) {
113
190
  font-size: var(--font-size-xl);
114
- margin-block-start: var(--paragraph-spacing-xl);
191
+ margin-block-start: calc(
192
+ var(--paragraph-spacing-xl) * var(--ui-prose-flow) * var(--_prose-flow, 1)
193
+ );
115
194
  }
116
195
 
117
196
  :where(ul:not(:first-child)) {
118
- margin-block-start: var(--paragraph-spacing-md);
197
+ margin-block-start: calc(
198
+ var(--paragraph-spacing-md) * var(--ui-prose-flow) * var(--_prose-flow, 1)
199
+ );
119
200
  }
120
201
 
121
202
  :where(ol:not(:first-child)) {
122
- margin-block-start: var(--paragraph-spacing-md);
203
+ margin-block-start: calc(
204
+ var(--paragraph-spacing-md) * var(--ui-prose-flow) * var(--_prose-flow, 1)
205
+ );
123
206
  }
124
207
 
125
208
  :where(dl:not(:first-child)) {
126
- margin-block-start: var(--paragraph-spacing-md);
209
+ margin-block-start: calc(
210
+ var(--paragraph-spacing-md) * var(--ui-prose-flow) * var(--_prose-flow, 1)
211
+ );
127
212
  }
128
213
 
129
214
  :where(li:not(:first-child)) {
@@ -150,95 +235,141 @@
150
235
  }
151
236
 
152
237
  :where([data-ui~="text-display"]:not(:first-child)) {
153
- margin-block-start: var(--paragraph-spacing-display);
238
+ margin-block-start: calc(
239
+ var(--paragraph-spacing-display) * var(--ui-prose-flow) * var(--_prose-flow, 1)
240
+ );
154
241
  }
155
242
 
156
243
  :where([data-ui~="text-h1"]:not(:first-child), h1:not(:first-child)) {
157
- margin-block-start: var(--paragraph-spacing-h1);
244
+ margin-block-start: calc(
245
+ var(--paragraph-spacing-h1) * var(--ui-prose-flow) * var(--_prose-flow, 1)
246
+ );
158
247
  }
159
248
 
160
249
  :where([data-ui~="text-h2"]:not(:first-child), h2:not(:first-child)) {
161
- margin-block-start: var(--paragraph-spacing-h2);
250
+ margin-block-start: calc(
251
+ var(--paragraph-spacing-h2) * var(--ui-prose-flow) * var(--_prose-flow, 1)
252
+ );
162
253
  }
163
254
 
164
255
  :where([data-ui~="text-h3"]:not(:first-child), h3:not(:first-child)) {
165
- margin-block-start: var(--paragraph-spacing-h3);
256
+ margin-block-start: calc(
257
+ var(--paragraph-spacing-h3) * var(--ui-prose-flow) * var(--_prose-flow, 1)
258
+ );
166
259
  }
167
260
 
168
261
  :where([data-ui~="text-h4"]:not(:first-child), h4:not(:first-child)) {
169
- margin-block-start: var(--paragraph-spacing-h4);
262
+ margin-block-start: calc(
263
+ var(--paragraph-spacing-h4) * var(--ui-prose-flow) * var(--_prose-flow, 1)
264
+ );
170
265
  }
171
266
 
172
267
  :where([data-ui~="text-h5"]:not(:first-child), h5:not(:first-child)) {
173
- margin-block-start: var(--paragraph-spacing-h5);
268
+ margin-block-start: calc(
269
+ var(--paragraph-spacing-h5) * var(--ui-prose-flow) * var(--_prose-flow, 1)
270
+ );
174
271
  }
175
272
 
176
273
  :where([data-ui~="text-h6"]:not(:first-child), h6:not(:first-child)) {
177
- margin-block-start: var(--paragraph-spacing-h6);
274
+ margin-block-start: calc(
275
+ var(--paragraph-spacing-h6) * var(--ui-prose-flow) * var(--_prose-flow, 1)
276
+ );
178
277
  }
179
278
 
180
279
  :where([data-ui~="text-2xl"]:not(:first-child)) {
181
- margin-block-start: var(--paragraph-spacing-2xl);
280
+ margin-block-start: calc(
281
+ var(--paragraph-spacing-2xl) * var(--ui-prose-flow) * var(--_prose-flow, 1)
282
+ );
182
283
  }
183
284
 
184
285
  :where([data-ui~="text-xl"]:not(:first-child)) {
185
- margin-block-start: var(--paragraph-spacing-xl);
286
+ margin-block-start: calc(
287
+ var(--paragraph-spacing-xl) * var(--ui-prose-flow) * var(--_prose-flow, 1)
288
+ );
186
289
  }
187
290
 
188
291
  :where([data-ui~="text-lg"]:not(:first-child)) {
189
- margin-block-start: var(--paragraph-spacing-lg);
292
+ margin-block-start: calc(
293
+ var(--paragraph-spacing-lg) * var(--ui-prose-flow) * var(--_prose-flow, 1)
294
+ );
190
295
  }
191
296
 
192
297
  :where([data-ui~="text-md"]:not(:first-child), :is(p, pre):not(:first-child)) {
193
- margin-block-start: var(--paragraph-spacing-md);
298
+ margin-block-start: calc(
299
+ var(--paragraph-spacing-md) * var(--ui-prose-flow) * var(--_prose-flow, 1)
300
+ );
194
301
  }
195
302
 
196
303
  :where([data-ui~="text-sm"]:not(:first-child)) {
197
- margin-block-start: var(--paragraph-spacing-sm);
304
+ margin-block-start: calc(
305
+ var(--paragraph-spacing-sm) * var(--ui-prose-flow) * var(--_prose-flow, 1)
306
+ );
198
307
  }
199
308
 
200
309
  :where([data-ui~="text-xs"]:not(:first-child)) {
201
- margin-block-start: var(--paragraph-spacing-xs);
310
+ margin-block-start: calc(
311
+ var(--paragraph-spacing-xs) * var(--ui-prose-flow) * var(--_prose-flow, 1)
312
+ );
202
313
  }
203
314
 
204
315
  :where([data-ui~="text-2xs"]:not(:first-child)) {
205
- margin-block-start: var(--paragraph-spacing-2xs);
316
+ margin-block-start: calc(
317
+ var(--paragraph-spacing-2xs) * var(--ui-prose-flow) * var(--_prose-flow, 1)
318
+ );
206
319
  }
207
320
 
208
321
  :where([data-ui~="text-eyebrow"]:not(:first-child)) {
209
- margin-block-start: var(--paragraph-spacing-eyebrow);
322
+ margin-block-start: calc(
323
+ var(--paragraph-spacing-eyebrow) * var(--ui-prose-flow) * var(--_prose-flow, 1)
324
+ );
210
325
  }
211
326
 
212
327
  :where(hr:first-child) {
213
- margin-block-end: calc(var(--space-md) * var(--_paragraph-spacing-multiplier));
328
+ margin-block-end: calc(
329
+ var(--space-md) * var(--paragraph-spacing-multiplier) * var(--ui-prose-flow)
330
+ );
214
331
  }
215
332
 
216
333
  :where(hr:not(:first-child)) {
217
- margin-block: calc(var(--space-lg) * var(--_paragraph-spacing-multiplier));
334
+ margin-block: calc(
335
+ var(--space-lg) * var(--paragraph-spacing-multiplier) * var(--ui-prose-flow)
336
+ );
218
337
  }
219
338
 
220
339
  :where([data-ui~="text-eyebrow"] + *) {
221
- margin-block-start: var(--paragraph-spacing-xs);
340
+ margin-block-start: calc(
341
+ var(--paragraph-spacing-xs) * var(--ui-prose-flow) * var(--_prose-flow, 1)
342
+ );
222
343
  }
223
344
 
224
345
  :where(figure:not(:first-child)) {
225
- margin-block-start: var(--paragraph-spacing-md);
346
+ margin-block-start: calc(
347
+ var(--paragraph-spacing-md) * var(--ui-prose-flow) * var(--_prose-flow, 1)
348
+ );
226
349
  }
227
350
 
228
351
  :where(figure:not(:first-child):has(:is(img, video))) {
229
- margin-block-start: calc(var(--paragraph-spacing-md) * 2);
352
+ margin-block-start: calc(
353
+ var(--paragraph-spacing-md) * 2 * var(--ui-prose-flow) * var(--_prose-flow, 1)
354
+ );
230
355
  }
231
356
 
232
357
  :where(dl > dt:not(:first-child)) {
233
- margin-block-start: var(--paragraph-spacing-md);
358
+ margin-block-start: calc(
359
+ var(--paragraph-spacing-md) * var(--ui-prose-flow) * var(--_prose-flow, 1)
360
+ );
234
361
  }
235
362
 
236
363
  :where(blockquote:not(:first-child)) {
237
- margin-block-start: var(--paragraph-spacing-lg);
364
+ margin-block-start: calc(
365
+ var(--paragraph-spacing-lg) * var(--ui-prose-flow) * var(--_prose-flow, 1)
366
+ );
238
367
  }
239
368
 
240
369
  :where(blockquote:not(:last-child)) {
241
- margin-block-end: var(--paragraph-spacing-lg);
370
+ margin-block-end: calc(
371
+ var(--paragraph-spacing-lg) * var(--ui-prose-flow) * var(--_prose-flow, 1)
372
+ );
242
373
  }
243
374
  }
244
375
  }
@@ -2,7 +2,7 @@
2
2
  * _variables.css — Global design tokens (Tier 1).
3
3
  *
4
4
  * @layer variables
5
- * @requires _layers.css
5
+ * @requires _layers.css, _typography.css (--fluid, which --spacing reads)
6
6
  * @uses light-dark() — theme roles re-resolve per color-scheme (system,
7
7
  * data-ui="theme-dark" | "theme-light"); tokens stay unregistered on purpose
8
8
  * @uses oklch(from …) — shade/tint scales and shadow alphas
@@ -237,22 +237,27 @@
237
237
  --font-optical-sizing-heading: auto;
238
238
  --font-optical-sizing-body: auto;
239
239
 
240
- /* font-size — fluid clamp() */
241
- --font-size-eyebrow: clamp(0.512rem, 0.609rem + 0.1213vi, 0.5787rem);
242
- --font-size-2xs: clamp(0.512rem, 0.609rem + 0.1213vi, 0.5787rem);
243
- --font-size-xs: clamp(0.5787rem, 0.8584rem + 0.273vi, 0.64rem);
244
- --font-size-sm: clamp(0.7901rem, 0.9293rem + 0.1616vi, 0.8rem);
245
- --font-size-md: clamp(1rem, 1rem + 0vi, 1rem);
246
- --font-size-lg: clamp(1.125rem, 1.0682rem + 0.2273vi, 1.25rem);
247
- --font-size-xl: clamp(1.2656rem, 1.1307rem + 0.5398vi, 1.5625rem);
248
- --font-size-2xl: clamp(1.4238rem, 1.1832rem + 0.9624vi, 1.9531rem);
249
- --font-size-h6: clamp(1.2656rem, 1.1307rem + 0.5398vi, 1.5625rem);
250
- --font-size-h5: clamp(1.4238rem, 1.1832rem + 0.9624vi, 1.9531rem);
251
- --font-size-h4: clamp(1.6018rem, 1.2202rem + 1.5265vi, 2.4414rem);
252
- --font-size-h3: clamp(1.802rem, 1.234rem + 2.2722vi, 3.0518rem);
253
- --font-size-h2: clamp(2.0273rem, 1.2148rem + 3.2498vi, 3.8147rem);
254
- --font-size-h1: clamp(2.2807rem, 1.1499rem + 4.523vi, 4.7684rem);
255
- --font-size-display: clamp(2.5658rem, 1.0227rem + 6.1721vi, 5.9605rem);
240
+ /* fluid range — the viewport widths fluid type and spacing grow between;
241
+ below --fluid-min they hold their small end, above --fluid-max their large end */
242
+ --fluid-min: 25rem;
243
+ --fluid-max: 80rem;
244
+
245
+ /* typeset — the fluid type scale behind --font-size-*. md is the base; each step above it
246
+ multiplies by the scale (lg = 1 step, xl = 2, … display = 8). The base and
247
+ the scale each grow from -min to -max across the fluid range; the math
248
+ lives in _typography.css. */
249
+ --typeset-base-min: 1rem;
250
+ --typeset-base-max: 1rem;
251
+ --typeset-scale-min: 1.125;
252
+ --typeset-scale-max: 1.25;
253
+
254
+ /* sizes below md — multiples of the base at each end of the fluid range */
255
+ --typeset-sm-min: 0.8;
256
+ --typeset-sm-max: 0.8;
257
+ --typeset-xs-min: 0.64;
258
+ --typeset-xs-max: 0.64;
259
+ --typeset-2xs-min: 0.5787;
260
+ --typeset-2xs-max: 0.5787;
256
261
 
257
262
  /* font-weight */
258
263
  --font-weight-body: 400;
@@ -294,32 +299,36 @@
294
299
  --leading-2xs: 1.5;
295
300
  --leading-eyebrow: 1.2;
296
301
 
297
- /* paragraph-spacing */
298
- --_paragraph-spacing-multiplier: 1;
299
-
300
- --paragraph-spacing-display: calc(3.5rlh * var(--_paragraph-spacing-multiplier));
301
- --paragraph-spacing-h1: calc(3.5rlh * var(--_paragraph-spacing-multiplier));
302
- --paragraph-spacing-h2: calc(3rlh * var(--_paragraph-spacing-multiplier));
303
- --paragraph-spacing-h3: calc(3rlh * var(--_paragraph-spacing-multiplier));
304
- --paragraph-spacing-h4: calc(2rlh * var(--_paragraph-spacing-multiplier));
305
- --paragraph-spacing-h5: calc(2rlh * var(--_paragraph-spacing-multiplier));
306
- --paragraph-spacing-h6: calc(2rlh * var(--_paragraph-spacing-multiplier));
307
- --paragraph-spacing-2xl: calc(1rlh * var(--_paragraph-spacing-multiplier));
308
- --paragraph-spacing-xl: calc(0.75rlh * var(--_paragraph-spacing-multiplier));
309
- --paragraph-spacing-lg: calc(0.75rlh * var(--_paragraph-spacing-multiplier));
310
- --paragraph-spacing-md: calc(0.75rlh * var(--_paragraph-spacing-multiplier));
311
- --paragraph-spacing-sm: calc(0.5rlh * var(--_paragraph-spacing-multiplier));
312
- --paragraph-spacing-xs: calc(0.5rlh * var(--_paragraph-spacing-multiplier));
313
- --paragraph-spacing-2xs: calc(0.5rlh * var(--_paragraph-spacing-multiplier));
314
- --paragraph-spacing-eyebrow: calc(1rlh * var(--_paragraph-spacing-multiplier));
302
+ /* paragraph-spacing — the space above a block in prose; the multiplier
303
+ loosens or tightens every step at once (--ui-prose-flow scales it again per prose) */
304
+ --paragraph-spacing-multiplier: 1;
305
+
306
+ --paragraph-spacing-display: calc(3.5rlh * var(--paragraph-spacing-multiplier));
307
+ --paragraph-spacing-h1: calc(3.5rlh * var(--paragraph-spacing-multiplier));
308
+ --paragraph-spacing-h2: calc(3rlh * var(--paragraph-spacing-multiplier));
309
+ --paragraph-spacing-h3: calc(3rlh * var(--paragraph-spacing-multiplier));
310
+ --paragraph-spacing-h4: calc(2rlh * var(--paragraph-spacing-multiplier));
311
+ --paragraph-spacing-h5: calc(2rlh * var(--paragraph-spacing-multiplier));
312
+ --paragraph-spacing-h6: calc(2rlh * var(--paragraph-spacing-multiplier));
313
+ --paragraph-spacing-2xl: calc(1rlh * var(--paragraph-spacing-multiplier));
314
+ --paragraph-spacing-xl: calc(0.75rlh * var(--paragraph-spacing-multiplier));
315
+ --paragraph-spacing-lg: calc(0.75rlh * var(--paragraph-spacing-multiplier));
316
+ --paragraph-spacing-md: calc(0.75rlh * var(--paragraph-spacing-multiplier));
317
+ --paragraph-spacing-sm: calc(0.5rlh * var(--paragraph-spacing-multiplier));
318
+ --paragraph-spacing-xs: calc(0.5rlh * var(--paragraph-spacing-multiplier));
319
+ --paragraph-spacing-2xs: calc(0.5rlh * var(--paragraph-spacing-multiplier));
320
+ --paragraph-spacing-eyebrow: calc(1rlh * var(--paragraph-spacing-multiplier));
315
321
 
316
322
  /* ==========================================================================
317
323
  * Spacing — the --spacing unit and the --space-* scale
318
324
  * ========================================================================== */
319
325
 
320
- /* the utility scale unit: `--p: 4` is 4 × --spacing. Fluid between
321
- 0.225rem and 0.25rem; pin it with `:root { --spacing: 0.25rem }` for a fixed scale. */
322
- --spacing: clamp(0.225rem, 0.2136rem + 0.0455vi, 0.25rem);
326
+ /* the utility scale unit: `--p: 4` is 4 × --spacing. Fluid between its
327
+ min and max across the fluid range (--fluid comes from _typography.css);
328
+ set them equal, or pin `:root { --spacing: 0.25rem }`, for a fixed scale. */
329
+ --spacing-min: 0.225rem;
330
+ --spacing-max: 0.25rem;
331
+ --spacing: calc(var(--spacing-min) + var(--fluid) * (var(--spacing-max) - var(--spacing-min)));
323
332
 
324
333
  /* named spacing scale — for CSS and component hooks. In style utilities write the
325
334
  number instead (`--gap: 6`, not `var(--space-md)`). */
@@ -1 +1 @@
1
- {"version":3,"file":"dialog-lifecycle.d.ts","sourceRoot":"","sources":["dialog-lifecycle.ts"],"names":[],"mappings":"AAqCA;;;;;GAKG;AACH,iBAAS,qBAAqB,IAAI,OAAO,CAOxC;AAED;;;;;;;;GAQG;AACH,iBAAS,WAAW,CAAC,KAAK,EAAE,KAAK,GAAG,iBAAiB,GAAG,IAAI,CAQ3D;AAmCD,UAAU,qBAAqB;IAC7B,IAAI,IAAI,CAAC;IACT,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED;;;GAGG;AACH,QAAA,MAAM,mBAAmB,EAAE,qBAgC1B,CAAC;AAYF,OAAO,EAAE,WAAW,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,CAAC"}
1
+ {"version":3,"file":"dialog-lifecycle.d.ts","sourceRoot":"","sources":["dialog-lifecycle.ts"],"names":[],"mappings":"AAqCA;;;;;GAKG;AACH,iBAAS,qBAAqB,IAAI,OAAO,CAOxC;AAED;;;;;;;;GAQG;AACH,iBAAS,WAAW,CAAC,KAAK,EAAE,KAAK,GAAG,iBAAiB,GAAG,IAAI,CAQ3D;AAmCD,UAAU,qBAAqB;IAC7B,IAAI,IAAI,CAAC;IACT,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED;;;GAGG;AACH,QAAA,MAAM,mBAAmB,EAAE,qBAmC1B,CAAC;AAYF,OAAO,EAAE,WAAW,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,CAAC"}
@@ -110,7 +110,10 @@ const initDialogLifecycle = function () {
110
110
  }
111
111
  }
112
112
  });
113
- observer.observe(document.body, {
113
+ // The root, not <body>: swap navigation (base/navigation.ts) replaces the
114
+ // whole <body>, and an observer on the old one would watch nothing after
115
+ // the first in-site navigation. <html> stays put for the page's lifetime.
116
+ observer.observe(document.documentElement, {
114
117
  attributes: true,
115
118
  attributeFilter: ["open"],
116
119
  subtree: true,
@@ -127,7 +127,10 @@ const initDialogLifecycle: InitDialogLifecycleFn = function () {
127
127
  }
128
128
  }
129
129
  });
130
- observer.observe(document.body, {
130
+ // The root, not <body>: swap navigation (base/navigation.ts) replaces the
131
+ // whole <body>, and an observer on the old one would watch nothing after
132
+ // the first in-site navigation. <html> stays put for the page's lifetime.
133
+ observer.observe(document.documentElement, {
131
134
  attributes: true,
132
135
  attributeFilter: ["open"],
133
136
  subtree: true,
@@ -404,12 +404,9 @@
404
404
 
405
405
  :where([data-ui~="badge"][data-badge-variant="ghost"]) {
406
406
  --_badge-bg: transparent;
407
- /* the muted variant's opaque surface */
408
- --_badge-bg--hover: light-dark(
409
- color-mix(in srgb, var(--color-foreground) 5%, var(--color-background)),
410
- color-mix(in srgb, var(--color-foreground) 10%, var(--color-background))
411
- );
412
- --_badge-bg--active: oklch(from var(--_badge-bg--hover) calc(l - 0.025) c h);
407
+ /* the translucent muted role: shows the surface beneath and follows a retheme */
408
+ --_badge-bg--hover: var(--color-muted);
409
+ --_badge-bg--active: oklch(from var(--_badge-bg--hover) l c h / calc(alpha * 1.5));
413
410
 
414
411
  --_badge-text: var(--color-foreground);
415
412
  --_badge-text--hover: var(--color-foreground);
@@ -432,12 +432,9 @@
432
432
 
433
433
  :where([data-ui~="button"][data-button-variant="ghost"]) {
434
434
  --_button-bg: transparent;
435
- /* the muted variant's opaque surface */
436
- --_button-bg--hover: light-dark(
437
- color-mix(in srgb, var(--color-foreground) 5%, var(--color-background)),
438
- color-mix(in srgb, var(--color-foreground) 10%, var(--color-background))
439
- );
440
- --_button-bg--active: oklch(from var(--_button-bg--hover) calc(l - 0.025) c h);
435
+ /* the translucent muted role: shows the surface beneath and follows a retheme */
436
+ --_button-bg--hover: var(--color-muted);
437
+ --_button-bg--active: oklch(from var(--_button-bg--hover) l c h / calc(alpha * 1.5));
441
438
 
442
439
  --_button-text: var(--color-foreground);
443
440
  --_button-text--hover: var(--color-foreground);
@@ -16,7 +16,7 @@
16
16
  /* surface + border follow --ui-field-* */
17
17
  --ui-checkbox-size: calc(var(--spacing) * 4.5);
18
18
  --ui-checkbox-bg: var(--ui-field-bg);
19
- --ui-checkbox-foreground: var(--color-primary-foreground);
19
+ --ui-checkbox-glyph-color: var(--color-primary-foreground);
20
20
  --ui-checkbox-border-width: var(--ui-field-border-width);
21
21
  --ui-checkbox-border-style: var(--ui-field-border-style);
22
22
  --ui-checkbox-border-color: var(--ui-field-border-color);
@@ -103,7 +103,7 @@
103
103
  ) {
104
104
  background-color: var(--_bg-resolved, var(--ui-checkbox-bg--checked));
105
105
  border-color: var(--_border-color-resolved, var(--ui-checkbox-border-color--checked));
106
- color: var(--ui-checkbox-foreground);
106
+ color: var(--ui-checkbox-glyph-color);
107
107
  }
108
108
 
109
109
  /* The glyph is a masked ::before painted in currentColor (pseudo-elements
@@ -29,6 +29,11 @@
29
29
  * this control is inert without its script (the hidden input still submits a
30
30
  * server-set value, but no tags render).
31
31
  *
32
+ * Scripts read and set the selection through the element's `value` property,
33
+ * which mirrors `<select>.value`: setting it moves the selection, the label,
34
+ * and the hidden input without focusing the input or dispatching `change`; an
35
+ * unknown value clears the selection.
36
+ *
32
37
  * Attributes on the root: `data-combobox-variant="multiselect"`, `data-combobox-sort="score"`,
33
38
  * `data-combobox-filter="none"` (another source filters; the engine only navigates),
34
39
  * `data-combobox-min-length="<n>"`, `data-combobox-label-remove="Remove {label}"`.
@@ -95,6 +100,24 @@ declare class UiCombobox extends TypeaheadElement {
95
100
  * @param item - The committed option.
96
101
  */
97
102
  protected commit(item: HTMLElement, _source: "keyboard" | "pointer"): void;
103
+ /**
104
+ * @description The selected item's form value (`data-combobox-value`, or its
105
+ * label), like `<select>.value`; the empty string when nothing is selected.
106
+ * In the multiselect variant it is the first selected value.
107
+ *
108
+ * @returns The committed form value.
109
+ */
110
+ get value(): string;
111
+ /**
112
+ * @description Selects the item carrying this form value, as a script sets
113
+ * `<select>.value`: the label, the hidden input, and `aria-selected` follow,
114
+ * but no `change` is dispatched and focus stays where it was. A value no
115
+ * row carries clears the selection; in the multiselect variant the value
116
+ * becomes the whole selection, as `<select multiple>.value` does.
117
+ *
118
+ * @param value - The form value to select.
119
+ */
120
+ set value(value: string);
98
121
  }
99
122
  export { UiCombobox, resolveBlur, resolveRemoveLabel };
100
123
  export type { BlurOutcome };
@@ -1 +1 @@
1
- {"version":3,"file":"combobox.d.ts","sourceRoot":"","sources":["combobox.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AA0B3D,2EAA2E;AAC3E,UAAU,WAAW;IACnB,oDAAoD;IACpD,KAAK,EAAE,MAAM,CAAC;IACd,kDAAkD;IAClD,KAAK,EAAE,OAAO,CAAC;CAChB;AAED;;;;;;;;;;GAUG;AACH,iBAAS,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,GAAG,WAAW,CAI7F;AAED;;;;;;GAMG;AACH,iBAAS,kBAAkB,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAEnE;AAED,cAAM,UAAW,SAAQ,gBAAgB;;IACvC,SAAS,CAAC,QAAQ,CAAC,UAAU,cAAc;IAC3C,gFAAgF;IAChF,SAAS,CAAC,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAS;IAOhD,SAAS,CAAC,KAAK,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI,CAgIzC;IAED,SAAS,CAAC,QAAQ,IAAI,IAAI,CAOzB;IAED;;;;;;OAMG;IACH,SAAS,CAAC,SAAS,CAAC,IAAI,EAAE,WAAW,GAAG,MAAM,CAE7C;IAED;;;;OAIG;IACH,SAAS,CAAC,UAAU,IAAI,IAAI,CAK3B;IAED;;;;;;OAMG;IACH,SAAS,CAAC,MAAM,CAAC,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,UAAU,GAAG,SAAS,GAAG,IAAI,CA+BzE;CAuOF;AAID,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,kBAAkB,EAAE,CAAC;AACvD,YAAY,EAAE,WAAW,EAAE,CAAC"}
1
+ {"version":3,"file":"combobox.d.ts","sourceRoot":"","sources":["combobox.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AA0B3D,2EAA2E;AAC3E,UAAU,WAAW;IACnB,oDAAoD;IACpD,KAAK,EAAE,MAAM,CAAC;IACd,kDAAkD;IAClD,KAAK,EAAE,OAAO,CAAC;CAChB;AAED;;;;;;;;;;GAUG;AACH,iBAAS,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,GAAG,WAAW,CAI7F;AAED;;;;;;GAMG;AACH,iBAAS,kBAAkB,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAEnE;AAED,cAAM,UAAW,SAAQ,gBAAgB;;IACvC,SAAS,CAAC,QAAQ,CAAC,UAAU,cAAc;IAC3C,gFAAgF;IAChF,SAAS,CAAC,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAS;IAOhD,SAAS,CAAC,KAAK,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI,CAgIzC;IAED,SAAS,CAAC,QAAQ,IAAI,IAAI,CAOzB;IAED;;;;;;OAMG;IACH,SAAS,CAAC,SAAS,CAAC,IAAI,EAAE,WAAW,GAAG,MAAM,CAE7C;IAED;;;;OAIG;IACH,SAAS,CAAC,UAAU,IAAI,IAAI,CAK3B;IAED;;;;;;OAMG;IACH,SAAS,CAAC,MAAM,CAAC,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,UAAU,GAAG,SAAS,GAAG,IAAI,CA+BzE;IAwND;;;;;;OAMG;IACH,IAAI,KAAK,IAAI,MAAM,CAGlB;IAED;;;;;;;;OAQG;IACH,IAAI,KAAK,CAAC,KAAK,EAAE,MAAM,EAiBtB;CAqBF;AAID,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,kBAAkB,EAAE,CAAC;AACvD,YAAY,EAAE,WAAW,EAAE,CAAC"}
@@ -30,6 +30,11 @@
30
30
  * this control is inert without its script (the hidden input still submits a
31
31
  * server-set value, but no tags render).
32
32
  *
33
+ * Scripts read and set the selection through the element's `value` property,
34
+ * which mirrors `<select>.value`: setting it moves the selection, the label,
35
+ * and the hidden input without focusing the input or dispatching `change`; an
36
+ * unknown value clears the selection.
37
+ *
33
38
  * Attributes on the root: `data-combobox-variant="multiselect"`, `data-combobox-sort="score"`,
34
39
  * `data-combobox-filter="none"` (another source filters; the engine only navigates),
35
40
  * `data-combobox-min-length="<n>"`, `data-combobox-label-remove="Remove {label}"`.
@@ -457,9 +462,11 @@ class UiCombobox extends TypeaheadElement {
457
462
  /**
458
463
  * @description Empties the committed state: label, hidden value, tags, and
459
464
  * `aria-selected` all clear together.
465
+ *
466
+ * @param notify - Whether to dispatch `change` (a script setting `value` stays silent).
460
467
  * @private
461
468
  */
462
- #clearSelection() {
469
+ #clearSelection(notify = true) {
463
470
  this.#committedLabel = "";
464
471
  const multiselect = this.#multiselect();
465
472
  for (const item of this.items()) {
@@ -468,7 +475,51 @@ class UiCombobox extends TypeaheadElement {
468
475
  else
469
476
  item.removeAttribute("aria-selected");
470
477
  }
471
- this.#syncSelection(true);
478
+ if (this.searchInput)
479
+ this.searchInput.value = "";
480
+ this.query.set("");
481
+ this.#syncSelection(notify);
482
+ }
483
+ /**
484
+ * @description The selected item's form value (`data-combobox-value`, or its
485
+ * label), like `<select>.value`; the empty string when nothing is selected.
486
+ * In the multiselect variant it is the first selected value.
487
+ *
488
+ * @returns The committed form value.
489
+ */
490
+ get value() {
491
+ const selected = this.#selectedItems()[0];
492
+ return selected ? this.#itemFormValue(selected) : "";
493
+ }
494
+ /**
495
+ * @description Selects the item carrying this form value, as a script sets
496
+ * `<select>.value`: the label, the hidden input, and `aria-selected` follow,
497
+ * but no `change` is dispatched and focus stays where it was. A value no
498
+ * row carries clears the selection; in the multiselect variant the value
499
+ * becomes the whole selection, as `<select multiple>.value` does.
500
+ *
501
+ * @param value - The form value to select.
502
+ */
503
+ set value(value) {
504
+ const match = this.items().find((item) => this.#itemFormValue(item) === value);
505
+ if (!match) {
506
+ this.#clearSelection(false);
507
+ return;
508
+ }
509
+ const multiselect = this.#multiselect();
510
+ for (const other of this.items()) {
511
+ if (multiselect)
512
+ other.setAttribute("aria-selected", "false");
513
+ else
514
+ other.removeAttribute("aria-selected");
515
+ }
516
+ match.setAttribute("aria-selected", "true");
517
+ this.#committedLabel = multiselect ? "" : this.itemValue(match);
518
+ const input = this.searchInput;
519
+ if (input)
520
+ input.value = this.#committedLabel;
521
+ this.query.set("");
522
+ this.#syncSelection(false);
472
523
  }
473
524
  /**
474
525
  * @description Restores the selection the markup shipped with (form reset).