use-scroll-animate 3.7.0 → 3.8.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.
@@ -0,0 +1,1693 @@
1
+ type MotionIntensity = 'off' | 'low' | 'normal' | 'high';
2
+ /**
3
+ * Members shared by every `<usa-*>` element. Attribute helpers, a cleanup
4
+ * bag that is emptied on disconnect, and motion helpers that degrade to the
5
+ * final state without WAAPI or under reduced motion.
6
+ */
7
+ interface UsaElement extends HTMLElement {
8
+ /** `true` while reduced motion applies to this element. */
9
+ readonly reduced: boolean;
10
+ }
11
+
12
+ /** Entrance effects shared by `<usa-reveal>` and `<usa-stagger>` (transform / opacity / filter only). */
13
+ declare const REVEAL_EFFECTS: readonly ["fade", "fade-up", "fade-down", "fade-left", "fade-right", "zoom-in", "zoom-out", "blur", "blur-up", "flip-up", "flip-left", "rise"];
14
+ type RevealEffect = (typeof REVEAL_EFFECTS)[number];
15
+
16
+ /**
17
+ * `<usa-reveal>` — reveals its content when it scrolls into view.
18
+ *
19
+ * Attributes: `effect` (see {@link RevealEffect}, default `fade-up`),
20
+ * `duration` (ms, 700), `delay` (ms, 0), `distance` (px, 32), `easing`,
21
+ * `threshold` (0–1, 0.15), `root-margin`, `repeat` (hide again when it
22
+ * leaves, replay on re-entry). Events: `usa:enter`, `usa:leave`, `usa:complete`.
23
+ */
24
+ interface UsaRevealElement extends UsaElement {
25
+ effect: RevealEffect | string;
26
+ /** Play the entrance now (also called automatically on enter). */
27
+ reveal(): Promise<void>;
28
+ /** Hide again so the next `reveal()` replays the entrance. */
29
+ reset(): void;
30
+ readonly revealed: boolean;
31
+ }
32
+
33
+ /**
34
+ * `<usa-stagger>` — reveals its direct children one after another when the
35
+ * list scrolls into view.
36
+ *
37
+ * Attributes: `effect` (default `fade-up`), `interval` (ms between children,
38
+ * 70), `duration` (600), `delay` (0), `distance` (24), `easing`,
39
+ * `threshold` (0.1), `repeat`. Events: `usa:enter`, `usa:complete`.
40
+ */
41
+ interface UsaStaggerElement extends UsaElement {
42
+ reveal(): Promise<void>;
43
+ reset(): void;
44
+ }
45
+
46
+ /**
47
+ * `<usa-scroll-progress>` — a reading-progress bar.
48
+ *
49
+ * Attributes: `target` (CSS selector of an article to track; default the
50
+ * whole page), `position` (`top` | `bottom` | `inline`, default `top`),
51
+ * `label` (accessible name, default "Reading progress"). Style with
52
+ * `--usa-progress-color`, `--usa-progress-height`, `--usa-progress-track`.
53
+ * Exposes the progress (0–1) as `--usa-progress` on the element and as the
54
+ * `progress` property. Event: `usa:progress` (`detail.progress`).
55
+ *
56
+ * Writes only `transform: scaleX()` (compositor-friendly); reads layout
57
+ * once per animation frame, and only while scrolling.
58
+ */
59
+ interface UsaScrollProgressElement extends UsaElement {
60
+ readonly progress: number;
61
+ /** Re-measure (e.g. after content loaded). */
62
+ update(): void;
63
+ }
64
+
65
+ /**
66
+ * `<usa-scrolly>` — sticky scrollytelling. A child marked `data-sticky`
67
+ * stays pinned while the `[data-step]` children scroll past; the step that
68
+ * crosses the trigger line becomes active.
69
+ *
70
+ * Attributes: `offset` (trigger line as a fraction of the viewport height,
71
+ * default 0.5), `active` (reflected index of the active step). The active
72
+ * step gets `data-active`; the host gets `--usa-step` and `data-step-name`
73
+ * (the step's `data-step` value). Event: `usa:step` (`detail.index`,
74
+ * `detail.step`, `detail.name`).
75
+ */
76
+ interface UsaScrollyElement extends UsaElement {
77
+ readonly active: number;
78
+ readonly steps: HTMLElement[];
79
+ }
80
+
81
+ /**
82
+ * use-scroll-animate/components/reveal — entrance & scroll reveal components.
83
+ * `<usa-reveal>`, `<usa-stagger>`, `<usa-scroll-progress>`, `<usa-scrolly>`.
84
+ */
85
+
86
+ declare global {
87
+ interface HTMLElementTagNameMap {
88
+ 'usa-reveal': UsaRevealElement;
89
+ 'usa-stagger': UsaStaggerElement;
90
+ 'usa-scroll-progress': UsaScrollProgressElement;
91
+ 'usa-scrolly': UsaScrollyElement;
92
+ }
93
+ }
94
+
95
+ /**
96
+ * `<usa-typewriter>` — types text character by character, optionally cycling
97
+ * through several phrases (typing, pausing, deleting).
98
+ *
99
+ * Attributes: `text` (default: the element's text), `words` (phrases
100
+ * separated by `|`, overrides `text`), `speed` (ms per character, 55),
101
+ * `delete-speed` (ms, 30), `pause` (ms before deleting, 1400), `delay`
102
+ * (ms, 0), `loop`, `cursor="false"` to hide the caret, `start`
103
+ * (`view` | `load` | `manual`, default `view`). The full text is exposed to
104
+ * assistive tech via `aria-label`. Event: `usa:complete` (one pass done).
105
+ * Reduced motion: the text appears at once.
106
+ */
107
+ interface UsaTypewriterElement extends UsaElement {
108
+ /** Phrases being typed. */
109
+ readonly phrases: string[];
110
+ start(): void;
111
+ stop(): void;
112
+ restart(): void;
113
+ }
114
+
115
+ /**
116
+ * `<usa-split-text>` — splits its text into words or characters and reveals
117
+ * them in a cascade (pure CSS animation per unit, transform / opacity /
118
+ * filter only). Words never break across lines.
119
+ *
120
+ * Attributes: `by` (`chars` | `words`, default `chars`), `effect`
121
+ * (`rise` | `fade` | `blur` | `flip` | `pop`, default `rise`), `stagger`
122
+ * (ms between units, 28 for chars / 70 for words), `duration` (ms, 620),
123
+ * `delay` (ms, 0), `trigger` (`view` | `load` | `manual`, default `view`),
124
+ * `repeat`. The original text stays readable via `aria-label`.
125
+ * Event: `usa:complete`.
126
+ */
127
+ interface UsaSplitTextElement extends UsaElement {
128
+ readonly units: HTMLElement[];
129
+ play(): void;
130
+ reset(): void;
131
+ }
132
+
133
+ /**
134
+ * `<usa-scramble>` — "decodes" text out of random glyphs, left to right.
135
+ *
136
+ * Attributes: `text` (default: the element's text), `duration` (ms, 900),
137
+ * `chars` (glyph set), `trigger` (`view` | `hover` | `load` | `manual`,
138
+ * default `view`). Spaces and punctuation stay in place. Uses a monospace-
139
+ * friendly fixed width per glyph only if you style it so; the element sets
140
+ * nothing that causes reflow beyond its own text. Event: `usa:complete`.
141
+ * Reduced motion: shows the final text.
142
+ */
143
+ interface UsaScrambleElement extends UsaElement {
144
+ play(): Promise<void>;
145
+ }
146
+
147
+ /**
148
+ * `<usa-counter>` — counts up (or down) to a number when it scrolls into view.
149
+ *
150
+ * Attributes: `to` (target, required), `from` (0), `duration` (ms, 1600),
151
+ * `decimals` (0), `locale` (default: the document language), `prefix`,
152
+ * `suffix`, `grouping="false"` (no thousands separators), `start`
153
+ * (`view` | `load` | `manual`). Setting the `value` property animates from
154
+ * the current value — handy for live dashboards. Uses tabular digits so
155
+ * the width does not jump. Event: `usa:complete`. Reduced motion: jumps.
156
+ */
157
+ interface UsaCounterElement extends UsaElement {
158
+ /** Current target; setting it animates to the new number. */
159
+ value: number;
160
+ /** Animate to `to` (default: the `to` attribute). */
161
+ play(to?: number): Promise<void>;
162
+ format(n: number): string;
163
+ }
164
+
165
+ /**
166
+ * `<usa-shimmer-text>` — a light sweep across gradient-filled text (CSS
167
+ * only; the element just maps attributes to custom properties).
168
+ *
169
+ * Attributes: `duration` (ms, 2600), `color` (base text colour), `shine`
170
+ * (highlight colour), `angle` (deg, 110). Or style `--usa-shimmer-*`
171
+ * directly. Reduced motion: static gradient text.
172
+ */
173
+ type UsaShimmerTextElement = UsaElement;
174
+
175
+ /**
176
+ * `<usa-text-rotate>` — cycles through words in place ("Build *fast* /
177
+ * *small* / *typed* apps"). All words share one grid cell, so the width is
178
+ * that of the longest word and nothing around it reflows.
179
+ *
180
+ * Attributes: `words` (separated by `|`, default: the element's text split
181
+ * on `|`), `interval` (ms, 2200), `effect` (`slide` | `fade` | `flip` |
182
+ * `blur`, default `slide`), `paused`. Pauses while off-screen and on hover
183
+ * is not needed. Event: `usa:change` (`detail.index`, `detail.word`).
184
+ * Reduced motion: words still change, without movement (fade only).
185
+ */
186
+ interface UsaTextRotateElement extends UsaElement {
187
+ readonly index: number;
188
+ next(): void;
189
+ }
190
+
191
+ /**
192
+ * `<usa-wave-text>` — letters bob in a travelling wave.
193
+ * Attributes: `amplitude` (em, 0.25), `speed` (s per cycle, 1.6), `stagger`
194
+ * (s between letters, 0.06). Reduced motion: still text.
195
+ */
196
+ interface UsaWaveTextElement extends UsaElement {
197
+ }
198
+ /**
199
+ * `<usa-glitch>` — an RGB-split glitch on its text (`trigger="always"`
200
+ * default, or `hover`). Attributes: `intensity` (px, 3), `trigger`.
201
+ * Reduced motion: no animation (plain text).
202
+ */
203
+ interface UsaGlitchElement extends UsaElement {
204
+ }
205
+ /**
206
+ * `<usa-gradient-text>` — text filled with a flowing multi-colour gradient.
207
+ * Attributes: `colors` (comma list), `speed` (s, 6), `angle` (deg, 90).
208
+ * Reduced motion: a static gradient.
209
+ */
210
+ interface UsaGradientTextElement extends UsaElement {
211
+ }
212
+ /**
213
+ * `<usa-handwriting>` — the text draws itself stroke by stroke (SVG text
214
+ * outline), then fills in, when it scrolls into view.
215
+ * Attributes: `text`, `duration` (ms, 2400), `stroke` (colour), `size` (px,
216
+ * 64), `font` (family; a script font looks best). Events: `usa:complete`.
217
+ * Reduced motion: the filled text appears at once.
218
+ */
219
+ interface UsaHandwritingElement extends UsaElement {
220
+ play(): void;
221
+ }
222
+ /**
223
+ * `<usa-scroll-highlight>` — reading highlight: words light up one by one
224
+ * as the paragraph scrolls through the viewport (`mode="words"`, default),
225
+ * or a highlighter marker sweeps behind the text on enter (`mode="marker"`).
226
+ * Attributes: `mode`, `color` (marker), `dim` (opacity of unread words,
227
+ * 0.2). Reduced motion: fully highlighted text.
228
+ */
229
+ interface UsaScrollHighlightElement extends UsaElement {
230
+ readonly progress: number;
231
+ }
232
+
233
+ /**
234
+ * use-scroll-animate/components/text — text effects.
235
+ * `<usa-typewriter>`, `<usa-split-text>`, `<usa-scramble>`, `<usa-counter>`,
236
+ * `<usa-shimmer-text>`, `<usa-text-rotate>`.
237
+ */
238
+
239
+ declare global {
240
+ interface HTMLElementTagNameMap {
241
+ 'usa-wave-text': UsaWaveTextElement;
242
+ 'usa-glitch': UsaGlitchElement;
243
+ 'usa-gradient-text': UsaGradientTextElement;
244
+ 'usa-handwriting': UsaHandwritingElement;
245
+ 'usa-scroll-highlight': UsaScrollHighlightElement;
246
+ 'usa-typewriter': UsaTypewriterElement;
247
+ 'usa-split-text': UsaSplitTextElement;
248
+ 'usa-scramble': UsaScrambleElement;
249
+ 'usa-counter': UsaCounterElement;
250
+ 'usa-shimmer-text': UsaShimmerTextElement;
251
+ 'usa-text-rotate': UsaTextRotateElement;
252
+ }
253
+ }
254
+
255
+ /**
256
+ * `<usa-ripple>` — an ink ripple from the pointer (or the centre, for
257
+ * keyboard presses) on whatever it wraps: buttons, list items, cards.
258
+ *
259
+ * Attributes: `color` (default `currentColor`), `opacity` (0.22),
260
+ * `duration` (ms, 550), `centered`, `disabled`. Clips its content to its
261
+ * own border radius. Reduced motion: a brief highlight instead of the wave.
262
+ */
263
+ interface UsaRippleElement extends UsaElement {
264
+ /** Spawn a ripple at client coordinates (default: centre). */
265
+ ripple(x?: number, y?: number): void;
266
+ }
267
+
268
+ /**
269
+ * `<usa-magnetic>` — its content leans toward the pointer when the pointer
270
+ * comes near, and springs back when it leaves (great for CTAs and icons).
271
+ *
272
+ * Attributes: `strength` (0–1 share of the pointer offset, 0.35), `radius`
273
+ * (px of attraction beyond the element's edge, 60), `disabled`. Only on
274
+ * devices with a fine pointer that hovers; off under reduced motion.
275
+ * Writes one `transform` per frame through `--usa-mx` / `--usa-my`.
276
+ */
277
+ type UsaMagneticElement = UsaElement;
278
+
279
+ /**
280
+ * `<usa-tilt>` — a 3D card that tilts toward the pointer, with an optional
281
+ * glare highlight that follows it.
282
+ *
283
+ * Attributes: `max` (deg, 10), `scale` (1.03 while hovered), `perspective`
284
+ * (px, 900), `glare` (add the light reflection), `reverse` (tilt away),
285
+ * `disabled`. Off under reduced motion. Exposes `--usa-tilt-x` /
286
+ * `--usa-tilt-y` (−1…1) for parallax layers inside the card.
287
+ */
288
+ type UsaTiltElement = UsaElement;
289
+
290
+ /**
291
+ * `<usa-spotlight>` — the Windows Fluent "Reveal highlight": a soft light
292
+ * follows the pointer across a group of items, lighting up their borders
293
+ * (even of neighbours) and the background of the hovered one. Put buttons,
294
+ * tiles or menu items inside; each direct child is an item (or mark items
295
+ * with `data-spotlight` to pick them yourself).
296
+ *
297
+ * Attributes: `size` (px, radius of the light, 160), `color` (default a
298
+ * translucent white), `border` (px width of the lit border, 1),
299
+ * `no-fill` (only light the borders). Not a motion effect, so it stays on
300
+ * under reduced motion; off on touch-only devices.
301
+ */
302
+ type UsaSpotlightElement = UsaElement;
303
+
304
+ /**
305
+ * `<usa-press>` — tactile press feedback: content dips while pressed and
306
+ * springs back on release (the Fluent "pointer down" scale), or bounces once
307
+ * on click with `bounce`.
308
+ *
309
+ * Attributes: `scale` (pressed scale, 0.95), `bounce` (overshoot on
310
+ * release), `disabled`. Works with mouse, touch, pen and Space/Enter.
311
+ * Reduced motion: a subtle dim instead of scaling.
312
+ */
313
+ interface UsaPressElement extends UsaElement {
314
+ readonly pressed: boolean;
315
+ }
316
+
317
+ /**
318
+ * `<usa-toggle>` — an accessible switch whose knob stretches while pressed
319
+ * and glides across (the Windows 11 / iOS toggle). `role="switch"`,
320
+ * keyboard (Space / Enter), and form-associated where `ElementInternals`
321
+ * exists (submits `value`, default `"on"`, under `name` when checked).
322
+ *
323
+ * Attributes: `checked`, `disabled`, `name`, `value`, `label`
324
+ * (accessible name if there is no `aria-label` / `<label>`). Events:
325
+ * `change` and `usa:change` (`detail.checked`). Reduced motion: no glide.
326
+ */
327
+ interface UsaToggleElement extends UsaElement {
328
+ checked: boolean;
329
+ disabled: boolean;
330
+ toggle(force?: boolean): void;
331
+ }
332
+
333
+ /**
334
+ * use-scroll-animate/components/interaction — micro-interactions.
335
+ * `<usa-ripple>`, `<usa-magnetic>`, `<usa-tilt>`, `<usa-spotlight>`,
336
+ * `<usa-press>`, `<usa-toggle>`.
337
+ */
338
+
339
+ declare global {
340
+ interface HTMLElementTagNameMap {
341
+ 'usa-ripple': UsaRippleElement;
342
+ 'usa-magnetic': UsaMagneticElement;
343
+ 'usa-tilt': UsaTiltElement;
344
+ 'usa-spotlight': UsaSpotlightElement;
345
+ 'usa-press': UsaPressElement;
346
+ 'usa-toggle': UsaToggleElement;
347
+ }
348
+ }
349
+
350
+ declare const SPINNER_VARIANTS: readonly ["fluent", "windows", "ring", "dots", "pulse", "bars"];
351
+ type SpinnerVariant = (typeof SPINNER_VARIANTS)[number];
352
+ /**
353
+ * `<usa-spinner>` — indeterminate loading indicators, pure CSS animations
354
+ * of `transform` / `opacity` (plus an SVG stroke for `fluent`).
355
+ *
356
+ * Kinds (`kind`): `fluent` (default — the WinUI / Windows 11
357
+ * ProgressRing arc), `windows` (the Windows 10 boot "orbiting dots"),
358
+ * `ring` (classic border spinner), `dots` (three bouncing dots / typing
359
+ * indicator), `pulse` (expanding ripple), `bars` (equalizer).
360
+ * Attributes: `size` (px, 32), `label` (accessible name, "Loading"),
361
+ * `paused`. Colour follows `color` / `--usa-spinner-color`.
362
+ * `role="progressbar"` without a value (indeterminate). Reduced motion:
363
+ * a slow opacity pulse instead of movement.
364
+ */
365
+ interface UsaSpinnerElement extends UsaElement {
366
+ /** Spinner kind (`kind` attribute). */
367
+ kind: SpinnerVariant;
368
+ }
369
+
370
+ /**
371
+ * `<usa-skeleton>` — shimmering placeholders while content loads. With
372
+ * `loading`, it shows `lines` bars (or one block of `width` × `height`,
373
+ * or a `circle`) and hides its children; remove `loading` and the real
374
+ * content fades in.
375
+ *
376
+ * Attributes: `loading`, `lines` (3), `width`, `height` (CSS lengths),
377
+ * `circle`, `radius`, `avatar` (circle + lines, like a list row).
378
+ * `aria-busy` follows `loading`. Reduced motion: no shimmer sweep.
379
+ */
380
+ interface UsaSkeletonElement extends UsaElement {
381
+ loading: boolean;
382
+ }
383
+
384
+ /**
385
+ * `<usa-progress>` — a linear progress bar. Determinate (`value` / `max`)
386
+ * bars glide between values with `transform: scaleX()`; without a value,
387
+ * or with `indeterminate`, it shows the Windows Fluent indeterminate
388
+ * animation (two sliding segments).
389
+ *
390
+ * Attributes: `value`, `max` (100), `indeterminate`, `state`
391
+ * (`paused` | `error` — the WinUI states), `label` (accessible name).
392
+ * `role="progressbar"` with `aria-valuenow` when determinate.
393
+ * Reduced motion: no glide; indeterminate becomes a gentle pulse.
394
+ */
395
+ interface UsaProgressElement extends UsaElement {
396
+ value: number | null;
397
+ max: number;
398
+ /** 0–1, or `null` when indeterminate. */
399
+ readonly ratio: number | null;
400
+ }
401
+
402
+ type ToastType = 'info' | 'success' | 'warning' | 'error';
403
+ interface ToastOptions {
404
+ /** ms before it hides itself; `0` keeps it until closed (default 4000). */
405
+ duration?: number;
406
+ type?: ToastType;
407
+ /** Optional action button. */
408
+ action?: {
409
+ label: string;
410
+ onClick: () => void;
411
+ };
412
+ /** Show a close button (default `true`). */
413
+ dismissible?: boolean;
414
+ /** The toaster to use (default: the first `<usa-toaster>`, created if missing). */
415
+ toaster?: UsaToasterElement | string;
416
+ }
417
+ interface ToastHandle {
418
+ element: HTMLElement;
419
+ close(): Promise<void>;
420
+ }
421
+ /**
422
+ * `<usa-toaster>` — the region toasts slide into (`role="region"`, each
423
+ * toast `role="status"`, errors `role="alert"`). Toasts pause their timer
424
+ * while hovered or focused, and the stack re-flows with a FLIP animation.
425
+ *
426
+ * Attributes: `position` (`bottom-right` default, `bottom-left`,
427
+ * `bottom-center`, `top-right`, `top-left`, `top-center`), `max` (visible
428
+ * toasts, 4), `label` (region name, "Notifications").
429
+ * Reduced motion: toasts fade instead of sliding.
430
+ */
431
+ interface UsaToasterElement extends UsaElement {
432
+ show(message: string, options?: ToastOptions): ToastHandle;
433
+ clear(): void;
434
+ }
435
+
436
+ /**
437
+ * `<usa-check>` — an animated result icon: the circle draws itself, then the
438
+ * check mark (or cross / exclamation) strokes in with a little pop.
439
+ *
440
+ * Attributes: `kind` (`success` default, `error`, `warning`), `size`
441
+ * (px, 56), `start` (`view` default | `load` | `manual`), `label`
442
+ * (accessible name, e.g. "Payment complete"; the icon is decorative
443
+ * without it). Event: `usa:complete`. Reduced motion: drawn instantly.
444
+ */
445
+ interface UsaCheckElement extends UsaElement {
446
+ play(): Promise<void>;
447
+ reset(): void;
448
+ }
449
+
450
+ /**
451
+ * use-scroll-animate/components/feedback — loading & feedback.
452
+ * `<usa-spinner>`, `<usa-skeleton>`, `<usa-progress>`, `<usa-toaster>` +
453
+ * `toast()`, `<usa-check>`.
454
+ */
455
+
456
+ declare global {
457
+ interface HTMLElementTagNameMap {
458
+ 'usa-spinner': UsaSpinnerElement;
459
+ 'usa-skeleton': UsaSkeletonElement;
460
+ 'usa-progress': UsaProgressElement;
461
+ 'usa-toaster': UsaToasterElement;
462
+ 'usa-check': UsaCheckElement;
463
+ }
464
+ }
465
+
466
+ /**
467
+ * `<usa-aurora>` — a slow, drifting aurora / gradient-mesh backdrop behind
468
+ * its content. Soft radial gradients moved with `transform` only (no
469
+ * animated blur), paused while off-screen.
470
+ *
471
+ * Attributes: `colors` (comma-separated, default violet / cyan / pink),
472
+ * `speed` (multiplier, 1), `intensity` (0–1 opacity, 0.7), `paused`.
473
+ * Reduced motion: a still gradient.
474
+ */
475
+ type UsaAuroraElement = UsaElement;
476
+
477
+ /**
478
+ * `<usa-particles>` — a canvas of drifting particles, optionally linked by
479
+ * lines when close (a "constellation"), that drift away from the pointer.
480
+ * Fills its own box (place it as a background with
481
+ * `position: absolute; inset: 0`, or give it a height).
482
+ *
483
+ * Attributes: `count` (60; scaled down on small boxes), `color`
484
+ * (default `currentColor`), `size` (max radius px, 2.2), `speed` (0.35),
485
+ * `links` (max link distance px, 110; `0` disables), `interactive`,
486
+ * `paused`. Renders only while visible and the tab is shown, at device
487
+ * pixel ratio ≤ 2. Reduced motion: one still frame.
488
+ */
489
+ interface UsaParticlesElement extends UsaElement {
490
+ /** Re-seed the particles. */
491
+ reset(): void;
492
+ }
493
+
494
+ /**
495
+ * `<usa-grain>` — a film-grain / noise overlay on top of its content
496
+ * (SVG `feTurbulence` texture, no images to ship). With `animated`, the
497
+ * grain jitters like film (stepped `transform`, ~12 fps).
498
+ *
499
+ * Attributes: `opacity` (0.12), `animated`, `blend` (`mix-blend-mode`,
500
+ * default `overlay`), `scale` (texture size px, 180). Never intercepts
501
+ * pointer events. Reduced motion: static grain.
502
+ */
503
+ type UsaGrainElement = UsaElement;
504
+
505
+ /**
506
+ * `<usa-marquee>` — an infinite, seamless ticker of its children (logos,
507
+ * testimonials, tags). The content is cloned (clones are `aria-hidden` and
508
+ * `inert`) and the track slides with one WAAPI `transform` animation whose
509
+ * duration follows the measured width, so the speed is constant.
510
+ *
511
+ * Attributes: `speed` (px/s, 50), `direction` (`left` default | `right` |
512
+ * `up` | `down`), `gap` (px, 32), `pause-on-hover`, `fade` (soft edges),
513
+ * `paused`. Pauses off-screen. Reduced motion: no movement; the row
514
+ * becomes scrollable instead.
515
+ */
516
+ interface UsaMarqueeElement extends UsaElement {
517
+ pause(): void;
518
+ resume(): void;
519
+ }
520
+
521
+ /**
522
+ * `<usa-acrylic>` — Windows Fluent materials for the web: `acrylic`
523
+ * (frosted glass: backdrop blur + saturation + tint + subtle noise) and
524
+ * `mica` (an opaque, wallpaper-tinted base for app backgrounds; on the web it
525
+ * tints from `--usa-mica-source`, a gradient you control). Optional
526
+ * `shimmer` adds a light sweep when it appears or on hover.
527
+ *
528
+ * Attributes: `kind` (`acrylic` default | `mica`), `tint` (colour),
529
+ * `tint-opacity` (0–1, 0.55), `blur` (px, 30), `shimmer`
530
+ * (`hover` | `load` | `none`, default `none`). Falls back to a solid tint
531
+ * without `backdrop-filter` and under `prefers-reduced-transparency` or
532
+ * forced colours, like Windows does when transparency effects are off.
533
+ */
534
+ type UsaAcrylicElement = UsaElement;
535
+
536
+ /**
537
+ * `<usa-grid-glow>` — a line grid behind its content that lights up around
538
+ * the pointer. Attributes: `size` (cell px, 32), `color`, `radius` (px, 220).
539
+ * Reduced motion: the grid stays, a soft static glow in the centre.
540
+ */
541
+ interface UsaGridGlowElement extends UsaElement {
542
+ }
543
+ /**
544
+ * `<usa-blobs>` — soft, slowly morphing colour blobs (fluid gradient
545
+ * backdrop). Attributes: `colors` (comma list), `speed` (1), `blur` (px, 60).
546
+ * Reduced motion: still blobs.
547
+ */
548
+ interface UsaBlobsElement extends UsaElement {
549
+ }
550
+ /**
551
+ * `<usa-water-ripple>` — interactive water ripples on a canvas over its
552
+ * content (pointer moves and taps disturb the surface). Low-resolution height
553
+ * map, paused off-screen. Attributes: `damping` (0.96), `strength` (1),
554
+ * `color` (highlight). Reduced motion: nothing is drawn.
555
+ */
556
+ interface UsaWaterRippleElement extends UsaElement {
557
+ drop(x: number, y: number, strength?: number): void;
558
+ }
559
+ /**
560
+ * `<usa-dot-network>` — a grid of dots that swell and link up with lines
561
+ * around the pointer (a living network backdrop). Attributes: `gap` (px,
562
+ * 28), `color`, `radius` (px of influence, 140). Reduced motion: a static
563
+ * dot grid.
564
+ */
565
+ interface UsaDotNetworkElement extends UsaElement {
566
+ }
567
+
568
+ /**
569
+ * use-scroll-animate/components/background — backgrounds & decoration.
570
+ * `<usa-aurora>`, `<usa-particles>`, `<usa-grain>`, `<usa-marquee>`,
571
+ * `<usa-acrylic>`.
572
+ */
573
+
574
+ declare global {
575
+ interface HTMLElementTagNameMap {
576
+ 'usa-grid-glow': UsaGridGlowElement;
577
+ 'usa-blobs': UsaBlobsElement;
578
+ 'usa-water-ripple': UsaWaterRippleElement;
579
+ 'usa-dot-network': UsaDotNetworkElement;
580
+ 'usa-aurora': UsaAuroraElement;
581
+ 'usa-particles': UsaParticlesElement;
582
+ 'usa-grain': UsaGrainElement;
583
+ 'usa-marquee': UsaMarqueeElement;
584
+ 'usa-acrylic': UsaAcrylicElement;
585
+ }
586
+ }
587
+
588
+ /**
589
+ * `<usa-dialog>` — an animated modal or drawer built on the native
590
+ * `<dialog>` (top layer, focus trapping, inert page, Esc to close). Its
591
+ * children are slotted into the panel (they stay in the light DOM, so
592
+ * React / Vue / Svelte keep owning them). Style with `::part(panel)`,
593
+ * `::part(backdrop)` and the `--usa-dialog-*` custom properties.
594
+ *
595
+ * Attributes: `open` (reflects; set/remove to open/close), `kind`
596
+ * (`modal` default — Fluent scale + fade; `drawer-start` / `drawer-end`
597
+ * slide from the side, `drawer-bottom` / `sheet` from below), `label`
598
+ * (accessible name), `no-backdrop-close`, `no-esc`. Elements inside
599
+ * with `data-close` close it. Events: `usa:open`, `usa:close` (cancelable
600
+ * `usa:beforeclose`). Reduced motion: fade only.
601
+ */
602
+ interface UsaDialogElement extends UsaElement {
603
+ open: boolean;
604
+ show(): Promise<void>;
605
+ close(returnValue?: string): Promise<void>;
606
+ readonly dialog: HTMLDialogElement | null;
607
+ returnValue: string;
608
+ }
609
+
610
+ /**
611
+ * `<usa-accordion>` — smooth expand / collapse for the native `<details>`
612
+ * elements inside it (keeps their semantics, keyboard support and
613
+ * find-in-page, and adds no wrapper elements, so framework-rendered content
614
+ * is left alone). Only one stays open unless `multiple` is set.
615
+ *
616
+ * Attributes: `multiple`, `duration` (ms, 300). Event: `usa:toggle`
617
+ * (`detail.details`, `detail.open`). Reduced motion: instant.
618
+ * Heights are measured once per toggle and animated on the `<details>`.
619
+ */
620
+ interface UsaAccordionElement extends UsaElement {
621
+ readonly items: HTMLDetailsElement[];
622
+ toggleItem(details: HTMLDetailsElement, open?: boolean): Promise<void>;
623
+ }
624
+
625
+ /**
626
+ * `<usa-flip-list>` — animates its children to their new places whenever
627
+ * they are added, removed or reordered (FLIP: transforms only). Works with
628
+ * any rendering: plain DOM, React keyed lists, Vue `v-for`, Svelte `{#each}`.
629
+ *
630
+ * Attributes: `duration` (ms, 420), `easing`, `disabled`.
631
+ * Method: `flip(mutate)` for explicit changes (also measures resizes).
632
+ * Reduced motion: no animation.
633
+ */
634
+ interface UsaFlipListElement extends UsaElement {
635
+ flip(mutate: () => void | Promise<void>): Promise<void>;
636
+ }
637
+
638
+ /**
639
+ * `<usa-view-switch>` — shows one of its children at a time (tabs, wizard
640
+ * steps, app pages) and animates between them. Children are views; name
641
+ * them with `data-view`, or address them by index.
642
+ *
643
+ * Attributes: `active` (view name or index, default the first),
644
+ * `effect` (`fade` | `slide` (default, direction-aware — Fluent "page
645
+ * transition") | `scale` | `drill`), `duration` (ms, 320). Inactive views
646
+ * get `hidden` + `inert`. Event: `usa:change` (`detail.view`,
647
+ * `detail.index`). Reduced motion: a quick fade.
648
+ */
649
+ interface UsaViewSwitchElement extends UsaElement {
650
+ active: string;
651
+ readonly views: HTMLElement[];
652
+ show(view: string | number): Promise<void>;
653
+ }
654
+
655
+ /**
656
+ * use-scroll-animate/components/transitions — view & layout transitions.
657
+ * `<usa-dialog>`, `<usa-accordion>`, `<usa-flip-list>`, `<usa-view-switch>`
658
+ * and the `viewTransition()`, `flip()`, `connectedAnimation()` helpers.
659
+ */
660
+
661
+ declare global {
662
+ interface HTMLElementTagNameMap {
663
+ 'usa-dialog': UsaDialogElement;
664
+ 'usa-accordion': UsaAccordionElement;
665
+ 'usa-flip-list': UsaFlipListElement;
666
+ 'usa-view-switch': UsaViewSwitchElement;
667
+ }
668
+ }
669
+
670
+ /**
671
+ * `<usa-spring>` — spring / bounce effects on its content.
672
+ *
673
+ * Attributes: `effect` (`bounce-in` default, `pop`, `drop`, `jelly`,
674
+ * `rubber-band`), `trigger` (`view` default, `hover`, `click`, `manual`),
675
+ * `preset` (`gentle`, `wobbly`, `stiff`, `bouncy`, …) or `stiffness` /
676
+ * `damping` / `mass`, `delay` (ms), `duration` (ms, attention effects; 900),
677
+ * `repeat` (replay every time it re-enters the view), `block`.
678
+ * Events: `usa:complete`. Reduced motion: entrances fade, attention effects do nothing.
679
+ */
680
+ interface UsaSpringElement extends UsaElement {
681
+ effect: string;
682
+ play(): Promise<void>;
683
+ reset(): void;
684
+ }
685
+
686
+ /**
687
+ * `<usa-draggable>` — drag its content with the pointer (mouse, touch, pen)
688
+ * or the arrow keys; physics on release.
689
+ *
690
+ * Attributes: `axis` (`both` default, `x`, `y`), `spring-back` (return to
691
+ * the origin with a spring), `inertia` (keep gliding after a flick),
692
+ * `snap` (grid size like `80`, or points like `0,120,240`), `bounds`
693
+ * (`parent` = stay inside the parent box, rubber-banding past its edges),
694
+ * `preset` (spring, default `wobbly`), `step` (arrow-key step, px, 16),
695
+ * `disabled`. Methods: `moveTo(x, y, animate?)`, `reset()`. Events:
696
+ * `usa:drag-start`, `usa:drag-end` (`{ x, y, vx, vy }`), `usa:settle`.
697
+ * Reduced motion: positions change instantly (no spring or inertia).
698
+ */
699
+ interface UsaDraggableElement extends UsaElement {
700
+ readonly x: number;
701
+ readonly y: number;
702
+ readonly dragging: boolean;
703
+ moveTo(x: number, y: number, animate?: boolean): void;
704
+ reset(): void;
705
+ }
706
+
707
+ /**
708
+ * `<usa-overscroll>` — an elastic scroll container: pulling past the top or
709
+ * bottom (touch, trackpad or wheel) stretches the content with iOS-style
710
+ * rubber-band resistance and it springs back on release.
711
+ *
712
+ * Attributes: `axis` (`y` default, `x`), `max` (largest stretch in px, 120),
713
+ * `preset` (spring, default `default`), `disabled`. CSS variable
714
+ * `--usa-overscroll` holds the current offset. Reduced motion: no stretch
715
+ * (a plain scroll container with `overscroll-behavior: contain`).
716
+ */
717
+ interface UsaOverscrollElement extends UsaElement {
718
+ /** Current stretch in px (negative = pulled past the end). */
719
+ readonly offset: number;
720
+ }
721
+
722
+ /**
723
+ * use-scroll-animate/components/physics — spring & bounce physics (v2.3).
724
+ * `<usa-spring>` (bounce-in, pop, drop, jelly, rubber-band), `<usa-draggable>`
725
+ * (spring-back, inertia, snap) and `<usa-overscroll>` (elastic edges), plus
726
+ * the spring core: `spring()`, `springEasing()`, `createSpring()`,
727
+ * `SPRING_PRESETS`, `projectInertia()`, `snapTo()`, `rubberBand()`.
728
+ */
729
+
730
+ declare global {
731
+ interface HTMLElementTagNameMap {
732
+ 'usa-spring': UsaSpringElement;
733
+ 'usa-draggable': UsaDraggableElement;
734
+ 'usa-overscroll': UsaOverscrollElement;
735
+ }
736
+ }
737
+
738
+ /**
739
+ * `<usa-card>` — card effects, combinable: `effect="lift sheen"`.
740
+ *
741
+ * - `flip` — front/back (`[data-front]` / `[data-back]` children) flip on
742
+ * hover or `trigger="click"`, `axis="y"` (default, horizontal flip) or `x`.
743
+ * - `holo` — holographic foil that shifts with the pointer.
744
+ * - `glass` — frosted glass surface (backdrop blur).
745
+ * - `border-glow` — a glow on the border that follows the pointer.
746
+ * - `conic-border` — a rotating conic-gradient border.
747
+ * - `lift` — rises with a deeper shadow and a slight pointer tilt.
748
+ * - `spotlight` — a soft light that follows the pointer.
749
+ * - `sheen` — a light sweep across the card on hover / focus.
750
+ * - `parallax-layers` — children with `data-depth="0.2…1"` move at different depths.
751
+ * - `expand` — click to grow into a full detail view (`[data-detail]`
752
+ * content is shown), FLIP + spring; Esc, `[data-close]` or the backdrop closes.
753
+ *
754
+ * Attributes: `effect`, `axis`, `trigger`, `depth` (parallax px, 16),
755
+ * `color` (glow / spotlight colour), `flipped`, `expanded`, `disabled`.
756
+ * CSS variables: `--usa-card-x/-y` (pointer %, 0–100), `--usa-card-nx/-ny` (−1…1).
757
+ * Methods: `flip(force?)`, `expand()`, `collapse()`. Events: `usa:flip`,
758
+ * `usa:expand`, `usa:collapse`. Reduced motion: no tilt / parallax / sweep;
759
+ * flips and expansions cross-fade.
760
+ */
761
+ interface UsaCardElement extends UsaElement {
762
+ readonly effects: string[];
763
+ flipped: boolean;
764
+ readonly expanded: boolean;
765
+ flip(force?: boolean): void;
766
+ expand(): Promise<void>;
767
+ collapse(): Promise<void>;
768
+ }
769
+
770
+ /**
771
+ * `<usa-card-stack>` — a deck of cards (its element children). The top card
772
+ * can be swiped away left or right (pointer, touch or arrow keys); the rest
773
+ * fan out behind it and move up with a spring.
774
+ *
775
+ * Attributes: `threshold` (px to dismiss, 90), `visible` (cards fanned
776
+ * behind, 3), `offset` (px between cards, 10), `loop` (swiped cards go back
777
+ * to the bottom), `disabled`. Methods: `swipe(direction)`, `top`. Events:
778
+ * `usa:swipe` (`{ direction: 'left' | 'right', card }`), `usa:empty`.
779
+ * Reduced motion: cards are removed instantly, no rotation.
780
+ */
781
+ interface UsaCardStackElement extends UsaElement {
782
+ readonly top: HTMLElement | null;
783
+ swipe(direction: 'left' | 'right'): Promise<void>;
784
+ }
785
+
786
+ /**
787
+ * `<usa-sticky-stack>` — cards (element children) stick to the top while
788
+ * scrolling and the ones underneath scale down and dim as the next card
789
+ * slides over them, like a deck building up.
790
+ *
791
+ * Attributes: `top` (px from the viewport top, 80), `gap` (px each card
792
+ * peeks below the previous, 16), `scale` (how much a covered card shrinks,
793
+ * 0.06). Reduced motion: cards still stack (sticky) but do not scale.
794
+ */
795
+ interface UsaStickyStackElement extends UsaElement {
796
+ update(): void;
797
+ }
798
+
799
+ /**
800
+ * `<usa-carousel-3d>` — its element children on a 3D ring. Rotate with the
801
+ * arrow keys, a drag/swipe, the wheel (shift) or `next()` / `prev()`; the
802
+ * front item is `aria-current`. Spring-driven rotation.
803
+ *
804
+ * Attributes: `radius` (px, auto from item width), `autoplay` (ms between
805
+ * steps, pauses on hover/focus), `perspective` (px, 1200), `index`.
806
+ * Events: `usa:change` (`{ index }`). Reduced motion: a flat, instant
807
+ * switch (only the current item is shown, others dimmed).
808
+ */
809
+ interface UsaCarousel3dElement extends UsaElement {
810
+ index: number;
811
+ next(): void;
812
+ prev(): void;
813
+ goTo(i: number): void;
814
+ }
815
+
816
+ /**
817
+ * use-scroll-animate/components/cards — card effects (v2.4).
818
+ * `<usa-card effect="flip | holo | glass | border-glow | conic-border | lift |
819
+ * spotlight | sheen | parallax-layers | expand">` (combinable),
820
+ * `<usa-card-stack>` (swipeable deck), `<usa-sticky-stack>` (stacking on
821
+ * scroll) and `<usa-carousel-3d>`.
822
+ */
823
+
824
+ declare global {
825
+ interface HTMLElementTagNameMap {
826
+ 'usa-card': UsaCardElement;
827
+ 'usa-card-stack': UsaCardStackElement;
828
+ 'usa-sticky-stack': UsaStickyStackElement;
829
+ 'usa-carousel-3d': UsaCarousel3dElement;
830
+ }
831
+ }
832
+
833
+ /**
834
+ * `<usa-click>` — click / tap effects on whatever it wraps (combinable:
835
+ * `effect="press-spring burst"`).
836
+ *
837
+ * - `ripple` — an ink wave from the pointer (enhanced: `color`, soft edge);
838
+ * - `burst` — particles radiating from the pointer (`shape`: circle, square, star, heart, emoji);
839
+ * - `confetti` — a confetti cannon from the click point;
840
+ * - `squish` — squash on press, stretch on release (spring);
841
+ * - `press-spring` — dips while pressed, springs back with overshoot;
842
+ * - `shake` — horizontal error shake; plays on `invalid` events from a form
843
+ * inside, on `shake()`, or on click when `trigger="click"`.
844
+ *
845
+ * Attributes: `effect`, `color`, `shape`, `count`, `haptic` (vibrate ms,
846
+ * where supported), `disabled`. Keyboard (Space/Enter) triggers the effects
847
+ * from the centre. Reduced motion: no particles or movement; press dims.
848
+ */
849
+ interface UsaClickElement extends UsaElement {
850
+ readonly effects: string[];
851
+ play(x?: number, y?: number): void;
852
+ shake(): void;
853
+ }
854
+
855
+ type ButtonShape = 'pill' | 'circle' | 'icon';
856
+ type ButtonState = 'idle' | 'loading' | 'success' | 'error';
857
+ /**
858
+ * `<usa-button>` — **button click deformation** (按钮点击形变) around a
859
+ * native `<button>` (or `<a>`) child — or the element itself becomes a button.
860
+ *
861
+ * `deform` (combinable, e.g. `deform="squash wobble"`):
862
+ * - `squash` — squash on press, stretch-and-settle on release (spring);
863
+ * - `wobble` — elastic border-radius wobble after a click;
864
+ * - `gooey` — liquid blob: droplets squeeze out from the press point and
865
+ * merge back (SVG goo filter);
866
+ * - `dent` — the surface dents toward the pressed point (3D tilt + inner shade).
867
+ *
868
+ * `shape="pill | circle | icon"` morphs the outline with a spring (label =
869
+ * `[data-label]`, icon = `[data-icon]` children); `morphTo(shape)`.
870
+ *
871
+ * `morph="submit"` — click → `loading` (shrinks to a circle with a spinner,
872
+ * `aria-busy`), then `success` (check) or `error` (shake + cross), and back
873
+ * to `idle` after `reset` ms (1800). Drive it with `state="…"` / `.state`, or
874
+ * call `event.detail.done(ok)` from a `usa:submit` listener.
875
+ *
876
+ * Attributes: `deform`, `shape`, `morph`, `state`, `reset`, `haptic`,
877
+ * `disabled`. Events: `usa:submit`, `usa:state`. Reduced motion: no
878
+ * deformation; shape and state changes are instant; status still announced.
879
+ */
880
+ interface UsaButtonElement extends UsaElement {
881
+ readonly target: HTMLElement;
882
+ shape: ButtonShape;
883
+ state: ButtonState;
884
+ morphTo(shape: ButtonShape): Promise<void>;
885
+ }
886
+
887
+ /**
888
+ * `<usa-icon-morph>` — an icon that morphs between shapes with a spring:
889
+ * play ↔ pause, menu ↔ close, plus ↔ minus, check, arrow-right…
890
+ *
891
+ * Attributes: `icons` (comma list, cycled; default `play,pause`), `index`
892
+ * (current, 0), `size` (px, 24), `toggle` (makes it a button that cycles
893
+ * on click / Enter / Space), `labels` (comma list of accessible names per
894
+ * icon, e.g. `Play,Pause`), `preset` (spring, `wobbly`). Methods:
895
+ * `next()`, `show(nameOrIndex)`. Events: `usa:change` (`{ index, icon }`).
896
+ * Inside a `<usa-button>` or `<button>` it is decorative. Reduced motion:
897
+ * the icon switches instantly.
898
+ */
899
+ interface UsaIconMorphElement extends UsaElement {
900
+ index: number;
901
+ readonly icon: string;
902
+ next(): void;
903
+ show(icon: string | number): void;
904
+ }
905
+
906
+ /**
907
+ * `<usa-like>` — a like / favourite toggle: the heart pops with a spring and
908
+ * bursts into particles when liked. `role="button"` + `aria-pressed`.
909
+ *
910
+ * Attributes: `liked`, `count` (shown next to the heart, updated ±1),
911
+ * `label` (accessible name, default "Like"), `color`, `size` (px, 24),
912
+ * `haptic`, `disabled`. Events: `change`, `usa:change` (`{ liked, count }`).
913
+ * Reduced motion: colour change only.
914
+ */
915
+ interface UsaLikeElement extends UsaElement {
916
+ liked: boolean;
917
+ count: number | null;
918
+ toggle(force?: boolean): void;
919
+ }
920
+
921
+ /**
922
+ * `<usa-hold>` — hold-to-confirm: press and hold (pointer, Space or Enter)
923
+ * while a progress ring fills; releasing early rewinds it. Good for
924
+ * destructive actions.
925
+ *
926
+ * Attributes: `duration` (ms, 1200), `label` (accessible name), `color`,
927
+ * `disabled`. CSS variable `--usa-hold` (0–1). Events: `usa:progress`,
928
+ * `usa:confirm`, `usa:cancel`. Reduced motion: same timing, the ring fills
929
+ * without the scale pulse.
930
+ */
931
+ interface UsaHoldElement extends UsaElement {
932
+ readonly progress: number;
933
+ cancel(): void;
934
+ }
935
+
936
+ /**
937
+ * `<usa-double-tap>` — detects a double tap / double click on its content
938
+ * (photos, posts) and pops a heart (or `icon`) at the tap point.
939
+ *
940
+ * Attributes: `icon` (text / emoji, default ♥), `color`, `delay` (max ms
941
+ * between taps, 300), `haptic`, `disabled`. Events: `usa:double-tap`
942
+ * (`{ x, y }`, element-relative). Keyboard users: press `L` while focused.
943
+ * Reduced motion: the icon fades in and out without scaling or particles.
944
+ */
945
+ interface UsaDoubleTapElement extends UsaElement {
946
+ pop(x?: number, y?: number): void;
947
+ }
948
+
949
+ /**
950
+ * `<usa-checkbox>` — an animated, form-associated checkbox: the box springs
951
+ * and the check mark draws itself. `role="checkbox"` + `aria-checked`
952
+ * (`mixed` with `indeterminate`).
953
+ *
954
+ * Attributes: `checked`, `indeterminate`, `disabled`, `name`, `value`
955
+ * (`on`), `label`, `shape` (`square` default, `circle`). Events: `change`,
956
+ * `usa:change` (`{ checked }`). Reduced motion: no spring or drawing.
957
+ */
958
+ interface UsaCheckboxElement extends UsaElement {
959
+ checked: boolean;
960
+ indeterminate: boolean;
961
+ toggle(force?: boolean): void;
962
+ }
963
+
964
+ /**
965
+ * use-scroll-animate/components/click — click & tap effects (v2.5).
966
+ * `<usa-click>` (ripple, burst, confetti, squish, press-spring, shake),
967
+ * `<usa-button>` (button click deformation: squash, wobble, gooey, dent;
968
+ * shape morph; submit → loading → success), `<usa-icon-morph>`,
969
+ * `<usa-like>`, `<usa-hold>`, `<usa-double-tap>`, `<usa-checkbox>`, plus
970
+ * `burst()`, `confetti()`, `shake()` and `haptic()`.
971
+ */
972
+
973
+ declare global {
974
+ interface HTMLElementTagNameMap {
975
+ 'usa-click': UsaClickElement;
976
+ 'usa-button': UsaButtonElement;
977
+ 'usa-icon-morph': UsaIconMorphElement;
978
+ 'usa-like': UsaLikeElement;
979
+ 'usa-hold': UsaHoldElement;
980
+ 'usa-double-tap': UsaDoubleTapElement;
981
+ 'usa-checkbox': UsaCheckboxElement;
982
+ }
983
+ }
984
+
985
+ /**
986
+ * `<usa-tabs>` — accessible tabs with a sliding (spring) indicator.
987
+ * Tabs: `[data-tab]` children (buttons); panels: `[data-panel]` children, in
988
+ * the same order. Arrow keys / Home / End move between tabs (roving tabindex).
989
+ *
990
+ * Attributes: `selected` (index, 0), `indicator` (`line` default, `pill`),
991
+ * `variant`. Events: `usa:change` (`{ index }`). Panels fade/slide in;
992
+ * reduced motion: the indicator jumps and panels switch instantly.
993
+ */
994
+ interface UsaTabsElement extends UsaElement {
995
+ selected: number;
996
+ select(i: number, focus?: boolean): void;
997
+ }
998
+
999
+ /**
1000
+ * `<usa-drawer>` — a side panel that slides in with a spring and can be
1001
+ * dragged / swiped closed. Modal: backdrop, Esc, focus returns on close.
1002
+ * Attributes: `open`, `side` (`left` default, `right`, `top`, `bottom`),
1003
+ * `label`, `variant`. Events: `usa:open`, `usa:close`. `[data-close]` closes.
1004
+ * Reduced motion: opens and closes instantly.
1005
+ */
1006
+ interface UsaDrawerElement extends UsaElement {
1007
+ open: boolean;
1008
+ show(): void;
1009
+ close(): void;
1010
+ }
1011
+ /**
1012
+ * `<usa-bottom-sheet>` — a draggable bottom sheet with snap points
1013
+ * (`snap="0.3,0.6,0.92"`, fractions of the viewport height; default
1014
+ * `0.5,0.92`; `start` = index of the snap it opens at, default 0), inertia and drag-down-to-dismiss. `[data-handle]` (or the
1015
+ * built-in grabber) drags it. Attributes: `open`, `snap`, `start` (initial
1016
+ * snap index), `label`, `variant`. Events: `usa:open`, `usa:close`, `usa:snap`.
1017
+ */
1018
+ interface UsaBottomSheetElement extends UsaDrawerElement {
1019
+ }
1020
+
1021
+ /**
1022
+ * `<usa-pull-refresh>` — pull-to-refresh for a scroll container (itself):
1023
+ * pull down at the top (touch / pointer) and a spinner stretches in; past
1024
+ * `threshold` (px, 70) releasing fires `usa:refresh` — call
1025
+ * `event.detail.done()` (or return a promise to `onrefresh`) to finish.
1026
+ * Also exposes `refresh()` for a keyboard / button path.
1027
+ * Attributes: `threshold`, `disabled`, `label` (status text, "Refreshing").
1028
+ * Reduced motion: no stretch; the spinner simply appears while refreshing.
1029
+ */
1030
+ interface UsaPullRefreshElement extends UsaElement {
1031
+ readonly refreshing: boolean;
1032
+ refresh(): Promise<void>;
1033
+ }
1034
+
1035
+ /**
1036
+ * `<usa-fab>` — floating action button with a speed dial. The first element
1037
+ * child is the main button; the others are actions that fan out with a
1038
+ * staggered spring when it opens (`direction="up"` default, `down`, `left`,
1039
+ * `right`, `radial`). Esc / outside click closes; `aria-expanded` on the
1040
+ * main button; actions are hidden from AT while closed.
1041
+ * Attributes: `open`, `direction`, `position` (`bottom-right` default, `bottom-left`,
1042
+ * `inline`), `gap` (px, 56), `variant`. Events: `usa:toggle` (`{ open }`).
1043
+ * Reduced motion: actions appear without travel.
1044
+ */
1045
+ interface UsaFabElement extends UsaElement {
1046
+ open: boolean;
1047
+ toggle(force?: boolean): void;
1048
+ }
1049
+
1050
+ /**
1051
+ * `<usa-navbar>` — an app bar that hides while you scroll down and returns
1052
+ * as soon as you scroll up (or reach the top); `shrink` makes it compact
1053
+ * once scrolled. Focus inside always reveals it.
1054
+ * Attributes: `threshold` (px of scroll before hiding, 64), `shrink`,
1055
+ * `target` (selector of a scroll container instead of the page), `variant`.
1056
+ * State attributes: `data-hidden`, `data-scrolled`. Events: `usa:hide`, `usa:show`.
1057
+ * Reduced motion: hides/shows without sliding (instant).
1058
+ */
1059
+ interface UsaNavbarElement extends UsaElement {
1060
+ readonly hiddenByScroll: boolean;
1061
+ show(): void;
1062
+ }
1063
+
1064
+ /**
1065
+ * `<usa-slider>` — a form-associated range slider (`role="slider"`). The
1066
+ * thumb follows with a spring, grows while dragged and shows a value bubble.
1067
+ * Keyboard: arrows (step), PageUp/PageDown (10 steps), Home/End.
1068
+ * Attributes: `value`, `min` (0), `max` (100), `step` (1), `name`, `label`,
1069
+ * `bubble` (show the value while dragging), `disabled`, `variant`.
1070
+ * Events: `input` + `usa:input` while moving, `change` + `usa:change` on release.
1071
+ * Reduced motion: the thumb jumps (no spring).
1072
+ */
1073
+ interface UsaSliderElement extends UsaElement {
1074
+ value: number;
1075
+ }
1076
+
1077
+ /**
1078
+ * `<usa-rating>` — star rating with hover preview and a springy pop when a
1079
+ * value is chosen. `role="slider"` (arrow keys, Home/End, number keys).
1080
+ * Attributes: `value` (0), `max` (5), `icon` (★), `readonly`, `label`
1081
+ * ("Rating"), `name` (form value), `variant`. Events: `change`, `usa:change` (`{ value }`).
1082
+ * Reduced motion: no pop.
1083
+ */
1084
+ interface UsaRatingElement extends UsaElement {
1085
+ value: number;
1086
+ }
1087
+
1088
+ /**
1089
+ * `<usa-tooltip text="…">` — a tooltip for the element it wraps, shown on
1090
+ * hover (after `delay` ms, 300) and on keyboard focus, hidden on Esc / blur.
1091
+ * It springs in from its placement side and flips to stay on screen; the
1092
+ * trigger gets `aria-describedby`.
1093
+ * Attributes: `text`, `placement` (`top` default, `bottom`, `left`, `right`),
1094
+ * `delay`, `variant`. Reduced motion: fades only.
1095
+ */
1096
+ interface UsaTooltipElement extends UsaElement {
1097
+ show(): void;
1098
+ hide(): void;
1099
+ }
1100
+
1101
+ /**
1102
+ * `<usa-popover>` — a click-to-open popover: the first element child is the
1103
+ * trigger, `[data-popover]` is the content. Springs open from the trigger,
1104
+ * flips to stay on screen; Esc or an outside click closes and focus returns
1105
+ * to the trigger. `aria-expanded` / `aria-controls` on the trigger.
1106
+ * Attributes: `open`, `placement` (`bottom` default), `variant`. Events:
1107
+ * `usa:open`, `usa:close`. Reduced motion: fades only.
1108
+ */
1109
+ interface UsaPopoverElement extends UsaElement {
1110
+ open: boolean;
1111
+ toggle(force?: boolean): void;
1112
+ }
1113
+
1114
+ /**
1115
+ * `<usa-badge>` — a count / dot badge on whatever it wraps; bumps with a
1116
+ * spring whenever the value changes and pulses with `pulse`.
1117
+ * Attributes: `value` (number or text; 0 / empty hides it unless
1118
+ * `show-zero`), `max` (99 → "99+"), `dot`, `pulse`, `label` (accessible
1119
+ * text, default "{n} new"), `variant`. Reduced motion: no bump or pulse.
1120
+ */
1121
+ interface UsaBadgeElement extends UsaElement {
1122
+ value: string;
1123
+ }
1124
+
1125
+ /**
1126
+ * `<usa-avatar-stack>` — overlapping avatars (its children: `<img>` or any
1127
+ * element) that spread apart with a spring on hover / focus; extra ones
1128
+ * collapse into a "+N" chip.
1129
+ * Attributes: `max` (visible avatars, 5), `size` (px, 36), `overlap` (0–1,
1130
+ * 0.35), `label` (group name), `variant`. Reduced motion: no spreading.
1131
+ */
1132
+ interface UsaAvatarStackElement extends UsaElement {
1133
+ }
1134
+
1135
+ /**
1136
+ * use-scroll-animate/components/ui — animated UI components + style variants (v2.6).
1137
+ * `<usa-tabs>`, `<usa-drawer>`, `<usa-bottom-sheet>`, `<usa-pull-refresh>`,
1138
+ * `<usa-fab>`, `<usa-navbar>`, `<usa-slider>`, `<usa-rating>`,
1139
+ * `<usa-tooltip>`, `<usa-popover>`, `<usa-badge>`, `<usa-avatar-stack>`,
1140
+ * and `variant="minimal | neon | glass | brutalist | fluent | material"`
1141
+ * design tokens (`setVariant()`, `VARIANTS`).
1142
+ */
1143
+
1144
+ declare global {
1145
+ interface HTMLElementTagNameMap {
1146
+ 'usa-tabs': UsaTabsElement;
1147
+ 'usa-drawer': UsaDrawerElement;
1148
+ 'usa-bottom-sheet': UsaBottomSheetElement;
1149
+ 'usa-pull-refresh': UsaPullRefreshElement;
1150
+ 'usa-fab': UsaFabElement;
1151
+ 'usa-navbar': UsaNavbarElement;
1152
+ 'usa-slider': UsaSliderElement;
1153
+ 'usa-rating': UsaRatingElement;
1154
+ 'usa-tooltip': UsaTooltipElement;
1155
+ 'usa-popover': UsaPopoverElement;
1156
+ 'usa-badge': UsaBadgeElement;
1157
+ 'usa-avatar-stack': UsaAvatarStackElement;
1158
+ }
1159
+ }
1160
+
1161
+ /**
1162
+ * `<usa-cursor mode="dot | trail | magnetic | glow">` — a custom cursor for
1163
+ * the page (place it once, e.g. at the end of `<body>`).
1164
+ * - `dot` — a ring that follows with spring lag around the real pointer;
1165
+ * - `trail` — a comet tail of dots;
1166
+ * - `magnetic` — the ring snaps onto and wraps hovered targets (`a`,
1167
+ * `button`, `[data-cursor]`);
1168
+ * - `glow` — a large soft light following the pointer (great on dark UIs).
1169
+ * Attributes: `mode`, `color`, `size` (px, 28), `hide-native` (hide the
1170
+ * system cursor), `targets` (selector, magnetic). Only for fine pointers
1171
+ * (mouse / pen); never on touch. Reduced motion: not rendered.
1172
+ */
1173
+ interface UsaCursorElement extends UsaElement {
1174
+ readonly active: boolean;
1175
+ }
1176
+
1177
+ /**
1178
+ * `<usa-fullpage>` — full-screen sections (its element children) that snap
1179
+ * one at a time (CSS scroll snap), with keyboard paging (PageUp/PageDown,
1180
+ * arrows, Home/End), optional dot navigation and the current section in
1181
+ * `aria-current` + `usa:section`.
1182
+ * Attributes: `dots` (show the dot nav), `axis` (`y` default, `x`).
1183
+ * Methods: `go(i)`, `next()`, `prev()`. Reduced motion: snapping stays,
1184
+ * jumps are instant.
1185
+ */
1186
+ interface UsaFullpageElement extends UsaElement {
1187
+ readonly index: number;
1188
+ go(i: number): void;
1189
+ next(): void;
1190
+ prev(): void;
1191
+ }
1192
+
1193
+ /**
1194
+ * `<usa-loading-bar>` — a slim top loading bar for route changes and fetches
1195
+ * (NProgress-style): `start()` trickles towards 90 %, `done()` completes and
1196
+ * fades out, `set(0–1)` for real progress. `loadingBar` drives the first bar
1197
+ * on the page (created on demand). `role="progressbar"`, `aria-busy`.
1198
+ * Attributes: `color`, `height` (px, 3), `position` (`top` default, `bottom`).
1199
+ * Reduced motion: no trickle animation — the bar shows / hides.
1200
+ */
1201
+ interface UsaLoadingBarElement extends UsaElement {
1202
+ readonly progress: number;
1203
+ start(): void;
1204
+ set(p: number): void;
1205
+ done(): void;
1206
+ }
1207
+
1208
+ /**
1209
+ * `<usa-back-to-top>` — a floating button that appears after `offset` px
1210
+ * (300) of scrolling, shows page progress as a ring and springs the page
1211
+ * back to the top (then focuses `focus-target`, default `#main` / `body`).
1212
+ * Attributes: `offset`, `label` ("Back to top"), `focus-target`, `position`
1213
+ * (`bottom-right` default, `bottom-left`). Reduced motion: instant jump.
1214
+ */
1215
+ interface UsaBackToTopElement extends UsaElement {
1216
+ readonly visible: boolean;
1217
+ }
1218
+
1219
+ /**
1220
+ * `<usa-ambient effect="particles | snow | stars | noise | gradient">` — a
1221
+ * fixed, page-wide ambient layer behind (or, with `layer="front"`, over)
1222
+ * the content, never catching the pointer.
1223
+ * - `particles` — slow drifting dots; `snow` — falling flakes with sway;
1224
+ * `stars` — twinkling starfield (canvas, paused in hidden tabs, DPR ≤ 2);
1225
+ * - `noise` — animated film grain (CSS, SVG turbulence);
1226
+ * - `gradient` — a gradient whose hue shifts with the scroll position.
1227
+ * Attributes: `effect`, `density` (0.2–3, 1), `color`, `opacity` (0.6),
1228
+ * `layer` (`back` default, `front`), `speed` (1). Reduced motion: one
1229
+ * static frame (no falling, twinkling or grain flicker).
1230
+ */
1231
+ interface UsaAmbientElement extends UsaElement {
1232
+ }
1233
+
1234
+ /**
1235
+ * `<usa-splash>` — an app splash / launch screen: shows its content (logo,
1236
+ * spinner) over the page, then leaves with `exit` (`fade` default, `scale`,
1237
+ * `slide-up`, `circle`) once the page has loaded (or when you call
1238
+ * `done()`), but never sooner than `min` ms (600) — no flash.
1239
+ * Attributes: `min`, `exit`, `manual` (wait for `done()`), `label`.
1240
+ * Events: `usa:done`. The page underneath is `aria-busy` until then.
1241
+ * Reduced motion: fades.
1242
+ */
1243
+ interface UsaSplashElement extends UsaElement {
1244
+ done(): Promise<void>;
1245
+ }
1246
+
1247
+ /**
1248
+ * `<usa-auto-skeleton loading>` — automatic skeletons: while `loading` is
1249
+ * set, every text block, image, button and input inside is drawn as a
1250
+ * shimmering placeholder of its own size — no separate skeleton markup.
1251
+ * Remove `loading` (or set `.loading = false`) and the content fades in.
1252
+ * `aria-busy` while loading. Opt elements out with `data-no-skeleton`.
1253
+ * Reduced motion: static placeholders, no shimmer or fade.
1254
+ */
1255
+ interface UsaAutoSkeletonElement extends UsaElement {
1256
+ loading: boolean;
1257
+ }
1258
+
1259
+ /**
1260
+ * `<usa-motion-switch>` — a segmented control letting users choose the
1261
+ * app's motion intensity (Off · Low · Normal · High), persisted.
1262
+ * `role="radiogroup"`; arrow keys move. Attributes: `labels` (comma list),
1263
+ * `label` ("Motion"). Events: `usa:change` (`{ level }`).
1264
+ */
1265
+ interface UsaMotionSwitchElement extends UsaElement {
1266
+ value: MotionIntensity;
1267
+ }
1268
+
1269
+ /**
1270
+ * use-scroll-animate/components/page — page & app-wide effects (v2.7).
1271
+ * Page transitions (`pageTransition()`, `enableMpaTransitions()`,
1272
+ * `themeTransition()`), `<usa-cursor>`, `smoothScroll()` / `scrollToTarget()`,
1273
+ * `<usa-fullpage>`, `<usa-loading-bar>` + `loadingBar`, `<usa-back-to-top>`,
1274
+ * `<usa-ambient>`, `<usa-splash>`, `<usa-auto-skeleton>` and the global motion
1275
+ * intensity (`setMotionIntensity()`, `<usa-motion-switch>`).
1276
+ */
1277
+
1278
+ declare global {
1279
+ interface HTMLElementTagNameMap {
1280
+ 'usa-cursor': UsaCursorElement;
1281
+ 'usa-fullpage': UsaFullpageElement;
1282
+ 'usa-loading-bar': UsaLoadingBarElement;
1283
+ 'usa-back-to-top': UsaBackToTopElement;
1284
+ 'usa-ambient': UsaAmbientElement;
1285
+ 'usa-splash': UsaSplashElement;
1286
+ 'usa-auto-skeleton': UsaAutoSkeletonElement;
1287
+ 'usa-motion-switch': UsaMotionSwitchElement;
1288
+ }
1289
+ }
1290
+
1291
+ /**
1292
+ * Where a step starts on a timeline:
1293
+ * - a number: absolute time in ms
1294
+ * - `'>'` (default): when the previous step ends · `'<'`: when it starts
1295
+ * - `'+=200'` / `'-=200'`: after / overlapping the previous end
1296
+ * - `'<+=100'`: 100ms after the previous step's start
1297
+ * - `'intro'` / `'intro+=150'`: at (or relative to) a label
1298
+ */
1299
+ type TimelinePosition = number | string;
1300
+ interface TimelineStepOptions {
1301
+ /** Duration in ms (default: timeline default, 600). */
1302
+ duration?: number;
1303
+ /** CSS easing (default `cubic-bezier(0.22, 1, 0.36, 1)`). */
1304
+ easing?: string;
1305
+ /** Start position, see `TimelinePosition`. */
1306
+ at?: TimelinePosition;
1307
+ /** ms between targets when the selector matches several elements. */
1308
+ stagger?: number;
1309
+ }
1310
+ interface ScrubOptions {
1311
+ /** Scroll offset (px) before the source's top reaches the viewport bottom where progress starts. */
1312
+ offset?: number;
1313
+ /** Smoothing 0–1 (0 = immediate, default 0). */
1314
+ smooth?: number;
1315
+ }
1316
+ interface Timeline {
1317
+ /** Total length in ms. */
1318
+ readonly duration: number;
1319
+ /** Label positions in ms. */
1320
+ readonly labels: Readonly<Record<string, number>>;
1321
+ /** Current playhead in ms. */
1322
+ readonly time: number;
1323
+ /** Add a step: animate `target` with keyframes or a preset name (`fade-up`, `scale`…). */
1324
+ to(target: string | Element | Element[] | NodeList, frames: Keyframe[] | string, options?: TimelineStepOptions): Timeline;
1325
+ /** Name a position (default: the current end). */
1326
+ label(name: string, at?: TimelinePosition): Timeline;
1327
+ /** Run `fn` when the playhead passes `at`. */
1328
+ call(fn: () => void, at?: TimelinePosition): Timeline;
1329
+ /** Play forwards from the playhead (from 0 when at the end). Resolves at the end. */
1330
+ play(from?: TimelinePosition): Promise<void>;
1331
+ /** Play backwards to 0. */
1332
+ reverse(): Promise<void>;
1333
+ pause(): Timeline;
1334
+ /** Jump to a time (ms) or label. */
1335
+ seek(to: TimelinePosition): Timeline;
1336
+ /** Get or set progress 0–1. */
1337
+ progress(p?: number): number;
1338
+ /** Tie progress to the scroll position of `source` (it moves through the viewport). Returns a stop function. */
1339
+ scrub(source: Element, options?: ScrubOptions): () => void;
1340
+ /** Stop and drop every animation (elements keep their last frame). */
1341
+ cancel(): void;
1342
+ }
1343
+
1344
+ /**
1345
+ * `<usa-timeline>` — declarative choreography. Every descendant with
1346
+ * `data-tl="<preset>"` becomes a step, in document order; `data-at`
1347
+ * (`'-=200'`, `'<'`, `'label+=100'`, ms), `data-duration` and `data-label`
1348
+ * fine-tune it.
1349
+ *
1350
+ * Attributes: `trigger` (`view` default · `click` · `manual`), `scrub`
1351
+ * (progress follows scroll instead of playing), `overlap` (ms each step
1352
+ * overlaps the previous, default 0), `duration` (600), `stagger` (ms),
1353
+ * `repeat` (replay every time it enters the viewport). Methods: `play()`,
1354
+ * `reverse()`, `seek(t)`; property `timeline`. Event `usa:complete`.
1355
+ * Reduced motion: steps appear in their final state.
1356
+ */
1357
+ interface UsaTimelineElement extends UsaElement {
1358
+ readonly timeline: Timeline | null;
1359
+ play(): Promise<void>;
1360
+ reverse(): Promise<void>;
1361
+ seek(to: number | string): void;
1362
+ }
1363
+
1364
+ /**
1365
+ * use-scroll-animate/components/timeline — choreography (v3.1).
1366
+ * `timeline()` chains, overlaps, labels, seeks, reverses and scroll-scrubs
1367
+ * WAAPI animations on one playhead; `<usa-timeline>` builds one from
1368
+ * `data-tl` children.
1369
+ */
1370
+
1371
+ declare global {
1372
+ interface HTMLElementTagNameMap {
1373
+ 'usa-timeline': UsaTimelineElement;
1374
+ }
1375
+ }
1376
+
1377
+ type SwipeDirection = 'left' | 'right' | 'up' | 'down';
1378
+
1379
+ /**
1380
+ * `<usa-swipeable>` — swipe-to-dismiss / swipe actions. The content follows
1381
+ * the finger (rubber-banded past `distance`), flies out on a swipe or a drag
1382
+ * past `distance`, otherwise springs home with the release velocity.
1383
+ *
1384
+ * Attributes: `axis` (`x` default · `y`), `distance` (px, 120), `preset`
1385
+ * (spring), `dismiss` (remove the element after flying out), `disabled`.
1386
+ * Keyboard: Delete/Backspace dismisses, ←/→ swipe. Events `usa:swipe`
1387
+ * (`{ direction }`, cancelable), `usa:dismiss`. Methods `swipe(dir)`, `reset()`.
1388
+ * Reduced motion: no follow / fly-out animation, events still fire.
1389
+ */
1390
+ interface UsaSwipeableElement extends UsaElement {
1391
+ swipe(direction: SwipeDirection): void;
1392
+ reset(): void;
1393
+ readonly offset: number;
1394
+ }
1395
+
1396
+ /**
1397
+ * `<usa-pinch-zoom>` — pinch (two fingers or Ctrl/⌘ + wheel / trackpad
1398
+ * pinch) to zoom its content, pan while zoomed, double-tap to toggle zoom;
1399
+ * scale and position spring back inside the bounds on release.
1400
+ *
1401
+ * Attributes: `min` (1), `max` (4), `double-tap` (zoom level, 2), `preset`.
1402
+ * Keyboard: `+` / `-` / `0`. Property `scale`, method `zoomTo(scale)`.
1403
+ * Event `usa:zoom` (`{ scale }`). Reduced motion: zoom changes instantly.
1404
+ */
1405
+ interface UsaPinchZoomElement extends UsaElement {
1406
+ readonly scale: number;
1407
+ zoomTo(scale: number): void;
1408
+ }
1409
+
1410
+ /**
1411
+ * use-scroll-animate/components/gesture — unified gestures (v3.2).
1412
+ * `gesture()` recognises pan, swipe, pinch, long-press, tap and double-tap
1413
+ * with release velocities for springs; `<usa-swipeable>` (swipe-to-dismiss)
1414
+ * and `<usa-pinch-zoom>` are built on it.
1415
+ */
1416
+
1417
+ declare global {
1418
+ interface HTMLElementTagNameMap {
1419
+ 'usa-swipeable': UsaSwipeableElement;
1420
+ 'usa-pinch-zoom': UsaPinchZoomElement;
1421
+ }
1422
+ }
1423
+
1424
+ /**
1425
+ * `<usa-draw>` — line drawing: every stroke of the SVG inside draws itself.
1426
+ * Attributes: `trigger` (`view` default · `hover` · `click` · `scrub`),
1427
+ * `duration` (1600), `stagger` (0–0.9 share of the timeline, 0.2), `fill`
1428
+ * (fade the fill in after drawing), `repeat`. Method `play()`, property
1429
+ * `progress`, event `usa:complete`. Reduced motion: drawn immediately.
1430
+ */
1431
+ interface UsaDrawElement extends UsaElement {
1432
+ play(): void;
1433
+ progress: number;
1434
+ }
1435
+
1436
+ /**
1437
+ * `<usa-morph>` — morphs an SVG path through a list of shapes.
1438
+ * Put a `<svg><path></path></svg>` inside (one is created otherwise) and set
1439
+ * `paths="M… | M… | M…"` (same command structure morphs smoothly, others
1440
+ * switch at the midpoint). Attributes: `trigger` (`click` default · `hover`
1441
+ * · `auto` · `view`), `interval` (ms for auto, 2000), `duration` (600).
1442
+ * Property `index`, method `next()`, event `usa:change`.
1443
+ * Reduced motion: shapes switch without animating; `auto` does not cycle.
1444
+ */
1445
+ interface UsaMorphElement extends UsaElement {
1446
+ readonly index: number;
1447
+ next(): Promise<void>;
1448
+ }
1449
+
1450
+ /**
1451
+ * `<usa-mask-reveal>` — reveals its content through a growing mask shape.
1452
+ * Attributes: `shape` (`circle` default · `diamond` · `wipe` · `wipe-up` ·
1453
+ * `iris` · `star`), `duration` (900), `delay`, `trigger` (`view` · `hover`
1454
+ * · `click`), `repeat`, `at` (`x% y%` origin for circle). Event
1455
+ * `usa:complete`. Reduced motion: content is shown without the mask.
1456
+ */
1457
+ interface UsaMaskRevealElement extends UsaElement {
1458
+ reveal(): Promise<void>;
1459
+ }
1460
+
1461
+ /**
1462
+ * `<usa-anim-icon name="bell">` — an animated stroke icon that plays its
1463
+ * motion on `trigger` (`hover` default · `click` · `view` · `loop`).
1464
+ * Attributes: `name` (see `ANIM_ICONS`), `size` (24), `label` (accessible
1465
+ * name; decorative when absent). Method `play()`. Reduced motion: static.
1466
+ */
1467
+ interface UsaAnimIconElement extends UsaElement {
1468
+ play(): void;
1469
+ }
1470
+
1471
+ /**
1472
+ * use-scroll-animate/components/svg — SVG animation (v3.3).
1473
+ * `<usa-draw>` (line drawing), `<usa-morph>` (path morph), `<usa-mask-reveal>`
1474
+ * (mask / clip-path reveals) and `<usa-anim-icon>` (animated icons), plus
1475
+ * `interpolatePath()`, `morphTo()`, `drawLines()`.
1476
+ */
1477
+
1478
+ declare global {
1479
+ interface HTMLElementTagNameMap {
1480
+ 'usa-draw': UsaDrawElement;
1481
+ 'usa-morph': UsaMorphElement;
1482
+ 'usa-mask-reveal': UsaMaskRevealElement;
1483
+ 'usa-anim-icon': UsaAnimIconElement;
1484
+ }
1485
+ }
1486
+
1487
+ /**
1488
+ * Shared shell for the WebGL elements: a canvas over (or behind) the
1489
+ * content that renders only while visible and the tab is shown, a DPR cap
1490
+ * of 2, and a graceful fallback (`data-fallback`) when WebGL, the shader
1491
+ * or the image (CORS) is unavailable — the original content / CSS stays.
1492
+ */
1493
+ interface UsaGLElement extends UsaElement {
1494
+ /** `true` once WebGL rendering is active (otherwise the CSS fallback shows). */
1495
+ readonly active: boolean;
1496
+ }
1497
+
1498
+ /**
1499
+ * use-scroll-animate/components/webgl — lightweight canvas / WebGL (v3.4).
1500
+ * `<usa-shader>` (shader backgrounds), `<usa-distort>` (hover image
1501
+ * distortion), `<usa-liquid>` (ripple images) on a tiny single-quad runner
1502
+ * (`glQuad()`), with graceful fallbacks when WebGL is unavailable.
1503
+ */
1504
+
1505
+ declare global {
1506
+ interface HTMLElementTagNameMap {
1507
+ 'usa-shader': UsaGLElement;
1508
+ 'usa-distort': UsaGLElement;
1509
+ 'usa-liquid': UsaGLElement;
1510
+ }
1511
+ }
1512
+
1513
+ /**
1514
+ * `<usa-cube>` — a CSS 3D cube whose up-to-six element children are its faces
1515
+ * (front, right, back, left, top, bottom). Rotate with drag / swipe, arrow
1516
+ * keys, `autoplay` (ms) or `show(face | index)`; spring-driven.
1517
+ * Attributes: `size` (px, 200), `autoplay`, `perspective` (900).
1518
+ * `usa:change` (`{ index, face }`). Reduced motion: instant face switch.
1519
+ */
1520
+ interface UsaCubeElement extends UsaElement {
1521
+ readonly index: number;
1522
+ show(face: number | string): void;
1523
+ next(): void;
1524
+ prev(): void;
1525
+ }
1526
+
1527
+ /**
1528
+ * `<usa-depth>` — depth parallax: children with `data-depth` (-1…1, 0 = the
1529
+ * screen plane) move and scale by depth as the pointer moves, the device
1530
+ * tilts (`orientation`) or the page scrolls (`scroll`).
1531
+ * Attributes: `source` (`pointer` default · `orientation` · `scroll` ·
1532
+ * space-separated mix), `strength` (px at depth 1, 40), `rotate` (max tilt
1533
+ * of the whole scene in deg, 0). `requestPermission()` for iOS motion.
1534
+ * Reduced motion: layers stay flat.
1535
+ */
1536
+ interface UsaDepthElement extends UsaElement {
1537
+ /** Current -1…1 input. */
1538
+ readonly tilt: {
1539
+ x: number;
1540
+ y: number;
1541
+ };
1542
+ requestPermission(): Promise<boolean>;
1543
+ }
1544
+
1545
+ /**
1546
+ * use-scroll-animate/components/depth — 3D (v3.5).
1547
+ * `<usa-cube>` (CSS 3D cube), `<usa-depth>` (layered depth parallax driven by
1548
+ * pointer, device orientation or scroll) and `deviceTilt()`. The 3D ring
1549
+ * carousel is `<usa-carousel-3d>` in `components/cards`.
1550
+ */
1551
+
1552
+ declare global {
1553
+ interface HTMLElementTagNameMap {
1554
+ 'usa-cube': UsaCubeElement;
1555
+ 'usa-depth': UsaDepthElement;
1556
+ }
1557
+ }
1558
+
1559
+ /**
1560
+ * `<usa-auto-animate>` — wraps `autoAnimate()`: any change to its children
1561
+ * (add, remove, re-order, filter, size) animates. Attributes `duration`
1562
+ * (300), `no-scale`. Works for lists and CSS grids alike.
1563
+ */
1564
+ interface UsaAutoAnimateElement extends UsaElement {
1565
+ enable(): void;
1566
+ disable(): void;
1567
+ }
1568
+ /**
1569
+ * `<usa-masonry>` — a masonry (Pinterest-style) grid: children are placed in
1570
+ * the shortest column and glide to new spots when the width, the items or
1571
+ * their sizes change. Attributes `columns` (fixed count) or `min` (min
1572
+ * column width px, 220), `gap` (16). Without JS layout support it is a
1573
+ * plain CSS multi-column flow. Reduced motion: no glide.
1574
+ */
1575
+ interface UsaMasonryElement extends UsaElement {
1576
+ layout(): void;
1577
+ }
1578
+
1579
+ /**
1580
+ * use-scroll-animate/components/layout — layout animation (v3.6).
1581
+ * `autoAnimate()` / `<usa-auto-animate>` (list & grid reflow),
1582
+ * `<usa-masonry>`, and `sharedTransition()` for shared-element transitions
1583
+ * (View Transitions API with a FLIP fallback).
1584
+ */
1585
+
1586
+ declare global {
1587
+ interface HTMLElementTagNameMap {
1588
+ 'usa-auto-animate': UsaAutoAnimateElement;
1589
+ 'usa-masonry': UsaMasonryElement;
1590
+ }
1591
+ }
1592
+
1593
+ /** The component categories and their default tags. */
1594
+ declare const COMPONENT_CATEGORIES: {
1595
+ readonly reveal: readonly ["usa-reveal", "usa-stagger", "usa-scroll-progress", "usa-scrolly"];
1596
+ readonly text: readonly ["usa-typewriter", "usa-split-text", "usa-scramble", "usa-counter", "usa-shimmer-text", "usa-text-rotate", "usa-wave-text", "usa-glitch", "usa-gradient-text", "usa-handwriting", "usa-scroll-highlight"];
1597
+ readonly interaction: readonly ["usa-ripple", "usa-magnetic", "usa-tilt", "usa-spotlight", "usa-press", "usa-toggle"];
1598
+ readonly feedback: readonly ["usa-spinner", "usa-skeleton", "usa-progress", "usa-toaster", "usa-check"];
1599
+ readonly background: readonly ["usa-aurora", "usa-particles", "usa-grain", "usa-marquee", "usa-acrylic", "usa-grid-glow", "usa-blobs", "usa-water-ripple", "usa-dot-network"];
1600
+ readonly transitions: readonly ["usa-dialog", "usa-accordion", "usa-flip-list", "usa-view-switch"];
1601
+ readonly physics: readonly ["usa-spring", "usa-draggable", "usa-overscroll"];
1602
+ readonly cards: readonly ["usa-card", "usa-card-stack", "usa-sticky-stack", "usa-carousel-3d"];
1603
+ readonly click: readonly ["usa-click", "usa-button", "usa-icon-morph", "usa-like", "usa-hold", "usa-double-tap", "usa-checkbox"];
1604
+ readonly ui: readonly ["usa-tabs", "usa-drawer", "usa-bottom-sheet", "usa-pull-refresh", "usa-fab", "usa-navbar", "usa-slider", "usa-rating", "usa-tooltip", "usa-popover", "usa-badge", "usa-avatar-stack"];
1605
+ readonly page: readonly ["usa-cursor", "usa-fullpage", "usa-loading-bar", "usa-back-to-top", "usa-ambient", "usa-splash", "usa-auto-skeleton", "usa-motion-switch"];
1606
+ readonly timeline: readonly ["usa-timeline"];
1607
+ readonly gesture: readonly ["usa-swipeable", "usa-pinch-zoom"];
1608
+ readonly svg: readonly ["usa-draw", "usa-morph", "usa-mask-reveal", "usa-anim-icon"];
1609
+ readonly webgl: readonly ["usa-shader", "usa-distort", "usa-liquid"];
1610
+ readonly depth: readonly ["usa-cube", "usa-depth"];
1611
+ readonly layout: readonly ["usa-auto-animate", "usa-masonry"];
1612
+ };
1613
+ type ComponentCategory = keyof typeof COMPONENT_CATEGORIES;
1614
+
1615
+ /**
1616
+ * Framework-neutral binding for `<usa-*>` elements (v3.8): set DOM
1617
+ * **properties** and listen to `usa:*` events, with update / destroy — the
1618
+ * shape Svelte actions, Solid directives and Angular directives all share.
1619
+ */
1620
+ interface UsaBinding {
1621
+ /** DOM properties to set (`checked`, `value`, `open`, `index`…). */
1622
+ props?: Record<string, unknown>;
1623
+ /** Event handlers by name; `change` is shorthand for `usa:change`. */
1624
+ on?: Record<string, (e: CustomEvent) => void>;
1625
+ }
1626
+ /** Normalise an event key: `change` → `usa:change`, `usa:change` stays. */
1627
+ declare const usaEventName: (k: string) => string;
1628
+ /** Bind properties and `usa:*` listeners to an element; returns `{ update, destroy }`. */
1629
+ declare function bindUsa(el: HTMLElement, binding?: UsaBinding): {
1630
+ update(b: UsaBinding): void;
1631
+ destroy(): void;
1632
+ };
1633
+
1634
+ /**
1635
+ * use-scroll-animate/components/jsx — JSX typings for the raw `<usa-*>` tags (v2.9).
1636
+ *
1637
+ * ```ts
1638
+ * // src/usa-jsx.d.ts (React 18/19)
1639
+ * import type { UsaIntrinsicElements } from 'use-scroll-animate/components/jsx';
1640
+ * declare module 'react' { namespace JSX { interface IntrinsicElements extends UsaIntrinsicElements {} } }
1641
+ * // Solid / Preact / other JSX: extend their JSX.IntrinsicElements the same way.
1642
+ * ```
1643
+ */
1644
+
1645
+ type Tags = (typeof COMPONENT_CATEGORIES)[keyof typeof COMPONENT_CATEGORIES][number];
1646
+ /** Attributes accepted by every `<usa-*>` element (all component attributes are strings / booleans). */
1647
+ interface UsaAttributes {
1648
+ [attr: string]: unknown;
1649
+ class?: string;
1650
+ className?: string;
1651
+ id?: string;
1652
+ style?: unknown;
1653
+ slot?: string;
1654
+ variant?: 'minimal' | 'neon' | 'glass' | 'brutalist' | 'fluent' | 'material' | (string & {});
1655
+ children?: unknown;
1656
+ ref?: unknown;
1657
+ }
1658
+ type UsaIntrinsicElements = {
1659
+ [K in Tags]: UsaAttributes;
1660
+ };
1661
+
1662
+ /**
1663
+ * use-scroll-animate/components/solid — Solid integration (v3.8).
1664
+ * Solid renders custom elements natively: set properties with `prop:` and
1665
+ * listen with `on:` (`<usa-toggle prop:checked={on()} on:usa:change={…}>`).
1666
+ * This entry adds `defineUsa()` (client only, SolidStart-safe), a `usa`
1667
+ * directive for `use:usa={{ props, on }}`, and JSX types.
1668
+ *
1669
+ * ```tsx
1670
+ * import { defineUsa, usa } from 'use-scroll-animate/components/solid';
1671
+ * import type {} from 'use-scroll-animate/components/solid'; // JSX types
1672
+ * onMount(() => defineUsa());
1673
+ * false && usa; // keep the directive import (Solid convention)
1674
+ * <usa-card use:usa={{ on: { flip: (e) => console.log(e.detail) } }} effect="flip">…</usa-card>
1675
+ * ```
1676
+ */
1677
+
1678
+ /**
1679
+ * Solid directive (`use:usa`). Solid calls it with the element and an
1680
+ * accessor; the binding is read once on mount and re-read whenever
1681
+ * `refresh()` on the returned handle is called (or wrap it in `createEffect`).
1682
+ */
1683
+ declare function usa(el: HTMLElement, accessor: () => UsaBinding | undefined): {
1684
+ refresh(): void;
1685
+ destroy(): void;
1686
+ };
1687
+ /** Register the elements (all, or some categories) — call from `onMount` in SSR apps. */
1688
+ declare function defineUsa(categories?: ComponentCategory[]): void;
1689
+ /** JSX intrinsic elements for Solid (same attribute types as the React/Preact ones). */
1690
+ type SolidUsaIntrinsicElements = UsaIntrinsicElements;
1691
+
1692
+ export { bindUsa, defineUsa, usa, usaEventName };
1693
+ export type { SolidUsaIntrinsicElements, UsaBinding };