motionary 0.0.0-stage → 6.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +803 -0
- package/LICENSE +21 -0
- package/README.md +218 -2
- package/README_ja.md +219 -0
- package/README_zh.md +219 -0
- package/bin/usa-codemod-5.mjs +79 -0
- package/bin/usa-codemod-6.mjs +146 -0
- package/dist/chunks/base-BaQV-2ha.cjs +436 -0
- package/dist/chunks/base-BaQV-2ha.cjs.map +1 -0
- package/dist/chunks/base-C_3cAoRz.js +404 -0
- package/dist/chunks/base-C_3cAoRz.js.map +1 -0
- package/dist/chunks/bind-B_CTL6Qn.js +22 -0
- package/dist/chunks/bind-B_CTL6Qn.js.map +1 -0
- package/dist/chunks/bind-Ui43-n2d.cjs +25 -0
- package/dist/chunks/bind-Ui43-n2d.cjs.map +1 -0
- package/dist/chunks/core-B5T0dhFH.cjs +920 -0
- package/dist/chunks/core-B5T0dhFH.cjs.map +1 -0
- package/dist/chunks/core-BGAyaY6L.cjs +265 -0
- package/dist/chunks/core-BGAyaY6L.cjs.map +1 -0
- package/dist/chunks/core-D7cVumUu.js +909 -0
- package/dist/chunks/core-D7cVumUu.js.map +1 -0
- package/dist/chunks/core-VEBw36QK.js +260 -0
- package/dist/chunks/core-VEBw36QK.js.map +1 -0
- package/dist/chunks/core-ps8uvYuN.js +181 -0
- package/dist/chunks/core-ps8uvYuN.js.map +1 -0
- package/dist/chunks/core-zq17EeCI.cjs +185 -0
- package/dist/chunks/core-zq17EeCI.cjs.map +1 -0
- package/dist/chunks/fx-Bs6IrV4Q.js +109 -0
- package/dist/chunks/fx-Bs6IrV4Q.js.map +1 -0
- package/dist/chunks/fx-lBGVtQO1.cjs +114 -0
- package/dist/chunks/fx-lBGVtQO1.cjs.map +1 -0
- package/dist/chunks/generative-D2YyhaeO.js +336 -0
- package/dist/chunks/generative-D2YyhaeO.js.map +1 -0
- package/dist/chunks/generative-DzIZq-_g.cjs +348 -0
- package/dist/chunks/generative-DzIZq-_g.cjs.map +1 -0
- package/dist/chunks/gpu-Bu7qwugO.js +380 -0
- package/dist/chunks/gpu-Bu7qwugO.js.map +1 -0
- package/dist/chunks/gpu-CenK2l6b.cjs +387 -0
- package/dist/chunks/gpu-CenK2l6b.cjs.map +1 -0
- package/dist/chunks/index-tags-DucKMQr_.js +26 -0
- package/dist/chunks/index-tags-DucKMQr_.js.map +1 -0
- package/dist/chunks/index-tags-wv0R_vkO.cjs +28 -0
- package/dist/chunks/index-tags-wv0R_vkO.cjs.map +1 -0
- package/dist/chunks/presets-BYBVJVeP.js +226 -0
- package/dist/chunks/presets-BYBVJVeP.js.map +1 -0
- package/dist/chunks/presets-CUHys3sK.cjs +233 -0
- package/dist/chunks/presets-CUHys3sK.cjs.map +1 -0
- package/dist/chunks/registry-CKNLQpwd.js +121 -0
- package/dist/chunks/registry-CKNLQpwd.js.map +1 -0
- package/dist/chunks/registry-DehBVRDV.cjs +131 -0
- package/dist/chunks/registry-DehBVRDV.cjs.map +1 -0
- package/dist/chunks/spring-CbvHfVtP.js +219 -0
- package/dist/chunks/spring-CbvHfVtP.js.map +1 -0
- package/dist/chunks/spring-Dgx187Vh.cjs +232 -0
- package/dist/chunks/spring-Dgx187Vh.cjs.map +1 -0
- package/dist/chunks/stagger-CCFyhzSw.cjs +86 -0
- package/dist/chunks/stagger-CCFyhzSw.cjs.map +1 -0
- package/dist/chunks/stagger-DtMKo2SK.js +84 -0
- package/dist/chunks/stagger-DtMKo2SK.js.map +1 -0
- package/dist/chunks/variants-BhjyddG8.cjs +39 -0
- package/dist/chunks/variants-BhjyddG8.cjs.map +1 -0
- package/dist/chunks/variants-DRlKVHvu.js +35 -0
- package/dist/chunks/variants-DRlKVHvu.js.map +1 -0
- package/dist/components/a11y.cjs +276 -0
- package/dist/components/a11y.cjs.map +1 -0
- package/dist/components/a11y.d.cts +131 -0
- package/dist/components/a11y.d.ts +131 -0
- package/dist/components/a11y.js +259 -0
- package/dist/components/a11y.js.map +1 -0
- package/dist/components/angular.cjs +76 -0
- package/dist/components/angular.cjs.map +1 -0
- package/dist/components/angular.d.cts +1734 -0
- package/dist/components/angular.d.ts +1734 -0
- package/dist/components/angular.js +70 -0
- package/dist/components/angular.js.map +1 -0
- package/dist/components/background.cjs +659 -0
- package/dist/components/background.cjs.map +1 -0
- package/dist/components/background.css +9 -0
- package/dist/components/background.d.cts +166 -0
- package/dist/components/background.d.ts +166 -0
- package/dist/components/background.js +647 -0
- package/dist/components/background.js.map +1 -0
- package/dist/components/bridge.cjs +154 -0
- package/dist/components/bridge.cjs.map +1 -0
- package/dist/components/bridge.d.cts +63 -0
- package/dist/components/bridge.d.ts +63 -0
- package/dist/components/bridge.js +147 -0
- package/dist/components/bridge.js.map +1 -0
- package/dist/components/cards.cjs +561 -0
- package/dist/components/cards.cjs.map +1 -0
- package/dist/components/cards.css +6 -0
- package/dist/components/cards.d.cts +115 -0
- package/dist/components/cards.d.ts +115 -0
- package/dist/components/cards.js +554 -0
- package/dist/components/cards.js.map +1 -0
- package/dist/components/click.cjs +877 -0
- package/dist/components/click.cjs.map +1 -0
- package/dist/components/click.css +9 -0
- package/dist/components/click.d.cts +218 -0
- package/dist/components/click.d.ts +218 -0
- package/dist/components/click.js +863 -0
- package/dist/components/click.js.map +1 -0
- package/dist/components/depth.cjs +250 -0
- package/dist/components/depth.cjs.map +1 -0
- package/dist/components/depth.css +3 -0
- package/dist/components/depth.d.cts +86 -0
- package/dist/components/depth.d.ts +86 -0
- package/dist/components/depth.js +242 -0
- package/dist/components/depth.js.map +1 -0
- package/dist/components/effects.cjs +2258 -0
- package/dist/components/effects.cjs.map +1 -0
- package/dist/components/effects.d.cts +545 -0
- package/dist/components/effects.d.ts +545 -0
- package/dist/components/effects.js +2200 -0
- package/dist/components/effects.js.map +1 -0
- package/dist/components/feedback.cjs +442 -0
- package/dist/components/feedback.cjs.map +1 -0
- package/dist/components/feedback.css +7 -0
- package/dist/components/feedback.d.cts +144 -0
- package/dist/components/feedback.d.ts +144 -0
- package/dist/components/feedback.js +433 -0
- package/dist/components/feedback.js.map +1 -0
- package/dist/components/fx-gpu.cjs +12 -0
- package/dist/components/fx-gpu.cjs.map +1 -0
- package/dist/components/fx-gpu.d.cts +63 -0
- package/dist/components/fx-gpu.d.ts +63 -0
- package/dist/components/fx-gpu.js +5 -0
- package/dist/components/fx-gpu.js.map +1 -0
- package/dist/components/fx.cjs +169 -0
- package/dist/components/fx.cjs.map +1 -0
- package/dist/components/fx.css +3 -0
- package/dist/components/fx.d.cts +114 -0
- package/dist/components/fx.d.ts +114 -0
- package/dist/components/fx.js +156 -0
- package/dist/components/fx.js.map +1 -0
- package/dist/components/fx2.cjs +25 -0
- package/dist/components/fx2.cjs.map +1 -0
- package/dist/components/fx2.d.cts +136 -0
- package/dist/components/fx2.d.ts +136 -0
- package/dist/components/fx2.js +17 -0
- package/dist/components/fx2.js.map +1 -0
- package/dist/components/gesture.cjs +209 -0
- package/dist/components/gesture.cjs.map +1 -0
- package/dist/components/gesture.css +3 -0
- package/dist/components/gesture.d.cts +134 -0
- package/dist/components/gesture.d.ts +134 -0
- package/dist/components/gesture.js +203 -0
- package/dist/components/gesture.js.map +1 -0
- package/dist/components/interaction.cjs +424 -0
- package/dist/components/interaction.cjs.map +1 -0
- package/dist/components/interaction.css +8 -0
- package/dist/components/interaction.d.cts +115 -0
- package/dist/components/interaction.d.ts +115 -0
- package/dist/components/interaction.js +416 -0
- package/dist/components/interaction.js.map +1 -0
- package/dist/components/jsx.cjs +3 -0
- package/dist/components/jsx.cjs.map +1 -0
- package/dist/components/jsx.d.cts +53 -0
- package/dist/components/jsx.d.ts +53 -0
- package/dist/components/jsx.js +2 -0
- package/dist/components/jsx.js.map +1 -0
- package/dist/components/layout.cjs +257 -0
- package/dist/components/layout.cjs.map +1 -0
- package/dist/components/layout.css +3 -0
- package/dist/components/layout.d.cts +99 -0
- package/dist/components/layout.d.ts +99 -0
- package/dist/components/layout.js +249 -0
- package/dist/components/layout.js.map +1 -0
- package/dist/components/lazy.cjs +92 -0
- package/dist/components/lazy.cjs.map +1 -0
- package/dist/components/lazy.d.cts +48 -0
- package/dist/components/lazy.d.ts +48 -0
- package/dist/components/lazy.js +87 -0
- package/dist/components/lazy.js.map +1 -0
- package/dist/components/lite.cjs +11095 -0
- package/dist/components/lite.cjs.map +1 -0
- package/dist/components/lite.d.cts +4 -0
- package/dist/components/lite.d.ts +4 -0
- package/dist/components/lite.js +10827 -0
- package/dist/components/lite.js.map +1 -0
- package/dist/components/packs.cjs +192 -0
- package/dist/components/packs.cjs.map +1 -0
- package/dist/components/packs.css +3 -0
- package/dist/components/packs.d.cts +72 -0
- package/dist/components/packs.d.ts +72 -0
- package/dist/components/packs.js +184 -0
- package/dist/components/packs.js.map +1 -0
- package/dist/components/page.cjs +824 -0
- package/dist/components/page.cjs.map +1 -0
- package/dist/components/page.css +11 -0
- package/dist/components/page.d.cts +249 -0
- package/dist/components/page.d.ts +249 -0
- package/dist/components/page.js +799 -0
- package/dist/components/page.js.map +1 -0
- package/dist/components/perf.cjs +120 -0
- package/dist/components/perf.cjs.map +1 -0
- package/dist/components/perf.d.cts +98 -0
- package/dist/components/perf.d.ts +98 -0
- package/dist/components/perf.js +110 -0
- package/dist/components/perf.js.map +1 -0
- package/dist/components/physics.cjs +448 -0
- package/dist/components/physics.cjs.map +1 -0
- package/dist/components/physics.css +5 -0
- package/dist/components/physics.d.cts +189 -0
- package/dist/components/physics.d.ts +189 -0
- package/dist/components/physics.js +430 -0
- package/dist/components/physics.js.map +1 -0
- 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 +362 -0
- package/dist/components/reveal.cjs.map +1 -0
- package/dist/components/reveal.css +5 -0
- package/dist/components/reveal.d.cts +105 -0
- package/dist/components/reveal.d.ts +105 -0
- package/dist/components/reveal.js +353 -0
- package/dist/components/reveal.js.map +1 -0
- package/dist/components/solid.cjs +86 -0
- package/dist/components/solid.cjs.map +1 -0
- package/dist/components/solid.d.cts +1751 -0
- package/dist/components/solid.d.ts +1751 -0
- package/dist/components/solid.js +82 -0
- package/dist/components/solid.js.map +1 -0
- package/dist/components/svelte.cjs +68 -0
- package/dist/components/svelte.cjs.map +1 -0
- package/dist/components/svelte.d.cts +1733 -0
- package/dist/components/svelte.d.ts +1733 -0
- package/dist/components/svelte.js +64 -0
- package/dist/components/svelte.js.map +1 -0
- package/dist/components/svg.cjs +359 -0
- package/dist/components/svg.cjs.map +1 -0
- package/dist/components/svg.css +3 -0
- package/dist/components/svg.d.cts +113 -0
- package/dist/components/svg.d.ts +113 -0
- package/dist/components/svg.js +347 -0
- package/dist/components/svg.js.map +1 -0
- package/dist/components/text.cjs +968 -0
- package/dist/components/text.cjs.map +1 -0
- package/dist/components/text.css +8 -0
- package/dist/components/text.d.cts +342 -0
- package/dist/components/text.d.ts +342 -0
- package/dist/components/text.js +947 -0
- package/dist/components/text.js.map +1 -0
- package/dist/components/timeline.cjs +109 -0
- package/dist/components/timeline.cjs.map +1 -0
- package/dist/components/timeline.css +3 -0
- package/dist/components/timeline.d.cts +155 -0
- package/dist/components/timeline.d.ts +155 -0
- package/dist/components/timeline.js +103 -0
- package/dist/components/timeline.js.map +1 -0
- package/dist/components/tokens.cjs +226 -0
- package/dist/components/tokens.cjs.map +1 -0
- package/dist/components/tokens.d.cts +74 -0
- package/dist/components/tokens.d.ts +74 -0
- package/dist/components/tokens.js +211 -0
- package/dist/components/tokens.js.map +1 -0
- package/dist/components/transitions.cjs +430 -0
- package/dist/components/transitions.cjs.map +1 -0
- package/dist/components/transitions.css +5 -0
- package/dist/components/transitions.d.cts +126 -0
- package/dist/components/transitions.d.ts +126 -0
- package/dist/components/transitions.js +423 -0
- package/dist/components/transitions.js.map +1 -0
- package/dist/components/ui.cjs +1050 -0
- package/dist/components/ui.cjs.map +1 -0
- package/dist/components/ui.css +14 -0
- package/dist/components/ui.d.cts +224 -0
- package/dist/components/ui.d.ts +224 -0
- package/dist/components/ui.js +1034 -0
- package/dist/components/ui.js.map +1 -0
- package/dist/components/vue.cjs +67 -0
- package/dist/components/vue.cjs.map +1 -0
- package/dist/components/vue.d.cts +1722 -0
- package/dist/components/vue.d.ts +1722 -0
- package/dist/components/vue.js +64 -0
- package/dist/components/vue.js.map +1 -0
- package/dist/components/webgl.cjs +459 -0
- package/dist/components/webgl.cjs.map +1 -0
- package/dist/components/webgl.css +3 -0
- package/dist/components/webgl.d.cts +133 -0
- package/dist/components/webgl.d.ts +133 -0
- package/dist/components/webgl.js +442 -0
- package/dist/components/webgl.js.map +1 -0
- package/dist/components/widgets.cjs +591 -0
- package/dist/components/widgets.cjs.map +1 -0
- package/dist/components/widgets.d.cts +110 -0
- package/dist/components/widgets.d.ts +110 -0
- package/dist/components/widgets.js +581 -0
- package/dist/components/widgets.js.map +1 -0
- package/dist/components.cjs +351 -0
- package/dist/components.cjs.map +1 -0
- package/dist/components.css +75 -0
- package/dist/components.d.cts +2997 -0
- package/dist/components.d.ts +2997 -0
- package/dist/components.js +106 -0
- package/dist/components.js.map +1 -0
- package/dist/components.umd.js +23 -0
- package/dist/components.umd.js.map +1 -0
- package/dist/element.cjs +97 -0
- package/dist/element.cjs.map +1 -0
- package/dist/element.d.cts +215 -0
- package/dist/element.d.ts +215 -0
- package/dist/element.js +95 -0
- package/dist/element.js.map +1 -0
- package/dist/element.umd.js +2 -0
- package/dist/element.umd.js.map +1 -0
- package/dist/index.cjs +149 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +425 -0
- package/dist/index.d.ts +425 -0
- package/dist/index.js +131 -0
- package/dist/index.js.map +1 -0
- package/dist/index.umd.js +15 -0
- package/dist/index.umd.js.map +1 -0
- package/dist/presets/extended.cjs +243 -0
- package/dist/presets/extended.cjs.map +1 -0
- package/dist/presets/extended.d.cts +37 -0
- package/dist/presets/extended.d.ts +37 -0
- package/dist/presets/extended.js +239 -0
- package/dist/presets/extended.js.map +1 -0
- package/dist/presets-extended.umd.js +2 -0
- package/dist/presets-extended.umd.js.map +1 -0
- package/dist/react.cjs +68 -0
- package/dist/react.cjs.map +1 -0
- package/dist/react.d.cts +158 -0
- package/dist/react.d.ts +158 -0
- package/dist/react.js +65 -0
- package/dist/react.js.map +1 -0
- package/dist/solid.cjs +93 -0
- package/dist/solid.cjs.map +1 -0
- package/dist/solid.d.cts +249 -0
- package/dist/solid.d.ts +249 -0
- package/dist/solid.js +89 -0
- package/dist/solid.js.map +1 -0
- package/dist/svelte.cjs +66 -0
- package/dist/svelte.cjs.map +1 -0
- package/dist/svelte.d.cts +243 -0
- package/dist/svelte.d.ts +243 -0
- package/dist/svelte.js +63 -0
- package/dist/svelte.js.map +1 -0
- package/dist/vue.cjs +62 -0
- package/dist/vue.cjs.map +1 -0
- package/dist/vue.d.cts +158 -0
- package/dist/vue.d.ts +158 -0
- package/dist/vue.js +60 -0
- package/dist/vue.js.map +1 -0
- package/dist/widgets.umd.js +2 -0
- package/dist/widgets.umd.js.map +1 -0
- package/docs/API.md +147 -0
- package/docs/ROADMAP.md +14 -0
- package/docs/accessibility.md +60 -0
- package/docs/components.md +564 -0
- package/docs/deprecations.md +30 -0
- package/docs/frameworks-ssr.md +100 -0
- package/docs/hybrid-apps.md +145 -0
- package/docs/images/showcase-detail.png +0 -0
- package/docs/images/showcase-grid.png +0 -0
- package/docs/images/showcase-mobile.png +0 -0
- package/docs/migration-from-aos.md +67 -0
- package/docs/migration-from-gsap-scrolltrigger.md +80 -0
- package/docs/motion-tokens.css +31 -0
- package/docs/motion-tokens.md +46 -0
- package/docs/motion.tokens.json +132 -0
- package/docs/performance.md +24 -0
- package/docs/presets.md +310 -0
- package/docs/upgrading-3.md +21 -0
- package/docs/upgrading-4.md +65 -0
- package/docs/upgrading-5.md +31 -0
- package/docs/upgrading-6.md +32 -0
- package/docs/windows-apps.md +119 -0
- package/package.json +562 -4
|
@@ -0,0 +1,2997 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* motionary/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 `motionary/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). 5.0: the
|
|
20
|
+
* OS setting can no longer be ignored (`'no-preference'` was removed).
|
|
21
|
+
*/
|
|
22
|
+
reducedMotion?: 'user' | 'reduce';
|
|
23
|
+
/**
|
|
24
|
+
* Global motion intensity (v2.7): `'low'` (shorter, calmer), `'normal'`
|
|
25
|
+
* (default) or `'high'`. Scales every component animation's duration and
|
|
26
|
+
* sets `--usa-motion` (0.6 / 1 / 1.25) on `<html>` for your own CSS. 5.0:
|
|
27
|
+
* `'off'` was removed — use `motionSensitivity: 'minimal'`.
|
|
28
|
+
*/
|
|
29
|
+
motionIntensity?: MotionIntensity;
|
|
30
|
+
/**
|
|
31
|
+
* Motion-sensitivity level (v4.4), finer than reduced motion:
|
|
32
|
+
* `'full'` (default) · `'gentle'` (no spins, zooms, skews or parallax —
|
|
33
|
+
* translations and fades only, safe for vestibular disorders) ·
|
|
34
|
+
* `'minimal'` (fades only; components use their reduced-motion variants) ·
|
|
35
|
+
* `'static'` (no animation: every component shows its static alternative).
|
|
36
|
+
* See `setMotionSensitivity()` in `motionary/components/a11y`.
|
|
37
|
+
*/
|
|
38
|
+
motionSensitivity?: MotionSensitivity;
|
|
39
|
+
}
|
|
40
|
+
type MotionSensitivity = 'full' | 'gentle' | 'minimal' | 'static';
|
|
41
|
+
declare const MOTION_SENSITIVITY_LEVELS: readonly MotionSensitivity[];
|
|
42
|
+
type MotionIntensity = 'low' | 'normal' | 'high';
|
|
43
|
+
declare const MOTION_SCALE: Record<MotionIntensity, number>;
|
|
44
|
+
/** Change global component settings (call before `define*()` for `injectStyles`). */
|
|
45
|
+
declare function configureComponents(options: ComponentsConfig): void;
|
|
46
|
+
/** The current motion-sensitivity level (v4.4). */
|
|
47
|
+
declare function getMotionSensitivity(): MotionSensitivity;
|
|
48
|
+
/**
|
|
49
|
+
* Adapt keyframes to the sensitivity level: `gentle` drops transforms that
|
|
50
|
+
* spin, zoom or skew (and 3D), `minimal` keeps opacity only, `static` keeps
|
|
51
|
+
* just the final frame. `full` returns them unchanged.
|
|
52
|
+
*/
|
|
53
|
+
declare function adaptKeyframes(frames: Keyframe[], level?: MotionSensitivity): Keyframe[];
|
|
54
|
+
/** Run `fn` without 4.9 deprecation warnings (library-internal calls). */
|
|
55
|
+
declare function withoutDeprecations<T>(fn: () => T): T;
|
|
56
|
+
/** The current global motion intensity. */
|
|
57
|
+
declare function getMotionIntensity(): MotionIntensity;
|
|
58
|
+
/** Duration multiplier for the current intensity (1 when `normal`). */
|
|
59
|
+
declare function motionScale(): number;
|
|
60
|
+
/** `true` when animations should be reduced (OS setting or `configureComponents`). */
|
|
61
|
+
declare function prefersReducedMotion(): boolean;
|
|
62
|
+
type Cleanup$1 = () => void;
|
|
63
|
+
/**
|
|
64
|
+
* Members shared by every `<usa-*>` element. Attribute helpers, a cleanup
|
|
65
|
+
* bag that is emptied on disconnect, and motion helpers that degrade to the
|
|
66
|
+
* final state without WAAPI or under reduced motion.
|
|
67
|
+
*/
|
|
68
|
+
interface UsaElement extends HTMLElement {
|
|
69
|
+
/** `true` while reduced motion applies to this element. */
|
|
70
|
+
readonly reduced: boolean;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* `el.animate()` with the library's motion rules (5.0, shared by elements and
|
|
74
|
+
* registered effects): motion sensitivity (keyframes adapted, `static` →
|
|
75
|
+
* final frame), intensity (duration scale) and the animation budget. Returns
|
|
76
|
+
* `null` (final frame applied) when nothing should animate.
|
|
77
|
+
*/
|
|
78
|
+
declare function animateWithMotion(el: Element, keyframes: Keyframe[], options: KeyframeAnimationOptions): Animation | null;
|
|
79
|
+
/** Run `fn(time, dt)` every frame on the shared scheduler until the returned function is called. */
|
|
80
|
+
declare function onFrame(fn: (t: number, dt: number) => void): () => void;
|
|
81
|
+
/** Scheduler counters: frames flushed, callbacks run, peak callbacks in one frame, pending now. */
|
|
82
|
+
declare function schedulerStats(): {
|
|
83
|
+
frames: number;
|
|
84
|
+
callbacks: number;
|
|
85
|
+
peak: number;
|
|
86
|
+
pending: number;
|
|
87
|
+
loops: number;
|
|
88
|
+
};
|
|
89
|
+
/** Number of component animations running right now. */
|
|
90
|
+
declare const activeAnimations: () => number;
|
|
91
|
+
/** Cap concurrent component animations; extra ones jump to their final frame (`Infinity` = no cap). */
|
|
92
|
+
declare function setAnimationBudget(max: number): void;
|
|
93
|
+
/** The current cap. */
|
|
94
|
+
declare const animationBudget: () => number;
|
|
95
|
+
|
|
96
|
+
/** Entrance effects shared by `<usa-reveal>` and `<usa-stagger>` (transform / opacity / filter only). */
|
|
97
|
+
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"];
|
|
98
|
+
type RevealEffect = (typeof REVEAL_EFFECTS)[number];
|
|
99
|
+
/** Keyframes from the effect to the natural state. */
|
|
100
|
+
declare function revealKeyframes(effect: string, distance?: number): Keyframe[];
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* `<usa-reveal>` — reveals its content when it scrolls into view.
|
|
104
|
+
*
|
|
105
|
+
* Attributes: `effect` (see {@link RevealEffect}, default `fade-up`),
|
|
106
|
+
* `duration` (ms, 700), `delay` (ms, 0), `distance` (px, 32), `easing`,
|
|
107
|
+
* `threshold` (0–1, 0.15), `root-margin`, `repeat` (hide again when it
|
|
108
|
+
* leaves, replay on re-entry). Events: `usa:enter`, `usa:leave`, `usa:complete`.
|
|
109
|
+
*/
|
|
110
|
+
interface UsaRevealElement extends UsaElement {
|
|
111
|
+
effect: RevealEffect | string;
|
|
112
|
+
/** Play the entrance now (also called automatically on enter). */
|
|
113
|
+
reveal(): Promise<void>;
|
|
114
|
+
/** Hide again so the next `reveal()` replays the entrance. */
|
|
115
|
+
reset(): void;
|
|
116
|
+
readonly revealed: boolean;
|
|
117
|
+
}
|
|
118
|
+
declare function defineReveal(tag?: string): CustomElementConstructor | undefined;
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* `<usa-stagger>` — reveals its direct children one after another when the
|
|
122
|
+
* list scrolls into view.
|
|
123
|
+
*
|
|
124
|
+
* Attributes: `effect` (default `fade-up`), `interval` (ms between children,
|
|
125
|
+
* 70), `duration` (600), `delay` (0), `distance` (24), `easing`,
|
|
126
|
+
* `threshold` (0.1), `repeat`. Events: `usa:enter`, `usa:complete`.
|
|
127
|
+
*/
|
|
128
|
+
interface UsaStaggerElement extends UsaElement {
|
|
129
|
+
reveal(): Promise<void>;
|
|
130
|
+
reset(): void;
|
|
131
|
+
}
|
|
132
|
+
declare function defineStagger(tag?: string): CustomElementConstructor | undefined;
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* `<usa-scroll-progress>` — a reading-progress bar.
|
|
136
|
+
*
|
|
137
|
+
* Attributes: `target` (CSS selector of an article to track; default the
|
|
138
|
+
* whole page), `position` (`top` | `bottom` | `inline`, default `top`),
|
|
139
|
+
* `label` (accessible name, default "Reading progress"). Style with
|
|
140
|
+
* `--usa-progress-color`, `--usa-progress-height`, `--usa-progress-track`.
|
|
141
|
+
* Exposes the progress (0–1) as `--usa-progress` on the element and as the
|
|
142
|
+
* `progress` property. Event: `usa:progress` (`detail.progress`).
|
|
143
|
+
*
|
|
144
|
+
* Writes only `transform: scaleX()` (compositor-friendly); reads layout
|
|
145
|
+
* once per animation frame, and only while scrolling.
|
|
146
|
+
*/
|
|
147
|
+
interface UsaScrollProgressElement extends UsaElement {
|
|
148
|
+
readonly progress: number;
|
|
149
|
+
/** Re-measure (e.g. after content loaded). */
|
|
150
|
+
update(): void;
|
|
151
|
+
}
|
|
152
|
+
/** Progress (0–1) of `target` scrolling through the viewport, or of the page. */
|
|
153
|
+
declare function readScrollProgress(target?: Element | null): number;
|
|
154
|
+
declare function defineScrollProgress(tag?: string): CustomElementConstructor | undefined;
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* `<usa-scrolly>` — sticky scrollytelling. A child marked `data-sticky`
|
|
158
|
+
* stays pinned while the `[data-step]` children scroll past; the step that
|
|
159
|
+
* crosses the trigger line becomes active.
|
|
160
|
+
*
|
|
161
|
+
* Attributes: `offset` (trigger line as a fraction of the viewport height,
|
|
162
|
+
* default 0.5), `active` (reflected index of the active step). The active
|
|
163
|
+
* step gets `data-active`; the host gets `--usa-step` and `data-step-name`
|
|
164
|
+
* (the step's `data-step` value). Event: `usa:step` (`detail.index`,
|
|
165
|
+
* `detail.step`, `detail.name`).
|
|
166
|
+
*/
|
|
167
|
+
interface UsaScrollyElement extends UsaElement {
|
|
168
|
+
readonly active: number;
|
|
169
|
+
readonly steps: HTMLElement[];
|
|
170
|
+
}
|
|
171
|
+
declare function defineScrolly(tag?: string): CustomElementConstructor | undefined;
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* motionary/components/reveal — entrance & scroll reveal components.
|
|
175
|
+
* `<usa-reveal>`, `<usa-stagger>`, `<usa-scroll-progress>`, `<usa-scrolly>`.
|
|
176
|
+
*/
|
|
177
|
+
|
|
178
|
+
/** Register every component of this category under its default tag. */
|
|
179
|
+
declare function defineRevealComponents(): void;
|
|
180
|
+
declare global {
|
|
181
|
+
interface HTMLElementTagNameMap {
|
|
182
|
+
'usa-reveal': UsaRevealElement;
|
|
183
|
+
'usa-stagger': UsaStaggerElement;
|
|
184
|
+
'usa-scroll-progress': UsaScrollProgressElement;
|
|
185
|
+
'usa-scrolly': UsaScrollyElement;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* `<usa-typewriter>` — types text character by character, optionally cycling
|
|
191
|
+
* through several phrases (typing, pausing, deleting).
|
|
192
|
+
*
|
|
193
|
+
* Attributes: `text` (default: the element's text), `words` (phrases
|
|
194
|
+
* separated by `|`, overrides `text`), `speed` (ms per character, 55),
|
|
195
|
+
* `delete-speed` (ms, 30), `pause` (ms before deleting, 1400), `delay`
|
|
196
|
+
* (ms, 0), `loop`, `cursor="false"` to hide the caret, `start`
|
|
197
|
+
* (`view` | `load` | `manual`, default `view`). The full text is exposed to
|
|
198
|
+
* assistive tech via `aria-label`. Event: `usa:complete` (one pass done).
|
|
199
|
+
* Reduced motion: the text appears at once.
|
|
200
|
+
*/
|
|
201
|
+
interface UsaTypewriterElement extends UsaElement {
|
|
202
|
+
/** Phrases being typed. */
|
|
203
|
+
readonly phrases: string[];
|
|
204
|
+
start(): void;
|
|
205
|
+
stop(): void;
|
|
206
|
+
restart(): void;
|
|
207
|
+
}
|
|
208
|
+
declare function defineTypewriter(tag?: string): CustomElementConstructor | undefined;
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* `<usa-split-text>` — splits its text into words or characters and reveals
|
|
212
|
+
* them in a cascade (pure CSS animation per unit, transform / opacity /
|
|
213
|
+
* filter only). Words never break across lines.
|
|
214
|
+
*
|
|
215
|
+
* 4.3: `Intl.Segmenter`-aware (emoji, CJK words), Arabic-script words are
|
|
216
|
+
* never split below the word, `by="lines"` reveals line by line, and `from`
|
|
217
|
+
* (`start` · `end` · `center` · `edges` · `random`) sets the cascade order.
|
|
218
|
+
*
|
|
219
|
+
* Attributes: `by` (`chars` | `words` | `lines`, default `chars`), `effect`
|
|
220
|
+
* (`rise` | `fade` | `blur` | `flip` | `pop`, default `rise`), `stagger`
|
|
221
|
+
* (ms between units, 28 for chars / 70 for words), `duration` (ms, 620),
|
|
222
|
+
* `delay` (ms, 0), `trigger` (`view` | `load` | `manual`, default `view`),
|
|
223
|
+
* `repeat`. The original text stays readable via `aria-label`.
|
|
224
|
+
* Event: `usa:complete`.
|
|
225
|
+
*/
|
|
226
|
+
interface UsaSplitTextElement extends UsaElement {
|
|
227
|
+
readonly units: HTMLElement[];
|
|
228
|
+
play(): void;
|
|
229
|
+
reset(): void;
|
|
230
|
+
}
|
|
231
|
+
declare function defineSplitText(tag?: string): CustomElementConstructor | undefined;
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* `<usa-scramble>` — "decodes" text out of random glyphs, left to right.
|
|
235
|
+
*
|
|
236
|
+
* Attributes: `text` (default: the element's text), `duration` (ms, 900),
|
|
237
|
+
* `chars` (glyph set), `trigger` (`view` | `hover` | `load` | `manual`,
|
|
238
|
+
* default `view`). Spaces and punctuation stay in place. Uses a monospace-
|
|
239
|
+
* friendly fixed width per glyph only if you style it so; the element sets
|
|
240
|
+
* nothing that causes reflow beyond its own text. Event: `usa:complete`.
|
|
241
|
+
* Reduced motion: shows the final text.
|
|
242
|
+
*/
|
|
243
|
+
interface UsaScrambleElement extends UsaElement {
|
|
244
|
+
play(): Promise<void>;
|
|
245
|
+
}
|
|
246
|
+
/** One frame of the scramble: the first `progress` share is resolved. */
|
|
247
|
+
declare function scrambleFrame(text: string, progress: number, glyphs?: string, rnd?: () => number): string;
|
|
248
|
+
declare function defineScramble(tag?: string): CustomElementConstructor | undefined;
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* `<usa-counter>` — counts up (or down) to a number when it scrolls into view.
|
|
252
|
+
*
|
|
253
|
+
* Attributes: `to` (target, required), `from` (0), `duration` (ms, 1600),
|
|
254
|
+
* `decimals` (0), `locale` (default: the document language), `prefix`,
|
|
255
|
+
* `suffix`, `grouping="false"` (no thousands separators), `start`
|
|
256
|
+
* (`view` | `load` | `manual`). Setting the `value` property animates from
|
|
257
|
+
* the current value — handy for live dashboards. Uses tabular digits so
|
|
258
|
+
* the width does not jump. Event: `usa:complete`. Reduced motion: jumps.
|
|
259
|
+
*/
|
|
260
|
+
interface UsaCounterElement extends UsaElement {
|
|
261
|
+
/** Current target; setting it animates to the new number. */
|
|
262
|
+
value: number;
|
|
263
|
+
/** Animate to `to` (default: the `to` attribute). */
|
|
264
|
+
play(to?: number): Promise<void>;
|
|
265
|
+
format(n: number): string;
|
|
266
|
+
}
|
|
267
|
+
/** easeOutExpo */
|
|
268
|
+
declare const easeOutExpo: (t: number) => number;
|
|
269
|
+
declare function defineCounter(tag?: string): CustomElementConstructor | undefined;
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* `<usa-shimmer-text>` — a light sweep across gradient-filled text (CSS
|
|
273
|
+
* only; the element just maps attributes to custom properties).
|
|
274
|
+
*
|
|
275
|
+
* Attributes: `duration` (ms, 2600), `color` (base text colour), `shine`
|
|
276
|
+
* (highlight colour), `angle` (deg, 110). Or style `--usa-shimmer-*`
|
|
277
|
+
* directly. Reduced motion: static gradient text.
|
|
278
|
+
*/
|
|
279
|
+
type UsaShimmerTextElement = UsaElement;
|
|
280
|
+
declare function defineShimmerText(tag?: string): CustomElementConstructor | undefined;
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* `<usa-text-rotate>` — cycles through words in place ("Build *fast* /
|
|
284
|
+
* *small* / *typed* apps"). All words share one grid cell, so the width is
|
|
285
|
+
* that of the longest word and nothing around it reflows.
|
|
286
|
+
*
|
|
287
|
+
* Attributes: `words` (separated by `|`, default: the element's text split
|
|
288
|
+
* on `|`), `interval` (ms, 2200), `effect` (`slide` | `fade` | `flip` |
|
|
289
|
+
* `blur`, default `slide`), `paused`. Pauses while off-screen and on hover
|
|
290
|
+
* is not needed. Event: `usa:change` (`detail.index`, `detail.word`).
|
|
291
|
+
* Reduced motion: words still change, without movement (fade only).
|
|
292
|
+
*/
|
|
293
|
+
interface UsaTextRotateElement extends UsaElement {
|
|
294
|
+
readonly index: number;
|
|
295
|
+
next(): void;
|
|
296
|
+
}
|
|
297
|
+
declare function defineTextRotate(tag?: string): CustomElementConstructor | undefined;
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* `<usa-wave-text>` — letters bob in a travelling wave.
|
|
301
|
+
* Attributes: `amplitude` (em, 0.25), `speed` (s per cycle, 1.6), `stagger`
|
|
302
|
+
* (s between letters, 0.06). Reduced motion: still text.
|
|
303
|
+
*/
|
|
304
|
+
interface UsaWaveTextElement extends UsaElement {
|
|
305
|
+
}
|
|
306
|
+
declare function defineWaveText(tag?: string): CustomElementConstructor | undefined;
|
|
307
|
+
/**
|
|
308
|
+
* `<usa-glitch>` — an RGB-split glitch on its text (`trigger="always"`
|
|
309
|
+
* default, or `hover`). Attributes: `intensity` (px, 3), `trigger`.
|
|
310
|
+
* Reduced motion: no animation (plain text).
|
|
311
|
+
*/
|
|
312
|
+
interface UsaGlitchElement extends UsaElement {
|
|
313
|
+
}
|
|
314
|
+
declare function defineGlitch(tag?: string): CustomElementConstructor | undefined;
|
|
315
|
+
/**
|
|
316
|
+
* `<usa-gradient-text>` — text filled with a flowing multi-colour gradient.
|
|
317
|
+
* Attributes: `colors` (comma list), `speed` (s, 6), `angle` (deg, 90).
|
|
318
|
+
* Reduced motion: a static gradient.
|
|
319
|
+
*/
|
|
320
|
+
interface UsaGradientTextElement extends UsaElement {
|
|
321
|
+
}
|
|
322
|
+
declare function defineGradientText(tag?: string): CustomElementConstructor | undefined;
|
|
323
|
+
/**
|
|
324
|
+
* `<usa-handwriting>` — the text draws itself stroke by stroke (SVG text
|
|
325
|
+
* outline), then fills in, when it scrolls into view.
|
|
326
|
+
* Attributes: `text`, `duration` (ms, 2400), `stroke` (colour), `size` (px,
|
|
327
|
+
* 64), `font` (family; a script font looks best). Events: `usa:complete`.
|
|
328
|
+
* Reduced motion: the filled text appears at once.
|
|
329
|
+
*/
|
|
330
|
+
interface UsaHandwritingElement extends UsaElement {
|
|
331
|
+
play(): void;
|
|
332
|
+
}
|
|
333
|
+
declare function defineHandwriting(tag?: string): CustomElementConstructor | undefined;
|
|
334
|
+
/**
|
|
335
|
+
* `<usa-scroll-highlight>` — reading highlight: words light up one by one
|
|
336
|
+
* as the paragraph scrolls through the viewport (`mode="words"`, default),
|
|
337
|
+
* or a highlighter marker sweeps behind the text on enter (`mode="marker"`).
|
|
338
|
+
* Attributes: `mode`, `color` (marker), `dim` (opacity of unread words,
|
|
339
|
+
* 0.2). Reduced motion: fully highlighted text.
|
|
340
|
+
*/
|
|
341
|
+
interface UsaScrollHighlightElement extends UsaElement {
|
|
342
|
+
readonly progress: number;
|
|
343
|
+
}
|
|
344
|
+
declare function defineScrollHighlight(tag?: string): CustomElementConstructor | undefined;
|
|
345
|
+
|
|
346
|
+
/**
|
|
347
|
+
* Where a step starts on a timeline:
|
|
348
|
+
* - a number: absolute time in ms
|
|
349
|
+
* - `'>'` (default): when the previous step ends · `'<'`: when it starts
|
|
350
|
+
* - `'+=200'` / `'-=200'`: after / overlapping the previous end
|
|
351
|
+
* - `'<+=100'`: 100ms after the previous step's start
|
|
352
|
+
* - `'intro'` / `'intro+=150'`: at (or relative to) a label
|
|
353
|
+
*/
|
|
354
|
+
type TimelinePosition = number | string;
|
|
355
|
+
interface TimelineStepOptions {
|
|
356
|
+
/** Duration in ms or a motion token name (`'fast'`, `'slow'`…; 4.2). Default: timeline default, 600. */
|
|
357
|
+
duration?: number | string;
|
|
358
|
+
/** CSS easing or a motion token name (`'emphasized'`, `'spring'`…; 4.2). Default `cubic-bezier(0.22, 1, 0.36, 1)`. */
|
|
359
|
+
easing?: string;
|
|
360
|
+
/** Start position, see `TimelinePosition`. */
|
|
361
|
+
at?: TimelinePosition;
|
|
362
|
+
/** ms between targets when the selector matches several elements. */
|
|
363
|
+
stagger?: number;
|
|
364
|
+
}
|
|
365
|
+
interface TimelineOptions {
|
|
366
|
+
/** Defaults for every step. */
|
|
367
|
+
defaults?: Pick<TimelineStepOptions, 'duration' | 'easing' | 'stagger'>;
|
|
368
|
+
/** Playback rate (1 = normal). */
|
|
369
|
+
speed?: number;
|
|
370
|
+
/** Called after `play()` reaches the end (or the start when reversed). */
|
|
371
|
+
onComplete?: () => void;
|
|
372
|
+
/** Called on every frame with progress 0–1. */
|
|
373
|
+
onUpdate?: (progress: number) => void;
|
|
374
|
+
}
|
|
375
|
+
interface ScrubOptions {
|
|
376
|
+
/** Scroll offset (px) before the source's top reaches the viewport bottom where progress starts (JS engine only). */
|
|
377
|
+
offset?: number;
|
|
378
|
+
/** Smoothing 0–1 (0 = immediate, default 0). Smoothing needs the JS engine. */
|
|
379
|
+
smooth?: number;
|
|
380
|
+
/**
|
|
381
|
+
* 4.1: which progress source drives the timeline.
|
|
382
|
+
* - `'view'` (default): `source` moving through the viewport (CSS `ViewTimeline`, range `cover`).
|
|
383
|
+
* - `'scroll'`: the scroll position of `source` itself (a scroll container; CSS `ScrollTimeline`).
|
|
384
|
+
*/
|
|
385
|
+
source?: 'view' | 'scroll';
|
|
386
|
+
/** 4.1: `'auto'` (default) uses the browser's native scroll-driven animations when available, `'js'` forces the fallback. */
|
|
387
|
+
engine?: 'auto' | 'native' | 'js';
|
|
388
|
+
/** 4.1: scroll axis, `'block'` (default) · `'inline'` · `'x'` · `'y'`. */
|
|
389
|
+
axis?: 'block' | 'inline' | 'x' | 'y';
|
|
390
|
+
}
|
|
391
|
+
/** The function `scrub()` returns: call it to stop. `native` tells which engine runs it. */
|
|
392
|
+
interface ScrubHandle {
|
|
393
|
+
(): void;
|
|
394
|
+
/** `true` when the browser's ScrollTimeline / ViewTimeline drives it (compositor, no JS per frame). */
|
|
395
|
+
readonly native: boolean;
|
|
396
|
+
}
|
|
397
|
+
/** 4.1: whether `scrub()` can use native ScrollTimeline / ViewTimeline here. */
|
|
398
|
+
declare function supportsNativeScrub(source?: 'view' | 'scroll'): boolean;
|
|
399
|
+
interface Timeline {
|
|
400
|
+
/** Total length in ms. */
|
|
401
|
+
readonly duration: number;
|
|
402
|
+
/** Label positions in ms. */
|
|
403
|
+
readonly labels: Readonly<Record<string, number>>;
|
|
404
|
+
/** Current playhead in ms. */
|
|
405
|
+
readonly time: number;
|
|
406
|
+
/** Add a step: animate `target` with keyframes or a preset name (`fade-up`, `scale`…). */
|
|
407
|
+
to(target: string | Element | Element[] | NodeList, frames: Keyframe[] | string, options?: TimelineStepOptions): Timeline;
|
|
408
|
+
/** Name a position (default: the current end). */
|
|
409
|
+
label(name: string, at?: TimelinePosition): Timeline;
|
|
410
|
+
/** Run `fn` when the playhead passes `at`. */
|
|
411
|
+
call(fn: () => void, at?: TimelinePosition): Timeline;
|
|
412
|
+
/** Play forwards from the playhead (from 0 when at the end). Resolves at the end. */
|
|
413
|
+
play(from?: TimelinePosition): Promise<void>;
|
|
414
|
+
/** Play backwards to 0. */
|
|
415
|
+
reverse(): Promise<void>;
|
|
416
|
+
pause(): Timeline;
|
|
417
|
+
/** Jump to a time (ms) or label. */
|
|
418
|
+
seek(to: TimelinePosition): Timeline;
|
|
419
|
+
/** Get or set progress 0–1. */
|
|
420
|
+
progress(p?: number): number;
|
|
421
|
+
/**
|
|
422
|
+
* Tie progress to scroll: `source` moving through the viewport (or, with
|
|
423
|
+
* `{ source: 'scroll' }`, a scroll container's own position). Runs on native
|
|
424
|
+
* ScrollTimeline / ViewTimeline when available (and no `smooth`, `offset`,
|
|
425
|
+
* `call()` cues or `onUpdate` need JS), else on a rAF-throttled listener.
|
|
426
|
+
* Returns a stop function with a `native` flag.
|
|
427
|
+
*/
|
|
428
|
+
scrub(source: Element, options?: ScrubOptions): ScrubHandle;
|
|
429
|
+
/** Stop and drop every animation (elements keep their last frame). */
|
|
430
|
+
cancel(): void;
|
|
431
|
+
}
|
|
432
|
+
/** Keyframe presets usable by name in `to()` and `data-tl`. */
|
|
433
|
+
declare const TIMELINE_PRESETS: Record<string, Keyframe[]>;
|
|
434
|
+
/** Resolve a position against the previous step and labels (pure). */
|
|
435
|
+
declare function resolvePosition(pos: TimelinePosition | undefined, end: number, prevStart: number, labels?: Record<string, number>): number;
|
|
436
|
+
/**
|
|
437
|
+
* Choreograph animations on one clock: chain, overlap, label, seek, reverse and
|
|
438
|
+
* scrub them with scroll. Built on WAAPI (paused animations driven by one
|
|
439
|
+
* playhead); without WAAPI or under reduced motion it jumps to the end state.
|
|
440
|
+
*
|
|
441
|
+
* @example
|
|
442
|
+
* const tl = timeline({ defaults: { duration: 500 } })
|
|
443
|
+
* .to('.title', 'fade-up')
|
|
444
|
+
* .label('cards')
|
|
445
|
+
* .to('.card', 'scale', { stagger: 80, at: '-=200' })
|
|
446
|
+
* .to('.cta', [{ opacity: 0 }, { opacity: 1 }], { at: 'cards+=400' });
|
|
447
|
+
* tl.play(); // or tl.scrub(document.querySelector('.hero'))
|
|
448
|
+
*/
|
|
449
|
+
declare function timeline(options?: TimelineOptions): Timeline;
|
|
450
|
+
|
|
451
|
+
/**
|
|
452
|
+
* `splitText()` (4.3) — split an element's text into characters, words and / or
|
|
453
|
+
* lines, ready for per-unit choreography with `timeline()`.
|
|
454
|
+
*
|
|
455
|
+
* - Grapheme- and word-aware via `Intl.Segmenter` when available: emoji and
|
|
456
|
+
* combining marks stay whole; Chinese / Japanese / Korean text is split into
|
|
457
|
+
* real words (or one unit per character without `Segmenter`).
|
|
458
|
+
* - RTL aware: Arabic-script text (cursive, letters join) is never split
|
|
459
|
+
* below the word, so shaping is preserved; Hebrew and other RTL scripts
|
|
460
|
+
* split per character. Units stay in logical (reading) order.
|
|
461
|
+
* - Nested inline markup (`<em>`, `<a>`, `<br>`) is preserved.
|
|
462
|
+
* - Accessible: the original text stays available to assistive tech via a
|
|
463
|
+
* visually hidden copy; the split spans are `aria-hidden`.
|
|
464
|
+
*/
|
|
465
|
+
type SplitBy = 'char' | 'word' | 'line';
|
|
466
|
+
interface SplitTextOptions {
|
|
467
|
+
/** What to split into: `'char'`, `'word'`, `'line'` or several, e.g. `['word', 'line']`. Default `'char'` (words are always wrapped too). */
|
|
468
|
+
by?: SplitBy | SplitBy[] | string;
|
|
469
|
+
/** Locale for `Intl.Segmenter` (default: the element's `lang`, else the document's). */
|
|
470
|
+
locale?: string;
|
|
471
|
+
/** Class prefix (default `usa-split`): units get `usa-split-char` / `-word` / `-line`. */
|
|
472
|
+
className?: string;
|
|
473
|
+
}
|
|
474
|
+
interface SplitResult {
|
|
475
|
+
chars: HTMLElement[];
|
|
476
|
+
words: HTMLElement[];
|
|
477
|
+
lines: HTMLElement[];
|
|
478
|
+
/** `'rtl'` or `'ltr'` — the direction the split ran in. */
|
|
479
|
+
direction: 'ltr' | 'rtl';
|
|
480
|
+
/** Re-measure lines (call after a resize or font load). */
|
|
481
|
+
relayout(): HTMLElement[];
|
|
482
|
+
/** Restore the original markup. */
|
|
483
|
+
revert(): void;
|
|
484
|
+
}
|
|
485
|
+
/** Scripts whose letters join (splitting them would break shaping). */
|
|
486
|
+
declare const JOINING_SCRIPT: RegExp;
|
|
487
|
+
/** Grapheme clusters of `s` (emoji / combining marks stay whole). */
|
|
488
|
+
declare function graphemes(s: string, locale?: string): string[];
|
|
489
|
+
/**
|
|
490
|
+
* Word-ish tokens of `s`, whitespace kept as separate tokens. CJK text is
|
|
491
|
+
* segmented into words with `Intl.Segmenter`, or per character without it.
|
|
492
|
+
*/
|
|
493
|
+
declare function words(s: string, locale?: string): string[];
|
|
494
|
+
declare function splitText(el: HTMLElement, options?: SplitTextOptions): SplitResult;
|
|
495
|
+
type SplitFrom = 'start' | 'end' | 'center' | 'edges' | 'random';
|
|
496
|
+
/** Order indices `0…n-1` by choreography: from the start, end, center outwards, edges inwards, or random (seeded). */
|
|
497
|
+
declare function splitOrder(n: number, from?: SplitFrom, seed?: number): number[];
|
|
498
|
+
interface SplitTimelineOptions extends SplitTextOptions {
|
|
499
|
+
/** Which units to animate (default: the finest in `by`). */
|
|
500
|
+
unit?: 'char' | 'word' | 'line';
|
|
501
|
+
/** Timeline preset name or keyframes (default `'fade-up'`). */
|
|
502
|
+
preset?: string | Keyframe[];
|
|
503
|
+
/** ms between units (default 30 for chars, 80 for words, 140 for lines). */
|
|
504
|
+
stagger?: number;
|
|
505
|
+
/** Duration per unit in ms or a motion token name (default 500). */
|
|
506
|
+
duration?: number | string;
|
|
507
|
+
easing?: string;
|
|
508
|
+
/** Choreography order (default `'start'` — reading order, also for RTL). */
|
|
509
|
+
from?: SplitFrom;
|
|
510
|
+
}
|
|
511
|
+
/**
|
|
512
|
+
* Split `el` and build a `timeline()` with one step per unit — play it,
|
|
513
|
+
* `scrub()` it with scroll, `reverse()` or `seek()` it.
|
|
514
|
+
*
|
|
515
|
+
* ```ts
|
|
516
|
+
* const { timeline: tl } = splitTimeline(h1, { by: 'char', preset: 'blur', from: 'center' });
|
|
517
|
+
* tl.play();
|
|
518
|
+
* ```
|
|
519
|
+
*/
|
|
520
|
+
declare function splitTimeline(el: HTMLElement, options?: SplitTimelineOptions): {
|
|
521
|
+
split: SplitResult;
|
|
522
|
+
timeline: Timeline;
|
|
523
|
+
};
|
|
524
|
+
|
|
525
|
+
/**
|
|
526
|
+
* motionary/components/text — text effects.
|
|
527
|
+
* `<usa-typewriter>`, `<usa-split-text>`, `<usa-scramble>`, `<usa-counter>`,
|
|
528
|
+
* `<usa-shimmer-text>`, `<usa-text-rotate>`.
|
|
529
|
+
*/
|
|
530
|
+
|
|
531
|
+
/** Register every component of this category under its default tag. */
|
|
532
|
+
declare function defineTextComponents(): void;
|
|
533
|
+
declare global {
|
|
534
|
+
interface HTMLElementTagNameMap {
|
|
535
|
+
'usa-wave-text': UsaWaveTextElement;
|
|
536
|
+
'usa-glitch': UsaGlitchElement;
|
|
537
|
+
'usa-gradient-text': UsaGradientTextElement;
|
|
538
|
+
'usa-handwriting': UsaHandwritingElement;
|
|
539
|
+
'usa-scroll-highlight': UsaScrollHighlightElement;
|
|
540
|
+
'usa-typewriter': UsaTypewriterElement;
|
|
541
|
+
'usa-split-text': UsaSplitTextElement;
|
|
542
|
+
'usa-scramble': UsaScrambleElement;
|
|
543
|
+
'usa-counter': UsaCounterElement;
|
|
544
|
+
'usa-shimmer-text': UsaShimmerTextElement;
|
|
545
|
+
'usa-text-rotate': UsaTextRotateElement;
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
/**
|
|
550
|
+
* `<usa-ripple>` — an ink ripple from the pointer (or the centre, for
|
|
551
|
+
* keyboard presses) on whatever it wraps: buttons, list items, cards.
|
|
552
|
+
*
|
|
553
|
+
* Attributes: `color` (default `currentColor`), `opacity` (0.22),
|
|
554
|
+
* `duration` (ms, 550), `centered`, `disabled`. Clips its content to its
|
|
555
|
+
* own border radius. Reduced motion: a brief highlight instead of the wave.
|
|
556
|
+
*/
|
|
557
|
+
interface UsaRippleElement extends UsaElement {
|
|
558
|
+
/** Spawn a ripple at client coordinates (default: centre). */
|
|
559
|
+
ripple(x?: number, y?: number): void;
|
|
560
|
+
}
|
|
561
|
+
declare function defineRipple(tag?: string): CustomElementConstructor | undefined;
|
|
562
|
+
|
|
563
|
+
/**
|
|
564
|
+
* `<usa-magnetic>` — its content leans toward the pointer when the pointer
|
|
565
|
+
* comes near, and springs back when it leaves (great for CTAs and icons).
|
|
566
|
+
*
|
|
567
|
+
* Attributes: `strength` (0–1 share of the pointer offset, 0.35), `radius`
|
|
568
|
+
* (px of attraction beyond the element's edge, 60), `disabled`. Only on
|
|
569
|
+
* devices with a fine pointer that hovers; off under reduced motion.
|
|
570
|
+
* Writes one `transform` per frame through `--usa-mx` / `--usa-my`.
|
|
571
|
+
*/
|
|
572
|
+
type UsaMagneticElement = UsaElement;
|
|
573
|
+
declare function defineMagnetic(tag?: string): CustomElementConstructor | undefined;
|
|
574
|
+
|
|
575
|
+
/**
|
|
576
|
+
* `<usa-tilt>` — a 3D card that tilts toward the pointer, with an optional
|
|
577
|
+
* glare highlight that follows it.
|
|
578
|
+
*
|
|
579
|
+
* Attributes: `max` (deg, 10), `scale` (1.03 while hovered), `perspective`
|
|
580
|
+
* (px, 900), `glare` (add the light reflection), `reverse` (tilt away),
|
|
581
|
+
* `disabled`. Off under reduced motion. Exposes `--usa-tilt-x` /
|
|
582
|
+
* `--usa-tilt-y` (−1…1) for parallax layers inside the card.
|
|
583
|
+
*/
|
|
584
|
+
type UsaTiltElement = UsaElement;
|
|
585
|
+
declare function defineTilt(tag?: string): CustomElementConstructor | undefined;
|
|
586
|
+
|
|
587
|
+
/**
|
|
588
|
+
* `<usa-spotlight>` — the Windows Fluent "Reveal highlight": a soft light
|
|
589
|
+
* follows the pointer across a group of items, lighting up their borders
|
|
590
|
+
* (even of neighbours) and the background of the hovered one. Put buttons,
|
|
591
|
+
* tiles or menu items inside; each direct child is an item (or mark items
|
|
592
|
+
* with `data-spotlight` to pick them yourself).
|
|
593
|
+
*
|
|
594
|
+
* Attributes: `size` (px, radius of the light, 160), `color` (default a
|
|
595
|
+
* translucent white), `border` (px width of the lit border, 1),
|
|
596
|
+
* `no-fill` (only light the borders). Not a motion effect, so it stays on
|
|
597
|
+
* under reduced motion; off on touch-only devices.
|
|
598
|
+
*/
|
|
599
|
+
type UsaSpotlightElement = UsaElement;
|
|
600
|
+
declare function defineSpotlight(tag?: string): CustomElementConstructor | undefined;
|
|
601
|
+
|
|
602
|
+
/**
|
|
603
|
+
* `<usa-press>` — tactile press feedback: content dips while pressed and
|
|
604
|
+
* springs back on release (the Fluent "pointer down" scale), or bounces once
|
|
605
|
+
* on click with `bounce`.
|
|
606
|
+
*
|
|
607
|
+
* Attributes: `scale` (pressed scale, 0.95), `bounce` (overshoot on
|
|
608
|
+
* release), `disabled`. Works with mouse, touch, pen and Space/Enter.
|
|
609
|
+
* Reduced motion: a subtle dim instead of scaling.
|
|
610
|
+
*/
|
|
611
|
+
interface UsaPressElement extends UsaElement {
|
|
612
|
+
readonly pressed: boolean;
|
|
613
|
+
}
|
|
614
|
+
declare function definePress(tag?: string): CustomElementConstructor | undefined;
|
|
615
|
+
|
|
616
|
+
/**
|
|
617
|
+
* `<usa-toggle>` — an accessible switch whose knob stretches while pressed
|
|
618
|
+
* and glides across (the Windows 11 / iOS toggle). `role="switch"`,
|
|
619
|
+
* keyboard (Space / Enter), and form-associated where `ElementInternals`
|
|
620
|
+
* exists (submits `value`, default `"on"`, under `name` when checked).
|
|
621
|
+
*
|
|
622
|
+
* Attributes: `checked`, `disabled`, `name`, `value`, `label`
|
|
623
|
+
* (accessible name if there is no `aria-label` / `<label>`). Events:
|
|
624
|
+
* `change` and `usa:change` (`detail.checked`). Reduced motion: no glide.
|
|
625
|
+
*/
|
|
626
|
+
interface UsaToggleElement extends UsaElement {
|
|
627
|
+
checked: boolean;
|
|
628
|
+
disabled: boolean;
|
|
629
|
+
toggle(force?: boolean): void;
|
|
630
|
+
}
|
|
631
|
+
declare function defineToggle(tag?: string): CustomElementConstructor | undefined;
|
|
632
|
+
|
|
633
|
+
/**
|
|
634
|
+
* motionary/components/interaction — micro-interactions.
|
|
635
|
+
* `<usa-ripple>`, `<usa-magnetic>`, `<usa-tilt>`, `<usa-spotlight>`,
|
|
636
|
+
* `<usa-press>`, `<usa-toggle>`.
|
|
637
|
+
*/
|
|
638
|
+
|
|
639
|
+
/** Register every component of this category under its default tag. */
|
|
640
|
+
declare function defineInteractionComponents(): void;
|
|
641
|
+
declare global {
|
|
642
|
+
interface HTMLElementTagNameMap {
|
|
643
|
+
'usa-ripple': UsaRippleElement;
|
|
644
|
+
'usa-magnetic': UsaMagneticElement;
|
|
645
|
+
'usa-tilt': UsaTiltElement;
|
|
646
|
+
'usa-spotlight': UsaSpotlightElement;
|
|
647
|
+
'usa-press': UsaPressElement;
|
|
648
|
+
'usa-toggle': UsaToggleElement;
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
declare const SPINNER_VARIANTS: readonly ["fluent", "windows", "ring", "dots", "pulse", "bars"];
|
|
653
|
+
type SpinnerVariant = (typeof SPINNER_VARIANTS)[number];
|
|
654
|
+
/**
|
|
655
|
+
* `<usa-spinner>` — indeterminate loading indicators, pure CSS animations
|
|
656
|
+
* of `transform` / `opacity` (plus an SVG stroke for `fluent`).
|
|
657
|
+
*
|
|
658
|
+
* Kinds (`kind`): `fluent` (default — the WinUI / Windows 11
|
|
659
|
+
* ProgressRing arc), `windows` (the Windows 10 boot "orbiting dots"),
|
|
660
|
+
* `ring` (classic border spinner), `dots` (three bouncing dots / typing
|
|
661
|
+
* indicator), `pulse` (expanding ripple), `bars` (equalizer).
|
|
662
|
+
* Attributes: `size` (px, 32), `label` (accessible name, "Loading"),
|
|
663
|
+
* `paused`. Colour follows `color` / `--usa-spinner-color`.
|
|
664
|
+
* `role="progressbar"` without a value (indeterminate). Reduced motion:
|
|
665
|
+
* a slow opacity pulse instead of movement.
|
|
666
|
+
*/
|
|
667
|
+
interface UsaSpinnerElement extends UsaElement {
|
|
668
|
+
/** Spinner kind (`kind` attribute). */
|
|
669
|
+
kind: SpinnerVariant;
|
|
670
|
+
}
|
|
671
|
+
declare function defineSpinner(tag?: string): CustomElementConstructor | undefined;
|
|
672
|
+
|
|
673
|
+
/**
|
|
674
|
+
* `<usa-skeleton>` — shimmering placeholders while content loads. With
|
|
675
|
+
* `loading`, it shows `lines` bars (or one block of `width` × `height`,
|
|
676
|
+
* or a `circle`) and hides its children; remove `loading` and the real
|
|
677
|
+
* content fades in.
|
|
678
|
+
*
|
|
679
|
+
* Attributes: `loading`, `lines` (3), `width`, `height` (CSS lengths),
|
|
680
|
+
* `circle`, `radius`, `avatar` (circle + lines, like a list row).
|
|
681
|
+
* `aria-busy` follows `loading`. Reduced motion: no shimmer sweep.
|
|
682
|
+
*/
|
|
683
|
+
interface UsaSkeletonElement extends UsaElement {
|
|
684
|
+
loading: boolean;
|
|
685
|
+
}
|
|
686
|
+
declare function defineSkeleton(tag?: string): CustomElementConstructor | undefined;
|
|
687
|
+
|
|
688
|
+
/**
|
|
689
|
+
* `<usa-progress>` — a linear progress bar. Determinate (`value` / `max`)
|
|
690
|
+
* bars glide between values with `transform: scaleX()`; without a value,
|
|
691
|
+
* or with `indeterminate`, it shows the Windows Fluent indeterminate
|
|
692
|
+
* animation (two sliding segments).
|
|
693
|
+
*
|
|
694
|
+
* Attributes: `value`, `max` (100), `indeterminate`, `state`
|
|
695
|
+
* (`paused` | `error` — the WinUI states), `label` (accessible name).
|
|
696
|
+
* `role="progressbar"` with `aria-valuenow` when determinate.
|
|
697
|
+
* Reduced motion: no glide; indeterminate becomes a gentle pulse.
|
|
698
|
+
*/
|
|
699
|
+
interface UsaProgressElement extends UsaElement {
|
|
700
|
+
value: number | null;
|
|
701
|
+
max: number;
|
|
702
|
+
/** 0–1, or `null` when indeterminate. */
|
|
703
|
+
readonly ratio: number | null;
|
|
704
|
+
}
|
|
705
|
+
declare function defineProgress(tag?: string): CustomElementConstructor | undefined;
|
|
706
|
+
|
|
707
|
+
type ToastType = 'info' | 'success' | 'warning' | 'error';
|
|
708
|
+
interface ToastOptions {
|
|
709
|
+
/** ms before it hides itself; `0` keeps it until closed (default 4000). */
|
|
710
|
+
duration?: number;
|
|
711
|
+
type?: ToastType;
|
|
712
|
+
/** Optional action button. */
|
|
713
|
+
action?: {
|
|
714
|
+
label: string;
|
|
715
|
+
onClick: () => void;
|
|
716
|
+
};
|
|
717
|
+
/** Show a close button (default `true`). */
|
|
718
|
+
dismissible?: boolean;
|
|
719
|
+
/** The toaster to use (default: the first `<usa-toaster>`, created if missing). */
|
|
720
|
+
toaster?: UsaToasterElement | string;
|
|
721
|
+
}
|
|
722
|
+
interface ToastHandle {
|
|
723
|
+
element: HTMLElement;
|
|
724
|
+
close(): Promise<void>;
|
|
725
|
+
}
|
|
726
|
+
/**
|
|
727
|
+
* `<usa-toaster>` — the region toasts slide into (`role="region"`, each
|
|
728
|
+
* toast `role="status"`, errors `role="alert"`). Toasts pause their timer
|
|
729
|
+
* while hovered or focused, and the stack re-flows with a FLIP animation.
|
|
730
|
+
*
|
|
731
|
+
* Attributes: `position` (`bottom-right` default, `bottom-left`,
|
|
732
|
+
* `bottom-center`, `top-right`, `top-left`, `top-center`), `max` (visible
|
|
733
|
+
* toasts, 4), `label` (region name, "Notifications").
|
|
734
|
+
* Reduced motion: toasts fade instead of sliding.
|
|
735
|
+
*/
|
|
736
|
+
interface UsaToasterElement extends UsaElement {
|
|
737
|
+
show(message: string, options?: ToastOptions): ToastHandle;
|
|
738
|
+
clear(): void;
|
|
739
|
+
}
|
|
740
|
+
declare function defineToaster(tag?: string): CustomElementConstructor | undefined;
|
|
741
|
+
/**
|
|
742
|
+
* Show a toast. Defines `<usa-toaster>` and adds one to `<body>` if the
|
|
743
|
+
* page has none. Returns a handle with `close()`. No-op on the server.
|
|
744
|
+
*
|
|
745
|
+
* ```js
|
|
746
|
+
* toast('Saved', { type: 'success' });
|
|
747
|
+
* ```
|
|
748
|
+
*/
|
|
749
|
+
declare function toast(message: string, options?: ToastOptions): ToastHandle | null;
|
|
750
|
+
|
|
751
|
+
/**
|
|
752
|
+
* `<usa-check>` — an animated result icon: the circle draws itself, then the
|
|
753
|
+
* check mark (or cross / exclamation) strokes in with a little pop.
|
|
754
|
+
*
|
|
755
|
+
* Attributes: `kind` (`success` default, `error`, `warning`), `size`
|
|
756
|
+
* (px, 56), `start` (`view` default | `load` | `manual`), `label`
|
|
757
|
+
* (accessible name, e.g. "Payment complete"; the icon is decorative
|
|
758
|
+
* without it). Event: `usa:complete`. Reduced motion: drawn instantly.
|
|
759
|
+
*/
|
|
760
|
+
interface UsaCheckElement extends UsaElement {
|
|
761
|
+
play(): Promise<void>;
|
|
762
|
+
reset(): void;
|
|
763
|
+
}
|
|
764
|
+
declare function defineCheck(tag?: string): CustomElementConstructor | undefined;
|
|
765
|
+
|
|
766
|
+
/**
|
|
767
|
+
* motionary/components/feedback — loading & feedback.
|
|
768
|
+
* `<usa-spinner>`, `<usa-skeleton>`, `<usa-progress>`, `<usa-toaster>` +
|
|
769
|
+
* `toast()`, `<usa-check>`.
|
|
770
|
+
*/
|
|
771
|
+
|
|
772
|
+
/** Register every component of this category under its default tag. */
|
|
773
|
+
declare function defineFeedbackComponents(): void;
|
|
774
|
+
declare global {
|
|
775
|
+
interface HTMLElementTagNameMap {
|
|
776
|
+
'usa-spinner': UsaSpinnerElement;
|
|
777
|
+
'usa-skeleton': UsaSkeletonElement;
|
|
778
|
+
'usa-progress': UsaProgressElement;
|
|
779
|
+
'usa-toaster': UsaToasterElement;
|
|
780
|
+
'usa-check': UsaCheckElement;
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
/**
|
|
785
|
+
* `<usa-aurora>` — a slow, drifting aurora / gradient-mesh backdrop behind
|
|
786
|
+
* its content. Soft radial gradients moved with `transform` only (no
|
|
787
|
+
* animated blur), paused while off-screen.
|
|
788
|
+
*
|
|
789
|
+
* Attributes: `colors` (comma-separated, default violet / cyan / pink),
|
|
790
|
+
* `speed` (multiplier, 1), `intensity` (0–1 opacity, 0.7), `paused`.
|
|
791
|
+
* Reduced motion: a still gradient.
|
|
792
|
+
*/
|
|
793
|
+
type UsaAuroraElement = UsaElement;
|
|
794
|
+
declare function defineAurora(tag?: string): CustomElementConstructor | undefined;
|
|
795
|
+
|
|
796
|
+
/**
|
|
797
|
+
* `<usa-particles>` — a canvas of drifting particles, optionally linked by
|
|
798
|
+
* lines when close (a "constellation"), that drift away from the pointer.
|
|
799
|
+
* Fills its own box (place it as a background with
|
|
800
|
+
* `position: absolute; inset: 0`, or give it a height).
|
|
801
|
+
*
|
|
802
|
+
* Attributes: `count` (60; scaled down on small boxes), `color`
|
|
803
|
+
* (default `currentColor`), `size` (max radius px, 2.2), `speed` (0.35),
|
|
804
|
+
* `links` (max link distance px, 110; `0` disables), `interactive`,
|
|
805
|
+
* `paused`. Renders only while visible and the tab is shown, at device
|
|
806
|
+
* pixel ratio ≤ 2. Reduced motion: one still frame.
|
|
807
|
+
*/
|
|
808
|
+
interface UsaParticlesElement extends UsaElement {
|
|
809
|
+
/** Re-seed the particles. */
|
|
810
|
+
reset(): void;
|
|
811
|
+
}
|
|
812
|
+
declare function defineParticles(tag?: string): CustomElementConstructor | undefined;
|
|
813
|
+
|
|
814
|
+
/**
|
|
815
|
+
* `<usa-grain>` — a film-grain / noise overlay on top of its content
|
|
816
|
+
* (SVG `feTurbulence` texture, no images to ship). With `animated`, the
|
|
817
|
+
* grain jitters like film (stepped `transform`, ~12 fps).
|
|
818
|
+
*
|
|
819
|
+
* Attributes: `opacity` (0.12), `animated`, `blend` (`mix-blend-mode`,
|
|
820
|
+
* default `overlay`), `scale` (texture size px, 180). Never intercepts
|
|
821
|
+
* pointer events. Reduced motion: static grain.
|
|
822
|
+
*/
|
|
823
|
+
type UsaGrainElement = UsaElement;
|
|
824
|
+
declare function defineGrain(tag?: string): CustomElementConstructor | undefined;
|
|
825
|
+
|
|
826
|
+
/**
|
|
827
|
+
* `<usa-marquee>` — an infinite, seamless ticker of its children (logos,
|
|
828
|
+
* testimonials, tags). The content is cloned (clones are `aria-hidden` and
|
|
829
|
+
* `inert`) and the track slides with one WAAPI `transform` animation whose
|
|
830
|
+
* duration follows the measured width, so the speed is constant.
|
|
831
|
+
*
|
|
832
|
+
* Attributes: `speed` (px/s, 50), `direction` (`left` default | `right` |
|
|
833
|
+
* `up` | `down`), `gap` (px, 32), `pause-on-hover`, `fade` (soft edges),
|
|
834
|
+
* `paused`. Pauses off-screen. Reduced motion: no movement; the row
|
|
835
|
+
* becomes scrollable instead.
|
|
836
|
+
*/
|
|
837
|
+
interface UsaMarqueeElement extends UsaElement {
|
|
838
|
+
pause(): void;
|
|
839
|
+
resume(): void;
|
|
840
|
+
}
|
|
841
|
+
declare function defineMarquee(tag?: string): CustomElementConstructor | undefined;
|
|
842
|
+
|
|
843
|
+
/**
|
|
844
|
+
* `<usa-acrylic>` — Windows Fluent materials for the web: `acrylic`
|
|
845
|
+
* (frosted glass: backdrop blur + saturation + tint + subtle noise) and
|
|
846
|
+
* `mica` (an opaque, wallpaper-tinted base for app backgrounds; on the web it
|
|
847
|
+
* tints from `--usa-mica-source`, a gradient you control). Optional
|
|
848
|
+
* `shimmer` adds a light sweep when it appears or on hover.
|
|
849
|
+
*
|
|
850
|
+
* Attributes: `kind` (`acrylic` default | `mica`), `tint` (colour),
|
|
851
|
+
* `tint-opacity` (0–1, 0.55), `blur` (px, 30), `shimmer`
|
|
852
|
+
* (`hover` | `load` | `none`, default `none`). Falls back to a solid tint
|
|
853
|
+
* without `backdrop-filter` and under `prefers-reduced-transparency` or
|
|
854
|
+
* forced colours, like Windows does when transparency effects are off.
|
|
855
|
+
*/
|
|
856
|
+
type UsaAcrylicElement = UsaElement;
|
|
857
|
+
declare function defineAcrylic(tag?: string): CustomElementConstructor | undefined;
|
|
858
|
+
|
|
859
|
+
/**
|
|
860
|
+
* `<usa-grid-glow>` — a line grid behind its content that lights up around
|
|
861
|
+
* the pointer. Attributes: `size` (cell px, 32), `color`, `radius` (px, 220).
|
|
862
|
+
* Reduced motion: the grid stays, a soft static glow in the centre.
|
|
863
|
+
*/
|
|
864
|
+
interface UsaGridGlowElement extends UsaElement {
|
|
865
|
+
}
|
|
866
|
+
declare function defineGridGlow(tag?: string): CustomElementConstructor | undefined;
|
|
867
|
+
/**
|
|
868
|
+
* `<usa-blobs>` — soft, slowly morphing colour blobs (fluid gradient
|
|
869
|
+
* backdrop). Attributes: `colors` (comma list), `speed` (1), `blur` (px, 60).
|
|
870
|
+
* Reduced motion: still blobs.
|
|
871
|
+
*/
|
|
872
|
+
interface UsaBlobsElement extends UsaElement {
|
|
873
|
+
}
|
|
874
|
+
declare function defineBlobs(tag?: string): CustomElementConstructor | undefined;
|
|
875
|
+
/**
|
|
876
|
+
* `<usa-water-ripple>` — interactive water ripples on a canvas over its
|
|
877
|
+
* content (pointer moves and taps disturb the surface). Low-resolution height
|
|
878
|
+
* map, paused off-screen. Attributes: `damping` (0.96), `strength` (1),
|
|
879
|
+
* `color` (highlight). Reduced motion: nothing is drawn.
|
|
880
|
+
*/
|
|
881
|
+
interface UsaWaterRippleElement extends UsaElement {
|
|
882
|
+
drop(x: number, y: number, strength?: number): void;
|
|
883
|
+
}
|
|
884
|
+
declare function defineWaterRipple(tag?: string): CustomElementConstructor | undefined;
|
|
885
|
+
/**
|
|
886
|
+
* `<usa-dot-network>` — a grid of dots that swell and link up with lines
|
|
887
|
+
* around the pointer (a living network backdrop). Attributes: `gap` (px,
|
|
888
|
+
* 28), `color`, `radius` (px of influence, 140). Reduced motion: a static
|
|
889
|
+
* dot grid.
|
|
890
|
+
*/
|
|
891
|
+
interface UsaDotNetworkElement extends UsaElement {
|
|
892
|
+
}
|
|
893
|
+
declare function defineDotNetwork(tag?: string): CustomElementConstructor | undefined;
|
|
894
|
+
|
|
895
|
+
interface FluentPresetOptions {
|
|
896
|
+
/** Root to apply to (default `document.documentElement`). */
|
|
897
|
+
root?: HTMLElement;
|
|
898
|
+
/** Reveal highlight on interactive elements (default `true`). */
|
|
899
|
+
reveal?: boolean;
|
|
900
|
+
/** Reveal targets (default buttons, links, `[data-fluent-reveal]`). */
|
|
901
|
+
selector?: string;
|
|
902
|
+
/** Mica-style tinted window background on `<body>` (default `true`). */
|
|
903
|
+
mica?: boolean;
|
|
904
|
+
}
|
|
905
|
+
/**
|
|
906
|
+
* Windows 11 **Fluent preset** (v2.8): applies the `fluent` variant
|
|
907
|
+
* (Segoe UI Variable, Windows accent, 8 px radii), a Mica-style tinted
|
|
908
|
+
* window background, Acrylic on `.usa-acrylic` / `[data-acrylic]`, and
|
|
909
|
+
* Reveal highlight (a light following the pointer on borders and
|
|
910
|
+
* backgrounds of interactive elements). Ideal for WebView2 / Electron /
|
|
911
|
+
* Tauri apps on Windows. Returns a function that removes it.
|
|
912
|
+
* Respects reduced motion / transparency (no Reveal tracking; solid materials).
|
|
913
|
+
*/
|
|
914
|
+
declare function fluentPreset(options?: FluentPresetOptions): () => void;
|
|
915
|
+
|
|
916
|
+
/**
|
|
917
|
+
* motionary/components/background — backgrounds & decoration.
|
|
918
|
+
* `<usa-aurora>`, `<usa-particles>`, `<usa-grain>`, `<usa-marquee>`,
|
|
919
|
+
* `<usa-acrylic>`.
|
|
920
|
+
*/
|
|
921
|
+
|
|
922
|
+
/** Register every component of this category under its default tag. */
|
|
923
|
+
declare function defineBackgroundComponents(): void;
|
|
924
|
+
declare global {
|
|
925
|
+
interface HTMLElementTagNameMap {
|
|
926
|
+
'usa-grid-glow': UsaGridGlowElement;
|
|
927
|
+
'usa-blobs': UsaBlobsElement;
|
|
928
|
+
'usa-water-ripple': UsaWaterRippleElement;
|
|
929
|
+
'usa-dot-network': UsaDotNetworkElement;
|
|
930
|
+
'usa-aurora': UsaAuroraElement;
|
|
931
|
+
'usa-particles': UsaParticlesElement;
|
|
932
|
+
'usa-grain': UsaGrainElement;
|
|
933
|
+
'usa-marquee': UsaMarqueeElement;
|
|
934
|
+
'usa-acrylic': UsaAcrylicElement;
|
|
935
|
+
}
|
|
936
|
+
}
|
|
937
|
+
|
|
938
|
+
type DialogVariant = 'modal' | 'drawer-start' | 'drawer-end' | 'drawer-bottom' | 'sheet';
|
|
939
|
+
/**
|
|
940
|
+
* `<usa-dialog>` — an animated modal or drawer built on the native
|
|
941
|
+
* `<dialog>` (top layer, focus trapping, inert page, Esc to close). Its
|
|
942
|
+
* children are slotted into the panel (they stay in the light DOM, so
|
|
943
|
+
* React / Vue / Svelte keep owning them). Style with `::part(panel)`,
|
|
944
|
+
* `::part(backdrop)` and the `--usa-dialog-*` custom properties.
|
|
945
|
+
*
|
|
946
|
+
* Attributes: `open` (reflects; set/remove to open/close), `kind`
|
|
947
|
+
* (`modal` default — Fluent scale + fade; `drawer-start` / `drawer-end`
|
|
948
|
+
* slide from the side, `drawer-bottom` / `sheet` from below), `label`
|
|
949
|
+
* (accessible name), `no-backdrop-close`, `no-esc`. Elements inside
|
|
950
|
+
* with `data-close` close it. Events: `usa:open`, `usa:close` (cancelable
|
|
951
|
+
* `usa:beforeclose`). Reduced motion: fade only.
|
|
952
|
+
*/
|
|
953
|
+
interface UsaDialogElement extends UsaElement {
|
|
954
|
+
open: boolean;
|
|
955
|
+
show(): Promise<void>;
|
|
956
|
+
close(returnValue?: string): Promise<void>;
|
|
957
|
+
readonly dialog: HTMLDialogElement | null;
|
|
958
|
+
returnValue: string;
|
|
959
|
+
}
|
|
960
|
+
declare function defineDialog(tag?: string): CustomElementConstructor | undefined;
|
|
961
|
+
|
|
962
|
+
/**
|
|
963
|
+
* `<usa-accordion>` — smooth expand / collapse for the native `<details>`
|
|
964
|
+
* elements inside it (keeps their semantics, keyboard support and
|
|
965
|
+
* find-in-page, and adds no wrapper elements, so framework-rendered content
|
|
966
|
+
* is left alone). Only one stays open unless `multiple` is set.
|
|
967
|
+
*
|
|
968
|
+
* Attributes: `multiple`, `duration` (ms, 300). Event: `usa:toggle`
|
|
969
|
+
* (`detail.details`, `detail.open`). Reduced motion: instant.
|
|
970
|
+
* Heights are measured once per toggle and animated on the `<details>`.
|
|
971
|
+
*/
|
|
972
|
+
interface UsaAccordionElement extends UsaElement {
|
|
973
|
+
readonly items: HTMLDetailsElement[];
|
|
974
|
+
toggleItem(details: HTMLDetailsElement, open?: boolean): Promise<void>;
|
|
975
|
+
}
|
|
976
|
+
declare function defineAccordion(tag?: string): CustomElementConstructor | undefined;
|
|
977
|
+
|
|
978
|
+
/**
|
|
979
|
+
* `<usa-view-switch>` — shows one of its children at a time (tabs, wizard
|
|
980
|
+
* steps, app pages) and animates between them. Children are views; name
|
|
981
|
+
* them with `data-view`, or address them by index.
|
|
982
|
+
*
|
|
983
|
+
* Attributes: `active` (view name or index, default the first),
|
|
984
|
+
* `effect` (`fade` | `slide` (default, direction-aware — Fluent "page
|
|
985
|
+
* transition") | `scale` | `drill`), `duration` (ms, 320). Inactive views
|
|
986
|
+
* get `hidden` + `inert`. Event: `usa:change` (`detail.view`,
|
|
987
|
+
* `detail.index`). Reduced motion: a quick fade.
|
|
988
|
+
*/
|
|
989
|
+
interface UsaViewSwitchElement extends UsaElement {
|
|
990
|
+
active: string;
|
|
991
|
+
readonly views: HTMLElement[];
|
|
992
|
+
show(view: string | number): Promise<void>;
|
|
993
|
+
}
|
|
994
|
+
declare function defineViewSwitch(tag?: string): CustomElementConstructor | undefined;
|
|
995
|
+
|
|
996
|
+
interface ViewTransitionOptions {
|
|
997
|
+
/**
|
|
998
|
+
* Element to cross-fade when the View Transitions API is missing (default:
|
|
999
|
+
* none — the update is applied without animation).
|
|
1000
|
+
*/
|
|
1001
|
+
fallback?: HTMLElement | null;
|
|
1002
|
+
/** Fallback fade duration in ms (default 180 out + 220 in). */
|
|
1003
|
+
duration?: number;
|
|
1004
|
+
/** View transition types (`document.startViewTransition({ types })`, where supported). */
|
|
1005
|
+
types?: string[];
|
|
1006
|
+
}
|
|
1007
|
+
/**
|
|
1008
|
+
* Run `update()` (which changes the DOM) inside a view transition:
|
|
1009
|
+
* `document.startViewTransition()` where available (Chrome/Edge 111+, so
|
|
1010
|
+
* Electron, WebView2 and Tauri on Windows), otherwise a short cross-fade of
|
|
1011
|
+
* `options.fallback`. Instant under reduced motion. Resolves when finished.
|
|
1012
|
+
*
|
|
1013
|
+
* Give elements a `view-transition-name` in CSS for shared-element morphs.
|
|
1014
|
+
*/
|
|
1015
|
+
declare function viewTransition(update: () => void | Promise<void>, options?: ViewTransitionOptions): Promise<void>;
|
|
1016
|
+
interface FlipOptions {
|
|
1017
|
+
duration?: number;
|
|
1018
|
+
easing?: string;
|
|
1019
|
+
/** Fade/scale in elements that did not exist before (default true). */
|
|
1020
|
+
animateEnter?: boolean;
|
|
1021
|
+
}
|
|
1022
|
+
type Targets = Element | Iterable<Element> | ArrayLike<Element>;
|
|
1023
|
+
/**
|
|
1024
|
+
* FLIP animation for layout changes (list reorder, filter, grid resize):
|
|
1025
|
+
* measures `targets` (an element's children, or a list), runs `mutate()`,
|
|
1026
|
+
* then animates each element from its old position to its new one with
|
|
1027
|
+
* transforms only. Elements added by `mutate()` fade in.
|
|
1028
|
+
*
|
|
1029
|
+
* ```js
|
|
1030
|
+
* await flip(list, () => list.append(...shuffled));
|
|
1031
|
+
* ```
|
|
1032
|
+
*/
|
|
1033
|
+
declare function flip(targets: Targets, mutate: () => void | Promise<void>, options?: FlipOptions): Promise<void>;
|
|
1034
|
+
|
|
1035
|
+
/**
|
|
1036
|
+
* motionary/components/transitions — view & layout transitions.
|
|
1037
|
+
* `<usa-dialog>`, `<usa-accordion>`, `<usa-view-switch>`
|
|
1038
|
+
* and the `viewTransition()` and `flip()` helpers (4.0: `<usa-flip-list>` → `<usa-auto-animate>`,
|
|
1039
|
+
* `connectedAnimation()` → `sharedTransition()`, both in `components/layout`).
|
|
1040
|
+
*/
|
|
1041
|
+
|
|
1042
|
+
/** Register every component of this category under its default tag. */
|
|
1043
|
+
declare function defineTransitionComponents(): void;
|
|
1044
|
+
declare global {
|
|
1045
|
+
interface HTMLElementTagNameMap {
|
|
1046
|
+
'usa-dialog': UsaDialogElement;
|
|
1047
|
+
'usa-accordion': UsaAccordionElement;
|
|
1048
|
+
'usa-view-switch': UsaViewSwitchElement;
|
|
1049
|
+
}
|
|
1050
|
+
}
|
|
1051
|
+
|
|
1052
|
+
declare const SPRING_EFFECTS: readonly ["bounce-in", "pop", "drop", "jelly", "rubber-band"];
|
|
1053
|
+
type SpringEffect = (typeof SPRING_EFFECTS)[number];
|
|
1054
|
+
/** Keyframes of a spring effect (entrances use spring timing, attention effects fixed frames). */
|
|
1055
|
+
declare function springEffectKeyframes(effect: string, reduced?: boolean): Keyframe[];
|
|
1056
|
+
/**
|
|
1057
|
+
* `<usa-spring>` — spring / bounce effects on its content.
|
|
1058
|
+
*
|
|
1059
|
+
* Attributes: `effect` (`bounce-in` default, `pop`, `drop`, `jelly`,
|
|
1060
|
+
* `rubber-band`), `trigger` (`view` default, `hover`, `click`, `manual`),
|
|
1061
|
+
* `preset` (`gentle`, `wobbly`, `stiff`, `bouncy`, …) or `stiffness` /
|
|
1062
|
+
* `damping` / `mass`, `delay` (ms), `duration` (ms, attention effects; 900),
|
|
1063
|
+
* `repeat` (replay every time it re-enters the view), `block`.
|
|
1064
|
+
* Events: `usa:complete`. Reduced motion: entrances fade, attention effects do nothing.
|
|
1065
|
+
*/
|
|
1066
|
+
interface UsaSpringElement extends UsaElement {
|
|
1067
|
+
effect: string;
|
|
1068
|
+
play(): Promise<void>;
|
|
1069
|
+
reset(): void;
|
|
1070
|
+
}
|
|
1071
|
+
declare function defineSpring(tag?: string): CustomElementConstructor | undefined;
|
|
1072
|
+
|
|
1073
|
+
/**
|
|
1074
|
+
* `<usa-draggable>` — drag its content with the pointer (mouse, touch, pen)
|
|
1075
|
+
* or the arrow keys; physics on release.
|
|
1076
|
+
*
|
|
1077
|
+
* Attributes: `axis` (`both` default, `x`, `y`), `spring-back` (return to
|
|
1078
|
+
* the origin with a spring), `inertia` (keep gliding after a flick),
|
|
1079
|
+
* `snap` (grid size like `80`, or points like `0,120,240`), `bounds`
|
|
1080
|
+
* (`parent` = stay inside the parent box, rubber-banding past its edges),
|
|
1081
|
+
* `preset` (spring, default `wobbly`), `step` (arrow-key step, px, 16),
|
|
1082
|
+
* `disabled`. Methods: `moveTo(x, y, animate?)`, `reset()`. Events:
|
|
1083
|
+
* `usa:drag-start`, `usa:drag-end` (`{ x, y, vx, vy }`), `usa:settle`.
|
|
1084
|
+
* Reduced motion: positions change instantly (no spring or inertia).
|
|
1085
|
+
*/
|
|
1086
|
+
interface UsaDraggableElement extends UsaElement {
|
|
1087
|
+
readonly x: number;
|
|
1088
|
+
readonly y: number;
|
|
1089
|
+
readonly dragging: boolean;
|
|
1090
|
+
moveTo(x: number, y: number, animate?: boolean): void;
|
|
1091
|
+
reset(): void;
|
|
1092
|
+
}
|
|
1093
|
+
declare function defineDraggable(tag?: string): CustomElementConstructor | undefined;
|
|
1094
|
+
|
|
1095
|
+
/**
|
|
1096
|
+
* `<usa-overscroll>` — an elastic scroll container: pulling past the top or
|
|
1097
|
+
* bottom (touch, trackpad or wheel) stretches the content with iOS-style
|
|
1098
|
+
* rubber-band resistance and it springs back on release.
|
|
1099
|
+
*
|
|
1100
|
+
* Attributes: `axis` (`y` default, `x`), `max` (largest stretch in px, 120),
|
|
1101
|
+
* `preset` (spring, default `default`), `disabled`. CSS variable
|
|
1102
|
+
* `--usa-overscroll` holds the current offset. Reduced motion: no stretch
|
|
1103
|
+
* (a plain scroll container with `overscroll-behavior: contain`).
|
|
1104
|
+
*/
|
|
1105
|
+
interface UsaOverscrollElement extends UsaElement {
|
|
1106
|
+
/** Current stretch in px (negative = pulled past the end). */
|
|
1107
|
+
readonly offset: number;
|
|
1108
|
+
}
|
|
1109
|
+
declare function defineOverscroll(tag?: string): CustomElementConstructor | undefined;
|
|
1110
|
+
|
|
1111
|
+
/**
|
|
1112
|
+
* Spring physics core (v2.3). A damped harmonic oscillator integrated in
|
|
1113
|
+
* 1 ms steps: `stiffness` (k, N/m), `damping` (c) and `mass` (m). Used by
|
|
1114
|
+
* the `<usa-spring>`, `<usa-draggable>` and `<usa-overscroll>` elements and
|
|
1115
|
+
* exported for your own animations:
|
|
1116
|
+
*
|
|
1117
|
+
* - `springEasing()` turns a spring into a CSS `linear()` easing + duration
|
|
1118
|
+
* for WAAPI / CSS (falls back to a cubic-bezier overshoot where `linear()`
|
|
1119
|
+
* is unsupported);
|
|
1120
|
+
* - `spring(el, keyframes, cfg)` animates with it;
|
|
1121
|
+
* - `createSpring()` is an interruptible, velocity-preserving value for
|
|
1122
|
+
* gestures (drag, inertia, snap).
|
|
1123
|
+
*/
|
|
1124
|
+
interface SpringConfig {
|
|
1125
|
+
/** Spring stiffness (default 170). Higher = faster, snappier. */
|
|
1126
|
+
stiffness?: number;
|
|
1127
|
+
/** Damping / friction (default 26). Lower = more bounces. */
|
|
1128
|
+
damping?: number;
|
|
1129
|
+
/** Mass (default 1). Higher = slower, heavier. */
|
|
1130
|
+
mass?: number;
|
|
1131
|
+
/** Initial velocity in progress units per second (default 0). */
|
|
1132
|
+
velocity?: number;
|
|
1133
|
+
/** Rest threshold (default 0.001). */
|
|
1134
|
+
precision?: number;
|
|
1135
|
+
}
|
|
1136
|
+
type SpringPreset = 'default' | 'gentle' | 'wobbly' | 'stiff' | 'bouncy' | 'slow' | 'molasses';
|
|
1137
|
+
declare const SPRING_PRESETS: Record<SpringPreset, Required<Pick<SpringConfig, 'stiffness' | 'damping' | 'mass'>>>;
|
|
1138
|
+
type SpringInput = SpringPreset | SpringConfig | string | undefined;
|
|
1139
|
+
/** Resolve a preset name or a partial config to a full config. */
|
|
1140
|
+
declare function resolveSpring(input?: SpringInput): Required<SpringConfig>;
|
|
1141
|
+
/** One integration step (semi-implicit Euler) towards `to`. Returns [x, v]. */
|
|
1142
|
+
declare function stepSpring(cfg: Required<SpringConfig>, x: number, v: number, to: number, dt: number): [number, number];
|
|
1143
|
+
/**
|
|
1144
|
+
* Sample the spring from 0 to 1 at `fps` (default 60). `values` may exceed 1
|
|
1145
|
+
* (overshoot); `duration` is the time to rest, in ms (max 10 s).
|
|
1146
|
+
*/
|
|
1147
|
+
declare function springSamples(input?: SpringInput, fps?: number): {
|
|
1148
|
+
values: number[];
|
|
1149
|
+
duration: number;
|
|
1150
|
+
};
|
|
1151
|
+
/** `true` when CSS `linear()` easing is supported. */
|
|
1152
|
+
declare function supportsLinearEasing(): boolean;
|
|
1153
|
+
/**
|
|
1154
|
+
* The spring as `{ easing, duration }` for `el.animate()` / CSS. `easing` is
|
|
1155
|
+
* a `linear(…)` function with at most `points` stops (default 48), or a
|
|
1156
|
+
* cubic-bezier overshoot where `linear()` is unsupported.
|
|
1157
|
+
*/
|
|
1158
|
+
declare function springEasing(input?: SpringInput, points?: number): {
|
|
1159
|
+
easing: string;
|
|
1160
|
+
duration: number;
|
|
1161
|
+
};
|
|
1162
|
+
/** Build a CSS `linear()` easing from samples (down-sampled to `points`). */
|
|
1163
|
+
declare function linearEasing(values: number[], points?: number): string;
|
|
1164
|
+
/**
|
|
1165
|
+
* Animate `el` between keyframes with spring timing (WAAPI). Under reduced
|
|
1166
|
+
* motion the final frame is applied immediately. Returns the Animation (or
|
|
1167
|
+
* `null` without WAAPI / under reduced motion).
|
|
1168
|
+
*/
|
|
1169
|
+
declare function spring(el: Element, keyframes: Keyframe[], input?: SpringInput, options?: KeyframeAnimationOptions): Animation | null;
|
|
1170
|
+
interface SpringValueOptions {
|
|
1171
|
+
/** Start value (default 0). */
|
|
1172
|
+
value?: number;
|
|
1173
|
+
/** Spring config or preset (default `'default'`). */
|
|
1174
|
+
spring?: SpringInput;
|
|
1175
|
+
/** Called with the value every frame (and on `jump()`). */
|
|
1176
|
+
onUpdate?: (value: number, velocity: number) => void;
|
|
1177
|
+
/** Called when the value comes to rest at its target. */
|
|
1178
|
+
onRest?: (value: number) => void;
|
|
1179
|
+
}
|
|
1180
|
+
interface SpringValue {
|
|
1181
|
+
readonly value: number;
|
|
1182
|
+
/** Units per second. */
|
|
1183
|
+
readonly velocity: number;
|
|
1184
|
+
readonly target: number;
|
|
1185
|
+
readonly animating: boolean;
|
|
1186
|
+
/** Animate to `target`, optionally with a new initial velocity (units/s). */
|
|
1187
|
+
set(target: number, velocity?: number): void;
|
|
1188
|
+
/** Jump to `value` with no animation. */
|
|
1189
|
+
jump(value: number): void;
|
|
1190
|
+
/** Stop where it is. */
|
|
1191
|
+
stop(): void;
|
|
1192
|
+
/** Change the spring config. */
|
|
1193
|
+
configure(spring: SpringInput): void;
|
|
1194
|
+
}
|
|
1195
|
+
/**
|
|
1196
|
+
* An interruptible spring-animated number: call `set()` as often as you like,
|
|
1197
|
+
* the motion keeps its velocity (like iOS / Framer springs). Reduced motion
|
|
1198
|
+
* jumps straight to the target.
|
|
1199
|
+
*/
|
|
1200
|
+
declare function createSpring(opts?: SpringValueOptions): SpringValue;
|
|
1201
|
+
/**
|
|
1202
|
+
* Where a flick at `velocity` (units/s) comes to rest with exponential
|
|
1203
|
+
* decay: `value + velocity · timeConstant` (default 0.325 s, iOS-like).
|
|
1204
|
+
*/
|
|
1205
|
+
declare function projectInertia(value: number, velocity: number, timeConstant?: number): number;
|
|
1206
|
+
/** Snap to a grid (`number`) or the nearest of a list of points. */
|
|
1207
|
+
declare function snapTo(value: number, to: number | number[] | null | undefined): number;
|
|
1208
|
+
/** iOS-style rubber-band resistance: how far content moves when pulled `distance` past an edge. */
|
|
1209
|
+
declare function rubberBand(distance: number, dimension: number, constant?: number): number;
|
|
1210
|
+
|
|
1211
|
+
/**
|
|
1212
|
+
* motionary/components/physics — spring & bounce physics (v2.3).
|
|
1213
|
+
* `<usa-spring>` (bounce-in, pop, drop, jelly, rubber-band), `<usa-draggable>`
|
|
1214
|
+
* (spring-back, inertia, snap) and `<usa-overscroll>` (elastic edges), plus
|
|
1215
|
+
* the spring core: `spring()`, `springEasing()`, `createSpring()`,
|
|
1216
|
+
* `SPRING_PRESETS`, `projectInertia()`, `snapTo()`, `rubberBand()`.
|
|
1217
|
+
*/
|
|
1218
|
+
|
|
1219
|
+
/** Register every component of this category under its default tag. */
|
|
1220
|
+
declare function definePhysicsComponents(): void;
|
|
1221
|
+
declare global {
|
|
1222
|
+
interface HTMLElementTagNameMap {
|
|
1223
|
+
'usa-spring': UsaSpringElement;
|
|
1224
|
+
'usa-draggable': UsaDraggableElement;
|
|
1225
|
+
'usa-overscroll': UsaOverscrollElement;
|
|
1226
|
+
}
|
|
1227
|
+
}
|
|
1228
|
+
|
|
1229
|
+
declare const CARD_EFFECTS: readonly ["flip", "holo", "glass", "border-glow", "conic-border", "lift", "spotlight", "sheen", "parallax-layers", "expand"];
|
|
1230
|
+
type CardEffect = (typeof CARD_EFFECTS)[number];
|
|
1231
|
+
/**
|
|
1232
|
+
* `<usa-card>` — card effects, combinable: `effect="lift sheen"`.
|
|
1233
|
+
*
|
|
1234
|
+
* - `flip` — front/back (`[data-front]` / `[data-back]` children) flip on
|
|
1235
|
+
* hover or `trigger="click"`, `axis="y"` (default, horizontal flip) or `x`.
|
|
1236
|
+
* - `holo` — holographic foil that shifts with the pointer.
|
|
1237
|
+
* - `glass` — frosted glass surface (backdrop blur).
|
|
1238
|
+
* - `border-glow` — a glow on the border that follows the pointer.
|
|
1239
|
+
* - `conic-border` — a rotating conic-gradient border.
|
|
1240
|
+
* - `lift` — rises with a deeper shadow and a slight pointer tilt.
|
|
1241
|
+
* - `spotlight` — a soft light that follows the pointer.
|
|
1242
|
+
* - `sheen` — a light sweep across the card on hover / focus.
|
|
1243
|
+
* - `parallax-layers` — children with `data-depth="0.2…1"` move at different depths.
|
|
1244
|
+
* - `expand` — click to grow into a full detail view (`[data-detail]`
|
|
1245
|
+
* content is shown), FLIP + spring; Esc, `[data-close]` or the backdrop closes.
|
|
1246
|
+
*
|
|
1247
|
+
* Attributes: `effect`, `axis`, `trigger`, `depth` (parallax px, 16),
|
|
1248
|
+
* `color` (glow / spotlight colour), `flipped`, `expanded`, `disabled`.
|
|
1249
|
+
* CSS variables: `--usa-card-x/-y` (pointer %, 0–100), `--usa-card-nx/-ny` (−1…1).
|
|
1250
|
+
* Methods: `flip(force?)`, `expand()`, `collapse()`. Events: `usa:flip`,
|
|
1251
|
+
* `usa:expand`, `usa:collapse`. Reduced motion: no tilt / parallax / sweep;
|
|
1252
|
+
* flips and expansions cross-fade.
|
|
1253
|
+
*/
|
|
1254
|
+
interface UsaCardElement extends UsaElement {
|
|
1255
|
+
readonly effects: string[];
|
|
1256
|
+
flipped: boolean;
|
|
1257
|
+
readonly expanded: boolean;
|
|
1258
|
+
flip(force?: boolean): void;
|
|
1259
|
+
expand(): Promise<void>;
|
|
1260
|
+
collapse(): Promise<void>;
|
|
1261
|
+
}
|
|
1262
|
+
declare function defineCard(tag?: string): CustomElementConstructor | undefined;
|
|
1263
|
+
|
|
1264
|
+
/**
|
|
1265
|
+
* `<usa-card-stack>` — a deck of cards (its element children). The top card
|
|
1266
|
+
* can be swiped away left or right (pointer, touch or arrow keys); the rest
|
|
1267
|
+
* fan out behind it and move up with a spring.
|
|
1268
|
+
*
|
|
1269
|
+
* Attributes: `threshold` (px to dismiss, 90), `visible` (cards fanned
|
|
1270
|
+
* behind, 3), `offset` (px between cards, 10), `loop` (swiped cards go back
|
|
1271
|
+
* to the bottom), `disabled`. Methods: `swipe(direction)`, `top`. Events:
|
|
1272
|
+
* `usa:swipe` (`{ direction: 'left' | 'right', card }`), `usa:empty`.
|
|
1273
|
+
* Reduced motion: cards are removed instantly, no rotation.
|
|
1274
|
+
*/
|
|
1275
|
+
interface UsaCardStackElement extends UsaElement {
|
|
1276
|
+
readonly top: HTMLElement | null;
|
|
1277
|
+
swipe(direction: 'left' | 'right'): Promise<void>;
|
|
1278
|
+
}
|
|
1279
|
+
declare function defineCardStack(tag?: string): CustomElementConstructor | undefined;
|
|
1280
|
+
|
|
1281
|
+
/**
|
|
1282
|
+
* `<usa-sticky-stack>` — cards (element children) stick to the top while
|
|
1283
|
+
* scrolling and the ones underneath scale down and dim as the next card
|
|
1284
|
+
* slides over them, like a deck building up.
|
|
1285
|
+
*
|
|
1286
|
+
* Attributes: `top` (px from the viewport top, 80), `gap` (px each card
|
|
1287
|
+
* peeks below the previous, 16), `scale` (how much a covered card shrinks,
|
|
1288
|
+
* 0.06). Reduced motion: cards still stack (sticky) but do not scale.
|
|
1289
|
+
*/
|
|
1290
|
+
interface UsaStickyStackElement extends UsaElement {
|
|
1291
|
+
update(): void;
|
|
1292
|
+
}
|
|
1293
|
+
declare function defineStickyStack(tag?: string): CustomElementConstructor | undefined;
|
|
1294
|
+
|
|
1295
|
+
/**
|
|
1296
|
+
* `<usa-carousel-3d>` — its element children on a 3D ring. Rotate with the
|
|
1297
|
+
* arrow keys, a drag/swipe, the wheel (shift) or `next()` / `prev()`; the
|
|
1298
|
+
* front item is `aria-current`. Spring-driven rotation.
|
|
1299
|
+
*
|
|
1300
|
+
* Attributes: `radius` (px, auto from item width), `autoplay` (ms between
|
|
1301
|
+
* steps, pauses on hover/focus), `perspective` (px, 1200), `index`.
|
|
1302
|
+
* Events: `usa:change` (`{ index }`). Reduced motion: a flat, instant
|
|
1303
|
+
* switch (only the current item is shown, others dimmed).
|
|
1304
|
+
*/
|
|
1305
|
+
interface UsaCarousel3dElement extends UsaElement {
|
|
1306
|
+
index: number;
|
|
1307
|
+
next(): void;
|
|
1308
|
+
prev(): void;
|
|
1309
|
+
goTo(i: number): void;
|
|
1310
|
+
}
|
|
1311
|
+
declare function defineCarousel3d(tag?: string): CustomElementConstructor | undefined;
|
|
1312
|
+
|
|
1313
|
+
/**
|
|
1314
|
+
* motionary/components/cards — card effects (v2.4).
|
|
1315
|
+
* `<usa-card effect="flip | holo | glass | border-glow | conic-border | lift |
|
|
1316
|
+
* spotlight | sheen | parallax-layers | expand">` (combinable),
|
|
1317
|
+
* `<usa-card-stack>` (swipeable deck), `<usa-sticky-stack>` (stacking on
|
|
1318
|
+
* scroll) and `<usa-carousel-3d>`.
|
|
1319
|
+
*/
|
|
1320
|
+
|
|
1321
|
+
/** Register every component of this category under its default tag. */
|
|
1322
|
+
declare function defineCardComponents(): void;
|
|
1323
|
+
declare global {
|
|
1324
|
+
interface HTMLElementTagNameMap {
|
|
1325
|
+
'usa-card': UsaCardElement;
|
|
1326
|
+
'usa-card-stack': UsaCardStackElement;
|
|
1327
|
+
'usa-sticky-stack': UsaStickyStackElement;
|
|
1328
|
+
'usa-carousel-3d': UsaCarousel3dElement;
|
|
1329
|
+
}
|
|
1330
|
+
}
|
|
1331
|
+
|
|
1332
|
+
declare const CLICK_EFFECTS: readonly ["ripple", "burst", "confetti", "squish", "press-spring", "shake"];
|
|
1333
|
+
type ClickEffect = (typeof CLICK_EFFECTS)[number];
|
|
1334
|
+
/**
|
|
1335
|
+
* `<usa-click>` — click / tap effects on whatever it wraps (combinable:
|
|
1336
|
+
* `effect="press-spring burst"`).
|
|
1337
|
+
*
|
|
1338
|
+
* - `ripple` — an ink wave from the pointer (enhanced: `color`, soft edge);
|
|
1339
|
+
* - `burst` — particles radiating from the pointer (`shape`: circle, square, star, heart, emoji);
|
|
1340
|
+
* - `confetti` — a confetti cannon from the click point;
|
|
1341
|
+
* - `squish` — squash on press, stretch on release (spring);
|
|
1342
|
+
* - `press-spring` — dips while pressed, springs back with overshoot;
|
|
1343
|
+
* - `shake` — horizontal error shake; plays on `invalid` events from a form
|
|
1344
|
+
* inside, on `shake()`, or on click when `trigger="click"`.
|
|
1345
|
+
*
|
|
1346
|
+
* Attributes: `effect`, `color`, `shape`, `count`, `haptic` (vibrate ms,
|
|
1347
|
+
* where supported), `disabled`. Keyboard (Space/Enter) triggers the effects
|
|
1348
|
+
* from the centre. Reduced motion: no particles or movement; press dims.
|
|
1349
|
+
*/
|
|
1350
|
+
interface UsaClickElement extends UsaElement {
|
|
1351
|
+
readonly effects: string[];
|
|
1352
|
+
play(x?: number, y?: number): void;
|
|
1353
|
+
shake(): void;
|
|
1354
|
+
}
|
|
1355
|
+
declare function defineClick(tag?: string): CustomElementConstructor | undefined;
|
|
1356
|
+
|
|
1357
|
+
declare const BUTTON_DEFORMS: readonly ["squash", "wobble", "gooey", "dent"];
|
|
1358
|
+
type ButtonDeform = (typeof BUTTON_DEFORMS)[number];
|
|
1359
|
+
type ButtonShape = 'pill' | 'circle' | 'icon';
|
|
1360
|
+
type ButtonState = 'idle' | 'loading' | 'success' | 'error';
|
|
1361
|
+
/**
|
|
1362
|
+
* `<usa-button>` — **button click deformation** (按钮点击形变) around a
|
|
1363
|
+
* native `<button>` (or `<a>`) child — or the element itself becomes a button.
|
|
1364
|
+
*
|
|
1365
|
+
* `deform` (combinable, e.g. `deform="squash wobble"`):
|
|
1366
|
+
* - `squash` — squash on press, stretch-and-settle on release (spring);
|
|
1367
|
+
* - `wobble` — elastic border-radius wobble after a click;
|
|
1368
|
+
* - `gooey` — liquid blob: droplets squeeze out from the press point and
|
|
1369
|
+
* merge back (SVG goo filter);
|
|
1370
|
+
* - `dent` — the surface dents toward the pressed point (3D tilt + inner shade).
|
|
1371
|
+
*
|
|
1372
|
+
* `shape="pill | circle | icon"` morphs the outline with a spring (label =
|
|
1373
|
+
* `[data-label]`, icon = `[data-icon]` children); `morphTo(shape)`.
|
|
1374
|
+
*
|
|
1375
|
+
* `morph="submit"` — click → `loading` (shrinks to a circle with a spinner,
|
|
1376
|
+
* `aria-busy`), then `success` (check) or `error` (shake + cross), and back
|
|
1377
|
+
* to `idle` after `reset` ms (1800). Drive it with `state="…"` / `.state`, or
|
|
1378
|
+
* call `event.detail.done(ok)` from a `usa:submit` listener.
|
|
1379
|
+
*
|
|
1380
|
+
* Attributes: `deform`, `shape`, `morph`, `state`, `reset`, `haptic`,
|
|
1381
|
+
* `disabled`. Events: `usa:submit`, `usa:state`. Reduced motion: no
|
|
1382
|
+
* deformation; shape and state changes are instant; status still announced.
|
|
1383
|
+
*/
|
|
1384
|
+
interface UsaButtonElement extends UsaElement {
|
|
1385
|
+
readonly target: HTMLElement;
|
|
1386
|
+
shape: ButtonShape;
|
|
1387
|
+
state: ButtonState;
|
|
1388
|
+
morphTo(shape: ButtonShape): Promise<void>;
|
|
1389
|
+
}
|
|
1390
|
+
declare function defineButton(tag?: string): CustomElementConstructor | undefined;
|
|
1391
|
+
|
|
1392
|
+
type Pt = [number, number];
|
|
1393
|
+
type Quad = [Pt, Pt, Pt, Pt];
|
|
1394
|
+
/**
|
|
1395
|
+
* Morphable icons: every icon is three quads (four points each) on a 24×24
|
|
1396
|
+
* grid, so any icon can morph into any other by interpolating points.
|
|
1397
|
+
*/
|
|
1398
|
+
declare const MORPH_ICONS: Record<string, [Quad, Quad, Quad]>;
|
|
1399
|
+
/** SVG path data for an icon, or for the interpolation `t` (0–1) between two. */
|
|
1400
|
+
declare function morphPath(from: string, to?: string, t?: number): string;
|
|
1401
|
+
/**
|
|
1402
|
+
* `<usa-icon-morph>` — an icon that morphs between shapes with a spring:
|
|
1403
|
+
* play ↔ pause, menu ↔ close, plus ↔ minus, check, arrow-right…
|
|
1404
|
+
*
|
|
1405
|
+
* Attributes: `icons` (comma list, cycled; default `play,pause`), `index`
|
|
1406
|
+
* (current, 0), `size` (px, 24), `toggle` (makes it a button that cycles
|
|
1407
|
+
* on click / Enter / Space), `labels` (comma list of accessible names per
|
|
1408
|
+
* icon, e.g. `Play,Pause`), `preset` (spring, `wobbly`). Methods:
|
|
1409
|
+
* `next()`, `show(nameOrIndex)`. Events: `usa:change` (`{ index, icon }`).
|
|
1410
|
+
* Inside a `<usa-button>` or `<button>` it is decorative. Reduced motion:
|
|
1411
|
+
* the icon switches instantly.
|
|
1412
|
+
*/
|
|
1413
|
+
interface UsaIconMorphElement extends UsaElement {
|
|
1414
|
+
index: number;
|
|
1415
|
+
readonly icon: string;
|
|
1416
|
+
next(): void;
|
|
1417
|
+
show(icon: string | number): void;
|
|
1418
|
+
}
|
|
1419
|
+
declare function defineIconMorph(tag?: string): CustomElementConstructor | undefined;
|
|
1420
|
+
|
|
1421
|
+
/**
|
|
1422
|
+
* `<usa-like>` — a like / favourite toggle: the heart pops with a spring and
|
|
1423
|
+
* bursts into particles when liked. `role="button"` + `aria-pressed`.
|
|
1424
|
+
*
|
|
1425
|
+
* Attributes: `liked`, `count` (shown next to the heart, updated ±1),
|
|
1426
|
+
* `label` (accessible name, default "Like"), `color`, `size` (px, 24),
|
|
1427
|
+
* `haptic`, `disabled`. Events: `change`, `usa:change` (`{ liked, count }`).
|
|
1428
|
+
* Reduced motion: colour change only.
|
|
1429
|
+
*/
|
|
1430
|
+
interface UsaLikeElement extends UsaElement {
|
|
1431
|
+
liked: boolean;
|
|
1432
|
+
count: number | null;
|
|
1433
|
+
toggle(force?: boolean): void;
|
|
1434
|
+
}
|
|
1435
|
+
declare function defineLike(tag?: string): CustomElementConstructor | undefined;
|
|
1436
|
+
|
|
1437
|
+
/**
|
|
1438
|
+
* `<usa-hold>` — hold-to-confirm: press and hold (pointer, Space or Enter)
|
|
1439
|
+
* while a progress ring fills; releasing early rewinds it. Good for
|
|
1440
|
+
* destructive actions.
|
|
1441
|
+
*
|
|
1442
|
+
* Attributes: `duration` (ms, 1200), `label` (accessible name), `color`,
|
|
1443
|
+
* `disabled`. CSS variable `--usa-hold` (0–1). Events: `usa:progress`,
|
|
1444
|
+
* `usa:confirm`, `usa:cancel`. Reduced motion: same timing, the ring fills
|
|
1445
|
+
* without the scale pulse.
|
|
1446
|
+
*/
|
|
1447
|
+
interface UsaHoldElement extends UsaElement {
|
|
1448
|
+
readonly progress: number;
|
|
1449
|
+
cancel(): void;
|
|
1450
|
+
}
|
|
1451
|
+
declare function defineHold(tag?: string): CustomElementConstructor | undefined;
|
|
1452
|
+
|
|
1453
|
+
/**
|
|
1454
|
+
* `<usa-double-tap>` — detects a double tap / double click on its content
|
|
1455
|
+
* (photos, posts) and pops a heart (or `icon`) at the tap point.
|
|
1456
|
+
*
|
|
1457
|
+
* Attributes: `icon` (text / emoji, default ♥), `color`, `delay` (max ms
|
|
1458
|
+
* between taps, 300), `haptic`, `disabled`. Events: `usa:double-tap`
|
|
1459
|
+
* (`{ x, y }`, element-relative). Keyboard users: press `L` while focused.
|
|
1460
|
+
* Reduced motion: the icon fades in and out without scaling or particles.
|
|
1461
|
+
*/
|
|
1462
|
+
interface UsaDoubleTapElement extends UsaElement {
|
|
1463
|
+
pop(x?: number, y?: number): void;
|
|
1464
|
+
}
|
|
1465
|
+
declare function defineDoubleTap(tag?: string): CustomElementConstructor | undefined;
|
|
1466
|
+
|
|
1467
|
+
/**
|
|
1468
|
+
* `<usa-checkbox>` — an animated, form-associated checkbox: the box springs
|
|
1469
|
+
* and the check mark draws itself. `role="checkbox"` + `aria-checked`
|
|
1470
|
+
* (`mixed` with `indeterminate`).
|
|
1471
|
+
*
|
|
1472
|
+
* Attributes: `checked`, `indeterminate`, `disabled`, `name`, `value`
|
|
1473
|
+
* (`on`), `label`, `shape` (`square` default, `circle`). Events: `change`,
|
|
1474
|
+
* `usa:change` (`{ checked }`). Reduced motion: no spring or drawing.
|
|
1475
|
+
*/
|
|
1476
|
+
interface UsaCheckboxElement extends UsaElement {
|
|
1477
|
+
checked: boolean;
|
|
1478
|
+
indeterminate: boolean;
|
|
1479
|
+
toggle(force?: boolean): void;
|
|
1480
|
+
}
|
|
1481
|
+
declare function defineCheckbox(tag?: string): CustomElementConstructor | undefined;
|
|
1482
|
+
|
|
1483
|
+
interface BurstOptions {
|
|
1484
|
+
/** Number of particles (default 12). */
|
|
1485
|
+
count?: number;
|
|
1486
|
+
/** Colours to pick from (default: accent palette). */
|
|
1487
|
+
colors?: string[];
|
|
1488
|
+
/** Travel distance in px (default 48). */
|
|
1489
|
+
distance?: number;
|
|
1490
|
+
/** Particle size in px (default 6). */
|
|
1491
|
+
size?: number;
|
|
1492
|
+
/** `circle` (default), `square`, `star`, `heart` or any text / emoji. */
|
|
1493
|
+
shape?: 'circle' | 'square' | 'star' | 'heart' | string;
|
|
1494
|
+
/** Duration in ms (default 600). */
|
|
1495
|
+
duration?: number;
|
|
1496
|
+
}
|
|
1497
|
+
interface ConfettiOptions {
|
|
1498
|
+
/** Origin in client px (default: centre-bottom third of the viewport). */
|
|
1499
|
+
x?: number;
|
|
1500
|
+
y?: number;
|
|
1501
|
+
/** Pieces (default 80). */
|
|
1502
|
+
count?: number;
|
|
1503
|
+
/** Spread angle in degrees (default 70). */
|
|
1504
|
+
spread?: number;
|
|
1505
|
+
/** Launch speed multiplier (default 1). */
|
|
1506
|
+
velocity?: number;
|
|
1507
|
+
colors?: string[];
|
|
1508
|
+
/** Duration in ms (default 1600). */
|
|
1509
|
+
duration?: number;
|
|
1510
|
+
}
|
|
1511
|
+
/** `navigator.vibrate()` where supported (Android Chrome, some WebViews). Returns whether it ran. */
|
|
1512
|
+
declare function haptic(pattern?: number | number[]): boolean;
|
|
1513
|
+
|
|
1514
|
+
/**
|
|
1515
|
+
* motionary/components/click — click & tap effects (v2.5).
|
|
1516
|
+
* `<usa-click>` (ripple, burst, confetti, squish, press-spring, shake),
|
|
1517
|
+
* `<usa-button>` (button click deformation: squash, wobble, gooey, dent;
|
|
1518
|
+
* shape morph; submit → loading → success), `<usa-icon-morph>`,
|
|
1519
|
+
* `<usa-like>`, `<usa-hold>`, `<usa-double-tap>`, `<usa-checkbox>`, plus
|
|
1520
|
+
* `haptic()`. 6.0: `burst()`, `confetti()` and `shake()` were removed — play
|
|
1521
|
+
* the registered effects instead: `playEffect(el, 'burst' | 'confetti' | 'shake')`.
|
|
1522
|
+
*/
|
|
1523
|
+
|
|
1524
|
+
/** Register every component of this category under its default tag. */
|
|
1525
|
+
declare function defineClickComponents(): void;
|
|
1526
|
+
declare global {
|
|
1527
|
+
interface HTMLElementTagNameMap {
|
|
1528
|
+
'usa-click': UsaClickElement;
|
|
1529
|
+
'usa-button': UsaButtonElement;
|
|
1530
|
+
'usa-icon-morph': UsaIconMorphElement;
|
|
1531
|
+
'usa-like': UsaLikeElement;
|
|
1532
|
+
'usa-hold': UsaHoldElement;
|
|
1533
|
+
'usa-double-tap': UsaDoubleTapElement;
|
|
1534
|
+
'usa-checkbox': UsaCheckboxElement;
|
|
1535
|
+
}
|
|
1536
|
+
}
|
|
1537
|
+
|
|
1538
|
+
/**
|
|
1539
|
+
* `<usa-tabs>` — accessible tabs with a sliding (spring) indicator.
|
|
1540
|
+
* Tabs: `[data-tab]` children (buttons); panels: `[data-panel]` children, in
|
|
1541
|
+
* the same order. Arrow keys / Home / End move between tabs (roving tabindex).
|
|
1542
|
+
*
|
|
1543
|
+
* Attributes: `selected` (index, 0), `indicator` (`line` default, `pill`),
|
|
1544
|
+
* `variant`. Events: `usa:change` (`{ index }`). Panels fade/slide in;
|
|
1545
|
+
* reduced motion: the indicator jumps and panels switch instantly.
|
|
1546
|
+
*/
|
|
1547
|
+
interface UsaTabsElement extends UsaElement {
|
|
1548
|
+
selected: number;
|
|
1549
|
+
select(i: number, focus?: boolean): void;
|
|
1550
|
+
}
|
|
1551
|
+
declare function defineTabs(tag?: string): CustomElementConstructor | undefined;
|
|
1552
|
+
|
|
1553
|
+
/**
|
|
1554
|
+
* `<usa-drawer>` — a side panel that slides in with a spring and can be
|
|
1555
|
+
* dragged / swiped closed. Modal: backdrop, Esc, focus returns on close.
|
|
1556
|
+
* Attributes: `open`, `side` (`left` default, `right`, `top`, `bottom`),
|
|
1557
|
+
* `label`, `variant`. Events: `usa:open`, `usa:close`. `[data-close]` closes.
|
|
1558
|
+
* Reduced motion: opens and closes instantly.
|
|
1559
|
+
*/
|
|
1560
|
+
interface UsaDrawerElement extends UsaElement {
|
|
1561
|
+
open: boolean;
|
|
1562
|
+
show(): void;
|
|
1563
|
+
close(): void;
|
|
1564
|
+
}
|
|
1565
|
+
/**
|
|
1566
|
+
* `<usa-bottom-sheet>` — a draggable bottom sheet with snap points
|
|
1567
|
+
* (`snap="0.3,0.6,0.92"`, fractions of the viewport height; default
|
|
1568
|
+
* `0.5,0.92`; `start` = index of the snap it opens at, default 0), inertia and drag-down-to-dismiss. `[data-handle]` (or the
|
|
1569
|
+
* built-in grabber) drags it. Attributes: `open`, `snap`, `start` (initial
|
|
1570
|
+
* snap index), `label`, `variant`. Events: `usa:open`, `usa:close`, `usa:snap`.
|
|
1571
|
+
*/
|
|
1572
|
+
interface UsaBottomSheetElement extends UsaDrawerElement {
|
|
1573
|
+
}
|
|
1574
|
+
declare function defineDrawer(tag?: string): CustomElementConstructor | undefined;
|
|
1575
|
+
declare function defineBottomSheet(tag?: string): CustomElementConstructor | undefined;
|
|
1576
|
+
|
|
1577
|
+
/**
|
|
1578
|
+
* `<usa-pull-refresh>` — pull-to-refresh for a scroll container (itself):
|
|
1579
|
+
* pull down at the top (touch / pointer) and a spinner stretches in; past
|
|
1580
|
+
* `threshold` (px, 70) releasing fires `usa:refresh` — call
|
|
1581
|
+
* `event.detail.done()` (or return a promise to `onrefresh`) to finish.
|
|
1582
|
+
* Also exposes `refresh()` for a keyboard / button path.
|
|
1583
|
+
* Attributes: `threshold`, `disabled`, `label` (status text, "Refreshing").
|
|
1584
|
+
* Reduced motion: no stretch; the spinner simply appears while refreshing.
|
|
1585
|
+
*/
|
|
1586
|
+
interface UsaPullRefreshElement extends UsaElement {
|
|
1587
|
+
readonly refreshing: boolean;
|
|
1588
|
+
refresh(): Promise<void>;
|
|
1589
|
+
}
|
|
1590
|
+
declare function definePullRefresh(tag?: string): CustomElementConstructor | undefined;
|
|
1591
|
+
|
|
1592
|
+
/**
|
|
1593
|
+
* `<usa-fab>` — floating action button with a speed dial. The first element
|
|
1594
|
+
* child is the main button; the others are actions that fan out with a
|
|
1595
|
+
* staggered spring when it opens (`direction="up"` default, `down`, `left`,
|
|
1596
|
+
* `right`, `radial`). Esc / outside click closes; `aria-expanded` on the
|
|
1597
|
+
* main button; actions are hidden from AT while closed.
|
|
1598
|
+
* Attributes: `open`, `direction`, `position` (`bottom-right` default, `bottom-left`,
|
|
1599
|
+
* `inline`), `gap` (px, 56), `variant`. Events: `usa:toggle` (`{ open }`).
|
|
1600
|
+
* Reduced motion: actions appear without travel.
|
|
1601
|
+
*/
|
|
1602
|
+
interface UsaFabElement extends UsaElement {
|
|
1603
|
+
open: boolean;
|
|
1604
|
+
toggle(force?: boolean): void;
|
|
1605
|
+
}
|
|
1606
|
+
declare function defineFab(tag?: string): CustomElementConstructor | undefined;
|
|
1607
|
+
|
|
1608
|
+
/**
|
|
1609
|
+
* `<usa-navbar>` — an app bar that hides while you scroll down and returns
|
|
1610
|
+
* as soon as you scroll up (or reach the top); `shrink` makes it compact
|
|
1611
|
+
* once scrolled. Focus inside always reveals it.
|
|
1612
|
+
* Attributes: `threshold` (px of scroll before hiding, 64), `shrink`,
|
|
1613
|
+
* `target` (selector of a scroll container instead of the page), `variant`.
|
|
1614
|
+
* State attributes: `data-hidden`, `data-scrolled`. Events: `usa:hide`, `usa:show`.
|
|
1615
|
+
* Reduced motion: hides/shows without sliding (instant).
|
|
1616
|
+
*/
|
|
1617
|
+
interface UsaNavbarElement extends UsaElement {
|
|
1618
|
+
readonly hiddenByScroll: boolean;
|
|
1619
|
+
show(): void;
|
|
1620
|
+
}
|
|
1621
|
+
declare function defineNavbar(tag?: string): CustomElementConstructor | undefined;
|
|
1622
|
+
|
|
1623
|
+
/**
|
|
1624
|
+
* `<usa-slider>` — a form-associated range slider (`role="slider"`). The
|
|
1625
|
+
* thumb follows with a spring, grows while dragged and shows a value bubble.
|
|
1626
|
+
* Keyboard: arrows (step), PageUp/PageDown (10 steps), Home/End.
|
|
1627
|
+
* Attributes: `value`, `min` (0), `max` (100), `step` (1), `name`, `label`,
|
|
1628
|
+
* `bubble` (show the value while dragging), `disabled`, `variant`.
|
|
1629
|
+
* Events: `input` + `usa:input` while moving, `change` + `usa:change` on release.
|
|
1630
|
+
* Reduced motion: the thumb jumps (no spring).
|
|
1631
|
+
*/
|
|
1632
|
+
interface UsaSliderElement extends UsaElement {
|
|
1633
|
+
value: number;
|
|
1634
|
+
}
|
|
1635
|
+
declare function defineSlider(tag?: string): CustomElementConstructor | undefined;
|
|
1636
|
+
|
|
1637
|
+
/**
|
|
1638
|
+
* `<usa-rating>` — star rating with hover preview and a springy pop when a
|
|
1639
|
+
* value is chosen. `role="slider"` (arrow keys, Home/End, number keys).
|
|
1640
|
+
* Attributes: `value` (0), `max` (5), `icon` (★), `readonly`, `label`
|
|
1641
|
+
* ("Rating"), `name` (form value), `variant`. Events: `change`, `usa:change` (`{ value }`).
|
|
1642
|
+
* Reduced motion: no pop.
|
|
1643
|
+
*/
|
|
1644
|
+
interface UsaRatingElement extends UsaElement {
|
|
1645
|
+
value: number;
|
|
1646
|
+
}
|
|
1647
|
+
declare function defineRating(tag?: string): CustomElementConstructor | undefined;
|
|
1648
|
+
|
|
1649
|
+
/**
|
|
1650
|
+
* `<usa-tooltip text="…">` — a tooltip for the element it wraps, shown on
|
|
1651
|
+
* hover (after `delay` ms, 300) and on keyboard focus, hidden on Esc / blur.
|
|
1652
|
+
* It springs in from its placement side and flips to stay on screen; the
|
|
1653
|
+
* trigger gets `aria-describedby`.
|
|
1654
|
+
* Attributes: `text`, `placement` (`top` default, `bottom`, `left`, `right`),
|
|
1655
|
+
* `delay`, `variant`. Reduced motion: fades only.
|
|
1656
|
+
*/
|
|
1657
|
+
interface UsaTooltipElement extends UsaElement {
|
|
1658
|
+
show(): void;
|
|
1659
|
+
hide(): void;
|
|
1660
|
+
}
|
|
1661
|
+
declare function defineTooltip(tag?: string): CustomElementConstructor | undefined;
|
|
1662
|
+
|
|
1663
|
+
/**
|
|
1664
|
+
* `<usa-popover>` — a click-to-open popover: the first element child is the
|
|
1665
|
+
* trigger, `[data-popover]` is the content. Springs open from the trigger,
|
|
1666
|
+
* flips to stay on screen; Esc or an outside click closes and focus returns
|
|
1667
|
+
* to the trigger. `aria-expanded` / `aria-controls` on the trigger.
|
|
1668
|
+
* Attributes: `open`, `placement` (`bottom` default), `variant`. Events:
|
|
1669
|
+
* `usa:open`, `usa:close`. Reduced motion: fades only.
|
|
1670
|
+
*/
|
|
1671
|
+
interface UsaPopoverElement extends UsaElement {
|
|
1672
|
+
open: boolean;
|
|
1673
|
+
toggle(force?: boolean): void;
|
|
1674
|
+
}
|
|
1675
|
+
declare function definePopover(tag?: string): CustomElementConstructor | undefined;
|
|
1676
|
+
|
|
1677
|
+
/**
|
|
1678
|
+
* `<usa-badge>` — a count / dot badge on whatever it wraps; bumps with a
|
|
1679
|
+
* spring whenever the value changes and pulses with `pulse`.
|
|
1680
|
+
* Attributes: `value` (number or text; 0 / empty hides it unless
|
|
1681
|
+
* `show-zero`), `max` (99 → "99+"), `dot`, `pulse`, `label` (accessible
|
|
1682
|
+
* text, default "{n} new"), `variant`. Reduced motion: no bump or pulse.
|
|
1683
|
+
*/
|
|
1684
|
+
interface UsaBadgeElement extends UsaElement {
|
|
1685
|
+
value: string;
|
|
1686
|
+
}
|
|
1687
|
+
declare function defineBadge(tag?: string): CustomElementConstructor | undefined;
|
|
1688
|
+
|
|
1689
|
+
/**
|
|
1690
|
+
* `<usa-avatar-stack>` — overlapping avatars (its children: `<img>` or any
|
|
1691
|
+
* element) that spread apart with a spring on hover / focus; extra ones
|
|
1692
|
+
* collapse into a "+N" chip.
|
|
1693
|
+
* Attributes: `max` (visible avatars, 5), `size` (px, 36), `overlap` (0–1,
|
|
1694
|
+
* 0.35), `label` (group name), `variant`. Reduced motion: no spreading.
|
|
1695
|
+
*/
|
|
1696
|
+
interface UsaAvatarStackElement extends UsaElement {
|
|
1697
|
+
}
|
|
1698
|
+
declare function defineAvatarStack(tag?: string): CustomElementConstructor | undefined;
|
|
1699
|
+
|
|
1700
|
+
/**
|
|
1701
|
+
* Style variants (v2.6): `variant="minimal | neon | glass | brutalist |
|
|
1702
|
+
* fluent | material"` on any `<usa-*>` element — or on any ancestor as
|
|
1703
|
+
* `data-usa-variant`, or page-wide with `setVariant()` — sets the shared
|
|
1704
|
+
* design tokens every component reads:
|
|
1705
|
+
*
|
|
1706
|
+
* `--usa-accent`, `--usa-accent-text`, `--usa-surface`, `--usa-text`,
|
|
1707
|
+
* `--usa-radius`, `--usa-border`, `--usa-shadow`, `--usa-blur`, `--usa-font`.
|
|
1708
|
+
*
|
|
1709
|
+
* (`<usa-spinner>`, `<usa-check>` and `<usa-dialog>` already use `variant`
|
|
1710
|
+
* for their kind; the token names never clash with those values except
|
|
1711
|
+
* `fluent`, which means the same thing there.)
|
|
1712
|
+
*/
|
|
1713
|
+
declare const VARIANTS: readonly ["minimal", "neon", "glass", "brutalist", "fluent", "material"];
|
|
1714
|
+
type Variant = (typeof VARIANTS)[number];
|
|
1715
|
+
/** Inject the variant token sheet (done automatically by every `ui` component). */
|
|
1716
|
+
declare function adoptVariants(): void;
|
|
1717
|
+
/** Apply a variant to the whole page (or `root`); `null` removes it. */
|
|
1718
|
+
declare function setVariant(variant: Variant | null, root?: Element | null): void;
|
|
1719
|
+
|
|
1720
|
+
type Placement = 'top' | 'bottom' | 'left' | 'right';
|
|
1721
|
+
|
|
1722
|
+
/**
|
|
1723
|
+
* motionary/components/ui — animated UI components + style variants (v2.6).
|
|
1724
|
+
* `<usa-tabs>`, `<usa-drawer>`, `<usa-bottom-sheet>`, `<usa-pull-refresh>`,
|
|
1725
|
+
* `<usa-fab>`, `<usa-navbar>`, `<usa-slider>`, `<usa-rating>`,
|
|
1726
|
+
* `<usa-tooltip>`, `<usa-popover>`, `<usa-badge>`, `<usa-avatar-stack>`,
|
|
1727
|
+
* and `variant="minimal | neon | glass | brutalist | fluent | material"`
|
|
1728
|
+
* design tokens (`setVariant()`, `VARIANTS`).
|
|
1729
|
+
*/
|
|
1730
|
+
|
|
1731
|
+
/** Register every component of this category under its default tag. */
|
|
1732
|
+
declare function defineUiComponents(): void;
|
|
1733
|
+
declare global {
|
|
1734
|
+
interface HTMLElementTagNameMap {
|
|
1735
|
+
'usa-tabs': UsaTabsElement;
|
|
1736
|
+
'usa-drawer': UsaDrawerElement;
|
|
1737
|
+
'usa-bottom-sheet': UsaBottomSheetElement;
|
|
1738
|
+
'usa-pull-refresh': UsaPullRefreshElement;
|
|
1739
|
+
'usa-fab': UsaFabElement;
|
|
1740
|
+
'usa-navbar': UsaNavbarElement;
|
|
1741
|
+
'usa-slider': UsaSliderElement;
|
|
1742
|
+
'usa-rating': UsaRatingElement;
|
|
1743
|
+
'usa-tooltip': UsaTooltipElement;
|
|
1744
|
+
'usa-popover': UsaPopoverElement;
|
|
1745
|
+
'usa-badge': UsaBadgeElement;
|
|
1746
|
+
'usa-avatar-stack': UsaAvatarStackElement;
|
|
1747
|
+
}
|
|
1748
|
+
}
|
|
1749
|
+
|
|
1750
|
+
declare const CURSOR_MODES: readonly ["dot", "magnetic", "glow"];
|
|
1751
|
+
type CursorMode = (typeof CURSOR_MODES)[number];
|
|
1752
|
+
/**
|
|
1753
|
+
* `<usa-cursor mode="dot | magnetic | glow">` — a custom cursor for
|
|
1754
|
+
* the page (place it once, e.g. at the end of `<body>`).
|
|
1755
|
+
* - `dot` — a ring that follows with spring lag around the real pointer;
|
|
1756
|
+
* (6.0: `mode="trail"` was removed — use the registered `comet-trail` effect;
|
|
1757
|
+
* unknown modes render as `dot`.)
|
|
1758
|
+
* - `magnetic` — the ring snaps onto and wraps hovered targets (`a`,
|
|
1759
|
+
* `button`, `[data-cursor]`);
|
|
1760
|
+
* - `glow` — a large soft light following the pointer (great on dark UIs).
|
|
1761
|
+
* Attributes: `mode`, `color`, `size` (px, 28), `hide-native` (hide the
|
|
1762
|
+
* system cursor), `targets` (selector, magnetic). Only for fine pointers
|
|
1763
|
+
* (mouse / pen); never on touch. Reduced motion: not rendered.
|
|
1764
|
+
*/
|
|
1765
|
+
interface UsaCursorElement extends UsaElement {
|
|
1766
|
+
readonly active: boolean;
|
|
1767
|
+
}
|
|
1768
|
+
declare function defineCursor(tag?: string): CustomElementConstructor | undefined;
|
|
1769
|
+
|
|
1770
|
+
/**
|
|
1771
|
+
* `<usa-fullpage>` — full-screen sections (its element children) that snap
|
|
1772
|
+
* one at a time (CSS scroll snap), with keyboard paging (PageUp/PageDown,
|
|
1773
|
+
* arrows, Home/End), optional dot navigation and the current section in
|
|
1774
|
+
* `aria-current` + `usa:section`.
|
|
1775
|
+
* Attributes: `dots` (show the dot nav), `axis` (`y` default, `x`).
|
|
1776
|
+
* Methods: `go(i)`, `next()`, `prev()`. Reduced motion: snapping stays,
|
|
1777
|
+
* jumps are instant.
|
|
1778
|
+
*/
|
|
1779
|
+
interface UsaFullpageElement extends UsaElement {
|
|
1780
|
+
readonly index: number;
|
|
1781
|
+
go(i: number): void;
|
|
1782
|
+
next(): void;
|
|
1783
|
+
prev(): void;
|
|
1784
|
+
}
|
|
1785
|
+
declare function defineFullpage(tag?: string): CustomElementConstructor | undefined;
|
|
1786
|
+
|
|
1787
|
+
/**
|
|
1788
|
+
* `<usa-loading-bar>` — a slim top loading bar for route changes and fetches
|
|
1789
|
+
* (NProgress-style): `start()` trickles towards 90 %, `done()` completes and
|
|
1790
|
+
* fades out, `set(0–1)` for real progress. `loadingBar` drives the first bar
|
|
1791
|
+
* on the page (created on demand). `role="progressbar"`, `aria-busy`.
|
|
1792
|
+
* Attributes: `color`, `height` (px, 3), `position` (`top` default, `bottom`).
|
|
1793
|
+
* Reduced motion: no trickle animation — the bar shows / hides.
|
|
1794
|
+
*/
|
|
1795
|
+
interface UsaLoadingBarElement extends UsaElement {
|
|
1796
|
+
readonly progress: number;
|
|
1797
|
+
start(): void;
|
|
1798
|
+
set(p: number): void;
|
|
1799
|
+
done(): void;
|
|
1800
|
+
}
|
|
1801
|
+
declare function defineLoadingBar(tag?: string): CustomElementConstructor | undefined;
|
|
1802
|
+
/** Drive the page's `<usa-loading-bar>` (created on first use). */
|
|
1803
|
+
declare const loadingBar: {
|
|
1804
|
+
start: () => void;
|
|
1805
|
+
set: (p: number) => void;
|
|
1806
|
+
done: () => void;
|
|
1807
|
+
/** Run `task` with the bar shown; resolves with its result. */
|
|
1808
|
+
track<T>(task: Promise<T> | (() => Promise<T>)): Promise<T>;
|
|
1809
|
+
};
|
|
1810
|
+
|
|
1811
|
+
/**
|
|
1812
|
+
* `<usa-back-to-top>` — a floating button that appears after `offset` px
|
|
1813
|
+
* (300) of scrolling, shows page progress as a ring and springs the page
|
|
1814
|
+
* back to the top (then focuses `focus-target`, default `#main` / `body`).
|
|
1815
|
+
* Attributes: `offset`, `label` ("Back to top"), `focus-target`, `position`
|
|
1816
|
+
* (`bottom-right` default, `bottom-left`). Reduced motion: instant jump.
|
|
1817
|
+
*/
|
|
1818
|
+
interface UsaBackToTopElement extends UsaElement {
|
|
1819
|
+
readonly visible: boolean;
|
|
1820
|
+
}
|
|
1821
|
+
declare function defineBackToTop(tag?: string): CustomElementConstructor | undefined;
|
|
1822
|
+
|
|
1823
|
+
declare const AMBIENT_EFFECTS: readonly ["particles", "snow", "stars", "noise", "gradient"];
|
|
1824
|
+
type AmbientEffect = (typeof AMBIENT_EFFECTS)[number];
|
|
1825
|
+
/**
|
|
1826
|
+
* `<usa-ambient effect="particles | snow | stars | noise | gradient">` — a
|
|
1827
|
+
* fixed, page-wide ambient layer behind (or, with `layer="front"`, over)
|
|
1828
|
+
* the content, never catching the pointer.
|
|
1829
|
+
* - `particles` — slow drifting dots; `snow` — falling flakes with sway;
|
|
1830
|
+
* `stars` — twinkling starfield (canvas, paused in hidden tabs, DPR ≤ 2);
|
|
1831
|
+
* - `noise` — animated film grain (CSS, SVG turbulence);
|
|
1832
|
+
* - `gradient` — a gradient whose hue shifts with the scroll position.
|
|
1833
|
+
* Attributes: `effect`, `density` (0.2–3, 1), `color`, `opacity` (0.6),
|
|
1834
|
+
* `layer` (`back` default, `front`), `speed` (1). Reduced motion: one
|
|
1835
|
+
* static frame (no falling, twinkling or grain flicker).
|
|
1836
|
+
*/
|
|
1837
|
+
interface UsaAmbientElement extends UsaElement {
|
|
1838
|
+
}
|
|
1839
|
+
declare function defineAmbient(tag?: string): CustomElementConstructor | undefined;
|
|
1840
|
+
|
|
1841
|
+
/**
|
|
1842
|
+
* `<usa-splash>` — an app splash / launch screen: shows its content (logo,
|
|
1843
|
+
* spinner) over the page, then leaves with `exit` (`fade` default, `scale`,
|
|
1844
|
+
* `slide-up`, `circle`) once the page has loaded (or when you call
|
|
1845
|
+
* `done()`), but never sooner than `min` ms (600) — no flash.
|
|
1846
|
+
* Attributes: `min`, `exit`, `manual` (wait for `done()`), `label`.
|
|
1847
|
+
* Events: `usa:done`. The page underneath is `aria-busy` until then.
|
|
1848
|
+
* Reduced motion: fades.
|
|
1849
|
+
*/
|
|
1850
|
+
interface UsaSplashElement extends UsaElement {
|
|
1851
|
+
done(): Promise<void>;
|
|
1852
|
+
}
|
|
1853
|
+
declare function defineSplash(tag?: string): CustomElementConstructor | undefined;
|
|
1854
|
+
|
|
1855
|
+
/**
|
|
1856
|
+
* `<usa-auto-skeleton loading>` — automatic skeletons: while `loading` is
|
|
1857
|
+
* set, every text block, image, button and input inside is drawn as a
|
|
1858
|
+
* shimmering placeholder of its own size — no separate skeleton markup.
|
|
1859
|
+
* Remove `loading` (or set `.loading = false`) and the content fades in.
|
|
1860
|
+
* `aria-busy` while loading. Opt elements out with `data-no-skeleton`.
|
|
1861
|
+
* Reduced motion: static placeholders, no shimmer or fade.
|
|
1862
|
+
*/
|
|
1863
|
+
interface UsaAutoSkeletonElement extends UsaElement {
|
|
1864
|
+
loading: boolean;
|
|
1865
|
+
}
|
|
1866
|
+
declare function defineAutoSkeleton(tag?: string): CustomElementConstructor | undefined;
|
|
1867
|
+
|
|
1868
|
+
/** The switch's levels: Off (motion sensitivity `minimal`) + the three intensities. */
|
|
1869
|
+
type MotionSwitchLevel = 'off' | MotionIntensity;
|
|
1870
|
+
/**
|
|
1871
|
+
* Set the global motion intensity for every `<usa-*>` component:
|
|
1872
|
+
* `'low'`, `'normal'` (default), `'high'`. Sets `--usa-motion` and
|
|
1873
|
+
* `data-usa-motion` on `<html>`; with `persist` the choice is remembered
|
|
1874
|
+
* (localStorage) and restored by `restoreMotionIntensity()`.
|
|
1875
|
+
* 5.0: `'off'` was removed — use `setMotionSensitivity('minimal')`.
|
|
1876
|
+
*/
|
|
1877
|
+
declare function setMotionIntensity(level: MotionIntensity, persist?: boolean): void;
|
|
1878
|
+
/** Apply a switch level: `'off'` = motion sensitivity `minimal`, otherwise full motion at that intensity. */
|
|
1879
|
+
declare function setMotionLevel(level: MotionSwitchLevel, persist?: boolean): void;
|
|
1880
|
+
/** The current switch level. */
|
|
1881
|
+
declare function getMotionLevel(): MotionSwitchLevel;
|
|
1882
|
+
/** Re-apply a persisted level (call early on page load). Returns the active intensity. */
|
|
1883
|
+
declare function restoreMotionIntensity(): MotionIntensity;
|
|
1884
|
+
/**
|
|
1885
|
+
* `<usa-motion-switch>` — a segmented control letting users choose the
|
|
1886
|
+
* app's motion intensity (Off · Low · Normal · High), persisted.
|
|
1887
|
+
* `role="radiogroup"`; arrow keys move. Attributes: `labels` (comma list),
|
|
1888
|
+
* `label` ("Motion"). Events: `usa:change` (`{ level }`).
|
|
1889
|
+
*/
|
|
1890
|
+
interface UsaMotionSwitchElement extends UsaElement {
|
|
1891
|
+
value: MotionSwitchLevel;
|
|
1892
|
+
}
|
|
1893
|
+
declare function defineMotionSwitch(tag?: string): CustomElementConstructor | undefined;
|
|
1894
|
+
|
|
1895
|
+
/**
|
|
1896
|
+
* Page & app-wide transitions (v2.7), built on the View Transitions API
|
|
1897
|
+
* (Chromium: Chrome, Edge, Electron, WebView2) with graceful fallbacks.
|
|
1898
|
+
*
|
|
1899
|
+
* - `pageTransition(update, { effect })` — SPA route changes: `fade`,
|
|
1900
|
+
* `slide` (`slide-left` / `slide-right` / `slide-up`), `circle` (reveal
|
|
1901
|
+
* from `x`, `y`), `blinds`, `pixel` (stepped dissolve), `zoom`.
|
|
1902
|
+
* - `enableMpaTransitions(effect)` — the same effects for multi-page sites
|
|
1903
|
+
* (`@view-transition { navigation: auto }`); call it on every page.
|
|
1904
|
+
* - `themeTransition(apply, { x, y })` — a circle-reveal theme switch.
|
|
1905
|
+
*
|
|
1906
|
+
* Without View Transitions (Firefox, older Safari) or under reduced motion
|
|
1907
|
+
* the update runs immediately (`fade` falls back to a short cross-fade of
|
|
1908
|
+
* `fallback` when given).
|
|
1909
|
+
*/
|
|
1910
|
+
declare const PAGE_EFFECTS: readonly ["fade", "slide", "slide-left", "slide-right", "slide-up", "circle", "blinds", "pixel", "zoom"];
|
|
1911
|
+
type PageEffect = (typeof PAGE_EFFECTS)[number];
|
|
1912
|
+
interface PageTransitionOptions {
|
|
1913
|
+
effect?: PageEffect;
|
|
1914
|
+
/** Circle origin in client px (default: viewport centre / last pointer). */
|
|
1915
|
+
x?: number;
|
|
1916
|
+
y?: number;
|
|
1917
|
+
/** Duration in ms (default 600). */
|
|
1918
|
+
duration?: number;
|
|
1919
|
+
/** Element to cross-fade when View Transitions are unavailable. */
|
|
1920
|
+
fallback?: Element | null;
|
|
1921
|
+
}
|
|
1922
|
+
/** `true` when `document.startViewTransition` exists. */
|
|
1923
|
+
declare const supportsViewTransitions: () => boolean;
|
|
1924
|
+
/** Run `update` (sync or async) as an animated page transition. Resolves when it is done. */
|
|
1925
|
+
declare function pageTransition(update: () => unknown, options?: PageTransitionOptions): Promise<void>;
|
|
1926
|
+
/** Opt a multi-page site into cross-document view transitions with `effect`. */
|
|
1927
|
+
declare function enableMpaTransitions(effect?: PageEffect, duration?: number): void;
|
|
1928
|
+
/**
|
|
1929
|
+
* Switch theme with a circle reveal from (`x`, `y`) (default: last pointer).
|
|
1930
|
+
* `apply` flips your theme (e.g. toggles a class / `data-theme`).
|
|
1931
|
+
*/
|
|
1932
|
+
declare function themeTransition(apply: () => unknown, options?: Omit<PageTransitionOptions, 'effect'>): Promise<void>;
|
|
1933
|
+
|
|
1934
|
+
/**
|
|
1935
|
+
* `smoothScroll()` — inertial wheel smoothing for the page (or a scroll
|
|
1936
|
+
* container): wheel deltas are eased with a lerp each frame. Touch and
|
|
1937
|
+
* keyboard scrolling stay native. Returns a function that turns it off.
|
|
1938
|
+
* No-op under reduced motion, on touch-only devices and on the server.
|
|
1939
|
+
*/
|
|
1940
|
+
interface SmoothScrollOptions {
|
|
1941
|
+
/** Scroll container (default: the page). */
|
|
1942
|
+
target?: HTMLElement | null;
|
|
1943
|
+
/** 0–1, lower = smoother / longer glide (default 0.12). */
|
|
1944
|
+
lerp?: number;
|
|
1945
|
+
/** Wheel multiplier (default 1). */
|
|
1946
|
+
wheelMultiplier?: number;
|
|
1947
|
+
}
|
|
1948
|
+
declare function smoothScroll(options?: SmoothScrollOptions): () => void;
|
|
1949
|
+
/**
|
|
1950
|
+
* Scroll to a y position, element or selector with spring timing (or
|
|
1951
|
+
* instantly under reduced motion). Resolves when done.
|
|
1952
|
+
*/
|
|
1953
|
+
declare function scrollToTarget(to: number | Element | string, options?: {
|
|
1954
|
+
offset?: number;
|
|
1955
|
+
target?: HTMLElement | null;
|
|
1956
|
+
preset?: string;
|
|
1957
|
+
}): Promise<void>;
|
|
1958
|
+
|
|
1959
|
+
/**
|
|
1960
|
+
* motionary/components/page — page & app-wide effects (v2.7).
|
|
1961
|
+
* Page transitions (`pageTransition()`, `enableMpaTransitions()`,
|
|
1962
|
+
* `themeTransition()`), `<usa-cursor>`, `smoothScroll()` / `scrollToTarget()`,
|
|
1963
|
+
* `<usa-fullpage>`, `<usa-loading-bar>` + `loadingBar`, `<usa-back-to-top>`,
|
|
1964
|
+
* `<usa-ambient>`, `<usa-splash>`, `<usa-auto-skeleton>` and the global motion
|
|
1965
|
+
* intensity (`setMotionIntensity()`, `<usa-motion-switch>`).
|
|
1966
|
+
*/
|
|
1967
|
+
|
|
1968
|
+
/** Register every component of this category under its default tag. */
|
|
1969
|
+
declare function definePageComponents(): void;
|
|
1970
|
+
declare global {
|
|
1971
|
+
interface HTMLElementTagNameMap {
|
|
1972
|
+
'usa-cursor': UsaCursorElement;
|
|
1973
|
+
'usa-fullpage': UsaFullpageElement;
|
|
1974
|
+
'usa-loading-bar': UsaLoadingBarElement;
|
|
1975
|
+
'usa-back-to-top': UsaBackToTopElement;
|
|
1976
|
+
'usa-ambient': UsaAmbientElement;
|
|
1977
|
+
'usa-splash': UsaSplashElement;
|
|
1978
|
+
'usa-auto-skeleton': UsaAutoSkeletonElement;
|
|
1979
|
+
'usa-motion-switch': UsaMotionSwitchElement;
|
|
1980
|
+
}
|
|
1981
|
+
}
|
|
1982
|
+
|
|
1983
|
+
/**
|
|
1984
|
+
* `<usa-timeline>` — declarative choreography. Every descendant with
|
|
1985
|
+
* `data-tl="<preset>"` becomes a step, in document order; `data-at`
|
|
1986
|
+
* (`'-=200'`, `'<'`, `'label+=100'`, ms), `data-duration` and `data-label`
|
|
1987
|
+
* fine-tune it.
|
|
1988
|
+
*
|
|
1989
|
+
* Attributes: `trigger` (`view` default · `click` · `manual`), `scrub`
|
|
1990
|
+
* (progress follows scroll instead of playing), `overlap` (ms each step
|
|
1991
|
+
* overlaps the previous, default 0), `duration` (600), `stagger` (ms),
|
|
1992
|
+
* `repeat` (replay every time it enters the viewport). 4.1: `scrub` runs on native
|
|
1993
|
+
* ScrollTimeline / ViewTimeline when supported (`data-native` is set); `scrub="scroll"`
|
|
1994
|
+
* and `smooth` tune it (5.0: `scrub="js"` removed — the JS engine is automatic). Methods: `play()`,
|
|
1995
|
+
* `reverse()`, `seek(t)`; property `timeline`. Event `usa:complete`.
|
|
1996
|
+
* Reduced motion: steps appear in their final state.
|
|
1997
|
+
*/
|
|
1998
|
+
interface UsaTimelineElement extends UsaElement {
|
|
1999
|
+
readonly timeline: Timeline | null;
|
|
2000
|
+
play(): Promise<void>;
|
|
2001
|
+
reverse(): Promise<void>;
|
|
2002
|
+
seek(to: number | string): void;
|
|
2003
|
+
}
|
|
2004
|
+
declare function defineTimeline(tag?: string): CustomElementConstructor | undefined;
|
|
2005
|
+
|
|
2006
|
+
/**
|
|
2007
|
+
* motionary/components/timeline — choreography (v3.1).
|
|
2008
|
+
* `timeline()` chains, overlaps, labels, seeks, reverses and scroll-scrubs
|
|
2009
|
+
* WAAPI animations on one playhead; `<usa-timeline>` builds one from
|
|
2010
|
+
* `data-tl` children.
|
|
2011
|
+
*/
|
|
2012
|
+
|
|
2013
|
+
/** Register every component of this category under its default tag. */
|
|
2014
|
+
declare function defineTimelineComponents(): void;
|
|
2015
|
+
declare global {
|
|
2016
|
+
interface HTMLElementTagNameMap {
|
|
2017
|
+
'usa-timeline': UsaTimelineElement;
|
|
2018
|
+
}
|
|
2019
|
+
}
|
|
2020
|
+
|
|
2021
|
+
interface PanState {
|
|
2022
|
+
/** Offset from the gesture start (px). */
|
|
2023
|
+
dx: number;
|
|
2024
|
+
dy: number;
|
|
2025
|
+
/** Velocity (px/s). */
|
|
2026
|
+
vx: number;
|
|
2027
|
+
vy: number;
|
|
2028
|
+
first: boolean;
|
|
2029
|
+
last: boolean;
|
|
2030
|
+
event: Event;
|
|
2031
|
+
}
|
|
2032
|
+
type SwipeDirection = 'left' | 'right' | 'up' | 'down';
|
|
2033
|
+
interface SwipeState {
|
|
2034
|
+
direction: SwipeDirection;
|
|
2035
|
+
velocity: number;
|
|
2036
|
+
dx: number;
|
|
2037
|
+
dy: number;
|
|
2038
|
+
}
|
|
2039
|
+
interface PinchState {
|
|
2040
|
+
scale: number; /** Midpoint of the two pointers (client px). */
|
|
2041
|
+
x: number;
|
|
2042
|
+
y: number;
|
|
2043
|
+
first: boolean;
|
|
2044
|
+
last: boolean;
|
|
2045
|
+
}
|
|
2046
|
+
interface PressState {
|
|
2047
|
+
x: number;
|
|
2048
|
+
y: number;
|
|
2049
|
+
}
|
|
2050
|
+
interface GestureHandlers {
|
|
2051
|
+
onPan?: (s: PanState) => void;
|
|
2052
|
+
onSwipe?: (s: SwipeState) => void;
|
|
2053
|
+
onPinch?: (s: PinchState) => void;
|
|
2054
|
+
onLongPress?: (s: PressState) => void;
|
|
2055
|
+
onTap?: (s: PressState) => void;
|
|
2056
|
+
onDoubleTap?: (s: PressState) => void;
|
|
2057
|
+
}
|
|
2058
|
+
interface GestureOptions {
|
|
2059
|
+
/** Restrict panning to an axis. */
|
|
2060
|
+
axis?: 'x' | 'y';
|
|
2061
|
+
/** Movement (px) before a pan starts (default 4). */
|
|
2062
|
+
threshold?: number;
|
|
2063
|
+
/** Minimum distance (px, default 40) and speed (px/s, default 300) for a swipe. */
|
|
2064
|
+
swipeDistance?: number;
|
|
2065
|
+
swipeVelocity?: number;
|
|
2066
|
+
/** Long-press delay (ms, default 500). */
|
|
2067
|
+
longPress?: number;
|
|
2068
|
+
/** Ctrl/⌘ + wheel (trackpad pinch) counts as pinch (default true). */
|
|
2069
|
+
wheelPinch?: boolean;
|
|
2070
|
+
}
|
|
2071
|
+
/** The swipe a pointer release represents, or `null` (pure). */
|
|
2072
|
+
declare function swipeDirection(dx: number, dy: number, vx: number, vy: number, o?: {
|
|
2073
|
+
distance?: number;
|
|
2074
|
+
velocity?: number;
|
|
2075
|
+
axis?: 'x' | 'y';
|
|
2076
|
+
}): SwipeState | null;
|
|
2077
|
+
/** Scale between two pointer distances, clamped to [min, max] (pure). */
|
|
2078
|
+
declare function pinchScale(startDistance: number, distance: number, base?: number, min?: number, max?: number): number;
|
|
2079
|
+
/**
|
|
2080
|
+
* One recognizer for pan, swipe, pinch (two pointers or Ctrl + wheel),
|
|
2081
|
+
* long-press, tap and double-tap, with velocities ready to hand to a spring
|
|
2082
|
+
* (`createSpring().set(target, velocity)`). Works with mouse, touch and pen
|
|
2083
|
+
* through Pointer Events. Returns a cleanup function.
|
|
2084
|
+
*
|
|
2085
|
+
* @example
|
|
2086
|
+
* const x = createSpring({ onUpdate: (v) => (card.style.translate = `${v}px`) });
|
|
2087
|
+
* gesture(card, {
|
|
2088
|
+
* onPan: ({ dx, last, vx }) => (last ? x.set(0, vx) : x.jump(dx)),
|
|
2089
|
+
* onSwipe: ({ direction }) => dismiss(direction),
|
|
2090
|
+
* }, { axis: 'x' });
|
|
2091
|
+
*/
|
|
2092
|
+
declare function gesture(el: HTMLElement, h: GestureHandlers, o?: GestureOptions): () => void;
|
|
2093
|
+
|
|
2094
|
+
/**
|
|
2095
|
+
* `<usa-swipeable>` — swipe-to-dismiss / swipe actions. The content follows
|
|
2096
|
+
* the finger (rubber-banded past `distance`), flies out on a swipe or a drag
|
|
2097
|
+
* past `distance`, otherwise springs home with the release velocity.
|
|
2098
|
+
*
|
|
2099
|
+
* Attributes: `axis` (`x` default · `y`), `distance` (px, 120), `preset`
|
|
2100
|
+
* (spring), `dismiss` (remove the element after flying out), `disabled`.
|
|
2101
|
+
* Keyboard: Delete/Backspace dismisses, ←/→ swipe. Events `usa:swipe`
|
|
2102
|
+
* (`{ direction }`, cancelable), `usa:dismiss`. Methods `swipe(dir)`, `reset()`.
|
|
2103
|
+
* Reduced motion: no follow / fly-out animation, events still fire.
|
|
2104
|
+
*/
|
|
2105
|
+
interface UsaSwipeableElement extends UsaElement {
|
|
2106
|
+
swipe(direction: SwipeDirection): void;
|
|
2107
|
+
reset(): void;
|
|
2108
|
+
readonly offset: number;
|
|
2109
|
+
}
|
|
2110
|
+
declare function defineSwipeable(tag?: string): CustomElementConstructor | undefined;
|
|
2111
|
+
|
|
2112
|
+
/**
|
|
2113
|
+
* `<usa-pinch-zoom>` — pinch (two fingers or Ctrl/⌘ + wheel / trackpad
|
|
2114
|
+
* pinch) to zoom its content, pan while zoomed, double-tap to toggle zoom;
|
|
2115
|
+
* scale and position spring back inside the bounds on release.
|
|
2116
|
+
*
|
|
2117
|
+
* Attributes: `min` (1), `max` (4), `double-tap` (zoom level, 2), `preset`.
|
|
2118
|
+
* Keyboard: `+` / `-` / `0`. Property `scale`, method `zoomTo(scale)`.
|
|
2119
|
+
* Event `usa:zoom` (`{ scale }`). Reduced motion: zoom changes instantly.
|
|
2120
|
+
*/
|
|
2121
|
+
interface UsaPinchZoomElement extends UsaElement {
|
|
2122
|
+
readonly scale: number;
|
|
2123
|
+
zoomTo(scale: number): void;
|
|
2124
|
+
}
|
|
2125
|
+
declare function definePinchZoom(tag?: string): CustomElementConstructor | undefined;
|
|
2126
|
+
|
|
2127
|
+
/**
|
|
2128
|
+
* motionary/components/gesture — unified gestures (v3.2).
|
|
2129
|
+
* `gesture()` recognises pan, swipe, pinch, long-press, tap and double-tap
|
|
2130
|
+
* with release velocities for springs; `<usa-swipeable>` (swipe-to-dismiss)
|
|
2131
|
+
* and `<usa-pinch-zoom>` are built on it.
|
|
2132
|
+
*/
|
|
2133
|
+
|
|
2134
|
+
/** Register every component of this category under its default tag. */
|
|
2135
|
+
declare function defineGestureComponents(): void;
|
|
2136
|
+
declare global {
|
|
2137
|
+
interface HTMLElementTagNameMap {
|
|
2138
|
+
'usa-swipeable': UsaSwipeableElement;
|
|
2139
|
+
'usa-pinch-zoom': UsaPinchZoomElement;
|
|
2140
|
+
}
|
|
2141
|
+
}
|
|
2142
|
+
|
|
2143
|
+
/**
|
|
2144
|
+
* `<usa-draw>` — line drawing: every stroke of the SVG inside draws itself.
|
|
2145
|
+
* Attributes: `trigger` (`view` default · `hover` · `click` · `scrub`),
|
|
2146
|
+
* `duration` (1600), `stagger` (0–0.9 share of the timeline, 0.2), `fill`
|
|
2147
|
+
* (fade the fill in after drawing), `repeat`. Method `play()`, property
|
|
2148
|
+
* `progress`, event `usa:complete`. Reduced motion: drawn immediately.
|
|
2149
|
+
*/
|
|
2150
|
+
interface UsaDrawElement extends UsaElement {
|
|
2151
|
+
play(): void;
|
|
2152
|
+
progress: number;
|
|
2153
|
+
}
|
|
2154
|
+
declare function defineDraw(tag?: string): CustomElementConstructor | undefined;
|
|
2155
|
+
|
|
2156
|
+
/**
|
|
2157
|
+
* `<usa-morph>` — morphs an SVG path through a list of shapes.
|
|
2158
|
+
* Put a `<svg><path></path></svg>` inside (one is created otherwise) and set
|
|
2159
|
+
* `paths="M… | M… | M…"` (same command structure morphs smoothly, others
|
|
2160
|
+
* switch at the midpoint). Attributes: `trigger` (`click` default · `hover`
|
|
2161
|
+
* · `auto` · `view`), `interval` (ms for auto, 2000), `duration` (600).
|
|
2162
|
+
* Property `index`, method `next()`, event `usa:change`.
|
|
2163
|
+
* Reduced motion: shapes switch without animating; `auto` does not cycle.
|
|
2164
|
+
*/
|
|
2165
|
+
interface UsaMorphElement extends UsaElement {
|
|
2166
|
+
readonly index: number;
|
|
2167
|
+
next(): Promise<void>;
|
|
2168
|
+
}
|
|
2169
|
+
declare function defineMorph(tag?: string): CustomElementConstructor | undefined;
|
|
2170
|
+
|
|
2171
|
+
/** Clip-path start / end frames for each reveal shape. */
|
|
2172
|
+
declare const MASK_SHAPES: Record<string, [string, string]>;
|
|
2173
|
+
/**
|
|
2174
|
+
* `<usa-mask-reveal>` — reveals its content through a growing mask shape.
|
|
2175
|
+
* Attributes: `shape` (`circle` default · `diamond` · `wipe` · `wipe-up` ·
|
|
2176
|
+
* `iris` · `star`), `duration` (900), `delay`, `trigger` (`view` · `hover`
|
|
2177
|
+
* · `click`), `repeat`, `at` (`x% y%` origin for circle). Event
|
|
2178
|
+
* `usa:complete`. Reduced motion: content is shown without the mask.
|
|
2179
|
+
*/
|
|
2180
|
+
interface UsaMaskRevealElement extends UsaElement {
|
|
2181
|
+
reveal(): Promise<void>;
|
|
2182
|
+
}
|
|
2183
|
+
declare function defineMaskReveal(tag?: string): CustomElementConstructor | undefined;
|
|
2184
|
+
|
|
2185
|
+
type Icon = {
|
|
2186
|
+
d: string;
|
|
2187
|
+
frames: Keyframe[];
|
|
2188
|
+
duration: number;
|
|
2189
|
+
origin?: string;
|
|
2190
|
+
};
|
|
2191
|
+
/** Built-in animated icons (24×24 strokes) and the motion each one plays. */
|
|
2192
|
+
declare const ANIM_ICONS: Record<string, Icon>;
|
|
2193
|
+
/**
|
|
2194
|
+
* `<usa-anim-icon name="bell">` — an animated stroke icon that plays its
|
|
2195
|
+
* motion on `trigger` (`hover` default · `click` · `view` · `loop`).
|
|
2196
|
+
* Attributes: `name` (see `ANIM_ICONS`), `size` (24), `label` (accessible
|
|
2197
|
+
* name; decorative when absent). Method `play()`. Reduced motion: static.
|
|
2198
|
+
*/
|
|
2199
|
+
interface UsaAnimIconElement extends UsaElement {
|
|
2200
|
+
play(): void;
|
|
2201
|
+
}
|
|
2202
|
+
declare function defineAnimIcon(tag?: string): CustomElementConstructor | undefined;
|
|
2203
|
+
|
|
2204
|
+
/** `true` when two path strings share the same commands (so their numbers can be interpolated). */
|
|
2205
|
+
declare function pathsCompatible(a: string, b: string): boolean;
|
|
2206
|
+
/**
|
|
2207
|
+
* Path data between `a` and `b` at `t` (0–1). Paths with the same command
|
|
2208
|
+
* structure morph number-by-number; others switch at the midpoint.
|
|
2209
|
+
*/
|
|
2210
|
+
declare function interpolatePath(a: string, b: string, t: number): string;
|
|
2211
|
+
interface MorphOptions {
|
|
2212
|
+
duration?: number;
|
|
2213
|
+
easing?: (t: number) => number;
|
|
2214
|
+
}
|
|
2215
|
+
/** Animate a `<path>`'s `d` to `to`. Resolves when done; instant under reduced motion. */
|
|
2216
|
+
declare function morphTo(path: SVGPathElement | Element, to: string, o?: MorphOptions): Promise<void>;
|
|
2217
|
+
/**
|
|
2218
|
+
* Prepare every stroke in `root` for line drawing (normalised `pathLength=1`,
|
|
2219
|
+
* so no `getTotalLength()` is needed) and return a function that sets
|
|
2220
|
+
* progress 0–1, optionally staggered between shapes.
|
|
2221
|
+
*/
|
|
2222
|
+
declare function drawLines(root: Element, o?: {
|
|
2223
|
+
stagger?: number;
|
|
2224
|
+
}): (progress: number) => void;
|
|
2225
|
+
|
|
2226
|
+
/**
|
|
2227
|
+
* motionary/components/svg — SVG animation (v3.3).
|
|
2228
|
+
* `<usa-draw>` (line drawing), `<usa-morph>` (path morph), `<usa-mask-reveal>`
|
|
2229
|
+
* (mask / clip-path reveals) and `<usa-anim-icon>` (animated icons), plus
|
|
2230
|
+
* `interpolatePath()`, `morphTo()`, `drawLines()`.
|
|
2231
|
+
*/
|
|
2232
|
+
|
|
2233
|
+
/** Register every component of this category under its default tag. */
|
|
2234
|
+
declare function defineSvgComponents(): void;
|
|
2235
|
+
declare global {
|
|
2236
|
+
interface HTMLElementTagNameMap {
|
|
2237
|
+
'usa-draw': UsaDrawElement;
|
|
2238
|
+
'usa-morph': UsaMorphElement;
|
|
2239
|
+
'usa-mask-reveal': UsaMaskRevealElement;
|
|
2240
|
+
'usa-anim-icon': UsaAnimIconElement;
|
|
2241
|
+
}
|
|
2242
|
+
}
|
|
2243
|
+
|
|
2244
|
+
/**
|
|
2245
|
+
* Shared shell for the WebGL elements: a canvas over (or behind) the
|
|
2246
|
+
* content that renders only while visible and the tab is shown, a DPR cap
|
|
2247
|
+
* of 2, and a graceful fallback (`data-fallback`) when WebGL, the shader
|
|
2248
|
+
* or the image (CORS) is unavailable — the original content / CSS stays.
|
|
2249
|
+
*/
|
|
2250
|
+
interface UsaGLElement extends UsaElement {
|
|
2251
|
+
/** `true` once WebGL rendering is active (otherwise the CSS fallback shows). */
|
|
2252
|
+
readonly active: boolean;
|
|
2253
|
+
}
|
|
2254
|
+
/**
|
|
2255
|
+
* `<usa-shader>` — GPU shader background behind its content. `preset`
|
|
2256
|
+
* (`gradient` · `plasma` · `waves` · `aurora`) or your own fragment shader in
|
|
2257
|
+
* `<script type="x-shader/x-fragment">` (uniforms `u_time`, `u_resolution`,
|
|
2258
|
+
* `u_mouse`, `v_uv`); `speed`. Without WebGL: the element's CSS background.
|
|
2259
|
+
*/
|
|
2260
|
+
declare function defineShader(tag?: string): CustomElementConstructor | undefined;
|
|
2261
|
+
/**
|
|
2262
|
+
* `<usa-distort>` — hover distortion + RGB split on the `<img>` inside,
|
|
2263
|
+
* following the pointer. Without WebGL / CORS: a gentle CSS zoom.
|
|
2264
|
+
*/
|
|
2265
|
+
declare function defineDistort(tag?: string): CustomElementConstructor | undefined;
|
|
2266
|
+
/**
|
|
2267
|
+
* `<usa-liquid>` — liquid image: clicks / taps send ripples through the
|
|
2268
|
+
* `<img>` inside, hover adds a gentle wobble; `strength`. Fallback: plain image.
|
|
2269
|
+
*/
|
|
2270
|
+
declare function defineLiquid(tag?: string): CustomElementConstructor | undefined;
|
|
2271
|
+
/**
|
|
2272
|
+
* `<usa-post-fx effects="vignette grain crt" intensity="0.6">` — GPU
|
|
2273
|
+
* post-processing over the `<img>` inside (4.8): `vignette` · `grain` ·
|
|
2274
|
+
* `chromatic` · `scanlines` · `crt` · `bloom` · `pixelate` · `duotone` ·
|
|
2275
|
+
* `glitch`, chained in order. `quality="high"` disables adaptive quality.
|
|
2276
|
+
* Fallback: the image with an approximate CSS filter.
|
|
2277
|
+
*/
|
|
2278
|
+
declare function definePostFx(tag?: string): CustomElementConstructor | undefined;
|
|
2279
|
+
|
|
2280
|
+
/**
|
|
2281
|
+
* 4.8 — WebGL preset library on `glQuad()`: particle presets (`snow`,
|
|
2282
|
+
* `fireflies`, `stars`, `bokeh`, `rain` — usable as `<usa-shader preset>`),
|
|
2283
|
+
* chainable post-processing passes for images (`<usa-post-fx>`), one CSS
|
|
2284
|
+
* fallback per preset, and an adaptive quality governor (fps + battery).
|
|
2285
|
+
*/
|
|
2286
|
+
declare const PARTICLE_PRESETS: readonly ["snow", "fireflies", "stars", "bokeh", "rain"];
|
|
2287
|
+
type ParticlePreset = (typeof PARTICLE_PRESETS)[number];
|
|
2288
|
+
/** Post-processing passes: `vec3 fx(vec3 c, vec2 uv)` bodies, applied in order. `u_intensity` 0–1. */
|
|
2289
|
+
declare const POST_EFFECTS: Record<string, string>;
|
|
2290
|
+
type PostEffect = keyof typeof POST_EFFECTS;
|
|
2291
|
+
/** One fragment shader running the passes in order over `u_tex` (pixel-sampling passes read the source). */
|
|
2292
|
+
declare function postFxShader(effects: string[]): string;
|
|
2293
|
+
/** The unified CSS fallback (no WebGL / reduced data): a still background or image filter per preset. */
|
|
2294
|
+
declare const GL_FALLBACKS: Record<string, string>;
|
|
2295
|
+
/** CSS fallback for a shader preset / post effect list. */
|
|
2296
|
+
declare function glFallbackCss(preset: string, post?: boolean): string;
|
|
2297
|
+
interface GLGovernorOptions {
|
|
2298
|
+
/** Below this fps quality drops (default 40). */
|
|
2299
|
+
minFps?: number;
|
|
2300
|
+
/** Frame-rate cap on battery saver / low battery (default 30). */
|
|
2301
|
+
saverFps?: number;
|
|
2302
|
+
}
|
|
2303
|
+
interface GLGovernor {
|
|
2304
|
+
/** Feed a frame time (ms); returns `true` when this frame should render. */
|
|
2305
|
+
tick(t: number): boolean;
|
|
2306
|
+
/** Current resolution scale (1 → 0.5 → 0.35). */
|
|
2307
|
+
readonly scale: number;
|
|
2308
|
+
/** Measured fps over the last second. */
|
|
2309
|
+
readonly fps: number;
|
|
2310
|
+
/** Battery saver / low battery: renders at `saverFps` and scale ≤ 0.6. */
|
|
2311
|
+
saver: boolean;
|
|
2312
|
+
/** Called when `scale` changes (resize the canvas). */
|
|
2313
|
+
onScale?: (scale: number) => void;
|
|
2314
|
+
}
|
|
2315
|
+
/**
|
|
2316
|
+
* Adaptive quality for GL loops: measures fps, steps the resolution scale
|
|
2317
|
+
* down (1 → 0.5 → 0.35) after two slow seconds and back up after five good
|
|
2318
|
+
* ones, and caps the frame rate in battery-saver mode. Pure — feed it times.
|
|
2319
|
+
*/
|
|
2320
|
+
declare function glGovernor(options?: GLGovernorOptions): GLGovernor;
|
|
2321
|
+
/** Watch the Battery Status API (where available) and Save-Data; calls `cb(true)` in saver conditions. Returns a stop function. */
|
|
2322
|
+
declare function watchPowerSaver(cb: (saver: boolean) => void): () => void;
|
|
2323
|
+
|
|
2324
|
+
/** Built-in fragment shaders (bodies; uniforms `u_time`, `u_resolution`, `u_mouse` 0–1, `u_hover` 0–1, `u_tex`, `u_ripples[4]` = x, y, age, strength). */
|
|
2325
|
+
declare const SHADERS: Record<string, string>;
|
|
2326
|
+
/** Full fragment source for a preset or custom body (adds the shared header). */
|
|
2327
|
+
declare function fragmentSource(body: string): string;
|
|
2328
|
+
declare function supportsWebGL(): boolean;
|
|
2329
|
+
interface GLQuad {
|
|
2330
|
+
/** Draw a frame with these uniform values (`extra`: any other float uniforms by name, 4.8). */
|
|
2331
|
+
render(u: {
|
|
2332
|
+
time?: number;
|
|
2333
|
+
mouse?: [number, number];
|
|
2334
|
+
hover?: number;
|
|
2335
|
+
ripples?: number[];
|
|
2336
|
+
extra?: Record<string, number>;
|
|
2337
|
+
}): void;
|
|
2338
|
+
/** Resize the drawing buffer to the canvas' CSS size × DPR (≤ 2) × `scale` (4.8 adaptive quality). */
|
|
2339
|
+
resize(scale?: number): void;
|
|
2340
|
+
/** Upload an image as `u_tex`. */
|
|
2341
|
+
texture(img: TexImageSource): void;
|
|
2342
|
+
dispose(): void;
|
|
2343
|
+
}
|
|
2344
|
+
/** Compile `frag` on a full-canvas quad, or `null` when WebGL / compilation is unavailable. */
|
|
2345
|
+
declare function glQuad(canvas: HTMLCanvasElement, frag: string): GLQuad | null;
|
|
2346
|
+
|
|
2347
|
+
/**
|
|
2348
|
+
* motionary/components/webgl — lightweight canvas / WebGL (v3.4).
|
|
2349
|
+
* `<usa-shader>` (shader backgrounds), `<usa-distort>` (hover image
|
|
2350
|
+
* distortion), `<usa-liquid>` (ripple images) on a tiny single-quad runner
|
|
2351
|
+
* (`glQuad()`), with graceful fallbacks when WebGL is unavailable.
|
|
2352
|
+
*/
|
|
2353
|
+
|
|
2354
|
+
/** Register every component of this category under its default tag. */
|
|
2355
|
+
declare function defineWebglComponents(): void;
|
|
2356
|
+
declare global {
|
|
2357
|
+
interface HTMLElementTagNameMap {
|
|
2358
|
+
'usa-shader': UsaGLElement;
|
|
2359
|
+
'usa-distort': UsaGLElement;
|
|
2360
|
+
'usa-liquid': UsaGLElement;
|
|
2361
|
+
'usa-post-fx': UsaGLElement;
|
|
2362
|
+
}
|
|
2363
|
+
}
|
|
2364
|
+
|
|
2365
|
+
/**
|
|
2366
|
+
* `<usa-cube>` — a CSS 3D cube whose up-to-six element children are its faces
|
|
2367
|
+
* (front, right, back, left, top, bottom). Rotate with drag / swipe, arrow
|
|
2368
|
+
* keys, `autoplay` (ms) or `show(face | index)`; spring-driven.
|
|
2369
|
+
* Attributes: `size` (px, 200), `autoplay`, `perspective` (900).
|
|
2370
|
+
* `usa:change` (`{ index, face }`). Reduced motion: instant face switch.
|
|
2371
|
+
*/
|
|
2372
|
+
interface UsaCubeElement extends UsaElement {
|
|
2373
|
+
readonly index: number;
|
|
2374
|
+
show(face: number | string): void;
|
|
2375
|
+
next(): void;
|
|
2376
|
+
prev(): void;
|
|
2377
|
+
}
|
|
2378
|
+
declare function defineCube(tag?: string): CustomElementConstructor | undefined;
|
|
2379
|
+
|
|
2380
|
+
/**
|
|
2381
|
+
* `<usa-depth>` — depth parallax: children with `data-depth` (-1…1, 0 = the
|
|
2382
|
+
* screen plane) move and scale by depth as the pointer moves, the device
|
|
2383
|
+
* tilts (`orientation`) or the page scrolls (`scroll`).
|
|
2384
|
+
* Attributes: `source` (`pointer` default · `orientation` · `scroll` ·
|
|
2385
|
+
* space-separated mix), `strength` (px at depth 1, 40), `rotate` (max tilt
|
|
2386
|
+
* of the whole scene in deg, 0). `requestPermission()` for iOS motion.
|
|
2387
|
+
* Reduced motion: layers stay flat.
|
|
2388
|
+
*/
|
|
2389
|
+
interface UsaDepthElement extends UsaElement {
|
|
2390
|
+
/** Current -1…1 input. */
|
|
2391
|
+
readonly tilt: {
|
|
2392
|
+
x: number;
|
|
2393
|
+
y: number;
|
|
2394
|
+
};
|
|
2395
|
+
requestPermission(): Promise<boolean>;
|
|
2396
|
+
}
|
|
2397
|
+
declare function defineDepth(tag?: string): CustomElementConstructor | undefined;
|
|
2398
|
+
|
|
2399
|
+
interface TiltReading {
|
|
2400
|
+
/** Left/right tilt, -1…1. */
|
|
2401
|
+
x: number;
|
|
2402
|
+
/** Front/back tilt, -1…1. */
|
|
2403
|
+
y: number;
|
|
2404
|
+
}
|
|
2405
|
+
/** Map a DeviceOrientation reading (beta/gamma degrees) to -1…1 tilt around a resting pose (pure). */
|
|
2406
|
+
declare function orientationToTilt(beta: number | null, gamma: number | null, range?: number, rest?: number): TiltReading;
|
|
2407
|
+
/** `true` when DeviceOrientation events exist. */
|
|
2408
|
+
declare const supportsOrientation: () => boolean;
|
|
2409
|
+
/**
|
|
2410
|
+
* Ask for motion-sensor permission where required (iOS 13+; must run inside
|
|
2411
|
+
* a user gesture). Resolves `true` when tilt events can be used.
|
|
2412
|
+
*/
|
|
2413
|
+
declare function requestOrientationPermission(): Promise<boolean>;
|
|
2414
|
+
/**
|
|
2415
|
+
* Listen to device tilt (smoothed); falls back to nothing on desktops.
|
|
2416
|
+
* Returns a stop function.
|
|
2417
|
+
*/
|
|
2418
|
+
declare function deviceTilt(cb: (t: TiltReading) => void, o?: {
|
|
2419
|
+
range?: number;
|
|
2420
|
+
smooth?: number;
|
|
2421
|
+
}): () => void;
|
|
2422
|
+
|
|
2423
|
+
/**
|
|
2424
|
+
* motionary/components/depth — 3D (v3.5).
|
|
2425
|
+
* `<usa-cube>` (CSS 3D cube), `<usa-depth>` (layered depth parallax driven by
|
|
2426
|
+
* pointer, device orientation or scroll) and `deviceTilt()`. The 3D ring
|
|
2427
|
+
* carousel is `<usa-carousel-3d>` in `components/cards`.
|
|
2428
|
+
*/
|
|
2429
|
+
|
|
2430
|
+
/** Register every component of this category under its default tag. */
|
|
2431
|
+
declare function defineDepthComponents(): void;
|
|
2432
|
+
declare global {
|
|
2433
|
+
interface HTMLElementTagNameMap {
|
|
2434
|
+
'usa-cube': UsaCubeElement;
|
|
2435
|
+
'usa-depth': UsaDepthElement;
|
|
2436
|
+
}
|
|
2437
|
+
}
|
|
2438
|
+
|
|
2439
|
+
/**
|
|
2440
|
+
* `<usa-auto-animate>` — wraps `autoAnimate()`: any change to its children
|
|
2441
|
+
* (add, remove, re-order, filter, size) animates. Attributes `duration`
|
|
2442
|
+
* (300), `no-scale`. Works for lists and CSS grids alike.
|
|
2443
|
+
*/
|
|
2444
|
+
interface UsaAutoAnimateElement extends UsaElement {
|
|
2445
|
+
enable(): void;
|
|
2446
|
+
disable(): void;
|
|
2447
|
+
}
|
|
2448
|
+
declare function defineAutoAnimate(tag?: string): CustomElementConstructor | undefined;
|
|
2449
|
+
/**
|
|
2450
|
+
* `<usa-masonry>` — a masonry (Pinterest-style) grid: children are placed in
|
|
2451
|
+
* the shortest column and glide to new spots when the width, the items or
|
|
2452
|
+
* their sizes change. Attributes `columns` (fixed count) or `min` (min
|
|
2453
|
+
* column width px, 220), `gap` (16). Without JS layout support it is a
|
|
2454
|
+
* plain CSS multi-column flow. Reduced motion: no glide.
|
|
2455
|
+
*/
|
|
2456
|
+
interface UsaMasonryElement extends UsaElement {
|
|
2457
|
+
layout(): void;
|
|
2458
|
+
}
|
|
2459
|
+
declare function defineMasonry(tag?: string): CustomElementConstructor | undefined;
|
|
2460
|
+
|
|
2461
|
+
type Box = {
|
|
2462
|
+
left: number;
|
|
2463
|
+
top: number;
|
|
2464
|
+
width: number;
|
|
2465
|
+
height: number;
|
|
2466
|
+
};
|
|
2467
|
+
/** FLIP keyframes from a previous box to the current one (pure). */
|
|
2468
|
+
declare function flipFrames(from: Box, to: Box, scale?: boolean): Keyframe[];
|
|
2469
|
+
interface AutoAnimateOptions {
|
|
2470
|
+
duration?: number;
|
|
2471
|
+
easing?: string;
|
|
2472
|
+
/** Also animate size changes (default true). */
|
|
2473
|
+
scale?: boolean;
|
|
2474
|
+
}
|
|
2475
|
+
/**
|
|
2476
|
+
* Auto-animate a container: children that are added fade / scale in, removed
|
|
2477
|
+
* ones fade out in place, and moved ones (re-sort, filter, reflow, resize)
|
|
2478
|
+
* glide to their new spot — no extra code at the call site. Returns
|
|
2479
|
+
* `{ disable, enable, stop }`. Reduced motion: changes apply instantly.
|
|
2480
|
+
*
|
|
2481
|
+
* @example
|
|
2482
|
+
* const ctl = autoAnimate(document.querySelector('ul'));
|
|
2483
|
+
* list.append(item); // animates
|
|
2484
|
+
*/
|
|
2485
|
+
declare function autoAnimate(parent: HTMLElement, o?: AutoAnimateOptions): {
|
|
2486
|
+
enable(): void;
|
|
2487
|
+
disable(): void;
|
|
2488
|
+
stop(): void;
|
|
2489
|
+
};
|
|
2490
|
+
/** Masonry placement: shortest-column-first positions for item heights (pure). */
|
|
2491
|
+
declare function masonryLayout(heights: number[], columns: number, columnWidth: number, gap: number): {
|
|
2492
|
+
x: number;
|
|
2493
|
+
y: number;
|
|
2494
|
+
}[] & {
|
|
2495
|
+
height?: number;
|
|
2496
|
+
};
|
|
2497
|
+
interface SharedOptions {
|
|
2498
|
+
duration?: number;
|
|
2499
|
+
easing?: string;
|
|
2500
|
+
}
|
|
2501
|
+
/**
|
|
2502
|
+
* Shared-element transition between two states of the page: every element
|
|
2503
|
+
* with `data-shared="id"` before `update()` flies to the element with the
|
|
2504
|
+
* same id afterwards (size and position), the rest cross-fades. Uses the
|
|
2505
|
+
* View Transitions API when present (with `view-transition-name` per id),
|
|
2506
|
+
* otherwise a FLIP fallback. Reduced motion: just runs `update()`.
|
|
2507
|
+
*/
|
|
2508
|
+
declare function sharedTransition(update: () => void | Promise<void>, root?: ParentNode, o?: SharedOptions): Promise<void>;
|
|
2509
|
+
|
|
2510
|
+
/**
|
|
2511
|
+
* motionary/components/layout — layout animation (v3.6).
|
|
2512
|
+
* `autoAnimate()` / `<usa-auto-animate>` (list & grid reflow),
|
|
2513
|
+
* `<usa-masonry>`, and `sharedTransition()` for shared-element transitions
|
|
2514
|
+
* (View Transitions API with a FLIP fallback).
|
|
2515
|
+
*/
|
|
2516
|
+
|
|
2517
|
+
/** Register every component of this category under its default tag. */
|
|
2518
|
+
declare function defineLayoutComponents(): void;
|
|
2519
|
+
declare global {
|
|
2520
|
+
interface HTMLElementTagNameMap {
|
|
2521
|
+
'usa-auto-animate': UsaAutoAnimateElement;
|
|
2522
|
+
'usa-masonry': UsaMasonryElement;
|
|
2523
|
+
}
|
|
2524
|
+
}
|
|
2525
|
+
|
|
2526
|
+
/**
|
|
2527
|
+
* `<usa-pack name="ecommerce">` — applies an effect pack (`ecommerce` ·
|
|
2528
|
+
* `portfolio` · `dashboard` · `game` · `landing`) to its subtree:
|
|
2529
|
+
* descendants opt in with `data-role` (see `PACKS`). Re-applies when
|
|
2530
|
+
* `name` changes; undone on disconnect.
|
|
2531
|
+
*/
|
|
2532
|
+
interface UsaPackElement extends UsaElement {
|
|
2533
|
+
readonly roles: string[];
|
|
2534
|
+
}
|
|
2535
|
+
declare function definePack(tag?: string): CustomElementConstructor | undefined;
|
|
2536
|
+
|
|
2537
|
+
type Cleanup = () => void;
|
|
2538
|
+
interface PackContext {
|
|
2539
|
+
root: HTMLElement;
|
|
2540
|
+
/** Index of the element among those with the same role (for staggering). */
|
|
2541
|
+
index: number;
|
|
2542
|
+
reduced: boolean;
|
|
2543
|
+
}
|
|
2544
|
+
/** Count `el`'s number up from 0 when it enters the view (keeps prefix / suffix / decimals). */
|
|
2545
|
+
declare function countUp(el: HTMLElement, duration?: number): Cleanup;
|
|
2546
|
+
/**
|
|
2547
|
+
* Fly a copy of `from` (e.g. a product image) into `to` (the cart icon) along
|
|
2548
|
+
* an arc, then bump the target. Resolves when it lands. Instant under
|
|
2549
|
+
* reduced motion (only the bump's state change, no flight).
|
|
2550
|
+
*/
|
|
2551
|
+
declare function flyToCart(from: Element, to: Element, o?: {
|
|
2552
|
+
duration?: number;
|
|
2553
|
+
}): Promise<void>;
|
|
2554
|
+
/** The five effect packs: `data-role` → primitives. */
|
|
2555
|
+
declare const PACKS: Record<string, Record<string, string[]>>;
|
|
2556
|
+
type PackName = keyof typeof PACKS;
|
|
2557
|
+
/**
|
|
2558
|
+
* Apply an effect pack to `root`: every descendant with a `data-role` the
|
|
2559
|
+
* pack knows gets its effects (staggered by index). Returns an undo function.
|
|
2560
|
+
* Reduced motion: only non-motion behaviour (e.g. the cart event) remains.
|
|
2561
|
+
*
|
|
2562
|
+
* @example
|
|
2563
|
+
* applyPack('ecommerce', document.querySelector('main'));
|
|
2564
|
+
* // <article data-role="product">… <button data-role="add-to-cart"> … <a data-role="cart">
|
|
2565
|
+
*/
|
|
2566
|
+
declare function applyPack(name: PackName | string, root?: HTMLElement | Document): Cleanup;
|
|
2567
|
+
/** Primitive names a pack uses (for docs / tooling). */
|
|
2568
|
+
declare const PACK_PRIMITIVES: string[];
|
|
2569
|
+
|
|
2570
|
+
/**
|
|
2571
|
+
* motionary/components/packs — effect packs (v3.9).
|
|
2572
|
+
* Ready-made motion for e-commerce, portfolio, dashboard, game UI and
|
|
2573
|
+
* landing pages: mark elements with `data-role` and apply a pack with
|
|
2574
|
+
* `<usa-pack name="…">` or `applyPack(name, root)`. Includes `flyToCart()`
|
|
2575
|
+
* and `countUp()`.
|
|
2576
|
+
*/
|
|
2577
|
+
|
|
2578
|
+
/** Register every component of this category under its default tag. */
|
|
2579
|
+
declare function definePacksComponents(): void;
|
|
2580
|
+
declare global {
|
|
2581
|
+
interface HTMLElementTagNameMap {
|
|
2582
|
+
'usa-pack': UsaPackElement;
|
|
2583
|
+
}
|
|
2584
|
+
}
|
|
2585
|
+
|
|
2586
|
+
/**
|
|
2587
|
+
* motionary/components/tokens — motion design tokens (4.2).
|
|
2588
|
+
*
|
|
2589
|
+
* One source of truth for durations, easings and springs: as CSS custom
|
|
2590
|
+
* properties (`--usa-duration-fast`, `--usa-easing-emphasized`,
|
|
2591
|
+
* `--usa-spring-bouncy-stiffness`…), as W3C Design Tokens JSON, and importable
|
|
2592
|
+
* from Figma Tokens (Tokens Studio) or Style Dictionary exports.
|
|
2593
|
+
*
|
|
2594
|
+
* ```ts
|
|
2595
|
+
* import { applyMotionTokens, importMotionTokens, motionToken } from 'motionary/components/tokens';
|
|
2596
|
+
* applyMotionTokens(importMotionTokens(await (await fetch('/tokens.json')).json()));
|
|
2597
|
+
* el.animate(frames, { duration: motionToken('duration', 'slow'), easing: motionToken('easing', 'emphasized') });
|
|
2598
|
+
* ```
|
|
2599
|
+
*/
|
|
2600
|
+
interface SpringToken {
|
|
2601
|
+
stiffness: number;
|
|
2602
|
+
damping: number;
|
|
2603
|
+
mass: number;
|
|
2604
|
+
}
|
|
2605
|
+
interface MotionTokens {
|
|
2606
|
+
/** Durations in ms. */
|
|
2607
|
+
duration: Record<string, number>;
|
|
2608
|
+
/** CSS easing strings. */
|
|
2609
|
+
easing: Record<string, string>;
|
|
2610
|
+
/** Spring physics parameters. */
|
|
2611
|
+
spring: Record<string, SpringToken>;
|
|
2612
|
+
}
|
|
2613
|
+
/** The default motion scale (Material / Fluent-inspired). */
|
|
2614
|
+
declare const MOTION_TOKENS: MotionTokens;
|
|
2615
|
+
type MotionTokenGroup = keyof MotionTokens;
|
|
2616
|
+
type DeepPartialTokens = {
|
|
2617
|
+
[K in keyof MotionTokens]?: Partial<MotionTokens[K]>;
|
|
2618
|
+
};
|
|
2619
|
+
/** Merge partial tokens over a base (defaults: the built-in scale). */
|
|
2620
|
+
declare function mergeMotionTokens(partial: DeepPartialTokens, base?: MotionTokens): MotionTokens;
|
|
2621
|
+
/** The custom-property map: `{ '--usa-duration-fast': '150ms', … }`. */
|
|
2622
|
+
declare function motionTokensToVars(tokens?: MotionTokens, prefix?: string): Record<string, string>;
|
|
2623
|
+
/** A stylesheet string: `:root { --usa-duration-fast: 150ms; … }`. */
|
|
2624
|
+
declare function motionTokensToCss(tokens?: MotionTokens, selector?: string, prefix?: string): string;
|
|
2625
|
+
/** W3C Design Tokens (DTCG) JSON: `{ motion: { duration: { fast: { $type: 'duration', $value: '150ms' } } } }`. */
|
|
2626
|
+
declare function motionTokensToJSON(tokens?: MotionTokens): Record<string, unknown>;
|
|
2627
|
+
/** Parse `150ms`, `0.15s`, `150` → ms. */
|
|
2628
|
+
declare function parseDuration(v: unknown): number | undefined;
|
|
2629
|
+
/** Parse `[x1,y1,x2,y2]`, `'cubic-bezier(…)'`, `'0.2, 0, 0, 1'` or a keyword → CSS easing. */
|
|
2630
|
+
declare function parseEasing(v: unknown): string | undefined;
|
|
2631
|
+
/**
|
|
2632
|
+
* Import tokens from W3C DTCG JSON, Figma Tokens / Tokens Studio
|
|
2633
|
+
* (`{ value, type }`) or Style Dictionary (`{ value }`, nested) — anything
|
|
2634
|
+
* under a `duration` / `easing` / `spring` group (any depth, e.g.
|
|
2635
|
+
* `motion.duration.fast` or `global.animation.easing.out`), or typed leaves
|
|
2636
|
+
* (`duration`, `cubicBezier`, `transition`, `spring`). Unknown values are
|
|
2637
|
+
* skipped; the result is merged over the defaults.
|
|
2638
|
+
*/
|
|
2639
|
+
declare function importMotionTokens(json: unknown, base?: MotionTokens): MotionTokens;
|
|
2640
|
+
/** The tokens currently applied (via `applyMotionTokens`), or the defaults. */
|
|
2641
|
+
declare function getMotionTokens(): MotionTokens;
|
|
2642
|
+
/**
|
|
2643
|
+
* Write tokens as CSS custom properties on `root` (default `<html>`) and make
|
|
2644
|
+
* them the active set for `motionToken()`. Returns an undo function.
|
|
2645
|
+
*/
|
|
2646
|
+
declare function applyMotionTokens(tokens?: DeepPartialTokens | MotionTokens, root?: HTMLElement, prefix?: string): () => void;
|
|
2647
|
+
/** Look up a token: `motionToken('duration', 'fast')` → `150`; `motionToken('easing', 'emphasized')` → CSS easing. */
|
|
2648
|
+
declare function motionToken(group: 'duration', name: string): number;
|
|
2649
|
+
declare function motionToken(group: 'easing', name: string): string;
|
|
2650
|
+
declare function motionToken(group: 'spring', name: string): SpringToken;
|
|
2651
|
+
/** `var(--usa-duration-fast, 150ms)` — a CSS reference with the current value as fallback. */
|
|
2652
|
+
declare function motionVar(group: MotionTokenGroup, name: string, prop?: 'stiffness' | 'damping' | 'mass', prefix?: string): string;
|
|
2653
|
+
/** Resolve a duration that may be a token name (`'fast'`) or ms. */
|
|
2654
|
+
declare function resolveDurationToken(v: number | string | undefined, fallback: number): number;
|
|
2655
|
+
/** Resolve an easing that may be a token name (`'emphasized'`) or CSS. */
|
|
2656
|
+
declare function resolveEasingToken(v: string | undefined, fallback: string): string;
|
|
2657
|
+
|
|
2658
|
+
/** The component categories and their default tags. */
|
|
2659
|
+
declare const COMPONENT_CATEGORIES: {
|
|
2660
|
+
readonly reveal: readonly ["usa-reveal", "usa-stagger", "usa-scroll-progress", "usa-scrolly"];
|
|
2661
|
+
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"];
|
|
2662
|
+
readonly interaction: readonly ["usa-ripple", "usa-magnetic", "usa-tilt", "usa-spotlight", "usa-press", "usa-toggle"];
|
|
2663
|
+
readonly feedback: readonly ["usa-spinner", "usa-skeleton", "usa-progress", "usa-toaster", "usa-check"];
|
|
2664
|
+
readonly background: readonly ["usa-aurora", "usa-particles", "usa-grain", "usa-marquee", "usa-acrylic", "usa-grid-glow", "usa-blobs", "usa-water-ripple", "usa-dot-network"];
|
|
2665
|
+
readonly transitions: readonly ["usa-dialog", "usa-accordion", "usa-view-switch"];
|
|
2666
|
+
readonly physics: readonly ["usa-spring", "usa-draggable", "usa-overscroll"];
|
|
2667
|
+
readonly cards: readonly ["usa-card", "usa-card-stack", "usa-sticky-stack", "usa-carousel-3d"];
|
|
2668
|
+
readonly click: readonly ["usa-click", "usa-button", "usa-icon-morph", "usa-like", "usa-hold", "usa-double-tap", "usa-checkbox"];
|
|
2669
|
+
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"];
|
|
2670
|
+
readonly page: readonly ["usa-cursor", "usa-fullpage", "usa-loading-bar", "usa-back-to-top", "usa-ambient", "usa-splash", "usa-auto-skeleton", "usa-motion-switch"];
|
|
2671
|
+
readonly timeline: readonly ["usa-timeline"];
|
|
2672
|
+
readonly gesture: readonly ["usa-swipeable", "usa-pinch-zoom"];
|
|
2673
|
+
readonly svg: readonly ["usa-draw", "usa-morph", "usa-mask-reveal", "usa-anim-icon"];
|
|
2674
|
+
readonly webgl: readonly ["usa-shader", "usa-distort", "usa-liquid", "usa-post-fx"];
|
|
2675
|
+
readonly depth: readonly ["usa-cube", "usa-depth"];
|
|
2676
|
+
readonly layout: readonly ["usa-auto-animate", "usa-masonry"];
|
|
2677
|
+
readonly packs: readonly ["usa-pack"];
|
|
2678
|
+
readonly fx: readonly ["usa-fx"];
|
|
2679
|
+
};
|
|
2680
|
+
type ComponentCategory = keyof typeof COMPONENT_CATEGORIES;
|
|
2681
|
+
|
|
2682
|
+
interface BaselineFeature {
|
|
2683
|
+
id: string;
|
|
2684
|
+
required: boolean;
|
|
2685
|
+
supported: boolean;
|
|
2686
|
+
}
|
|
2687
|
+
/** Required in 5.0: Custom Elements, WAAPI, IntersectionObserver, ResizeObserver, adoptedStyleSheets. Progressive: View Transitions, scroll-driven animations, WebGL. */
|
|
2688
|
+
declare function baselineReport(): BaselineFeature[];
|
|
2689
|
+
/** Log (once) which required 5.0 features are missing here. Returns the missing ids. */
|
|
2690
|
+
declare function warnBaseline(): string[];
|
|
2691
|
+
|
|
2692
|
+
/**
|
|
2693
|
+
* motionary/components/a11y — accessibility toolkit (4.4).
|
|
2694
|
+
*
|
|
2695
|
+
* - Motion-sensitivity levels: `setMotionSensitivity('full' | 'gentle' | 'minimal' | 'static')`.
|
|
2696
|
+
* - Static alternatives: what every component shows when motion is off, and
|
|
2697
|
+
* `staticAlternative(root)` to freeze any subtree at its final state.
|
|
2698
|
+
* - `aria-live` conventions: one shared polite and one assertive region,
|
|
2699
|
+
* `announce(message, { politeness })`.
|
|
2700
|
+
* - `auditMotionA11y(root)`: the rules the automated regression tests run
|
|
2701
|
+
* over every `<usa-*>` element — usable in your own tests too.
|
|
2702
|
+
*
|
|
2703
|
+
* ```ts
|
|
2704
|
+
* import { setMotionSensitivity, announce, auditMotionA11y } from 'motionary/components/a11y';
|
|
2705
|
+
* setMotionSensitivity('gentle', true); // no spins / zooms / parallax, remembered
|
|
2706
|
+
* announce('3 items added to cart'); // polite live region
|
|
2707
|
+
* expect(auditMotionA11y(document.body).errors).toEqual([]);
|
|
2708
|
+
* ```
|
|
2709
|
+
*/
|
|
2710
|
+
|
|
2711
|
+
/** What each level allows, for docs and settings UIs. */
|
|
2712
|
+
declare const MOTION_SENSITIVITY: Record<MotionSensitivity, {
|
|
2713
|
+
en: string;
|
|
2714
|
+
zh: string;
|
|
2715
|
+
allows: string[];
|
|
2716
|
+
}>;
|
|
2717
|
+
/** CSS applied at the `static` / `minimal` / `gentle` levels (also stops your own CSS animations under `static`). */
|
|
2718
|
+
declare const SENSITIVITY_CSS: string;
|
|
2719
|
+
/**
|
|
2720
|
+
* Set the motion-sensitivity level for every `<usa-*>` component and the page:
|
|
2721
|
+
* sets `data-usa-sensitivity` on `<html>`, adapts component keyframes, and
|
|
2722
|
+
* with `persist` remembers the choice (`restoreMotionSensitivity()`).
|
|
2723
|
+
* Dispatches `usa:sensitivity` on `document`.
|
|
2724
|
+
*/
|
|
2725
|
+
declare function setMotionSensitivity(level: MotionSensitivity, persist?: boolean): void;
|
|
2726
|
+
/** Re-apply a persisted level (call early on page load). Returns the active level. */
|
|
2727
|
+
declare function restoreMotionSensitivity(): MotionSensitivity;
|
|
2728
|
+
/** `true` when the current level allows a kind of motion (`'rotate'`, `'parallax'`, `'loop'`…). */
|
|
2729
|
+
declare function motionAllowed(kind: string, level?: MotionSensitivity): boolean;
|
|
2730
|
+
/** The static alternative of each category: what its elements show without motion. */
|
|
2731
|
+
declare const STATIC_ALTERNATIVES: Record<ComponentCategory, string>;
|
|
2732
|
+
/**
|
|
2733
|
+
* Freeze a subtree at its static alternative: finishes running animations
|
|
2734
|
+
* (`finish()`, so content lands on its final state), marks the root with
|
|
2735
|
+
* `data-usa-static` and returns an undo that removes the mark.
|
|
2736
|
+
*/
|
|
2737
|
+
declare function staticAlternative(root: Element): () => void;
|
|
2738
|
+
type Politeness = 'polite' | 'assertive';
|
|
2739
|
+
/** The ids of the shared live regions. */
|
|
2740
|
+
declare const LIVE_REGION_IDS: Record<Politeness, string>;
|
|
2741
|
+
/** The shared live region (created once, visually hidden, `role="status"` / `role="alert"`). */
|
|
2742
|
+
declare function liveRegion(politeness?: Politeness): HTMLElement | null;
|
|
2743
|
+
/**
|
|
2744
|
+
* Announce a message through the shared live region. Conventions: `polite`
|
|
2745
|
+
* for results of the user's own actions (added, saved, copied), `assertive`
|
|
2746
|
+
* only for errors that block them. Identical messages within `dedupe` ms
|
|
2747
|
+
* (default 500) are dropped; the region is cleared first so repeats are read.
|
|
2748
|
+
*/
|
|
2749
|
+
declare function announce(message: string, options?: {
|
|
2750
|
+
politeness?: Politeness;
|
|
2751
|
+
dedupe?: number;
|
|
2752
|
+
}): boolean;
|
|
2753
|
+
interface A11yIssue {
|
|
2754
|
+
rule: string;
|
|
2755
|
+
level: 'error' | 'warning';
|
|
2756
|
+
element: Element;
|
|
2757
|
+
message: string;
|
|
2758
|
+
}
|
|
2759
|
+
/**
|
|
2760
|
+
* Check a subtree against the library's motion-a11y rules:
|
|
2761
|
+
* - `aria-hidden-focusable` (error): focusable content inside `aria-hidden`.
|
|
2762
|
+
* - `role-name` (error): a widget role without an accessible name.
|
|
2763
|
+
* - `range-value` (error): a slider / determinate progressbar without `aria-valuenow`.
|
|
2764
|
+
* - `img-alt` (error): an `<img>` without `alt`.
|
|
2765
|
+
* - `assertive-live` (warning): `aria-live="assertive"` outside `role="alert"`.
|
|
2766
|
+
* - `infinite-no-control` (warning, WCAG 2.2.2): an endless animation on a
|
|
2767
|
+
* page with no way to pause motion (`<usa-motion-switch>` or `[data-usa-pause]`).
|
|
2768
|
+
*/
|
|
2769
|
+
declare function auditMotionA11y(root: Element | Document): {
|
|
2770
|
+
errors: A11yIssue[];
|
|
2771
|
+
warnings: A11yIssue[];
|
|
2772
|
+
};
|
|
2773
|
+
/** Every `<usa-*>` tag, for sweeping audits. */
|
|
2774
|
+
declare const ALL_TAGS: string[];
|
|
2775
|
+
|
|
2776
|
+
/**
|
|
2777
|
+
* motionary/components/perf — performance toolkit (4.5).
|
|
2778
|
+
*
|
|
2779
|
+
* - One shared rAF scheduler for every component loop (`onFrame()`, `schedulerStats()`).
|
|
2780
|
+
* - Animation budget: `setAnimationBudget(n)` caps concurrent component
|
|
2781
|
+
* animations; extra ones land on their final frame.
|
|
2782
|
+
* - `autoDegrade()`: watches frame rate and animation count and steps motion
|
|
2783
|
+
* down (`low`, then a tighter budget) while the device struggles, restoring
|
|
2784
|
+
* it when frames recover.
|
|
2785
|
+
* - On-demand CSS: `loadCategoryStyles()` / `onDemandStyles()` — used by
|
|
2786
|
+
* `motionary/components/lite`, the build without inlined CSS.
|
|
2787
|
+
*/
|
|
2788
|
+
|
|
2789
|
+
interface AutoDegradeOptions {
|
|
2790
|
+
/** Frame rate below which motion is degraded (default 45). */
|
|
2791
|
+
minFps?: number;
|
|
2792
|
+
/** Concurrent animations above which motion is degraded (default 40). */
|
|
2793
|
+
maxActive?: number;
|
|
2794
|
+
/** Sample window in ms (default 1000). */
|
|
2795
|
+
sample?: number;
|
|
2796
|
+
/** Bad samples in a row before degrading (default 2). */
|
|
2797
|
+
patience?: number;
|
|
2798
|
+
/** Good samples in a row before restoring (default 3). */
|
|
2799
|
+
recovery?: number;
|
|
2800
|
+
/** Called on every change. */
|
|
2801
|
+
onChange?: (state: DegradeState) => void;
|
|
2802
|
+
}
|
|
2803
|
+
interface DegradeState {
|
|
2804
|
+
degraded: boolean;
|
|
2805
|
+
fps: number;
|
|
2806
|
+
active: number;
|
|
2807
|
+
reason: '' | 'fps' | 'count';
|
|
2808
|
+
}
|
|
2809
|
+
/**
|
|
2810
|
+
* Watch frame rate and animation count; while the device struggles, set
|
|
2811
|
+
* motion intensity to `low` and cap concurrent animations at `maxActive / 2`,
|
|
2812
|
+
* then restore the previous settings once frames recover. Dispatches
|
|
2813
|
+
* `usa:degrade` on `document`. Returns a stop function (restores settings).
|
|
2814
|
+
*/
|
|
2815
|
+
declare function autoDegrade(options?: AutoDegradeOptions): () => void;
|
|
2816
|
+
/** The category of a default `<usa-*>` tag. */
|
|
2817
|
+
declare const categoryOf: (tag: string) => ComponentCategory | undefined;
|
|
2818
|
+
/**
|
|
2819
|
+
* Add `<link rel="stylesheet" href="{base}components/{category}.css">` once.
|
|
2820
|
+
* `base` is the URL of the package's `dist/` folder.
|
|
2821
|
+
*/
|
|
2822
|
+
declare function loadCategoryStyles(category: ComponentCategory | 'all', base: string): HTMLLinkElement | null;
|
|
2823
|
+
/**
|
|
2824
|
+
* Load each category's CSS the first time one of its elements connects
|
|
2825
|
+
* (custom tags fall back to the full stylesheet). Returns an undo.
|
|
2826
|
+
*/
|
|
2827
|
+
declare function onDemandStyles(base: string): () => void;
|
|
2828
|
+
/** Categories whose CSS has been requested so far. */
|
|
2829
|
+
declare const loadedStyles: () => string[];
|
|
2830
|
+
|
|
2831
|
+
/**
|
|
2832
|
+
* motionary/components/bridge — native shell bridges (4.7).
|
|
2833
|
+
*
|
|
2834
|
+
* Keeps the web UI in sync with the host app's system settings when it runs
|
|
2835
|
+
* inside **WinUI 3 / WPF (WebView2)**, **.NET MAUI** (WebView / HybridWebView)
|
|
2836
|
+
* or **Flutter** (webview_flutter / flutter_inappwebview): the native side
|
|
2837
|
+
* sends "reduce motion", light / dark / high-contrast theme and accent color;
|
|
2838
|
+
* the page applies them to every `<usa-*>` component.
|
|
2839
|
+
*
|
|
2840
|
+
* Protocol (JSON, both directions):
|
|
2841
|
+
* - native → web `{ "type": "usa:settings", "reducedMotion": true, "theme": "dark", "accent": "#0078d4", "sensitivity": "gentle" }`
|
|
2842
|
+
* - web → native `{ "type": "usa:ready", "version": 1 }` on connect, `{ "type": "usa:request-settings" }`
|
|
2843
|
+
*
|
|
2844
|
+
* Hosts that can only run script call `window.usaNative.apply({...})`.
|
|
2845
|
+
* Samples: examples/native/{winui3,maui,flutter}.
|
|
2846
|
+
*/
|
|
2847
|
+
|
|
2848
|
+
type NativeHost = 'webview2' | 'maui' | 'flutter' | 'electron' | 'tauri' | 'browser';
|
|
2849
|
+
type NativeTheme = 'light' | 'dark' | 'high-contrast';
|
|
2850
|
+
interface NativeSettings {
|
|
2851
|
+
reducedMotion?: boolean;
|
|
2852
|
+
theme?: NativeTheme;
|
|
2853
|
+
/** CSS color (`#0078d4`, `rgb(…)`). */
|
|
2854
|
+
accent?: string;
|
|
2855
|
+
/** Optional finer level (4.4). */
|
|
2856
|
+
sensitivity?: MotionSensitivity;
|
|
2857
|
+
}
|
|
2858
|
+
interface NativeShellOptions {
|
|
2859
|
+
/** Element that gets `data-theme` / `color-scheme` / `--usa-accent` (default `<html>`). */
|
|
2860
|
+
root?: HTMLElement;
|
|
2861
|
+
/** Flutter JavaScriptChannel name (default `UsaBridge`). */
|
|
2862
|
+
channel?: string;
|
|
2863
|
+
/** Called after settings are applied. */
|
|
2864
|
+
onSettings?: (settings: NativeSettings, host: NativeHost) => void;
|
|
2865
|
+
}
|
|
2866
|
+
declare const BRIDGE_PROTOCOL_VERSION = 1;
|
|
2867
|
+
/** Which native shell (if any) hosts this page. */
|
|
2868
|
+
declare function detectNativeHost(channel?: string): NativeHost;
|
|
2869
|
+
/** Send a JSON message to the native host (no-op in a plain browser). Returns whether it was sent. */
|
|
2870
|
+
declare function postToNative(message: Record<string, unknown>, channel?: string): boolean;
|
|
2871
|
+
/** Validate an incoming message (string or object); unknown fields are dropped. */
|
|
2872
|
+
declare function parseNativeSettings(data: unknown): NativeSettings | null;
|
|
2873
|
+
/**
|
|
2874
|
+
* Apply native settings: reduce motion → `configureComponents({ reducedMotion: 'reduce' })`
|
|
2875
|
+
* (`false` → follow the media query again); theme → `data-theme`, `data-usa-contrast`
|
|
2876
|
+
* and `color-scheme`; accent → `--usa-accent`; sensitivity → `motionSensitivity`.
|
|
2877
|
+
*/
|
|
2878
|
+
declare function applyNativeSettings(s: NativeSettings, root?: HTMLElement): void;
|
|
2879
|
+
/**
|
|
2880
|
+
* Connect to the native shell: listens for `usa:settings` messages
|
|
2881
|
+
* (WebView2 `chrome.webview` messages, `window.postMessage`, or
|
|
2882
|
+
* `window.usaNative.apply()`), applies them, then announces `usa:ready` and
|
|
2883
|
+
* asks for the current settings. Returns `{ host, disconnect }`.
|
|
2884
|
+
*/
|
|
2885
|
+
declare function connectNativeShell(options?: NativeShellOptions): {
|
|
2886
|
+
host: NativeHost;
|
|
2887
|
+
disconnect: () => void;
|
|
2888
|
+
};
|
|
2889
|
+
|
|
2890
|
+
/**
|
|
2891
|
+
* `<usa-fx effect="pop" trigger="click">` — plays any registered effect
|
|
2892
|
+
* (`registerEffect()`) on its first element child (or itself with `self`).
|
|
2893
|
+
* `trigger`: `click` (default) · `hover` · `enter` · `load` · `loop` · `manual`;
|
|
2894
|
+
* `options` (JSON) is passed to the effect; `once`. Method `play()`.
|
|
2895
|
+
*/
|
|
2896
|
+
interface UsaFxElement extends UsaElement {
|
|
2897
|
+
readonly target: HTMLElement;
|
|
2898
|
+
play(): Promise<void>;
|
|
2899
|
+
}
|
|
2900
|
+
declare function defineFx(tag?: string): CustomElementConstructor | undefined;
|
|
2901
|
+
|
|
2902
|
+
/**
|
|
2903
|
+
* 5.0 — unified plugin-style effect registration. Every effect (built-in or
|
|
2904
|
+
* yours) is a plain object registered once and played the same way:
|
|
2905
|
+
* `playEffect(el, name)`, `bindEffect(el, name, { trigger })` or
|
|
2906
|
+
* `<usa-fx effect="name" trigger="click">`. Effects get a context that
|
|
2907
|
+
* already applies reduced motion, motion sensitivity, intensity and the
|
|
2908
|
+
* animation budget.
|
|
2909
|
+
*/
|
|
2910
|
+
|
|
2911
|
+
declare const EFFECT_KINDS: readonly ["enter", "exit", "attention", "click", "hover", "card", "loop", "page", "background", "text", "cursor", "scroll"];
|
|
2912
|
+
type EffectKind = (typeof EFFECT_KINDS)[number];
|
|
2913
|
+
declare const EFFECT_TRIGGERS: readonly ["click", "hover", "enter", "load", "loop", "manual"];
|
|
2914
|
+
type EffectTrigger = (typeof EFFECT_TRIGGERS)[number];
|
|
2915
|
+
interface EffectContext {
|
|
2916
|
+
/** Reduced motion applies (OS setting, `minimal` / `static` sensitivity). */
|
|
2917
|
+
readonly reduced: boolean;
|
|
2918
|
+
readonly sensitivity: MotionSensitivity;
|
|
2919
|
+
/** The triggering event (pointer position for click effects), if any. */
|
|
2920
|
+
readonly event?: Event;
|
|
2921
|
+
/** `el.animate()` with the library's motion rules (may return `null`). */
|
|
2922
|
+
animate(el: Element, keyframes: Keyframe[], options: KeyframeAnimationOptions): Animation | null;
|
|
2923
|
+
/** Register teardown for long-running effects (loops, listeners). */
|
|
2924
|
+
onCleanup(fn: Cleanup$1): void;
|
|
2925
|
+
}
|
|
2926
|
+
interface EffectDefinition<O extends Record<string, unknown> = Record<string, any>> {
|
|
2927
|
+
/** Unique, kebab-case. */
|
|
2928
|
+
name: string;
|
|
2929
|
+
kind: EffectKind;
|
|
2930
|
+
/** One line for docs and the gallery. */
|
|
2931
|
+
description?: string;
|
|
2932
|
+
/** Option defaults (merged under the caller's options). */
|
|
2933
|
+
defaults?: Partial<O>;
|
|
2934
|
+
/**
|
|
2935
|
+
* Under reduced motion: `'skip'` (do nothing — default for loop, background
|
|
2936
|
+
* and cursor effects) or `'run'` (run with `ctx.reduced === true`, the
|
|
2937
|
+
* effect degrades itself — default for everything else).
|
|
2938
|
+
*/
|
|
2939
|
+
reduced?: 'skip' | 'run';
|
|
2940
|
+
/** Play the effect. Return an Animation / Promise to be awaited, or a cleanup. */
|
|
2941
|
+
run(el: HTMLElement, options: O, ctx: EffectContext): void | Cleanup$1 | Animation | null | Promise<unknown>;
|
|
2942
|
+
}
|
|
2943
|
+
/** Register an effect (throws on a duplicate name unless `override`). Returns an unregister function. */
|
|
2944
|
+
declare function registerEffect<O extends Record<string, unknown>>(def: EffectDefinition<O>, opts?: {
|
|
2945
|
+
override?: boolean;
|
|
2946
|
+
}): () => void;
|
|
2947
|
+
/** Register several effects at once (already-registered names are skipped). */
|
|
2948
|
+
declare function registerEffects(defs: EffectDefinition<any>[]): void;
|
|
2949
|
+
declare const getEffect: (name: string) => EffectDefinition | undefined;
|
|
2950
|
+
declare const hasEffect: (name: string) => boolean;
|
|
2951
|
+
/** Registered effects (optionally of one kind), sorted by name. */
|
|
2952
|
+
declare function listEffects(kind?: EffectKind): EffectDefinition[];
|
|
2953
|
+
/**
|
|
2954
|
+
* Play a registered effect once on `el`. Resolves when it finishes (or
|
|
2955
|
+
* immediately for fire-and-forget effects). Unknown names reject.
|
|
2956
|
+
*/
|
|
2957
|
+
declare function playEffect(el: HTMLElement, name: string, options?: Record<string, unknown>, event?: Event): Promise<void>;
|
|
2958
|
+
/**
|
|
2959
|
+
* Bind an effect to a trigger on `el`: `click`, `hover` (pointerenter / focus),
|
|
2960
|
+
* `enter` (scrolls into view; `once` by default), `load` (now), `loop`
|
|
2961
|
+
* (starts now, cleanup stops it) or `manual` (nothing). Returns an unbind.
|
|
2962
|
+
*/
|
|
2963
|
+
declare function bindEffect(el: HTMLElement, name: string, options?: Record<string, unknown> & {
|
|
2964
|
+
trigger?: EffectTrigger;
|
|
2965
|
+
once?: boolean;
|
|
2966
|
+
}): Cleanup$1;
|
|
2967
|
+
|
|
2968
|
+
/** Every built-in 5.0 effect definition. */
|
|
2969
|
+
declare const BUILTIN_EFFECTS: EffectDefinition[];
|
|
2970
|
+
|
|
2971
|
+
/**
|
|
2972
|
+
* motionary/components/fx — unified plugin-style effects (5.0).
|
|
2973
|
+
* `registerEffect({ name, kind, run })`, `playEffect(el, name)`,
|
|
2974
|
+
* `bindEffect(el, name, { trigger })`, `<usa-fx effect trigger>`. Built-ins:
|
|
2975
|
+
* every timeline preset (`enter`), `pulse` · `pop` · `jelly` · `wiggle` ·
|
|
2976
|
+
* `heartbeat` · `bounce` · `flash` · `tada` · `shake` (attention),
|
|
2977
|
+
* `burst` · `confetti` · `ripple` (click). More packs: `motionary/components/effects`.
|
|
2978
|
+
*/
|
|
2979
|
+
|
|
2980
|
+
/** Register the built-in effects (idempotent; `defineFxComponents()` calls it). */
|
|
2981
|
+
declare function registerBuiltinEffects(): void;
|
|
2982
|
+
/** Register every component of this category under its default tag (+ the built-in effects). */
|
|
2983
|
+
declare function defineFxComponents(): void;
|
|
2984
|
+
declare global {
|
|
2985
|
+
interface HTMLElementTagNameMap {
|
|
2986
|
+
'usa-fx': UsaFxElement;
|
|
2987
|
+
}
|
|
2988
|
+
}
|
|
2989
|
+
|
|
2990
|
+
/**
|
|
2991
|
+
* Register every `<usa-*>` component (or only the given categories).
|
|
2992
|
+
* Safe to call more than once and on the server (no-op without DOM).
|
|
2993
|
+
*/
|
|
2994
|
+
declare function defineComponents(categories?: ComponentCategory[]): void;
|
|
2995
|
+
|
|
2996
|
+
export { ALL_TAGS, AMBIENT_EFFECTS, ANIM_ICONS, BRIDGE_PROTOCOL_VERSION, BUILTIN_EFFECTS, BUTTON_DEFORMS, CARD_EFFECTS, CLICK_EFFECTS, COMPONENT_CATEGORIES, CURSOR_MODES, EFFECT_KINDS, EFFECT_TRIGGERS, GL_FALLBACKS, JOINING_SCRIPT, LIVE_REGION_IDS, MASK_SHAPES, MORPH_ICONS, MOTION_SCALE, MOTION_SENSITIVITY, MOTION_SENSITIVITY_LEVELS, MOTION_TOKENS, PACKS, PACK_PRIMITIVES, PAGE_EFFECTS, PARTICLE_PRESETS, POST_EFFECTS, REVEAL_EFFECTS, SENSITIVITY_CSS, SHADERS, SPINNER_VARIANTS, SPRING_EFFECTS, SPRING_PRESETS, STATIC_ALTERNATIVES, TIMELINE_PRESETS, VARIANTS, activeAnimations, adaptKeyframes, adoptVariants, animateWithMotion, animationBudget, announce, applyMotionTokens, applyNativeSettings, applyPack, auditMotionA11y, autoAnimate, autoDegrade, baselineReport, bindEffect, categoryOf, configureComponents, connectNativeShell, countUp, createSpring, defineAccordion, defineAcrylic, defineAmbient, defineAnimIcon, defineAurora, defineAutoAnimate, defineAutoSkeleton, defineAvatarStack, defineBackToTop, defineBackgroundComponents, defineBadge, defineBlobs, defineBottomSheet, defineButton, defineCard, defineCardComponents, defineCardStack, defineCarousel3d, defineCheck, defineCheckbox, defineClick, defineClickComponents, defineComponents, defineCounter, defineCube, defineCursor, defineDepth, defineDepthComponents, defineDialog, defineDistort, defineDotNetwork, defineDoubleTap, defineDraggable, defineDraw, defineDrawer, defineFab, defineFeedbackComponents, defineFullpage, defineFx, defineFxComponents, defineGestureComponents, defineGlitch, defineGradientText, defineGrain, defineGridGlow, defineHandwriting, defineHold, defineIconMorph, defineInteractionComponents, defineLayoutComponents, defineLike, defineLiquid, defineLoadingBar, defineMagnetic, defineMarquee, defineMaskReveal, defineMasonry, defineMorph, defineMotionSwitch, defineNavbar, defineOverscroll, definePack, definePacksComponents, definePageComponents, defineParticles, definePhysicsComponents, definePinchZoom, definePopover, definePostFx, definePress, defineProgress, definePullRefresh, defineRating, defineReveal, defineRevealComponents, defineRipple, defineScramble, defineScrollHighlight, defineScrollProgress, defineScrolly, defineShader, defineShimmerText, defineSkeleton, defineSlider, defineSpinner, defineSplash, defineSplitText, defineSpotlight, defineSpring, defineStagger, defineStickyStack, defineSvgComponents, defineSwipeable, defineTabs, defineTextComponents, defineTextRotate, defineTilt, defineTimeline, defineTimelineComponents, defineToaster, defineToggle, defineTooltip, defineTransitionComponents, defineTypewriter, defineUiComponents, defineViewSwitch, defineWaterRipple, defineWaveText, defineWebglComponents, detectNativeHost, deviceTilt, drawLines, easeOutExpo, enableMpaTransitions, flip, flipFrames, fluentPreset, flyToCart, fragmentSource, gesture, getEffect, getMotionIntensity, getMotionLevel, getMotionSensitivity, getMotionTokens, glFallbackCss, glGovernor, glQuad, graphemes, haptic, hasEffect, importMotionTokens, interpolatePath, linearEasing, listEffects, liveRegion, loadCategoryStyles, loadedStyles, loadingBar, masonryLayout, mergeMotionTokens, morphPath, morphTo, motionAllowed, motionScale, motionToken, motionTokensToCss, motionTokensToJSON, motionTokensToVars, motionVar, onDemandStyles, onFrame, orientationToTilt, pageTransition, parseDuration, parseEasing, parseNativeSettings, pathsCompatible, pinchScale, playEffect, postFxShader, postToNative, prefersReducedMotion, projectInertia, readScrollProgress, registerBuiltinEffects, registerEffect, registerEffects, requestOrientationPermission, resolveDurationToken, resolveEasingToken, resolvePosition, resolveSpring, restoreMotionIntensity, restoreMotionSensitivity, revealKeyframes, rubberBand, schedulerStats, scrambleFrame, scrollToTarget, setAnimationBudget, setMotionIntensity, setMotionLevel, setMotionSensitivity, setVariant, sharedTransition, smoothScroll, snapTo, splitOrder, splitText, splitTimeline, words as splitWords, spring, springEasing, springEffectKeyframes, springSamples, staticAlternative, stepSpring, supportsLinearEasing, supportsNativeScrub, supportsOrientation, supportsViewTransitions, supportsWebGL, swipeDirection, themeTransition, timeline, toast, viewTransition, warnBaseline, watchPowerSaver, withoutDeprecations };
|
|
2997
|
+
export type { A11yIssue, AmbientEffect, AutoAnimateOptions, AutoDegradeOptions, BaselineFeature, BurstOptions, ButtonDeform, ButtonShape, ButtonState, CardEffect, ClickEffect, ComponentCategory, ComponentsConfig, ConfettiOptions, CursorMode, DeepPartialTokens, DegradeState, DialogVariant, EffectContext, EffectDefinition, EffectKind, EffectTrigger, FlipOptions, FluentPresetOptions, GLGovernor, GLGovernorOptions, GLQuad, GestureHandlers, GestureOptions, MorphOptions, MotionIntensity, MotionSensitivity, MotionSwitchLevel, MotionTokenGroup, MotionTokens, NativeHost, NativeSettings, NativeShellOptions, NativeTheme, PackContext, PackName, PageEffect, PageTransitionOptions, PanState, ParticlePreset, PinchState, Placement, Politeness, PostEffect, PressState, RevealEffect, ScrubHandle, ScrubOptions, SharedOptions, SmoothScrollOptions, SpinnerVariant, SplitBy, SplitFrom, SplitResult, SplitTextOptions, SplitTimelineOptions, SpringConfig, SpringEffect, SpringInput, SpringPreset, SpringToken, SpringValue, SpringValueOptions, SwipeDirection, SwipeState, TiltReading, Timeline, TimelineOptions, TimelinePosition, TimelineStepOptions, ToastHandle, ToastOptions, ToastType, UsaAccordionElement, UsaAcrylicElement, UsaAmbientElement, UsaAnimIconElement, UsaAuroraElement, UsaAutoAnimateElement, UsaAutoSkeletonElement, UsaAvatarStackElement, UsaBackToTopElement, UsaBadgeElement, UsaBlobsElement, UsaBottomSheetElement, UsaButtonElement, UsaCardElement, UsaCardStackElement, UsaCarousel3dElement, UsaCheckElement, UsaCheckboxElement, UsaClickElement, UsaCounterElement, UsaCubeElement, UsaCursorElement, UsaDepthElement, UsaDialogElement, UsaDotNetworkElement, UsaDoubleTapElement, UsaDraggableElement, UsaDrawElement, UsaDrawerElement, UsaElement, UsaFabElement, UsaFullpageElement, UsaFxElement, UsaGLElement, UsaGlitchElement, UsaGradientTextElement, UsaGrainElement, UsaGridGlowElement, UsaHandwritingElement, UsaHoldElement, UsaIconMorphElement, UsaLikeElement, UsaLoadingBarElement, UsaMagneticElement, UsaMarqueeElement, UsaMaskRevealElement, UsaMasonryElement, UsaMorphElement, UsaMotionSwitchElement, UsaNavbarElement, UsaOverscrollElement, UsaPackElement, UsaParticlesElement, UsaPinchZoomElement, UsaPopoverElement, UsaPressElement, UsaProgressElement, UsaPullRefreshElement, UsaRatingElement, UsaRevealElement, UsaRippleElement, UsaScrambleElement, UsaScrollHighlightElement, UsaScrollProgressElement, UsaScrollyElement, UsaShimmerTextElement, UsaSkeletonElement, UsaSliderElement, UsaSpinnerElement, UsaSplashElement, UsaSplitTextElement, UsaSpotlightElement, UsaSpringElement, UsaStaggerElement, UsaStickyStackElement, UsaSwipeableElement, UsaTabsElement, UsaTextRotateElement, UsaTiltElement, UsaTimelineElement, UsaToasterElement, UsaToggleElement, UsaTooltipElement, UsaTypewriterElement, UsaViewSwitchElement, UsaWaterRippleElement, UsaWaveTextElement, Variant, ViewTransitionOptions };
|