use-scroll-animate 2.0.1 → 2.2.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 (66) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/README.md +31 -1
  3. package/README_ja.md +18 -0
  4. package/README_zh.md +31 -0
  5. package/dist/chunks/base-BiTc85p_.cjs +232 -0
  6. package/dist/chunks/base-BiTc85p_.cjs.map +1 -0
  7. package/dist/chunks/base-CFtnmfli.js +219 -0
  8. package/dist/chunks/base-CFtnmfli.js.map +1 -0
  9. package/dist/components/background.cjs +395 -0
  10. package/dist/components/background.cjs.map +1 -0
  11. package/dist/components/background.css +7 -0
  12. package/dist/components/background.d.cts +132 -0
  13. package/dist/components/background.d.ts +132 -0
  14. package/dist/components/background.js +387 -0
  15. package/dist/components/background.js.map +1 -0
  16. package/dist/components/feedback.cjs +444 -0
  17. package/dist/components/feedback.cjs.map +1 -0
  18. package/dist/components/feedback.css +7 -0
  19. package/dist/components/feedback.d.cts +170 -0
  20. package/dist/components/feedback.d.ts +170 -0
  21. package/dist/components/feedback.js +434 -0
  22. package/dist/components/feedback.js.map +1 -0
  23. package/dist/components/interaction.cjs +426 -0
  24. package/dist/components/interaction.cjs.map +1 -0
  25. package/dist/components/interaction.css +8 -0
  26. package/dist/components/interaction.d.cts +142 -0
  27. package/dist/components/interaction.d.ts +142 -0
  28. package/dist/components/interaction.js +417 -0
  29. package/dist/components/interaction.js.map +1 -0
  30. package/dist/components/reveal.cjs +360 -0
  31. package/dist/components/reveal.cjs.map +1 -0
  32. package/dist/components/reveal.css +5 -0
  33. package/dist/components/reveal.d.cts +132 -0
  34. package/dist/components/reveal.d.ts +132 -0
  35. package/dist/components/reveal.js +350 -0
  36. package/dist/components/reveal.js.map +1 -0
  37. package/dist/components/text.cjs +528 -0
  38. package/dist/components/text.cjs.map +1 -0
  39. package/dist/components/text.css +7 -0
  40. package/dist/components/text.d.cts +164 -0
  41. package/dist/components/text.d.ts +164 -0
  42. package/dist/components/text.js +517 -0
  43. package/dist/components/text.js.map +1 -0
  44. package/dist/components/transitions.cjs +546 -0
  45. package/dist/components/transitions.cjs.map +1 -0
  46. package/dist/components/transitions.css +6 -0
  47. package/dist/components/transitions.d.cts +180 -0
  48. package/dist/components/transitions.d.ts +180 -0
  49. package/dist/components/transitions.js +536 -0
  50. package/dist/components/transitions.js.map +1 -0
  51. package/dist/components.cjs +106 -0
  52. package/dist/components.cjs.map +1 -0
  53. package/dist/components.css +30 -0
  54. package/dist/components.d.cts +741 -0
  55. package/dist/components.d.ts +741 -0
  56. package/dist/components.js +61 -0
  57. package/dist/components.js.map +1 -0
  58. package/dist/components.umd.js +22 -0
  59. package/dist/components.umd.js.map +1 -0
  60. package/docs/API.md +2 -0
  61. package/docs/components.md +155 -0
  62. package/docs/images/showcase-detail.png +0 -0
  63. package/docs/images/showcase-grid.png +0 -0
  64. package/docs/images/showcase-mobile.png +0 -0
  65. package/docs/windows-apps.md +108 -0
  66. package/package.json +93 -5
@@ -0,0 +1,741 @@
1
+ /**
2
+ * use-scroll-animate/components — shared base for the `<usa-*>` custom elements.
3
+ *
4
+ * Everything here is lazy: nothing touches `window`, `document`,
5
+ * `HTMLElement` or `matchMedia` at import time, so the components can be
6
+ * imported during SSR (Next, Nuxt, Astro…) and in Electron/Tauri preload
7
+ * scripts. Classes are created the first time a `define*()` function runs.
8
+ */
9
+ interface ComponentsConfig {
10
+ /**
11
+ * Inject each component's CSS when it is defined (default `true`). Uses a
12
+ * constructable stylesheet (`document.adoptedStyleSheets`, which a strict
13
+ * `style-src` CSP does not block) and falls back to a `<style>` tag. Set
14
+ * to `false` when you load `use-scroll-animate/components.css` yourself.
15
+ */
16
+ injectStyles?: boolean;
17
+ /**
18
+ * `'user'` (default) follows `prefers-reduced-motion`; `'reduce'` always
19
+ * uses the reduced variants (e.g. a kiosk / battery-saver mode);
20
+ * `'no-preference'` ignores the OS setting (only for demos — respect your users).
21
+ */
22
+ reducedMotion?: 'user' | 'reduce' | 'no-preference';
23
+ }
24
+ /** Change global component settings (call before `define*()` for `injectStyles`). */
25
+ declare function configureComponents(options: ComponentsConfig): void;
26
+ /** `true` when animations should be reduced (OS setting or `configureComponents`). */
27
+ declare function prefersReducedMotion(): boolean;
28
+ /**
29
+ * Members shared by every `<usa-*>` element. Attribute helpers, a cleanup
30
+ * bag that is emptied on disconnect, and motion helpers that degrade to the
31
+ * final state without WAAPI or under reduced motion.
32
+ */
33
+ interface UsaElement extends HTMLElement {
34
+ /** `true` while reduced motion applies to this element. */
35
+ readonly reduced: boolean;
36
+ }
37
+
38
+ /** Entrance effects shared by `<usa-reveal>` and `<usa-stagger>` (transform / opacity / filter only). */
39
+ 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"];
40
+ type RevealEffect = (typeof REVEAL_EFFECTS)[number];
41
+ /** Keyframes from the effect to the natural state. */
42
+ declare function revealKeyframes(effect: string, distance?: number): Keyframe[];
43
+
44
+ /**
45
+ * `<usa-reveal>` — reveals its content when it scrolls into view.
46
+ *
47
+ * Attributes: `effect` (see {@link RevealEffect}, default `fade-up`),
48
+ * `duration` (ms, 700), `delay` (ms, 0), `distance` (px, 32), `easing`,
49
+ * `threshold` (0–1, 0.15), `root-margin`, `repeat` (hide again when it
50
+ * leaves, replay on re-entry). Events: `usa:enter`, `usa:leave`, `usa:complete`.
51
+ */
52
+ interface UsaRevealElement extends UsaElement {
53
+ effect: RevealEffect | string;
54
+ /** Play the entrance now (also called automatically on enter). */
55
+ reveal(): Promise<void>;
56
+ /** Hide again so the next `reveal()` replays the entrance. */
57
+ reset(): void;
58
+ readonly revealed: boolean;
59
+ }
60
+ declare function defineReveal(tag?: string): CustomElementConstructor | undefined;
61
+
62
+ /**
63
+ * `<usa-stagger>` — reveals its direct children one after another when the
64
+ * list scrolls into view.
65
+ *
66
+ * Attributes: `effect` (default `fade-up`), `interval` (ms between children,
67
+ * 70), `duration` (600), `delay` (0), `distance` (24), `easing`,
68
+ * `threshold` (0.1), `repeat`. Events: `usa:enter`, `usa:complete`.
69
+ */
70
+ interface UsaStaggerElement extends UsaElement {
71
+ reveal(): Promise<void>;
72
+ reset(): void;
73
+ }
74
+ declare function defineStagger(tag?: string): CustomElementConstructor | undefined;
75
+
76
+ /**
77
+ * `<usa-scroll-progress>` — a reading-progress bar.
78
+ *
79
+ * Attributes: `target` (CSS selector of an article to track; default the
80
+ * whole page), `position` (`top` | `bottom` | `inline`, default `top`),
81
+ * `label` (accessible name, default "Reading progress"). Style with
82
+ * `--usa-progress-color`, `--usa-progress-height`, `--usa-progress-track`.
83
+ * Exposes the progress (0–1) as `--usa-progress` on the element and as the
84
+ * `progress` property. Event: `usa:progress` (`detail.progress`).
85
+ *
86
+ * Writes only `transform: scaleX()` (compositor-friendly); reads layout
87
+ * once per animation frame, and only while scrolling.
88
+ */
89
+ interface UsaScrollProgressElement extends UsaElement {
90
+ readonly progress: number;
91
+ /** Re-measure (e.g. after content loaded). */
92
+ update(): void;
93
+ }
94
+ /** Progress (0–1) of `target` scrolling through the viewport, or of the page. */
95
+ declare function readScrollProgress(target?: Element | null): number;
96
+ declare function defineScrollProgress(tag?: string): CustomElementConstructor | undefined;
97
+
98
+ /**
99
+ * `<usa-scrolly>` — sticky scrollytelling. A child marked `data-sticky`
100
+ * stays pinned while the `[data-step]` children scroll past; the step that
101
+ * crosses the trigger line becomes active.
102
+ *
103
+ * Attributes: `offset` (trigger line as a fraction of the viewport height,
104
+ * default 0.5), `active` (reflected index of the active step). The active
105
+ * step gets `data-active`; the host gets `--usa-step` and `data-step-name`
106
+ * (the step's `data-step` value). Event: `usa:step` (`detail.index`,
107
+ * `detail.step`, `detail.name`).
108
+ */
109
+ interface UsaScrollyElement extends UsaElement {
110
+ readonly active: number;
111
+ readonly steps: HTMLElement[];
112
+ }
113
+ declare function defineScrolly(tag?: string): CustomElementConstructor | undefined;
114
+
115
+ /**
116
+ * use-scroll-animate/components/reveal — entrance & scroll reveal components.
117
+ * `<usa-reveal>`, `<usa-stagger>`, `<usa-scroll-progress>`, `<usa-scrolly>`.
118
+ */
119
+
120
+ /** Register every component of this category under its default tag. */
121
+ declare function defineRevealComponents(): void;
122
+ declare global {
123
+ interface HTMLElementTagNameMap {
124
+ 'usa-reveal': UsaRevealElement;
125
+ 'usa-stagger': UsaStaggerElement;
126
+ 'usa-scroll-progress': UsaScrollProgressElement;
127
+ 'usa-scrolly': UsaScrollyElement;
128
+ }
129
+ }
130
+
131
+ /**
132
+ * `<usa-typewriter>` — types text character by character, optionally cycling
133
+ * through several phrases (typing, pausing, deleting).
134
+ *
135
+ * Attributes: `text` (default: the element's text), `words` (phrases
136
+ * separated by `|`, overrides `text`), `speed` (ms per character, 55),
137
+ * `delete-speed` (ms, 30), `pause` (ms before deleting, 1400), `delay`
138
+ * (ms, 0), `loop`, `cursor="false"` to hide the caret, `start`
139
+ * (`view` | `load` | `manual`, default `view`). The full text is exposed to
140
+ * assistive tech via `aria-label`. Event: `usa:complete` (one pass done).
141
+ * Reduced motion: the text appears at once.
142
+ */
143
+ interface UsaTypewriterElement extends UsaElement {
144
+ /** Phrases being typed. */
145
+ readonly phrases: string[];
146
+ start(): void;
147
+ stop(): void;
148
+ restart(): void;
149
+ }
150
+ declare function defineTypewriter(tag?: string): CustomElementConstructor | undefined;
151
+
152
+ /**
153
+ * `<usa-split-text>` — splits its text into words or characters and reveals
154
+ * them in a cascade (pure CSS animation per unit, transform / opacity /
155
+ * filter only). Words never break across lines.
156
+ *
157
+ * Attributes: `by` (`chars` | `words`, default `chars`), `effect`
158
+ * (`rise` | `fade` | `blur` | `flip` | `pop`, default `rise`), `stagger`
159
+ * (ms between units, 28 for chars / 70 for words), `duration` (ms, 620),
160
+ * `delay` (ms, 0), `trigger` (`view` | `load` | `manual`, default `view`),
161
+ * `repeat`. The original text stays readable via `aria-label`.
162
+ * Event: `usa:complete`.
163
+ */
164
+ interface UsaSplitTextElement extends UsaElement {
165
+ readonly units: HTMLElement[];
166
+ play(): void;
167
+ reset(): void;
168
+ }
169
+ declare function defineSplitText(tag?: string): CustomElementConstructor | undefined;
170
+
171
+ /**
172
+ * `<usa-scramble>` — "decodes" text out of random glyphs, left to right.
173
+ *
174
+ * Attributes: `text` (default: the element's text), `duration` (ms, 900),
175
+ * `chars` (glyph set), `trigger` (`view` | `hover` | `load` | `manual`,
176
+ * default `view`). Spaces and punctuation stay in place. Uses a monospace-
177
+ * friendly fixed width per glyph only if you style it so; the element sets
178
+ * nothing that causes reflow beyond its own text. Event: `usa:complete`.
179
+ * Reduced motion: shows the final text.
180
+ */
181
+ interface UsaScrambleElement extends UsaElement {
182
+ play(): Promise<void>;
183
+ }
184
+ /** One frame of the scramble: the first `progress` share is resolved. */
185
+ declare function scrambleFrame(text: string, progress: number, glyphs?: string, rnd?: () => number): string;
186
+ declare function defineScramble(tag?: string): CustomElementConstructor | undefined;
187
+
188
+ /**
189
+ * `<usa-counter>` — counts up (or down) to a number when it scrolls into view.
190
+ *
191
+ * Attributes: `to` (target, required), `from` (0), `duration` (ms, 1600),
192
+ * `decimals` (0), `locale` (default: the document language), `prefix`,
193
+ * `suffix`, `grouping="false"` (no thousands separators), `start`
194
+ * (`view` | `load` | `manual`). Setting the `value` property animates from
195
+ * the current value — handy for live dashboards. Uses tabular digits so
196
+ * the width does not jump. Event: `usa:complete`. Reduced motion: jumps.
197
+ */
198
+ interface UsaCounterElement extends UsaElement {
199
+ /** Current target; setting it animates to the new number. */
200
+ value: number;
201
+ /** Animate to `to` (default: the `to` attribute). */
202
+ play(to?: number): Promise<void>;
203
+ format(n: number): string;
204
+ }
205
+ /** easeOutExpo */
206
+ declare const easeOutExpo: (t: number) => number;
207
+ declare function defineCounter(tag?: string): CustomElementConstructor | undefined;
208
+
209
+ /**
210
+ * `<usa-shimmer-text>` — a light sweep across gradient-filled text (CSS
211
+ * only; the element just maps attributes to custom properties).
212
+ *
213
+ * Attributes: `duration` (ms, 2600), `color` (base text colour), `shine`
214
+ * (highlight colour), `angle` (deg, 110). Or style `--usa-shimmer-*`
215
+ * directly. Reduced motion: static gradient text.
216
+ */
217
+ type UsaShimmerTextElement = UsaElement;
218
+ declare function defineShimmerText(tag?: string): CustomElementConstructor | undefined;
219
+
220
+ /**
221
+ * `<usa-text-rotate>` — cycles through words in place ("Build *fast* /
222
+ * *small* / *typed* apps"). All words share one grid cell, so the width is
223
+ * that of the longest word and nothing around it reflows.
224
+ *
225
+ * Attributes: `words` (separated by `|`, default: the element's text split
226
+ * on `|`), `interval` (ms, 2200), `effect` (`slide` | `fade` | `flip` |
227
+ * `blur`, default `slide`), `paused`. Pauses while off-screen and on hover
228
+ * is not needed. Event: `usa:change` (`detail.index`, `detail.word`).
229
+ * Reduced motion: words still change, without movement (fade only).
230
+ */
231
+ interface UsaTextRotateElement extends UsaElement {
232
+ readonly index: number;
233
+ next(): void;
234
+ }
235
+ declare function defineTextRotate(tag?: string): CustomElementConstructor | undefined;
236
+
237
+ /**
238
+ * use-scroll-animate/components/text — text effects.
239
+ * `<usa-typewriter>`, `<usa-split-text>`, `<usa-scramble>`, `<usa-counter>`,
240
+ * `<usa-shimmer-text>`, `<usa-text-rotate>`.
241
+ */
242
+
243
+ /** Register every component of this category under its default tag. */
244
+ declare function defineTextComponents(): void;
245
+ declare global {
246
+ interface HTMLElementTagNameMap {
247
+ 'usa-typewriter': UsaTypewriterElement;
248
+ 'usa-split-text': UsaSplitTextElement;
249
+ 'usa-scramble': UsaScrambleElement;
250
+ 'usa-counter': UsaCounterElement;
251
+ 'usa-shimmer-text': UsaShimmerTextElement;
252
+ 'usa-text-rotate': UsaTextRotateElement;
253
+ }
254
+ }
255
+
256
+ /**
257
+ * `<usa-ripple>` — an ink ripple from the pointer (or the centre, for
258
+ * keyboard presses) on whatever it wraps: buttons, list items, cards.
259
+ *
260
+ * Attributes: `color` (default `currentColor`), `opacity` (0.22),
261
+ * `duration` (ms, 550), `centered`, `disabled`. Clips its content to its
262
+ * own border radius. Reduced motion: a brief highlight instead of the wave.
263
+ */
264
+ interface UsaRippleElement extends UsaElement {
265
+ /** Spawn a ripple at client coordinates (default: centre). */
266
+ ripple(x?: number, y?: number): void;
267
+ }
268
+ declare function defineRipple(tag?: string): CustomElementConstructor | undefined;
269
+
270
+ /**
271
+ * `<usa-magnetic>` — its content leans toward the pointer when the pointer
272
+ * comes near, and springs back when it leaves (great for CTAs and icons).
273
+ *
274
+ * Attributes: `strength` (0–1 share of the pointer offset, 0.35), `radius`
275
+ * (px of attraction beyond the element's edge, 60), `disabled`. Only on
276
+ * devices with a fine pointer that hovers; off under reduced motion.
277
+ * Writes one `transform` per frame through `--usa-mx` / `--usa-my`.
278
+ */
279
+ type UsaMagneticElement = UsaElement;
280
+ declare function defineMagnetic(tag?: string): CustomElementConstructor | undefined;
281
+
282
+ /**
283
+ * `<usa-tilt>` — a 3D card that tilts toward the pointer, with an optional
284
+ * glare highlight that follows it.
285
+ *
286
+ * Attributes: `max` (deg, 10), `scale` (1.03 while hovered), `perspective`
287
+ * (px, 900), `glare` (add the light reflection), `reverse` (tilt away),
288
+ * `disabled`. Off under reduced motion. Exposes `--usa-tilt-x` /
289
+ * `--usa-tilt-y` (−1…1) for parallax layers inside the card.
290
+ */
291
+ type UsaTiltElement = UsaElement;
292
+ declare function defineTilt(tag?: string): CustomElementConstructor | undefined;
293
+
294
+ /**
295
+ * `<usa-spotlight>` — the Windows Fluent "Reveal highlight": a soft light
296
+ * follows the pointer across a group of items, lighting up their borders
297
+ * (even of neighbours) and the background of the hovered one. Put buttons,
298
+ * tiles or menu items inside; each direct child is an item (or mark items
299
+ * with `data-spotlight` to pick them yourself).
300
+ *
301
+ * Attributes: `size` (px, radius of the light, 160), `color` (default a
302
+ * translucent white), `border` (px width of the lit border, 1),
303
+ * `no-fill` (only light the borders). Not a motion effect, so it stays on
304
+ * under reduced motion; off on touch-only devices.
305
+ */
306
+ type UsaSpotlightElement = UsaElement;
307
+ declare function defineSpotlight(tag?: string): CustomElementConstructor | undefined;
308
+
309
+ /**
310
+ * `<usa-press>` — tactile press feedback: content dips while pressed and
311
+ * springs back on release (the Fluent "pointer down" scale), or bounces once
312
+ * on click with `bounce`.
313
+ *
314
+ * Attributes: `scale` (pressed scale, 0.95), `bounce` (overshoot on
315
+ * release), `disabled`. Works with mouse, touch, pen and Space/Enter.
316
+ * Reduced motion: a subtle dim instead of scaling.
317
+ */
318
+ interface UsaPressElement extends UsaElement {
319
+ readonly pressed: boolean;
320
+ }
321
+ declare function definePress(tag?: string): CustomElementConstructor | undefined;
322
+
323
+ /**
324
+ * `<usa-toggle>` — an accessible switch whose knob stretches while pressed
325
+ * and glides across (the Windows 11 / iOS toggle). `role="switch"`,
326
+ * keyboard (Space / Enter), and form-associated where `ElementInternals`
327
+ * exists (submits `value`, default `"on"`, under `name` when checked).
328
+ *
329
+ * Attributes: `checked`, `disabled`, `name`, `value`, `label`
330
+ * (accessible name if there is no `aria-label` / `<label>`). Events:
331
+ * `change` and `usa:change` (`detail.checked`). Reduced motion: no glide.
332
+ */
333
+ interface UsaToggleElement extends UsaElement {
334
+ checked: boolean;
335
+ disabled: boolean;
336
+ toggle(force?: boolean): void;
337
+ }
338
+ declare function defineToggle(tag?: string): CustomElementConstructor | undefined;
339
+
340
+ /**
341
+ * use-scroll-animate/components/interaction — micro-interactions.
342
+ * `<usa-ripple>`, `<usa-magnetic>`, `<usa-tilt>`, `<usa-spotlight>`,
343
+ * `<usa-press>`, `<usa-toggle>`.
344
+ */
345
+
346
+ /** Register every component of this category under its default tag. */
347
+ declare function defineInteractionComponents(): void;
348
+ declare global {
349
+ interface HTMLElementTagNameMap {
350
+ 'usa-ripple': UsaRippleElement;
351
+ 'usa-magnetic': UsaMagneticElement;
352
+ 'usa-tilt': UsaTiltElement;
353
+ 'usa-spotlight': UsaSpotlightElement;
354
+ 'usa-press': UsaPressElement;
355
+ 'usa-toggle': UsaToggleElement;
356
+ }
357
+ }
358
+
359
+ declare const SPINNER_VARIANTS: readonly ["fluent", "windows", "ring", "dots", "pulse", "bars"];
360
+ type SpinnerVariant = (typeof SPINNER_VARIANTS)[number];
361
+ /**
362
+ * `<usa-spinner>` — indeterminate loading indicators, pure CSS animations
363
+ * of `transform` / `opacity` (plus an SVG stroke for `fluent`).
364
+ *
365
+ * Variants (`variant`): `fluent` (default — the WinUI / Windows 11
366
+ * ProgressRing arc), `windows` (the Windows 10 boot "orbiting dots"),
367
+ * `ring` (classic border spinner), `dots` (three bouncing dots / typing
368
+ * indicator), `pulse` (expanding ripple), `bars` (equalizer).
369
+ * Attributes: `size` (px, 32), `label` (accessible name, "Loading"),
370
+ * `paused`. Colour follows `color` / `--usa-spinner-color`.
371
+ * `role="progressbar"` without a value (indeterminate). Reduced motion:
372
+ * a slow opacity pulse instead of movement.
373
+ */
374
+ interface UsaSpinnerElement extends UsaElement {
375
+ variant: SpinnerVariant;
376
+ }
377
+ declare function defineSpinner(tag?: string): CustomElementConstructor | undefined;
378
+
379
+ /**
380
+ * `<usa-skeleton>` — shimmering placeholders while content loads. With
381
+ * `loading`, it shows `lines` bars (or one block of `width` × `height`,
382
+ * or a `circle`) and hides its children; remove `loading` and the real
383
+ * content fades in.
384
+ *
385
+ * Attributes: `loading`, `lines` (3), `width`, `height` (CSS lengths),
386
+ * `circle`, `radius`, `avatar` (circle + lines, like a list row).
387
+ * `aria-busy` follows `loading`. Reduced motion: no shimmer sweep.
388
+ */
389
+ interface UsaSkeletonElement extends UsaElement {
390
+ loading: boolean;
391
+ }
392
+ declare function defineSkeleton(tag?: string): CustomElementConstructor | undefined;
393
+
394
+ /**
395
+ * `<usa-progress>` — a linear progress bar. Determinate (`value` / `max`)
396
+ * bars glide between values with `transform: scaleX()`; without a value,
397
+ * or with `indeterminate`, it shows the Windows Fluent indeterminate
398
+ * animation (two sliding segments).
399
+ *
400
+ * Attributes: `value`, `max` (100), `indeterminate`, `state`
401
+ * (`paused` | `error` — the WinUI states), `label` (accessible name).
402
+ * `role="progressbar"` with `aria-valuenow` when determinate.
403
+ * Reduced motion: no glide; indeterminate becomes a gentle pulse.
404
+ */
405
+ interface UsaProgressElement extends UsaElement {
406
+ value: number | null;
407
+ max: number;
408
+ /** 0–1, or `null` when indeterminate. */
409
+ readonly ratio: number | null;
410
+ }
411
+ declare function defineProgress(tag?: string): CustomElementConstructor | undefined;
412
+
413
+ type ToastType = 'info' | 'success' | 'warning' | 'error';
414
+ interface ToastOptions {
415
+ /** ms before it hides itself; `0` keeps it until closed (default 4000). */
416
+ duration?: number;
417
+ type?: ToastType;
418
+ /** Optional action button. */
419
+ action?: {
420
+ label: string;
421
+ onClick: () => void;
422
+ };
423
+ /** Show a close button (default `true`). */
424
+ dismissible?: boolean;
425
+ /** The toaster to use (default: the first `<usa-toaster>`, created if missing). */
426
+ toaster?: UsaToasterElement | string;
427
+ }
428
+ interface ToastHandle {
429
+ element: HTMLElement;
430
+ close(): Promise<void>;
431
+ }
432
+ /**
433
+ * `<usa-toaster>` — the region toasts slide into (`role="region"`, each
434
+ * toast `role="status"`, errors `role="alert"`). Toasts pause their timer
435
+ * while hovered or focused, and the stack re-flows with a FLIP animation.
436
+ *
437
+ * Attributes: `position` (`bottom-right` default, `bottom-left`,
438
+ * `bottom-center`, `top-right`, `top-left`, `top-center`), `max` (visible
439
+ * toasts, 4), `label` (region name, "Notifications").
440
+ * Reduced motion: toasts fade instead of sliding.
441
+ */
442
+ interface UsaToasterElement extends UsaElement {
443
+ show(message: string, options?: ToastOptions): ToastHandle;
444
+ clear(): void;
445
+ }
446
+ declare function defineToaster(tag?: string): CustomElementConstructor | undefined;
447
+ /**
448
+ * Show a toast. Defines `<usa-toaster>` and adds one to `<body>` if the
449
+ * page has none. Returns a handle with `close()`. No-op on the server.
450
+ *
451
+ * ```js
452
+ * toast('Saved', { type: 'success' });
453
+ * ```
454
+ */
455
+ declare function toast(message: string, options?: ToastOptions): ToastHandle | null;
456
+
457
+ /**
458
+ * `<usa-check>` — an animated result icon: the circle draws itself, then the
459
+ * check mark (or cross / exclamation) strokes in with a little pop.
460
+ *
461
+ * Attributes: `variant` (`success` default, `error`, `warning`), `size`
462
+ * (px, 56), `start` (`view` default | `load` | `manual`), `label`
463
+ * (accessible name, e.g. "Payment complete"; the icon is decorative
464
+ * without it). Event: `usa:complete`. Reduced motion: drawn instantly.
465
+ */
466
+ interface UsaCheckElement extends UsaElement {
467
+ play(): Promise<void>;
468
+ reset(): void;
469
+ }
470
+ declare function defineCheck(tag?: string): CustomElementConstructor | undefined;
471
+
472
+ /**
473
+ * use-scroll-animate/components/feedback — loading & feedback.
474
+ * `<usa-spinner>`, `<usa-skeleton>`, `<usa-progress>`, `<usa-toaster>` +
475
+ * `toast()`, `<usa-check>`.
476
+ */
477
+
478
+ /** Register every component of this category under its default tag. */
479
+ declare function defineFeedbackComponents(): void;
480
+ declare global {
481
+ interface HTMLElementTagNameMap {
482
+ 'usa-spinner': UsaSpinnerElement;
483
+ 'usa-skeleton': UsaSkeletonElement;
484
+ 'usa-progress': UsaProgressElement;
485
+ 'usa-toaster': UsaToasterElement;
486
+ 'usa-check': UsaCheckElement;
487
+ }
488
+ }
489
+
490
+ /**
491
+ * `<usa-aurora>` — a slow, drifting aurora / gradient-mesh backdrop behind
492
+ * its content. Soft radial gradients moved with `transform` only (no
493
+ * animated blur), paused while off-screen.
494
+ *
495
+ * Attributes: `colors` (comma-separated, default violet / cyan / pink),
496
+ * `speed` (multiplier, 1), `intensity` (0–1 opacity, 0.7), `paused`.
497
+ * Reduced motion: a still gradient.
498
+ */
499
+ type UsaAuroraElement = UsaElement;
500
+ declare function defineAurora(tag?: string): CustomElementConstructor | undefined;
501
+
502
+ /**
503
+ * `<usa-particles>` — a canvas of drifting particles, optionally linked by
504
+ * lines when close (a "constellation"), that drift away from the pointer.
505
+ * Fills its own box (place it as a background with
506
+ * `position: absolute; inset: 0`, or give it a height).
507
+ *
508
+ * Attributes: `count` (60; scaled down on small boxes), `color`
509
+ * (default `currentColor`), `size` (max radius px, 2.2), `speed` (0.35),
510
+ * `links` (max link distance px, 110; `0` disables), `interactive`,
511
+ * `paused`. Renders only while visible and the tab is shown, at device
512
+ * pixel ratio ≤ 2. Reduced motion: one still frame.
513
+ */
514
+ interface UsaParticlesElement extends UsaElement {
515
+ /** Re-seed the particles. */
516
+ reset(): void;
517
+ }
518
+ declare function defineParticles(tag?: string): CustomElementConstructor | undefined;
519
+
520
+ /**
521
+ * `<usa-grain>` — a film-grain / noise overlay on top of its content
522
+ * (SVG `feTurbulence` texture, no images to ship). With `animated`, the
523
+ * grain jitters like film (stepped `transform`, ~12 fps).
524
+ *
525
+ * Attributes: `opacity` (0.12), `animated`, `blend` (`mix-blend-mode`,
526
+ * default `overlay`), `scale` (texture size px, 180). Never intercepts
527
+ * pointer events. Reduced motion: static grain.
528
+ */
529
+ type UsaGrainElement = UsaElement;
530
+ declare function defineGrain(tag?: string): CustomElementConstructor | undefined;
531
+
532
+ /**
533
+ * `<usa-marquee>` — an infinite, seamless ticker of its children (logos,
534
+ * testimonials, tags). The content is cloned (clones are `aria-hidden` and
535
+ * `inert`) and the track slides with one WAAPI `transform` animation whose
536
+ * duration follows the measured width, so the speed is constant.
537
+ *
538
+ * Attributes: `speed` (px/s, 50), `direction` (`left` default | `right` |
539
+ * `up` | `down`), `gap` (px, 32), `pause-on-hover`, `fade` (soft edges),
540
+ * `paused`. Pauses off-screen. Reduced motion: no movement; the row
541
+ * becomes scrollable instead.
542
+ */
543
+ interface UsaMarqueeElement extends UsaElement {
544
+ pause(): void;
545
+ resume(): void;
546
+ }
547
+ declare function defineMarquee(tag?: string): CustomElementConstructor | undefined;
548
+
549
+ /**
550
+ * `<usa-acrylic>` — Windows Fluent materials for the web: `acrylic`
551
+ * (frosted glass: backdrop blur + saturation + tint + subtle noise) and
552
+ * `mica` (an opaque, wallpaper-tinted base for app backgrounds; on the web it
553
+ * tints from `--usa-mica-source`, a gradient you control). Optional
554
+ * `shimmer` adds a light sweep when it appears or on hover.
555
+ *
556
+ * Attributes: `variant` (`acrylic` default | `mica`), `tint` (colour),
557
+ * `tint-opacity` (0–1, 0.55), `blur` (px, 30), `shimmer`
558
+ * (`hover` | `load` | `none`, default `none`). Falls back to a solid tint
559
+ * without `backdrop-filter` and under `prefers-reduced-transparency` or
560
+ * forced colours, like Windows does when transparency effects are off.
561
+ */
562
+ type UsaAcrylicElement = UsaElement;
563
+ declare function defineAcrylic(tag?: string): CustomElementConstructor | undefined;
564
+
565
+ /**
566
+ * use-scroll-animate/components/background — backgrounds & decoration.
567
+ * `<usa-aurora>`, `<usa-particles>`, `<usa-grain>`, `<usa-marquee>`,
568
+ * `<usa-acrylic>`.
569
+ */
570
+
571
+ /** Register every component of this category under its default tag. */
572
+ declare function defineBackgroundComponents(): void;
573
+ declare global {
574
+ interface HTMLElementTagNameMap {
575
+ 'usa-aurora': UsaAuroraElement;
576
+ 'usa-particles': UsaParticlesElement;
577
+ 'usa-grain': UsaGrainElement;
578
+ 'usa-marquee': UsaMarqueeElement;
579
+ 'usa-acrylic': UsaAcrylicElement;
580
+ }
581
+ }
582
+
583
+ type DialogVariant = 'modal' | 'drawer-start' | 'drawer-end' | 'drawer-bottom' | 'sheet';
584
+ /**
585
+ * `<usa-dialog>` — an animated modal or drawer built on the native
586
+ * `<dialog>` (top layer, focus trapping, inert page, Esc to close). Its
587
+ * children are slotted into the panel (they stay in the light DOM, so
588
+ * React / Vue / Svelte keep owning them). Style with `::part(panel)`,
589
+ * `::part(backdrop)` and the `--usa-dialog-*` custom properties.
590
+ *
591
+ * Attributes: `open` (reflects; set/remove to open/close), `variant`
592
+ * (`modal` default — Fluent scale + fade; `drawer-start` / `drawer-end`
593
+ * slide from the side, `drawer-bottom` / `sheet` from below), `label`
594
+ * (accessible name), `no-backdrop-close`, `no-esc`. Elements inside
595
+ * with `data-close` close it. Events: `usa:open`, `usa:close` (cancelable
596
+ * `usa:beforeclose`). Reduced motion: fade only.
597
+ */
598
+ interface UsaDialogElement extends UsaElement {
599
+ open: boolean;
600
+ show(): Promise<void>;
601
+ close(returnValue?: string): Promise<void>;
602
+ readonly dialog: HTMLDialogElement | null;
603
+ returnValue: string;
604
+ }
605
+ declare function defineDialog(tag?: string): CustomElementConstructor | undefined;
606
+
607
+ /**
608
+ * `<usa-accordion>` — smooth expand / collapse for the native `<details>`
609
+ * elements inside it (keeps their semantics, keyboard support and
610
+ * find-in-page, and adds no wrapper elements, so framework-rendered content
611
+ * is left alone). Only one stays open unless `multiple` is set.
612
+ *
613
+ * Attributes: `multiple`, `duration` (ms, 300). Event: `usa:toggle`
614
+ * (`detail.details`, `detail.open`). Reduced motion: instant.
615
+ * Heights are measured once per toggle and animated on the `<details>`.
616
+ */
617
+ interface UsaAccordionElement extends UsaElement {
618
+ readonly items: HTMLDetailsElement[];
619
+ toggleItem(details: HTMLDetailsElement, open?: boolean): Promise<void>;
620
+ }
621
+ declare function defineAccordion(tag?: string): CustomElementConstructor | undefined;
622
+
623
+ /**
624
+ * `<usa-flip-list>` — animates its children to their new places whenever
625
+ * they are added, removed or reordered (FLIP: transforms only). Works with
626
+ * any rendering: plain DOM, React keyed lists, Vue `v-for`, Svelte `{#each}`.
627
+ *
628
+ * Attributes: `duration` (ms, 420), `easing`, `disabled`.
629
+ * Method: `flip(mutate)` for explicit changes (also measures resizes).
630
+ * Reduced motion: no animation.
631
+ */
632
+ interface UsaFlipListElement extends UsaElement {
633
+ flip(mutate: () => void | Promise<void>): Promise<void>;
634
+ }
635
+ declare function defineFlipList(tag?: string): CustomElementConstructor | undefined;
636
+
637
+ /**
638
+ * `<usa-view-switch>` — shows one of its children at a time (tabs, wizard
639
+ * steps, app pages) and animates between them. Children are views; name
640
+ * them with `data-view`, or address them by index.
641
+ *
642
+ * Attributes: `active` (view name or index, default the first),
643
+ * `effect` (`fade` | `slide` (default, direction-aware — Fluent "page
644
+ * transition") | `scale` | `drill`), `duration` (ms, 320). Inactive views
645
+ * get `hidden` + `inert`. Event: `usa:change` (`detail.view`,
646
+ * `detail.index`). Reduced motion: a quick fade.
647
+ */
648
+ interface UsaViewSwitchElement extends UsaElement {
649
+ active: string;
650
+ readonly views: HTMLElement[];
651
+ show(view: string | number): Promise<void>;
652
+ }
653
+ declare function defineViewSwitch(tag?: string): CustomElementConstructor | undefined;
654
+
655
+ interface ViewTransitionOptions {
656
+ /**
657
+ * Element to cross-fade when the View Transitions API is missing (default:
658
+ * none — the update is applied without animation).
659
+ */
660
+ fallback?: HTMLElement | null;
661
+ /** Fallback fade duration in ms (default 180 out + 220 in). */
662
+ duration?: number;
663
+ /** View transition types (`document.startViewTransition({ types })`, where supported). */
664
+ types?: string[];
665
+ }
666
+ /**
667
+ * Run `update()` (which changes the DOM) inside a view transition:
668
+ * `document.startViewTransition()` where available (Chrome/Edge 111+, so
669
+ * Electron, WebView2 and Tauri on Windows), otherwise a short cross-fade of
670
+ * `options.fallback`. Instant under reduced motion. Resolves when finished.
671
+ *
672
+ * Give elements a `view-transition-name` in CSS for shared-element morphs.
673
+ */
674
+ declare function viewTransition(update: () => void | Promise<void>, options?: ViewTransitionOptions): Promise<void>;
675
+ interface FlipOptions {
676
+ duration?: number;
677
+ easing?: string;
678
+ /** Fade/scale in elements that did not exist before (default true). */
679
+ animateEnter?: boolean;
680
+ }
681
+ type Targets = Element | Iterable<Element> | ArrayLike<Element>;
682
+ /**
683
+ * FLIP animation for layout changes (list reorder, filter, grid resize):
684
+ * measures `targets` (an element's children, or a list), runs `mutate()`,
685
+ * then animates each element from its old position to its new one with
686
+ * transforms only. Elements added by `mutate()` fade in.
687
+ *
688
+ * ```js
689
+ * await flip(list, () => list.append(...shuffled));
690
+ * ```
691
+ */
692
+ declare function flip(targets: Targets, mutate: () => void | Promise<void>, options?: FlipOptions): Promise<void>;
693
+ interface ConnectedOptions {
694
+ duration?: number;
695
+ easing?: string;
696
+ /** Hide `from` while the animation runs (default true). */
697
+ hideSource?: boolean;
698
+ }
699
+ /**
700
+ * Connected (shared-element) animation, like WinUI's
701
+ * `ConnectedAnimationService`: `to` flies from the position and size of
702
+ * `from` into its own place (e.g. a thumbnail opening into a detail view).
703
+ * Call it right after `to` is shown. Transforms only.
704
+ */
705
+ declare function connectedAnimation(from: Element, to: HTMLElement, options?: ConnectedOptions): Promise<void>;
706
+
707
+ /**
708
+ * use-scroll-animate/components/transitions — view & layout transitions.
709
+ * `<usa-dialog>`, `<usa-accordion>`, `<usa-flip-list>`, `<usa-view-switch>`
710
+ * and the `viewTransition()`, `flip()`, `connectedAnimation()` helpers.
711
+ */
712
+
713
+ /** Register every component of this category under its default tag. */
714
+ declare function defineTransitionComponents(): void;
715
+ declare global {
716
+ interface HTMLElementTagNameMap {
717
+ 'usa-dialog': UsaDialogElement;
718
+ 'usa-accordion': UsaAccordionElement;
719
+ 'usa-flip-list': UsaFlipListElement;
720
+ 'usa-view-switch': UsaViewSwitchElement;
721
+ }
722
+ }
723
+
724
+ /** The component categories and their default tags. */
725
+ declare const COMPONENT_CATEGORIES: {
726
+ readonly reveal: readonly ["usa-reveal", "usa-stagger", "usa-scroll-progress", "usa-scrolly"];
727
+ readonly text: readonly ["usa-typewriter", "usa-split-text", "usa-scramble", "usa-counter", "usa-shimmer-text", "usa-text-rotate"];
728
+ readonly interaction: readonly ["usa-ripple", "usa-magnetic", "usa-tilt", "usa-spotlight", "usa-press", "usa-toggle"];
729
+ readonly feedback: readonly ["usa-spinner", "usa-skeleton", "usa-progress", "usa-toaster", "usa-check"];
730
+ readonly background: readonly ["usa-aurora", "usa-particles", "usa-grain", "usa-marquee", "usa-acrylic"];
731
+ readonly transitions: readonly ["usa-dialog", "usa-accordion", "usa-flip-list", "usa-view-switch"];
732
+ };
733
+ type ComponentCategory = keyof typeof COMPONENT_CATEGORIES;
734
+ /**
735
+ * Register every `<usa-*>` component (or only the given categories).
736
+ * Safe to call more than once and on the server (no-op without DOM).
737
+ */
738
+ declare function defineComponents(categories?: ComponentCategory[]): void;
739
+
740
+ export { COMPONENT_CATEGORIES, REVEAL_EFFECTS, SPINNER_VARIANTS, configureComponents, connectedAnimation, defineAccordion, defineAcrylic, defineAurora, defineBackgroundComponents, defineCheck, defineComponents, defineCounter, defineDialog, defineFeedbackComponents, defineFlipList, defineGrain, defineInteractionComponents, defineMagnetic, defineMarquee, defineParticles, definePress, defineProgress, defineReveal, defineRevealComponents, defineRipple, defineScramble, defineScrollProgress, defineScrolly, defineShimmerText, defineSkeleton, defineSpinner, defineSplitText, defineSpotlight, defineStagger, defineTextComponents, defineTextRotate, defineTilt, defineToaster, defineToggle, defineTransitionComponents, defineTypewriter, defineViewSwitch, easeOutExpo, flip, prefersReducedMotion, readScrollProgress, revealKeyframes, scrambleFrame, toast, viewTransition };
741
+ export type { ComponentCategory, ComponentsConfig, ConnectedOptions, DialogVariant, FlipOptions, RevealEffect, SpinnerVariant, ToastHandle, ToastOptions, ToastType, UsaAccordionElement, UsaAcrylicElement, UsaAuroraElement, UsaCheckElement, UsaCounterElement, UsaDialogElement, UsaElement, UsaFlipListElement, UsaGrainElement, UsaMagneticElement, UsaMarqueeElement, UsaParticlesElement, UsaPressElement, UsaProgressElement, UsaRevealElement, UsaRippleElement, UsaScrambleElement, UsaScrollProgressElement, UsaScrollyElement, UsaShimmerTextElement, UsaSkeletonElement, UsaSpinnerElement, UsaSplitTextElement, UsaSpotlightElement, UsaStaggerElement, UsaTextRotateElement, UsaTiltElement, UsaToasterElement, UsaToggleElement, UsaTypewriterElement, UsaViewSwitchElement, ViewTransitionOptions };