use-scroll-animate 2.1.0 → 2.3.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 (70) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/README.md +31 -2
  3. package/README_ja.md +19 -0
  4. package/README_zh.md +30 -0
  5. package/dist/chunks/base-CJ7XfidP.cjs +233 -0
  6. package/dist/chunks/base-CJ7XfidP.cjs.map +1 -0
  7. package/dist/chunks/base-CuvCgqLy.js +219 -0
  8. package/dist/chunks/base-CuvCgqLy.js.map +1 -0
  9. package/dist/components/background.cjs +395 -0
  10. package/dist/components/background.cjs.map +1 -0
  11. package/dist/components/background.css +7 -0
  12. package/dist/components/background.d.cts +132 -0
  13. package/dist/components/background.d.ts +132 -0
  14. package/dist/components/background.js +387 -0
  15. package/dist/components/background.js.map +1 -0
  16. package/dist/components/feedback.cjs +444 -0
  17. package/dist/components/feedback.cjs.map +1 -0
  18. package/dist/components/feedback.css +7 -0
  19. package/dist/components/feedback.d.cts +170 -0
  20. package/dist/components/feedback.d.ts +170 -0
  21. package/dist/components/feedback.js +434 -0
  22. package/dist/components/feedback.js.map +1 -0
  23. package/dist/components/interaction.cjs +426 -0
  24. package/dist/components/interaction.cjs.map +1 -0
  25. package/dist/components/interaction.css +8 -0
  26. package/dist/components/interaction.d.cts +142 -0
  27. package/dist/components/interaction.d.ts +142 -0
  28. package/dist/components/interaction.js +417 -0
  29. package/dist/components/interaction.js.map +1 -0
  30. package/dist/components/physics.cjs +664 -0
  31. package/dist/components/physics.cjs.map +1 -0
  32. package/dist/components/physics.css +5 -0
  33. package/dist/components/physics.d.cts +216 -0
  34. package/dist/components/physics.d.ts +216 -0
  35. package/dist/components/physics.js +644 -0
  36. package/dist/components/physics.js.map +1 -0
  37. package/dist/components/reveal.cjs +360 -0
  38. package/dist/components/reveal.cjs.map +1 -0
  39. package/dist/components/reveal.css +5 -0
  40. package/dist/components/reveal.d.cts +132 -0
  41. package/dist/components/reveal.d.ts +132 -0
  42. package/dist/components/reveal.js +350 -0
  43. package/dist/components/reveal.js.map +1 -0
  44. package/dist/components/text.cjs +528 -0
  45. package/dist/components/text.cjs.map +1 -0
  46. package/dist/components/text.css +7 -0
  47. package/dist/components/text.d.cts +164 -0
  48. package/dist/components/text.d.ts +164 -0
  49. package/dist/components/text.js +517 -0
  50. package/dist/components/text.js.map +1 -0
  51. package/dist/components/transitions.cjs +546 -0
  52. package/dist/components/transitions.cjs.map +1 -0
  53. package/dist/components/transitions.css +6 -0
  54. package/dist/components/transitions.d.cts +180 -0
  55. package/dist/components/transitions.d.ts +180 -0
  56. package/dist/components/transitions.js +536 -0
  57. package/dist/components/transitions.js.map +1 -0
  58. package/dist/components.cjs +127 -0
  59. package/dist/components.cjs.map +1 -0
  60. package/dist/components.css +33 -0
  61. package/dist/components.d.cts +919 -0
  62. package/dist/components.d.ts +919 -0
  63. package/dist/components.js +65 -0
  64. package/dist/components.js.map +1 -0
  65. package/dist/components.umd.js +22 -0
  66. package/dist/components.umd.js.map +1 -0
  67. package/docs/API.md +2 -0
  68. package/docs/components.md +169 -0
  69. package/docs/windows-apps.md +108 -0
  70. package/package.json +105 -5
@@ -0,0 +1,170 @@
1
+ /**
2
+ * use-scroll-animate/components — shared base for the `<usa-*>` custom elements.
3
+ *
4
+ * Everything here is lazy: nothing touches `window`, `document`,
5
+ * `HTMLElement` or `matchMedia` at import time, so the components can be
6
+ * imported during SSR (Next, Nuxt, Astro…) and in Electron/Tauri preload
7
+ * scripts. Classes are created the first time a `define*()` function runs.
8
+ */
9
+ interface ComponentsConfig {
10
+ /**
11
+ * Inject each component's CSS when it is defined (default `true`). Uses a
12
+ * constructable stylesheet (`document.adoptedStyleSheets`, which a strict
13
+ * `style-src` CSP does not block) and falls back to a `<style>` tag. Set
14
+ * to `false` when you load `use-scroll-animate/components.css` yourself.
15
+ */
16
+ injectStyles?: boolean;
17
+ /**
18
+ * `'user'` (default) follows `prefers-reduced-motion`; `'reduce'` always
19
+ * uses the reduced variants (e.g. a kiosk / battery-saver mode);
20
+ * `'no-preference'` ignores the OS setting (only for demos — respect your users).
21
+ */
22
+ reducedMotion?: 'user' | 'reduce' | 'no-preference';
23
+ }
24
+ /** Change global component settings (call before `define*()` for `injectStyles`). */
25
+ declare function configureComponents(options: ComponentsConfig): void;
26
+ /** `true` when animations should be reduced (OS setting or `configureComponents`). */
27
+ declare function prefersReducedMotion(): boolean;
28
+ /**
29
+ * Members shared by every `<usa-*>` element. Attribute helpers, a cleanup
30
+ * bag that is emptied on disconnect, and motion helpers that degrade to the
31
+ * final state without WAAPI or under reduced motion.
32
+ */
33
+ interface UsaElement extends HTMLElement {
34
+ /** `true` while reduced motion applies to this element. */
35
+ readonly reduced: boolean;
36
+ }
37
+
38
+ declare const SPINNER_VARIANTS: readonly ["fluent", "windows", "ring", "dots", "pulse", "bars"];
39
+ type SpinnerVariant = (typeof SPINNER_VARIANTS)[number];
40
+ /**
41
+ * `<usa-spinner>` — indeterminate loading indicators, pure CSS animations
42
+ * of `transform` / `opacity` (plus an SVG stroke for `fluent`).
43
+ *
44
+ * Variants (`variant`): `fluent` (default — the WinUI / Windows 11
45
+ * ProgressRing arc), `windows` (the Windows 10 boot "orbiting dots"),
46
+ * `ring` (classic border spinner), `dots` (three bouncing dots / typing
47
+ * indicator), `pulse` (expanding ripple), `bars` (equalizer).
48
+ * Attributes: `size` (px, 32), `label` (accessible name, "Loading"),
49
+ * `paused`. Colour follows `color` / `--usa-spinner-color`.
50
+ * `role="progressbar"` without a value (indeterminate). Reduced motion:
51
+ * a slow opacity pulse instead of movement.
52
+ */
53
+ interface UsaSpinnerElement extends UsaElement {
54
+ variant: SpinnerVariant;
55
+ }
56
+ declare function defineSpinner(tag?: string): CustomElementConstructor | undefined;
57
+
58
+ /**
59
+ * `<usa-skeleton>` — shimmering placeholders while content loads. With
60
+ * `loading`, it shows `lines` bars (or one block of `width` × `height`,
61
+ * or a `circle`) and hides its children; remove `loading` and the real
62
+ * content fades in.
63
+ *
64
+ * Attributes: `loading`, `lines` (3), `width`, `height` (CSS lengths),
65
+ * `circle`, `radius`, `avatar` (circle + lines, like a list row).
66
+ * `aria-busy` follows `loading`. Reduced motion: no shimmer sweep.
67
+ */
68
+ interface UsaSkeletonElement extends UsaElement {
69
+ loading: boolean;
70
+ }
71
+ declare function defineSkeleton(tag?: string): CustomElementConstructor | undefined;
72
+
73
+ /**
74
+ * `<usa-progress>` — a linear progress bar. Determinate (`value` / `max`)
75
+ * bars glide between values with `transform: scaleX()`; without a value,
76
+ * or with `indeterminate`, it shows the Windows Fluent indeterminate
77
+ * animation (two sliding segments).
78
+ *
79
+ * Attributes: `value`, `max` (100), `indeterminate`, `state`
80
+ * (`paused` | `error` — the WinUI states), `label` (accessible name).
81
+ * `role="progressbar"` with `aria-valuenow` when determinate.
82
+ * Reduced motion: no glide; indeterminate becomes a gentle pulse.
83
+ */
84
+ interface UsaProgressElement extends UsaElement {
85
+ value: number | null;
86
+ max: number;
87
+ /** 0–1, or `null` when indeterminate. */
88
+ readonly ratio: number | null;
89
+ }
90
+ declare function defineProgress(tag?: string): CustomElementConstructor | undefined;
91
+
92
+ type ToastType = 'info' | 'success' | 'warning' | 'error';
93
+ interface ToastOptions {
94
+ /** ms before it hides itself; `0` keeps it until closed (default 4000). */
95
+ duration?: number;
96
+ type?: ToastType;
97
+ /** Optional action button. */
98
+ action?: {
99
+ label: string;
100
+ onClick: () => void;
101
+ };
102
+ /** Show a close button (default `true`). */
103
+ dismissible?: boolean;
104
+ /** The toaster to use (default: the first `<usa-toaster>`, created if missing). */
105
+ toaster?: UsaToasterElement | string;
106
+ }
107
+ interface ToastHandle {
108
+ element: HTMLElement;
109
+ close(): Promise<void>;
110
+ }
111
+ /**
112
+ * `<usa-toaster>` — the region toasts slide into (`role="region"`, each
113
+ * toast `role="status"`, errors `role="alert"`). Toasts pause their timer
114
+ * while hovered or focused, and the stack re-flows with a FLIP animation.
115
+ *
116
+ * Attributes: `position` (`bottom-right` default, `bottom-left`,
117
+ * `bottom-center`, `top-right`, `top-left`, `top-center`), `max` (visible
118
+ * toasts, 4), `label` (region name, "Notifications").
119
+ * Reduced motion: toasts fade instead of sliding.
120
+ */
121
+ interface UsaToasterElement extends UsaElement {
122
+ show(message: string, options?: ToastOptions): ToastHandle;
123
+ clear(): void;
124
+ }
125
+ declare function defineToaster(tag?: string): CustomElementConstructor | undefined;
126
+ /**
127
+ * Show a toast. Defines `<usa-toaster>` and adds one to `<body>` if the
128
+ * page has none. Returns a handle with `close()`. No-op on the server.
129
+ *
130
+ * ```js
131
+ * toast('Saved', { type: 'success' });
132
+ * ```
133
+ */
134
+ declare function toast(message: string, options?: ToastOptions): ToastHandle | null;
135
+
136
+ /**
137
+ * `<usa-check>` — an animated result icon: the circle draws itself, then the
138
+ * check mark (or cross / exclamation) strokes in with a little pop.
139
+ *
140
+ * Attributes: `variant` (`success` default, `error`, `warning`), `size`
141
+ * (px, 56), `start` (`view` default | `load` | `manual`), `label`
142
+ * (accessible name, e.g. "Payment complete"; the icon is decorative
143
+ * without it). Event: `usa:complete`. Reduced motion: drawn instantly.
144
+ */
145
+ interface UsaCheckElement extends UsaElement {
146
+ play(): Promise<void>;
147
+ reset(): void;
148
+ }
149
+ declare function defineCheck(tag?: string): CustomElementConstructor | undefined;
150
+
151
+ /**
152
+ * use-scroll-animate/components/feedback — loading & feedback.
153
+ * `<usa-spinner>`, `<usa-skeleton>`, `<usa-progress>`, `<usa-toaster>` +
154
+ * `toast()`, `<usa-check>`.
155
+ */
156
+
157
+ /** Register every component of this category under its default tag. */
158
+ declare function defineFeedbackComponents(): void;
159
+ declare global {
160
+ interface HTMLElementTagNameMap {
161
+ 'usa-spinner': UsaSpinnerElement;
162
+ 'usa-skeleton': UsaSkeletonElement;
163
+ 'usa-progress': UsaProgressElement;
164
+ 'usa-toaster': UsaToasterElement;
165
+ 'usa-check': UsaCheckElement;
166
+ }
167
+ }
168
+
169
+ export { SPINNER_VARIANTS, configureComponents, defineCheck, defineFeedbackComponents, defineProgress, defineSkeleton, defineSpinner, defineToaster, prefersReducedMotion, toast };
170
+ export type { ComponentsConfig, SpinnerVariant, ToastHandle, ToastOptions, ToastType, UsaCheckElement, UsaElement, UsaProgressElement, UsaSkeletonElement, UsaSpinnerElement, UsaToasterElement };
@@ -0,0 +1,170 @@
1
+ /**
2
+ * use-scroll-animate/components — shared base for the `<usa-*>` custom elements.
3
+ *
4
+ * Everything here is lazy: nothing touches `window`, `document`,
5
+ * `HTMLElement` or `matchMedia` at import time, so the components can be
6
+ * imported during SSR (Next, Nuxt, Astro…) and in Electron/Tauri preload
7
+ * scripts. Classes are created the first time a `define*()` function runs.
8
+ */
9
+ interface ComponentsConfig {
10
+ /**
11
+ * Inject each component's CSS when it is defined (default `true`). Uses a
12
+ * constructable stylesheet (`document.adoptedStyleSheets`, which a strict
13
+ * `style-src` CSP does not block) and falls back to a `<style>` tag. Set
14
+ * to `false` when you load `use-scroll-animate/components.css` yourself.
15
+ */
16
+ injectStyles?: boolean;
17
+ /**
18
+ * `'user'` (default) follows `prefers-reduced-motion`; `'reduce'` always
19
+ * uses the reduced variants (e.g. a kiosk / battery-saver mode);
20
+ * `'no-preference'` ignores the OS setting (only for demos — respect your users).
21
+ */
22
+ reducedMotion?: 'user' | 'reduce' | 'no-preference';
23
+ }
24
+ /** Change global component settings (call before `define*()` for `injectStyles`). */
25
+ declare function configureComponents(options: ComponentsConfig): void;
26
+ /** `true` when animations should be reduced (OS setting or `configureComponents`). */
27
+ declare function prefersReducedMotion(): boolean;
28
+ /**
29
+ * Members shared by every `<usa-*>` element. Attribute helpers, a cleanup
30
+ * bag that is emptied on disconnect, and motion helpers that degrade to the
31
+ * final state without WAAPI or under reduced motion.
32
+ */
33
+ interface UsaElement extends HTMLElement {
34
+ /** `true` while reduced motion applies to this element. */
35
+ readonly reduced: boolean;
36
+ }
37
+
38
+ declare const SPINNER_VARIANTS: readonly ["fluent", "windows", "ring", "dots", "pulse", "bars"];
39
+ type SpinnerVariant = (typeof SPINNER_VARIANTS)[number];
40
+ /**
41
+ * `<usa-spinner>` — indeterminate loading indicators, pure CSS animations
42
+ * of `transform` / `opacity` (plus an SVG stroke for `fluent`).
43
+ *
44
+ * Variants (`variant`): `fluent` (default — the WinUI / Windows 11
45
+ * ProgressRing arc), `windows` (the Windows 10 boot "orbiting dots"),
46
+ * `ring` (classic border spinner), `dots` (three bouncing dots / typing
47
+ * indicator), `pulse` (expanding ripple), `bars` (equalizer).
48
+ * Attributes: `size` (px, 32), `label` (accessible name, "Loading"),
49
+ * `paused`. Colour follows `color` / `--usa-spinner-color`.
50
+ * `role="progressbar"` without a value (indeterminate). Reduced motion:
51
+ * a slow opacity pulse instead of movement.
52
+ */
53
+ interface UsaSpinnerElement extends UsaElement {
54
+ variant: SpinnerVariant;
55
+ }
56
+ declare function defineSpinner(tag?: string): CustomElementConstructor | undefined;
57
+
58
+ /**
59
+ * `<usa-skeleton>` — shimmering placeholders while content loads. With
60
+ * `loading`, it shows `lines` bars (or one block of `width` × `height`,
61
+ * or a `circle`) and hides its children; remove `loading` and the real
62
+ * content fades in.
63
+ *
64
+ * Attributes: `loading`, `lines` (3), `width`, `height` (CSS lengths),
65
+ * `circle`, `radius`, `avatar` (circle + lines, like a list row).
66
+ * `aria-busy` follows `loading`. Reduced motion: no shimmer sweep.
67
+ */
68
+ interface UsaSkeletonElement extends UsaElement {
69
+ loading: boolean;
70
+ }
71
+ declare function defineSkeleton(tag?: string): CustomElementConstructor | undefined;
72
+
73
+ /**
74
+ * `<usa-progress>` — a linear progress bar. Determinate (`value` / `max`)
75
+ * bars glide between values with `transform: scaleX()`; without a value,
76
+ * or with `indeterminate`, it shows the Windows Fluent indeterminate
77
+ * animation (two sliding segments).
78
+ *
79
+ * Attributes: `value`, `max` (100), `indeterminate`, `state`
80
+ * (`paused` | `error` — the WinUI states), `label` (accessible name).
81
+ * `role="progressbar"` with `aria-valuenow` when determinate.
82
+ * Reduced motion: no glide; indeterminate becomes a gentle pulse.
83
+ */
84
+ interface UsaProgressElement extends UsaElement {
85
+ value: number | null;
86
+ max: number;
87
+ /** 0–1, or `null` when indeterminate. */
88
+ readonly ratio: number | null;
89
+ }
90
+ declare function defineProgress(tag?: string): CustomElementConstructor | undefined;
91
+
92
+ type ToastType = 'info' | 'success' | 'warning' | 'error';
93
+ interface ToastOptions {
94
+ /** ms before it hides itself; `0` keeps it until closed (default 4000). */
95
+ duration?: number;
96
+ type?: ToastType;
97
+ /** Optional action button. */
98
+ action?: {
99
+ label: string;
100
+ onClick: () => void;
101
+ };
102
+ /** Show a close button (default `true`). */
103
+ dismissible?: boolean;
104
+ /** The toaster to use (default: the first `<usa-toaster>`, created if missing). */
105
+ toaster?: UsaToasterElement | string;
106
+ }
107
+ interface ToastHandle {
108
+ element: HTMLElement;
109
+ close(): Promise<void>;
110
+ }
111
+ /**
112
+ * `<usa-toaster>` — the region toasts slide into (`role="region"`, each
113
+ * toast `role="status"`, errors `role="alert"`). Toasts pause their timer
114
+ * while hovered or focused, and the stack re-flows with a FLIP animation.
115
+ *
116
+ * Attributes: `position` (`bottom-right` default, `bottom-left`,
117
+ * `bottom-center`, `top-right`, `top-left`, `top-center`), `max` (visible
118
+ * toasts, 4), `label` (region name, "Notifications").
119
+ * Reduced motion: toasts fade instead of sliding.
120
+ */
121
+ interface UsaToasterElement extends UsaElement {
122
+ show(message: string, options?: ToastOptions): ToastHandle;
123
+ clear(): void;
124
+ }
125
+ declare function defineToaster(tag?: string): CustomElementConstructor | undefined;
126
+ /**
127
+ * Show a toast. Defines `<usa-toaster>` and adds one to `<body>` if the
128
+ * page has none. Returns a handle with `close()`. No-op on the server.
129
+ *
130
+ * ```js
131
+ * toast('Saved', { type: 'success' });
132
+ * ```
133
+ */
134
+ declare function toast(message: string, options?: ToastOptions): ToastHandle | null;
135
+
136
+ /**
137
+ * `<usa-check>` — an animated result icon: the circle draws itself, then the
138
+ * check mark (or cross / exclamation) strokes in with a little pop.
139
+ *
140
+ * Attributes: `variant` (`success` default, `error`, `warning`), `size`
141
+ * (px, 56), `start` (`view` default | `load` | `manual`), `label`
142
+ * (accessible name, e.g. "Payment complete"; the icon is decorative
143
+ * without it). Event: `usa:complete`. Reduced motion: drawn instantly.
144
+ */
145
+ interface UsaCheckElement extends UsaElement {
146
+ play(): Promise<void>;
147
+ reset(): void;
148
+ }
149
+ declare function defineCheck(tag?: string): CustomElementConstructor | undefined;
150
+
151
+ /**
152
+ * use-scroll-animate/components/feedback — loading & feedback.
153
+ * `<usa-spinner>`, `<usa-skeleton>`, `<usa-progress>`, `<usa-toaster>` +
154
+ * `toast()`, `<usa-check>`.
155
+ */
156
+
157
+ /** Register every component of this category under its default tag. */
158
+ declare function defineFeedbackComponents(): void;
159
+ declare global {
160
+ interface HTMLElementTagNameMap {
161
+ 'usa-spinner': UsaSpinnerElement;
162
+ 'usa-skeleton': UsaSkeletonElement;
163
+ 'usa-progress': UsaProgressElement;
164
+ 'usa-toaster': UsaToasterElement;
165
+ 'usa-check': UsaCheckElement;
166
+ }
167
+ }
168
+
169
+ export { SPINNER_VARIANTS, configureComponents, defineCheck, defineFeedbackComponents, defineProgress, defineSkeleton, defineSpinner, defineToaster, prefersReducedMotion, toast };
170
+ export type { ComponentsConfig, SpinnerVariant, ToastHandle, ToastOptions, ToastType, UsaCheckElement, UsaElement, UsaProgressElement, UsaSkeletonElement, UsaSpinnerElement, UsaToasterElement };