use-scroll-animate 4.3.0 → 4.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +24 -0
- package/dist/chunks/{base-BPG5zvex.js → base-CZiIAMBc.js} +140 -13
- package/dist/chunks/base-CZiIAMBc.js.map +1 -0
- package/dist/chunks/{base-CXx7jZ-o.cjs → base-CxYU2NK_.cjs} +148 -12
- package/dist/chunks/base-CxYU2NK_.cjs.map +1 -0
- package/dist/chunks/{core-LkGRmgES.js → core-CJHJeMI_.js} +2 -2
- package/dist/chunks/{core-LkGRmgES.js.map → core-CJHJeMI_.js.map} +1 -1
- package/dist/chunks/{core-eXX8rB_b.js → core-COi3DrLx.js} +2 -2
- package/dist/chunks/{core-eXX8rB_b.js.map → core-COi3DrLx.js.map} +1 -1
- package/dist/chunks/{core-IaorbTdu.cjs → core-CctNfzuP.cjs} +2 -2
- package/dist/chunks/{core-IaorbTdu.cjs.map → core-CctNfzuP.cjs.map} +1 -1
- package/dist/chunks/{core-BRIIoKeS.cjs → core-HLqH3qkA.cjs} +2 -2
- package/dist/chunks/{core-BRIIoKeS.cjs.map → core-HLqH3qkA.cjs.map} +1 -1
- package/dist/chunks/{spring-BziPsW3r.js → spring-BS5tg6aK.js} +2 -2
- package/dist/chunks/{spring-BziPsW3r.js.map → spring-BS5tg6aK.js.map} +1 -1
- package/dist/chunks/{spring-2OTnYCzm.cjs → spring-Dkpygsuj.cjs} +2 -2
- package/dist/chunks/{spring-2OTnYCzm.cjs.map → spring-Dkpygsuj.cjs.map} +1 -1
- package/dist/chunks/{variants-BNIrn4ch.cjs → variants-CfJzrzMh.cjs} +2 -2
- package/dist/chunks/{variants-BNIrn4ch.cjs.map → variants-CfJzrzMh.cjs.map} +1 -1
- package/dist/chunks/{variants-BVYMcxRv.js → variants-D9n-3x27.js} +2 -2
- package/dist/chunks/{variants-BVYMcxRv.js.map → variants-D9n-3x27.js.map} +1 -1
- package/dist/components/a11y.cjs +239 -0
- package/dist/components/a11y.cjs.map +1 -0
- package/dist/components/a11y.d.cts +120 -0
- package/dist/components/a11y.d.ts +120 -0
- package/dist/components/a11y.js +224 -0
- package/dist/components/a11y.js.map +1 -0
- package/dist/components/angular.cjs +7 -5
- package/dist/components/angular.cjs.map +1 -1
- package/dist/components/angular.js +7 -5
- package/dist/components/angular.js.map +1 -1
- package/dist/components/background.cjs +2 -2
- package/dist/components/background.d.cts +10 -0
- package/dist/components/background.d.ts +10 -0
- package/dist/components/background.js +3 -3
- package/dist/components/cards.cjs +2 -2
- package/dist/components/cards.d.cts +10 -0
- package/dist/components/cards.d.ts +10 -0
- package/dist/components/cards.js +3 -3
- package/dist/components/click.cjs +2 -2
- package/dist/components/click.d.cts +10 -0
- package/dist/components/click.d.ts +10 -0
- package/dist/components/click.js +3 -3
- package/dist/components/depth.cjs +3 -3
- package/dist/components/depth.d.cts +10 -0
- package/dist/components/depth.d.ts +10 -0
- package/dist/components/depth.js +4 -4
- package/dist/components/feedback.cjs +1 -1
- package/dist/components/feedback.d.cts +10 -0
- package/dist/components/feedback.d.ts +10 -0
- package/dist/components/feedback.js +2 -2
- package/dist/components/gesture.cjs +3 -3
- package/dist/components/gesture.d.cts +10 -0
- package/dist/components/gesture.d.ts +10 -0
- package/dist/components/gesture.js +5 -5
- package/dist/components/interaction.cjs +1 -1
- package/dist/components/interaction.d.cts +10 -0
- package/dist/components/interaction.d.ts +10 -0
- package/dist/components/interaction.js +2 -2
- package/dist/components/layout.cjs +1 -1
- package/dist/components/layout.d.cts +10 -0
- package/dist/components/layout.d.ts +10 -0
- package/dist/components/layout.js +2 -2
- package/dist/components/lite.cjs +10398 -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 +10161 -0
- package/dist/components/lite.js.map +1 -0
- package/dist/components/packs.cjs +1 -1
- package/dist/components/packs.d.cts +10 -0
- package/dist/components/packs.d.ts +10 -0
- package/dist/components/packs.js +2 -2
- package/dist/components/page.cjs +6 -3
- package/dist/components/page.cjs.map +1 -1
- package/dist/components/page.d.cts +10 -0
- package/dist/components/page.d.ts +10 -0
- package/dist/components/page.js +7 -4
- package/dist/components/page.js.map +1 -1
- package/dist/components/perf.cjs +121 -0
- package/dist/components/perf.cjs.map +1 -0
- package/dist/components/perf.d.cts +97 -0
- package/dist/components/perf.d.ts +97 -0
- package/dist/components/perf.js +111 -0
- package/dist/components/perf.js.map +1 -0
- package/dist/components/physics.cjs +2 -2
- package/dist/components/physics.d.cts +10 -0
- package/dist/components/physics.d.ts +10 -0
- package/dist/components/physics.js +4 -4
- package/dist/components/reveal.cjs +1 -1
- package/dist/components/reveal.d.cts +10 -0
- package/dist/components/reveal.d.ts +10 -0
- package/dist/components/reveal.js +2 -2
- package/dist/components/solid.cjs +7 -5
- package/dist/components/solid.cjs.map +1 -1
- package/dist/components/solid.js +7 -5
- package/dist/components/solid.js.map +1 -1
- package/dist/components/svelte.cjs +7 -5
- package/dist/components/svelte.cjs.map +1 -1
- package/dist/components/svelte.js +7 -5
- package/dist/components/svelte.js.map +1 -1
- package/dist/components/svg.cjs +1 -1
- package/dist/components/svg.d.cts +10 -0
- package/dist/components/svg.d.ts +10 -0
- package/dist/components/svg.js +2 -2
- package/dist/components/text.cjs +2 -2
- package/dist/components/text.d.cts +10 -0
- package/dist/components/text.d.ts +10 -0
- package/dist/components/text.js +3 -3
- package/dist/components/timeline.cjs +2 -2
- package/dist/components/timeline.d.cts +10 -0
- package/dist/components/timeline.d.ts +10 -0
- package/dist/components/timeline.js +4 -4
- package/dist/components/transitions.cjs +1 -1
- package/dist/components/transitions.d.cts +10 -0
- package/dist/components/transitions.d.ts +10 -0
- package/dist/components/transitions.js +2 -2
- package/dist/components/ui.cjs +3 -3
- package/dist/components/ui.d.cts +10 -0
- package/dist/components/ui.d.ts +10 -0
- package/dist/components/ui.js +5 -5
- package/dist/components/vue.cjs +7 -5
- package/dist/components/vue.cjs.map +1 -1
- package/dist/components/vue.js +7 -5
- package/dist/components/vue.js.map +1 -1
- package/dist/components/webgl.cjs +1 -1
- package/dist/components/webgl.d.cts +10 -0
- package/dist/components/webgl.d.ts +10 -0
- package/dist/components/webgl.js +2 -2
- package/dist/components.cjs +32 -5
- package/dist/components.cjs.map +1 -1
- package/dist/components.d.cts +176 -2
- package/dist/components.d.ts +176 -2
- package/dist/components.js +9 -7
- package/dist/components.js.map +1 -1
- package/dist/components.umd.js +2 -2
- package/dist/components.umd.js.map +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.js +2 -2
- package/dist/index.umd.js +2 -2
- package/dist/index.umd.js.map +1 -1
- package/docs/ROADMAP.md +2 -2
- package/docs/accessibility.md +28 -0
- package/docs/performance.md +24 -0
- package/package.json +31 -1
- package/dist/chunks/base-BPG5zvex.js.map +0 -1
- package/dist/chunks/base-CXx7jZ-o.cjs.map +0 -1
package/dist/components.d.cts
CHANGED
|
@@ -27,11 +27,30 @@ interface ComponentsConfig {
|
|
|
27
27
|
* 1.25) on `<html>` for your own CSS. See `setMotionIntensity()`.
|
|
28
28
|
*/
|
|
29
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 `use-scroll-animate/components/a11y`.
|
|
37
|
+
*/
|
|
38
|
+
motionSensitivity?: MotionSensitivity;
|
|
30
39
|
}
|
|
40
|
+
type MotionSensitivity = 'full' | 'gentle' | 'minimal' | 'static';
|
|
41
|
+
declare const MOTION_SENSITIVITY_LEVELS: readonly MotionSensitivity[];
|
|
31
42
|
type MotionIntensity = 'off' | 'low' | 'normal' | 'high';
|
|
32
43
|
declare const MOTION_SCALE: Record<MotionIntensity, number>;
|
|
33
44
|
/** Change global component settings (call before `define*()` for `injectStyles`). */
|
|
34
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[];
|
|
35
54
|
/** The current global motion intensity. */
|
|
36
55
|
declare function getMotionIntensity(): MotionIntensity;
|
|
37
56
|
/** `true` when animations should be reduced (OS setting or `configureComponents`). */
|
|
@@ -45,6 +64,22 @@ interface UsaElement extends HTMLElement {
|
|
|
45
64
|
/** `true` while reduced motion applies to this element. */
|
|
46
65
|
readonly reduced: boolean;
|
|
47
66
|
}
|
|
67
|
+
/** Run `fn(time, dt)` every frame on the shared scheduler until the returned function is called. */
|
|
68
|
+
declare function onFrame(fn: (t: number, dt: number) => void): () => void;
|
|
69
|
+
/** Scheduler counters: frames flushed, callbacks run, peak callbacks in one frame, pending now. */
|
|
70
|
+
declare function schedulerStats(): {
|
|
71
|
+
frames: number;
|
|
72
|
+
callbacks: number;
|
|
73
|
+
peak: number;
|
|
74
|
+
pending: number;
|
|
75
|
+
loops: number;
|
|
76
|
+
};
|
|
77
|
+
/** Number of component animations running right now. */
|
|
78
|
+
declare const activeAnimations: () => number;
|
|
79
|
+
/** Cap concurrent component animations; extra ones jump to their final frame (`Infinity` = no cap). */
|
|
80
|
+
declare function setAnimationBudget(max: number): void;
|
|
81
|
+
/** The current cap. */
|
|
82
|
+
declare const animationBudget: () => number;
|
|
48
83
|
|
|
49
84
|
/** Entrance effects shared by `<usa-reveal>` and `<usa-stagger>` (transform / opacity / filter only). */
|
|
50
85
|
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"];
|
|
@@ -2574,11 +2609,150 @@ declare const COMPONENT_CATEGORIES: {
|
|
|
2574
2609
|
};
|
|
2575
2610
|
type ComponentCategory = keyof typeof COMPONENT_CATEGORIES;
|
|
2576
2611
|
|
|
2612
|
+
/**
|
|
2613
|
+
* use-scroll-animate/components/a11y — accessibility toolkit (4.4).
|
|
2614
|
+
*
|
|
2615
|
+
* - Motion-sensitivity levels: `setMotionSensitivity('full' | 'gentle' | 'minimal' | 'static')`.
|
|
2616
|
+
* - Static alternatives: what every component shows when motion is off, and
|
|
2617
|
+
* `staticAlternative(root)` to freeze any subtree at its final state.
|
|
2618
|
+
* - `aria-live` conventions: one shared polite and one assertive region,
|
|
2619
|
+
* `announce(message, { politeness })`.
|
|
2620
|
+
* - `auditMotionA11y(root)`: the rules the automated regression tests run
|
|
2621
|
+
* over every `<usa-*>` element — usable in your own tests too.
|
|
2622
|
+
*
|
|
2623
|
+
* ```ts
|
|
2624
|
+
* import { setMotionSensitivity, announce, auditMotionA11y } from 'use-scroll-animate/components/a11y';
|
|
2625
|
+
* setMotionSensitivity('gentle', true); // no spins / zooms / parallax, remembered
|
|
2626
|
+
* announce('3 items added to cart'); // polite live region
|
|
2627
|
+
* expect(auditMotionA11y(document.body).errors).toEqual([]);
|
|
2628
|
+
* ```
|
|
2629
|
+
*/
|
|
2630
|
+
|
|
2631
|
+
/** What each level allows, for docs and settings UIs. */
|
|
2632
|
+
declare const MOTION_SENSITIVITY: Record<MotionSensitivity, {
|
|
2633
|
+
en: string;
|
|
2634
|
+
zh: string;
|
|
2635
|
+
allows: string[];
|
|
2636
|
+
}>;
|
|
2637
|
+
/** CSS applied at the `static` / `minimal` / `gentle` levels (also stops your own CSS animations under `static`). */
|
|
2638
|
+
declare const SENSITIVITY_CSS: string;
|
|
2639
|
+
/**
|
|
2640
|
+
* Set the motion-sensitivity level for every `<usa-*>` component and the page:
|
|
2641
|
+
* sets `data-usa-sensitivity` on `<html>`, adapts component keyframes, and
|
|
2642
|
+
* with `persist` remembers the choice (`restoreMotionSensitivity()`).
|
|
2643
|
+
* Dispatches `usa:sensitivity` on `document`.
|
|
2644
|
+
*/
|
|
2645
|
+
declare function setMotionSensitivity(level: MotionSensitivity, persist?: boolean): void;
|
|
2646
|
+
/** Re-apply a persisted level (call early on page load). Returns the active level. */
|
|
2647
|
+
declare function restoreMotionSensitivity(): MotionSensitivity;
|
|
2648
|
+
/** `true` when the current level allows a kind of motion (`'rotate'`, `'parallax'`, `'loop'`…). */
|
|
2649
|
+
declare function motionAllowed(kind: string, level?: MotionSensitivity): boolean;
|
|
2650
|
+
/** The static alternative of each category: what its elements show without motion. */
|
|
2651
|
+
declare const STATIC_ALTERNATIVES: Record<ComponentCategory, string>;
|
|
2652
|
+
/**
|
|
2653
|
+
* Freeze a subtree at its static alternative: finishes running animations
|
|
2654
|
+
* (`finish()`, so content lands on its final state), marks the root with
|
|
2655
|
+
* `data-usa-static` and returns an undo that removes the mark.
|
|
2656
|
+
*/
|
|
2657
|
+
declare function staticAlternative(root: Element): () => void;
|
|
2658
|
+
type Politeness = 'polite' | 'assertive';
|
|
2659
|
+
/** The ids of the shared live regions. */
|
|
2660
|
+
declare const LIVE_REGION_IDS: Record<Politeness, string>;
|
|
2661
|
+
/** The shared live region (created once, visually hidden, `role="status"` / `role="alert"`). */
|
|
2662
|
+
declare function liveRegion(politeness?: Politeness): HTMLElement | null;
|
|
2663
|
+
/**
|
|
2664
|
+
* Announce a message through the shared live region. Conventions: `polite`
|
|
2665
|
+
* for results of the user's own actions (added, saved, copied), `assertive`
|
|
2666
|
+
* only for errors that block them. Identical messages within `dedupe` ms
|
|
2667
|
+
* (default 500) are dropped; the region is cleared first so repeats are read.
|
|
2668
|
+
*/
|
|
2669
|
+
declare function announce(message: string, options?: {
|
|
2670
|
+
politeness?: Politeness;
|
|
2671
|
+
dedupe?: number;
|
|
2672
|
+
}): boolean;
|
|
2673
|
+
interface A11yIssue {
|
|
2674
|
+
rule: string;
|
|
2675
|
+
level: 'error' | 'warning';
|
|
2676
|
+
element: Element;
|
|
2677
|
+
message: string;
|
|
2678
|
+
}
|
|
2679
|
+
/**
|
|
2680
|
+
* Check a subtree against the library's motion-a11y rules:
|
|
2681
|
+
* - `aria-hidden-focusable` (error): focusable content inside `aria-hidden`.
|
|
2682
|
+
* - `role-name` (error): a widget role without an accessible name.
|
|
2683
|
+
* - `range-value` (error): a slider / determinate progressbar without `aria-valuenow`.
|
|
2684
|
+
* - `img-alt` (error): an `<img>` without `alt`.
|
|
2685
|
+
* - `assertive-live` (warning): `aria-live="assertive"` outside `role="alert"`.
|
|
2686
|
+
* - `infinite-no-control` (warning, WCAG 2.2.2): an endless animation on a
|
|
2687
|
+
* page with no way to pause motion (`<usa-motion-switch>` or `[data-usa-pause]`).
|
|
2688
|
+
*/
|
|
2689
|
+
declare function auditMotionA11y(root: Element | Document): {
|
|
2690
|
+
errors: A11yIssue[];
|
|
2691
|
+
warnings: A11yIssue[];
|
|
2692
|
+
};
|
|
2693
|
+
/** Every `<usa-*>` tag, for sweeping audits. */
|
|
2694
|
+
declare const ALL_TAGS: string[];
|
|
2695
|
+
|
|
2696
|
+
/**
|
|
2697
|
+
* use-scroll-animate/components/perf — performance toolkit (4.5).
|
|
2698
|
+
*
|
|
2699
|
+
* - One shared rAF scheduler for every component loop (`onFrame()`, `schedulerStats()`).
|
|
2700
|
+
* - Animation budget: `setAnimationBudget(n)` caps concurrent component
|
|
2701
|
+
* animations; extra ones land on their final frame.
|
|
2702
|
+
* - `autoDegrade()`: watches frame rate and animation count and steps motion
|
|
2703
|
+
* down (`low`, then a tighter budget) while the device struggles, restoring
|
|
2704
|
+
* it when frames recover.
|
|
2705
|
+
* - On-demand CSS: `loadCategoryStyles()` / `onDemandStyles()` — used by
|
|
2706
|
+
* `use-scroll-animate/components/lite`, the build without inlined CSS.
|
|
2707
|
+
*/
|
|
2708
|
+
|
|
2709
|
+
interface AutoDegradeOptions {
|
|
2710
|
+
/** Frame rate below which motion is degraded (default 45). */
|
|
2711
|
+
minFps?: number;
|
|
2712
|
+
/** Concurrent animations above which motion is degraded (default 40). */
|
|
2713
|
+
maxActive?: number;
|
|
2714
|
+
/** Sample window in ms (default 1000). */
|
|
2715
|
+
sample?: number;
|
|
2716
|
+
/** Bad samples in a row before degrading (default 2). */
|
|
2717
|
+
patience?: number;
|
|
2718
|
+
/** Good samples in a row before restoring (default 3). */
|
|
2719
|
+
recovery?: number;
|
|
2720
|
+
/** Called on every change. */
|
|
2721
|
+
onChange?: (state: DegradeState) => void;
|
|
2722
|
+
}
|
|
2723
|
+
interface DegradeState {
|
|
2724
|
+
degraded: boolean;
|
|
2725
|
+
fps: number;
|
|
2726
|
+
active: number;
|
|
2727
|
+
reason: '' | 'fps' | 'count';
|
|
2728
|
+
}
|
|
2729
|
+
/**
|
|
2730
|
+
* Watch frame rate and animation count; while the device struggles, set
|
|
2731
|
+
* motion intensity to `low` and cap concurrent animations at `maxActive / 2`,
|
|
2732
|
+
* then restore the previous settings once frames recover. Dispatches
|
|
2733
|
+
* `usa:degrade` on `document`. Returns a stop function (restores settings).
|
|
2734
|
+
*/
|
|
2735
|
+
declare function autoDegrade(options?: AutoDegradeOptions): () => void;
|
|
2736
|
+
/** The category of a default `<usa-*>` tag. */
|
|
2737
|
+
declare const categoryOf: (tag: string) => ComponentCategory | undefined;
|
|
2738
|
+
/**
|
|
2739
|
+
* Add `<link rel="stylesheet" href="{base}components/{category}.css">` once.
|
|
2740
|
+
* `base` is the URL of the package's `dist/` folder.
|
|
2741
|
+
*/
|
|
2742
|
+
declare function loadCategoryStyles(category: ComponentCategory | 'all', base: string): HTMLLinkElement | null;
|
|
2743
|
+
/**
|
|
2744
|
+
* Load each category's CSS the first time one of its elements connects
|
|
2745
|
+
* (custom tags fall back to the full stylesheet). Returns an undo.
|
|
2746
|
+
*/
|
|
2747
|
+
declare function onDemandStyles(base: string): () => void;
|
|
2748
|
+
/** Categories whose CSS has been requested so far. */
|
|
2749
|
+
declare const loadedStyles: () => string[];
|
|
2750
|
+
|
|
2577
2751
|
/**
|
|
2578
2752
|
* Register every `<usa-*>` component (or only the given categories).
|
|
2579
2753
|
* Safe to call more than once and on the server (no-op without DOM).
|
|
2580
2754
|
*/
|
|
2581
2755
|
declare function defineComponents(categories?: ComponentCategory[]): void;
|
|
2582
2756
|
|
|
2583
|
-
export { AMBIENT_EFFECTS, ANIM_ICONS, BUTTON_DEFORMS, CARD_EFFECTS, CLICK_EFFECTS, COMPONENT_CATEGORIES, CURSOR_MODES, JOINING_SCRIPT, MASK_SHAPES, MORPH_ICONS, MOTION_SCALE, MOTION_TOKENS, PACKS, PACK_PRIMITIVES, PAGE_EFFECTS, REVEAL_EFFECTS, SHADERS, SPINNER_VARIANTS, SPRING_EFFECTS, SPRING_PRESETS, TIMELINE_PRESETS, VARIANTS, adoptVariants, applyMotionTokens, applyPack, autoAnimate, burst, confetti, configureComponents, 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, 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, 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, deviceTilt, drawLines, easeOutExpo, enableMpaTransitions, flip, flipFrames, fluentPreset, flyToCart, fragmentSource, gesture, getMotionIntensity, getMotionTokens, glQuad, graphemes, haptic, importMotionTokens, interpolatePath, linearEasing, loadingBar, masonryLayout, mergeMotionTokens, morphPath, morphTo, motionToken, motionTokensToCss, motionTokensToJSON, motionTokensToVars, motionVar, orientationToTilt, pageTransition, parseDuration, parseEasing, pathsCompatible, pinchScale, prefersReducedMotion, projectInertia, readScrollProgress, requestOrientationPermission, resolveDurationToken, resolveEasingToken, resolvePosition, resolveSpring, restoreMotionIntensity, revealKeyframes, rubberBand, scrambleFrame, scrollToTarget, setMotionIntensity, setVariant, shake, sharedTransition, smoothScroll, snapTo, splitOrder, splitText, splitTimeline, words as splitWords, spring, springEasing, springEffectKeyframes, springSamples, stepSpring, supportsLinearEasing, supportsNativeScrub, supportsOrientation, supportsViewTransitions, supportsWebGL, swipeDirection, themeTransition, timeline, toast, viewTransition };
|
|
2584
|
-
export type { AmbientEffect, AutoAnimateOptions, BurstOptions, ButtonDeform, ButtonShape, ButtonState, CardEffect, ClickEffect, ComponentCategory, ComponentsConfig, ConfettiOptions, CursorMode, DeepPartialTokens, DialogVariant, FlipOptions, FluentPresetOptions, GLQuad, GestureHandlers, GestureOptions, MorphOptions, MotionIntensity, MotionTokenGroup, MotionTokens, PackContext, PackName, PageEffect, PageTransitionOptions, PanState, PinchState, Placement, 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, 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 };
|
|
2757
|
+
export { ALL_TAGS, AMBIENT_EFFECTS, ANIM_ICONS, BUTTON_DEFORMS, CARD_EFFECTS, CLICK_EFFECTS, COMPONENT_CATEGORIES, CURSOR_MODES, JOINING_SCRIPT, LIVE_REGION_IDS, MASK_SHAPES, MORPH_ICONS, MOTION_SCALE, MOTION_SENSITIVITY, MOTION_SENSITIVITY_LEVELS, MOTION_TOKENS, PACKS, PACK_PRIMITIVES, PAGE_EFFECTS, REVEAL_EFFECTS, SENSITIVITY_CSS, SHADERS, SPINNER_VARIANTS, SPRING_EFFECTS, SPRING_PRESETS, STATIC_ALTERNATIVES, TIMELINE_PRESETS, VARIANTS, activeAnimations, adaptKeyframes, adoptVariants, animationBudget, announce, applyMotionTokens, applyPack, auditMotionA11y, autoAnimate, autoDegrade, burst, categoryOf, confetti, configureComponents, 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, 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, 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, deviceTilt, drawLines, easeOutExpo, enableMpaTransitions, flip, flipFrames, fluentPreset, flyToCart, fragmentSource, gesture, getMotionIntensity, getMotionSensitivity, getMotionTokens, glQuad, graphemes, haptic, importMotionTokens, interpolatePath, linearEasing, liveRegion, loadCategoryStyles, loadedStyles, loadingBar, masonryLayout, mergeMotionTokens, morphPath, morphTo, motionAllowed, motionToken, motionTokensToCss, motionTokensToJSON, motionTokensToVars, motionVar, onDemandStyles, onFrame, orientationToTilt, pageTransition, parseDuration, parseEasing, pathsCompatible, pinchScale, prefersReducedMotion, projectInertia, readScrollProgress, requestOrientationPermission, resolveDurationToken, resolveEasingToken, resolvePosition, resolveSpring, restoreMotionIntensity, restoreMotionSensitivity, revealKeyframes, rubberBand, schedulerStats, scrambleFrame, scrollToTarget, setAnimationBudget, setMotionIntensity, setMotionSensitivity, setVariant, shake, 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 };
|
|
2758
|
+
export type { A11yIssue, AmbientEffect, AutoAnimateOptions, AutoDegradeOptions, BurstOptions, ButtonDeform, ButtonShape, ButtonState, CardEffect, ClickEffect, ComponentCategory, ComponentsConfig, ConfettiOptions, CursorMode, DeepPartialTokens, DegradeState, DialogVariant, FlipOptions, FluentPresetOptions, GLQuad, GestureHandlers, GestureOptions, MorphOptions, MotionIntensity, MotionSensitivity, MotionTokenGroup, MotionTokens, PackContext, PackName, PageEffect, PageTransitionOptions, PanState, PinchState, Placement, Politeness, 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, 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 };
|
package/dist/components.d.ts
CHANGED
|
@@ -27,11 +27,30 @@ interface ComponentsConfig {
|
|
|
27
27
|
* 1.25) on `<html>` for your own CSS. See `setMotionIntensity()`.
|
|
28
28
|
*/
|
|
29
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 `use-scroll-animate/components/a11y`.
|
|
37
|
+
*/
|
|
38
|
+
motionSensitivity?: MotionSensitivity;
|
|
30
39
|
}
|
|
40
|
+
type MotionSensitivity = 'full' | 'gentle' | 'minimal' | 'static';
|
|
41
|
+
declare const MOTION_SENSITIVITY_LEVELS: readonly MotionSensitivity[];
|
|
31
42
|
type MotionIntensity = 'off' | 'low' | 'normal' | 'high';
|
|
32
43
|
declare const MOTION_SCALE: Record<MotionIntensity, number>;
|
|
33
44
|
/** Change global component settings (call before `define*()` for `injectStyles`). */
|
|
34
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[];
|
|
35
54
|
/** The current global motion intensity. */
|
|
36
55
|
declare function getMotionIntensity(): MotionIntensity;
|
|
37
56
|
/** `true` when animations should be reduced (OS setting or `configureComponents`). */
|
|
@@ -45,6 +64,22 @@ interface UsaElement extends HTMLElement {
|
|
|
45
64
|
/** `true` while reduced motion applies to this element. */
|
|
46
65
|
readonly reduced: boolean;
|
|
47
66
|
}
|
|
67
|
+
/** Run `fn(time, dt)` every frame on the shared scheduler until the returned function is called. */
|
|
68
|
+
declare function onFrame(fn: (t: number, dt: number) => void): () => void;
|
|
69
|
+
/** Scheduler counters: frames flushed, callbacks run, peak callbacks in one frame, pending now. */
|
|
70
|
+
declare function schedulerStats(): {
|
|
71
|
+
frames: number;
|
|
72
|
+
callbacks: number;
|
|
73
|
+
peak: number;
|
|
74
|
+
pending: number;
|
|
75
|
+
loops: number;
|
|
76
|
+
};
|
|
77
|
+
/** Number of component animations running right now. */
|
|
78
|
+
declare const activeAnimations: () => number;
|
|
79
|
+
/** Cap concurrent component animations; extra ones jump to their final frame (`Infinity` = no cap). */
|
|
80
|
+
declare function setAnimationBudget(max: number): void;
|
|
81
|
+
/** The current cap. */
|
|
82
|
+
declare const animationBudget: () => number;
|
|
48
83
|
|
|
49
84
|
/** Entrance effects shared by `<usa-reveal>` and `<usa-stagger>` (transform / opacity / filter only). */
|
|
50
85
|
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"];
|
|
@@ -2574,11 +2609,150 @@ declare const COMPONENT_CATEGORIES: {
|
|
|
2574
2609
|
};
|
|
2575
2610
|
type ComponentCategory = keyof typeof COMPONENT_CATEGORIES;
|
|
2576
2611
|
|
|
2612
|
+
/**
|
|
2613
|
+
* use-scroll-animate/components/a11y — accessibility toolkit (4.4).
|
|
2614
|
+
*
|
|
2615
|
+
* - Motion-sensitivity levels: `setMotionSensitivity('full' | 'gentle' | 'minimal' | 'static')`.
|
|
2616
|
+
* - Static alternatives: what every component shows when motion is off, and
|
|
2617
|
+
* `staticAlternative(root)` to freeze any subtree at its final state.
|
|
2618
|
+
* - `aria-live` conventions: one shared polite and one assertive region,
|
|
2619
|
+
* `announce(message, { politeness })`.
|
|
2620
|
+
* - `auditMotionA11y(root)`: the rules the automated regression tests run
|
|
2621
|
+
* over every `<usa-*>` element — usable in your own tests too.
|
|
2622
|
+
*
|
|
2623
|
+
* ```ts
|
|
2624
|
+
* import { setMotionSensitivity, announce, auditMotionA11y } from 'use-scroll-animate/components/a11y';
|
|
2625
|
+
* setMotionSensitivity('gentle', true); // no spins / zooms / parallax, remembered
|
|
2626
|
+
* announce('3 items added to cart'); // polite live region
|
|
2627
|
+
* expect(auditMotionA11y(document.body).errors).toEqual([]);
|
|
2628
|
+
* ```
|
|
2629
|
+
*/
|
|
2630
|
+
|
|
2631
|
+
/** What each level allows, for docs and settings UIs. */
|
|
2632
|
+
declare const MOTION_SENSITIVITY: Record<MotionSensitivity, {
|
|
2633
|
+
en: string;
|
|
2634
|
+
zh: string;
|
|
2635
|
+
allows: string[];
|
|
2636
|
+
}>;
|
|
2637
|
+
/** CSS applied at the `static` / `minimal` / `gentle` levels (also stops your own CSS animations under `static`). */
|
|
2638
|
+
declare const SENSITIVITY_CSS: string;
|
|
2639
|
+
/**
|
|
2640
|
+
* Set the motion-sensitivity level for every `<usa-*>` component and the page:
|
|
2641
|
+
* sets `data-usa-sensitivity` on `<html>`, adapts component keyframes, and
|
|
2642
|
+
* with `persist` remembers the choice (`restoreMotionSensitivity()`).
|
|
2643
|
+
* Dispatches `usa:sensitivity` on `document`.
|
|
2644
|
+
*/
|
|
2645
|
+
declare function setMotionSensitivity(level: MotionSensitivity, persist?: boolean): void;
|
|
2646
|
+
/** Re-apply a persisted level (call early on page load). Returns the active level. */
|
|
2647
|
+
declare function restoreMotionSensitivity(): MotionSensitivity;
|
|
2648
|
+
/** `true` when the current level allows a kind of motion (`'rotate'`, `'parallax'`, `'loop'`…). */
|
|
2649
|
+
declare function motionAllowed(kind: string, level?: MotionSensitivity): boolean;
|
|
2650
|
+
/** The static alternative of each category: what its elements show without motion. */
|
|
2651
|
+
declare const STATIC_ALTERNATIVES: Record<ComponentCategory, string>;
|
|
2652
|
+
/**
|
|
2653
|
+
* Freeze a subtree at its static alternative: finishes running animations
|
|
2654
|
+
* (`finish()`, so content lands on its final state), marks the root with
|
|
2655
|
+
* `data-usa-static` and returns an undo that removes the mark.
|
|
2656
|
+
*/
|
|
2657
|
+
declare function staticAlternative(root: Element): () => void;
|
|
2658
|
+
type Politeness = 'polite' | 'assertive';
|
|
2659
|
+
/** The ids of the shared live regions. */
|
|
2660
|
+
declare const LIVE_REGION_IDS: Record<Politeness, string>;
|
|
2661
|
+
/** The shared live region (created once, visually hidden, `role="status"` / `role="alert"`). */
|
|
2662
|
+
declare function liveRegion(politeness?: Politeness): HTMLElement | null;
|
|
2663
|
+
/**
|
|
2664
|
+
* Announce a message through the shared live region. Conventions: `polite`
|
|
2665
|
+
* for results of the user's own actions (added, saved, copied), `assertive`
|
|
2666
|
+
* only for errors that block them. Identical messages within `dedupe` ms
|
|
2667
|
+
* (default 500) are dropped; the region is cleared first so repeats are read.
|
|
2668
|
+
*/
|
|
2669
|
+
declare function announce(message: string, options?: {
|
|
2670
|
+
politeness?: Politeness;
|
|
2671
|
+
dedupe?: number;
|
|
2672
|
+
}): boolean;
|
|
2673
|
+
interface A11yIssue {
|
|
2674
|
+
rule: string;
|
|
2675
|
+
level: 'error' | 'warning';
|
|
2676
|
+
element: Element;
|
|
2677
|
+
message: string;
|
|
2678
|
+
}
|
|
2679
|
+
/**
|
|
2680
|
+
* Check a subtree against the library's motion-a11y rules:
|
|
2681
|
+
* - `aria-hidden-focusable` (error): focusable content inside `aria-hidden`.
|
|
2682
|
+
* - `role-name` (error): a widget role without an accessible name.
|
|
2683
|
+
* - `range-value` (error): a slider / determinate progressbar without `aria-valuenow`.
|
|
2684
|
+
* - `img-alt` (error): an `<img>` without `alt`.
|
|
2685
|
+
* - `assertive-live` (warning): `aria-live="assertive"` outside `role="alert"`.
|
|
2686
|
+
* - `infinite-no-control` (warning, WCAG 2.2.2): an endless animation on a
|
|
2687
|
+
* page with no way to pause motion (`<usa-motion-switch>` or `[data-usa-pause]`).
|
|
2688
|
+
*/
|
|
2689
|
+
declare function auditMotionA11y(root: Element | Document): {
|
|
2690
|
+
errors: A11yIssue[];
|
|
2691
|
+
warnings: A11yIssue[];
|
|
2692
|
+
};
|
|
2693
|
+
/** Every `<usa-*>` tag, for sweeping audits. */
|
|
2694
|
+
declare const ALL_TAGS: string[];
|
|
2695
|
+
|
|
2696
|
+
/**
|
|
2697
|
+
* use-scroll-animate/components/perf — performance toolkit (4.5).
|
|
2698
|
+
*
|
|
2699
|
+
* - One shared rAF scheduler for every component loop (`onFrame()`, `schedulerStats()`).
|
|
2700
|
+
* - Animation budget: `setAnimationBudget(n)` caps concurrent component
|
|
2701
|
+
* animations; extra ones land on their final frame.
|
|
2702
|
+
* - `autoDegrade()`: watches frame rate and animation count and steps motion
|
|
2703
|
+
* down (`low`, then a tighter budget) while the device struggles, restoring
|
|
2704
|
+
* it when frames recover.
|
|
2705
|
+
* - On-demand CSS: `loadCategoryStyles()` / `onDemandStyles()` — used by
|
|
2706
|
+
* `use-scroll-animate/components/lite`, the build without inlined CSS.
|
|
2707
|
+
*/
|
|
2708
|
+
|
|
2709
|
+
interface AutoDegradeOptions {
|
|
2710
|
+
/** Frame rate below which motion is degraded (default 45). */
|
|
2711
|
+
minFps?: number;
|
|
2712
|
+
/** Concurrent animations above which motion is degraded (default 40). */
|
|
2713
|
+
maxActive?: number;
|
|
2714
|
+
/** Sample window in ms (default 1000). */
|
|
2715
|
+
sample?: number;
|
|
2716
|
+
/** Bad samples in a row before degrading (default 2). */
|
|
2717
|
+
patience?: number;
|
|
2718
|
+
/** Good samples in a row before restoring (default 3). */
|
|
2719
|
+
recovery?: number;
|
|
2720
|
+
/** Called on every change. */
|
|
2721
|
+
onChange?: (state: DegradeState) => void;
|
|
2722
|
+
}
|
|
2723
|
+
interface DegradeState {
|
|
2724
|
+
degraded: boolean;
|
|
2725
|
+
fps: number;
|
|
2726
|
+
active: number;
|
|
2727
|
+
reason: '' | 'fps' | 'count';
|
|
2728
|
+
}
|
|
2729
|
+
/**
|
|
2730
|
+
* Watch frame rate and animation count; while the device struggles, set
|
|
2731
|
+
* motion intensity to `low` and cap concurrent animations at `maxActive / 2`,
|
|
2732
|
+
* then restore the previous settings once frames recover. Dispatches
|
|
2733
|
+
* `usa:degrade` on `document`. Returns a stop function (restores settings).
|
|
2734
|
+
*/
|
|
2735
|
+
declare function autoDegrade(options?: AutoDegradeOptions): () => void;
|
|
2736
|
+
/** The category of a default `<usa-*>` tag. */
|
|
2737
|
+
declare const categoryOf: (tag: string) => ComponentCategory | undefined;
|
|
2738
|
+
/**
|
|
2739
|
+
* Add `<link rel="stylesheet" href="{base}components/{category}.css">` once.
|
|
2740
|
+
* `base` is the URL of the package's `dist/` folder.
|
|
2741
|
+
*/
|
|
2742
|
+
declare function loadCategoryStyles(category: ComponentCategory | 'all', base: string): HTMLLinkElement | null;
|
|
2743
|
+
/**
|
|
2744
|
+
* Load each category's CSS the first time one of its elements connects
|
|
2745
|
+
* (custom tags fall back to the full stylesheet). Returns an undo.
|
|
2746
|
+
*/
|
|
2747
|
+
declare function onDemandStyles(base: string): () => void;
|
|
2748
|
+
/** Categories whose CSS has been requested so far. */
|
|
2749
|
+
declare const loadedStyles: () => string[];
|
|
2750
|
+
|
|
2577
2751
|
/**
|
|
2578
2752
|
* Register every `<usa-*>` component (or only the given categories).
|
|
2579
2753
|
* Safe to call more than once and on the server (no-op without DOM).
|
|
2580
2754
|
*/
|
|
2581
2755
|
declare function defineComponents(categories?: ComponentCategory[]): void;
|
|
2582
2756
|
|
|
2583
|
-
export { AMBIENT_EFFECTS, ANIM_ICONS, BUTTON_DEFORMS, CARD_EFFECTS, CLICK_EFFECTS, COMPONENT_CATEGORIES, CURSOR_MODES, JOINING_SCRIPT, MASK_SHAPES, MORPH_ICONS, MOTION_SCALE, MOTION_TOKENS, PACKS, PACK_PRIMITIVES, PAGE_EFFECTS, REVEAL_EFFECTS, SHADERS, SPINNER_VARIANTS, SPRING_EFFECTS, SPRING_PRESETS, TIMELINE_PRESETS, VARIANTS, adoptVariants, applyMotionTokens, applyPack, autoAnimate, burst, confetti, configureComponents, 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, 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, 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, deviceTilt, drawLines, easeOutExpo, enableMpaTransitions, flip, flipFrames, fluentPreset, flyToCart, fragmentSource, gesture, getMotionIntensity, getMotionTokens, glQuad, graphemes, haptic, importMotionTokens, interpolatePath, linearEasing, loadingBar, masonryLayout, mergeMotionTokens, morphPath, morphTo, motionToken, motionTokensToCss, motionTokensToJSON, motionTokensToVars, motionVar, orientationToTilt, pageTransition, parseDuration, parseEasing, pathsCompatible, pinchScale, prefersReducedMotion, projectInertia, readScrollProgress, requestOrientationPermission, resolveDurationToken, resolveEasingToken, resolvePosition, resolveSpring, restoreMotionIntensity, revealKeyframes, rubberBand, scrambleFrame, scrollToTarget, setMotionIntensity, setVariant, shake, sharedTransition, smoothScroll, snapTo, splitOrder, splitText, splitTimeline, words as splitWords, spring, springEasing, springEffectKeyframes, springSamples, stepSpring, supportsLinearEasing, supportsNativeScrub, supportsOrientation, supportsViewTransitions, supportsWebGL, swipeDirection, themeTransition, timeline, toast, viewTransition };
|
|
2584
|
-
export type { AmbientEffect, AutoAnimateOptions, BurstOptions, ButtonDeform, ButtonShape, ButtonState, CardEffect, ClickEffect, ComponentCategory, ComponentsConfig, ConfettiOptions, CursorMode, DeepPartialTokens, DialogVariant, FlipOptions, FluentPresetOptions, GLQuad, GestureHandlers, GestureOptions, MorphOptions, MotionIntensity, MotionTokenGroup, MotionTokens, PackContext, PackName, PageEffect, PageTransitionOptions, PanState, PinchState, Placement, 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, 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 };
|
|
2757
|
+
export { ALL_TAGS, AMBIENT_EFFECTS, ANIM_ICONS, BUTTON_DEFORMS, CARD_EFFECTS, CLICK_EFFECTS, COMPONENT_CATEGORIES, CURSOR_MODES, JOINING_SCRIPT, LIVE_REGION_IDS, MASK_SHAPES, MORPH_ICONS, MOTION_SCALE, MOTION_SENSITIVITY, MOTION_SENSITIVITY_LEVELS, MOTION_TOKENS, PACKS, PACK_PRIMITIVES, PAGE_EFFECTS, REVEAL_EFFECTS, SENSITIVITY_CSS, SHADERS, SPINNER_VARIANTS, SPRING_EFFECTS, SPRING_PRESETS, STATIC_ALTERNATIVES, TIMELINE_PRESETS, VARIANTS, activeAnimations, adaptKeyframes, adoptVariants, animationBudget, announce, applyMotionTokens, applyPack, auditMotionA11y, autoAnimate, autoDegrade, burst, categoryOf, confetti, configureComponents, 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, 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, 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, deviceTilt, drawLines, easeOutExpo, enableMpaTransitions, flip, flipFrames, fluentPreset, flyToCart, fragmentSource, gesture, getMotionIntensity, getMotionSensitivity, getMotionTokens, glQuad, graphemes, haptic, importMotionTokens, interpolatePath, linearEasing, liveRegion, loadCategoryStyles, loadedStyles, loadingBar, masonryLayout, mergeMotionTokens, morphPath, morphTo, motionAllowed, motionToken, motionTokensToCss, motionTokensToJSON, motionTokensToVars, motionVar, onDemandStyles, onFrame, orientationToTilt, pageTransition, parseDuration, parseEasing, pathsCompatible, pinchScale, prefersReducedMotion, projectInertia, readScrollProgress, requestOrientationPermission, resolveDurationToken, resolveEasingToken, resolvePosition, resolveSpring, restoreMotionIntensity, restoreMotionSensitivity, revealKeyframes, rubberBand, schedulerStats, scrambleFrame, scrollToTarget, setAnimationBudget, setMotionIntensity, setMotionSensitivity, setVariant, shake, 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 };
|
|
2758
|
+
export type { A11yIssue, AmbientEffect, AutoAnimateOptions, AutoDegradeOptions, BurstOptions, ButtonDeform, ButtonShape, ButtonState, CardEffect, ClickEffect, ComponentCategory, ComponentsConfig, ConfettiOptions, CursorMode, DeepPartialTokens, DegradeState, DialogVariant, FlipOptions, FluentPresetOptions, GLQuad, GestureHandlers, GestureOptions, MorphOptions, MotionIntensity, MotionSensitivity, MotionTokenGroup, MotionTokens, PackContext, PackName, PageEffect, PageTransitionOptions, PanState, PinchState, Placement, Politeness, 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, 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 };
|
package/dist/components.js
CHANGED
|
@@ -34,15 +34,17 @@ import { defineLayoutComponents } from './components/layout.js';
|
|
|
34
34
|
export { autoAnimate, defineAutoAnimate, defineMasonry, flipFrames, masonryLayout, sharedTransition } from './components/layout.js';
|
|
35
35
|
import { definePacksComponents } from './components/packs.js';
|
|
36
36
|
export { PACKS, PACK_PRIMITIVES, applyPack, countUp, definePack, flyToCart } from './components/packs.js';
|
|
37
|
-
import { a as adoptVariants } from './chunks/variants-
|
|
38
|
-
export { V as VARIANTS, s as setVariant } from './chunks/variants-
|
|
39
|
-
import { c as canDefine } from './chunks/base-
|
|
40
|
-
export { M as MOTION_SCALE, a as configureComponents, g as getMotionIntensity, p as prefersReducedMotion } from './chunks/base-
|
|
37
|
+
import { a as adoptVariants } from './chunks/variants-D9n-3x27.js';
|
|
38
|
+
export { V as VARIANTS, s as setVariant } from './chunks/variants-D9n-3x27.js';
|
|
39
|
+
import { c as canDefine } from './chunks/base-CZiIAMBc.js';
|
|
40
|
+
export { M as MOTION_SCALE, a as MOTION_SENSITIVITY_LEVELS, b as activeAnimations, d as adaptKeyframes, e as animationBudget, f as configureComponents, g as getMotionIntensity, h as getMotionSensitivity, o as onFrame, p as prefersReducedMotion, s as schedulerStats, i as setAnimationBudget } from './chunks/base-CZiIAMBc.js';
|
|
41
41
|
export { MOTION_TOKENS, applyMotionTokens, getMotionTokens, importMotionTokens, mergeMotionTokens, motionToken, motionTokensToCss, motionTokensToJSON, motionTokensToVars, motionVar, parseDuration, parseEasing, resolveDurationToken, resolveEasingToken } from './components/tokens.js';
|
|
42
|
+
export { ALL_TAGS, LIVE_REGION_IDS, MOTION_SENSITIVITY, SENSITIVITY_CSS, STATIC_ALTERNATIVES, announce, auditMotionA11y, liveRegion, motionAllowed, restoreMotionSensitivity, setMotionSensitivity, staticAlternative } from './components/a11y.js';
|
|
43
|
+
export { autoDegrade, categoryOf, loadCategoryStyles, loadedStyles, onDemandStyles } from './components/perf.js';
|
|
42
44
|
export { C as COMPONENT_CATEGORIES } from './chunks/index-tags-43Xtd01A.js';
|
|
43
|
-
export { S as SPRING_PRESETS, c as createSpring, l as linearEasing, p as projectInertia, r as resolveSpring, a as rubberBand, s as snapTo, b as spring, d as springEasing, e as springSamples, f as stepSpring, g as supportsLinearEasing } from './chunks/spring-
|
|
44
|
-
export { T as TIMELINE_PRESETS, r as resolvePosition, s as supportsNativeScrub, t as timeline } from './chunks/core-
|
|
45
|
-
export { g as gesture, p as pinchScale, s as swipeDirection } from './chunks/core-
|
|
45
|
+
export { S as SPRING_PRESETS, c as createSpring, l as linearEasing, p as projectInertia, r as resolveSpring, a as rubberBand, s as snapTo, b as spring, d as springEasing, e as springSamples, f as stepSpring, g as supportsLinearEasing } from './chunks/spring-BS5tg6aK.js';
|
|
46
|
+
export { T as TIMELINE_PRESETS, r as resolvePosition, s as supportsNativeScrub, t as timeline } from './chunks/core-CJHJeMI_.js';
|
|
47
|
+
export { g as gesture, p as pinchScale, s as swipeDirection } from './chunks/core-COi3DrLx.js';
|
|
46
48
|
|
|
47
49
|
/**
|
|
48
50
|
* use-scroll-animate/components
|
package/dist/components.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"components.js","sources":["../src/components/index.ts"],"sourcesContent":["/**\n * use-scroll-animate/components\n *\n * Framework-agnostic, dependency-free animated UI components built on\n * Custom Elements + CSS + the Web Animations API. They run in any browser\n * and in Windows desktop apps that render with a web view: Electron, Tauri\n * (WebView2), WinUI 3 / WPF / WinForms with WebView2, and installed PWAs.\n *\n * ```js\n * import { defineComponents } from 'use-scroll-animate/components';\n * defineComponents(); // registers every <usa-*> element\n * // or only what you use (tree-shakable):\n * import { defineTypewriter } from 'use-scroll-animate/components/text';\n * ```\n *\n * Importing has no side effects and is SSR-safe; nothing is registered\n * until a `define*()` function runs in a browser.\n *\n * @license MIT\n */\nimport { defineRevealComponents } from './reveal/index';\nimport { defineTextComponents } from './text/index';\nimport { defineInteractionComponents } from './interaction/index';\nimport { defineFeedbackComponents } from './feedback/index';\nimport { defineBackgroundComponents } from './background/index';\nimport { defineTransitionComponents } from './transitions/index';\nimport { definePhysicsComponents } from './physics/index';\nimport { defineCardComponents } from './cards/index';\nimport { defineClickComponents } from './click/index';\nimport { defineUiComponents } from './ui/index';\nimport { definePageComponents } from './page/index';\nimport { defineTimelineComponents } from './timeline/index';\nimport { defineGestureComponents } from './gesture/index';\nimport { defineSvgComponents } from './svg/index';\nimport { defineWebglComponents } from './webgl/index';\nimport { defineDepthComponents } from './depth/index';\nimport { defineLayoutComponents } from './layout/index';\nimport { definePacksComponents } from './packs/index';\nimport { adoptVariants } from './ui/variants';\nimport { canDefine } from './base';\n\nexport * from './reveal/index';\nexport * from './text/index';\nexport * from './interaction/index';\nexport * from './feedback/index';\nexport * from './background/index';\nexport * from './transitions/index';\nexport * from './physics/index';\nexport * from './cards/index';\nexport * from './click/index';\nexport * from './ui/index';\nexport * from './page/index';\nexport * from './timeline/index';\nexport * from './gesture/index';\nexport * from './svg/index';\nexport * from './webgl/index';\nexport * from './depth/index';\nexport * from './layout/index';\nexport * from './packs/index';\nexport * from './tokens/index';\n\nexport { COMPONENT_CATEGORIES } from './index-tags';\nexport type { ComponentCategory } from './index-tags';\nimport { COMPONENT_CATEGORIES, type ComponentCategory } from './index-tags';\n\nconst BY_CATEGORY: Record<ComponentCategory, () => void> = {\n reveal: defineRevealComponents,\n text: defineTextComponents,\n interaction: defineInteractionComponents,\n feedback: defineFeedbackComponents,\n background: defineBackgroundComponents,\n transitions: defineTransitionComponents,\n physics: definePhysicsComponents,\n cards: defineCardComponents,\n click: defineClickComponents,\n ui: defineUiComponents,\n page: definePageComponents,\n timeline: defineTimelineComponents,\n gesture: defineGestureComponents,\n svg: defineSvgComponents,\n webgl: defineWebglComponents,\n depth: defineDepthComponents,\n layout: defineLayoutComponents,\n packs: definePacksComponents,\n};\n\n/**\n * Register every `<usa-*>` component (or only the given categories).\n * Safe to call more than once and on the server (no-op without DOM).\n */\nexport function defineComponents(categories?: ComponentCategory[]): void {\n if (canDefine()) adoptVariants();\n (categories || (Object.keys(BY_CATEGORY) as ComponentCategory[])).forEach((c) => BY_CATEGORY[c]?.());\n}\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"components.js","sources":["../src/components/index.ts"],"sourcesContent":["/**\n * use-scroll-animate/components\n *\n * Framework-agnostic, dependency-free animated UI components built on\n * Custom Elements + CSS + the Web Animations API. They run in any browser\n * and in Windows desktop apps that render with a web view: Electron, Tauri\n * (WebView2), WinUI 3 / WPF / WinForms with WebView2, and installed PWAs.\n *\n * ```js\n * import { defineComponents } from 'use-scroll-animate/components';\n * defineComponents(); // registers every <usa-*> element\n * // or only what you use (tree-shakable):\n * import { defineTypewriter } from 'use-scroll-animate/components/text';\n * ```\n *\n * Importing has no side effects and is SSR-safe; nothing is registered\n * until a `define*()` function runs in a browser.\n *\n * @license MIT\n */\nimport { defineRevealComponents } from './reveal/index';\nimport { defineTextComponents } from './text/index';\nimport { defineInteractionComponents } from './interaction/index';\nimport { defineFeedbackComponents } from './feedback/index';\nimport { defineBackgroundComponents } from './background/index';\nimport { defineTransitionComponents } from './transitions/index';\nimport { definePhysicsComponents } from './physics/index';\nimport { defineCardComponents } from './cards/index';\nimport { defineClickComponents } from './click/index';\nimport { defineUiComponents } from './ui/index';\nimport { definePageComponents } from './page/index';\nimport { defineTimelineComponents } from './timeline/index';\nimport { defineGestureComponents } from './gesture/index';\nimport { defineSvgComponents } from './svg/index';\nimport { defineWebglComponents } from './webgl/index';\nimport { defineDepthComponents } from './depth/index';\nimport { defineLayoutComponents } from './layout/index';\nimport { definePacksComponents } from './packs/index';\nimport { adoptVariants } from './ui/variants';\nimport { canDefine } from './base';\n\nexport * from './reveal/index';\nexport * from './text/index';\nexport * from './interaction/index';\nexport * from './feedback/index';\nexport * from './background/index';\nexport * from './transitions/index';\nexport * from './physics/index';\nexport * from './cards/index';\nexport * from './click/index';\nexport * from './ui/index';\nexport * from './page/index';\nexport * from './timeline/index';\nexport * from './gesture/index';\nexport * from './svg/index';\nexport * from './webgl/index';\nexport * from './depth/index';\nexport * from './layout/index';\nexport * from './packs/index';\nexport * from './tokens/index';\nexport * from './a11y/index';\nexport * from './perf/index';\n\nexport { COMPONENT_CATEGORIES } from './index-tags';\nexport type { ComponentCategory } from './index-tags';\nimport { COMPONENT_CATEGORIES, type ComponentCategory } from './index-tags';\n\nconst BY_CATEGORY: Record<ComponentCategory, () => void> = {\n reveal: defineRevealComponents,\n text: defineTextComponents,\n interaction: defineInteractionComponents,\n feedback: defineFeedbackComponents,\n background: defineBackgroundComponents,\n transitions: defineTransitionComponents,\n physics: definePhysicsComponents,\n cards: defineCardComponents,\n click: defineClickComponents,\n ui: defineUiComponents,\n page: definePageComponents,\n timeline: defineTimelineComponents,\n gesture: defineGestureComponents,\n svg: defineSvgComponents,\n webgl: defineWebglComponents,\n depth: defineDepthComponents,\n layout: defineLayoutComponents,\n packs: definePacksComponents,\n};\n\n/**\n * Register every `<usa-*>` component (or only the given categories).\n * Safe to call more than once and on the server (no-op without DOM).\n */\nexport function defineComponents(categories?: ComponentCategory[]): void {\n if (canDefine()) adoptVariants();\n (categories || (Object.keys(BY_CATEGORY) as ComponentCategory[])).forEach((c) => BY_CATEGORY[c]?.());\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;AAmBG;AAgDH,MAAM,WAAW,GAA0C;AACzD,IAAA,MAAM,EAAE,sBAAsB;AAC9B,IAAA,IAAI,EAAE,oBAAoB;AAC1B,IAAA,WAAW,EAAE,2BAA2B;AACxC,IAAA,QAAQ,EAAE,wBAAwB;AAClC,IAAA,UAAU,EAAE,0BAA0B;AACtC,IAAA,WAAW,EAAE,0BAA0B;AACvC,IAAA,OAAO,EAAE,uBAAuB;AAChC,IAAA,KAAK,EAAE,oBAAoB;AAC3B,IAAA,KAAK,EAAE,qBAAqB;AAC5B,IAAA,EAAE,EAAE,kBAAkB;AACtB,IAAA,IAAI,EAAE,oBAAoB;AAC1B,IAAA,QAAQ,EAAE,wBAAwB;AAClC,IAAA,OAAO,EAAE,uBAAuB;AAChC,IAAA,GAAG,EAAE,mBAAmB;AACxB,IAAA,KAAK,EAAE,qBAAqB;AAC5B,IAAA,KAAK,EAAE,qBAAqB;AAC5B,IAAA,MAAM,EAAE,sBAAsB;AAC9B,IAAA,KAAK,EAAE,qBAAqB;CAC7B;AAED;;;AAGG;AACG,SAAU,gBAAgB,CAAC,UAAgC,EAAA;AAC/D,IAAA,IAAI,SAAS,EAAE;AAAE,QAAA,aAAa,EAAE;IAChC,CAAC,UAAU,IAAK,MAAM,CAAC,IAAI,CAAC,WAAW,CAAyB,EAAE,OAAO,CAAC,CAAC,CAAC,KAAK,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC;AACtG;;;;"}
|