use-scroll-animate 2.6.0 → 2.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/README.md +1 -0
  3. package/README_ja.md +1 -0
  4. package/README_zh.md +1 -0
  5. package/dist/chunks/{base-5DFCAnvH.cjs → base-BR6fYLBA.cjs} +23 -2
  6. package/dist/chunks/base-BR6fYLBA.cjs.map +1 -0
  7. package/dist/chunks/{base-08OYzphB.js → base-D6zLiNGH.js} +21 -3
  8. package/dist/chunks/base-D6zLiNGH.js.map +1 -0
  9. package/dist/chunks/{spring-CpeFkxNd.js → spring-C2Megtcf.js} +3 -3
  10. package/dist/chunks/spring-C2Megtcf.js.map +1 -0
  11. package/dist/chunks/{spring-Bi4qY0pL.cjs → spring-DyHe1Hfa.cjs} +3 -3
  12. package/dist/chunks/spring-DyHe1Hfa.cjs.map +1 -0
  13. package/dist/components/background.cjs +1 -1
  14. package/dist/components/background.d.cts +8 -0
  15. package/dist/components/background.d.ts +8 -0
  16. package/dist/components/background.js +2 -2
  17. package/dist/components/cards.cjs +2 -2
  18. package/dist/components/cards.d.cts +8 -0
  19. package/dist/components/cards.d.ts +8 -0
  20. package/dist/components/cards.js +3 -3
  21. package/dist/components/click.cjs +2 -2
  22. package/dist/components/click.d.cts +8 -0
  23. package/dist/components/click.d.ts +8 -0
  24. package/dist/components/click.js +3 -3
  25. package/dist/components/feedback.cjs +1 -1
  26. package/dist/components/feedback.d.cts +8 -0
  27. package/dist/components/feedback.d.ts +8 -0
  28. package/dist/components/feedback.js +2 -2
  29. package/dist/components/interaction.cjs +1 -1
  30. package/dist/components/interaction.d.cts +8 -0
  31. package/dist/components/interaction.d.ts +8 -0
  32. package/dist/components/interaction.js +2 -2
  33. package/dist/components/page.cjs +801 -0
  34. package/dist/components/page.cjs.map +1 -0
  35. package/dist/components/page.css +11 -0
  36. package/dist/components/page.d.cts +275 -0
  37. package/dist/components/page.d.ts +275 -0
  38. package/dist/components/page.js +776 -0
  39. package/dist/components/page.js.map +1 -0
  40. package/dist/components/physics.cjs +2 -2
  41. package/dist/components/physics.d.cts +8 -0
  42. package/dist/components/physics.d.ts +8 -0
  43. package/dist/components/physics.js +4 -4
  44. package/dist/components/reveal.cjs +1 -1
  45. package/dist/components/reveal.d.cts +8 -0
  46. package/dist/components/reveal.d.ts +8 -0
  47. package/dist/components/reveal.js +2 -2
  48. package/dist/components/text.cjs +1 -1
  49. package/dist/components/text.d.cts +8 -0
  50. package/dist/components/text.d.ts +8 -0
  51. package/dist/components/text.js +2 -2
  52. package/dist/components/transitions.cjs +1 -1
  53. package/dist/components/transitions.d.cts +8 -0
  54. package/dist/components/transitions.d.ts +8 -0
  55. package/dist/components/transitions.js +2 -2
  56. package/dist/components/ui.cjs +2 -2
  57. package/dist/components/ui.d.cts +8 -0
  58. package/dist/components/ui.d.ts +8 -0
  59. package/dist/components/ui.js +3 -3
  60. package/dist/components.cjs +28 -2
  61. package/dist/components.cjs.map +1 -1
  62. package/dist/components.css +9 -0
  63. package/dist/components.d.cts +239 -2
  64. package/dist/components.d.ts +239 -2
  65. package/dist/components.js +8 -4
  66. package/dist/components.js.map +1 -1
  67. package/dist/components.umd.js +2 -2
  68. package/dist/components.umd.js.map +1 -1
  69. package/docs/components.md +17 -0
  70. package/package.json +13 -2
  71. package/dist/chunks/base-08OYzphB.js.map +0 -1
  72. package/dist/chunks/base-5DFCAnvH.cjs.map +0 -1
  73. package/dist/chunks/spring-Bi4qY0pL.cjs.map +0 -1
  74. package/dist/chunks/spring-CpeFkxNd.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -7,6 +7,23 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [2.7.0] - 2026-10-07
11
+
12
+ ### Added
13
+ - **Page & app-wide effects** — new category `use-scroll-animate/components/page` (+ `components/page.css`):
14
+ - **Page transitions** on the View Transitions API: `pageTransition(update, { effect })` for SPA route changes — `fade`, `slide` / `slide-left` / `slide-right` / `slide-up`, `circle` (reveal from the click point), `blinds`, `pixel` (stepped dissolve), `zoom`; `enableMpaTransitions(effect)` for multi-page sites (`@view-transition { navigation: auto }`); `themeTransition(apply)` circle-reveal theme switch. Falls back to an instant update (optional cross-fade) without View Transitions.
15
+ - `<usa-cursor mode="dot | trail | magnetic | glow">` custom cursors (fine pointers only, `hide-native`).
16
+ - `smoothScroll()` (inertial wheel smoothing, touch/keyboard stay native) and `scrollToTarget()` (spring timing).
17
+ - `<usa-fullpage>` full-screen snapping sections with keyboard paging and dot navigation.
18
+ - `<usa-loading-bar>` + `loadingBar.start() / set() / done() / track(promise)` top loading bar (the scroll progress bar remains `<usa-scroll-progress>`).
19
+ - `<usa-back-to-top>` with a reading-progress ring, spring scroll and focus return.
20
+ - `<usa-ambient effect="particles | snow | stars | noise | gradient">` page-wide ambient layer (scroll-driven gradient, canvas paused in hidden tabs).
21
+ - `<usa-splash>` launch / splash screen (`fade`, `scale`, `slide-up`, `circle` exit; `min` duration; `manual` + `done()`).
22
+ - `<usa-auto-skeleton loading>` automatic skeletons from the existing markup.
23
+ - **Global motion intensity**: `setMotionIntensity('off' | 'low' | 'normal' | 'high', persist?)`, `restoreMotionIntensity()`, `getMotionIntensity()`, `configureComponents({ motionIntensity })` and the `<usa-motion-switch>` control. It scales every component animation (and `spring()`), sets `--usa-motion` / `data-usa-motion` on `<html>`, and `off` behaves like `prefers-reduced-motion`.
24
+ - Reduced motion: transitions update instantly, no cursor / smooth scrolling / ambient animation, instant jumps.
25
+ - Showcase: **Page & app-wide** category with live page-transition, theme reveal, cursor, ambient, splash, loading-bar, auto-skeleton, fullpage and motion-intensity demos.
26
+
10
27
  ## [2.6.0] - 2026-10-07
11
28
 
12
29
  ### Added
package/README.md CHANGED
@@ -54,6 +54,7 @@ defineComponents(); // or per category: import { defineTextComponents } from 'us
54
54
  | **Card effects** (`/components/cards`) | `<usa-card>` (flip · holo · glass · border-glow · conic-border · lift · spotlight · sheen · parallax-layers · expand — combinable) · `<usa-card-stack>` (swipe) · `<usa-sticky-stack>` · `<usa-carousel-3d>` |
55
55
  | **Click & tap** (`/components/click`) | `<usa-button>` **button click deformation** (squash · wobble · gooey · dent · shape morph · submit→loading→success) · `<usa-icon-morph>` · `<usa-click>` (ripple · burst · confetti · squish · press-spring · shake) · `<usa-like>` · `<usa-hold>` · `<usa-double-tap>` · `<usa-checkbox>` · `confetti()` · `haptic()` |
56
56
  | **UI components & variants** (`/components/ui`) | `<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>` · `variant="minimal \| neon \| glass \| brutalist \| fluent \| material"` on every component |
57
+ | **Page & app-wide** (`/components/page`) | `pageTransition()` (fade · slide · circle · blinds · pixel · zoom; SPA + MPA) · `themeTransition()` · `<usa-cursor>` · `smoothScroll()` · `<usa-fullpage>` · `<usa-loading-bar>` · `<usa-back-to-top>` · `<usa-ambient>` (particles · snow · stars · noise · gradient) · `<usa-splash>` · `<usa-auto-skeleton>` · `<usa-motion-switch>` / `setMotionIntensity()` |
57
58
 
58
59
  Whole bundle ≈ 22 kB gzip (JS + CSS); one category 3.5–6.4 kB; a single component ≈ 2 kB. The scroll-animation core below is unaffected.
59
60
 
package/README_ja.md CHANGED
@@ -44,6 +44,7 @@ defineComponents(); // カテゴリ単位: import { defineTextComponents } from
44
44
  | **カード効果**(`/components/cards`) | `<usa-card>`(flip · holo · glass · border-glow · conic-border · lift · spotlight · sheen · parallax-layers · expand)· `<usa-card-stack>` · `<usa-sticky-stack>` · `<usa-carousel-3d>` |
45
45
  | **クリック・タップ**(`/components/click`) | `<usa-button>`(squash · wobble · gooey · dent · shape morph · submit)· `<usa-icon-morph>` · `<usa-click>` · `<usa-like>` · `<usa-hold>` · `<usa-double-tap>` · `<usa-checkbox>` |
46
46
  | **UI コンポーネント・バリアント**(`/components/ui`) | `<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>` · 全コンポーネントで `variant` |
47
+ | **ページ・アプリ全体**(`/components/page`) | `pageTransition()` · `themeTransition()` · `<usa-cursor>` · `smoothScroll()` · `<usa-fullpage>` · `<usa-loading-bar>` · `<usa-back-to-top>` · `<usa-ambient>` · `<usa-splash>` · `<usa-auto-skeleton>` · `<usa-motion-switch>` |
47
48
 
48
49
  ## ドキュメント
49
50
 
package/README_zh.md CHANGED
@@ -53,6 +53,7 @@ defineComponents(); // 或按分类:import { defineTextComponents } from 'use-
53
53
  | **卡片效果**(`/components/cards`) | `<usa-card>` 翻转 · 全息 · 玻璃 · 边框光晕 · 流光边框 · 悬浮 · 聚光 · 扫光 · 视差分层 · 展开详情(可组合)· `<usa-card-stack>` 滑动卡堆 · `<usa-sticky-stack>` 滚动堆叠 · `<usa-carousel-3d>` 3D 轮播 |
54
54
  | **点击与轻触**(`/components/click`) | `<usa-button>` 按钮点击形变(挤压拉伸 · 弹性圆角 · 液态粘滞 · 按压凹陷 · 形状变形 · 提交→加载→成功)· `<usa-icon-morph>` 图标变形 · `<usa-click>` 水波纹 / 迸发 / 彩带 / 抖动 · `<usa-like>` · `<usa-hold>` · `<usa-double-tap>` · `<usa-checkbox>` |
55
55
  | **UI 组件与风格变体**(`/components/ui`) | `<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>` · 所有组件均支持 `variant`(极简 / 霓虹 / 玻璃 / 粗野 / Fluent / Material) |
56
+ | **页面与全局效果**(`/components/page`) | `pageTransition()` 页面切换(淡入 · 滑动 · 圆形揭示 · 百叶窗 · 像素溶解,单页 + 多页)· `themeTransition()` 主题圆形切换 · `<usa-cursor>` 自定义光标 · `smoothScroll()` · `<usa-fullpage>` 整屏 · `<usa-loading-bar>` · `<usa-back-to-top>` · `<usa-ambient>` 雪花 / 星空 / 噪点 · `<usa-splash>` 启动屏 · `<usa-auto-skeleton>` 自动骨架屏 · `<usa-motion-switch>` 动效强度 |
56
57
 
57
58
  完整包约 22 kB gzip(JS + CSS);单个分类 3.5–6.4 kB;单个组件约 2 kB。下方的滚动动画核心不受影响。
58
59
 
@@ -8,14 +8,29 @@
8
8
  * imported during SSR (Next, Nuxt, Astro…) and in Electron/Tauri preload
9
9
  * scripts. Classes are created the first time a `define*()` function runs.
10
10
  */
11
- const config = { injectStyles: true, reducedMotion: 'user' };
11
+ const MOTION_SCALE = { off: 0, low: 0.6, normal: 1, high: 1.25 };
12
+ const config = { injectStyles: true, reducedMotion: 'user', motionIntensity: 'normal' };
12
13
  /** Change global component settings (call before `define*()` for `injectStyles`). */
13
14
  function configureComponents(options) {
14
15
  Object.assign(config, options);
16
+ if (options.motionIntensity && typeof document !== 'undefined') {
17
+ document.documentElement.style.setProperty('--usa-motion', String(MOTION_SCALE[options.motionIntensity] ?? 1));
18
+ document.documentElement.setAttribute('data-usa-motion', options.motionIntensity);
19
+ }
20
+ }
21
+ /** The current global motion intensity. */
22
+ function getMotionIntensity() {
23
+ return config.motionIntensity;
24
+ }
25
+ /** Duration multiplier for the current intensity (1 when `normal`). */
26
+ function motionScale() {
27
+ return MOTION_SCALE[config.motionIntensity] ?? 1;
15
28
  }
16
29
  const canDefine = () => typeof customElements !== 'undefined' && typeof HTMLElement !== 'undefined';
17
30
  /** `true` when animations should be reduced (OS setting or `configureComponents`). */
18
31
  function prefersReducedMotion() {
32
+ if (config.motionIntensity === 'off')
33
+ return true;
19
34
  if (config.reducedMotion !== 'user')
20
35
  return config.reducedMotion === 'reduce';
21
36
  return typeof matchMedia === 'function' && !!matchMedia('(prefers-reduced-motion: reduce)').matches;
@@ -156,6 +171,9 @@ function getBase() {
156
171
  applyFrame(el, keyframes[keyframes.length - 1]);
157
172
  return null;
158
173
  }
174
+ const k = motionScale();
175
+ if (k !== 1 && k > 0 && typeof options.duration === 'number')
176
+ options = { ...options, duration: options.duration * k, delay: (options.delay || 0) * k };
159
177
  return el.animate(keyframes, options);
160
178
  }
161
179
  emit(type, detail) {
@@ -220,6 +238,7 @@ const clamp = (v, min, max) => Math.min(max, Math.max(min, v));
220
238
  exports.EASE_OUT = EASE_OUT;
221
239
  exports.EASE_SPRING = EASE_SPRING;
222
240
  exports.FLUENT_DECELERATE = FLUENT_DECELERATE;
241
+ exports.MOTION_SCALE = MOTION_SCALE;
223
242
  exports.adoptStyles = adoptStyles;
224
243
  exports.applyFrame = applyFrame;
225
244
  exports.caf = caf;
@@ -227,9 +246,11 @@ exports.canDefine = canDefine;
227
246
  exports.clamp = clamp;
228
247
  exports.configureComponents = configureComponents;
229
248
  exports.defineElement = defineElement;
249
+ exports.getMotionIntensity = getMotionIntensity;
250
+ exports.motionScale = motionScale;
230
251
  exports.now = now;
231
252
  exports.prefersReducedMotion = prefersReducedMotion;
232
253
  exports.raf = raf;
233
254
  exports.shadowStyles = shadowStyles;
234
255
  exports.srText = srText;
235
- //# sourceMappingURL=base-5DFCAnvH.cjs.map
256
+ //# sourceMappingURL=base-BR6fYLBA.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base-BR6fYLBA.cjs","sources":["../../src/components/base.ts"],"sourcesContent":["/**\n * use-scroll-animate/components — shared base for the `<usa-*>` custom elements.\n *\n * Everything here is lazy: nothing touches `window`, `document`,\n * `HTMLElement` or `matchMedia` at import time, so the components can be\n * imported during SSR (Next, Nuxt, Astro…) and in Electron/Tauri preload\n * scripts. Classes are created the first time a `define*()` function runs.\n */\n\nexport interface ComponentsConfig {\n /**\n * Inject each component's CSS when it is defined (default `true`). Uses a\n * constructable stylesheet (`document.adoptedStyleSheets`, which a strict\n * `style-src` CSP does not block) and falls back to a `<style>` tag. Set\n * to `false` when you load `use-scroll-animate/components.css` yourself.\n */\n injectStyles?: boolean;\n /**\n * `'user'` (default) follows `prefers-reduced-motion`; `'reduce'` always\n * uses the reduced variants (e.g. a kiosk / battery-saver mode);\n * `'no-preference'` ignores the OS setting (only for demos — respect your users).\n */\n reducedMotion?: 'user' | 'reduce' | 'no-preference';\n /**\n * Global motion intensity (v2.7): `'off'` (same as reduced motion),\n * `'low'` (shorter, calmer), `'normal'` (default) or `'high'`. Scales every\n * component animation's duration and sets `--usa-motion` (0 / 0.6 / 1 /\n * 1.25) on `<html>` for your own CSS. See `setMotionIntensity()`.\n */\n motionIntensity?: MotionIntensity;\n}\n\nexport type MotionIntensity = 'off' | 'low' | 'normal' | 'high';\nexport const MOTION_SCALE: Record<MotionIntensity, number> = { off: 0, low: 0.6, normal: 1, high: 1.25 };\n\nconst config: Required<ComponentsConfig> = { injectStyles: true, reducedMotion: 'user', motionIntensity: 'normal' };\n\n/** Change global component settings (call before `define*()` for `injectStyles`). */\nexport function configureComponents(options: ComponentsConfig): void {\n Object.assign(config, options);\n if (options.motionIntensity && typeof document !== 'undefined') {\n document.documentElement.style.setProperty('--usa-motion', String(MOTION_SCALE[options.motionIntensity] ?? 1));\n document.documentElement.setAttribute('data-usa-motion', options.motionIntensity);\n }\n}\n\n/** The current global motion intensity. */\nexport function getMotionIntensity(): MotionIntensity {\n return config.motionIntensity;\n}\n\n/** Duration multiplier for the current intensity (1 when `normal`). */\nexport function motionScale(): number {\n return MOTION_SCALE[config.motionIntensity] ?? 1;\n}\n\nexport const canDefine = (): boolean => typeof customElements !== 'undefined' && typeof HTMLElement !== 'undefined';\n\n/** `true` when animations should be reduced (OS setting or `configureComponents`). */\nexport function prefersReducedMotion(): boolean {\n if (config.motionIntensity === 'off') return true;\n if (config.reducedMotion !== 'user') return config.reducedMotion === 'reduce';\n return typeof matchMedia === 'function' && !!matchMedia('(prefers-reduced-motion: reduce)').matches;\n}\n\nconst injected = new Set<string>();\n\n/** Add a component's stylesheet to the document once. */\nexport function adoptStyles(id: string, css: string): void {\n if (!config.injectStyles || !css || injected.has(id) || typeof document === 'undefined') return;\n injected.add(id);\n try {\n if (typeof CSSStyleSheet === 'function' && 'adoptedStyleSheets' in document) {\n const sheet = new CSSStyleSheet();\n sheet.replaceSync(css);\n document.adoptedStyleSheets = [...document.adoptedStyleSheets, sheet];\n return;\n }\n } catch {\n /* fall through to <style> */\n }\n const style = document.createElement('style');\n style.setAttribute('data-usa', id);\n style.textContent = css;\n (document.head || document.documentElement).appendChild(style);\n}\n\n/** Attach `css` to a shadow root (constructable sheet where supported, else `<style>`). */\nexport function shadowStyles(root: ShadowRoot, css: string): void {\n try {\n if (typeof CSSStyleSheet === 'function' && 'adoptedStyleSheets' in root) {\n const sheet = new CSSStyleSheet();\n sheet.replaceSync(css);\n root.adoptedStyleSheets = [sheet];\n return;\n }\n } catch {\n /* fall through */\n }\n const style = document.createElement('style');\n style.textContent = css;\n root.prepend(style);\n}\n\nexport type Cleanup = () => void;\n\n/**\n * Members shared by every `<usa-*>` element. Attribute helpers, a cleanup\n * bag that is emptied on disconnect, and motion helpers that degrade to the\n * final state without WAAPI or under reduced motion.\n */\nexport interface UsaElement extends HTMLElement {\n /** `true` while reduced motion applies to this element. */\n readonly reduced: boolean;\n}\n\nexport interface UsaBase extends UsaElement {\n mount(): void;\n changed(name: string): void;\n unmount(): void;\n str(name: string, fallback?: string): string;\n num(name: string, fallback: number): number;\n flag(name: string): boolean;\n setFlag(name: string, on: boolean): void;\n onCleanup(fn: Cleanup): void;\n listen<K extends keyof HTMLElementEventMap>(\n target: EventTarget,\n type: K | string,\n fn: (e: any) => void,\n options?: AddEventListenerOptions\n ): void;\n inView(cb: (visible: boolean, entry?: IntersectionObserverEntry) => void, init?: IntersectionObserverInit, target?: Element): void;\n motion(el: Element, keyframes: Keyframe[], options: KeyframeAnimationOptions): Animation | null;\n emit(type: string, detail?: unknown): boolean;\n}\n\ntype BaseCtor = new () => UsaBase;\nlet baseClass: BaseCtor | null = null;\n\n/** The lazily created base class (needs `HTMLElement`). */\nexport function getBase(): BaseCtor {\n if (baseClass) return baseClass;\n class Base extends HTMLElement {\n private _cleanups: Cleanup[] = [];\n private _connected = false;\n\n get reduced(): boolean {\n return prefersReducedMotion();\n }\n\n connectedCallback(): void {\n if (this._connected) return;\n this._connected = true;\n // Upgraded while the parser is still inside us (a <script> in <head>\n // defined the element): children/text are not there yet, so wait.\n if (typeof document !== 'undefined' && document.readyState === 'loading' && !this.nextSibling && !this.childNodes.length) {\n const go = () => {\n if (this._connected && this.isConnected) this.mount();\n };\n document.addEventListener('DOMContentLoaded', go, { once: true });\n this._cleanups.push(() => document.removeEventListener('DOMContentLoaded', go));\n return;\n }\n this.mount();\n }\n\n disconnectedCallback(): void {\n this._connected = false;\n this.teardown();\n }\n\n attributeChangedCallback(_name: string, oldValue: string | null, value: string | null): void {\n if (!this._connected || oldValue === value) return;\n this.changed(_name);\n }\n\n /** Re-mount on attribute change (override for finer updates). */\n changed(_name: string): void {\n this.teardown();\n this.mount();\n }\n\n private teardown(): void {\n this._cleanups.splice(0).reverse().forEach((fn) => fn());\n this.unmount();\n }\n\n mount(): void {}\n unmount(): void {}\n\n str(name: string, fallback = ''): string {\n const v = this.getAttribute(name);\n return v === null ? fallback : v;\n }\n\n num(name: string, fallback: number): number {\n const v = this.getAttribute(name);\n const n = v === null || v.trim() === '' ? NaN : Number(v);\n return Number.isFinite(n) ? n : fallback;\n }\n\n /** Boolean attribute: present and not `\"false\"`. */\n flag(name: string): boolean {\n const v = this.getAttribute(name);\n return v !== null && v !== 'false';\n }\n\n setFlag(name: string, on: boolean): void {\n if (on) this.setAttribute(name, '');\n else this.removeAttribute(name);\n }\n\n onCleanup(fn: Cleanup): void {\n this._cleanups.push(fn);\n }\n\n listen(target: EventTarget, type: string, fn: (e: any) => void, options?: AddEventListenerOptions): void {\n target.addEventListener(type, fn, options);\n this.onCleanup(() => target.removeEventListener(type, fn, options));\n }\n\n /** Calls `cb(true/false)` as the element enters / leaves the viewport. */\n inView(cb: (visible: boolean, entry?: IntersectionObserverEntry) => void, init?: IntersectionObserverInit, target: Element = this): void {\n if (typeof IntersectionObserver === 'undefined') {\n cb(true);\n return;\n }\n const io = new IntersectionObserver((entries) => {\n for (const e of entries) cb(e.isIntersecting, e);\n }, init);\n io.observe(target);\n this.onCleanup(() => io.disconnect());\n }\n\n /** `el.animate()` that returns `null` (and applies the last frame) without WAAPI. */\n motion(el: Element, keyframes: Keyframe[], options: KeyframeAnimationOptions): Animation | null {\n if (typeof (el as HTMLElement).animate !== 'function') {\n applyFrame(el as HTMLElement, keyframes[keyframes.length - 1]);\n return null;\n }\n const k = motionScale();\n if (k !== 1 && k > 0 && typeof options.duration === 'number') options = { ...options, duration: options.duration * k, delay: (options.delay || 0) * k };\n return (el as HTMLElement).animate(keyframes, options);\n }\n\n emit(type: string, detail?: unknown): boolean {\n return this.dispatchEvent(new CustomEvent(`usa:${type}`, { detail, bubbles: true, cancelable: true }));\n }\n }\n baseClass = Base as unknown as BaseCtor;\n return baseClass;\n}\n\n/** Write a keyframe's properties as inline styles (no-WAAPI fallback). */\nexport function applyFrame(el: HTMLElement, frame?: Keyframe): void {\n if (!frame) return;\n for (const [k, v] of Object.entries(frame)) {\n if (k === 'offset' || k === 'easing' || k === 'composite' || v == null) continue;\n (el.style as any)[k] = String(v);\n }\n}\n\n/**\n * Register `tag` with the class built by `make(Base)`. Returns the\n * constructor, the already registered one, or `undefined` without DOM.\n */\nexport function defineElement(\n tag: string,\n make: (Base: BaseCtor) => CustomElementConstructor,\n css?: { id: string; text: string }\n): CustomElementConstructor | undefined {\n if (!canDefine()) return undefined;\n adoptStyles('base', BASE_CSS);\n if (css) adoptStyles(css.id, css.text);\n const existing = customElements.get(tag);\n if (existing) return existing;\n const ctor = make(getBase());\n customElements.define(tag, ctor);\n return ctor;\n}\n\nconst BASE_CSS = '.usa-sr{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0 0 0 0);clip-path:inset(50%);white-space:nowrap;border:0}';\n\n/** A visually hidden copy of `text` for screen readers (the animated copy is `aria-hidden`). */\nexport function srText(text: string): HTMLSpanElement {\n const s = document.createElement('span');\n s.className = 'usa-sr';\n s.textContent = text;\n return s;\n}\n\n/** requestAnimationFrame with a timeout fallback (jsdom / hidden documents). */\nexport const raf = (cb: FrameRequestCallback): number =>\n typeof requestAnimationFrame === 'function' ? requestAnimationFrame(cb) : (setTimeout(() => cb(Date.now()), 16) as unknown as number);\n/** Monotonic time in ms (rAF callback timestamps differ between environments, so loops use this). */\nexport const now = (): number => (typeof performance !== 'undefined' ? performance.now() : Date.now());\nexport const caf = (id: number): void => {\n if (typeof cancelAnimationFrame === 'function') cancelAnimationFrame(id);\n else clearTimeout(id);\n};\n\n/** Spring-ish easing used across the components. */\nexport const EASE_OUT = 'cubic-bezier(0.22, 1, 0.36, 1)';\nexport const EASE_SPRING = 'cubic-bezier(0.34, 1.56, 0.64, 1)';\n/** Windows Fluent \"decelerate\" / \"point-to-point\" curves. */\nexport const FLUENT_DECELERATE = 'cubic-bezier(0.1, 0.9, 0.2, 1)';\n\nexport const clamp = (v: number, min: number, max: number): number => Math.min(max, Math.max(min, v));\n"],"names":[],"mappings":";;AAAA;;;;;;;AAOG;MA0BU,YAAY,GAAoC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,IAAI;AAEtG,MAAM,MAAM,GAA+B,EAAE,YAAY,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,EAAE,eAAe,EAAE,QAAQ,EAAE;AAEnH;AACM,SAAU,mBAAmB,CAAC,OAAyB,EAAA;AAC3D,IAAA,MAAM,CAAC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M,SAAU,MAAM,CAAC,IAAY,EAAA;IACjC,MAAM,CAAC,GAAG,QAAQ,CAAC,aAAa,CAAC,MAAM,CAAC;AACxC,IAAA,CAAC,CAAC,SAAS,GAAG,QAAQ;AACtB,IAAA,CAAC,CAAC,WAAW,GAAG,IAAI;AACpB,IAAA,OAAO,CAAC;AACV;AAEA;AACO,MAAM,GAAG,GAAG,CAAC,EAAwB,KAC1C,OAAO,qBAAqB,KAAK,UAAU,GAAG,qBAAqB,CAAC,EAAE,CAAC,GAAI,UAAU,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE;AAChH;AACO,MAAM,GAAG,GAAG,OAAe,OAAO,WAAW,KAAK,WAAW,GAAG,WAAW,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,GAAG,EAAE;AAC9F,MAAM,GAAG,GAAG,CAAC,EAAU,KAAU;IACtC,IAAI,OAAO,oBAAoB,KAAK,UAAU;QAAE,oBAAoB,CAAC,EAAE,CAAC;;QACnE,YAAY,CAAC,EAAE,CAAC;AACvB;AAEA;AACO,MAAM,QAAQ,GAAG;AACjB,MAAM,WAAW,GAAG;AAC3B;AACO,MAAM,iBAAiB,GAAG;AAE1B,MAAM,KAAK,GAAG,CAAC,CAAS,EAAE,GAAW,EAAE,GAAW,KAAa,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC;;;;;;;;;;;;;;;;;;;;;"}
@@ -6,14 +6,29 @@
6
6
  * imported during SSR (Next, Nuxt, Astro…) and in Electron/Tauri preload
7
7
  * scripts. Classes are created the first time a `define*()` function runs.
8
8
  */
9
- const config = { injectStyles: true, reducedMotion: 'user' };
9
+ const MOTION_SCALE = { off: 0, low: 0.6, normal: 1, high: 1.25 };
10
+ const config = { injectStyles: true, reducedMotion: 'user', motionIntensity: 'normal' };
10
11
  /** Change global component settings (call before `define*()` for `injectStyles`). */
11
12
  function configureComponents(options) {
12
13
  Object.assign(config, options);
14
+ if (options.motionIntensity && typeof document !== 'undefined') {
15
+ document.documentElement.style.setProperty('--usa-motion', String(MOTION_SCALE[options.motionIntensity] ?? 1));
16
+ document.documentElement.setAttribute('data-usa-motion', options.motionIntensity);
17
+ }
18
+ }
19
+ /** The current global motion intensity. */
20
+ function getMotionIntensity() {
21
+ return config.motionIntensity;
22
+ }
23
+ /** Duration multiplier for the current intensity (1 when `normal`). */
24
+ function motionScale() {
25
+ return MOTION_SCALE[config.motionIntensity] ?? 1;
13
26
  }
14
27
  const canDefine = () => typeof customElements !== 'undefined' && typeof HTMLElement !== 'undefined';
15
28
  /** `true` when animations should be reduced (OS setting or `configureComponents`). */
16
29
  function prefersReducedMotion() {
30
+ if (config.motionIntensity === 'off')
31
+ return true;
17
32
  if (config.reducedMotion !== 'user')
18
33
  return config.reducedMotion === 'reduce';
19
34
  return typeof matchMedia === 'function' && !!matchMedia('(prefers-reduced-motion: reduce)').matches;
@@ -154,6 +169,9 @@ function getBase() {
154
169
  applyFrame(el, keyframes[keyframes.length - 1]);
155
170
  return null;
156
171
  }
172
+ const k = motionScale();
173
+ if (k !== 1 && k > 0 && typeof options.duration === 'number')
174
+ options = { ...options, duration: options.duration * k, delay: (options.delay || 0) * k };
157
175
  return el.animate(keyframes, options);
158
176
  }
159
177
  emit(type, detail) {
@@ -215,5 +233,5 @@ const EASE_SPRING = 'cubic-bezier(0.34, 1.56, 0.64, 1)';
215
233
  const FLUENT_DECELERATE = 'cubic-bezier(0.1, 0.9, 0.2, 1)';
216
234
  const clamp = (v, min, max) => Math.min(max, Math.max(min, v));
217
235
 
218
- export { EASE_OUT as E, FLUENT_DECELERATE as F, configureComponents as a, clamp as b, canDefine as c, defineElement as d, caf as e, EASE_SPRING as f, shadowStyles as g, adoptStyles as h, applyFrame as i, now as n, prefersReducedMotion as p, raf as r, srText as s };
219
- //# sourceMappingURL=base-08OYzphB.js.map
236
+ export { EASE_OUT as E, FLUENT_DECELERATE as F, MOTION_SCALE as M, configureComponents as a, clamp as b, canDefine as c, defineElement as d, caf as e, EASE_SPRING as f, getMotionIntensity as g, shadowStyles as h, adoptStyles as i, applyFrame as j, motionScale as m, now as n, prefersReducedMotion as p, raf as r, srText as s };
237
+ //# sourceMappingURL=base-D6zLiNGH.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base-D6zLiNGH.js","sources":["../../src/components/base.ts"],"sourcesContent":["/**\n * use-scroll-animate/components — shared base for the `<usa-*>` custom elements.\n *\n * Everything here is lazy: nothing touches `window`, `document`,\n * `HTMLElement` or `matchMedia` at import time, so the components can be\n * imported during SSR (Next, Nuxt, Astro…) and in Electron/Tauri preload\n * scripts. Classes are created the first time a `define*()` function runs.\n */\n\nexport interface ComponentsConfig {\n /**\n * Inject each component's CSS when it is defined (default `true`). Uses a\n * constructable stylesheet (`document.adoptedStyleSheets`, which a strict\n * `style-src` CSP does not block) and falls back to a `<style>` tag. Set\n * to `false` when you load `use-scroll-animate/components.css` yourself.\n */\n injectStyles?: boolean;\n /**\n * `'user'` (default) follows `prefers-reduced-motion`; `'reduce'` always\n * uses the reduced variants (e.g. a kiosk / battery-saver mode);\n * `'no-preference'` ignores the OS setting (only for demos — respect your users).\n */\n reducedMotion?: 'user' | 'reduce' | 'no-preference';\n /**\n * Global motion intensity (v2.7): `'off'` (same as reduced motion),\n * `'low'` (shorter, calmer), `'normal'` (default) or `'high'`. Scales every\n * component animation's duration and sets `--usa-motion` (0 / 0.6 / 1 /\n * 1.25) on `<html>` for your own CSS. See `setMotionIntensity()`.\n */\n motionIntensity?: MotionIntensity;\n}\n\nexport type MotionIntensity = 'off' | 'low' | 'normal' | 'high';\nexport const MOTION_SCALE: Record<MotionIntensity, number> = { off: 0, low: 0.6, normal: 1, high: 1.25 };\n\nconst config: Required<ComponentsConfig> = { injectStyles: true, reducedMotion: 'user', motionIntensity: 'normal' };\n\n/** Change global component settings (call before `define*()` for `injectStyles`). */\nexport function configureComponents(options: ComponentsConfig): void {\n Object.assign(config, options);\n if (options.motionIntensity && typeof document !== 'undefined') {\n document.documentElement.style.setProperty('--usa-motion', String(MOTION_SCALE[options.motionIntensity] ?? 1));\n document.documentElement.setAttribute('data-usa-motion', options.motionIntensity);\n }\n}\n\n/** The current global motion intensity. */\nexport function getMotionIntensity(): MotionIntensity {\n return config.motionIntensity;\n}\n\n/** Duration multiplier for the current intensity (1 when `normal`). */\nexport function motionScale(): number {\n return MOTION_SCALE[config.motionIntensity] ?? 1;\n}\n\nexport const canDefine = (): boolean => typeof customElements !== 'undefined' && typeof HTMLElement !== 'undefined';\n\n/** `true` when animations should be reduced (OS setting or `configureComponents`). */\nexport function prefersReducedMotion(): boolean {\n if (config.motionIntensity === 'off') return true;\n if (config.reducedMotion !== 'user') return config.reducedMotion === 'reduce';\n return typeof matchMedia === 'function' && !!matchMedia('(prefers-reduced-motion: reduce)').matches;\n}\n\nconst injected = new Set<string>();\n\n/** Add a component's stylesheet to the document once. */\nexport function adoptStyles(id: string, css: string): void {\n if (!config.injectStyles || !css || injected.has(id) || typeof document === 'undefined') return;\n injected.add(id);\n try {\n if (typeof CSSStyleSheet === 'function' && 'adoptedStyleSheets' in document) {\n const sheet = new CSSStyleSheet();\n sheet.replaceSync(css);\n document.adoptedStyleSheets = [...document.adoptedStyleSheets, sheet];\n return;\n }\n } catch {\n /* fall through to <style> */\n }\n const style = document.createElement('style');\n style.setAttribute('data-usa', id);\n style.textContent = css;\n (document.head || document.documentElement).appendChild(style);\n}\n\n/** Attach `css` to a shadow root (constructable sheet where supported, else `<style>`). */\nexport function shadowStyles(root: ShadowRoot, css: string): void {\n try {\n if (typeof CSSStyleSheet === 'function' && 'adoptedStyleSheets' in root) {\n const sheet = new CSSStyleSheet();\n sheet.replaceSync(css);\n root.adoptedStyleSheets = [sheet];\n return;\n }\n } catch {\n /* fall through */\n }\n const style = document.createElement('style');\n style.textContent = css;\n root.prepend(style);\n}\n\nexport type Cleanup = () => void;\n\n/**\n * Members shared by every `<usa-*>` element. Attribute helpers, a cleanup\n * bag that is emptied on disconnect, and motion helpers that degrade to the\n * final state without WAAPI or under reduced motion.\n */\nexport interface UsaElement extends HTMLElement {\n /** `true` while reduced motion applies to this element. */\n readonly reduced: boolean;\n}\n\nexport interface UsaBase extends UsaElement {\n mount(): void;\n changed(name: string): void;\n unmount(): void;\n str(name: string, fallback?: string): string;\n num(name: string, fallback: number): number;\n flag(name: string): boolean;\n setFlag(name: string, on: boolean): void;\n onCleanup(fn: Cleanup): void;\n listen<K extends keyof HTMLElementEventMap>(\n target: EventTarget,\n type: K | string,\n fn: (e: any) => void,\n options?: AddEventListenerOptions\n ): void;\n inView(cb: (visible: boolean, entry?: IntersectionObserverEntry) => void, init?: IntersectionObserverInit, target?: Element): void;\n motion(el: Element, keyframes: Keyframe[], options: KeyframeAnimationOptions): Animation | null;\n emit(type: string, detail?: unknown): boolean;\n}\n\ntype BaseCtor = new () => UsaBase;\nlet baseClass: BaseCtor | null = null;\n\n/** The lazily created base class (needs `HTMLElement`). */\nexport function getBase(): BaseCtor {\n if (baseClass) return baseClass;\n class Base extends HTMLElement {\n private _cleanups: Cleanup[] = [];\n private _connected = false;\n\n get reduced(): boolean {\n return prefersReducedMotion();\n }\n\n connectedCallback(): void {\n if (this._connected) return;\n this._connected = true;\n // Upgraded while the parser is still inside us (a <script> in <head>\n // defined the element): children/text are not there yet, so wait.\n if (typeof document !== 'undefined' && document.readyState === 'loading' && !this.nextSibling && !this.childNodes.length) {\n const go = () => {\n if (this._connected && this.isConnected) this.mount();\n };\n document.addEventListener('DOMContentLoaded', go, { once: true });\n this._cleanups.push(() => document.removeEventListener('DOMContentLoaded', go));\n return;\n }\n this.mount();\n }\n\n disconnectedCallback(): void {\n this._connected = false;\n this.teardown();\n }\n\n attributeChangedCallback(_name: string, oldValue: string | null, value: string | null): void {\n if (!this._connected || oldValue === value) return;\n this.changed(_name);\n }\n\n /** Re-mount on attribute change (override for finer updates). */\n changed(_name: string): void {\n this.teardown();\n this.mount();\n }\n\n private teardown(): void {\n this._cleanups.splice(0).reverse().forEach((fn) => fn());\n this.unmount();\n }\n\n mount(): void {}\n unmount(): void {}\n\n str(name: string, fallback = ''): string {\n const v = this.getAttribute(name);\n return v === null ? fallback : v;\n }\n\n num(name: string, fallback: number): number {\n const v = this.getAttribute(name);\n const n = v === null || v.trim() === '' ? NaN : Number(v);\n return Number.isFinite(n) ? n : fallback;\n }\n\n /** Boolean attribute: present and not `\"false\"`. */\n flag(name: string): boolean {\n const v = this.getAttribute(name);\n return v !== null && v !== 'false';\n }\n\n setFlag(name: string, on: boolean): void {\n if (on) this.setAttribute(name, '');\n else this.removeAttribute(name);\n }\n\n onCleanup(fn: Cleanup): void {\n this._cleanups.push(fn);\n }\n\n listen(target: EventTarget, type: string, fn: (e: any) => void, options?: AddEventListenerOptions): void {\n target.addEventListener(type, fn, options);\n this.onCleanup(() => target.removeEventListener(type, fn, options));\n }\n\n /** Calls `cb(true/false)` as the element enters / leaves the viewport. */\n inView(cb: (visible: boolean, entry?: IntersectionObserverEntry) => void, init?: IntersectionObserverInit, target: Element = this): void {\n if (typeof IntersectionObserver === 'undefined') {\n cb(true);\n return;\n }\n const io = new IntersectionObserver((entries) => {\n for (const e of entries) cb(e.isIntersecting, e);\n }, init);\n io.observe(target);\n this.onCleanup(() => io.disconnect());\n }\n\n /** `el.animate()` that returns `null` (and applies the last frame) without WAAPI. */\n motion(el: Element, keyframes: Keyframe[], options: KeyframeAnimationOptions): Animation | null {\n if (typeof (el as HTMLElement).animate !== 'function') {\n applyFrame(el as HTMLElement, keyframes[keyframes.length - 1]);\n return null;\n }\n const k = motionScale();\n if (k !== 1 && k > 0 && typeof options.duration === 'number') options = { ...options, duration: options.duration * k, delay: (options.delay || 0) * k };\n return (el as HTMLElement).animate(keyframes, options);\n }\n\n emit(type: string, detail?: unknown): boolean {\n return this.dispatchEvent(new CustomEvent(`usa:${type}`, { detail, bubbles: true, cancelable: true }));\n }\n }\n baseClass = Base as unknown as BaseCtor;\n return baseClass;\n}\n\n/** Write a keyframe's properties as inline styles (no-WAAPI fallback). */\nexport function applyFrame(el: HTMLElement, frame?: Keyframe): void {\n if (!frame) return;\n for (const [k, v] of Object.entries(frame)) {\n if (k === 'offset' || k === 'easing' || k === 'composite' || v == null) continue;\n (el.style as any)[k] = String(v);\n }\n}\n\n/**\n * Register `tag` with the class built by `make(Base)`. Returns the\n * constructor, the already registered one, or `undefined` without DOM.\n */\nexport function defineElement(\n tag: string,\n make: (Base: BaseCtor) => CustomElementConstructor,\n css?: { id: string; text: string }\n): CustomElementConstructor | undefined {\n if (!canDefine()) return undefined;\n adoptStyles('base', BASE_CSS);\n if (css) adoptStyles(css.id, css.text);\n const existing = customElements.get(tag);\n if (existing) return existing;\n const ctor = make(getBase());\n customElements.define(tag, ctor);\n return ctor;\n}\n\nconst BASE_CSS = '.usa-sr{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0 0 0 0);clip-path:inset(50%);white-space:nowrap;border:0}';\n\n/** A visually hidden copy of `text` for screen readers (the animated copy is `aria-hidden`). */\nexport function srText(text: string): HTMLSpanElement {\n const s = document.createElement('span');\n s.className = 'usa-sr';\n s.textContent = text;\n return s;\n}\n\n/** requestAnimationFrame with a timeout fallback (jsdom / hidden documents). */\nexport const raf = (cb: FrameRequestCallback): number =>\n typeof requestAnimationFrame === 'function' ? requestAnimationFrame(cb) : (setTimeout(() => cb(Date.now()), 16) as unknown as number);\n/** Monotonic time in ms (rAF callback timestamps differ between environments, so loops use this). */\nexport const now = (): number => (typeof performance !== 'undefined' ? performance.now() : Date.now());\nexport const caf = (id: number): void => {\n if (typeof cancelAnimationFrame === 'function') cancelAnimationFrame(id);\n else clearTimeout(id);\n};\n\n/** Spring-ish easing used across the components. */\nexport const EASE_OUT = 'cubic-bezier(0.22, 1, 0.36, 1)';\nexport const EASE_SPRING = 'cubic-bezier(0.34, 1.56, 0.64, 1)';\n/** Windows Fluent \"decelerate\" / \"point-to-point\" curves. */\nexport const FLUENT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AAW,KAAa,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC;;;;"}
@@ -1,4 +1,4 @@
1
- import { p as prefersReducedMotion, i as applyFrame, f as EASE_SPRING, n as now, r as raf, e as caf } from './base-08OYzphB.js';
1
+ import { p as prefersReducedMotion, j as applyFrame, m as motionScale, f as EASE_SPRING, n as now, r as raf, e as caf } from './base-D6zLiNGH.js';
2
2
 
3
3
  const SPRING_PRESETS = {
4
4
  default: { stiffness: 170, damping: 26, mass: 1 },
@@ -99,7 +99,7 @@ function spring(el, keyframes, input, options = {}) {
99
99
  return null;
100
100
  }
101
101
  const { easing, duration } = springEasing(input);
102
- return target.animate(keyframes, { duration, easing, fill: 'both', ...options });
102
+ return target.animate(keyframes, { duration: duration * motionScale(), easing, fill: 'both', ...options });
103
103
  }
104
104
  /**
105
105
  * An interruptible spring-animated number: call `set()` as often as you like,
@@ -216,4 +216,4 @@ function rubberBand(distance, dimension, constant = 0.55) {
216
216
  }
217
217
 
218
218
  export { SPRING_PRESETS as S, rubberBand as a, spring as b, createSpring as c, springEasing as d, springSamples as e, stepSpring as f, supportsLinearEasing as g, linearEasing as l, projectInertia as p, resolveSpring as r, snapTo as s };
219
- //# sourceMappingURL=spring-CpeFkxNd.js.map
219
+ //# sourceMappingURL=spring-C2Megtcf.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spring-C2Megtcf.js","sources":["../../src/components/physics/spring.ts"],"sourcesContent":["import { prefersReducedMotion, motionScale, raf, caf, now, applyFrame, EASE_SPRING } from '../base';\n\n/**\n * Spring physics core (v2.3). A damped harmonic oscillator integrated in\n * 1 ms steps: `stiffness` (k, N/m), `damping` (c) and `mass` (m). Used by\n * the `<usa-spring>`, `<usa-draggable>` and `<usa-overscroll>` elements and\n * exported for your own animations:\n *\n * - `springEasing()` turns a spring into a CSS `linear()` easing + duration\n * for WAAPI / CSS (falls back to a cubic-bezier overshoot where `linear()`\n * is unsupported);\n * - `spring(el, keyframes, cfg)` animates with it;\n * - `createSpring()` is an interruptible, velocity-preserving value for\n * gestures (drag, inertia, snap).\n */\nexport interface SpringConfig {\n /** Spring stiffness (default 170). Higher = faster, snappier. */\n stiffness?: number;\n /** Damping / friction (default 26). Lower = more bounces. */\n damping?: number;\n /** Mass (default 1). Higher = slower, heavier. */\n mass?: number;\n /** Initial velocity in progress units per second (default 0). */\n velocity?: number;\n /** Rest threshold (default 0.001). */\n precision?: number;\n}\n\nexport type SpringPreset = 'default' | 'gentle' | 'wobbly' | 'stiff' | 'bouncy' | 'slow' | 'molasses';\n\nexport const SPRING_PRESETS: Record<SpringPreset, Required<Pick<SpringConfig, 'stiffness' | 'damping' | 'mass'>>> = {\n default: { stiffness: 170, damping: 26, mass: 1 },\n gentle: { stiffness: 120, damping: 14, mass: 1 },\n wobbly: { stiffness: 180, damping: 12, mass: 1 },\n stiff: { stiffness: 210, damping: 20, mass: 1 },\n bouncy: { stiffness: 300, damping: 10, mass: 1 },\n slow: { stiffness: 280, damping: 60, mass: 1 },\n molasses: { stiffness: 280, damping: 120, mass: 1 },\n};\n\nexport type SpringInput = SpringPreset | SpringConfig | string | undefined;\n\n/** Resolve a preset name or a partial config to a full config. */\nexport function resolveSpring(input?: SpringInput): Required<SpringConfig> {\n const base = typeof input === 'string' ? SPRING_PRESETS[input as SpringPreset] || SPRING_PRESETS.default : { ...SPRING_PRESETS.default, ...(input || {}) };\n const pos = (v: unknown, d: number) => (typeof v === 'number' && Number.isFinite(v) && v > 0 ? v : d);\n const o = (typeof input === 'object' && input) || {};\n return {\n stiffness: pos(base.stiffness, 170),\n damping: Math.max(0, Number.isFinite(base.damping) ? base.damping : 26),\n mass: pos(base.mass, 1),\n velocity: Number.isFinite(o.velocity) ? (o.velocity as number) : 0,\n precision: pos(o.precision, 0.001),\n };\n}\n\n/** One integration step (semi-implicit Euler) towards `to`. Returns [x, v]. */\nexport function stepSpring(cfg: Required<SpringConfig>, x: number, v: number, to: number, dt: number): [number, number] {\n const a = (-cfg.stiffness * (x - to) - cfg.damping * v) / cfg.mass;\n const nv = v + a * dt;\n return [x + nv * dt, nv];\n}\n\nconst cache = new Map<string, { values: number[]; duration: number }>();\n\n/**\n * Sample the spring from 0 to 1 at `fps` (default 60). `values` may exceed 1\n * (overshoot); `duration` is the time to rest, in ms (max 10 s).\n */\nexport function springSamples(input?: SpringInput, fps = 60): { values: number[]; duration: number } {\n const cfg = resolveSpring(input);\n const key = `${cfg.stiffness}|${cfg.damping}|${cfg.mass}|${cfg.velocity}|${cfg.precision}|${fps}`;\n const hit = cache.get(key);\n if (hit) return hit;\n const values = [0];\n let x = 0;\n let v = cfg.velocity;\n const frame = 1000 / fps;\n let t = 0;\n let next = frame;\n while (t < 10000) {\n [x, v] = stepSpring(cfg, x, v, 1, 0.001);\n t += 1;\n if (t >= next) {\n values.push(x);\n next += frame;\n if (Math.abs(1 - x) < cfg.precision && Math.abs(v) < cfg.precision * 10) break;\n }\n }\n values[values.length - 1] = 1;\n const out = { values, duration: Math.round(t) };\n if (cache.size > 64) cache.clear();\n cache.set(key, out);\n return out;\n}\n\n/** `true` when CSS `linear()` easing is supported. */\nexport function supportsLinearEasing(): boolean {\n return typeof CSS !== 'undefined' && typeof CSS.supports === 'function' && CSS.supports('animation-timing-function', 'linear(0, 1)');\n}\n\n/**\n * The spring as `{ easing, duration }` for `el.animate()` / CSS. `easing` is\n * a `linear(…)` function with at most `points` stops (default 48), or a\n * cubic-bezier overshoot where `linear()` is unsupported.\n */\nexport function springEasing(input?: SpringInput, points = 48): { easing: string; duration: number } {\n const { values, duration } = springSamples(input);\n if (!supportsLinearEasing()) return { easing: EASE_SPRING, duration: Math.min(duration, 1200) };\n return { easing: linearEasing(values, points), duration };\n}\n\n/** Build a CSS `linear()` easing from samples (down-sampled to `points`). */\nexport function linearEasing(values: number[], points = 48): string {\n const n = values.length;\n const step = Math.max(1, Math.ceil((n - 1) / Math.max(2, points - 1)));\n const out: string[] = [];\n for (let i = 0; i < n - 1; i += step) out.push(String(Math.round(values[i] * 1000) / 1000));\n out.push('1');\n return `linear(${out.join(', ')})`;\n}\n\n/**\n * Animate `el` between keyframes with spring timing (WAAPI). Under reduced\n * motion the final frame is applied immediately. Returns the Animation (or\n * `null` without WAAPI / under reduced motion).\n */\nexport function spring(el: Element, keyframes: Keyframe[], input?: SpringInput, options: KeyframeAnimationOptions = {}): Animation | null {\n const target = el as HTMLElement;\n if (prefersReducedMotion() || typeof target.animate !== 'function') {\n applyFrame(target, keyframes[keyframes.length - 1]);\n return null;\n }\n const { easing, duration } = springEasing(input);\n return target.animate(keyframes, { duration: duration * motionScale(), easing, fill: 'both', ...options });\n}\n\n/* ------------------------------------------------------------------ */\n/* Interactive springs */\n/* ------------------------------------------------------------------ */\n\nexport interface SpringValueOptions {\n /** Start value (default 0). */\n value?: number;\n /** Spring config or preset (default `'default'`). */\n spring?: SpringInput;\n /** Called with the value every frame (and on `jump()`). */\n onUpdate?: (value: number, velocity: number) => void;\n /** Called when the value comes to rest at its target. */\n onRest?: (value: number) => void;\n}\n\nexport interface SpringValue {\n readonly value: number;\n /** Units per second. */\n readonly velocity: number;\n readonly target: number;\n readonly animating: boolean;\n /** Animate to `target`, optionally with a new initial velocity (units/s). */\n set(target: number, velocity?: number): void;\n /** Jump to `value` with no animation. */\n jump(value: number): void;\n /** Stop where it is. */\n stop(): void;\n /** Change the spring config. */\n configure(spring: SpringInput): void;\n}\n\n/**\n * An interruptible spring-animated number: call `set()` as often as you like,\n * the motion keeps its velocity (like iOS / Framer springs). Reduced motion\n * jumps straight to the target.\n */\nexport function createSpring(opts: SpringValueOptions = {}): SpringValue {\n let cfg = resolveSpring(opts.spring);\n let x = opts.value ?? 0;\n let v = 0;\n let to = x;\n let id = 0;\n let last = 0;\n let running = false;\n const stop = () => {\n if (running) caf(id);\n running = false;\n };\n const loop = () => {\n const t = now();\n let dt = Math.min(64, Math.max(1, t - last));\n last = t;\n while (dt > 0) {\n const s = Math.min(dt, 4);\n [x, v] = stepSpring(cfg, x, v, to, s / 1000);\n dt -= s;\n }\n const scale = Math.max(1, Math.abs(to) * 0.0005);\n if (Math.abs(to - x) < cfg.precision * scale * 10 && Math.abs(v) < cfg.precision * scale * 100) {\n x = to;\n v = 0;\n running = false;\n opts.onUpdate?.(x, 0);\n opts.onRest?.(x);\n return;\n }\n opts.onUpdate?.(x, v);\n id = raf(loop);\n };\n const api: SpringValue = {\n get value() {\n return x;\n },\n get velocity() {\n return v;\n },\n get target() {\n return to;\n },\n get animating() {\n return running;\n },\n set(target, velocity) {\n to = target;\n if (velocity !== undefined && Number.isFinite(velocity)) v = velocity;\n if (prefersReducedMotion()) {\n api.jump(target);\n opts.onRest?.(target);\n return;\n }\n if (!running) {\n running = true;\n last = now();\n id = raf(loop);\n }\n },\n jump(value) {\n stop();\n x = to = value;\n v = 0;\n opts.onUpdate?.(x, 0);\n },\n stop() {\n stop();\n v = 0;\n to = x;\n },\n configure(input) {\n cfg = resolveSpring(input);\n },\n };\n return api;\n}\n\n/* ------------------------------------------------------------------ */\n/* Inertia + snapping */\n/* ------------------------------------------------------------------ */\n\n/**\n * Where a flick at `velocity` (units/s) comes to rest with exponential\n * decay: `value + velocity · timeConstant` (default 0.325 s, iOS-like).\n */\nexport function projectInertia(value: number, velocity: number, timeConstant = 0.325): number {\n return value + velocity * timeConstant;\n}\n\n/** Snap to a grid (`number`) or the nearest of a list of points. */\nexport function snapTo(value: number, to: number | number[] | null | undefined): number {\n if (Array.isArray(to)) {\n if (!to.length) return value;\n return to.reduce((best, p) => (Math.abs(p - value) < Math.abs(best - value) ? p : best), to[0]);\n }\n if (typeof to === 'number' && to > 0) return Math.round(value / to) * to;\n return value;\n}\n\n/** iOS-style rubber-band resistance: how far content moves when pulled `distance` past an edge. */\nexport function rubberBand(distance: number, dimension: number, constant = 0.55): number {\n if (dimension <= 0) return 0;\n const sign = distance < 0 ? -1 : 1;\n const d = Math.abs(distance);\n return sign * (1 - 1 / ((d * constant) / dimension + 1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MAAM,CAAC,CAAC,IAAI,EAAE,CAAC,MAAM,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,GAAG,KAAK,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;IACjG;AACA,IAAA,IAAI,OAAO,EAAE,KAAK,QAAQ,IAAI,EAAE,GAAG,CAAC;QAAE,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,EAAE,CAAC,GAAG,EAAE;AACxE,IAAA,OAAO,KAAK;AACd;AAEA;AACM,SAAU,UAAU,CAAC,QAAgB,EAAE,SAAiB,EAAE,QAAQ,GAAG,IAAI,EAAA;IAC7E,IAAI,SAAS,IAAI,CAAC;AAAE,QAAA,OAAO,CAAC;AAC5B,IAAA,MAAM,IAAI,GAAG,QAAQ,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC;IAClC,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC;IAC5B,OAAO,IAAI,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,GAAG,QAAQ,IAAI,SAAS,GAAG,CAAC,CAAC,CAAC,GAAG,SAAS;AACtE;;;;"}
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var base = require('./base-5DFCAnvH.cjs');
3
+ var base = require('./base-BR6fYLBA.cjs');
4
4
 
5
5
  const SPRING_PRESETS = {
6
6
  default: { stiffness: 170, damping: 26, mass: 1 },
@@ -101,7 +101,7 @@ function spring(el, keyframes, input, options = {}) {
101
101
  return null;
102
102
  }
103
103
  const { easing, duration } = springEasing(input);
104
- return target.animate(keyframes, { duration, easing, fill: 'both', ...options });
104
+ return target.animate(keyframes, { duration: duration * base.motionScale(), easing, fill: 'both', ...options });
105
105
  }
106
106
  /**
107
107
  * An interruptible spring-animated number: call `set()` as often as you like,
@@ -229,4 +229,4 @@ exports.springEasing = springEasing;
229
229
  exports.springSamples = springSamples;
230
230
  exports.stepSpring = stepSpring;
231
231
  exports.supportsLinearEasing = supportsLinearEasing;
232
- //# sourceMappingURL=spring-Bi4qY0pL.cjs.map
232
+ //# sourceMappingURL=spring-DyHe1Hfa.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spring-DyHe1Hfa.cjs","sources":["../../src/components/physics/spring.ts"],"sourcesContent":["import { prefersReducedMotion, motionScale, raf, caf, now, applyFrame, EASE_SPRING } from '../base';\n\n/**\n * Spring physics core (v2.3). A damped harmonic oscillator integrated in\n * 1 ms steps: `stiffness` (k, N/m), `damping` (c) and `mass` (m). Used by\n * the `<usa-spring>`, `<usa-draggable>` and `<usa-overscroll>` elements and\n * exported for your own animations:\n *\n * - `springEasing()` turns a spring into a CSS `linear()` easing + duration\n * for WAAPI / CSS (falls back to a cubic-bezier overshoot where `linear()`\n * is unsupported);\n * - `spring(el, keyframes, cfg)` animates with it;\n * - `createSpring()` is an interruptible, velocity-preserving value for\n * gestures (drag, inertia, snap).\n */\nexport interface SpringConfig {\n /** Spring stiffness (default 170). Higher = faster, snappier. */\n stiffness?: number;\n /** Damping / friction (default 26). Lower = more bounces. */\n damping?: number;\n /** Mass (default 1). Higher = slower, heavier. */\n mass?: number;\n /** Initial velocity in progress units per second (default 0). */\n velocity?: number;\n /** Rest threshold (default 0.001). */\n precision?: number;\n}\n\nexport type SpringPreset = 'default' | 'gentle' | 'wobbly' | 'stiff' | 'bouncy' | 'slow' | 'molasses';\n\nexport const SPRING_PRESETS: Record<SpringPreset, Required<Pick<SpringConfig, 'stiffness' | 'damping' | 'mass'>>> = {\n default: { stiffness: 170, damping: 26, mass: 1 },\n gentle: { stiffness: 120, damping: 14, mass: 1 },\n wobbly: { stiffness: 180, damping: 12, mass: 1 },\n stiff: { stiffness: 210, damping: 20, mass: 1 },\n bouncy: { stiffness: 300, damping: 10, mass: 1 },\n slow: { stiffness: 280, damping: 60, mass: 1 },\n molasses: { stiffness: 280, damping: 120, mass: 1 },\n};\n\nexport type SpringInput = SpringPreset | SpringConfig | string | undefined;\n\n/** Resolve a preset name or a partial config to a full config. */\nexport function resolveSpring(input?: SpringInput): Required<SpringConfig> {\n const base = typeof input === 'string' ? SPRING_PRESETS[input as SpringPreset] || SPRING_PRESETS.default : { ...SPRING_PRESETS.default, ...(input || {}) };\n const pos = (v: unknown, d: number) => (typeof v === 'number' && Number.isFinite(v) && v > 0 ? v : d);\n const o = (typeof input === 'object' && input) || {};\n return {\n stiffness: pos(base.stiffness, 170),\n damping: Math.max(0, Number.isFinite(base.damping) ? base.damping : 26),\n mass: pos(base.mass, 1),\n velocity: Number.isFinite(o.velocity) ? (o.velocity as number) : 0,\n precision: pos(o.precision, 0.001),\n };\n}\n\n/** One integration step (semi-implicit Euler) towards `to`. Returns [x, v]. */\nexport function stepSpring(cfg: Required<SpringConfig>, x: number, v: number, to: number, dt: number): [number, number] {\n const a = (-cfg.stiffness * (x - to) - cfg.damping * v) / cfg.mass;\n const nv = v + a * dt;\n return [x + nv * dt, nv];\n}\n\nconst cache = new Map<string, { values: number[]; duration: number }>();\n\n/**\n * Sample the spring from 0 to 1 at `fps` (default 60). `values` may exceed 1\n * (overshoot); `duration` is the time to rest, in ms (max 10 s).\n */\nexport function springSamples(input?: SpringInput, fps = 60): { values: number[]; duration: number } {\n const cfg = resolveSpring(input);\n const key = `${cfg.stiffness}|${cfg.damping}|${cfg.mass}|${cfg.velocity}|${cfg.precision}|${fps}`;\n const hit = cache.get(key);\n if (hit) return hit;\n const values = [0];\n let x = 0;\n let v = cfg.velocity;\n const frame = 1000 / fps;\n let t = 0;\n let next = frame;\n while (t < 10000) {\n [x, v] = stepSpring(cfg, x, v, 1, 0.001);\n t += 1;\n if (t >= next) {\n values.push(x);\n next += frame;\n if (Math.abs(1 - x) < cfg.precision && Math.abs(v) < cfg.precision * 10) break;\n }\n }\n values[values.length - 1] = 1;\n const out = { values, duration: Math.round(t) };\n if (cache.size > 64) cache.clear();\n cache.set(key, out);\n return out;\n}\n\n/** `true` when CSS `linear()` easing is supported. */\nexport function supportsLinearEasing(): boolean {\n return typeof CSS !== 'undefined' && typeof CSS.supports === 'function' && CSS.supports('animation-timing-function', 'linear(0, 1)');\n}\n\n/**\n * The spring as `{ easing, duration }` for `el.animate()` / CSS. `easing` is\n * a `linear(…)` function with at most `points` stops (default 48), or a\n * cubic-bezier overshoot where `linear()` is unsupported.\n */\nexport function springEasing(input?: SpringInput, points = 48): { easing: string; duration: number } {\n const { values, duration } = springSamples(input);\n if (!supportsLinearEasing()) return { easing: EASE_SPRING, duration: Math.min(duration, 1200) };\n return { easing: linearEasing(values, points), duration };\n}\n\n/** Build a CSS `linear()` easing from samples (down-sampled to `points`). */\nexport function linearEasing(values: number[], points = 48): string {\n const n = values.length;\n const step = Math.max(1, Math.ceil((n - 1) / Math.max(2, points - 1)));\n const out: string[] = [];\n for (let i = 0; i < n - 1; i += step) out.push(String(Math.round(values[i] * 1000) / 1000));\n out.push('1');\n return `linear(${out.join(', ')})`;\n}\n\n/**\n * Animate `el` between keyframes with spring timing (WAAPI). Under reduced\n * motion the final frame is applied immediately. Returns the Animation (or\n * `null` without WAAPI / under reduced motion).\n */\nexport function spring(el: Element, keyframes: Keyframe[], input?: SpringInput, options: KeyframeAnimationOptions = {}): Animation | null {\n const target = el as HTMLElement;\n if (prefersReducedMotion() || typeof target.animate !== 'function') {\n applyFrame(target, keyframes[keyframes.length - 1]);\n return null;\n }\n const { easing, duration } = springEasing(input);\n return target.animate(keyframes, { duration: duration * motionScale(), easing, fill: 'both', ...options });\n}\n\n/* ------------------------------------------------------------------ */\n/* Interactive springs */\n/* ------------------------------------------------------------------ */\n\nexport interface SpringValueOptions {\n /** Start value (default 0). */\n value?: number;\n /** Spring config or preset (default `'default'`). */\n spring?: SpringInput;\n /** Called with the value every frame (and on `jump()`). */\n onUpdate?: (value: number, velocity: number) => void;\n /** Called when the value comes to rest at its target. */\n onRest?: (value: number) => void;\n}\n\nexport interface SpringValue {\n readonly value: number;\n /** Units per second. */\n readonly velocity: number;\n readonly target: number;\n readonly animating: boolean;\n /** Animate to `target`, optionally with a new initial velocity (units/s). */\n set(target: number, velocity?: number): void;\n /** Jump to `value` with no animation. */\n jump(value: number): void;\n /** Stop where it is. */\n stop(): void;\n /** Change the spring config. */\n configure(spring: SpringInput): void;\n}\n\n/**\n * An interruptible spring-animated number: call `set()` as often as you like,\n * the motion keeps its velocity (like iOS / Framer springs). Reduced motion\n * jumps straight to the target.\n */\nexport function createSpring(opts: SpringValueOptions = {}): SpringValue {\n let cfg = resolveSpring(opts.spring);\n let x = opts.value ?? 0;\n let v = 0;\n let to = x;\n let id = 0;\n let last = 0;\n let running = false;\n const stop = () => {\n if (running) caf(id);\n running = false;\n };\n const loop = () => {\n const t = now();\n let dt = Math.min(64, Math.max(1, t - last));\n last = t;\n while (dt > 0) {\n const s = Math.min(dt, 4);\n [x, v] = stepSpring(cfg, x, v, to, s / 1000);\n dt -= s;\n }\n const scale = Math.max(1, Math.abs(to) * 0.0005);\n if (Math.abs(to - x) < cfg.precision * scale * 10 && Math.abs(v) < cfg.precision * scale * 100) {\n x = to;\n v = 0;\n running = false;\n opts.onUpdate?.(x, 0);\n opts.onRest?.(x);\n return;\n }\n opts.onUpdate?.(x, v);\n id = raf(loop);\n };\n const api: SpringValue = {\n get value() {\n return x;\n },\n get velocity() {\n return v;\n },\n get target() {\n return to;\n },\n get animating() {\n return running;\n },\n set(target, velocity) {\n to = target;\n if (velocity !== undefined && Number.isFinite(velocity)) v = velocity;\n if (prefersReducedMotion()) {\n api.jump(target);\n opts.onRest?.(target);\n return;\n }\n if (!running) {\n running = true;\n last = now();\n id = raf(loop);\n }\n },\n jump(value) {\n stop();\n x = to = value;\n v = 0;\n opts.onUpdate?.(x, 0);\n },\n stop() {\n stop();\n v = 0;\n to = x;\n },\n configure(input) {\n cfg = resolveSpring(input);\n },\n };\n return api;\n}\n\n/* ------------------------------------------------------------------ */\n/* Inertia + snapping */\n/* ------------------------------------------------------------------ */\n\n/**\n * Where a flick at `velocity` (units/s) comes to rest with exponential\n * decay: `value + velocity · timeConstant` (default 0.325 s, iOS-like).\n */\nexport function projectInertia(value: number, velocity: number, timeConstant = 0.325): number {\n return value + velocity * timeConstant;\n}\n\n/** Snap to a grid (`number`) or the nearest of a list of points. */\nexport function snapTo(value: number, to: number | number[] | null | undefined): number {\n if (Array.isArray(to)) {\n if (!to.length) return value;\n return to.reduce((best, p) => (Math.abs(p - value) < Math.abs(best - value) ? p : best), to[0]);\n }\n if (typeof to === 'number' && to > 0) return Math.round(value / to) * to;\n return value;\n}\n\n/** iOS-style rubber-band resistance: how far content moves when pulled `distance` past an edge. */\nexport function rubberBand(distance: number, dimension: number, constant = 0.55): number {\n if (dimension <= 0) return 0;\n const sign = distance < 0 ? -1 : 1;\n const d = Math.abs(distance);\n return sign * (1 - 1 / ((d * constant) / dimension + 1)) * dimension;\n}\n"],"names":["EASE_SPRING","prefersReducedMotion","applyFrame","motionScale","caf","now","raf"],"mappings":";;;;AA8BO,MAAM,cAAc,GAAyF;AAClH,IAAA,OAAO,EAAE,EAAE,SAAS,EAAE,GAAG,EAAE,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE;AACjD,IAAA,MAAM,EAAE,EAAE,SAAS,EAAE,GAAG,EAAE,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE;AAChD,IAAA,MAAM,EAAE,EAAE,SAAS,EAAE,GAAG,EAAE,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE;AAChD,IAAA,KAAK,EAAE,EAAE,SAAS,EAAE,GAAG,EAAE,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE;AAC/C,IAAA,MAAM,EAAE,EAAE,SAAS,EAAE,GAAG,EAAE,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE;AAChD,IAAA,IAAI,EAAE,EAAE,SAAS,EAAE,GAAG,EAAE,OAAO,EAAE,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I,CAAC,GAAG,CAAC,QAAQ,CAAC;IAC5B,OAAO,IAAI,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,GAAG,QAAQ,IAAI,SAAS,GAAG,CAAC,CAAC,CAAC,GAAG,SAAS;AACtE;;;;;;;;;;;;;;;"}
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var base = require('../chunks/base-5DFCAnvH.cjs');
3
+ var base = require('../chunks/base-BR6fYLBA.cjs');
4
4
 
5
5
  var css$4 = "usa-aurora{position:relative;display:block;isolation:isolate;overflow:hidden}usa-aurora .usa-aurora-layer{position:absolute;inset:0;z-index:-1;pointer-events:none;opacity:var(--usa-aurora-opacity,0.7);overflow:hidden;contain:strict}usa-aurora .usa-aurora-layer i{position:absolute;display:block;width:70%;aspect-ratio:1;border-radius:50%;background:radial-gradient(closest-side,var(--c),transparent);will-change:transform;animation:usa-aurora-a var(--usa-aurora-speed,18s) ease-in-out infinite alternate}usa-aurora .usa-aurora-layer i:nth-child(1){left:-15%;top:-30%}usa-aurora .usa-aurora-layer i:nth-child(2){right:-20%;top:-10%;animation-name:usa-aurora-b;animation-duration:calc(var(--usa-aurora-speed,18s) * 1.3)}usa-aurora .usa-aurora-layer i:nth-child(3){left:10%;bottom:-45%;animation-name:usa-aurora-c;animation-duration:calc(var(--usa-aurora-speed,18s) * 0.9)}usa-aurora .usa-aurora-layer i:nth-child(4){right:0;bottom:-30%;width:50%;animation-name:usa-aurora-b;animation-direction:alternate-reverse}usa-aurora[paused] .usa-aurora-layer i,usa-aurora[data-offscreen] .usa-aurora-layer i{animation-play-state:paused}@keyframes usa-aurora-a{from{transform:translate3d(0,0,0) scale(1)}to{transform:translate3d(30%,20%,0) scale(1.25)}}@keyframes usa-aurora-b{from{transform:translate3d(0,0,0) scale(1.1)}to{transform:translate3d(-35%,25%,0) scale(0.85)}}@keyframes usa-aurora-c{from{transform:translate3d(0,0,0) rotate(0deg) scale(1)}to{transform:translate3d(25%,-30%,0) rotate(40deg) scale(1.2)}}@media (prefers-reduced-motion:reduce){usa-aurora .usa-aurora-layer i,usa-grain .usa-grain-layer,usa-acrylic::after{animation:none !important}}";
6
6
 
@@ -20,7 +20,15 @@ interface ComponentsConfig {
20
20
  * `'no-preference'` ignores the OS setting (only for demos — respect your users).
21
21
  */
22
22
  reducedMotion?: 'user' | 'reduce' | 'no-preference';
23
+ /**
24
+ * Global motion intensity (v2.7): `'off'` (same as reduced motion),
25
+ * `'low'` (shorter, calmer), `'normal'` (default) or `'high'`. Scales every
26
+ * component animation's duration and sets `--usa-motion` (0 / 0.6 / 1 /
27
+ * 1.25) on `<html>` for your own CSS. See `setMotionIntensity()`.
28
+ */
29
+ motionIntensity?: MotionIntensity;
23
30
  }
31
+ type MotionIntensity = 'off' | 'low' | 'normal' | 'high';
24
32
  /** Change global component settings (call before `define*()` for `injectStyles`). */
25
33
  declare function configureComponents(options: ComponentsConfig): void;
26
34
  /** `true` when animations should be reduced (OS setting or `configureComponents`). */
@@ -20,7 +20,15 @@ interface ComponentsConfig {
20
20
  * `'no-preference'` ignores the OS setting (only for demos — respect your users).
21
21
  */
22
22
  reducedMotion?: 'user' | 'reduce' | 'no-preference';
23
+ /**
24
+ * Global motion intensity (v2.7): `'off'` (same as reduced motion),
25
+ * `'low'` (shorter, calmer), `'normal'` (default) or `'high'`. Scales every
26
+ * component animation's duration and sets `--usa-motion` (0 / 0.6 / 1 /
27
+ * 1.25) on `<html>` for your own CSS. See `setMotionIntensity()`.
28
+ */
29
+ motionIntensity?: MotionIntensity;
23
30
  }
31
+ type MotionIntensity = 'off' | 'low' | 'normal' | 'high';
24
32
  /** Change global component settings (call before `define*()` for `injectStyles`). */
25
33
  declare function configureComponents(options: ComponentsConfig): void;
26
34
  /** `true` when animations should be reduced (OS setting or `configureComponents`). */
@@ -1,5 +1,5 @@
1
- import { d as defineElement, e as caf, r as raf } from '../chunks/base-08OYzphB.js';
2
- export { a as configureComponents, p as prefersReducedMotion } from '../chunks/base-08OYzphB.js';
1
+ import { d as defineElement, e as caf, r as raf } from '../chunks/base-D6zLiNGH.js';
2
+ export { a as configureComponents, p as prefersReducedMotion } from '../chunks/base-D6zLiNGH.js';
3
3
 
4
4
  var css$4 = "usa-aurora{position:relative;display:block;isolation:isolate;overflow:hidden}usa-aurora .usa-aurora-layer{position:absolute;inset:0;z-index:-1;pointer-events:none;opacity:var(--usa-aurora-opacity,0.7);overflow:hidden;contain:strict}usa-aurora .usa-aurora-layer i{position:absolute;display:block;width:70%;aspect-ratio:1;border-radius:50%;background:radial-gradient(closest-side,var(--c),transparent);will-change:transform;animation:usa-aurora-a var(--usa-aurora-speed,18s) ease-in-out infinite alternate}usa-aurora .usa-aurora-layer i:nth-child(1){left:-15%;top:-30%}usa-aurora .usa-aurora-layer i:nth-child(2){right:-20%;top:-10%;animation-name:usa-aurora-b;animation-duration:calc(var(--usa-aurora-speed,18s) * 1.3)}usa-aurora .usa-aurora-layer i:nth-child(3){left:10%;bottom:-45%;animation-name:usa-aurora-c;animation-duration:calc(var(--usa-aurora-speed,18s) * 0.9)}usa-aurora .usa-aurora-layer i:nth-child(4){right:0;bottom:-30%;width:50%;animation-name:usa-aurora-b;animation-direction:alternate-reverse}usa-aurora[paused] .usa-aurora-layer i,usa-aurora[data-offscreen] .usa-aurora-layer i{animation-play-state:paused}@keyframes usa-aurora-a{from{transform:translate3d(0,0,0) scale(1)}to{transform:translate3d(30%,20%,0) scale(1.25)}}@keyframes usa-aurora-b{from{transform:translate3d(0,0,0) scale(1.1)}to{transform:translate3d(-35%,25%,0) scale(0.85)}}@keyframes usa-aurora-c{from{transform:translate3d(0,0,0) rotate(0deg) scale(1)}to{transform:translate3d(25%,-30%,0) rotate(40deg) scale(1.2)}}@media (prefers-reduced-motion:reduce){usa-aurora .usa-aurora-layer i,usa-grain .usa-grain-layer,usa-acrylic::after{animation:none !important}}";
5
5
 
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var base = require('../chunks/base-5DFCAnvH.cjs');
4
- var spring = require('../chunks/spring-Bi4qY0pL.cjs');
3
+ var base = require('../chunks/base-BR6fYLBA.cjs');
4
+ var spring = require('../chunks/spring-DyHe1Hfa.cjs');
5
5
 
6
6
  var css$3 = "usa-card{--usa-card-radius:18px;--usa-card-bg:var(--usa-surface,#1b1e27);--usa-card-glow:var(--usa-accent,#7c5cff);--usa-card-x:50%;--usa-card-y:50%;--usa-card-nx:0;--usa-card-ny:0;position:relative;display:block;border-radius:var(--usa-card-radius);isolation:isolate;-webkit-tap-highlight-color:transparent}usa-card:focus-visible{outline:2px solid var(--usa-card-glow);outline-offset:3px}usa-card[effect~=\"lift\"]{transition:transform 0.45s cubic-bezier(0.34,1.56,0.64,1),box-shadow 0.45s ease}usa-card[effect~=\"lift\"][data-hover],usa-card[effect~=\"lift\"]:focus-visible{transform:translateY(-6px) perspective(900px) rotateX(calc(var(--usa-card-ny) * -4deg)) rotateY(calc(var(--usa-card-nx) * 4deg));box-shadow:0 22px 44px -18px rgb(0 0 0 / 0.55)}usa-card[effect~=\"glass\"]{background:color-mix(in srgb,var(--usa-card-bg) 45%,transparent);border:1px solid rgb(255 255 255 / 0.16);-webkit-backdrop-filter:blur(18px) saturate(1.5);backdrop-filter:blur(18px) saturate(1.5)}usa-card[effect~=\"spotlight\"]::before,usa-card[effect~=\"border-glow\"]::after{content:\"\";position:absolute;inset:0;border-radius:inherit;pointer-events:none;opacity:0;transition:opacity 0.3s ease}usa-card[effect~=\"spotlight\"]::before{z-index:-1;background:radial-gradient(260px circle at var(--usa-card-x) var(--usa-card-y),color-mix(in srgb,var(--usa-card-glow) 28%,transparent),transparent 70%)}usa-card[effect~=\"border-glow\"]::after{padding:1.5px;background:radial-gradient(180px circle at var(--usa-card-x) var(--usa-card-y),var(--usa-card-glow),transparent 70%);-webkit-mask:linear-gradient(#000 0 0) content-box exclude,linear-gradient(#000 0 0);mask:linear-gradient(#000 0 0) content-box exclude,linear-gradient(#000 0 0)}usa-card[data-hover]::before,usa-card[data-hover]::after{opacity:1}@property --usa-card-angle{syntax:\"<angle>\";inherits:false;initial-value:0deg}usa-card[effect~=\"conic-border\"]{border:2px solid transparent;background:linear-gradient(var(--usa-card-bg),var(--usa-card-bg)) padding-box,conic-gradient(from var(--usa-card-angle),var(--usa-card-glow),#22d3ee,#f472b6,var(--usa-card-glow)) border-box;animation:usa-card-spin 4s linear infinite}@keyframes usa-card-spin{to{--usa-card-angle:360deg}}usa-card .usa-card-sheen{position:absolute;inset:0;border-radius:inherit;overflow:hidden;pointer-events:none}usa-card .usa-card-sheen::before{content:\"\";position:absolute;top:0;bottom:0;width:45%;left:-60%;transform:skewX(-20deg);background:linear-gradient(90deg,transparent,rgb(255 255 255 / 0.35),transparent)}usa-card[effect~=\"sheen\"]:hover .usa-card-sheen::before,usa-card[effect~=\"sheen\"]:focus-visible .usa-card-sheen::before{left:130%;transition:left 0.8s cubic-bezier(0.22,1,0.36,1)}usa-card .usa-card-holo{position:absolute;inset:0;border-radius:inherit;pointer-events:none;mix-blend-mode:color-dodge;opacity:0.35;background:linear-gradient(115deg,transparent 20%,#ff7ad9 35%,#7af0ff 45%,#ffe27a 55%,transparent 70%) calc(var(--usa-card-x) * 1.4 - 20%) calc(var(--usa-card-y) * 1.4 - 20%) / 220% 220%;transition:opacity 0.3s ease}usa-card[data-hover] .usa-card-holo{opacity:0.7}usa-card[effect~=\"parallax-layers\"] [data-depth]{transition:transform 0.25s ease-out;will-change:transform}usa-card[effect~=\"flip\"]{perspective:1000px;display:grid}usa-card[effect~=\"flip\"]>[data-front],usa-card[effect~=\"flip\"]>[data-back]{grid-area:1 / 1;backface-visibility:hidden;-webkit-backface-visibility:hidden;border-radius:inherit;transition:transform 0.7s cubic-bezier(0.34,1.3,0.64,1),opacity 0.3s ease}usa-card[effect~=\"flip\"]>[data-back]{transform:rotateY(180deg)}usa-card[effect~=\"flip\"][axis=\"x\"]>[data-back]{transform:rotateX(180deg)}usa-card[effect~=\"flip\"][flipped]>[data-front],usa-card[effect~=\"flip\"]:not([trigger=\"click\"]):hover>[data-front]{transform:rotateY(-180deg)}usa-card[effect~=\"flip\"][flipped]>[data-back],usa-card[effect~=\"flip\"]:not([trigger=\"click\"]):hover>[data-back]{transform:rotateY(0deg)}usa-card[effect~=\"flip\"][axis=\"x\"][flipped]>[data-front],usa-card[effect~=\"flip\"][axis=\"x\"]:not([trigger=\"click\"]):hover>[data-front]{transform:rotateX(180deg)}usa-card[effect~=\"flip\"][axis=\"x\"][flipped]>[data-back],usa-card[effect~=\"flip\"][axis=\"x\"]:not([trigger=\"click\"]):hover>[data-back]{transform:rotateX(0deg)}usa-card[effect~=\"flip\"][trigger=\"click\"]{cursor:pointer}usa-card[effect~=\"expand\"]{cursor:zoom-in}usa-card[effect~=\"expand\"]:not([expanded]) [data-detail]{display:none}usa-card[expanded]{position:fixed;inset:6vh max(4vw,calc(50vw - 420px));z-index:1000;overflow:auto;cursor:default;background:var(--usa-card-bg);box-shadow:0 30px 80px -20px rgb(0 0 0 / 0.6)}.usa-card-backdrop{position:fixed;inset:0;z-index:999;background:rgb(0 0 0 / 0.45)}@media (prefers-reduced-motion:reduce){usa-card,usa-card *,usa-card .usa-card-sheen::before{transition-duration:0.01ms !important;animation:none !important}usa-card[effect~=\"lift\"][data-hover]{transform:none}usa-card[effect~=\"flip\"]>[data-front],usa-card[effect~=\"flip\"]>[data-back]{transform:none !important}usa-card[effect~=\"flip\"][flipped]>[data-front],usa-card[effect~=\"flip\"]:not([flipped])>[data-back]{opacity:0;visibility:hidden}usa-card[effect~=\"flip\"]:not([trigger=\"click\"]):hover>[data-front]{opacity:0;visibility:hidden}usa-card[effect~=\"flip\"]:not([trigger=\"click\"]):hover>[data-back]{opacity:1;visibility:visible}}@media (prefers-reduced-transparency:reduce),(forced-colors:active){usa-card[effect~=\"glass\"]{background:var(--usa-card-bg);-webkit-backdrop-filter:none;backdrop-filter:none}}";
7
7
 
@@ -20,7 +20,15 @@ interface ComponentsConfig {
20
20
  * `'no-preference'` ignores the OS setting (only for demos — respect your users).
21
21
  */
22
22
  reducedMotion?: 'user' | 'reduce' | 'no-preference';
23
+ /**
24
+ * Global motion intensity (v2.7): `'off'` (same as reduced motion),
25
+ * `'low'` (shorter, calmer), `'normal'` (default) or `'high'`. Scales every
26
+ * component animation's duration and sets `--usa-motion` (0 / 0.6 / 1 /
27
+ * 1.25) on `<html>` for your own CSS. See `setMotionIntensity()`.
28
+ */
29
+ motionIntensity?: MotionIntensity;
23
30
  }
31
+ type MotionIntensity = 'off' | 'low' | 'normal' | 'high';
24
32
  /** Change global component settings (call before `define*()` for `injectStyles`). */
25
33
  declare function configureComponents(options: ComponentsConfig): void;
26
34
  /** `true` when animations should be reduced (OS setting or `configureComponents`). */
@@ -20,7 +20,15 @@ interface ComponentsConfig {
20
20
  * `'no-preference'` ignores the OS setting (only for demos — respect your users).
21
21
  */
22
22
  reducedMotion?: 'user' | 'reduce' | 'no-preference';
23
+ /**
24
+ * Global motion intensity (v2.7): `'off'` (same as reduced motion),
25
+ * `'low'` (shorter, calmer), `'normal'` (default) or `'high'`. Scales every
26
+ * component animation's duration and sets `--usa-motion` (0 / 0.6 / 1 /
27
+ * 1.25) on `<html>` for your own CSS. See `setMotionIntensity()`.
28
+ */
29
+ motionIntensity?: MotionIntensity;
23
30
  }
31
+ type MotionIntensity = 'off' | 'low' | 'normal' | 'high';
24
32
  /** Change global component settings (call before `define*()` for `injectStyles`). */
25
33
  declare function configureComponents(options: ComponentsConfig): void;
26
34
  /** `true` when animations should be reduced (OS setting or `configureComponents`). */
@@ -1,6 +1,6 @@
1
- import { d as defineElement, r as raf, e as caf, E as EASE_OUT, b as clamp } from '../chunks/base-08OYzphB.js';
2
- export { a as configureComponents, p as prefersReducedMotion } from '../chunks/base-08OYzphB.js';
3
- import { d as springEasing, c as createSpring } from '../chunks/spring-CpeFkxNd.js';
1
+ import { d as defineElement, r as raf, e as caf, E as EASE_OUT, b as clamp } from '../chunks/base-D6zLiNGH.js';
2
+ export { a as configureComponents, p as prefersReducedMotion } from '../chunks/base-D6zLiNGH.js';
3
+ import { d as springEasing, c as createSpring } from '../chunks/spring-C2Megtcf.js';
4
4
 
5
5
  var css$3 = "usa-card{--usa-card-radius:18px;--usa-card-bg:var(--usa-surface,#1b1e27);--usa-card-glow:var(--usa-accent,#7c5cff);--usa-card-x:50%;--usa-card-y:50%;--usa-card-nx:0;--usa-card-ny:0;position:relative;display:block;border-radius:var(--usa-card-radius);isolation:isolate;-webkit-tap-highlight-color:transparent}usa-card:focus-visible{outline:2px solid var(--usa-card-glow);outline-offset:3px}usa-card[effect~=\"lift\"]{transition:transform 0.45s cubic-bezier(0.34,1.56,0.64,1),box-shadow 0.45s ease}usa-card[effect~=\"lift\"][data-hover],usa-card[effect~=\"lift\"]:focus-visible{transform:translateY(-6px) perspective(900px) rotateX(calc(var(--usa-card-ny) * -4deg)) rotateY(calc(var(--usa-card-nx) * 4deg));box-shadow:0 22px 44px -18px rgb(0 0 0 / 0.55)}usa-card[effect~=\"glass\"]{background:color-mix(in srgb,var(--usa-card-bg) 45%,transparent);border:1px solid rgb(255 255 255 / 0.16);-webkit-backdrop-filter:blur(18px) saturate(1.5);backdrop-filter:blur(18px) saturate(1.5)}usa-card[effect~=\"spotlight\"]::before,usa-card[effect~=\"border-glow\"]::after{content:\"\";position:absolute;inset:0;border-radius:inherit;pointer-events:none;opacity:0;transition:opacity 0.3s ease}usa-card[effect~=\"spotlight\"]::before{z-index:-1;background:radial-gradient(260px circle at var(--usa-card-x) var(--usa-card-y),color-mix(in srgb,var(--usa-card-glow) 28%,transparent),transparent 70%)}usa-card[effect~=\"border-glow\"]::after{padding:1.5px;background:radial-gradient(180px circle at var(--usa-card-x) var(--usa-card-y),var(--usa-card-glow),transparent 70%);-webkit-mask:linear-gradient(#000 0 0) content-box exclude,linear-gradient(#000 0 0);mask:linear-gradient(#000 0 0) content-box exclude,linear-gradient(#000 0 0)}usa-card[data-hover]::before,usa-card[data-hover]::after{opacity:1}@property --usa-card-angle{syntax:\"<angle>\";inherits:false;initial-value:0deg}usa-card[effect~=\"conic-border\"]{border:2px solid transparent;background:linear-gradient(var(--usa-card-bg),var(--usa-card-bg)) padding-box,conic-gradient(from var(--usa-card-angle),var(--usa-card-glow),#22d3ee,#f472b6,var(--usa-card-glow)) border-box;animation:usa-card-spin 4s linear infinite}@keyframes usa-card-spin{to{--usa-card-angle:360deg}}usa-card .usa-card-sheen{position:absolute;inset:0;border-radius:inherit;overflow:hidden;pointer-events:none}usa-card .usa-card-sheen::before{content:\"\";position:absolute;top:0;bottom:0;width:45%;left:-60%;transform:skewX(-20deg);background:linear-gradient(90deg,transparent,rgb(255 255 255 / 0.35),transparent)}usa-card[effect~=\"sheen\"]:hover .usa-card-sheen::before,usa-card[effect~=\"sheen\"]:focus-visible .usa-card-sheen::before{left:130%;transition:left 0.8s cubic-bezier(0.22,1,0.36,1)}usa-card .usa-card-holo{position:absolute;inset:0;border-radius:inherit;pointer-events:none;mix-blend-mode:color-dodge;opacity:0.35;background:linear-gradient(115deg,transparent 20%,#ff7ad9 35%,#7af0ff 45%,#ffe27a 55%,transparent 70%) calc(var(--usa-card-x) * 1.4 - 20%) calc(var(--usa-card-y) * 1.4 - 20%) / 220% 220%;transition:opacity 0.3s ease}usa-card[data-hover] .usa-card-holo{opacity:0.7}usa-card[effect~=\"parallax-layers\"] [data-depth]{transition:transform 0.25s ease-out;will-change:transform}usa-card[effect~=\"flip\"]{perspective:1000px;display:grid}usa-card[effect~=\"flip\"]>[data-front],usa-card[effect~=\"flip\"]>[data-back]{grid-area:1 / 1;backface-visibility:hidden;-webkit-backface-visibility:hidden;border-radius:inherit;transition:transform 0.7s cubic-bezier(0.34,1.3,0.64,1),opacity 0.3s ease}usa-card[effect~=\"flip\"]>[data-back]{transform:rotateY(180deg)}usa-card[effect~=\"flip\"][axis=\"x\"]>[data-back]{transform:rotateX(180deg)}usa-card[effect~=\"flip\"][flipped]>[data-front],usa-card[effect~=\"flip\"]:not([trigger=\"click\"]):hover>[data-front]{transform:rotateY(-180deg)}usa-card[effect~=\"flip\"][flipped]>[data-back],usa-card[effect~=\"flip\"]:not([trigger=\"click\"]):hover>[data-back]{transform:rotateY(0deg)}usa-card[effect~=\"flip\"][axis=\"x\"][flipped]>[data-front],usa-card[effect~=\"flip\"][axis=\"x\"]:not([trigger=\"click\"]):hover>[data-front]{transform:rotateX(180deg)}usa-card[effect~=\"flip\"][axis=\"x\"][flipped]>[data-back],usa-card[effect~=\"flip\"][axis=\"x\"]:not([trigger=\"click\"]):hover>[data-back]{transform:rotateX(0deg)}usa-card[effect~=\"flip\"][trigger=\"click\"]{cursor:pointer}usa-card[effect~=\"expand\"]{cursor:zoom-in}usa-card[effect~=\"expand\"]:not([expanded]) [data-detail]{display:none}usa-card[expanded]{position:fixed;inset:6vh max(4vw,calc(50vw - 420px));z-index:1000;overflow:auto;cursor:default;background:var(--usa-card-bg);box-shadow:0 30px 80px -20px rgb(0 0 0 / 0.6)}.usa-card-backdrop{position:fixed;inset:0;z-index:999;background:rgb(0 0 0 / 0.45)}@media (prefers-reduced-motion:reduce){usa-card,usa-card *,usa-card .usa-card-sheen::before{transition-duration:0.01ms !important;animation:none !important}usa-card[effect~=\"lift\"][data-hover]{transform:none}usa-card[effect~=\"flip\"]>[data-front],usa-card[effect~=\"flip\"]>[data-back]{transform:none !important}usa-card[effect~=\"flip\"][flipped]>[data-front],usa-card[effect~=\"flip\"]:not([flipped])>[data-back]{opacity:0;visibility:hidden}usa-card[effect~=\"flip\"]:not([trigger=\"click\"]):hover>[data-front]{opacity:0;visibility:hidden}usa-card[effect~=\"flip\"]:not([trigger=\"click\"]):hover>[data-back]{opacity:1;visibility:visible}}@media (prefers-reduced-transparency:reduce),(forced-colors:active){usa-card[effect~=\"glass\"]{background:var(--usa-card-bg);-webkit-backdrop-filter:none;backdrop-filter:none}}";
6
6
 
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var base = require('../chunks/base-5DFCAnvH.cjs');
4
- var spring = require('../chunks/spring-Bi4qY0pL.cjs');
3
+ var base = require('../chunks/base-BR6fYLBA.cjs');
4
+ var spring = require('../chunks/spring-DyHe1Hfa.cjs');
5
5
 
6
6
  /**
7
7
  * Click-effect helpers (v2.5): `burst()`, `confetti()`, `shake()`, `haptic()`.
@@ -20,7 +20,15 @@ interface ComponentsConfig {
20
20
  * `'no-preference'` ignores the OS setting (only for demos — respect your users).
21
21
  */
22
22
  reducedMotion?: 'user' | 'reduce' | 'no-preference';
23
+ /**
24
+ * Global motion intensity (v2.7): `'off'` (same as reduced motion),
25
+ * `'low'` (shorter, calmer), `'normal'` (default) or `'high'`. Scales every
26
+ * component animation's duration and sets `--usa-motion` (0 / 0.6 / 1 /
27
+ * 1.25) on `<html>` for your own CSS. See `setMotionIntensity()`.
28
+ */
29
+ motionIntensity?: MotionIntensity;
23
30
  }
31
+ type MotionIntensity = 'off' | 'low' | 'normal' | 'high';
24
32
  /** Change global component settings (call before `define*()` for `injectStyles`). */
25
33
  declare function configureComponents(options: ComponentsConfig): void;
26
34
  /** `true` when animations should be reduced (OS setting or `configureComponents`). */
@@ -20,7 +20,15 @@ interface ComponentsConfig {
20
20
  * `'no-preference'` ignores the OS setting (only for demos — respect your users).
21
21
  */
22
22
  reducedMotion?: 'user' | 'reduce' | 'no-preference';
23
+ /**
24
+ * Global motion intensity (v2.7): `'off'` (same as reduced motion),
25
+ * `'low'` (shorter, calmer), `'normal'` (default) or `'high'`. Scales every
26
+ * component animation's duration and sets `--usa-motion` (0 / 0.6 / 1 /
27
+ * 1.25) on `<html>` for your own CSS. See `setMotionIntensity()`.
28
+ */
29
+ motionIntensity?: MotionIntensity;
23
30
  }
31
+ type MotionIntensity = 'off' | 'low' | 'normal' | 'high';
24
32
  /** Change global component settings (call before `define*()` for `injectStyles`). */
25
33
  declare function configureComponents(options: ComponentsConfig): void;
26
34
  /** `true` when animations should be reduced (OS setting or `configureComponents`). */