use-scroll-animate 2.8.0 → 2.9.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.
- package/CHANGELOG.md +24 -0
- package/README.md +2 -2
- package/README_zh.md +1 -1
- package/dist/chunks/{base-BR6fYLBA.cjs → base-BkQcvoSG.cjs} +29 -1
- package/dist/chunks/{base-BR6fYLBA.cjs.map → base-BkQcvoSG.cjs.map} +1 -1
- package/dist/chunks/{base-C_w9ibbn.js → base-CB8gChoe.js} +29 -2
- package/dist/chunks/{base-C_w9ibbn.js.map → base-CB8gChoe.js.map} +1 -1
- package/dist/chunks/{core-B_J4rXbC.cjs → core-C1cEwjJj.cjs} +11 -2
- package/dist/chunks/core-C1cEwjJj.cjs.map +1 -0
- package/dist/chunks/{core-BP-a1iNc.js → core-J_KM443q.js} +12 -3
- package/dist/chunks/core-J_KM443q.js.map +1 -0
- package/dist/chunks/index-tags-BEM98giN.cjs +20 -0
- package/dist/chunks/index-tags-BEM98giN.cjs.map +1 -0
- package/dist/chunks/index-tags-f37txHmb.js +18 -0
- package/dist/chunks/index-tags-f37txHmb.js.map +1 -0
- package/dist/chunks/{spring-DyHe1Hfa.cjs → spring-7U9MC6yQ.cjs} +2 -2
- package/dist/chunks/{spring-DyHe1Hfa.cjs.map → spring-7U9MC6yQ.cjs.map} +1 -1
- package/dist/chunks/{spring-Dc8ZqDWE.js → spring-ka0YJ_ZR.js} +2 -2
- package/dist/chunks/{spring-Dc8ZqDWE.js.map → spring-ka0YJ_ZR.js.map} +1 -1
- package/dist/chunks/{stagger-DTv_WiUQ.js → stagger-CGF18oNs.js} +2 -2
- package/dist/chunks/{stagger-DTv_WiUQ.js.map → stagger-CGF18oNs.js.map} +1 -1
- package/dist/chunks/{stagger-DHw0ExuR.cjs → stagger-DtKKS6GP.cjs} +2 -2
- package/dist/chunks/{stagger-DHw0ExuR.cjs.map → stagger-DtKKS6GP.cjs.map} +1 -1
- package/dist/chunks/{variants-idgMVXhE.js → variants-Ce9CboVc.js} +2 -2
- package/dist/chunks/{variants-idgMVXhE.js.map → variants-Ce9CboVc.js.map} +1 -1
- package/dist/chunks/{variants-Bbatdq8d.cjs → variants-PsCXbQ5h.cjs} +2 -2
- package/dist/chunks/{variants-Bbatdq8d.cjs.map → variants-PsCXbQ5h.cjs.map} +1 -1
- package/dist/components/background.cjs +3 -3
- package/dist/components/background.cjs.map +1 -1
- package/dist/components/background.css +1 -1
- package/dist/components/background.d.cts +1 -1
- package/dist/components/background.d.ts +1 -1
- package/dist/components/background.js +4 -4
- package/dist/components/background.js.map +1 -1
- package/dist/components/cards.cjs +2 -2
- package/dist/components/cards.js +3 -3
- package/dist/components/click.cjs +2 -2
- package/dist/components/click.js +3 -3
- package/dist/components/feedback.cjs +15 -8
- package/dist/components/feedback.cjs.map +1 -1
- package/dist/components/feedback.d.cts +4 -1
- package/dist/components/feedback.d.ts +4 -1
- package/dist/components/feedback.js +16 -9
- package/dist/components/feedback.js.map +1 -1
- package/dist/components/interaction.cjs +1 -1
- package/dist/components/interaction.js +2 -2
- package/dist/components/jsx.cjs +3 -0
- package/dist/components/jsx.cjs.map +1 -0
- package/dist/components/jsx.d.cts +45 -0
- package/dist/components/jsx.d.ts +45 -0
- package/dist/components/jsx.js +2 -0
- package/dist/components/jsx.js.map +1 -0
- package/dist/components/lazy.cjs +84 -0
- package/dist/components/lazy.cjs.map +1 -0
- package/dist/components/lazy.d.cts +40 -0
- package/dist/components/lazy.d.ts +40 -0
- package/dist/components/lazy.js +79 -0
- package/dist/components/lazy.js.map +1 -0
- package/dist/components/page.cjs +2 -2
- package/dist/components/page.js +3 -3
- package/dist/components/physics.cjs +2 -2
- package/dist/components/physics.js +4 -4
- package/dist/components/react.cjs +96 -0
- package/dist/components/react.cjs.map +1 -0
- package/dist/components/react.d.cts +18 -0
- package/dist/components/react.d.ts +18 -0
- package/dist/components/react.js +91 -0
- package/dist/components/react.js.map +1 -0
- package/dist/components/reveal.cjs +1 -1
- package/dist/components/reveal.js +2 -2
- package/dist/components/text.cjs +1 -1
- package/dist/components/text.js +2 -2
- package/dist/components/transitions.cjs +3 -4
- package/dist/components/transitions.cjs.map +1 -1
- package/dist/components/transitions.js +4 -5
- package/dist/components/transitions.js.map +1 -1
- package/dist/components/ui.cjs +3 -3
- package/dist/components/ui.js +5 -5
- package/dist/components/vue.cjs +51 -0
- package/dist/components/vue.cjs.map +1 -0
- package/dist/components/vue.d.cts +1344 -0
- package/dist/components/vue.d.ts +1344 -0
- package/dist/components/vue.js +48 -0
- package/dist/components/vue.js.map +1 -0
- package/dist/components.cjs +5 -18
- package/dist/components.cjs.map +1 -1
- package/dist/components.css +1 -1
- package/dist/components.d.cts +6 -2
- package/dist/components.d.ts +6 -2
- package/dist/components.js +7 -20
- package/dist/components.js.map +1 -1
- package/dist/components.umd.js +2 -2
- package/dist/components.umd.js.map +1 -1
- package/dist/element.cjs +1 -1
- package/dist/element.js +1 -1
- package/dist/element.umd.js +1 -1
- package/dist/element.umd.js.map +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.js +3 -3
- package/dist/index.umd.js +2 -2
- package/dist/index.umd.js.map +1 -1
- package/dist/react.cjs +2 -2
- package/dist/react.js +2 -2
- package/dist/solid.cjs +2 -2
- package/dist/solid.js +2 -2
- package/dist/svelte.cjs +2 -2
- package/dist/svelte.js +2 -2
- package/dist/vue.cjs +2 -2
- package/dist/vue.js +2 -2
- package/docs/accessibility.md +32 -0
- package/docs/components.md +28 -6
- package/docs/frameworks-ssr.md +64 -0
- package/docs/upgrading-3.md +20 -0
- package/docs/windows-apps.md +2 -2
- package/package.json +42 -1
- package/dist/chunks/core-BP-a1iNc.js.map +0 -1
- package/dist/chunks/core-B_J4rXbC.cjs.map +0 -1
|
@@ -0,0 +1,1344 @@
|
|
|
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`; `variant` is a deprecated alias until 3.0): `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
|
+
/** @deprecated alias of `kind`, removed in 3.0. */
|
|
369
|
+
variant: SpinnerVariant;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
/**
|
|
373
|
+
* `<usa-skeleton>` — shimmering placeholders while content loads. With
|
|
374
|
+
* `loading`, it shows `lines` bars (or one block of `width` × `height`,
|
|
375
|
+
* or a `circle`) and hides its children; remove `loading` and the real
|
|
376
|
+
* content fades in.
|
|
377
|
+
*
|
|
378
|
+
* Attributes: `loading`, `lines` (3), `width`, `height` (CSS lengths),
|
|
379
|
+
* `circle`, `radius`, `avatar` (circle + lines, like a list row).
|
|
380
|
+
* `aria-busy` follows `loading`. Reduced motion: no shimmer sweep.
|
|
381
|
+
*/
|
|
382
|
+
interface UsaSkeletonElement extends UsaElement {
|
|
383
|
+
loading: boolean;
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
/**
|
|
387
|
+
* `<usa-progress>` — a linear progress bar. Determinate (`value` / `max`)
|
|
388
|
+
* bars glide between values with `transform: scaleX()`; without a value,
|
|
389
|
+
* or with `indeterminate`, it shows the Windows Fluent indeterminate
|
|
390
|
+
* animation (two sliding segments).
|
|
391
|
+
*
|
|
392
|
+
* Attributes: `value`, `max` (100), `indeterminate`, `state`
|
|
393
|
+
* (`paused` | `error` — the WinUI states), `label` (accessible name).
|
|
394
|
+
* `role="progressbar"` with `aria-valuenow` when determinate.
|
|
395
|
+
* Reduced motion: no glide; indeterminate becomes a gentle pulse.
|
|
396
|
+
*/
|
|
397
|
+
interface UsaProgressElement extends UsaElement {
|
|
398
|
+
value: number | null;
|
|
399
|
+
max: number;
|
|
400
|
+
/** 0–1, or `null` when indeterminate. */
|
|
401
|
+
readonly ratio: number | null;
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
type ToastType = 'info' | 'success' | 'warning' | 'error';
|
|
405
|
+
interface ToastOptions {
|
|
406
|
+
/** ms before it hides itself; `0` keeps it until closed (default 4000). */
|
|
407
|
+
duration?: number;
|
|
408
|
+
type?: ToastType;
|
|
409
|
+
/** Optional action button. */
|
|
410
|
+
action?: {
|
|
411
|
+
label: string;
|
|
412
|
+
onClick: () => void;
|
|
413
|
+
};
|
|
414
|
+
/** Show a close button (default `true`). */
|
|
415
|
+
dismissible?: boolean;
|
|
416
|
+
/** The toaster to use (default: the first `<usa-toaster>`, created if missing). */
|
|
417
|
+
toaster?: UsaToasterElement | string;
|
|
418
|
+
}
|
|
419
|
+
interface ToastHandle {
|
|
420
|
+
element: HTMLElement;
|
|
421
|
+
close(): Promise<void>;
|
|
422
|
+
}
|
|
423
|
+
/**
|
|
424
|
+
* `<usa-toaster>` — the region toasts slide into (`role="region"`, each
|
|
425
|
+
* toast `role="status"`, errors `role="alert"`). Toasts pause their timer
|
|
426
|
+
* while hovered or focused, and the stack re-flows with a FLIP animation.
|
|
427
|
+
*
|
|
428
|
+
* Attributes: `position` (`bottom-right` default, `bottom-left`,
|
|
429
|
+
* `bottom-center`, `top-right`, `top-left`, `top-center`), `max` (visible
|
|
430
|
+
* toasts, 4), `label` (region name, "Notifications").
|
|
431
|
+
* Reduced motion: toasts fade instead of sliding.
|
|
432
|
+
*/
|
|
433
|
+
interface UsaToasterElement extends UsaElement {
|
|
434
|
+
show(message: string, options?: ToastOptions): ToastHandle;
|
|
435
|
+
clear(): void;
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
/**
|
|
439
|
+
* `<usa-check>` — an animated result icon: the circle draws itself, then the
|
|
440
|
+
* check mark (or cross / exclamation) strokes in with a little pop.
|
|
441
|
+
*
|
|
442
|
+
* Attributes: `variant` (`success` default, `error`, `warning`), `size`
|
|
443
|
+
* (px, 56), `start` (`view` default | `load` | `manual`), `label`
|
|
444
|
+
* (accessible name, e.g. "Payment complete"; the icon is decorative
|
|
445
|
+
* without it). Event: `usa:complete`. Reduced motion: drawn instantly.
|
|
446
|
+
*/
|
|
447
|
+
interface UsaCheckElement extends UsaElement {
|
|
448
|
+
play(): Promise<void>;
|
|
449
|
+
reset(): void;
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
/**
|
|
453
|
+
* use-scroll-animate/components/feedback — loading & feedback.
|
|
454
|
+
* `<usa-spinner>`, `<usa-skeleton>`, `<usa-progress>`, `<usa-toaster>` +
|
|
455
|
+
* `toast()`, `<usa-check>`.
|
|
456
|
+
*/
|
|
457
|
+
|
|
458
|
+
declare global {
|
|
459
|
+
interface HTMLElementTagNameMap {
|
|
460
|
+
'usa-spinner': UsaSpinnerElement;
|
|
461
|
+
'usa-skeleton': UsaSkeletonElement;
|
|
462
|
+
'usa-progress': UsaProgressElement;
|
|
463
|
+
'usa-toaster': UsaToasterElement;
|
|
464
|
+
'usa-check': UsaCheckElement;
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
/**
|
|
469
|
+
* `<usa-aurora>` — a slow, drifting aurora / gradient-mesh backdrop behind
|
|
470
|
+
* its content. Soft radial gradients moved with `transform` only (no
|
|
471
|
+
* animated blur), paused while off-screen.
|
|
472
|
+
*
|
|
473
|
+
* Attributes: `colors` (comma-separated, default violet / cyan / pink),
|
|
474
|
+
* `speed` (multiplier, 1), `intensity` (0–1 opacity, 0.7), `paused`.
|
|
475
|
+
* Reduced motion: a still gradient.
|
|
476
|
+
*/
|
|
477
|
+
type UsaAuroraElement = UsaElement;
|
|
478
|
+
|
|
479
|
+
/**
|
|
480
|
+
* `<usa-particles>` — a canvas of drifting particles, optionally linked by
|
|
481
|
+
* lines when close (a "constellation"), that drift away from the pointer.
|
|
482
|
+
* Fills its own box (place it as a background with
|
|
483
|
+
* `position: absolute; inset: 0`, or give it a height).
|
|
484
|
+
*
|
|
485
|
+
* Attributes: `count` (60; scaled down on small boxes), `color`
|
|
486
|
+
* (default `currentColor`), `size` (max radius px, 2.2), `speed` (0.35),
|
|
487
|
+
* `links` (max link distance px, 110; `0` disables), `interactive`,
|
|
488
|
+
* `paused`. Renders only while visible and the tab is shown, at device
|
|
489
|
+
* pixel ratio ≤ 2. Reduced motion: one still frame.
|
|
490
|
+
*/
|
|
491
|
+
interface UsaParticlesElement extends UsaElement {
|
|
492
|
+
/** Re-seed the particles. */
|
|
493
|
+
reset(): void;
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
/**
|
|
497
|
+
* `<usa-grain>` — a film-grain / noise overlay on top of its content
|
|
498
|
+
* (SVG `feTurbulence` texture, no images to ship). With `animated`, the
|
|
499
|
+
* grain jitters like film (stepped `transform`, ~12 fps).
|
|
500
|
+
*
|
|
501
|
+
* Attributes: `opacity` (0.12), `animated`, `blend` (`mix-blend-mode`,
|
|
502
|
+
* default `overlay`), `scale` (texture size px, 180). Never intercepts
|
|
503
|
+
* pointer events. Reduced motion: static grain.
|
|
504
|
+
*/
|
|
505
|
+
type UsaGrainElement = UsaElement;
|
|
506
|
+
|
|
507
|
+
/**
|
|
508
|
+
* `<usa-marquee>` — an infinite, seamless ticker of its children (logos,
|
|
509
|
+
* testimonials, tags). The content is cloned (clones are `aria-hidden` and
|
|
510
|
+
* `inert`) and the track slides with one WAAPI `transform` animation whose
|
|
511
|
+
* duration follows the measured width, so the speed is constant.
|
|
512
|
+
*
|
|
513
|
+
* Attributes: `speed` (px/s, 50), `direction` (`left` default | `right` |
|
|
514
|
+
* `up` | `down`), `gap` (px, 32), `pause-on-hover`, `fade` (soft edges),
|
|
515
|
+
* `paused`. Pauses off-screen. Reduced motion: no movement; the row
|
|
516
|
+
* becomes scrollable instead.
|
|
517
|
+
*/
|
|
518
|
+
interface UsaMarqueeElement extends UsaElement {
|
|
519
|
+
pause(): void;
|
|
520
|
+
resume(): void;
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
/**
|
|
524
|
+
* `<usa-acrylic>` — Windows Fluent materials for the web: `acrylic`
|
|
525
|
+
* (frosted glass: backdrop blur + saturation + tint + subtle noise) and
|
|
526
|
+
* `mica` (an opaque, wallpaper-tinted base for app backgrounds; on the web it
|
|
527
|
+
* tints from `--usa-mica-source`, a gradient you control). Optional
|
|
528
|
+
* `shimmer` adds a light sweep when it appears or on hover.
|
|
529
|
+
*
|
|
530
|
+
* Attributes: `kind` (`acrylic` default | `mica`; `variant` is a deprecated alias until 3.0), `tint` (colour),
|
|
531
|
+
* `tint-opacity` (0–1, 0.55), `blur` (px, 30), `shimmer`
|
|
532
|
+
* (`hover` | `load` | `none`, default `none`). Falls back to a solid tint
|
|
533
|
+
* without `backdrop-filter` and under `prefers-reduced-transparency` or
|
|
534
|
+
* forced colours, like Windows does when transparency effects are off.
|
|
535
|
+
*/
|
|
536
|
+
type UsaAcrylicElement = UsaElement;
|
|
537
|
+
|
|
538
|
+
/**
|
|
539
|
+
* `<usa-grid-glow>` — a line grid behind its content that lights up around
|
|
540
|
+
* the pointer. Attributes: `size` (cell px, 32), `color`, `radius` (px, 220).
|
|
541
|
+
* Reduced motion: the grid stays, a soft static glow in the centre.
|
|
542
|
+
*/
|
|
543
|
+
interface UsaGridGlowElement extends UsaElement {
|
|
544
|
+
}
|
|
545
|
+
/**
|
|
546
|
+
* `<usa-blobs>` — soft, slowly morphing colour blobs (fluid gradient
|
|
547
|
+
* backdrop). Attributes: `colors` (comma list), `speed` (1), `blur` (px, 60).
|
|
548
|
+
* Reduced motion: still blobs.
|
|
549
|
+
*/
|
|
550
|
+
interface UsaBlobsElement extends UsaElement {
|
|
551
|
+
}
|
|
552
|
+
/**
|
|
553
|
+
* `<usa-water-ripple>` — interactive water ripples on a canvas over its
|
|
554
|
+
* content (pointer moves and taps disturb the surface). Low-resolution height
|
|
555
|
+
* map, paused off-screen. Attributes: `damping` (0.96), `strength` (1),
|
|
556
|
+
* `color` (highlight). Reduced motion: nothing is drawn.
|
|
557
|
+
*/
|
|
558
|
+
interface UsaWaterRippleElement extends UsaElement {
|
|
559
|
+
drop(x: number, y: number, strength?: number): void;
|
|
560
|
+
}
|
|
561
|
+
/**
|
|
562
|
+
* `<usa-dot-network>` — a grid of dots that swell and link up with lines
|
|
563
|
+
* around the pointer (a living network backdrop). Attributes: `gap` (px,
|
|
564
|
+
* 28), `color`, `radius` (px of influence, 140). Reduced motion: a static
|
|
565
|
+
* dot grid.
|
|
566
|
+
*/
|
|
567
|
+
interface UsaDotNetworkElement extends UsaElement {
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
/**
|
|
571
|
+
* use-scroll-animate/components/background — backgrounds & decoration.
|
|
572
|
+
* `<usa-aurora>`, `<usa-particles>`, `<usa-grain>`, `<usa-marquee>`,
|
|
573
|
+
* `<usa-acrylic>`.
|
|
574
|
+
*/
|
|
575
|
+
|
|
576
|
+
declare global {
|
|
577
|
+
interface HTMLElementTagNameMap {
|
|
578
|
+
'usa-grid-glow': UsaGridGlowElement;
|
|
579
|
+
'usa-blobs': UsaBlobsElement;
|
|
580
|
+
'usa-water-ripple': UsaWaterRippleElement;
|
|
581
|
+
'usa-dot-network': UsaDotNetworkElement;
|
|
582
|
+
'usa-aurora': UsaAuroraElement;
|
|
583
|
+
'usa-particles': UsaParticlesElement;
|
|
584
|
+
'usa-grain': UsaGrainElement;
|
|
585
|
+
'usa-marquee': UsaMarqueeElement;
|
|
586
|
+
'usa-acrylic': UsaAcrylicElement;
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
/**
|
|
591
|
+
* `<usa-dialog>` — an animated modal or drawer built on the native
|
|
592
|
+
* `<dialog>` (top layer, focus trapping, inert page, Esc to close). Its
|
|
593
|
+
* children are slotted into the panel (they stay in the light DOM, so
|
|
594
|
+
* React / Vue / Svelte keep owning them). Style with `::part(panel)`,
|
|
595
|
+
* `::part(backdrop)` and the `--usa-dialog-*` custom properties.
|
|
596
|
+
*
|
|
597
|
+
* Attributes: `open` (reflects; set/remove to open/close), `variant`
|
|
598
|
+
* (`modal` default — Fluent scale + fade; `drawer-start` / `drawer-end`
|
|
599
|
+
* slide from the side, `drawer-bottom` / `sheet` from below), `label`
|
|
600
|
+
* (accessible name), `no-backdrop-close`, `no-esc`. Elements inside
|
|
601
|
+
* with `data-close` close it. Events: `usa:open`, `usa:close` (cancelable
|
|
602
|
+
* `usa:beforeclose`). Reduced motion: fade only.
|
|
603
|
+
*/
|
|
604
|
+
interface UsaDialogElement extends UsaElement {
|
|
605
|
+
open: boolean;
|
|
606
|
+
show(): Promise<void>;
|
|
607
|
+
close(returnValue?: string): Promise<void>;
|
|
608
|
+
readonly dialog: HTMLDialogElement | null;
|
|
609
|
+
returnValue: string;
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
/**
|
|
613
|
+
* `<usa-accordion>` — smooth expand / collapse for the native `<details>`
|
|
614
|
+
* elements inside it (keeps their semantics, keyboard support and
|
|
615
|
+
* find-in-page, and adds no wrapper elements, so framework-rendered content
|
|
616
|
+
* is left alone). Only one stays open unless `multiple` is set.
|
|
617
|
+
*
|
|
618
|
+
* Attributes: `multiple`, `duration` (ms, 300). Event: `usa:toggle`
|
|
619
|
+
* (`detail.details`, `detail.open`). Reduced motion: instant.
|
|
620
|
+
* Heights are measured once per toggle and animated on the `<details>`.
|
|
621
|
+
*/
|
|
622
|
+
interface UsaAccordionElement extends UsaElement {
|
|
623
|
+
readonly items: HTMLDetailsElement[];
|
|
624
|
+
toggleItem(details: HTMLDetailsElement, open?: boolean): Promise<void>;
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
/**
|
|
628
|
+
* `<usa-flip-list>` — animates its children to their new places whenever
|
|
629
|
+
* they are added, removed or reordered (FLIP: transforms only). Works with
|
|
630
|
+
* any rendering: plain DOM, React keyed lists, Vue `v-for`, Svelte `{#each}`.
|
|
631
|
+
*
|
|
632
|
+
* Attributes: `duration` (ms, 420), `easing`, `disabled`.
|
|
633
|
+
* Method: `flip(mutate)` for explicit changes (also measures resizes).
|
|
634
|
+
* Reduced motion: no animation.
|
|
635
|
+
*/
|
|
636
|
+
interface UsaFlipListElement extends UsaElement {
|
|
637
|
+
flip(mutate: () => void | Promise<void>): Promise<void>;
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
/**
|
|
641
|
+
* `<usa-view-switch>` — shows one of its children at a time (tabs, wizard
|
|
642
|
+
* steps, app pages) and animates between them. Children are views; name
|
|
643
|
+
* them with `data-view`, or address them by index.
|
|
644
|
+
*
|
|
645
|
+
* Attributes: `active` (view name or index, default the first),
|
|
646
|
+
* `effect` (`fade` | `slide` (default, direction-aware — Fluent "page
|
|
647
|
+
* transition") | `scale` | `drill`), `duration` (ms, 320). Inactive views
|
|
648
|
+
* get `hidden` + `inert`. Event: `usa:change` (`detail.view`,
|
|
649
|
+
* `detail.index`). Reduced motion: a quick fade.
|
|
650
|
+
*/
|
|
651
|
+
interface UsaViewSwitchElement extends UsaElement {
|
|
652
|
+
active: string;
|
|
653
|
+
readonly views: HTMLElement[];
|
|
654
|
+
show(view: string | number): Promise<void>;
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
/**
|
|
658
|
+
* use-scroll-animate/components/transitions — view & layout transitions.
|
|
659
|
+
* `<usa-dialog>`, `<usa-accordion>`, `<usa-flip-list>`, `<usa-view-switch>`
|
|
660
|
+
* and the `viewTransition()`, `flip()`, `connectedAnimation()` helpers.
|
|
661
|
+
*/
|
|
662
|
+
|
|
663
|
+
declare global {
|
|
664
|
+
interface HTMLElementTagNameMap {
|
|
665
|
+
'usa-dialog': UsaDialogElement;
|
|
666
|
+
'usa-accordion': UsaAccordionElement;
|
|
667
|
+
'usa-flip-list': UsaFlipListElement;
|
|
668
|
+
'usa-view-switch': UsaViewSwitchElement;
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
/**
|
|
673
|
+
* `<usa-spring>` — spring / bounce effects on its content.
|
|
674
|
+
*
|
|
675
|
+
* Attributes: `effect` (`bounce-in` default, `pop`, `drop`, `jelly`,
|
|
676
|
+
* `rubber-band`), `trigger` (`view` default, `hover`, `click`, `manual`),
|
|
677
|
+
* `preset` (`gentle`, `wobbly`, `stiff`, `bouncy`, …) or `stiffness` /
|
|
678
|
+
* `damping` / `mass`, `delay` (ms), `duration` (ms, attention effects; 900),
|
|
679
|
+
* `repeat` (replay every time it re-enters the view), `block`.
|
|
680
|
+
* Events: `usa:complete`. Reduced motion: entrances fade, attention effects do nothing.
|
|
681
|
+
*/
|
|
682
|
+
interface UsaSpringElement extends UsaElement {
|
|
683
|
+
effect: string;
|
|
684
|
+
play(): Promise<void>;
|
|
685
|
+
reset(): void;
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
/**
|
|
689
|
+
* `<usa-draggable>` — drag its content with the pointer (mouse, touch, pen)
|
|
690
|
+
* or the arrow keys; physics on release.
|
|
691
|
+
*
|
|
692
|
+
* Attributes: `axis` (`both` default, `x`, `y`), `spring-back` (return to
|
|
693
|
+
* the origin with a spring), `inertia` (keep gliding after a flick),
|
|
694
|
+
* `snap` (grid size like `80`, or points like `0,120,240`), `bounds`
|
|
695
|
+
* (`parent` = stay inside the parent box, rubber-banding past its edges),
|
|
696
|
+
* `preset` (spring, default `wobbly`), `step` (arrow-key step, px, 16),
|
|
697
|
+
* `disabled`. Methods: `moveTo(x, y, animate?)`, `reset()`. Events:
|
|
698
|
+
* `usa:drag-start`, `usa:drag-end` (`{ x, y, vx, vy }`), `usa:settle`.
|
|
699
|
+
* Reduced motion: positions change instantly (no spring or inertia).
|
|
700
|
+
*/
|
|
701
|
+
interface UsaDraggableElement extends UsaElement {
|
|
702
|
+
readonly x: number;
|
|
703
|
+
readonly y: number;
|
|
704
|
+
readonly dragging: boolean;
|
|
705
|
+
moveTo(x: number, y: number, animate?: boolean): void;
|
|
706
|
+
reset(): void;
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
/**
|
|
710
|
+
* `<usa-overscroll>` — an elastic scroll container: pulling past the top or
|
|
711
|
+
* bottom (touch, trackpad or wheel) stretches the content with iOS-style
|
|
712
|
+
* rubber-band resistance and it springs back on release.
|
|
713
|
+
*
|
|
714
|
+
* Attributes: `axis` (`y` default, `x`), `max` (largest stretch in px, 120),
|
|
715
|
+
* `preset` (spring, default `default`), `disabled`. CSS variable
|
|
716
|
+
* `--usa-overscroll` holds the current offset. Reduced motion: no stretch
|
|
717
|
+
* (a plain scroll container with `overscroll-behavior: contain`).
|
|
718
|
+
*/
|
|
719
|
+
interface UsaOverscrollElement extends UsaElement {
|
|
720
|
+
/** Current stretch in px (negative = pulled past the end). */
|
|
721
|
+
readonly offset: number;
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
/**
|
|
725
|
+
* use-scroll-animate/components/physics — spring & bounce physics (v2.3).
|
|
726
|
+
* `<usa-spring>` (bounce-in, pop, drop, jelly, rubber-band), `<usa-draggable>`
|
|
727
|
+
* (spring-back, inertia, snap) and `<usa-overscroll>` (elastic edges), plus
|
|
728
|
+
* the spring core: `spring()`, `springEasing()`, `createSpring()`,
|
|
729
|
+
* `SPRING_PRESETS`, `projectInertia()`, `snapTo()`, `rubberBand()`.
|
|
730
|
+
*/
|
|
731
|
+
|
|
732
|
+
declare global {
|
|
733
|
+
interface HTMLElementTagNameMap {
|
|
734
|
+
'usa-spring': UsaSpringElement;
|
|
735
|
+
'usa-draggable': UsaDraggableElement;
|
|
736
|
+
'usa-overscroll': UsaOverscrollElement;
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
|
|
740
|
+
/**
|
|
741
|
+
* `<usa-card>` — card effects, combinable: `effect="lift sheen"`.
|
|
742
|
+
*
|
|
743
|
+
* - `flip` — front/back (`[data-front]` / `[data-back]` children) flip on
|
|
744
|
+
* hover or `trigger="click"`, `axis="y"` (default, horizontal flip) or `x`.
|
|
745
|
+
* - `holo` — holographic foil that shifts with the pointer.
|
|
746
|
+
* - `glass` — frosted glass surface (backdrop blur).
|
|
747
|
+
* - `border-glow` — a glow on the border that follows the pointer.
|
|
748
|
+
* - `conic-border` — a rotating conic-gradient border.
|
|
749
|
+
* - `lift` — rises with a deeper shadow and a slight pointer tilt.
|
|
750
|
+
* - `spotlight` — a soft light that follows the pointer.
|
|
751
|
+
* - `sheen` — a light sweep across the card on hover / focus.
|
|
752
|
+
* - `parallax-layers` — children with `data-depth="0.2…1"` move at different depths.
|
|
753
|
+
* - `expand` — click to grow into a full detail view (`[data-detail]`
|
|
754
|
+
* content is shown), FLIP + spring; Esc, `[data-close]` or the backdrop closes.
|
|
755
|
+
*
|
|
756
|
+
* Attributes: `effect`, `axis`, `trigger`, `depth` (parallax px, 16),
|
|
757
|
+
* `color` (glow / spotlight colour), `flipped`, `expanded`, `disabled`.
|
|
758
|
+
* CSS variables: `--usa-card-x/-y` (pointer %, 0–100), `--usa-card-nx/-ny` (−1…1).
|
|
759
|
+
* Methods: `flip(force?)`, `expand()`, `collapse()`. Events: `usa:flip`,
|
|
760
|
+
* `usa:expand`, `usa:collapse`. Reduced motion: no tilt / parallax / sweep;
|
|
761
|
+
* flips and expansions cross-fade.
|
|
762
|
+
*/
|
|
763
|
+
interface UsaCardElement extends UsaElement {
|
|
764
|
+
readonly effects: string[];
|
|
765
|
+
flipped: boolean;
|
|
766
|
+
readonly expanded: boolean;
|
|
767
|
+
flip(force?: boolean): void;
|
|
768
|
+
expand(): Promise<void>;
|
|
769
|
+
collapse(): Promise<void>;
|
|
770
|
+
}
|
|
771
|
+
|
|
772
|
+
/**
|
|
773
|
+
* `<usa-card-stack>` — a deck of cards (its element children). The top card
|
|
774
|
+
* can be swiped away left or right (pointer, touch or arrow keys); the rest
|
|
775
|
+
* fan out behind it and move up with a spring.
|
|
776
|
+
*
|
|
777
|
+
* Attributes: `threshold` (px to dismiss, 90), `visible` (cards fanned
|
|
778
|
+
* behind, 3), `offset` (px between cards, 10), `loop` (swiped cards go back
|
|
779
|
+
* to the bottom), `disabled`. Methods: `swipe(direction)`, `top`. Events:
|
|
780
|
+
* `usa:swipe` (`{ direction: 'left' | 'right', card }`), `usa:empty`.
|
|
781
|
+
* Reduced motion: cards are removed instantly, no rotation.
|
|
782
|
+
*/
|
|
783
|
+
interface UsaCardStackElement extends UsaElement {
|
|
784
|
+
readonly top: HTMLElement | null;
|
|
785
|
+
swipe(direction: 'left' | 'right'): Promise<void>;
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
/**
|
|
789
|
+
* `<usa-sticky-stack>` — cards (element children) stick to the top while
|
|
790
|
+
* scrolling and the ones underneath scale down and dim as the next card
|
|
791
|
+
* slides over them, like a deck building up.
|
|
792
|
+
*
|
|
793
|
+
* Attributes: `top` (px from the viewport top, 80), `gap` (px each card
|
|
794
|
+
* peeks below the previous, 16), `scale` (how much a covered card shrinks,
|
|
795
|
+
* 0.06). Reduced motion: cards still stack (sticky) but do not scale.
|
|
796
|
+
*/
|
|
797
|
+
interface UsaStickyStackElement extends UsaElement {
|
|
798
|
+
update(): void;
|
|
799
|
+
}
|
|
800
|
+
|
|
801
|
+
/**
|
|
802
|
+
* `<usa-carousel-3d>` — its element children on a 3D ring. Rotate with the
|
|
803
|
+
* arrow keys, a drag/swipe, the wheel (shift) or `next()` / `prev()`; the
|
|
804
|
+
* front item is `aria-current`. Spring-driven rotation.
|
|
805
|
+
*
|
|
806
|
+
* Attributes: `radius` (px, auto from item width), `autoplay` (ms between
|
|
807
|
+
* steps, pauses on hover/focus), `perspective` (px, 1200), `index`.
|
|
808
|
+
* Events: `usa:change` (`{ index }`). Reduced motion: a flat, instant
|
|
809
|
+
* switch (only the current item is shown, others dimmed).
|
|
810
|
+
*/
|
|
811
|
+
interface UsaCarousel3dElement extends UsaElement {
|
|
812
|
+
index: number;
|
|
813
|
+
next(): void;
|
|
814
|
+
prev(): void;
|
|
815
|
+
goTo(i: number): void;
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
/**
|
|
819
|
+
* use-scroll-animate/components/cards — card effects (v2.4).
|
|
820
|
+
* `<usa-card effect="flip | holo | glass | border-glow | conic-border | lift |
|
|
821
|
+
* spotlight | sheen | parallax-layers | expand">` (combinable),
|
|
822
|
+
* `<usa-card-stack>` (swipeable deck), `<usa-sticky-stack>` (stacking on
|
|
823
|
+
* scroll) and `<usa-carousel-3d>`.
|
|
824
|
+
*/
|
|
825
|
+
|
|
826
|
+
declare global {
|
|
827
|
+
interface HTMLElementTagNameMap {
|
|
828
|
+
'usa-card': UsaCardElement;
|
|
829
|
+
'usa-card-stack': UsaCardStackElement;
|
|
830
|
+
'usa-sticky-stack': UsaStickyStackElement;
|
|
831
|
+
'usa-carousel-3d': UsaCarousel3dElement;
|
|
832
|
+
}
|
|
833
|
+
}
|
|
834
|
+
|
|
835
|
+
/**
|
|
836
|
+
* `<usa-click>` — click / tap effects on whatever it wraps (combinable:
|
|
837
|
+
* `effect="press-spring burst"`).
|
|
838
|
+
*
|
|
839
|
+
* - `ripple` — an ink wave from the pointer (enhanced: `color`, soft edge);
|
|
840
|
+
* - `burst` — particles radiating from the pointer (`shape`: circle, square, star, heart, emoji);
|
|
841
|
+
* - `confetti` — a confetti cannon from the click point;
|
|
842
|
+
* - `squish` — squash on press, stretch on release (spring);
|
|
843
|
+
* - `press-spring` — dips while pressed, springs back with overshoot;
|
|
844
|
+
* - `shake` — horizontal error shake; plays on `invalid` events from a form
|
|
845
|
+
* inside, on `shake()`, or on click when `trigger="click"`.
|
|
846
|
+
*
|
|
847
|
+
* Attributes: `effect`, `color`, `shape`, `count`, `haptic` (vibrate ms,
|
|
848
|
+
* where supported), `disabled`. Keyboard (Space/Enter) triggers the effects
|
|
849
|
+
* from the centre. Reduced motion: no particles or movement; press dims.
|
|
850
|
+
*/
|
|
851
|
+
interface UsaClickElement extends UsaElement {
|
|
852
|
+
readonly effects: string[];
|
|
853
|
+
play(x?: number, y?: number): void;
|
|
854
|
+
shake(): void;
|
|
855
|
+
}
|
|
856
|
+
|
|
857
|
+
type ButtonShape = 'pill' | 'circle' | 'icon';
|
|
858
|
+
type ButtonState = 'idle' | 'loading' | 'success' | 'error';
|
|
859
|
+
/**
|
|
860
|
+
* `<usa-button>` — **button click deformation** (按钮点击形变) around a
|
|
861
|
+
* native `<button>` (or `<a>`) child — or the element itself becomes a button.
|
|
862
|
+
*
|
|
863
|
+
* `deform` (combinable, e.g. `deform="squash wobble"`):
|
|
864
|
+
* - `squash` — squash on press, stretch-and-settle on release (spring);
|
|
865
|
+
* - `wobble` — elastic border-radius wobble after a click;
|
|
866
|
+
* - `gooey` — liquid blob: droplets squeeze out from the press point and
|
|
867
|
+
* merge back (SVG goo filter);
|
|
868
|
+
* - `dent` — the surface dents toward the pressed point (3D tilt + inner shade).
|
|
869
|
+
*
|
|
870
|
+
* `shape="pill | circle | icon"` morphs the outline with a spring (label =
|
|
871
|
+
* `[data-label]`, icon = `[data-icon]` children); `morphTo(shape)`.
|
|
872
|
+
*
|
|
873
|
+
* `morph="submit"` — click → `loading` (shrinks to a circle with a spinner,
|
|
874
|
+
* `aria-busy`), then `success` (check) or `error` (shake + cross), and back
|
|
875
|
+
* to `idle` after `reset` ms (1800). Drive it with `state="…"` / `.state`, or
|
|
876
|
+
* call `event.detail.done(ok)` from a `usa:submit` listener.
|
|
877
|
+
*
|
|
878
|
+
* Attributes: `deform`, `shape`, `morph`, `state`, `reset`, `haptic`,
|
|
879
|
+
* `disabled`. Events: `usa:submit`, `usa:state`. Reduced motion: no
|
|
880
|
+
* deformation; shape and state changes are instant; status still announced.
|
|
881
|
+
*/
|
|
882
|
+
interface UsaButtonElement extends UsaElement {
|
|
883
|
+
readonly target: HTMLElement;
|
|
884
|
+
shape: ButtonShape;
|
|
885
|
+
state: ButtonState;
|
|
886
|
+
morphTo(shape: ButtonShape): Promise<void>;
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
/**
|
|
890
|
+
* `<usa-icon-morph>` — an icon that morphs between shapes with a spring:
|
|
891
|
+
* play ↔ pause, menu ↔ close, plus ↔ minus, check, arrow-right…
|
|
892
|
+
*
|
|
893
|
+
* Attributes: `icons` (comma list, cycled; default `play,pause`), `index`
|
|
894
|
+
* (current, 0), `size` (px, 24), `toggle` (makes it a button that cycles
|
|
895
|
+
* on click / Enter / Space), `labels` (comma list of accessible names per
|
|
896
|
+
* icon, e.g. `Play,Pause`), `preset` (spring, `wobbly`). Methods:
|
|
897
|
+
* `next()`, `show(nameOrIndex)`. Events: `usa:change` (`{ index, icon }`).
|
|
898
|
+
* Inside a `<usa-button>` or `<button>` it is decorative. Reduced motion:
|
|
899
|
+
* the icon switches instantly.
|
|
900
|
+
*/
|
|
901
|
+
interface UsaIconMorphElement extends UsaElement {
|
|
902
|
+
index: number;
|
|
903
|
+
readonly icon: string;
|
|
904
|
+
next(): void;
|
|
905
|
+
show(icon: string | number): void;
|
|
906
|
+
}
|
|
907
|
+
|
|
908
|
+
/**
|
|
909
|
+
* `<usa-like>` — a like / favourite toggle: the heart pops with a spring and
|
|
910
|
+
* bursts into particles when liked. `role="button"` + `aria-pressed`.
|
|
911
|
+
*
|
|
912
|
+
* Attributes: `liked`, `count` (shown next to the heart, updated ±1),
|
|
913
|
+
* `label` (accessible name, default "Like"), `color`, `size` (px, 24),
|
|
914
|
+
* `haptic`, `disabled`. Events: `change`, `usa:change` (`{ liked, count }`).
|
|
915
|
+
* Reduced motion: colour change only.
|
|
916
|
+
*/
|
|
917
|
+
interface UsaLikeElement extends UsaElement {
|
|
918
|
+
liked: boolean;
|
|
919
|
+
count: number | null;
|
|
920
|
+
toggle(force?: boolean): void;
|
|
921
|
+
}
|
|
922
|
+
|
|
923
|
+
/**
|
|
924
|
+
* `<usa-hold>` — hold-to-confirm: press and hold (pointer, Space or Enter)
|
|
925
|
+
* while a progress ring fills; releasing early rewinds it. Good for
|
|
926
|
+
* destructive actions.
|
|
927
|
+
*
|
|
928
|
+
* Attributes: `duration` (ms, 1200), `label` (accessible name), `color`,
|
|
929
|
+
* `disabled`. CSS variable `--usa-hold` (0–1). Events: `usa:progress`,
|
|
930
|
+
* `usa:confirm`, `usa:cancel`. Reduced motion: same timing, the ring fills
|
|
931
|
+
* without the scale pulse.
|
|
932
|
+
*/
|
|
933
|
+
interface UsaHoldElement extends UsaElement {
|
|
934
|
+
readonly progress: number;
|
|
935
|
+
cancel(): void;
|
|
936
|
+
}
|
|
937
|
+
|
|
938
|
+
/**
|
|
939
|
+
* `<usa-double-tap>` — detects a double tap / double click on its content
|
|
940
|
+
* (photos, posts) and pops a heart (or `icon`) at the tap point.
|
|
941
|
+
*
|
|
942
|
+
* Attributes: `icon` (text / emoji, default ♥), `color`, `delay` (max ms
|
|
943
|
+
* between taps, 300), `haptic`, `disabled`. Events: `usa:double-tap`
|
|
944
|
+
* (`{ x, y }`, element-relative). Keyboard users: press `L` while focused.
|
|
945
|
+
* Reduced motion: the icon fades in and out without scaling or particles.
|
|
946
|
+
*/
|
|
947
|
+
interface UsaDoubleTapElement extends UsaElement {
|
|
948
|
+
pop(x?: number, y?: number): void;
|
|
949
|
+
}
|
|
950
|
+
|
|
951
|
+
/**
|
|
952
|
+
* `<usa-checkbox>` — an animated, form-associated checkbox: the box springs
|
|
953
|
+
* and the check mark draws itself. `role="checkbox"` + `aria-checked`
|
|
954
|
+
* (`mixed` with `indeterminate`).
|
|
955
|
+
*
|
|
956
|
+
* Attributes: `checked`, `indeterminate`, `disabled`, `name`, `value`
|
|
957
|
+
* (`on`), `label`, `shape` (`square` default, `circle`). Events: `change`,
|
|
958
|
+
* `usa:change` (`{ checked }`). Reduced motion: no spring or drawing.
|
|
959
|
+
*/
|
|
960
|
+
interface UsaCheckboxElement extends UsaElement {
|
|
961
|
+
checked: boolean;
|
|
962
|
+
indeterminate: boolean;
|
|
963
|
+
toggle(force?: boolean): void;
|
|
964
|
+
}
|
|
965
|
+
|
|
966
|
+
/**
|
|
967
|
+
* use-scroll-animate/components/click — click & tap effects (v2.5).
|
|
968
|
+
* `<usa-click>` (ripple, burst, confetti, squish, press-spring, shake),
|
|
969
|
+
* `<usa-button>` (button click deformation: squash, wobble, gooey, dent;
|
|
970
|
+
* shape morph; submit → loading → success), `<usa-icon-morph>`,
|
|
971
|
+
* `<usa-like>`, `<usa-hold>`, `<usa-double-tap>`, `<usa-checkbox>`, plus
|
|
972
|
+
* `burst()`, `confetti()`, `shake()` and `haptic()`.
|
|
973
|
+
*/
|
|
974
|
+
|
|
975
|
+
declare global {
|
|
976
|
+
interface HTMLElementTagNameMap {
|
|
977
|
+
'usa-click': UsaClickElement;
|
|
978
|
+
'usa-button': UsaButtonElement;
|
|
979
|
+
'usa-icon-morph': UsaIconMorphElement;
|
|
980
|
+
'usa-like': UsaLikeElement;
|
|
981
|
+
'usa-hold': UsaHoldElement;
|
|
982
|
+
'usa-double-tap': UsaDoubleTapElement;
|
|
983
|
+
'usa-checkbox': UsaCheckboxElement;
|
|
984
|
+
}
|
|
985
|
+
}
|
|
986
|
+
|
|
987
|
+
/**
|
|
988
|
+
* `<usa-tabs>` — accessible tabs with a sliding (spring) indicator.
|
|
989
|
+
* Tabs: `[data-tab]` children (buttons); panels: `[data-panel]` children, in
|
|
990
|
+
* the same order. Arrow keys / Home / End move between tabs (roving tabindex).
|
|
991
|
+
*
|
|
992
|
+
* Attributes: `selected` (index, 0), `indicator` (`line` default, `pill`),
|
|
993
|
+
* `variant`. Events: `usa:change` (`{ index }`). Panels fade/slide in;
|
|
994
|
+
* reduced motion: the indicator jumps and panels switch instantly.
|
|
995
|
+
*/
|
|
996
|
+
interface UsaTabsElement extends UsaElement {
|
|
997
|
+
selected: number;
|
|
998
|
+
select(i: number, focus?: boolean): void;
|
|
999
|
+
}
|
|
1000
|
+
|
|
1001
|
+
/**
|
|
1002
|
+
* `<usa-drawer>` — a side panel that slides in with a spring and can be
|
|
1003
|
+
* dragged / swiped closed. Modal: backdrop, Esc, focus returns on close.
|
|
1004
|
+
* Attributes: `open`, `side` (`left` default, `right`, `top`, `bottom`),
|
|
1005
|
+
* `label`, `variant`. Events: `usa:open`, `usa:close`. `[data-close]` closes.
|
|
1006
|
+
* Reduced motion: opens and closes instantly.
|
|
1007
|
+
*/
|
|
1008
|
+
interface UsaDrawerElement extends UsaElement {
|
|
1009
|
+
open: boolean;
|
|
1010
|
+
show(): void;
|
|
1011
|
+
close(): void;
|
|
1012
|
+
}
|
|
1013
|
+
/**
|
|
1014
|
+
* `<usa-bottom-sheet>` — a draggable bottom sheet with snap points
|
|
1015
|
+
* (`snap="0.3,0.6,0.92"`, fractions of the viewport height; default
|
|
1016
|
+
* `0.5,0.92`; `start` = index of the snap it opens at, default 0), inertia and drag-down-to-dismiss. `[data-handle]` (or the
|
|
1017
|
+
* built-in grabber) drags it. Attributes: `open`, `snap`, `start` (initial
|
|
1018
|
+
* snap index), `label`, `variant`. Events: `usa:open`, `usa:close`, `usa:snap`.
|
|
1019
|
+
*/
|
|
1020
|
+
interface UsaBottomSheetElement extends UsaDrawerElement {
|
|
1021
|
+
}
|
|
1022
|
+
|
|
1023
|
+
/**
|
|
1024
|
+
* `<usa-pull-refresh>` — pull-to-refresh for a scroll container (itself):
|
|
1025
|
+
* pull down at the top (touch / pointer) and a spinner stretches in; past
|
|
1026
|
+
* `threshold` (px, 70) releasing fires `usa:refresh` — call
|
|
1027
|
+
* `event.detail.done()` (or return a promise to `onrefresh`) to finish.
|
|
1028
|
+
* Also exposes `refresh()` for a keyboard / button path.
|
|
1029
|
+
* Attributes: `threshold`, `disabled`, `label` (status text, "Refreshing").
|
|
1030
|
+
* Reduced motion: no stretch; the spinner simply appears while refreshing.
|
|
1031
|
+
*/
|
|
1032
|
+
interface UsaPullRefreshElement extends UsaElement {
|
|
1033
|
+
readonly refreshing: boolean;
|
|
1034
|
+
refresh(): Promise<void>;
|
|
1035
|
+
}
|
|
1036
|
+
|
|
1037
|
+
/**
|
|
1038
|
+
* `<usa-fab>` — floating action button with a speed dial. The first element
|
|
1039
|
+
* child is the main button; the others are actions that fan out with a
|
|
1040
|
+
* staggered spring when it opens (`direction="up"` default, `down`, `left`,
|
|
1041
|
+
* `right`, `radial`). Esc / outside click closes; `aria-expanded` on the
|
|
1042
|
+
* main button; actions are hidden from AT while closed.
|
|
1043
|
+
* Attributes: `open`, `direction`, `position` (`bottom-right` default, `bottom-left`,
|
|
1044
|
+
* `inline`), `gap` (px, 56), `variant`. Events: `usa:toggle` (`{ open }`).
|
|
1045
|
+
* Reduced motion: actions appear without travel.
|
|
1046
|
+
*/
|
|
1047
|
+
interface UsaFabElement extends UsaElement {
|
|
1048
|
+
open: boolean;
|
|
1049
|
+
toggle(force?: boolean): void;
|
|
1050
|
+
}
|
|
1051
|
+
|
|
1052
|
+
/**
|
|
1053
|
+
* `<usa-navbar>` — an app bar that hides while you scroll down and returns
|
|
1054
|
+
* as soon as you scroll up (or reach the top); `shrink` makes it compact
|
|
1055
|
+
* once scrolled. Focus inside always reveals it.
|
|
1056
|
+
* Attributes: `threshold` (px of scroll before hiding, 64), `shrink`,
|
|
1057
|
+
* `target` (selector of a scroll container instead of the page), `variant`.
|
|
1058
|
+
* State attributes: `data-hidden`, `data-scrolled`. Events: `usa:hide`, `usa:show`.
|
|
1059
|
+
* Reduced motion: hides/shows without sliding (instant).
|
|
1060
|
+
*/
|
|
1061
|
+
interface UsaNavbarElement extends UsaElement {
|
|
1062
|
+
readonly hiddenByScroll: boolean;
|
|
1063
|
+
show(): void;
|
|
1064
|
+
}
|
|
1065
|
+
|
|
1066
|
+
/**
|
|
1067
|
+
* `<usa-slider>` — a form-associated range slider (`role="slider"`). The
|
|
1068
|
+
* thumb follows with a spring, grows while dragged and shows a value bubble.
|
|
1069
|
+
* Keyboard: arrows (step), PageUp/PageDown (10 steps), Home/End.
|
|
1070
|
+
* Attributes: `value`, `min` (0), `max` (100), `step` (1), `name`, `label`,
|
|
1071
|
+
* `bubble` (show the value while dragging), `disabled`, `variant`.
|
|
1072
|
+
* Events: `input` + `usa:input` while moving, `change` + `usa:change` on release.
|
|
1073
|
+
* Reduced motion: the thumb jumps (no spring).
|
|
1074
|
+
*/
|
|
1075
|
+
interface UsaSliderElement extends UsaElement {
|
|
1076
|
+
value: number;
|
|
1077
|
+
}
|
|
1078
|
+
|
|
1079
|
+
/**
|
|
1080
|
+
* `<usa-rating>` — star rating with hover preview and a springy pop when a
|
|
1081
|
+
* value is chosen. `role="slider"` (arrow keys, Home/End, number keys).
|
|
1082
|
+
* Attributes: `value` (0), `max` (5), `icon` (★), `readonly`, `label`
|
|
1083
|
+
* ("Rating"), `name` (form value), `variant`. Events: `change`, `usa:change` (`{ value }`).
|
|
1084
|
+
* Reduced motion: no pop.
|
|
1085
|
+
*/
|
|
1086
|
+
interface UsaRatingElement extends UsaElement {
|
|
1087
|
+
value: number;
|
|
1088
|
+
}
|
|
1089
|
+
|
|
1090
|
+
/**
|
|
1091
|
+
* `<usa-tooltip text="…">` — a tooltip for the element it wraps, shown on
|
|
1092
|
+
* hover (after `delay` ms, 300) and on keyboard focus, hidden on Esc / blur.
|
|
1093
|
+
* It springs in from its placement side and flips to stay on screen; the
|
|
1094
|
+
* trigger gets `aria-describedby`.
|
|
1095
|
+
* Attributes: `text`, `placement` (`top` default, `bottom`, `left`, `right`),
|
|
1096
|
+
* `delay`, `variant`. Reduced motion: fades only.
|
|
1097
|
+
*/
|
|
1098
|
+
interface UsaTooltipElement extends UsaElement {
|
|
1099
|
+
show(): void;
|
|
1100
|
+
hide(): void;
|
|
1101
|
+
}
|
|
1102
|
+
|
|
1103
|
+
/**
|
|
1104
|
+
* `<usa-popover>` — a click-to-open popover: the first element child is the
|
|
1105
|
+
* trigger, `[data-popover]` is the content. Springs open from the trigger,
|
|
1106
|
+
* flips to stay on screen; Esc or an outside click closes and focus returns
|
|
1107
|
+
* to the trigger. `aria-expanded` / `aria-controls` on the trigger.
|
|
1108
|
+
* Attributes: `open`, `placement` (`bottom` default), `variant`. Events:
|
|
1109
|
+
* `usa:open`, `usa:close`. Reduced motion: fades only.
|
|
1110
|
+
*/
|
|
1111
|
+
interface UsaPopoverElement extends UsaElement {
|
|
1112
|
+
open: boolean;
|
|
1113
|
+
toggle(force?: boolean): void;
|
|
1114
|
+
}
|
|
1115
|
+
|
|
1116
|
+
/**
|
|
1117
|
+
* `<usa-badge>` — a count / dot badge on whatever it wraps; bumps with a
|
|
1118
|
+
* spring whenever the value changes and pulses with `pulse`.
|
|
1119
|
+
* Attributes: `value` (number or text; 0 / empty hides it unless
|
|
1120
|
+
* `show-zero`), `max` (99 → "99+"), `dot`, `pulse`, `label` (accessible
|
|
1121
|
+
* text, default "{n} new"), `variant`. Reduced motion: no bump or pulse.
|
|
1122
|
+
*/
|
|
1123
|
+
interface UsaBadgeElement extends UsaElement {
|
|
1124
|
+
value: string;
|
|
1125
|
+
}
|
|
1126
|
+
|
|
1127
|
+
/**
|
|
1128
|
+
* `<usa-avatar-stack>` — overlapping avatars (its children: `<img>` or any
|
|
1129
|
+
* element) that spread apart with a spring on hover / focus; extra ones
|
|
1130
|
+
* collapse into a "+N" chip.
|
|
1131
|
+
* Attributes: `max` (visible avatars, 5), `size` (px, 36), `overlap` (0–1,
|
|
1132
|
+
* 0.35), `label` (group name), `variant`. Reduced motion: no spreading.
|
|
1133
|
+
*/
|
|
1134
|
+
interface UsaAvatarStackElement extends UsaElement {
|
|
1135
|
+
}
|
|
1136
|
+
|
|
1137
|
+
/**
|
|
1138
|
+
* use-scroll-animate/components/ui — animated UI components + style variants (v2.6).
|
|
1139
|
+
* `<usa-tabs>`, `<usa-drawer>`, `<usa-bottom-sheet>`, `<usa-pull-refresh>`,
|
|
1140
|
+
* `<usa-fab>`, `<usa-navbar>`, `<usa-slider>`, `<usa-rating>`,
|
|
1141
|
+
* `<usa-tooltip>`, `<usa-popover>`, `<usa-badge>`, `<usa-avatar-stack>`,
|
|
1142
|
+
* and `variant="minimal | neon | glass | brutalist | fluent | material"`
|
|
1143
|
+
* design tokens (`setVariant()`, `VARIANTS`).
|
|
1144
|
+
*/
|
|
1145
|
+
|
|
1146
|
+
declare global {
|
|
1147
|
+
interface HTMLElementTagNameMap {
|
|
1148
|
+
'usa-tabs': UsaTabsElement;
|
|
1149
|
+
'usa-drawer': UsaDrawerElement;
|
|
1150
|
+
'usa-bottom-sheet': UsaBottomSheetElement;
|
|
1151
|
+
'usa-pull-refresh': UsaPullRefreshElement;
|
|
1152
|
+
'usa-fab': UsaFabElement;
|
|
1153
|
+
'usa-navbar': UsaNavbarElement;
|
|
1154
|
+
'usa-slider': UsaSliderElement;
|
|
1155
|
+
'usa-rating': UsaRatingElement;
|
|
1156
|
+
'usa-tooltip': UsaTooltipElement;
|
|
1157
|
+
'usa-popover': UsaPopoverElement;
|
|
1158
|
+
'usa-badge': UsaBadgeElement;
|
|
1159
|
+
'usa-avatar-stack': UsaAvatarStackElement;
|
|
1160
|
+
}
|
|
1161
|
+
}
|
|
1162
|
+
|
|
1163
|
+
/**
|
|
1164
|
+
* `<usa-cursor mode="dot | trail | magnetic | glow">` — a custom cursor for
|
|
1165
|
+
* the page (place it once, e.g. at the end of `<body>`).
|
|
1166
|
+
* - `dot` — a ring that follows with spring lag around the real pointer;
|
|
1167
|
+
* - `trail` — a comet tail of dots;
|
|
1168
|
+
* - `magnetic` — the ring snaps onto and wraps hovered targets (`a`,
|
|
1169
|
+
* `button`, `[data-cursor]`);
|
|
1170
|
+
* - `glow` — a large soft light following the pointer (great on dark UIs).
|
|
1171
|
+
* Attributes: `mode`, `color`, `size` (px, 28), `hide-native` (hide the
|
|
1172
|
+
* system cursor), `targets` (selector, magnetic). Only for fine pointers
|
|
1173
|
+
* (mouse / pen); never on touch. Reduced motion: not rendered.
|
|
1174
|
+
*/
|
|
1175
|
+
interface UsaCursorElement extends UsaElement {
|
|
1176
|
+
readonly active: boolean;
|
|
1177
|
+
}
|
|
1178
|
+
|
|
1179
|
+
/**
|
|
1180
|
+
* `<usa-fullpage>` — full-screen sections (its element children) that snap
|
|
1181
|
+
* one at a time (CSS scroll snap), with keyboard paging (PageUp/PageDown,
|
|
1182
|
+
* arrows, Home/End), optional dot navigation and the current section in
|
|
1183
|
+
* `aria-current` + `usa:section`.
|
|
1184
|
+
* Attributes: `dots` (show the dot nav), `axis` (`y` default, `x`).
|
|
1185
|
+
* Methods: `go(i)`, `next()`, `prev()`. Reduced motion: snapping stays,
|
|
1186
|
+
* jumps are instant.
|
|
1187
|
+
*/
|
|
1188
|
+
interface UsaFullpageElement extends UsaElement {
|
|
1189
|
+
readonly index: number;
|
|
1190
|
+
go(i: number): void;
|
|
1191
|
+
next(): void;
|
|
1192
|
+
prev(): void;
|
|
1193
|
+
}
|
|
1194
|
+
|
|
1195
|
+
/**
|
|
1196
|
+
* `<usa-loading-bar>` — a slim top loading bar for route changes and fetches
|
|
1197
|
+
* (NProgress-style): `start()` trickles towards 90 %, `done()` completes and
|
|
1198
|
+
* fades out, `set(0–1)` for real progress. `loadingBar` drives the first bar
|
|
1199
|
+
* on the page (created on demand). `role="progressbar"`, `aria-busy`.
|
|
1200
|
+
* Attributes: `color`, `height` (px, 3), `position` (`top` default, `bottom`).
|
|
1201
|
+
* Reduced motion: no trickle animation — the bar shows / hides.
|
|
1202
|
+
*/
|
|
1203
|
+
interface UsaLoadingBarElement extends UsaElement {
|
|
1204
|
+
readonly progress: number;
|
|
1205
|
+
start(): void;
|
|
1206
|
+
set(p: number): void;
|
|
1207
|
+
done(): void;
|
|
1208
|
+
}
|
|
1209
|
+
|
|
1210
|
+
/**
|
|
1211
|
+
* `<usa-back-to-top>` — a floating button that appears after `offset` px
|
|
1212
|
+
* (300) of scrolling, shows page progress as a ring and springs the page
|
|
1213
|
+
* back to the top (then focuses `focus-target`, default `#main` / `body`).
|
|
1214
|
+
* Attributes: `offset`, `label` ("Back to top"), `focus-target`, `position`
|
|
1215
|
+
* (`bottom-right` default, `bottom-left`). Reduced motion: instant jump.
|
|
1216
|
+
*/
|
|
1217
|
+
interface UsaBackToTopElement extends UsaElement {
|
|
1218
|
+
readonly visible: boolean;
|
|
1219
|
+
}
|
|
1220
|
+
|
|
1221
|
+
/**
|
|
1222
|
+
* `<usa-ambient effect="particles | snow | stars | noise | gradient">` — a
|
|
1223
|
+
* fixed, page-wide ambient layer behind (or, with `layer="front"`, over)
|
|
1224
|
+
* the content, never catching the pointer.
|
|
1225
|
+
* - `particles` — slow drifting dots; `snow` — falling flakes with sway;
|
|
1226
|
+
* `stars` — twinkling starfield (canvas, paused in hidden tabs, DPR ≤ 2);
|
|
1227
|
+
* - `noise` — animated film grain (CSS, SVG turbulence);
|
|
1228
|
+
* - `gradient` — a gradient whose hue shifts with the scroll position.
|
|
1229
|
+
* Attributes: `effect`, `density` (0.2–3, 1), `color`, `opacity` (0.6),
|
|
1230
|
+
* `layer` (`back` default, `front`), `speed` (1). Reduced motion: one
|
|
1231
|
+
* static frame (no falling, twinkling or grain flicker).
|
|
1232
|
+
*/
|
|
1233
|
+
interface UsaAmbientElement extends UsaElement {
|
|
1234
|
+
}
|
|
1235
|
+
|
|
1236
|
+
/**
|
|
1237
|
+
* `<usa-splash>` — an app splash / launch screen: shows its content (logo,
|
|
1238
|
+
* spinner) over the page, then leaves with `exit` (`fade` default, `scale`,
|
|
1239
|
+
* `slide-up`, `circle`) once the page has loaded (or when you call
|
|
1240
|
+
* `done()`), but never sooner than `min` ms (600) — no flash.
|
|
1241
|
+
* Attributes: `min`, `exit`, `manual` (wait for `done()`), `label`.
|
|
1242
|
+
* Events: `usa:done`. The page underneath is `aria-busy` until then.
|
|
1243
|
+
* Reduced motion: fades.
|
|
1244
|
+
*/
|
|
1245
|
+
interface UsaSplashElement extends UsaElement {
|
|
1246
|
+
done(): Promise<void>;
|
|
1247
|
+
}
|
|
1248
|
+
|
|
1249
|
+
/**
|
|
1250
|
+
* `<usa-auto-skeleton loading>` — automatic skeletons: while `loading` is
|
|
1251
|
+
* set, every text block, image, button and input inside is drawn as a
|
|
1252
|
+
* shimmering placeholder of its own size — no separate skeleton markup.
|
|
1253
|
+
* Remove `loading` (or set `.loading = false`) and the content fades in.
|
|
1254
|
+
* `aria-busy` while loading. Opt elements out with `data-no-skeleton`.
|
|
1255
|
+
* Reduced motion: static placeholders, no shimmer or fade.
|
|
1256
|
+
*/
|
|
1257
|
+
interface UsaAutoSkeletonElement extends UsaElement {
|
|
1258
|
+
loading: boolean;
|
|
1259
|
+
}
|
|
1260
|
+
|
|
1261
|
+
/**
|
|
1262
|
+
* `<usa-motion-switch>` — a segmented control letting users choose the
|
|
1263
|
+
* app's motion intensity (Off · Low · Normal · High), persisted.
|
|
1264
|
+
* `role="radiogroup"`; arrow keys move. Attributes: `labels` (comma list),
|
|
1265
|
+
* `label` ("Motion"). Events: `usa:change` (`{ level }`).
|
|
1266
|
+
*/
|
|
1267
|
+
interface UsaMotionSwitchElement extends UsaElement {
|
|
1268
|
+
value: MotionIntensity;
|
|
1269
|
+
}
|
|
1270
|
+
|
|
1271
|
+
/**
|
|
1272
|
+
* use-scroll-animate/components/page — page & app-wide effects (v2.7).
|
|
1273
|
+
* Page transitions (`pageTransition()`, `enableMpaTransitions()`,
|
|
1274
|
+
* `themeTransition()`), `<usa-cursor>`, `smoothScroll()` / `scrollToTarget()`,
|
|
1275
|
+
* `<usa-fullpage>`, `<usa-loading-bar>` + `loadingBar`, `<usa-back-to-top>`,
|
|
1276
|
+
* `<usa-ambient>`, `<usa-splash>`, `<usa-auto-skeleton>` and the global motion
|
|
1277
|
+
* intensity (`setMotionIntensity()`, `<usa-motion-switch>`).
|
|
1278
|
+
*/
|
|
1279
|
+
|
|
1280
|
+
declare global {
|
|
1281
|
+
interface HTMLElementTagNameMap {
|
|
1282
|
+
'usa-cursor': UsaCursorElement;
|
|
1283
|
+
'usa-fullpage': UsaFullpageElement;
|
|
1284
|
+
'usa-loading-bar': UsaLoadingBarElement;
|
|
1285
|
+
'usa-back-to-top': UsaBackToTopElement;
|
|
1286
|
+
'usa-ambient': UsaAmbientElement;
|
|
1287
|
+
'usa-splash': UsaSplashElement;
|
|
1288
|
+
'usa-auto-skeleton': UsaAutoSkeletonElement;
|
|
1289
|
+
'usa-motion-switch': UsaMotionSwitchElement;
|
|
1290
|
+
}
|
|
1291
|
+
}
|
|
1292
|
+
|
|
1293
|
+
/** The component categories and their default tags. */
|
|
1294
|
+
declare const COMPONENT_CATEGORIES: {
|
|
1295
|
+
readonly reveal: readonly ["usa-reveal", "usa-stagger", "usa-scroll-progress", "usa-scrolly"];
|
|
1296
|
+
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"];
|
|
1297
|
+
readonly interaction: readonly ["usa-ripple", "usa-magnetic", "usa-tilt", "usa-spotlight", "usa-press", "usa-toggle"];
|
|
1298
|
+
readonly feedback: readonly ["usa-spinner", "usa-skeleton", "usa-progress", "usa-toaster", "usa-check"];
|
|
1299
|
+
readonly background: readonly ["usa-aurora", "usa-particles", "usa-grain", "usa-marquee", "usa-acrylic", "usa-grid-glow", "usa-blobs", "usa-water-ripple", "usa-dot-network"];
|
|
1300
|
+
readonly transitions: readonly ["usa-dialog", "usa-accordion", "usa-flip-list", "usa-view-switch"];
|
|
1301
|
+
readonly physics: readonly ["usa-spring", "usa-draggable", "usa-overscroll"];
|
|
1302
|
+
readonly cards: readonly ["usa-card", "usa-card-stack", "usa-sticky-stack", "usa-carousel-3d"];
|
|
1303
|
+
readonly click: readonly ["usa-click", "usa-button", "usa-icon-morph", "usa-like", "usa-hold", "usa-double-tap", "usa-checkbox"];
|
|
1304
|
+
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"];
|
|
1305
|
+
readonly page: readonly ["usa-cursor", "usa-fullpage", "usa-loading-bar", "usa-back-to-top", "usa-ambient", "usa-splash", "usa-auto-skeleton", "usa-motion-switch"];
|
|
1306
|
+
};
|
|
1307
|
+
type ComponentCategory = keyof typeof COMPONENT_CATEGORIES;
|
|
1308
|
+
|
|
1309
|
+
/**
|
|
1310
|
+
* use-scroll-animate/components/vue — Vue integration (v2.9).
|
|
1311
|
+
*
|
|
1312
|
+
* ```js
|
|
1313
|
+
* // vite.config.js
|
|
1314
|
+
* import vue from '@vitejs/plugin-vue';
|
|
1315
|
+
* import { isUsaElement } from 'use-scroll-animate/components/vue';
|
|
1316
|
+
* export default { plugins: [vue({ template: { compilerOptions: { isCustomElement: isUsaElement } } })] };
|
|
1317
|
+
*
|
|
1318
|
+
* // main.js
|
|
1319
|
+
* import { UsaPlugin } from 'use-scroll-animate/components/vue';
|
|
1320
|
+
* app.use(UsaPlugin, { categories: ['click', 'cards'] });
|
|
1321
|
+
* ```
|
|
1322
|
+
* In templates, listen with `@usa:change="…"` and bind properties with
|
|
1323
|
+
* `.prop`: `<usa-toggle :checked.prop="on" @usa:change="on = $event.detail.checked">`.
|
|
1324
|
+
*/
|
|
1325
|
+
|
|
1326
|
+
/** `compilerOptions.isCustomElement` predicate for every `<usa-*>` tag. */
|
|
1327
|
+
declare const isUsaElement: (tag: string) => boolean;
|
|
1328
|
+
interface UsaPluginOptions {
|
|
1329
|
+
/** Only register these categories (default: all). */
|
|
1330
|
+
categories?: ComponentCategory[];
|
|
1331
|
+
}
|
|
1332
|
+
/** Vue plugin: registers the `<usa-*>` elements (client only) and sets `isCustomElement` at runtime. */
|
|
1333
|
+
declare const UsaPlugin: {
|
|
1334
|
+
install(app: {
|
|
1335
|
+
config: {
|
|
1336
|
+
compilerOptions?: {
|
|
1337
|
+
isCustomElement?: (t: string) => boolean;
|
|
1338
|
+
};
|
|
1339
|
+
};
|
|
1340
|
+
}, options?: UsaPluginOptions): void;
|
|
1341
|
+
};
|
|
1342
|
+
|
|
1343
|
+
export { UsaPlugin, isUsaElement };
|
|
1344
|
+
export type { UsaPluginOptions };
|