use-scroll-animate 2.5.0 → 2.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/CHANGELOG.md +37 -0
  2. package/README.md +2 -0
  3. package/README_ja.md +2 -0
  4. package/README_zh.md +2 -0
  5. package/dist/chunks/{base-CJ7XfidP.cjs → base-BR6fYLBA.cjs} +25 -2
  6. package/dist/chunks/base-BR6fYLBA.cjs.map +1 -0
  7. package/dist/chunks/{base-CuvCgqLy.js → base-D6zLiNGH.js} +21 -3
  8. package/dist/chunks/base-D6zLiNGH.js.map +1 -0
  9. package/dist/chunks/{spring-BKUU7-Xm.js → spring-C2Megtcf.js} +3 -3
  10. package/dist/chunks/spring-C2Megtcf.js.map +1 -0
  11. package/dist/chunks/{spring-CGO9Jd9b.cjs → spring-DyHe1Hfa.cjs} +3 -3
  12. package/dist/chunks/spring-DyHe1Hfa.cjs.map +1 -0
  13. package/dist/components/background.cjs +1 -1
  14. package/dist/components/background.d.cts +8 -0
  15. package/dist/components/background.d.ts +8 -0
  16. package/dist/components/background.js +2 -2
  17. package/dist/components/cards.cjs +2 -2
  18. package/dist/components/cards.d.cts +8 -0
  19. package/dist/components/cards.d.ts +8 -0
  20. package/dist/components/cards.js +3 -3
  21. package/dist/components/click.cjs +2 -2
  22. package/dist/components/click.d.cts +8 -0
  23. package/dist/components/click.d.ts +8 -0
  24. package/dist/components/click.js +3 -3
  25. package/dist/components/feedback.cjs +2 -2
  26. package/dist/components/feedback.css +1 -1
  27. package/dist/components/feedback.d.cts +8 -0
  28. package/dist/components/feedback.d.ts +8 -0
  29. package/dist/components/feedback.js +3 -3
  30. package/dist/components/interaction.cjs +2 -2
  31. package/dist/components/interaction.css +1 -1
  32. package/dist/components/interaction.d.cts +8 -0
  33. package/dist/components/interaction.d.ts +8 -0
  34. package/dist/components/interaction.js +3 -3
  35. package/dist/components/page.cjs +801 -0
  36. package/dist/components/page.cjs.map +1 -0
  37. package/dist/components/page.css +11 -0
  38. package/dist/components/page.d.cts +275 -0
  39. package/dist/components/page.d.ts +275 -0
  40. package/dist/components/page.js +776 -0
  41. package/dist/components/page.js.map +1 -0
  42. package/dist/components/physics.cjs +2 -2
  43. package/dist/components/physics.d.cts +8 -0
  44. package/dist/components/physics.d.ts +8 -0
  45. package/dist/components/physics.js +4 -4
  46. package/dist/components/reveal.cjs +1 -1
  47. package/dist/components/reveal.d.cts +8 -0
  48. package/dist/components/reveal.d.ts +8 -0
  49. package/dist/components/reveal.js +2 -2
  50. package/dist/components/text.cjs +1 -1
  51. package/dist/components/text.d.cts +8 -0
  52. package/dist/components/text.d.ts +8 -0
  53. package/dist/components/text.js +2 -2
  54. package/dist/components/transitions.cjs +1 -1
  55. package/dist/components/transitions.d.cts +8 -0
  56. package/dist/components/transitions.d.ts +8 -0
  57. package/dist/components/transitions.js +2 -2
  58. package/dist/components/ui.cjs +1082 -0
  59. package/dist/components/ui.cjs.map +1 -0
  60. package/dist/components/ui.css +14 -0
  61. package/dist/components/ui.d.cts +259 -0
  62. package/dist/components/ui.d.ts +259 -0
  63. package/dist/components/ui.js +1064 -0
  64. package/dist/components/ui.js.map +1 -0
  65. package/dist/components.cjs +51 -4
  66. package/dist/components.cjs.map +1 -1
  67. package/dist/components.css +23 -2
  68. package/dist/components.d.cts +452 -2
  69. package/dist/components.d.ts +452 -2
  70. package/dist/components.js +14 -3
  71. package/dist/components.js.map +1 -1
  72. package/dist/components.umd.js +2 -2
  73. package/dist/components.umd.js.map +1 -1
  74. package/docs/components.md +37 -0
  75. package/package.json +24 -2
  76. package/dist/chunks/base-CJ7XfidP.cjs.map +0 -1
  77. package/dist/chunks/base-CuvCgqLy.js.map +0 -1
  78. package/dist/chunks/spring-BKUU7-Xm.js.map +0 -1
  79. package/dist/chunks/spring-CGO9Jd9b.cjs.map +0 -1
@@ -0,0 +1,259 @@
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
+ * Global motion intensity (v2.7): `'off'` (same as reduced motion),
25
+ * `'low'` (shorter, calmer), `'normal'` (default) or `'high'`. Scales every
26
+ * component animation's duration and sets `--usa-motion` (0 / 0.6 / 1 /
27
+ * 1.25) on `<html>` for your own CSS. See `setMotionIntensity()`.
28
+ */
29
+ motionIntensity?: MotionIntensity;
30
+ }
31
+ type MotionIntensity = 'off' | 'low' | 'normal' | 'high';
32
+ /** Change global component settings (call before `define*()` for `injectStyles`). */
33
+ declare function configureComponents(options: ComponentsConfig): void;
34
+ /** `true` when animations should be reduced (OS setting or `configureComponents`). */
35
+ declare function prefersReducedMotion(): boolean;
36
+ /**
37
+ * Members shared by every `<usa-*>` element. Attribute helpers, a cleanup
38
+ * bag that is emptied on disconnect, and motion helpers that degrade to the
39
+ * final state without WAAPI or under reduced motion.
40
+ */
41
+ interface UsaElement extends HTMLElement {
42
+ /** `true` while reduced motion applies to this element. */
43
+ readonly reduced: boolean;
44
+ }
45
+
46
+ /**
47
+ * `<usa-tabs>` — accessible tabs with a sliding (spring) indicator.
48
+ * Tabs: `[data-tab]` children (buttons); panels: `[data-panel]` children, in
49
+ * the same order. Arrow keys / Home / End move between tabs (roving tabindex).
50
+ *
51
+ * Attributes: `selected` (index, 0), `indicator` (`line` default, `pill`),
52
+ * `variant`. Events: `usa:change` (`{ index }`). Panels fade/slide in;
53
+ * reduced motion: the indicator jumps and panels switch instantly.
54
+ */
55
+ interface UsaTabsElement extends UsaElement {
56
+ selected: number;
57
+ select(i: number, focus?: boolean): void;
58
+ }
59
+ declare function defineTabs(tag?: string): CustomElementConstructor | undefined;
60
+
61
+ /**
62
+ * `<usa-drawer>` — a side panel that slides in with a spring and can be
63
+ * dragged / swiped closed. Modal: backdrop, Esc, focus returns on close.
64
+ * Attributes: `open`, `side` (`left` default, `right`, `top`, `bottom`),
65
+ * `label`, `variant`. Events: `usa:open`, `usa:close`. `[data-close]` closes.
66
+ * Reduced motion: opens and closes instantly.
67
+ */
68
+ interface UsaDrawerElement extends UsaElement {
69
+ open: boolean;
70
+ show(): void;
71
+ close(): void;
72
+ }
73
+ /**
74
+ * `<usa-bottom-sheet>` — a draggable bottom sheet with snap points
75
+ * (`snap="0.3,0.6,0.92"`, fractions of the viewport height; default
76
+ * `0.5,0.92`; `start` = index of the snap it opens at, default 0), inertia and drag-down-to-dismiss. `[data-handle]` (or the
77
+ * built-in grabber) drags it. Attributes: `open`, `snap`, `start` (initial
78
+ * snap index), `label`, `variant`. Events: `usa:open`, `usa:close`, `usa:snap`.
79
+ */
80
+ interface UsaBottomSheetElement extends UsaDrawerElement {
81
+ }
82
+ declare function defineDrawer(tag?: string): CustomElementConstructor | undefined;
83
+ declare function defineBottomSheet(tag?: string): CustomElementConstructor | undefined;
84
+
85
+ /**
86
+ * `<usa-pull-refresh>` — pull-to-refresh for a scroll container (itself):
87
+ * pull down at the top (touch / pointer) and a spinner stretches in; past
88
+ * `threshold` (px, 70) releasing fires `usa:refresh` — call
89
+ * `event.detail.done()` (or return a promise to `onrefresh`) to finish.
90
+ * Also exposes `refresh()` for a keyboard / button path.
91
+ * Attributes: `threshold`, `disabled`, `label` (status text, "Refreshing").
92
+ * Reduced motion: no stretch; the spinner simply appears while refreshing.
93
+ */
94
+ interface UsaPullRefreshElement extends UsaElement {
95
+ readonly refreshing: boolean;
96
+ refresh(): Promise<void>;
97
+ }
98
+ declare function definePullRefresh(tag?: string): CustomElementConstructor | undefined;
99
+
100
+ /**
101
+ * `<usa-fab>` — floating action button with a speed dial. The first element
102
+ * child is the main button; the others are actions that fan out with a
103
+ * staggered spring when it opens (`direction="up"` default, `down`, `left`,
104
+ * `right`, `radial`). Esc / outside click closes; `aria-expanded` on the
105
+ * main button; actions are hidden from AT while closed.
106
+ * Attributes: `open`, `direction`, `position` (`bottom-right` default, `bottom-left`,
107
+ * `inline`), `gap` (px, 56), `variant`. Events: `usa:toggle` (`{ open }`).
108
+ * Reduced motion: actions appear without travel.
109
+ */
110
+ interface UsaFabElement extends UsaElement {
111
+ open: boolean;
112
+ toggle(force?: boolean): void;
113
+ }
114
+ declare function defineFab(tag?: string): CustomElementConstructor | undefined;
115
+
116
+ /**
117
+ * `<usa-navbar>` — an app bar that hides while you scroll down and returns
118
+ * as soon as you scroll up (or reach the top); `shrink` makes it compact
119
+ * once scrolled. Focus inside always reveals it.
120
+ * Attributes: `threshold` (px of scroll before hiding, 64), `shrink`,
121
+ * `target` (selector of a scroll container instead of the page), `variant`.
122
+ * State attributes: `data-hidden`, `data-scrolled`. Events: `usa:hide`, `usa:show`.
123
+ * Reduced motion: hides/shows without sliding (instant).
124
+ */
125
+ interface UsaNavbarElement extends UsaElement {
126
+ readonly hiddenByScroll: boolean;
127
+ show(): void;
128
+ }
129
+ declare function defineNavbar(tag?: string): CustomElementConstructor | undefined;
130
+
131
+ /**
132
+ * `<usa-slider>` — a form-associated range slider (`role="slider"`). The
133
+ * thumb follows with a spring, grows while dragged and shows a value bubble.
134
+ * Keyboard: arrows (step), PageUp/PageDown (10 steps), Home/End.
135
+ * Attributes: `value`, `min` (0), `max` (100), `step` (1), `name`, `label`,
136
+ * `bubble` (show the value while dragging), `disabled`, `variant`.
137
+ * Events: `input` + `usa:input` while moving, `change` + `usa:change` on release.
138
+ * Reduced motion: the thumb jumps (no spring).
139
+ */
140
+ interface UsaSliderElement extends UsaElement {
141
+ value: number;
142
+ }
143
+ declare function defineSlider(tag?: string): CustomElementConstructor | undefined;
144
+
145
+ /**
146
+ * `<usa-rating>` — star rating with hover preview and a springy pop when a
147
+ * value is chosen. `role="slider"` (arrow keys, Home/End, number keys).
148
+ * Attributes: `value` (0), `max` (5), `icon` (★), `readonly`, `label`
149
+ * ("Rating"), `name` (form value), `variant`. Events: `change`, `usa:change` (`{ value }`).
150
+ * Reduced motion: no pop.
151
+ */
152
+ interface UsaRatingElement extends UsaElement {
153
+ value: number;
154
+ }
155
+ declare function defineRating(tag?: string): CustomElementConstructor | undefined;
156
+
157
+ /**
158
+ * `<usa-tooltip text="…">` — a tooltip for the element it wraps, shown on
159
+ * hover (after `delay` ms, 300) and on keyboard focus, hidden on Esc / blur.
160
+ * It springs in from its placement side and flips to stay on screen; the
161
+ * trigger gets `aria-describedby`.
162
+ * Attributes: `text`, `placement` (`top` default, `bottom`, `left`, `right`),
163
+ * `delay`, `variant`. Reduced motion: fades only.
164
+ */
165
+ interface UsaTooltipElement extends UsaElement {
166
+ show(): void;
167
+ hide(): void;
168
+ }
169
+ declare function defineTooltip(tag?: string): CustomElementConstructor | undefined;
170
+
171
+ /**
172
+ * `<usa-popover>` — a click-to-open popover: the first element child is the
173
+ * trigger, `[data-popover]` is the content. Springs open from the trigger,
174
+ * flips to stay on screen; Esc or an outside click closes and focus returns
175
+ * to the trigger. `aria-expanded` / `aria-controls` on the trigger.
176
+ * Attributes: `open`, `placement` (`bottom` default), `variant`. Events:
177
+ * `usa:open`, `usa:close`. Reduced motion: fades only.
178
+ */
179
+ interface UsaPopoverElement extends UsaElement {
180
+ open: boolean;
181
+ toggle(force?: boolean): void;
182
+ }
183
+ declare function definePopover(tag?: string): CustomElementConstructor | undefined;
184
+
185
+ /**
186
+ * `<usa-badge>` — a count / dot badge on whatever it wraps; bumps with a
187
+ * spring whenever the value changes and pulses with `pulse`.
188
+ * Attributes: `value` (number or text; 0 / empty hides it unless
189
+ * `show-zero`), `max` (99 → "99+"), `dot`, `pulse`, `label` (accessible
190
+ * text, default "{n} new"), `variant`. Reduced motion: no bump or pulse.
191
+ */
192
+ interface UsaBadgeElement extends UsaElement {
193
+ value: string;
194
+ }
195
+ declare function defineBadge(tag?: string): CustomElementConstructor | undefined;
196
+
197
+ /**
198
+ * `<usa-avatar-stack>` — overlapping avatars (its children: `<img>` or any
199
+ * element) that spread apart with a spring on hover / focus; extra ones
200
+ * collapse into a "+N" chip.
201
+ * Attributes: `max` (visible avatars, 5), `size` (px, 36), `overlap` (0–1,
202
+ * 0.35), `label` (group name), `variant`. Reduced motion: no spreading.
203
+ */
204
+ interface UsaAvatarStackElement extends UsaElement {
205
+ }
206
+ declare function defineAvatarStack(tag?: string): CustomElementConstructor | undefined;
207
+
208
+ /**
209
+ * Style variants (v2.6): `variant="minimal | neon | glass | brutalist |
210
+ * fluent | material"` on any `<usa-*>` element — or on any ancestor as
211
+ * `data-usa-variant`, or page-wide with `setVariant()` — sets the shared
212
+ * design tokens every component reads:
213
+ *
214
+ * `--usa-accent`, `--usa-accent-text`, `--usa-surface`, `--usa-text`,
215
+ * `--usa-radius`, `--usa-border`, `--usa-shadow`, `--usa-blur`, `--usa-font`.
216
+ *
217
+ * (`<usa-spinner>`, `<usa-check>` and `<usa-dialog>` already use `variant`
218
+ * for their kind; the token names never clash with those values except
219
+ * `fluent`, which means the same thing there.)
220
+ */
221
+ declare const VARIANTS: readonly ["minimal", "neon", "glass", "brutalist", "fluent", "material"];
222
+ type Variant = (typeof VARIANTS)[number];
223
+ /** Inject the variant token sheet (done automatically by every `ui` component). */
224
+ declare function adoptVariants(): void;
225
+ /** Apply a variant to the whole page (or `root`); `null` removes it. */
226
+ declare function setVariant(variant: Variant | null, root?: Element | null): void;
227
+
228
+ type Placement = 'top' | 'bottom' | 'left' | 'right';
229
+
230
+ /**
231
+ * use-scroll-animate/components/ui — animated UI components + style variants (v2.6).
232
+ * `<usa-tabs>`, `<usa-drawer>`, `<usa-bottom-sheet>`, `<usa-pull-refresh>`,
233
+ * `<usa-fab>`, `<usa-navbar>`, `<usa-slider>`, `<usa-rating>`,
234
+ * `<usa-tooltip>`, `<usa-popover>`, `<usa-badge>`, `<usa-avatar-stack>`,
235
+ * and `variant="minimal | neon | glass | brutalist | fluent | material"`
236
+ * design tokens (`setVariant()`, `VARIANTS`).
237
+ */
238
+
239
+ /** Register every component of this category under its default tag. */
240
+ declare function defineUiComponents(): void;
241
+ declare global {
242
+ interface HTMLElementTagNameMap {
243
+ 'usa-tabs': UsaTabsElement;
244
+ 'usa-drawer': UsaDrawerElement;
245
+ 'usa-bottom-sheet': UsaBottomSheetElement;
246
+ 'usa-pull-refresh': UsaPullRefreshElement;
247
+ 'usa-fab': UsaFabElement;
248
+ 'usa-navbar': UsaNavbarElement;
249
+ 'usa-slider': UsaSliderElement;
250
+ 'usa-rating': UsaRatingElement;
251
+ 'usa-tooltip': UsaTooltipElement;
252
+ 'usa-popover': UsaPopoverElement;
253
+ 'usa-badge': UsaBadgeElement;
254
+ 'usa-avatar-stack': UsaAvatarStackElement;
255
+ }
256
+ }
257
+
258
+ export { VARIANTS, adoptVariants, configureComponents, defineAvatarStack, defineBadge, defineBottomSheet, defineDrawer, defineFab, defineNavbar, definePopover, definePullRefresh, defineRating, defineSlider, defineTabs, defineTooltip, defineUiComponents, prefersReducedMotion, setVariant };
259
+ export type { ComponentsConfig, Placement, UsaAvatarStackElement, UsaBadgeElement, UsaBottomSheetElement, UsaDrawerElement, UsaElement, UsaFabElement, UsaNavbarElement, UsaPopoverElement, UsaPullRefreshElement, UsaRatingElement, UsaSliderElement, UsaTabsElement, UsaTooltipElement, Variant };