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