use-scroll-animate 2.4.0 → 2.6.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.
Files changed (55) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/README.md +2 -0
  3. package/README_ja.md +2 -0
  4. package/README_zh.md +2 -0
  5. package/dist/chunks/{base-CuvCgqLy.js → base-08OYzphB.js} +2 -2
  6. package/dist/chunks/{base-CuvCgqLy.js.map → base-08OYzphB.js.map} +1 -1
  7. package/dist/chunks/{base-CJ7XfidP.cjs → base-5DFCAnvH.cjs} +3 -1
  8. package/dist/chunks/{base-CJ7XfidP.cjs.map → base-5DFCAnvH.cjs.map} +1 -1
  9. package/dist/chunks/{spring-CGO9Jd9b.cjs → spring-Bi4qY0pL.cjs} +2 -2
  10. package/dist/chunks/{spring-CGO9Jd9b.cjs.map → spring-Bi4qY0pL.cjs.map} +1 -1
  11. package/dist/chunks/{spring-BKUU7-Xm.js → spring-CpeFkxNd.js} +2 -2
  12. package/dist/chunks/{spring-BKUU7-Xm.js.map → spring-CpeFkxNd.js.map} +1 -1
  13. package/dist/components/background.cjs +1 -1
  14. package/dist/components/background.js +2 -2
  15. package/dist/components/cards.cjs +2 -2
  16. package/dist/components/cards.js +3 -3
  17. package/dist/components/click.cjs +985 -0
  18. package/dist/components/click.cjs.map +1 -0
  19. package/dist/components/click.css +9 -0
  20. package/dist/components/click.d.cts +250 -0
  21. package/dist/components/click.d.ts +250 -0
  22. package/dist/components/click.js +967 -0
  23. package/dist/components/click.js.map +1 -0
  24. package/dist/components/feedback.cjs +2 -2
  25. package/dist/components/feedback.css +1 -1
  26. package/dist/components/feedback.js +3 -3
  27. package/dist/components/interaction.cjs +2 -2
  28. package/dist/components/interaction.css +1 -1
  29. package/dist/components/interaction.js +3 -3
  30. package/dist/components/physics.cjs +2 -2
  31. package/dist/components/physics.js +4 -4
  32. package/dist/components/reveal.cjs +1 -1
  33. package/dist/components/reveal.js +2 -2
  34. package/dist/components/text.cjs +1 -1
  35. package/dist/components/text.js +2 -2
  36. package/dist/components/transitions.cjs +1 -1
  37. package/dist/components/transitions.js +2 -2
  38. package/dist/components/ui.cjs +1082 -0
  39. package/dist/components/ui.cjs.map +1 -0
  40. package/dist/components/ui.css +14 -0
  41. package/dist/components/ui.d.cts +251 -0
  42. package/dist/components/ui.d.ts +251 -0
  43. package/dist/components/ui.js +1064 -0
  44. package/dist/components/ui.js.map +1 -0
  45. package/dist/components.cjs +44 -4
  46. package/dist/components.cjs.map +1 -1
  47. package/dist/components.css +21 -2
  48. package/dist/components.d.cts +427 -2
  49. package/dist/components.d.ts +427 -2
  50. package/dist/components.js +14 -3
  51. package/dist/components.js.map +1 -1
  52. package/dist/components.umd.js +2 -2
  53. package/dist/components.umd.js.map +1 -1
  54. package/docs/components.md +33 -0
  55. package/package.json +24 -2
@@ -0,0 +1,1082 @@
1
+ 'use strict';
2
+
3
+ var base = require('../chunks/base-5DFCAnvH.cjs');
4
+ var spring = require('../chunks/spring-Bi4qY0pL.cjs');
5
+
6
+ var css$b = ":root{--usa-accent:#7c5cff;--usa-accent-text:#fff;--usa-surface:#1b1e27;--usa-text:inherit;--usa-radius:14px;--usa-border:1px solid rgb(127 127 127 / 0.25);--usa-shadow:0 10px 30px -12px rgb(0 0 0 / 0.45);--usa-blur:0px;--usa-font:inherit}:where([variant=\"minimal\"],[data-usa-variant=\"minimal\"]){--usa-accent:currentColor;--usa-accent-text:Canvas;--usa-surface:transparent;--usa-radius:6px;--usa-border:1px solid color-mix(in srgb,currentColor 22%,transparent);--usa-shadow:none;--usa-blur:0px}:where([variant=\"neon\"],[data-usa-variant=\"neon\"]){--usa-accent:#00f0ff;--usa-accent-text:#04121a;--usa-surface:#0a0b14;--usa-text:#e6fbff;--usa-radius:10px;--usa-border:1px solid #00f0ff;--usa-shadow:0 0 6px #00f0ff,0 0 22px rgb(0 240 255 / 0.45);--usa-blur:0px}:where([variant=\"glass\"],[data-usa-variant=\"glass\"]){--usa-accent:#a78bfa;--usa-accent-text:#fff;--usa-surface:rgb(255 255 255 / 0.12);--usa-radius:18px;--usa-border:1px solid rgb(255 255 255 / 0.28);--usa-shadow:0 12px 40px -12px rgb(0 0 0 / 0.35);--usa-blur:16px}:where([variant=\"brutalist\"],[data-usa-variant=\"brutalist\"]){--usa-accent:#ff3d00;--usa-accent-text:#000;--usa-surface:#fff;--usa-text:#000;--usa-radius:0px;--usa-border:3px solid #000;--usa-shadow:5px 5px 0 #000;--usa-blur:0px;--usa-font:ui-monospace,\"SFMono-Regular\",Menlo,monospace}:where([variant=\"fluent\"],[data-usa-variant=\"fluent\"]){--usa-accent:#0067c0;--usa-accent-text:#fff;--usa-surface:rgb(249 249 249 / 0.82);--usa-text:#1a1a1a;--usa-radius:8px;--usa-border:1px solid rgb(0 0 0 / 0.08);--usa-shadow:0 2px 4px rgb(0 0 0 / 0.14),0 0 2px rgb(0 0 0 / 0.12);--usa-blur:30px;--usa-font:\"Segoe UI Variable\",\"Segoe UI\",system-ui,sans-serif}:where([variant=\"material\"],[data-usa-variant=\"material\"]){--usa-accent:#6750a4;--usa-accent-text:#fff;--usa-surface:#fffbfe;--usa-text:#1c1b1f;--usa-radius:20px;--usa-border:0 solid transparent;--usa-shadow:0 1px 3px rgb(0 0 0 / 0.3),0 4px 8px 3px rgb(0 0 0 / 0.15);--usa-blur:0px;--usa-font:Roboto,system-ui,sans-serif}@media (prefers-color-scheme:dark){:where([variant=\"fluent\"],[data-usa-variant=\"fluent\"]){--usa-accent:#4cc2ff;--usa-accent-text:#000;--usa-surface:rgb(44 44 44 / 0.8);--usa-text:#fff;--usa-border:1px solid rgb(255 255 255 / 0.08)}:where([variant=\"material\"],[data-usa-variant=\"material\"]){--usa-accent:#d0bcff;--usa-accent-text:#381e72;--usa-surface:#1c1b1f;--usa-text:#e6e1e5}}.usa-surface{background:var(--usa-surface);color:var(--usa-text);border:var(--usa-border);border-radius:var(--usa-radius);box-shadow:var(--usa-shadow);font-family:var(--usa-font);-webkit-backdrop-filter:blur(var(--usa-blur));backdrop-filter:blur(var(--usa-blur))}@media (prefers-reduced-transparency:reduce){.usa-surface{-webkit-backdrop-filter:none;backdrop-filter:none}}";
7
+
8
+ /**
9
+ * Style variants (v2.6): `variant="minimal | neon | glass | brutalist |
10
+ * fluent | material"` on any `<usa-*>` element — or on any ancestor as
11
+ * `data-usa-variant`, or page-wide with `setVariant()` — sets the shared
12
+ * design tokens every component reads:
13
+ *
14
+ * `--usa-accent`, `--usa-accent-text`, `--usa-surface`, `--usa-text`,
15
+ * `--usa-radius`, `--usa-border`, `--usa-shadow`, `--usa-blur`, `--usa-font`.
16
+ *
17
+ * (`<usa-spinner>`, `<usa-check>` and `<usa-dialog>` already use `variant`
18
+ * for their kind; the token names never clash with those values except
19
+ * `fluent`, which means the same thing there.)
20
+ */
21
+ const VARIANTS = ['minimal', 'neon', 'glass', 'brutalist', 'fluent', 'material'];
22
+ /** Inject the variant token sheet (done automatically by every `ui` component). */
23
+ function adoptVariants() {
24
+ base.adoptStyles('variants', css$b);
25
+ }
26
+ /** Apply a variant to the whole page (or `root`); `null` removes it. */
27
+ function setVariant(variant, root = typeof document !== 'undefined' ? document.documentElement : null) {
28
+ if (!root)
29
+ return;
30
+ adoptVariants();
31
+ if (variant)
32
+ root.setAttribute('data-usa-variant', variant);
33
+ else
34
+ root.removeAttribute('data-usa-variant');
35
+ }
36
+
37
+ /** Position a fixed `floating` element next to `anchor`, flipping when it would leave the viewport. */
38
+ function place(floating, anchor, placement = 'top', gap = 8) {
39
+ const a = anchor.getBoundingClientRect();
40
+ const f = floating.getBoundingClientRect();
41
+ const W = window.innerWidth || 1024;
42
+ const H = window.innerHeight || 768;
43
+ const fits = {
44
+ top: a.top - f.height - gap >= 0,
45
+ bottom: a.bottom + f.height + gap <= H,
46
+ left: a.left - f.width - gap >= 0,
47
+ right: a.right + f.width + gap <= W,
48
+ };
49
+ const opposite = { top: 'bottom', bottom: 'top', left: 'right', right: 'left' };
50
+ const p = fits[placement] || !fits[opposite[placement]] ? placement : opposite[placement];
51
+ let x = 0;
52
+ let y = 0;
53
+ if (p === 'top' || p === 'bottom') {
54
+ x = Math.min(Math.max(4, a.left + a.width / 2 - f.width / 2), W - f.width - 4);
55
+ y = p === 'top' ? a.top - f.height - gap : a.bottom + gap;
56
+ }
57
+ else {
58
+ y = Math.min(Math.max(4, a.top + a.height / 2 - f.height / 2), H - f.height - 4);
59
+ x = p === 'left' ? a.left - f.width - gap : a.right + gap;
60
+ }
61
+ floating.style.left = `${Math.round(x)}px`;
62
+ floating.style.top = `${Math.round(y)}px`;
63
+ floating.setAttribute('data-placement', p);
64
+ return p;
65
+ }
66
+ let uid = 0;
67
+ const nextId = (prefix) => `${prefix}-${++uid}`;
68
+
69
+ var css$a = "usa-tabs{display:block;font-family:var(--usa-font)}usa-tabs .usa-tabs-list{position:relative;display:flex;gap:4px;border-bottom:1px solid color-mix(in srgb,currentColor 14%,transparent)}usa-tabs [role=\"tab\"]{position:relative;z-index:1;padding:10px 14px;border:0;background:none;color:inherit;font:inherit;cursor:pointer;opacity:0.7;transition:opacity 0.2s ease,color 0.2s ease;border-radius:calc(var(--usa-radius,14px) / 2)}usa-tabs [role=\"tab\"][aria-selected=\"true\"]{opacity:1;color:var(--usa-accent,#7c5cff)}usa-tabs [role=\"tab\"]:focus-visible{outline:2px solid var(--usa-accent,#7c5cff);outline-offset:-2px}usa-tabs .usa-tabs-indicator{position:absolute;left:0;bottom:-1px;height:3px;width:0;border-radius:3px;background:var(--usa-accent,#7c5cff);pointer-events:none}usa-tabs[indicator=\"pill\"] .usa-tabs-list{border-bottom:0;padding:4px;border-radius:999px;background:color-mix(in srgb,currentColor 8%,transparent)}usa-tabs[indicator=\"pill\"] .usa-tabs-indicator{top:4px;bottom:4px;height:auto;border-radius:999px;opacity:0.18}usa-tabs [role=\"tabpanel\"]{padding:14px 2px}usa-tabs [role=\"tabpanel\"]:focus-visible{outline:2px solid var(--usa-accent,#7c5cff);outline-offset:2px;border-radius:6px}";
70
+
71
+ function defineTabs(tag = 'usa-tabs') {
72
+ adoptVariants();
73
+ return base.defineElement(tag, (Base) => class UsaTabs extends Base {
74
+ constructor() {
75
+ super(...arguments);
76
+ this._i = 0;
77
+ this._bar = null;
78
+ }
79
+ static get observedAttributes() {
80
+ return ['indicator'];
81
+ }
82
+ get selected() {
83
+ return this._i;
84
+ }
85
+ set selected(v) {
86
+ this.select(v);
87
+ }
88
+ tabs() {
89
+ return Array.from(this.querySelectorAll('[data-tab]')).filter((t) => t.closest(this.localName) === this);
90
+ }
91
+ panels() {
92
+ return Array.from(this.querySelectorAll('[data-panel]')).filter((t) => t.closest(this.localName) === this);
93
+ }
94
+ mount() {
95
+ const tabs = this.tabs();
96
+ const panels = this.panels();
97
+ const list = tabs[0]?.parentElement;
98
+ if (!list)
99
+ return;
100
+ list.setAttribute('role', 'tablist');
101
+ list.classList.add('usa-tabs-list');
102
+ if (!list.querySelector(':scope > .usa-tabs-indicator')) {
103
+ this._bar = document.createElement('span');
104
+ this._bar.className = 'usa-tabs-indicator';
105
+ this._bar.setAttribute('aria-hidden', 'true');
106
+ list.append(this._bar);
107
+ }
108
+ else
109
+ this._bar = list.querySelector(':scope > .usa-tabs-indicator');
110
+ tabs.forEach((t, i) => {
111
+ t.id || (t.id = nextId('usa-tab'));
112
+ t.setAttribute('role', 'tab');
113
+ const p = panels[i];
114
+ if (p) {
115
+ p.id || (p.id = nextId('usa-panel'));
116
+ p.setAttribute('role', 'tabpanel');
117
+ p.setAttribute('aria-labelledby', t.id);
118
+ t.setAttribute('aria-controls', p.id);
119
+ if (!p.hasAttribute('tabindex'))
120
+ p.tabIndex = 0;
121
+ }
122
+ this.listen(t, 'click', () => this.select(i));
123
+ });
124
+ this.listen(list, 'keydown', (e) => {
125
+ const n = tabs.length;
126
+ const map = { ArrowRight: this._i + 1, ArrowDown: this._i + 1, ArrowLeft: this._i - 1, ArrowUp: this._i - 1, Home: 0, End: n - 1 };
127
+ if (!(e.key in map))
128
+ return;
129
+ e.preventDefault();
130
+ this.select((map[e.key] + n) % n, true);
131
+ });
132
+ const ro = typeof ResizeObserver !== 'undefined' ? new ResizeObserver(() => this.moveBar(false)) : null;
133
+ ro?.observe(list);
134
+ this.onCleanup(() => ro?.disconnect());
135
+ this.select(Math.max(0, Math.min(tabs.length - 1, this.num('selected', 0))), false, true);
136
+ }
137
+ moveBar(animate) {
138
+ const t = this.tabs()[this._i];
139
+ const bar = this._bar;
140
+ if (!t || !bar)
141
+ return;
142
+ const from = bar.style.transform;
143
+ const fromW = bar.style.width;
144
+ bar.style.width = `${t.offsetWidth}px`;
145
+ bar.style.transform = `translateX(${t.offsetLeft}px)`;
146
+ if (animate && from && !this.reduced)
147
+ this.motion(bar, [{ transform: from, width: fromW }, { transform: bar.style.transform, width: bar.style.width }], spring.springEasing('stiff'));
148
+ }
149
+ select(i, focus = false, initial = false) {
150
+ const tabs = this.tabs();
151
+ const panels = this.panels();
152
+ if (!tabs[i])
153
+ return;
154
+ const prev = this._i;
155
+ this._i = i;
156
+ this.setAttribute('selected', String(i));
157
+ tabs.forEach((t, j) => {
158
+ t.setAttribute('aria-selected', String(j === i));
159
+ t.tabIndex = j === i ? 0 : -1;
160
+ });
161
+ panels.forEach((p, j) => (p.hidden = j !== i));
162
+ if (focus)
163
+ tabs[i].focus();
164
+ this.moveBar(!initial);
165
+ if (initial || prev === i)
166
+ return;
167
+ const p = panels[i];
168
+ if (p && !this.reduced)
169
+ this.motion(p, [{ opacity: 0, transform: `translateX(${i > prev ? 16 : -16}px)` }, { opacity: 1, transform: 'none' }], { duration: 280, easing: 'cubic-bezier(0.22, 1, 0.36, 1)' });
170
+ this.emit('change', { index: i });
171
+ }
172
+ }, { id: 'tabs', text: css$a });
173
+ }
174
+
175
+ var css$9 = "usa-drawer,usa-bottom-sheet{position:fixed;z-index:1001;box-sizing:border-box;overflow:auto;overscroll-behavior:contain;touch-action:pan-y;will-change:transform;outline:none}usa-drawer{top:0;bottom:0;left:0;width:min(86vw,360px);border-radius:0 var(--usa-radius,14px) var(--usa-radius,14px) 0;padding:20px}usa-drawer[side=\"right\"]{left:auto;right:0;border-radius:var(--usa-radius,14px) 0 0 var(--usa-radius,14px)}usa-drawer[side=\"top\"],usa-drawer[side=\"bottom\"]{left:0;right:0;width:auto;bottom:auto;max-height:80vh;border-radius:0 0 var(--usa-radius,14px) var(--usa-radius,14px);touch-action:pan-x}usa-drawer[side=\"bottom\"]{top:auto;bottom:0;border-radius:var(--usa-radius,14px) var(--usa-radius,14px) 0 0}usa-bottom-sheet{left:0;right:0;bottom:0;margin:0 auto;max-width:640px;border-radius:22px 22px 0 0;padding:8px 20px 24px;touch-action:none}usa-bottom-sheet .usa-sheet-handle{width:40px;height:5px;border-radius:3px;margin:4px auto 14px;background:color-mix(in srgb,currentColor 35%,transparent);cursor:grab}usa-drawer[hidden],usa-bottom-sheet[hidden]{display:none}.usa-panel-backdrop{position:fixed;inset:0;z-index:1000;background:rgb(0 0 0 / 0.45)}";
176
+
177
+ /** Shared machinery of `<usa-drawer>` and `<usa-bottom-sheet>`: backdrop, focus, Esc, drag-to-dismiss. */
178
+ function makePanel(Base, kind) {
179
+ return class UsaPanel extends Base {
180
+ constructor() {
181
+ super(...arguments);
182
+ this._backdrop = null;
183
+ this._return = null;
184
+ this._drag = null;
185
+ }
186
+ static get observedAttributes() {
187
+ return ['open', 'side'];
188
+ }
189
+ get open() {
190
+ return this.flag('open');
191
+ }
192
+ set open(v) {
193
+ this.setFlag('open', v);
194
+ }
195
+ /** Main axis size of the panel (px). */
196
+ size() {
197
+ const r = this.getBoundingClientRect();
198
+ return (kind === 'sheet' || this.vertical() ? r.height : r.width) || (kind === 'sheet' ? window.innerHeight * 0.9 : 320);
199
+ }
200
+ vertical() {
201
+ return kind === 'sheet' || this.str('side') === 'top' || this.str('side') === 'bottom';
202
+ }
203
+ /** +1 when hiding moves the panel in the positive axis direction. */
204
+ dir() {
205
+ const side = kind === 'sheet' ? 'bottom' : this.str('side', 'left');
206
+ return side === 'left' || side === 'top' ? -1 : 1;
207
+ }
208
+ /** Offsets (px from fully open) the panel may rest at; the largest closes it. */
209
+ stops() {
210
+ return [0];
211
+ }
212
+ render(v) {
213
+ const axis = this.vertical() ? 'Y' : 'X';
214
+ this.style.transform = `translate${axis}(${(v * this.dir()).toFixed(1)}px)`;
215
+ if (this._backdrop)
216
+ this._backdrop.style.opacity = String(base.clamp(1 - v / (this.size() || 1), 0, 1));
217
+ }
218
+ mount() {
219
+ this.setAttribute('role', 'dialog');
220
+ if (this.str('label'))
221
+ this.setAttribute('aria-label', this.str('label'));
222
+ if (!this.hasAttribute('tabindex'))
223
+ this.tabIndex = -1;
224
+ this.classList.add('usa-surface');
225
+ this._pos = spring.createSpring({ value: this.size() * 2, spring: 'stiff', onUpdate: (v) => this.render(v), onRest: (v) => v >= this.size() - 1 && !this.open && this.afterClose() });
226
+ if (this.open)
227
+ this.show(false);
228
+ else {
229
+ this.hidden = true;
230
+ this._pos.jump(this.size() * 1.2);
231
+ }
232
+ this.listen(document, 'keydown', (e) => e.key === 'Escape' && this.open && this.close());
233
+ this.listen(this, 'click', (e) => e.target.closest?.('[data-close]') && this.close());
234
+ this.listen(this, 'pointerdown', (e) => this.dragStart(e));
235
+ this.listen(this, 'pointermove', (e) => this.dragMove(e));
236
+ this.listen(this, 'pointerup', (e) => this.dragEnd(e));
237
+ this.listen(this, 'pointercancel', (e) => this.dragEnd(e));
238
+ }
239
+ unmount() {
240
+ this._pos?.stop();
241
+ this._backdrop?.remove();
242
+ this._backdrop = null;
243
+ }
244
+ changed(name) {
245
+ if (name !== 'open')
246
+ return super.changed(name);
247
+ if (this.open && this.hidden)
248
+ this.show(true);
249
+ else if (!this.open && !this.hidden)
250
+ this.hide();
251
+ }
252
+ show(animate = true) {
253
+ this._return = document.activeElement;
254
+ this.hidden = false;
255
+ this.setAttribute('aria-modal', 'true');
256
+ if (!this._backdrop) {
257
+ this._backdrop = document.createElement('div');
258
+ this._backdrop.className = 'usa-panel-backdrop';
259
+ this._backdrop.addEventListener('click', () => this.close());
260
+ this.before(this._backdrop);
261
+ }
262
+ const target = this.stops()[this.initialStop()];
263
+ if (!animate)
264
+ this._pos.jump(target);
265
+ else {
266
+ this._pos.jump(this.size());
267
+ this._pos.set(target);
268
+ }
269
+ this.setFlag('open', true);
270
+ this.focus({ preventScroll: true });
271
+ this.emit('open');
272
+ }
273
+ initialStop() {
274
+ return 0;
275
+ }
276
+ hide() {
277
+ this._pos.set(this.size() * 1.05);
278
+ this.emit('close');
279
+ }
280
+ afterClose() {
281
+ this.hidden = true;
282
+ this._backdrop?.remove();
283
+ this._backdrop = null;
284
+ if (this._return instanceof HTMLElement)
285
+ this._return.focus({ preventScroll: true });
286
+ }
287
+ close() {
288
+ this.setFlag('open', false);
289
+ }
290
+ dragStart(e) {
291
+ const handle = kind === 'sheet' ? e.target.closest?.('[data-handle], .usa-sheet-handle') || (this.scrollTop <= 0 ? this : null) : this;
292
+ if (!handle || e.target.closest?.('input, textarea, select, button, a, [data-no-drag]'))
293
+ return;
294
+ const p = this.vertical() ? e.clientY : e.clientX;
295
+ this._pos.stop();
296
+ this._drag = { id: e.pointerId, start: p, origin: this._pos.value, t: e.timeStamp, last: p, lt: e.timeStamp };
297
+ }
298
+ dragMove(e) {
299
+ const d = this._drag;
300
+ if (!d || e.pointerId !== d.id)
301
+ return;
302
+ const p = this.vertical() ? e.clientY : e.clientX;
303
+ let v = d.origin + (p - d.start) * this.dir();
304
+ if (v < 0)
305
+ v = spring.rubberBand(v, 200);
306
+ d.lt = d.t;
307
+ d.t = e.timeStamp;
308
+ d.last = p;
309
+ this._pos.jump(v);
310
+ }
311
+ dragEnd(e) {
312
+ const d = this._drag;
313
+ if (!d || e.pointerId !== d.id)
314
+ return;
315
+ this._drag = null;
316
+ const moved = this._pos.value - d.origin;
317
+ const dt = Math.max(16, d.t - d.lt) / 1000;
318
+ const vel = Math.abs(moved) > 4 ? (moved / Math.max(dt, (e.timeStamp - (d.lt || 0)) / 1000 || 0.1)) * 0.2 : 0;
319
+ const projected = spring.projectInertia(this._pos.value, base.clamp(vel, -3e3, 3000));
320
+ const stops = [...this.stops(), this.size()];
321
+ const to = spring.snapTo(projected, stops);
322
+ if (to >= this.size() - 1)
323
+ this.close();
324
+ else
325
+ this._pos.set(to);
326
+ this.emit('snap', { offset: to });
327
+ }
328
+ };
329
+ }
330
+ function defineDrawer(tag = 'usa-drawer') {
331
+ adoptVariants();
332
+ return base.defineElement(tag, (Base) => makePanel(Base, 'drawer'), { id: 'sheet', text: css$9 });
333
+ }
334
+ function defineBottomSheet(tag = 'usa-bottom-sheet') {
335
+ adoptVariants();
336
+ return base.defineElement(tag, (Base) => {
337
+ const Panel = makePanel(Base, 'sheet');
338
+ return class UsaBottomSheet extends Panel {
339
+ static get observedAttributes() {
340
+ return ['open', 'snap'];
341
+ }
342
+ mount() {
343
+ if (!this.querySelector(':scope > .usa-sheet-handle')) {
344
+ const h = document.createElement('div');
345
+ h.className = 'usa-sheet-handle';
346
+ h.setAttribute('aria-hidden', 'true');
347
+ this.prepend(h);
348
+ }
349
+ super.mount();
350
+ }
351
+ size() {
352
+ return (window.innerHeight || 800) * Math.max(...this.fractions());
353
+ }
354
+ fractions() {
355
+ const f = this.str('snap', '0.5,0.92').split(',').map(Number).filter((n) => n > 0 && n <= 1);
356
+ return f.length ? f : [0.5, 0.92];
357
+ }
358
+ stops() {
359
+ const full = this.size();
360
+ const H = window.innerHeight || 800;
361
+ return this.fractions().map((f) => Math.max(0, full - f * H)).sort((a, b) => a - b);
362
+ }
363
+ initialStop() {
364
+ const f = this.fractions();
365
+ const pick = f[base.clamp(this.num('start', 0), 0, f.length - 1)];
366
+ const target = Math.max(0, this.size() - pick * (window.innerHeight || 800));
367
+ const s = this.stops();
368
+ return Math.max(0, s.indexOf(target));
369
+ }
370
+ render(v) {
371
+ this.style.height = `${this.size()}px`;
372
+ super.render(v);
373
+ }
374
+ };
375
+ }, { id: 'sheet', text: css$9 });
376
+ }
377
+
378
+ var css$8 = "usa-pull-refresh{position:relative;display:block;overflow:auto;overscroll-behavior-y:contain;touch-action:pan-x pan-down}usa-pull-refresh>:not(.usa-pull-indicator):not(.usa-sr){transform:translateY(var(--usa-pull,0px))}usa-pull-refresh .usa-pull-indicator{position:absolute;left:50%;top:0;width:34px;height:34px;margin-left:-17px;z-index:2;display:grid;place-items:center;border-radius:50%;background:var(--usa-surface,#1b1e27);box-shadow:var(--usa-shadow);color:var(--usa-accent,#7c5cff);transform:translateY(calc(var(--usa-pull,0px) - 40px)) rotate(calc(var(--usa-pull-p,0) * 270deg));opacity:var(--usa-pull-p,0);pointer-events:none}usa-pull-refresh .usa-pull-indicator svg{width:20px;height:20px;fill:none;stroke:currentColor;stroke-width:3;stroke-linecap:round}usa-pull-refresh .usa-pull-indicator circle{stroke-dasharray:calc(var(--usa-pull-p,0) * 75) 100}usa-pull-refresh[data-armed] .usa-pull-indicator{background:var(--usa-accent,#7c5cff);color:var(--usa-accent-text,#fff)}usa-pull-refresh[data-refreshing] .usa-pull-indicator{opacity:1;animation:usa-pull-spin 0.8s linear infinite}usa-pull-refresh[data-refreshing] .usa-pull-indicator circle{stroke-dasharray:60 100}@keyframes usa-pull-spin{from{transform:translateY(calc(var(--usa-pull,0px) - 40px)) rotate(0)}to{transform:translateY(calc(var(--usa-pull,0px) - 40px)) rotate(360deg)}}@media (prefers-reduced-motion:reduce){usa-pull-refresh[data-refreshing] .usa-pull-indicator{animation-duration:2.4s;transform:translateY(8px)}}";
379
+
380
+ function definePullRefresh(tag = 'usa-pull-refresh') {
381
+ adoptVariants();
382
+ return base.defineElement(tag, (Base) => class UsaPullRefresh extends Base {
383
+ constructor() {
384
+ super(...arguments);
385
+ this._busy = false;
386
+ this._ind = null;
387
+ this._live = null;
388
+ }
389
+ get refreshing() {
390
+ return this._busy;
391
+ }
392
+ draw(v) {
393
+ const th = this.num('threshold', 70);
394
+ this.style.setProperty('--usa-pull', `${v.toFixed(1)}px`);
395
+ this.style.setProperty('--usa-pull-p', Math.min(1, v / th).toFixed(3));
396
+ this.toggleAttribute('data-armed', v >= th && !this._busy);
397
+ }
398
+ mount() {
399
+ if (!this.querySelector(':scope > .usa-pull-indicator')) {
400
+ this._ind = document.createElement('div');
401
+ this._ind.className = 'usa-pull-indicator';
402
+ this._ind.setAttribute('aria-hidden', 'true');
403
+ this._ind.innerHTML = '<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="9" pathLength="100"/></svg>';
404
+ this.prepend(this._ind);
405
+ this._live = document.createElement('span');
406
+ this._live.className = 'usa-sr';
407
+ this._live.setAttribute('role', 'status');
408
+ this.append(this._live);
409
+ }
410
+ this._y = spring.createSpring({ spring: 'stiff', onUpdate: (v) => this.draw(v) });
411
+ let start = null;
412
+ let id = -1;
413
+ this.listen(this, 'pointerdown', (e) => {
414
+ if (this.flag('disabled') || this._busy || this.scrollTop > 0)
415
+ return;
416
+ start = e.clientY;
417
+ id = e.pointerId;
418
+ });
419
+ this.listen(this, 'pointermove', (e) => {
420
+ if (start === null || e.pointerId !== id)
421
+ return;
422
+ const d = e.clientY - start;
423
+ if (d <= 0)
424
+ return;
425
+ this._y.jump(this.reduced ? 0 : spring.rubberBand(d, 220));
426
+ if (this.reduced && d > this.num('threshold', 70))
427
+ this.setAttribute('data-armed', '');
428
+ });
429
+ const end = (e) => {
430
+ if (start === null || e.pointerId !== id)
431
+ return;
432
+ const d = e.clientY - start;
433
+ start = null;
434
+ const armed = this.hasAttribute('data-armed') || (!this.reduced && this._y.value >= this.num('threshold', 70)) || (this.reduced && d > this.num('threshold', 70));
435
+ if (armed)
436
+ this.refresh();
437
+ else
438
+ this._y.set(0);
439
+ };
440
+ this.listen(this, 'pointerup', end);
441
+ this.listen(this, 'pointercancel', end);
442
+ }
443
+ unmount() {
444
+ this._y?.stop();
445
+ }
446
+ refresh() {
447
+ if (this._busy)
448
+ return Promise.resolve();
449
+ this._busy = true;
450
+ this.removeAttribute('data-armed');
451
+ this.setAttribute('data-refreshing', '');
452
+ this.setAttribute('aria-busy', 'true');
453
+ if (this._live)
454
+ this._live.textContent = this.str('label', 'Refreshing');
455
+ this._y.set(this.reduced ? 0 : this.num('threshold', 70) * 0.8);
456
+ return new Promise((resolve) => {
457
+ let finished = false;
458
+ const done = () => {
459
+ if (finished)
460
+ return;
461
+ finished = true;
462
+ this._busy = false;
463
+ this.removeAttribute('data-refreshing');
464
+ this.removeAttribute('aria-busy');
465
+ if (this._live)
466
+ this._live.textContent = '';
467
+ this._y.set(0);
468
+ resolve();
469
+ };
470
+ const ev = new CustomEvent('usa:refresh', { detail: { done }, bubbles: true, cancelable: true });
471
+ this.dispatchEvent(ev);
472
+ const fn = this.onrefresh;
473
+ if (typeof fn === 'function')
474
+ Promise.resolve(fn(ev)).then(done, done);
475
+ });
476
+ }
477
+ }, { id: 'pull-refresh', text: css$8 });
478
+ }
479
+
480
+ var css$7 = "usa-fab{position:fixed;right:max(20px,env(safe-area-inset-right));bottom:max(20px,env(safe-area-inset-bottom));z-index:900;display:grid;place-items:center}usa-fab[position=\"bottom-left\"]{right:auto;left:max(20px,env(safe-area-inset-left))}usa-fab[position=\"inline\"]{position:relative;right:auto;bottom:auto;display:inline-grid}usa-fab>*{grid-area:1 / 1}usa-fab .usa-fab-main{position:relative;z-index:1;width:56px;height:56px;border-radius:min(var(--usa-radius,14px) * 1.2,28px);border:0;display:grid;place-items:center;font-size:24px;cursor:pointer;background:var(--usa-accent,#7c5cff);color:var(--usa-accent-text,#fff);box-shadow:var(--usa-shadow);transition:transform 0.35s cubic-bezier(0.34,1.56,0.64,1)}usa-fab[open] .usa-fab-main{transform:rotate(45deg)}usa-fab .usa-fab-action{width:44px;height:44px;border-radius:50%;display:grid;place-items:center;opacity:0;transform:scale(0.4);will-change:transform,opacity}usa-fab .usa-fab-main:focus-visible,usa-fab .usa-fab-action:focus-visible{outline:2px solid var(--usa-accent,#7c5cff);outline-offset:3px}@media (prefers-reduced-motion:reduce){usa-fab .usa-fab-main{transition:none}}";
481
+
482
+ function defineFab(tag = 'usa-fab') {
483
+ adoptVariants();
484
+ return base.defineElement(tag, (Base) => class UsaFab extends Base {
485
+ static get observedAttributes() {
486
+ return ['direction', 'gap'];
487
+ }
488
+ get open() {
489
+ return this.flag('open');
490
+ }
491
+ set open(v) {
492
+ this.toggle(v);
493
+ }
494
+ parts() {
495
+ const kids = Array.from(this.children);
496
+ return [kids[0] || null, kids.slice(1)];
497
+ }
498
+ offset(i, n) {
499
+ const g = this.num('gap', 56) * (i + 1);
500
+ switch (this.str('direction', 'up')) {
501
+ case 'down':
502
+ return [0, g];
503
+ case 'left':
504
+ return [-g, 0];
505
+ case 'right':
506
+ return [g, 0];
507
+ case 'radial': {
508
+ const a = Math.PI + (n > 1 ? (i / (n - 1)) * (Math.PI / 2) : Math.PI / 4);
509
+ const r = this.num('gap', 56) * 1.6;
510
+ return [Math.cos(a) * r, Math.sin(a) * r];
511
+ }
512
+ default:
513
+ return [0, -g];
514
+ }
515
+ }
516
+ mount() {
517
+ const [main, actions] = this.parts();
518
+ if (!main)
519
+ return;
520
+ main.classList.add('usa-fab-main');
521
+ main.setAttribute('aria-haspopup', 'true');
522
+ actions.forEach((a) => a.classList.add('usa-fab-action'));
523
+ this.apply(false);
524
+ this.listen(main, 'click', () => this.toggle());
525
+ this.listen(document, 'keydown', (e) => {
526
+ if (e.key === 'Escape' && this.open) {
527
+ this.toggle(false);
528
+ main.focus();
529
+ }
530
+ });
531
+ this.listen(document, 'pointerdown', (e) => this.open && !this.contains(e.target) && this.toggle(false));
532
+ this.listen(this, 'click', (e) => {
533
+ const a = e.target.closest?.('.usa-fab-action');
534
+ if (a && this.contains(a))
535
+ this.toggle(false);
536
+ });
537
+ }
538
+ apply(animate) {
539
+ const [main, actions] = this.parts();
540
+ if (!main)
541
+ return;
542
+ const open = this.open;
543
+ main.setAttribute('aria-expanded', String(open));
544
+ actions.forEach((a, i) => {
545
+ const [x, y] = this.offset(i, actions.length);
546
+ a.toggleAttribute('inert', !open);
547
+ a.setAttribute('aria-hidden', String(!open));
548
+ const to = open ? `translate(${x.toFixed(1)}px, ${y.toFixed(1)}px) scale(1)` : 'translate(0, 0) scale(0.4)';
549
+ const from = a.style.transform || 'translate(0, 0) scale(0.4)';
550
+ a.style.transform = this.reduced ? (open ? `translate(${x.toFixed(1)}px, ${y.toFixed(1)}px)` : 'translate(0, 0)') : to;
551
+ a.style.opacity = open ? '1' : '0';
552
+ if (animate && !this.reduced) {
553
+ const t = spring.springEasing(open ? 'wobbly' : 'stiff');
554
+ this.motion(a, [{ transform: from, opacity: open ? 0 : 1 }, { transform: to, opacity: open ? 1 : 0 }], { ...t, delay: (open ? i : actions.length - 1 - i) * 35 });
555
+ }
556
+ });
557
+ }
558
+ toggle(force) {
559
+ const next = force === undefined ? !this.open : force;
560
+ if (next === this.open)
561
+ return;
562
+ this.setFlag('open', next);
563
+ this.apply(true);
564
+ this.emit('toggle', { open: next });
565
+ }
566
+ }, { id: 'fab', text: css$7 });
567
+ }
568
+
569
+ var css$6 = "usa-navbar{position:sticky;top:0;z-index:800;display:block;transition:transform 0.35s cubic-bezier(0.22,1,0.36,1),padding 0.25s ease,box-shadow 0.25s ease;will-change:transform}usa-navbar[data-hidden]{transform:translateY(-100%)}usa-navbar[data-scrolled]{box-shadow:var(--usa-shadow,0 6px 20px -10px rgb(0 0 0 / 0.4))}usa-navbar[shrink][data-scrolled]{padding-block:4px}@media (prefers-reduced-motion:reduce){usa-navbar{transition:none}}";
570
+
571
+ function defineNavbar(tag = 'usa-navbar') {
572
+ adoptVariants();
573
+ return base.defineElement(tag, (Base) => class UsaNavbar extends Base {
574
+ constructor() {
575
+ super(...arguments);
576
+ this._frame = 0;
577
+ this._last = 0;
578
+ }
579
+ get hiddenByScroll() {
580
+ return this.hasAttribute('data-hidden');
581
+ }
582
+ mount() {
583
+ const sel = this.str('target');
584
+ const scroller = (sel && document.querySelector(sel)) || window;
585
+ const pos = () => (scroller === window ? window.scrollY || document.documentElement.scrollTop : scroller.scrollTop);
586
+ this._last = pos();
587
+ const update = () => {
588
+ this._frame = 0;
589
+ const y = pos();
590
+ const dy = y - this._last;
591
+ this._last = y;
592
+ this.toggleAttribute('data-scrolled', y > 4);
593
+ if (y <= this.num('threshold', 64) || dy < -2)
594
+ this.show();
595
+ else if (dy > 2 && !this.contains(document.activeElement))
596
+ this.hide();
597
+ };
598
+ const on = () => {
599
+ if (!this._frame)
600
+ this._frame = base.raf(update);
601
+ };
602
+ this.listen(scroller, 'scroll', on, { passive: true });
603
+ this.listen(this, 'focusin', () => this.show());
604
+ update();
605
+ }
606
+ unmount() {
607
+ base.caf(this._frame);
608
+ this._frame = 0;
609
+ }
610
+ hide() {
611
+ if (this.hiddenByScroll)
612
+ return;
613
+ this.setAttribute('data-hidden', '');
614
+ this.emit('hide');
615
+ }
616
+ show() {
617
+ if (!this.hiddenByScroll)
618
+ return;
619
+ this.removeAttribute('data-hidden');
620
+ this.emit('show');
621
+ }
622
+ }, { id: 'navbar', text: css$6 });
623
+ }
624
+
625
+ var css$5 = "usa-slider{--usa-slider:0;position:relative;display:block;height:28px;min-width:120px;touch-action:none;cursor:pointer;-webkit-tap-highlight-color:transparent}usa-slider .usa-slider-track{position:absolute;left:0;right:0;top:50%;height:6px;margin-top:-3px;border-radius:3px;background:color-mix(in srgb,currentColor 16%,transparent);overflow:hidden}usa-slider .usa-slider-fill{position:absolute;inset:0;background:var(--usa-accent,#7c5cff);transform-origin:0 50%;transform:scaleX(var(--usa-slider))}usa-slider .usa-slider-thumb{position:absolute;top:50%;left:calc(var(--usa-slider) * 100%);width:20px;height:20px;margin:-10px 0 0 -10px;border-radius:50%;background:#fff;box-shadow:0 1px 4px rgb(0 0 0 / 0.35),0 0 0 4px color-mix(in srgb,var(--usa-accent,#7c5cff) 0%,transparent);transition:transform 0.25s cubic-bezier(0.34,1.56,0.64,1),box-shadow 0.2s ease}usa-slider:hover .usa-slider-thumb,usa-slider:focus-visible .usa-slider-thumb{box-shadow:0 1px 4px rgb(0 0 0 / 0.35),0 0 0 6px color-mix(in srgb,var(--usa-accent,#7c5cff) 25%,transparent)}usa-slider[data-dragging] .usa-slider-thumb{transform:scale(1.25)}usa-slider .usa-slider-bubble{position:absolute;bottom:150%;left:50%;transform:translateX(-50%) scale(0.6);opacity:0;padding:2px 8px;border-radius:8px;font:600 12px/1.6 system-ui,sans-serif;color:var(--usa-accent-text,#fff);background:var(--usa-accent,#7c5cff);white-space:nowrap;pointer-events:none;transition:opacity 0.15s ease,transform 0.25s cubic-bezier(0.34,1.56,0.64,1)}usa-slider[bubble][data-dragging] .usa-slider-bubble,usa-slider[bubble]:focus-visible .usa-slider-bubble{opacity:1;transform:translateX(-50%) scale(1)}usa-slider:focus-visible{outline:none}usa-slider[disabled]{opacity:0.45;cursor:not-allowed}@media (prefers-reduced-motion:reduce){usa-slider .usa-slider-thumb,usa-slider .usa-slider-bubble{transition:none}}";
626
+
627
+ function defineSlider(tag = 'usa-slider') {
628
+ adoptVariants();
629
+ return base.defineElement(tag, (Base) => {
630
+ class UsaSlider extends Base {
631
+ static get observedAttributes() {
632
+ return ['min', 'max', 'disabled', 'label'];
633
+ }
634
+ constructor() {
635
+ super();
636
+ this._internals = null;
637
+ this._v = 0;
638
+ this._id = -1;
639
+ try {
640
+ this._internals = this.attachInternals?.() ?? null;
641
+ }
642
+ catch {
643
+ this._internals = null;
644
+ }
645
+ }
646
+ range() {
647
+ const min = this.num('min', 0);
648
+ const max = Math.max(min + 1e-9, this.num('max', 100));
649
+ return [min, max, Math.max(1e-9, this.num('step', 1))];
650
+ }
651
+ get value() {
652
+ return this._v;
653
+ }
654
+ set value(v) {
655
+ this.setValue(v, false);
656
+ }
657
+ fraction(v = this._v) {
658
+ const [min, max] = this.range();
659
+ return (v - min) / (max - min);
660
+ }
661
+ setValue(v, user, animate = true) {
662
+ const [min, max, step] = this.range();
663
+ const q = base.clamp(Math.round((v - min) / step) * step + min, min, max);
664
+ const val = Number(q.toFixed(10));
665
+ const changed = val !== this._v;
666
+ this._v = val;
667
+ this.setAttribute('aria-valuenow', String(val));
668
+ this.setAttribute('aria-valuetext', String(val));
669
+ this._internals?.setFormValue?.(String(val));
670
+ const bubble = this.querySelector('.usa-slider-bubble');
671
+ if (bubble)
672
+ bubble.textContent = String(val);
673
+ if (animate)
674
+ this._pos?.set(this.fraction());
675
+ else
676
+ this._pos?.jump(this.fraction());
677
+ if (changed && user) {
678
+ this.dispatchEvent(new Event('input', { bubbles: true }));
679
+ this.emit('input', { value: val });
680
+ }
681
+ }
682
+ mount() {
683
+ if (!this.querySelector(':scope > .usa-slider-track')) {
684
+ this.innerHTML = '<span class="usa-slider-track"><span class="usa-slider-fill"></span></span><span class="usa-slider-thumb"><span class="usa-slider-bubble"></span></span>';
685
+ }
686
+ this.setAttribute('role', 'slider');
687
+ if (!this.hasAttribute('tabindex'))
688
+ this.tabIndex = 0;
689
+ const [min, max] = this.range();
690
+ this.setAttribute('aria-valuemin', String(min));
691
+ this.setAttribute('aria-valuemax', String(max));
692
+ if (this.str('label'))
693
+ this.setAttribute('aria-label', this.str('label'));
694
+ this.toggleAttribute('aria-disabled', this.flag('disabled'));
695
+ this._pos = spring.createSpring({ spring: 'stiff', onUpdate: (f) => this.style.setProperty('--usa-slider', base.clamp(f, 0, 1).toFixed(4)) });
696
+ this.setValue(this.num('value', min), false, false);
697
+ const fromPointer = (e) => {
698
+ const r = this.getBoundingClientRect();
699
+ return min + base.clamp((e.clientX - r.left) / (r.width || 1), 0, 1) * (max - min);
700
+ };
701
+ this.listen(this, 'pointerdown', (e) => {
702
+ if (this.flag('disabled'))
703
+ return;
704
+ this._id = e.pointerId;
705
+ try {
706
+ this.setPointerCapture?.(e.pointerId);
707
+ }
708
+ catch {
709
+ /* synthetic */
710
+ }
711
+ this.setAttribute('data-dragging', '');
712
+ this.setValue(fromPointer(e), true);
713
+ });
714
+ this.listen(this, 'pointermove', (e) => e.pointerId === this._id && this.setValue(fromPointer(e), true));
715
+ const end = (e) => {
716
+ if (e.pointerId !== this._id)
717
+ return;
718
+ this._id = -1;
719
+ this.removeAttribute('data-dragging');
720
+ this.commit();
721
+ };
722
+ this.listen(this, 'pointerup', end);
723
+ this.listen(this, 'pointercancel', end);
724
+ this.listen(this, 'keydown', (e) => {
725
+ if (this.flag('disabled'))
726
+ return;
727
+ const [mn, mx, st] = this.range();
728
+ const map = { ArrowRight: this._v + st, ArrowUp: this._v + st, ArrowLeft: this._v - st, ArrowDown: this._v - st, PageUp: this._v + st * 10, PageDown: this._v - st * 10, Home: mn, End: mx };
729
+ if (!(e.key in map))
730
+ return;
731
+ e.preventDefault();
732
+ this.setValue(map[e.key], true);
733
+ this.commit();
734
+ });
735
+ }
736
+ unmount() {
737
+ this._pos?.stop();
738
+ }
739
+ commit() {
740
+ this.dispatchEvent(new Event('change', { bubbles: true }));
741
+ this.emit('change', { value: this._v });
742
+ }
743
+ }
744
+ UsaSlider.formAssociated = true;
745
+ return UsaSlider;
746
+ }, { id: 'slider', text: css$5 });
747
+ }
748
+
749
+ var css$4 = "usa-rating{--usa-rating-on:#f5b301;display:inline-flex;gap:2px;font-size:1.5em;line-height:1;cursor:pointer;user-select:none;-webkit-tap-highlight-color:transparent}usa-rating[readonly]{cursor:default}usa-rating .usa-rating-star{display:inline-block;color:color-mix(in srgb,currentColor 22%,transparent);transition:color 0.15s ease,transform 0.2s ease}usa-rating .usa-rating-star[data-on]{color:var(--usa-rating-on)}usa-rating[data-previewing] .usa-rating-star{color:color-mix(in srgb,currentColor 22%,transparent)}usa-rating[data-previewing] .usa-rating-star[data-preview]{color:var(--usa-rating-on);transform:scale(1.12)}usa-rating:focus-visible{outline:2px solid var(--usa-accent,#7c5cff);outline-offset:3px;border-radius:6px}@media (prefers-reduced-motion:reduce){usa-rating .usa-rating-star{transition:none;transform:none !important}}";
750
+
751
+ function defineRating(tag = 'usa-rating') {
752
+ adoptVariants();
753
+ return base.defineElement(tag, (Base) => {
754
+ class UsaRating extends Base {
755
+ static get observedAttributes() {
756
+ return ['max', 'icon', 'readonly'];
757
+ }
758
+ constructor() {
759
+ super();
760
+ this._internals = null;
761
+ try {
762
+ this._internals = this.attachInternals?.() ?? null;
763
+ }
764
+ catch {
765
+ this._internals = null;
766
+ }
767
+ }
768
+ get value() {
769
+ return base.clamp(this.num('value', 0), 0, this.num('max', 5));
770
+ }
771
+ set value(v) {
772
+ this.setAttribute('value', String(base.clamp(Math.round(v), 0, this.num('max', 5))));
773
+ this.sync();
774
+ }
775
+ mount() {
776
+ const max = this.num('max', 5);
777
+ this.innerHTML = Array.from({ length: max }, (_, i) => `<span class="usa-rating-star" data-i="${i + 1}" aria-hidden="true">${this.str('icon', '★')}</span>`).join('');
778
+ this.setAttribute('role', 'slider');
779
+ this.setAttribute('aria-valuemin', '0');
780
+ this.setAttribute('aria-valuemax', String(max));
781
+ this.setAttribute('aria-label', this.str('label', 'Rating'));
782
+ if (this.flag('readonly'))
783
+ this.setAttribute('aria-readonly', 'true');
784
+ else if (!this.hasAttribute('tabindex'))
785
+ this.tabIndex = 0;
786
+ this.sync();
787
+ if (this.flag('readonly'))
788
+ return;
789
+ this.listen(this, 'pointerover', (e) => {
790
+ const s = e.target.closest?.('[data-i]');
791
+ if (s)
792
+ this.preview(Number(s.dataset.i));
793
+ });
794
+ this.listen(this, 'pointerleave', () => this.preview(0));
795
+ this.listen(this, 'click', (e) => {
796
+ const s = e.target.closest?.('[data-i]');
797
+ if (s)
798
+ this.choose(Number(s.dataset.i) === this.value ? 0 : Number(s.dataset.i));
799
+ });
800
+ this.listen(this, 'keydown', (e) => {
801
+ const v = this.value;
802
+ const map = { ArrowRight: v + 1, ArrowUp: v + 1, ArrowLeft: v - 1, ArrowDown: v - 1, Home: 0, End: max };
803
+ const n = /^[0-9]$/.test(e.key) ? Number(e.key) : map[e.key];
804
+ if (n === undefined)
805
+ return;
806
+ e.preventDefault();
807
+ this.choose(base.clamp(n, 0, max));
808
+ });
809
+ }
810
+ preview(n) {
811
+ this.querySelectorAll('[data-i]').forEach((s) => s.toggleAttribute('data-preview', n > 0 && Number(s.dataset.i) <= n));
812
+ this.toggleAttribute('data-previewing', n > 0);
813
+ }
814
+ sync() {
815
+ const v = this.value;
816
+ this.setAttribute('aria-valuenow', String(v));
817
+ this.setAttribute('aria-valuetext', `${v} of ${this.num('max', 5)}`);
818
+ this._internals?.setFormValue?.(String(v));
819
+ this.querySelectorAll('[data-i]').forEach((s) => s.toggleAttribute('data-on', Number(s.dataset.i) <= v));
820
+ }
821
+ choose(n) {
822
+ if (n === this.value)
823
+ return;
824
+ this.value = n;
825
+ const star = this.querySelector(`[data-i="${n}"]`);
826
+ if (star && !this.reduced)
827
+ this.motion(star, [{ transform: 'scale(0.5) rotate(-20deg)' }, { transform: 'scale(1) rotate(0)' }], spring.springEasing('bouncy'));
828
+ this.dispatchEvent(new Event('change', { bubbles: true }));
829
+ this.emit('change', { value: n });
830
+ }
831
+ }
832
+ UsaRating.formAssociated = true;
833
+ return UsaRating;
834
+ }, { id: 'rating', text: css$4 });
835
+ }
836
+
837
+ var css$3 = "usa-tooltip{display:inline-block}usa-tooltip .usa-tooltip-bubble{position:fixed;z-index:2000;max-width:260px;padding:6px 10px;font-size:0.85rem;line-height:1.4;pointer-events:none;--usa-radius:8px;white-space:normal}usa-tooltip .usa-tooltip-bubble[hidden]{display:none}";
838
+
839
+ function defineTooltip(tag = 'usa-tooltip') {
840
+ adoptVariants();
841
+ return base.defineElement(tag, (Base) => class UsaTooltip extends Base {
842
+ constructor() {
843
+ super(...arguments);
844
+ this._tip = null;
845
+ }
846
+ static get observedAttributes() {
847
+ return ['text'];
848
+ }
849
+ mount() {
850
+ const trigger = this.firstElementChild || this;
851
+ const tip = document.createElement('span');
852
+ tip.className = 'usa-tooltip-bubble usa-surface';
853
+ tip.setAttribute('role', 'tooltip');
854
+ tip.id = nextId('usa-tip');
855
+ tip.textContent = this.str('text');
856
+ tip.hidden = true;
857
+ this.append(tip);
858
+ this._tip = tip;
859
+ trigger.setAttribute('aria-describedby', tip.id);
860
+ const later = () => {
861
+ clearTimeout(this._t);
862
+ this._t = setTimeout(() => this.show(), this.num('delay', 300));
863
+ };
864
+ this.listen(this, 'pointerenter', later);
865
+ this.listen(this, 'pointerleave', () => this.hide());
866
+ this.listen(this, 'focusin', () => this.show());
867
+ this.listen(this, 'focusout', () => this.hide());
868
+ this.listen(document, 'keydown', (e) => e.key === 'Escape' && this.hide());
869
+ this.onCleanup(() => {
870
+ clearTimeout(this._t);
871
+ tip.remove();
872
+ trigger.removeAttribute('aria-describedby');
873
+ });
874
+ }
875
+ show() {
876
+ const tip = this._tip;
877
+ if (!tip || !tip.hidden || !this.str('text'))
878
+ return;
879
+ clearTimeout(this._t);
880
+ tip.hidden = false;
881
+ const p = place(tip, this.firstElementChild || this, this.str('placement', 'top'));
882
+ const d = { top: [0, 6], bottom: [0, -6], left: [6, 0], right: [-6, 0] }[p];
883
+ this.motion(tip, this.reduced ? [{ opacity: 0 }, { opacity: 1 }] : [{ opacity: 0, transform: `translate(${d[0]}px, ${d[1]}px) scale(0.85)` }, { opacity: 1, transform: 'none' }], this.reduced ? { duration: 120 } : spring.springEasing('stiff'));
884
+ }
885
+ hide() {
886
+ clearTimeout(this._t);
887
+ if (this._tip)
888
+ this._tip.hidden = true;
889
+ }
890
+ }, { id: 'tooltip', text: css$3 });
891
+ }
892
+
893
+ var css$2 = "usa-popover{display:inline-block}usa-popover .usa-popover-panel{position:fixed;z-index:1500;min-width:180px;max-width:min(92vw,360px);padding:12px 14px;outline:none}usa-popover .usa-popover-panel[hidden]{display:none}";
894
+
895
+ function definePopover(tag = 'usa-popover') {
896
+ adoptVariants();
897
+ return base.defineElement(tag, (Base) => class UsaPopover extends Base {
898
+ get open() {
899
+ return this.flag('open');
900
+ }
901
+ set open(v) {
902
+ this.toggle(v);
903
+ }
904
+ parts() {
905
+ return [this.firstElementChild, this.querySelector(':scope > [data-popover]')];
906
+ }
907
+ mount() {
908
+ const [trigger, panel] = this.parts();
909
+ if (!trigger || !panel || trigger === panel)
910
+ return;
911
+ panel.id || (panel.id = nextId('usa-pop'));
912
+ panel.classList.add('usa-surface', 'usa-popover-panel');
913
+ if (!panel.hasAttribute('role'))
914
+ panel.setAttribute('role', 'dialog');
915
+ panel.tabIndex = -1;
916
+ trigger.setAttribute('aria-controls', panel.id);
917
+ trigger.setAttribute('aria-haspopup', 'dialog');
918
+ this.render(false);
919
+ this.listen(trigger, 'click', () => this.toggle());
920
+ this.listen(document, 'keydown', (e) => {
921
+ if (e.key === 'Escape' && this.open) {
922
+ this.toggle(false);
923
+ trigger.focus();
924
+ }
925
+ });
926
+ this.listen(document, 'pointerdown', (e) => this.open && !this.contains(e.target) && this.toggle(false));
927
+ this.listen(window, 'resize', () => this.open && place(panel, trigger, this.str('placement', 'bottom')));
928
+ }
929
+ render(animate) {
930
+ const [trigger, panel] = this.parts();
931
+ if (!trigger || !panel)
932
+ return;
933
+ trigger.setAttribute('aria-expanded', String(this.open));
934
+ panel.hidden = !this.open;
935
+ if (!this.open)
936
+ return;
937
+ const p = place(panel, trigger, this.str('placement', 'bottom'));
938
+ if (!animate)
939
+ return;
940
+ const origin = { top: '50% 100%', bottom: '50% 0', left: '100% 50%', right: '0 50%' }[p];
941
+ panel.style.transformOrigin = origin;
942
+ this.motion(panel, this.reduced ? [{ opacity: 0 }, { opacity: 1 }] : [{ opacity: 0, transform: 'scale(0.9)' }, { opacity: 1, transform: 'none' }], this.reduced ? { duration: 120 } : spring.springEasing('wobbly'));
943
+ panel.focus({ preventScroll: true });
944
+ }
945
+ toggle(force) {
946
+ const next = force === undefined ? !this.open : force;
947
+ if (next === this.open)
948
+ return;
949
+ this.setFlag('open', next);
950
+ this.render(true);
951
+ this.emit(next ? 'open' : 'close');
952
+ }
953
+ }, { id: 'popover', text: css$2 });
954
+ }
955
+
956
+ var css$1 = "usa-badge{position:relative;display:inline-block}usa-badge .usa-badge-count{position:absolute;top:0;right:0;transform-origin:50% 50%;translate:45% -45%;min-width:18px;height:18px;padding:0 5px;box-sizing:border-box;border-radius:9px;display:grid;place-items:center;font:700 11px/1 system-ui,sans-serif;color:var(--usa-accent-text,#fff);background:var(--usa-badge-color,#e5484d);box-shadow:0 0 0 2px var(--usa-badge-ring,Canvas);pointer-events:none}usa-badge[data-dot] .usa-badge-count{min-width:10px;width:10px;height:10px;padding:0}usa-badge .usa-badge-count[hidden]{display:none}usa-badge[pulse] .usa-badge-count::after{content:\"\";position:absolute;inset:0;border-radius:inherit;background:inherit;animation:usa-badge-pulse 1.6s ease-out infinite;z-index:-1}@keyframes usa-badge-pulse{from{transform:scale(1);opacity:0.6}to{transform:scale(2.4);opacity:0}}@media (prefers-reduced-motion:reduce){usa-badge[pulse] .usa-badge-count::after{animation:none}}";
957
+
958
+ function defineBadge(tag = 'usa-badge') {
959
+ adoptVariants();
960
+ return base.defineElement(tag, (Base) => class UsaBadge extends Base {
961
+ constructor() {
962
+ super(...arguments);
963
+ this._el = null;
964
+ }
965
+ static get observedAttributes() {
966
+ return ['value', 'max', 'dot', 'label'];
967
+ }
968
+ get value() {
969
+ return this.str('value');
970
+ }
971
+ set value(v) {
972
+ this.setAttribute('value', String(v));
973
+ }
974
+ mount() {
975
+ if (!this._el || !this._el.isConnected) {
976
+ this._el = document.createElement('span');
977
+ this._el.className = 'usa-badge-count';
978
+ this.append(this._el);
979
+ }
980
+ this.sync(false);
981
+ }
982
+ changed(name) {
983
+ this.sync(name === 'value');
984
+ }
985
+ sync(bump) {
986
+ const el = this._el;
987
+ if (!el)
988
+ return;
989
+ const raw = this.value;
990
+ const n = Number(raw);
991
+ const max = this.num('max', 99);
992
+ const text = this.flag('dot') ? '' : raw !== '' && Number.isFinite(n) && n > max ? `${max}+` : raw;
993
+ const empty = !this.flag('dot') && (raw === '' || (raw === '0' && !this.flag('show-zero')));
994
+ el.textContent = text;
995
+ el.hidden = empty;
996
+ this.toggleAttribute('data-dot', this.flag('dot'));
997
+ const label = this.str('label', raw ? `${raw} new` : 'New');
998
+ el.setAttribute('aria-label', label.replace('{n}', raw));
999
+ el.setAttribute('role', 'status');
1000
+ if (bump && !empty && !this.reduced)
1001
+ this.motion(el, [{ transform: 'scale(0.4)' }, { transform: 'scale(1)' }], spring.springEasing('bouncy'));
1002
+ }
1003
+ }, { id: 'badge', text: css$1 });
1004
+ }
1005
+
1006
+ var css = "usa-avatar-stack{--usa-avatar-size:36px;--usa-avatar-overlap:0.35;display:inline-flex;align-items:center;padding-inline-start:calc(var(--usa-avatar-size) * var(--usa-avatar-overlap))}usa-avatar-stack .usa-avatar{width:var(--usa-avatar-size);height:var(--usa-avatar-size);border-radius:50%;object-fit:cover;flex:none;box-shadow:0 0 0 2px var(--usa-avatar-ring,Canvas);margin-inline-start:calc(var(--usa-avatar-size) * var(--usa-avatar-overlap) * -1);transition:margin 0.45s cubic-bezier(0.34,1.56,0.64,1),transform 0.3s cubic-bezier(0.34,1.56,0.64,1);display:grid;place-items:center;font:700 12px/1 system-ui,sans-serif;background:color-mix(in srgb,currentColor 14%,transparent)}usa-avatar-stack .usa-avatar[hidden]{display:none}usa-avatar-stack:hover .usa-avatar,usa-avatar-stack:focus-within .usa-avatar{margin-inline-start:4px}usa-avatar-stack .usa-avatar:hover{transform:translateY(-4px) scale(1.08)}@media (prefers-reduced-motion:reduce){usa-avatar-stack .usa-avatar{transition:none}usa-avatar-stack:hover .usa-avatar,usa-avatar-stack:focus-within .usa-avatar{margin-inline-start:calc(var(--usa-avatar-size) * var(--usa-avatar-overlap) * -1)}usa-avatar-stack .usa-avatar:hover{transform:none}}";
1007
+
1008
+ function defineAvatarStack(tag = 'usa-avatar-stack') {
1009
+ adoptVariants();
1010
+ return base.defineElement(tag, (Base) => class UsaAvatarStack extends Base {
1011
+ static get observedAttributes() {
1012
+ return ['max', 'size', 'overlap'];
1013
+ }
1014
+ mount() {
1015
+ this.querySelector(':scope > .usa-avatar-more')?.remove();
1016
+ const kids = Array.from(this.children);
1017
+ const max = Math.max(1, this.num('max', 5));
1018
+ this.style.setProperty('--usa-avatar-size', `${this.num('size', 36)}px`);
1019
+ this.style.setProperty('--usa-avatar-overlap', String(this.num('overlap', 0.35)));
1020
+ this.setAttribute('role', 'group');
1021
+ this.setAttribute('aria-label', this.str('label', `${kids.length} people`));
1022
+ kids.forEach((k, i) => {
1023
+ k.classList.add('usa-avatar');
1024
+ k.hidden = i >= max;
1025
+ k.style.setProperty('--i', String(i));
1026
+ k.style.zIndex = String(kids.length - i);
1027
+ });
1028
+ if (kids.length > max) {
1029
+ const more = document.createElement('span');
1030
+ more.className = 'usa-avatar usa-avatar-more';
1031
+ more.textContent = `+${kids.length - max}`;
1032
+ more.style.setProperty('--i', String(max));
1033
+ more.setAttribute('aria-label', `and ${kids.length - max} more`);
1034
+ this.append(more);
1035
+ }
1036
+ }
1037
+ }, { id: 'avatar-stack', text: css });
1038
+ }
1039
+
1040
+ /**
1041
+ * use-scroll-animate/components/ui — animated UI components + style variants (v2.6).
1042
+ * `<usa-tabs>`, `<usa-drawer>`, `<usa-bottom-sheet>`, `<usa-pull-refresh>`,
1043
+ * `<usa-fab>`, `<usa-navbar>`, `<usa-slider>`, `<usa-rating>`,
1044
+ * `<usa-tooltip>`, `<usa-popover>`, `<usa-badge>`, `<usa-avatar-stack>`,
1045
+ * and `variant="minimal | neon | glass | brutalist | fluent | material"`
1046
+ * design tokens (`setVariant()`, `VARIANTS`).
1047
+ */
1048
+ /** Register every component of this category under its default tag. */
1049
+ function defineUiComponents() {
1050
+ defineTabs();
1051
+ defineDrawer();
1052
+ defineBottomSheet();
1053
+ definePullRefresh();
1054
+ defineFab();
1055
+ defineNavbar();
1056
+ defineSlider();
1057
+ defineRating();
1058
+ defineTooltip();
1059
+ definePopover();
1060
+ defineBadge();
1061
+ defineAvatarStack();
1062
+ }
1063
+
1064
+ exports.configureComponents = base.configureComponents;
1065
+ exports.prefersReducedMotion = base.prefersReducedMotion;
1066
+ exports.VARIANTS = VARIANTS;
1067
+ exports.adoptVariants = adoptVariants;
1068
+ exports.defineAvatarStack = defineAvatarStack;
1069
+ exports.defineBadge = defineBadge;
1070
+ exports.defineBottomSheet = defineBottomSheet;
1071
+ exports.defineDrawer = defineDrawer;
1072
+ exports.defineFab = defineFab;
1073
+ exports.defineNavbar = defineNavbar;
1074
+ exports.definePopover = definePopover;
1075
+ exports.definePullRefresh = definePullRefresh;
1076
+ exports.defineRating = defineRating;
1077
+ exports.defineSlider = defineSlider;
1078
+ exports.defineTabs = defineTabs;
1079
+ exports.defineTooltip = defineTooltip;
1080
+ exports.defineUiComponents = defineUiComponents;
1081
+ exports.setVariant = setVariant;
1082
+ //# sourceMappingURL=ui.cjs.map