use-scroll-animate 4.0.1 → 4.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +24 -0
- package/dist/chunks/{base-ZARFccur.js → base-BPG5zvex.js} +2 -2
- package/dist/chunks/{base-ZARFccur.js.map → base-BPG5zvex.js.map} +1 -1
- package/dist/chunks/{core-DXqZm5Il.cjs → core-BRIIoKeS.cjs} +55 -12
- package/dist/chunks/core-BRIIoKeS.cjs.map +1 -0
- package/dist/chunks/{core-Co-6AL0h.js → core-LkGRmgES.js} +56 -14
- package/dist/chunks/core-LkGRmgES.js.map +1 -0
- package/dist/chunks/{core-DKY-fVzR.js → core-eXX8rB_b.js} +2 -2
- package/dist/chunks/{core-DKY-fVzR.js.map → core-eXX8rB_b.js.map} +1 -1
- package/dist/chunks/{spring-E2ickYNI.js → spring-BziPsW3r.js} +2 -2
- package/dist/chunks/{spring-E2ickYNI.js.map → spring-BziPsW3r.js.map} +1 -1
- package/dist/chunks/{variants-DvnxvRCM.js → variants-BVYMcxRv.js} +2 -2
- package/dist/chunks/{variants-DvnxvRCM.js.map → variants-BVYMcxRv.js.map} +1 -1
- package/dist/components/angular.cjs +2 -1
- package/dist/components/angular.cjs.map +1 -1
- package/dist/components/angular.d.cts +32 -8
- package/dist/components/angular.d.ts +32 -8
- package/dist/components/angular.js +6 -5
- package/dist/components/angular.js.map +1 -1
- package/dist/components/background.js +3 -3
- package/dist/components/cards.js +3 -3
- package/dist/components/click.js +3 -3
- package/dist/components/depth.js +4 -4
- package/dist/components/feedback.js +2 -2
- package/dist/components/gesture.js +5 -5
- package/dist/components/interaction.js +2 -2
- package/dist/components/layout.js +2 -2
- package/dist/components/packs.js +2 -2
- package/dist/components/page.js +3 -3
- package/dist/components/physics.js +4 -4
- package/dist/components/reveal.js +2 -2
- package/dist/components/solid.cjs +2 -1
- package/dist/components/solid.cjs.map +1 -1
- package/dist/components/solid.d.cts +32 -8
- package/dist/components/solid.d.ts +32 -8
- package/dist/components/solid.js +6 -5
- package/dist/components/solid.js.map +1 -1
- package/dist/components/svelte.cjs +2 -1
- package/dist/components/svelte.cjs.map +1 -1
- package/dist/components/svelte.d.cts +32 -8
- package/dist/components/svelte.d.ts +32 -8
- package/dist/components/svelte.js +6 -5
- package/dist/components/svelte.js.map +1 -1
- package/dist/components/svg.js +2 -2
- package/dist/components/text.js +2 -2
- package/dist/components/timeline.cjs +10 -2
- package/dist/components/timeline.cjs.map +1 -1
- package/dist/components/timeline.d.cts +36 -10
- package/dist/components/timeline.d.ts +36 -10
- package/dist/components/timeline.js +12 -5
- package/dist/components/timeline.js.map +1 -1
- package/dist/components/tokens.cjs +226 -0
- package/dist/components/tokens.cjs.map +1 -0
- package/dist/components/tokens.d.cts +74 -0
- package/dist/components/tokens.d.ts +74 -0
- package/dist/components/tokens.js +211 -0
- package/dist/components/tokens.js.map +1 -0
- package/dist/components/transitions.js +2 -2
- package/dist/components/ui.js +5 -5
- package/dist/components/vue.cjs +2 -1
- package/dist/components/vue.cjs.map +1 -1
- package/dist/components/vue.d.cts +32 -8
- package/dist/components/vue.d.ts +32 -8
- package/dist/components/vue.js +6 -5
- package/dist/components/vue.js.map +1 -1
- package/dist/components/webgl.js +2 -2
- package/dist/components.cjs +17 -1
- package/dist/components.cjs.map +1 -1
- package/dist/components.d.cts +109 -11
- package/dist/components.d.ts +109 -11
- package/dist/components.js +8 -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 +3 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +33 -9
- package/dist/index.d.ts +33 -9
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +2 -2
- package/dist/index.umd.js.map +1 -1
- package/docs/API.md +3 -1
- package/docs/ROADMAP.md +2 -2
- package/docs/motion-tokens.css +31 -0
- package/docs/motion-tokens.md +46 -0
- package/docs/motion.tokens.json +132 -0
- package/package.json +11 -1
- package/dist/chunks/core-Co-6AL0h.js.map +0 -1
- package/dist/chunks/core-DXqZm5Il.cjs.map +0 -1
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* use-scroll-animate/components/tokens — motion design tokens (4.2).
|
|
3
|
+
*
|
|
4
|
+
* One source of truth for durations, easings and springs: as CSS custom
|
|
5
|
+
* properties (`--usa-duration-fast`, `--usa-easing-emphasized`,
|
|
6
|
+
* `--usa-spring-bouncy-stiffness`…), as W3C Design Tokens JSON, and importable
|
|
7
|
+
* from Figma Tokens (Tokens Studio) or Style Dictionary exports.
|
|
8
|
+
*
|
|
9
|
+
* ```ts
|
|
10
|
+
* import { applyMotionTokens, importMotionTokens, motionToken } from 'use-scroll-animate/components/tokens';
|
|
11
|
+
* applyMotionTokens(importMotionTokens(await (await fetch('/tokens.json')).json()));
|
|
12
|
+
* el.animate(frames, { duration: motionToken('duration', 'slow'), easing: motionToken('easing', 'emphasized') });
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
/** The default motion scale (Material / Fluent-inspired). */
|
|
16
|
+
const MOTION_TOKENS = {
|
|
17
|
+
duration: { instant: 0, fast: 150, normal: 300, slow: 600, slower: 900, slowest: 1400 },
|
|
18
|
+
easing: {
|
|
19
|
+
linear: 'linear',
|
|
20
|
+
standard: 'cubic-bezier(0.2, 0, 0, 1)',
|
|
21
|
+
emphasized: 'cubic-bezier(0.22, 1, 0.36, 1)',
|
|
22
|
+
decelerate: 'cubic-bezier(0, 0, 0, 1)',
|
|
23
|
+
accelerate: 'cubic-bezier(0.3, 0, 1, 1)',
|
|
24
|
+
spring: 'cubic-bezier(0.34, 1.56, 0.64, 1)',
|
|
25
|
+
bounce: 'cubic-bezier(0.68, -0.55, 0.265, 1.55)',
|
|
26
|
+
},
|
|
27
|
+
spring: {
|
|
28
|
+
gentle: { stiffness: 120, damping: 14, mass: 1 },
|
|
29
|
+
snappy: { stiffness: 300, damping: 30, mass: 1 },
|
|
30
|
+
bouncy: { stiffness: 260, damping: 12, mass: 1 },
|
|
31
|
+
wobbly: { stiffness: 180, damping: 8, mass: 1 },
|
|
32
|
+
stiff: { stiffness: 500, damping: 40, mass: 1 },
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
let active = clone(MOTION_TOKENS);
|
|
36
|
+
function clone(t) {
|
|
37
|
+
return { duration: { ...t.duration }, easing: { ...t.easing }, spring: Object.fromEntries(Object.entries(t.spring).map(([k, v]) => [k, { ...v }])) };
|
|
38
|
+
}
|
|
39
|
+
/** Merge partial tokens over a base (defaults: the built-in scale). */
|
|
40
|
+
function mergeMotionTokens(partial, base = MOTION_TOKENS) {
|
|
41
|
+
const out = clone(base);
|
|
42
|
+
Object.assign(out.duration, partial.duration || {});
|
|
43
|
+
Object.assign(out.easing, partial.easing || {});
|
|
44
|
+
for (const [k, v] of Object.entries(partial.spring || {}))
|
|
45
|
+
out.spring[k] = { ...(out.spring[k] || { stiffness: 170, damping: 26, mass: 1 }), ...v };
|
|
46
|
+
return out;
|
|
47
|
+
}
|
|
48
|
+
const kebab = (s) => s.replace(/([a-z0-9])([A-Z])/g, '$1-$2').replace(/[\s_.]+/g, '-').toLowerCase();
|
|
49
|
+
/** The custom-property map: `{ '--usa-duration-fast': '150ms', … }`. */
|
|
50
|
+
function motionTokensToVars(tokens = active, prefix = '--usa') {
|
|
51
|
+
const vars = {};
|
|
52
|
+
for (const [k, v] of Object.entries(tokens.duration))
|
|
53
|
+
vars[`${prefix}-duration-${kebab(k)}`] = `${v}ms`;
|
|
54
|
+
for (const [k, v] of Object.entries(tokens.easing))
|
|
55
|
+
vars[`${prefix}-easing-${kebab(k)}`] = v;
|
|
56
|
+
for (const [k, v] of Object.entries(tokens.spring)) {
|
|
57
|
+
vars[`${prefix}-spring-${kebab(k)}-stiffness`] = String(v.stiffness);
|
|
58
|
+
vars[`${prefix}-spring-${kebab(k)}-damping`] = String(v.damping);
|
|
59
|
+
vars[`${prefix}-spring-${kebab(k)}-mass`] = String(v.mass);
|
|
60
|
+
}
|
|
61
|
+
return vars;
|
|
62
|
+
}
|
|
63
|
+
/** A stylesheet string: `:root { --usa-duration-fast: 150ms; … }`. */
|
|
64
|
+
function motionTokensToCss(tokens = active, selector = ':root', prefix = '--usa') {
|
|
65
|
+
const body = Object.entries(motionTokensToVars(tokens, prefix)).map(([k, v]) => ` ${k}: ${v};`).join('\n');
|
|
66
|
+
return `${selector} {\n${body}\n}\n`;
|
|
67
|
+
}
|
|
68
|
+
/** W3C Design Tokens (DTCG) JSON: `{ motion: { duration: { fast: { $type: 'duration', $value: '150ms' } } } }`. */
|
|
69
|
+
function motionTokensToJSON(tokens = active) {
|
|
70
|
+
const grp = (o, f) => Object.fromEntries(Object.entries(o).map(([k, v]) => [k, f(v)]));
|
|
71
|
+
return {
|
|
72
|
+
motion: {
|
|
73
|
+
duration: grp(tokens.duration, (v) => ({ $type: 'duration', $value: `${v}ms` })),
|
|
74
|
+
easing: grp(tokens.easing, (v) => {
|
|
75
|
+
const m = /^cubic-bezier\(([^)]+)\)$/.exec(v);
|
|
76
|
+
return m ? { $type: 'cubicBezier', $value: m[1].split(',').map(Number) } : { $type: 'string', $value: v };
|
|
77
|
+
}),
|
|
78
|
+
spring: grp(tokens.spring, (v) => ({ $type: 'spring', $value: { ...v } })),
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
/** Parse `150ms`, `0.15s`, `150` → ms. */
|
|
83
|
+
function parseDuration(v) {
|
|
84
|
+
if (typeof v === 'number' && isFinite(v))
|
|
85
|
+
return v;
|
|
86
|
+
if (typeof v === 'object' && v && 'value' in v && 'unit' in v)
|
|
87
|
+
return parseDuration(`${v.value}${v.unit}`);
|
|
88
|
+
const m = /^\s*(-?\d*\.?\d+)\s*(ms|s)?\s*$/.exec(String(v ?? ''));
|
|
89
|
+
if (!m)
|
|
90
|
+
return undefined;
|
|
91
|
+
return m[2] === 's' ? Number(m[1]) * 1000 : Number(m[1]);
|
|
92
|
+
}
|
|
93
|
+
/** Parse `[x1,y1,x2,y2]`, `'cubic-bezier(…)'`, `'0.2, 0, 0, 1'` or a keyword → CSS easing. */
|
|
94
|
+
function parseEasing(v) {
|
|
95
|
+
if (Array.isArray(v) && v.length === 4 && v.every((n) => typeof n === 'number'))
|
|
96
|
+
return `cubic-bezier(${v.join(', ')})`;
|
|
97
|
+
if (typeof v !== 'string' || !v.trim())
|
|
98
|
+
return undefined;
|
|
99
|
+
const s = v.trim();
|
|
100
|
+
if (/^-?\d*\.?\d+(\s*,\s*-?\d*\.?\d+){3}$/.test(s))
|
|
101
|
+
return `cubic-bezier(${s.split(/\s*,\s*/).join(', ')})`;
|
|
102
|
+
return s;
|
|
103
|
+
}
|
|
104
|
+
const isLeaf = (o) => o && typeof o === 'object' && ('$value' in o || 'value' in o);
|
|
105
|
+
const leafValue = (o) => ('$value' in o ? o.$value : o.value);
|
|
106
|
+
const leafType = (o) => String(o.$type ?? o.type ?? '').toLowerCase();
|
|
107
|
+
/**
|
|
108
|
+
* Import tokens from W3C DTCG JSON, Figma Tokens / Tokens Studio
|
|
109
|
+
* (`{ value, type }`) or Style Dictionary (`{ value }`, nested) — anything
|
|
110
|
+
* under a `duration` / `easing` / `spring` group (any depth, e.g.
|
|
111
|
+
* `motion.duration.fast` or `global.animation.easing.out`), or typed leaves
|
|
112
|
+
* (`duration`, `cubicBezier`, `transition`, `spring`). Unknown values are
|
|
113
|
+
* skipped; the result is merged over the defaults.
|
|
114
|
+
*/
|
|
115
|
+
function importMotionTokens(json, base = MOTION_TOKENS) {
|
|
116
|
+
const partial = { duration: {}, easing: {}, spring: {} };
|
|
117
|
+
const walk = (node, path) => {
|
|
118
|
+
if (!node || typeof node !== 'object')
|
|
119
|
+
return;
|
|
120
|
+
if (isLeaf(node)) {
|
|
121
|
+
const name = path[path.length - 1];
|
|
122
|
+
const type = leafType(node);
|
|
123
|
+
const group = path.slice(0, -1).map((p) => p.toLowerCase());
|
|
124
|
+
const val = leafValue(node);
|
|
125
|
+
const inGroup = (g) => group.some((p) => g.includes(p));
|
|
126
|
+
if (type === 'duration' || (!type && inGroup(['duration', 'durations'])) || (type !== 'cubicbezier' && inGroup(['duration', 'durations']))) {
|
|
127
|
+
const ms = parseDuration(val);
|
|
128
|
+
if (ms !== undefined)
|
|
129
|
+
partial.duration[name] = ms;
|
|
130
|
+
}
|
|
131
|
+
else if (type === 'cubicbezier' || type === 'easing' || inGroup(['easing', 'easings', 'ease'])) {
|
|
132
|
+
const e = parseEasing(val);
|
|
133
|
+
if (e)
|
|
134
|
+
partial.easing[name] = e;
|
|
135
|
+
}
|
|
136
|
+
else if (type === 'spring' || inGroup(['spring', 'springs'])) {
|
|
137
|
+
if (val && typeof val === 'object')
|
|
138
|
+
partial.spring[name] = { stiffness: Number(val.stiffness ?? 170), damping: Number(val.damping ?? 26), mass: Number(val.mass ?? 1) };
|
|
139
|
+
}
|
|
140
|
+
else if (type === 'transition' && val && typeof val === 'object') {
|
|
141
|
+
const ms = parseDuration(val.duration);
|
|
142
|
+
if (ms !== undefined)
|
|
143
|
+
partial.duration[name] = ms;
|
|
144
|
+
const e = parseEasing(val.timingFunction);
|
|
145
|
+
if (e)
|
|
146
|
+
partial.easing[name] = e;
|
|
147
|
+
}
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
for (const [k, v] of Object.entries(node))
|
|
151
|
+
if (!k.startsWith('$'))
|
|
152
|
+
walk(v, [...path, k]);
|
|
153
|
+
};
|
|
154
|
+
walk(json, []);
|
|
155
|
+
return mergeMotionTokens(partial, base);
|
|
156
|
+
}
|
|
157
|
+
/** The tokens currently applied (via `applyMotionTokens`), or the defaults. */
|
|
158
|
+
function getMotionTokens() {
|
|
159
|
+
return clone(active);
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Write tokens as CSS custom properties on `root` (default `<html>`) and make
|
|
163
|
+
* them the active set for `motionToken()`. Returns an undo function.
|
|
164
|
+
*/
|
|
165
|
+
function applyMotionTokens(tokens = MOTION_TOKENS, root, prefix = '--usa') {
|
|
166
|
+
const prev = active;
|
|
167
|
+
active = mergeMotionTokens(tokens, MOTION_TOKENS);
|
|
168
|
+
const el = root || (typeof document !== 'undefined' ? document.documentElement : null);
|
|
169
|
+
const vars = motionTokensToVars(active, prefix);
|
|
170
|
+
const old = {};
|
|
171
|
+
if (el)
|
|
172
|
+
for (const [k, v] of Object.entries(vars))
|
|
173
|
+
((old[k] = el.style.getPropertyValue(k)), el.style.setProperty(k, v));
|
|
174
|
+
return () => {
|
|
175
|
+
active = prev;
|
|
176
|
+
if (el)
|
|
177
|
+
for (const [k, v] of Object.entries(old))
|
|
178
|
+
v ? el.style.setProperty(k, v) : el.style.removeProperty(k);
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
function motionToken(group, name) {
|
|
182
|
+
const g = active[group];
|
|
183
|
+
return g[name] ?? MOTION_TOKENS[group][name];
|
|
184
|
+
}
|
|
185
|
+
/** `var(--usa-duration-fast, 150ms)` — a CSS reference with the current value as fallback. */
|
|
186
|
+
function motionVar(group, name, prop, prefix = '--usa') {
|
|
187
|
+
if (group === 'spring') {
|
|
188
|
+
const s = motionToken('spring', name);
|
|
189
|
+
const p = prop || 'stiffness';
|
|
190
|
+
return `var(${prefix}-spring-${kebab(name)}-${p}, ${s ? s[p] : ''})`;
|
|
191
|
+
}
|
|
192
|
+
const v = group === 'duration' ? `${motionToken('duration', name)}ms` : motionToken('easing', name);
|
|
193
|
+
return `var(${prefix}-${group}-${kebab(name)}, ${v})`;
|
|
194
|
+
}
|
|
195
|
+
/** Resolve a duration that may be a token name (`'fast'`) or ms. */
|
|
196
|
+
function resolveDurationToken(v, fallback) {
|
|
197
|
+
if (typeof v === 'number')
|
|
198
|
+
return v;
|
|
199
|
+
if (typeof v === 'string')
|
|
200
|
+
return (active.duration[v] ?? parseDuration(v)) ?? fallback;
|
|
201
|
+
return fallback;
|
|
202
|
+
}
|
|
203
|
+
/** Resolve an easing that may be a token name (`'emphasized'`) or CSS. */
|
|
204
|
+
function resolveEasingToken(v, fallback) {
|
|
205
|
+
if (!v)
|
|
206
|
+
return fallback;
|
|
207
|
+
return active.easing[v] ?? v;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
export { MOTION_TOKENS, applyMotionTokens, getMotionTokens, importMotionTokens, mergeMotionTokens, motionToken, motionTokensToCss, motionTokensToJSON, motionTokensToVars, motionVar, parseDuration, parseEasing, resolveDurationToken, resolveEasingToken };
|
|
211
|
+
//# sourceMappingURL=tokens.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tokens.js","sources":["../../src/components/tokens/index.ts"],"sourcesContent":["/**\n * use-scroll-animate/components/tokens — motion design tokens (4.2).\n *\n * One source of truth for durations, easings and springs: as CSS custom\n * properties (`--usa-duration-fast`, `--usa-easing-emphasized`,\n * `--usa-spring-bouncy-stiffness`…), as W3C Design Tokens JSON, and importable\n * from Figma Tokens (Tokens Studio) or Style Dictionary exports.\n *\n * ```ts\n * import { applyMotionTokens, importMotionTokens, motionToken } from 'use-scroll-animate/components/tokens';\n * applyMotionTokens(importMotionTokens(await (await fetch('/tokens.json')).json()));\n * el.animate(frames, { duration: motionToken('duration', 'slow'), easing: motionToken('easing', 'emphasized') });\n * ```\n */\n\nexport interface SpringToken {\n stiffness: number;\n damping: number;\n mass: number;\n}\n\nexport interface MotionTokens {\n /** Durations in ms. */\n duration: Record<string, number>;\n /** CSS easing strings. */\n easing: Record<string, string>;\n /** Spring physics parameters. */\n spring: Record<string, SpringToken>;\n}\n\n/** The default motion scale (Material / Fluent-inspired). */\nexport const MOTION_TOKENS: MotionTokens = {\n duration: { instant: 0, fast: 150, normal: 300, slow: 600, slower: 900, slowest: 1400 },\n easing: {\n linear: 'linear',\n standard: 'cubic-bezier(0.2, 0, 0, 1)',\n emphasized: 'cubic-bezier(0.22, 1, 0.36, 1)',\n decelerate: 'cubic-bezier(0, 0, 0, 1)',\n accelerate: 'cubic-bezier(0.3, 0, 1, 1)',\n spring: 'cubic-bezier(0.34, 1.56, 0.64, 1)',\n bounce: 'cubic-bezier(0.68, -0.55, 0.265, 1.55)',\n },\n spring: {\n gentle: { stiffness: 120, damping: 14, mass: 1 },\n snappy: { stiffness: 300, damping: 30, mass: 1 },\n bouncy: { stiffness: 260, damping: 12, mass: 1 },\n wobbly: { stiffness: 180, damping: 8, mass: 1 },\n stiff: { stiffness: 500, damping: 40, mass: 1 },\n },\n};\n\nexport type MotionTokenGroup = keyof MotionTokens;\nexport type DeepPartialTokens = { [K in keyof MotionTokens]?: Partial<MotionTokens[K]> };\n\nlet active: MotionTokens = clone(MOTION_TOKENS);\n\nfunction clone(t: MotionTokens): MotionTokens {\n return { duration: { ...t.duration }, easing: { ...t.easing }, spring: Object.fromEntries(Object.entries(t.spring).map(([k, v]) => [k, { ...v }])) };\n}\n\n/** Merge partial tokens over a base (defaults: the built-in scale). */\nexport function mergeMotionTokens(partial: DeepPartialTokens, base: MotionTokens = MOTION_TOKENS): MotionTokens {\n const out = clone(base);\n Object.assign(out.duration, partial.duration || {});\n Object.assign(out.easing, partial.easing || {});\n for (const [k, v] of Object.entries(partial.spring || {})) out.spring[k] = { ...(out.spring[k] || { stiffness: 170, damping: 26, mass: 1 }), ...v };\n return out;\n}\n\nconst kebab = (s: string) => s.replace(/([a-z0-9])([A-Z])/g, '$1-$2').replace(/[\\s_.]+/g, '-').toLowerCase();\n\n/** The custom-property map: `{ '--usa-duration-fast': '150ms', … }`. */\nexport function motionTokensToVars(tokens: MotionTokens = active, prefix = '--usa'): Record<string, string> {\n const vars: Record<string, string> = {};\n for (const [k, v] of Object.entries(tokens.duration)) vars[`${prefix}-duration-${kebab(k)}`] = `${v}ms`;\n for (const [k, v] of Object.entries(tokens.easing)) vars[`${prefix}-easing-${kebab(k)}`] = v;\n for (const [k, v] of Object.entries(tokens.spring)) {\n vars[`${prefix}-spring-${kebab(k)}-stiffness`] = String(v.stiffness);\n vars[`${prefix}-spring-${kebab(k)}-damping`] = String(v.damping);\n vars[`${prefix}-spring-${kebab(k)}-mass`] = String(v.mass);\n }\n return vars;\n}\n\n/** A stylesheet string: `:root { --usa-duration-fast: 150ms; … }`. */\nexport function motionTokensToCss(tokens: MotionTokens = active, selector = ':root', prefix = '--usa'): string {\n const body = Object.entries(motionTokensToVars(tokens, prefix)).map(([k, v]) => ` ${k}: ${v};`).join('\\n');\n return `${selector} {\\n${body}\\n}\\n`;\n}\n\n/** W3C Design Tokens (DTCG) JSON: `{ motion: { duration: { fast: { $type: 'duration', $value: '150ms' } } } }`. */\nexport function motionTokensToJSON(tokens: MotionTokens = active): Record<string, unknown> {\n const grp = <T>(o: Record<string, T>, f: (v: T) => unknown) => Object.fromEntries(Object.entries(o).map(([k, v]) => [k, f(v)]));\n return {\n motion: {\n duration: grp(tokens.duration, (v) => ({ $type: 'duration', $value: `${v}ms` })),\n easing: grp(tokens.easing, (v) => {\n const m = /^cubic-bezier\\(([^)]+)\\)$/.exec(v);\n return m ? { $type: 'cubicBezier', $value: m[1].split(',').map(Number) } : { $type: 'string', $value: v };\n }),\n spring: grp(tokens.spring, (v) => ({ $type: 'spring', $value: { ...v } })),\n },\n };\n}\n\n/** Parse `150ms`, `0.15s`, `150` → ms. */\nexport function parseDuration(v: unknown): number | undefined {\n if (typeof v === 'number' && isFinite(v)) return v;\n if (typeof v === 'object' && v && 'value' in (v as any) && 'unit' in (v as any)) return parseDuration(`${(v as any).value}${(v as any).unit}`);\n const m = /^\\s*(-?\\d*\\.?\\d+)\\s*(ms|s)?\\s*$/.exec(String(v ?? ''));\n if (!m) return undefined;\n return m[2] === 's' ? Number(m[1]) * 1000 : Number(m[1]);\n}\n\n/** Parse `[x1,y1,x2,y2]`, `'cubic-bezier(…)'`, `'0.2, 0, 0, 1'` or a keyword → CSS easing. */\nexport function parseEasing(v: unknown): string | undefined {\n if (Array.isArray(v) && v.length === 4 && v.every((n) => typeof n === 'number')) return `cubic-bezier(${v.join(', ')})`;\n if (typeof v !== 'string' || !v.trim()) return undefined;\n const s = v.trim();\n if (/^-?\\d*\\.?\\d+(\\s*,\\s*-?\\d*\\.?\\d+){3}$/.test(s)) return `cubic-bezier(${s.split(/\\s*,\\s*/).join(', ')})`;\n return s;\n}\n\nconst isLeaf = (o: any) => o && typeof o === 'object' && ('$value' in o || 'value' in o);\nconst leafValue = (o: any) => ('$value' in o ? o.$value : o.value);\nconst leafType = (o: any) => String(o.$type ?? o.type ?? '').toLowerCase();\n\n/**\n * Import tokens from W3C DTCG JSON, Figma Tokens / Tokens Studio\n * (`{ value, type }`) or Style Dictionary (`{ value }`, nested) — anything\n * under a `duration` / `easing` / `spring` group (any depth, e.g.\n * `motion.duration.fast` or `global.animation.easing.out`), or typed leaves\n * (`duration`, `cubicBezier`, `transition`, `spring`). Unknown values are\n * skipped; the result is merged over the defaults.\n */\nexport function importMotionTokens(json: unknown, base: MotionTokens = MOTION_TOKENS): MotionTokens {\n const partial: Required<DeepPartialTokens> = { duration: {}, easing: {}, spring: {} };\n const walk = (node: any, path: string[]) => {\n if (!node || typeof node !== 'object') return;\n if (isLeaf(node)) {\n const name = path[path.length - 1];\n const type = leafType(node);\n const group = path.slice(0, -1).map((p) => p.toLowerCase());\n const val = leafValue(node);\n const inGroup = (g: string[]) => group.some((p) => g.includes(p));\n if (type === 'duration' || (!type && inGroup(['duration', 'durations'])) || (type !== 'cubicbezier' && inGroup(['duration', 'durations']))) {\n const ms = parseDuration(val);\n if (ms !== undefined) partial.duration[name] = ms;\n } else if (type === 'cubicbezier' || type === 'easing' || inGroup(['easing', 'easings', 'ease'])) {\n const e = parseEasing(val);\n if (e) partial.easing[name] = e;\n } else if (type === 'spring' || inGroup(['spring', 'springs'])) {\n if (val && typeof val === 'object') partial.spring[name] = { stiffness: Number(val.stiffness ?? 170), damping: Number(val.damping ?? 26), mass: Number(val.mass ?? 1) };\n } else if (type === 'transition' && val && typeof val === 'object') {\n const ms = parseDuration(val.duration);\n if (ms !== undefined) partial.duration[name] = ms;\n const e = parseEasing(val.timingFunction);\n if (e) partial.easing[name] = e;\n }\n return;\n }\n for (const [k, v] of Object.entries(node)) if (!k.startsWith('$')) walk(v, [...path, k]);\n };\n walk(json, []);\n return mergeMotionTokens(partial, base);\n}\n\n/** The tokens currently applied (via `applyMotionTokens`), or the defaults. */\nexport function getMotionTokens(): MotionTokens {\n return clone(active);\n}\n\n/**\n * Write tokens as CSS custom properties on `root` (default `<html>`) and make\n * them the active set for `motionToken()`. Returns an undo function.\n */\nexport function applyMotionTokens(tokens: DeepPartialTokens | MotionTokens = MOTION_TOKENS, root?: HTMLElement, prefix = '--usa'): () => void {\n const prev = active;\n active = mergeMotionTokens(tokens as DeepPartialTokens, MOTION_TOKENS);\n const el = root || (typeof document !== 'undefined' ? document.documentElement : null);\n const vars = motionTokensToVars(active, prefix);\n const old: Record<string, string> = {};\n if (el) for (const [k, v] of Object.entries(vars)) ((old[k] = el.style.getPropertyValue(k)), el.style.setProperty(k, v));\n return () => {\n active = prev;\n if (el) for (const [k, v] of Object.entries(old)) v ? el.style.setProperty(k, v) : el.style.removeProperty(k);\n };\n}\n\n/** Look up a token: `motionToken('duration', 'fast')` → `150`; `motionToken('easing', 'emphasized')` → CSS easing. */\nexport function motionToken(group: 'duration', name: string): number;\nexport function motionToken(group: 'easing', name: string): string;\nexport function motionToken(group: 'spring', name: string): SpringToken;\nexport function motionToken(group: MotionTokenGroup, name: string): number | string | SpringToken | undefined {\n const g = active[group] as Record<string, any>;\n return g[name] ?? (MOTION_TOKENS[group] as Record<string, any>)[name];\n}\n\n/** `var(--usa-duration-fast, 150ms)` — a CSS reference with the current value as fallback. */\nexport function motionVar(group: MotionTokenGroup, name: string, prop?: 'stiffness' | 'damping' | 'mass', prefix = '--usa'): string {\n if (group === 'spring') {\n const s = motionToken('spring', name);\n const p = prop || 'stiffness';\n return `var(${prefix}-spring-${kebab(name)}-${p}, ${s ? s[p] : ''})`;\n }\n const v = group === 'duration' ? `${motionToken('duration', name)}ms` : motionToken('easing', name);\n return `var(${prefix}-${group}-${kebab(name)}, ${v})`;\n}\n\n/** Resolve a duration that may be a token name (`'fast'`) or ms. */\nexport function resolveDurationToken(v: number | string | undefined, fallback: number): number {\n if (typeof v === 'number') return v;\n if (typeof v === 'string') return (active.duration[v] ?? parseDuration(v)) ?? fallback;\n return fallback;\n}\n\n/** Resolve an easing that may be a token name (`'emphasized'`) or CSS. */\nexport function resolveEasingToken(v: string | undefined, fallback: string): string {\n if (!v) return fallback;\n return active.easing[v] ?? v;\n}\n"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;AAaG;AAiBH;AACO,MAAM,aAAa,GAAiB;IACzC,QAAQ,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE;AACvF,IAAA,MAAM,EAAE;AACN,QAAA,MAAM,EAAE,QAAQ;AAChB,QAAA,QAAQ,EAAE,4BAA4B;AACtC,QAAA,UAAU,EAAE,gCAAgC;AAC5C,QAAA,UAAU,EAAE,0BAA0B;AACtC,QAAA,UAAU,EAAE,4BAA4B;AACxC,QAAA,MAAM,EAAE,mCAAmC;AAC3C,QAAA,MAAM,EAAE,wCAAwC;AACjD,KAAA;AACD,IAAA,MAAM,EAAE;AACN,QAAA,MAAM,EAAE,EAAE,SAAS,EAAE,GAAG,EAAE,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE;AAChD,QAAA,MAAM,EAAE,EAAE,SAAS,EAAE,GAAG,EAAE,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE;AAChD,QAAA,MAAM,EAAE,EAAE,SAAS,EAAE,GAAG,EAAE,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE;AAChD,QAAA,MAAM,EAAE,EAAE,SAAS,EAAE,GAAG,EAAE,OAAO,EAAE,CAAC,EAAE,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C,QAAQ,EAAE,IAAI,CAAC;AACrC,QAAA,MAAM,CAAC,GAAG,IAAI,IAAI,WAAW;QAC7B,OAAO,CAAA,IAAA,EAAO,MAAM,CAAA,QAAA,EAAW,KAAK,CAAC,IAAI,CAAC,CAAA,CAAA,EAAI,CAAC,CAAA,EAAA,EAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,CAAA,CAAA,CAAG;IACtE;IACA,MAAM,CAAC,GAAG,KAAK,KAAK,UAAU,GAAG,CAAA,EAAG,WAAW,CAAC,UAAU,EAAE,IAAI,CAAC,CAAA,EAAA,CAAI,GAAG,WAAW,CAAC,QAAQ,EAAE,IAAI,CAAC;AACnG,IAAA,OAAO,CAAA,IAAA,EAAO,MAAM,CAAA,CAAA,EAAI,KAAK,CAAA,CAAA,EAAI,KAAK,CAAC,IAAI,CAAC,CAAA,EAAA,EAAK,CAAC,CAAA,CAAA,CAAG;AACvD;AAEA;AACM,SAAU,oBAAoB,CAAC,CAA8B,EAAE,QAAgB,EAAA;IACnF,IAAI,OAAO,CAAC,KAAK,QAAQ;AAAE,QAAA,OAAO,CAAC;IACnC,IAAI,OAAO,CAAC,KAAK,QAAQ;AAAE,QAAA,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,aAAa,CAAC,CAAC,CAAC,KAAK,QAAQ;AACtF,IAAA,OAAO,QAAQ;AACjB;AAEA;AACM,SAAU,kBAAkB,CAAC,CAAqB,EAAE,QAAgB,EAAA;AACxE,IAAA,IAAI,CAAC,CAAC;AAAE,QAAA,OAAO,QAAQ;IACvB,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC;AAC9B;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { h as defineElement, k as kindOf, s as shadowStyles, i as EASE_OUT, F as FLUENT_DECELERATE, p as prefersReducedMotion } from '../chunks/base-
|
|
2
|
-
export { a as configureComponents } from '../chunks/base-
|
|
1
|
+
import { h as defineElement, k as kindOf, s as shadowStyles, i as EASE_OUT, F as FLUENT_DECELERATE, p as prefersReducedMotion } from '../chunks/base-BPG5zvex.js';
|
|
2
|
+
export { a as configureComponents } from '../chunks/base-BPG5zvex.js';
|
|
3
3
|
|
|
4
4
|
var shadowCss = ":host{display:contents}dialog{position:fixed;inset:0;width:100%;height:100%;max-width:none;max-height:none;margin:0;padding:0;border:0;background:transparent;color:inherit;overflow:hidden}dialog:not([open]){display:none}dialog::backdrop{background:transparent}[part=\"backdrop\"]{position:absolute;inset:0;background:var(--usa-dialog-backdrop,rgb(0 0 0 / 0.42))}[part=\"panel\"]{position:absolute;left:50%;top:50%;translate:-50% -50%;box-sizing:border-box;width:min(var(--usa-dialog-width,480px),calc(100vw - 32px));max-height:calc(100vh - 32px);overflow:auto;padding:var(--usa-dialog-padding,24px);border-radius:var(--usa-dialog-radius,12px);background:var(--usa-dialog-bg,Canvas);color:var(--usa-dialog-fg,CanvasText);box-shadow:0 32px 64px -12px rgb(0 0 0 / 0.45),0 0 0 1px rgb(127 127 127 / 0.18)}dialog[data-kind^=\"drawer\"] [part=\"panel\"]{top:0;bottom:0;translate:none;max-height:none;height:100%;border-radius:0;width:min(var(--usa-dialog-width,380px),88vw)}dialog[data-kind=\"drawer-start\"] [part=\"panel\"]{left:0}dialog[data-kind=\"drawer-end\"] [part=\"panel\"]{left:auto;right:0}dialog[data-kind=\"drawer-bottom\"] [part=\"panel\"],dialog[data-kind=\"sheet\"] [part=\"panel\"]{top:auto;bottom:0;left:0;right:0;translate:none;width:100%;height:auto;max-height:85vh;border-radius:var(--usa-dialog-radius,16px) var(--usa-dialog-radius,16px) 0 0}dialog[data-kind=\"sheet\"] [part=\"panel\"]{left:50%;translate:-50% 0;width:min(var(--usa-dialog-width,560px),100vw)}";
|
|
5
5
|
|
package/dist/components/ui.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { h as defineElement,
|
|
2
|
-
export { a as configureComponents, p as prefersReducedMotion } from '../chunks/base-
|
|
3
|
-
import { d as springEasing, c as createSpring, p as projectInertia, s as snapTo, a as rubberBand } from '../chunks/spring-
|
|
4
|
-
import { a as adoptVariants } from '../chunks/variants-
|
|
5
|
-
export { V as VARIANTS, s as setVariant } from '../chunks/variants-
|
|
1
|
+
import { h as defineElement, b as clamp, d as caf, r as raf } from '../chunks/base-BPG5zvex.js';
|
|
2
|
+
export { a as configureComponents, p as prefersReducedMotion } from '../chunks/base-BPG5zvex.js';
|
|
3
|
+
import { d as springEasing, c as createSpring, p as projectInertia, s as snapTo, a as rubberBand } from '../chunks/spring-BziPsW3r.js';
|
|
4
|
+
import { a as adoptVariants } from '../chunks/variants-BVYMcxRv.js';
|
|
5
|
+
export { V as VARIANTS, s as setVariant } from '../chunks/variants-BVYMcxRv.js';
|
|
6
6
|
|
|
7
7
|
/** Position a fixed `floating` element next to `anchor`, flipping when it would leave the viewport. */
|
|
8
8
|
function place(floating, anchor, placement = 'top', gap = 8) {
|
package/dist/components/vue.cjs
CHANGED
|
@@ -16,7 +16,8 @@ require('./click.cjs');
|
|
|
16
16
|
require('./ui.cjs');
|
|
17
17
|
require('./page.cjs');
|
|
18
18
|
require('./timeline.cjs');
|
|
19
|
-
require('../chunks/core-
|
|
19
|
+
require('../chunks/core-BRIIoKeS.cjs');
|
|
20
|
+
require('./tokens.cjs');
|
|
20
21
|
require('./gesture.cjs');
|
|
21
22
|
require('../chunks/core-IaorbTdu.cjs');
|
|
22
23
|
require('./svg.cjs');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vue.cjs","sources":["../../src/components/frameworks/vue.ts"],"sourcesContent":["/**\n * use-scroll-animate/components/vue — Vue integration (v2.9).\n *\n * ```js\n * // vite.config.js\n * import vue from '@vitejs/plugin-vue';\n * import { isUsaElement } from 'use-scroll-animate/components/vue';\n * export default { plugins: [vue({ template: { compilerOptions: { isCustomElement: isUsaElement } } })] };\n *\n * // main.js\n * import { UsaPlugin } from 'use-scroll-animate/components/vue';\n * app.use(UsaPlugin, { categories: ['click', 'cards'] });\n * ```\n * In templates, listen with `@usa:change=\"…\"` and bind properties with\n * `.prop`: `<usa-toggle :checked.prop=\"on\" @usa:change=\"on = $event.detail.checked\">`.\n */\nimport { defineComponents, type ComponentCategory } from '../index';\n\n/** `compilerOptions.isCustomElement` predicate for every `<usa-*>` tag. */\nexport const isUsaElement = (tag: string): boolean => tag.startsWith('usa-');\n\nexport interface UsaPluginOptions {\n /** Only register these categories (default: all). */\n categories?: ComponentCategory[];\n}\n\n/** Vue plugin: registers the `<usa-*>` elements (client only) and sets `isCustomElement` at runtime. */\nexport const UsaPlugin = {\n install(app: { config: { compilerOptions?: { isCustomElement?: (t: string) => boolean } } }, options: UsaPluginOptions = {}): void {\n const co = (app.config.compilerOptions ||= {});\n const prev = co.isCustomElement;\n co.isCustomElement = (t: string) => isUsaElement(t) || !!prev?.(t);\n defineComponents(options.categories);\n },\n};\n"],"names":["defineComponents"],"mappings":"
|
|
1
|
+
{"version":3,"file":"vue.cjs","sources":["../../src/components/frameworks/vue.ts"],"sourcesContent":["/**\n * use-scroll-animate/components/vue — Vue integration (v2.9).\n *\n * ```js\n * // vite.config.js\n * import vue from '@vitejs/plugin-vue';\n * import { isUsaElement } from 'use-scroll-animate/components/vue';\n * export default { plugins: [vue({ template: { compilerOptions: { isCustomElement: isUsaElement } } })] };\n *\n * // main.js\n * import { UsaPlugin } from 'use-scroll-animate/components/vue';\n * app.use(UsaPlugin, { categories: ['click', 'cards'] });\n * ```\n * In templates, listen with `@usa:change=\"…\"` and bind properties with\n * `.prop`: `<usa-toggle :checked.prop=\"on\" @usa:change=\"on = $event.detail.checked\">`.\n */\nimport { defineComponents, type ComponentCategory } from '../index';\n\n/** `compilerOptions.isCustomElement` predicate for every `<usa-*>` tag. */\nexport const isUsaElement = (tag: string): boolean => tag.startsWith('usa-');\n\nexport interface UsaPluginOptions {\n /** Only register these categories (default: all). */\n categories?: ComponentCategory[];\n}\n\n/** Vue plugin: registers the `<usa-*>` elements (client only) and sets `isCustomElement` at runtime. */\nexport const UsaPlugin = {\n install(app: { config: { compilerOptions?: { isCustomElement?: (t: string) => boolean } } }, options: UsaPluginOptions = {}): void {\n const co = (app.config.compilerOptions ||= {});\n const prev = co.isCustomElement;\n co.isCustomElement = (t: string) => isUsaElement(t) || !!prev?.(t);\n defineComponents(options.categories);\n },\n};\n"],"names":["defineComponents"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;AAeG;AAGH;AACO,MAAM,YAAY,GAAG,CAAC,GAAW,KAAc,GAAG,CAAC,UAAU,CAAC,MAAM;AAO3E;AACO,MAAM,SAAS,GAAG;AACvB,IAAA,OAAO,CAAC,GAAmF,EAAE,OAAA,GAA4B,EAAE,EAAA;;AACzH,QAAA,MAAM,EAAE,IAAG,CAAA,EAAA,GAAC,GAAG,CAAC,MAAM,EAAC,eAAe,KAAA,EAAA,CAAf,eAAe,GAAK,EAAE,EAAC;AAC9C,QAAA,MAAM,IAAI,GAAG,EAAE,CAAC,eAAe;QAC/B,EAAE,CAAC,eAAe,GAAG,CAAC,CAAS,KAAK,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC;AAClE,QAAAA,2BAAgB,CAAC,OAAO,CAAC,UAAU,CAAC;IACtC,CAAC;;;;;;"}
|
|
@@ -1285,9 +1285,9 @@ declare global {
|
|
|
1285
1285
|
*/
|
|
1286
1286
|
type TimelinePosition = number | string;
|
|
1287
1287
|
interface TimelineStepOptions {
|
|
1288
|
-
/** Duration in ms (
|
|
1289
|
-
duration?: number;
|
|
1290
|
-
/** CSS easing (
|
|
1288
|
+
/** Duration in ms or a motion token name (`'fast'`, `'slow'`…; 4.2). Default: timeline default, 600. */
|
|
1289
|
+
duration?: number | string;
|
|
1290
|
+
/** CSS easing or a motion token name (`'emphasized'`, `'spring'`…; 4.2). Default `cubic-bezier(0.22, 1, 0.36, 1)`. */
|
|
1291
1291
|
easing?: string;
|
|
1292
1292
|
/** Start position, see `TimelinePosition`. */
|
|
1293
1293
|
at?: TimelinePosition;
|
|
@@ -1295,10 +1295,26 @@ interface TimelineStepOptions {
|
|
|
1295
1295
|
stagger?: number;
|
|
1296
1296
|
}
|
|
1297
1297
|
interface ScrubOptions {
|
|
1298
|
-
/** Scroll offset (px) before the source's top reaches the viewport bottom where progress starts. */
|
|
1298
|
+
/** Scroll offset (px) before the source's top reaches the viewport bottom where progress starts (JS engine only). */
|
|
1299
1299
|
offset?: number;
|
|
1300
|
-
/** Smoothing 0–1 (0 = immediate, default 0). */
|
|
1300
|
+
/** Smoothing 0–1 (0 = immediate, default 0). Smoothing needs the JS engine. */
|
|
1301
1301
|
smooth?: number;
|
|
1302
|
+
/**
|
|
1303
|
+
* 4.1: which progress source drives the timeline.
|
|
1304
|
+
* - `'view'` (default): `source` moving through the viewport (CSS `ViewTimeline`, range `cover`).
|
|
1305
|
+
* - `'scroll'`: the scroll position of `source` itself (a scroll container; CSS `ScrollTimeline`).
|
|
1306
|
+
*/
|
|
1307
|
+
source?: 'view' | 'scroll';
|
|
1308
|
+
/** 4.1: `'auto'` (default) uses the browser's native scroll-driven animations when available, `'js'` forces the fallback. */
|
|
1309
|
+
engine?: 'auto' | 'native' | 'js';
|
|
1310
|
+
/** 4.1: scroll axis, `'block'` (default) · `'inline'` · `'x'` · `'y'`. */
|
|
1311
|
+
axis?: 'block' | 'inline' | 'x' | 'y';
|
|
1312
|
+
}
|
|
1313
|
+
/** The function `scrub()` returns: call it to stop. `native` tells which engine runs it. */
|
|
1314
|
+
interface ScrubHandle {
|
|
1315
|
+
(): void;
|
|
1316
|
+
/** `true` when the browser's ScrollTimeline / ViewTimeline drives it (compositor, no JS per frame). */
|
|
1317
|
+
readonly native: boolean;
|
|
1302
1318
|
}
|
|
1303
1319
|
interface Timeline {
|
|
1304
1320
|
/** Total length in ms. */
|
|
@@ -1322,8 +1338,14 @@ interface Timeline {
|
|
|
1322
1338
|
seek(to: TimelinePosition): Timeline;
|
|
1323
1339
|
/** Get or set progress 0–1. */
|
|
1324
1340
|
progress(p?: number): number;
|
|
1325
|
-
/**
|
|
1326
|
-
|
|
1341
|
+
/**
|
|
1342
|
+
* Tie progress to scroll: `source` moving through the viewport (or, with
|
|
1343
|
+
* `{ source: 'scroll' }`, a scroll container's own position). Runs on native
|
|
1344
|
+
* ScrollTimeline / ViewTimeline when available (and no `smooth`, `offset`,
|
|
1345
|
+
* `call()` cues or `onUpdate` need JS), else on a rAF-throttled listener.
|
|
1346
|
+
* Returns a stop function with a `native` flag.
|
|
1347
|
+
*/
|
|
1348
|
+
scrub(source: Element, options?: ScrubOptions): ScrubHandle;
|
|
1327
1349
|
/** Stop and drop every animation (elements keep their last frame). */
|
|
1328
1350
|
cancel(): void;
|
|
1329
1351
|
}
|
|
@@ -1337,7 +1359,9 @@ interface Timeline {
|
|
|
1337
1359
|
* Attributes: `trigger` (`view` default · `click` · `manual`), `scrub`
|
|
1338
1360
|
* (progress follows scroll instead of playing), `overlap` (ms each step
|
|
1339
1361
|
* overlaps the previous, default 0), `duration` (600), `stagger` (ms),
|
|
1340
|
-
* `repeat` (replay every time it enters the viewport).
|
|
1362
|
+
* `repeat` (replay every time it enters the viewport). 4.1: `scrub` runs on native
|
|
1363
|
+
* ScrollTimeline / ViewTimeline when supported (`data-native` is set); `scrub="js"`,
|
|
1364
|
+
* `scrub="scroll"` and `smooth` tune it. Methods: `play()`,
|
|
1341
1365
|
* `reverse()`, `seek(t)`; property `timeline`. Event `usa:complete`.
|
|
1342
1366
|
* Reduced motion: steps appear in their final state.
|
|
1343
1367
|
*/
|
package/dist/components/vue.d.ts
CHANGED
|
@@ -1285,9 +1285,9 @@ declare global {
|
|
|
1285
1285
|
*/
|
|
1286
1286
|
type TimelinePosition = number | string;
|
|
1287
1287
|
interface TimelineStepOptions {
|
|
1288
|
-
/** Duration in ms (
|
|
1289
|
-
duration?: number;
|
|
1290
|
-
/** CSS easing (
|
|
1288
|
+
/** Duration in ms or a motion token name (`'fast'`, `'slow'`…; 4.2). Default: timeline default, 600. */
|
|
1289
|
+
duration?: number | string;
|
|
1290
|
+
/** CSS easing or a motion token name (`'emphasized'`, `'spring'`…; 4.2). Default `cubic-bezier(0.22, 1, 0.36, 1)`. */
|
|
1291
1291
|
easing?: string;
|
|
1292
1292
|
/** Start position, see `TimelinePosition`. */
|
|
1293
1293
|
at?: TimelinePosition;
|
|
@@ -1295,10 +1295,26 @@ interface TimelineStepOptions {
|
|
|
1295
1295
|
stagger?: number;
|
|
1296
1296
|
}
|
|
1297
1297
|
interface ScrubOptions {
|
|
1298
|
-
/** Scroll offset (px) before the source's top reaches the viewport bottom where progress starts. */
|
|
1298
|
+
/** Scroll offset (px) before the source's top reaches the viewport bottom where progress starts (JS engine only). */
|
|
1299
1299
|
offset?: number;
|
|
1300
|
-
/** Smoothing 0–1 (0 = immediate, default 0). */
|
|
1300
|
+
/** Smoothing 0–1 (0 = immediate, default 0). Smoothing needs the JS engine. */
|
|
1301
1301
|
smooth?: number;
|
|
1302
|
+
/**
|
|
1303
|
+
* 4.1: which progress source drives the timeline.
|
|
1304
|
+
* - `'view'` (default): `source` moving through the viewport (CSS `ViewTimeline`, range `cover`).
|
|
1305
|
+
* - `'scroll'`: the scroll position of `source` itself (a scroll container; CSS `ScrollTimeline`).
|
|
1306
|
+
*/
|
|
1307
|
+
source?: 'view' | 'scroll';
|
|
1308
|
+
/** 4.1: `'auto'` (default) uses the browser's native scroll-driven animations when available, `'js'` forces the fallback. */
|
|
1309
|
+
engine?: 'auto' | 'native' | 'js';
|
|
1310
|
+
/** 4.1: scroll axis, `'block'` (default) · `'inline'` · `'x'` · `'y'`. */
|
|
1311
|
+
axis?: 'block' | 'inline' | 'x' | 'y';
|
|
1312
|
+
}
|
|
1313
|
+
/** The function `scrub()` returns: call it to stop. `native` tells which engine runs it. */
|
|
1314
|
+
interface ScrubHandle {
|
|
1315
|
+
(): void;
|
|
1316
|
+
/** `true` when the browser's ScrollTimeline / ViewTimeline drives it (compositor, no JS per frame). */
|
|
1317
|
+
readonly native: boolean;
|
|
1302
1318
|
}
|
|
1303
1319
|
interface Timeline {
|
|
1304
1320
|
/** Total length in ms. */
|
|
@@ -1322,8 +1338,14 @@ interface Timeline {
|
|
|
1322
1338
|
seek(to: TimelinePosition): Timeline;
|
|
1323
1339
|
/** Get or set progress 0–1. */
|
|
1324
1340
|
progress(p?: number): number;
|
|
1325
|
-
/**
|
|
1326
|
-
|
|
1341
|
+
/**
|
|
1342
|
+
* Tie progress to scroll: `source` moving through the viewport (or, with
|
|
1343
|
+
* `{ source: 'scroll' }`, a scroll container's own position). Runs on native
|
|
1344
|
+
* ScrollTimeline / ViewTimeline when available (and no `smooth`, `offset`,
|
|
1345
|
+
* `call()` cues or `onUpdate` need JS), else on a rAF-throttled listener.
|
|
1346
|
+
* Returns a stop function with a `native` flag.
|
|
1347
|
+
*/
|
|
1348
|
+
scrub(source: Element, options?: ScrubOptions): ScrubHandle;
|
|
1327
1349
|
/** Stop and drop every animation (elements keep their last frame). */
|
|
1328
1350
|
cancel(): void;
|
|
1329
1351
|
}
|
|
@@ -1337,7 +1359,9 @@ interface Timeline {
|
|
|
1337
1359
|
* Attributes: `trigger` (`view` default · `click` · `manual`), `scrub`
|
|
1338
1360
|
* (progress follows scroll instead of playing), `overlap` (ms each step
|
|
1339
1361
|
* overlaps the previous, default 0), `duration` (600), `stagger` (ms),
|
|
1340
|
-
* `repeat` (replay every time it enters the viewport).
|
|
1362
|
+
* `repeat` (replay every time it enters the viewport). 4.1: `scrub` runs on native
|
|
1363
|
+
* ScrollTimeline / ViewTimeline when supported (`data-native` is set); `scrub="js"`,
|
|
1364
|
+
* `scrub="scroll"` and `smooth` tune it. Methods: `play()`,
|
|
1341
1365
|
* `reverse()`, `seek(t)`; property `timeline`. Event `usa:complete`.
|
|
1342
1366
|
* Reduced motion: steps appear in their final state.
|
|
1343
1367
|
*/
|
package/dist/components/vue.js
CHANGED
|
@@ -1,22 +1,23 @@
|
|
|
1
1
|
import { defineComponents } from '../components.js';
|
|
2
2
|
import './reveal.js';
|
|
3
|
-
import '../chunks/base-
|
|
3
|
+
import '../chunks/base-BPG5zvex.js';
|
|
4
4
|
import './text.js';
|
|
5
5
|
import './interaction.js';
|
|
6
6
|
import './feedback.js';
|
|
7
7
|
import './background.js';
|
|
8
|
-
import '../chunks/variants-
|
|
8
|
+
import '../chunks/variants-BVYMcxRv.js';
|
|
9
9
|
import './transitions.js';
|
|
10
10
|
import './physics.js';
|
|
11
|
-
import '../chunks/spring-
|
|
11
|
+
import '../chunks/spring-BziPsW3r.js';
|
|
12
12
|
import './cards.js';
|
|
13
13
|
import './click.js';
|
|
14
14
|
import './ui.js';
|
|
15
15
|
import './page.js';
|
|
16
16
|
import './timeline.js';
|
|
17
|
-
import '../chunks/core-
|
|
17
|
+
import '../chunks/core-LkGRmgES.js';
|
|
18
|
+
import './tokens.js';
|
|
18
19
|
import './gesture.js';
|
|
19
|
-
import '../chunks/core-
|
|
20
|
+
import '../chunks/core-eXX8rB_b.js';
|
|
20
21
|
import './svg.js';
|
|
21
22
|
import './webgl.js';
|
|
22
23
|
import './depth.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vue.js","sources":["../../src/components/frameworks/vue.ts"],"sourcesContent":["/**\n * use-scroll-animate/components/vue — Vue integration (v2.9).\n *\n * ```js\n * // vite.config.js\n * import vue from '@vitejs/plugin-vue';\n * import { isUsaElement } from 'use-scroll-animate/components/vue';\n * export default { plugins: [vue({ template: { compilerOptions: { isCustomElement: isUsaElement } } })] };\n *\n * // main.js\n * import { UsaPlugin } from 'use-scroll-animate/components/vue';\n * app.use(UsaPlugin, { categories: ['click', 'cards'] });\n * ```\n * In templates, listen with `@usa:change=\"…\"` and bind properties with\n * `.prop`: `<usa-toggle :checked.prop=\"on\" @usa:change=\"on = $event.detail.checked\">`.\n */\nimport { defineComponents, type ComponentCategory } from '../index';\n\n/** `compilerOptions.isCustomElement` predicate for every `<usa-*>` tag. */\nexport const isUsaElement = (tag: string): boolean => tag.startsWith('usa-');\n\nexport interface UsaPluginOptions {\n /** Only register these categories (default: all). */\n categories?: ComponentCategory[];\n}\n\n/** Vue plugin: registers the `<usa-*>` elements (client only) and sets `isCustomElement` at runtime. */\nexport const UsaPlugin = {\n install(app: { config: { compilerOptions?: { isCustomElement?: (t: string) => boolean } } }, options: UsaPluginOptions = {}): void {\n const co = (app.config.compilerOptions ||= {});\n const prev = co.isCustomElement;\n co.isCustomElement = (t: string) => isUsaElement(t) || !!prev?.(t);\n defineComponents(options.categories);\n },\n};\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"vue.js","sources":["../../src/components/frameworks/vue.ts"],"sourcesContent":["/**\n * use-scroll-animate/components/vue — Vue integration (v2.9).\n *\n * ```js\n * // vite.config.js\n * import vue from '@vitejs/plugin-vue';\n * import { isUsaElement } from 'use-scroll-animate/components/vue';\n * export default { plugins: [vue({ template: { compilerOptions: { isCustomElement: isUsaElement } } })] };\n *\n * // main.js\n * import { UsaPlugin } from 'use-scroll-animate/components/vue';\n * app.use(UsaPlugin, { categories: ['click', 'cards'] });\n * ```\n * In templates, listen with `@usa:change=\"…\"` and bind properties with\n * `.prop`: `<usa-toggle :checked.prop=\"on\" @usa:change=\"on = $event.detail.checked\">`.\n */\nimport { defineComponents, type ComponentCategory } from '../index';\n\n/** `compilerOptions.isCustomElement` predicate for every `<usa-*>` tag. */\nexport const isUsaElement = (tag: string): boolean => tag.startsWith('usa-');\n\nexport interface UsaPluginOptions {\n /** Only register these categories (default: all). */\n categories?: ComponentCategory[];\n}\n\n/** Vue plugin: registers the `<usa-*>` elements (client only) and sets `isCustomElement` at runtime. */\nexport const UsaPlugin = {\n install(app: { config: { compilerOptions?: { isCustomElement?: (t: string) => boolean } } }, options: UsaPluginOptions = {}): void {\n const co = (app.config.compilerOptions ||= {});\n const prev = co.isCustomElement;\n co.isCustomElement = (t: string) => isUsaElement(t) || !!prev?.(t);\n defineComponents(options.categories);\n },\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;AAeG;AAGH;AACO,MAAM,YAAY,GAAG,CAAC,GAAW,KAAc,GAAG,CAAC,UAAU,CAAC,MAAM;AAO3E;AACO,MAAM,SAAS,GAAG;AACvB,IAAA,OAAO,CAAC,GAAmF,EAAE,OAAA,GAA4B,EAAE,EAAA;;AACzH,QAAA,MAAM,EAAE,IAAG,CAAA,EAAA,GAAC,GAAG,CAAC,MAAM,EAAC,eAAe,KAAA,EAAA,CAAf,eAAe,GAAK,EAAE,EAAC;AAC9C,QAAA,MAAM,IAAI,GAAG,EAAE,CAAC,eAAe;QAC/B,EAAE,CAAC,eAAe,GAAG,CAAC,CAAS,KAAK,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC;AAClE,QAAA,gBAAgB,CAAC,OAAO,CAAC,UAAU,CAAC;IACtC,CAAC;;;;;"}
|
package/dist/components/webgl.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { h as defineElement, n as now,
|
|
2
|
-
export { a as configureComponents, p as prefersReducedMotion } from '../chunks/base-
|
|
1
|
+
import { h as defineElement, n as now, d as caf, b as clamp, r as raf } from '../chunks/base-BPG5zvex.js';
|
|
2
|
+
export { a as configureComponents, p as prefersReducedMotion } from '../chunks/base-BPG5zvex.js';
|
|
3
3
|
|
|
4
4
|
/** Minimal WebGL runner: one full-canvas quad, one fragment shader, optional image texture. */
|
|
5
5
|
const VERTEX = 'attribute vec2 p;varying vec2 v_uv;void main(){v_uv=p*.5+.5;gl_Position=vec4(p,0.,1.);}';
|
package/dist/components.cjs
CHANGED
|
@@ -20,9 +20,10 @@ var components_layout = require('./components/layout.cjs');
|
|
|
20
20
|
var components_packs = require('./components/packs.cjs');
|
|
21
21
|
var variants = require('./chunks/variants-BNIrn4ch.cjs');
|
|
22
22
|
var base = require('./chunks/base-CXx7jZ-o.cjs');
|
|
23
|
+
var components_tokens = require('./components/tokens.cjs');
|
|
23
24
|
var indexTags = require('./chunks/index-tags-BQh_uGqH.cjs');
|
|
24
25
|
var spring = require('./chunks/spring-2OTnYCzm.cjs');
|
|
25
|
-
var core = require('./chunks/core-
|
|
26
|
+
var core = require('./chunks/core-BRIIoKeS.cjs');
|
|
26
27
|
var core$1 = require('./chunks/core-IaorbTdu.cjs');
|
|
27
28
|
|
|
28
29
|
/**
|
|
@@ -243,6 +244,20 @@ exports.MOTION_SCALE = base.MOTION_SCALE;
|
|
|
243
244
|
exports.configureComponents = base.configureComponents;
|
|
244
245
|
exports.getMotionIntensity = base.getMotionIntensity;
|
|
245
246
|
exports.prefersReducedMotion = base.prefersReducedMotion;
|
|
247
|
+
exports.MOTION_TOKENS = components_tokens.MOTION_TOKENS;
|
|
248
|
+
exports.applyMotionTokens = components_tokens.applyMotionTokens;
|
|
249
|
+
exports.getMotionTokens = components_tokens.getMotionTokens;
|
|
250
|
+
exports.importMotionTokens = components_tokens.importMotionTokens;
|
|
251
|
+
exports.mergeMotionTokens = components_tokens.mergeMotionTokens;
|
|
252
|
+
exports.motionToken = components_tokens.motionToken;
|
|
253
|
+
exports.motionTokensToCss = components_tokens.motionTokensToCss;
|
|
254
|
+
exports.motionTokensToJSON = components_tokens.motionTokensToJSON;
|
|
255
|
+
exports.motionTokensToVars = components_tokens.motionTokensToVars;
|
|
256
|
+
exports.motionVar = components_tokens.motionVar;
|
|
257
|
+
exports.parseDuration = components_tokens.parseDuration;
|
|
258
|
+
exports.parseEasing = components_tokens.parseEasing;
|
|
259
|
+
exports.resolveDurationToken = components_tokens.resolveDurationToken;
|
|
260
|
+
exports.resolveEasingToken = components_tokens.resolveEasingToken;
|
|
246
261
|
exports.COMPONENT_CATEGORIES = indexTags.COMPONENT_CATEGORIES;
|
|
247
262
|
exports.SPRING_PRESETS = spring.SPRING_PRESETS;
|
|
248
263
|
exports.createSpring = spring.createSpring;
|
|
@@ -258,6 +273,7 @@ exports.stepSpring = spring.stepSpring;
|
|
|
258
273
|
exports.supportsLinearEasing = spring.supportsLinearEasing;
|
|
259
274
|
exports.TIMELINE_PRESETS = core.TIMELINE_PRESETS;
|
|
260
275
|
exports.resolvePosition = core.resolvePosition;
|
|
276
|
+
exports.supportsNativeScrub = core.supportsNativeScrub;
|
|
261
277
|
exports.timeline = core.timeline;
|
|
262
278
|
exports.gesture = core$1.gesture;
|
|
263
279
|
exports.pinchScale = core$1.pinchScale;
|
package/dist/components.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"components.cjs","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';\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":["defineRevealComponents","defineTextComponents","defineInteractionComponents","defineFeedbackComponents","defineBackgroundComponents","defineTransitionComponents","definePhysicsComponents","defineCardComponents","defineClickComponents","defineUiComponents","definePageComponents","defineTimelineComponents","defineGestureComponents","defineSvgComponents","defineWebglComponents","defineDepthComponents","defineLayoutComponents","definePacksComponents","canDefine","adoptVariants"],"mappings":"
|
|
1
|
+
{"version":3,"file":"components.cjs","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":["defineRevealComponents","defineTextComponents","defineInteractionComponents","defineFeedbackComponents","defineBackgroundComponents","defineTransitionComponents","definePhysicsComponents","defineCardComponents","defineClickComponents","defineUiComponents","definePageComponents","defineTimelineComponents","defineGestureComponents","defineSvgComponents","defineWebglComponents","defineDepthComponents","defineLayoutComponents","definePacksComponents","canDefine","adoptVariants"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;AAmBG;AA8CH,MAAM,WAAW,GAA0C;AACzD,IAAA,MAAM,EAAEA,wCAAsB;AAC9B,IAAA,IAAI,EAAEC,oCAAoB;AAC1B,IAAA,WAAW,EAAEC,kDAA2B;AACxC,IAAA,QAAQ,EAAEC,4CAAwB;AAClC,IAAA,UAAU,EAAEC,gDAA0B;AACtC,IAAA,WAAW,EAAEC,iDAA0B;AACvC,IAAA,OAAO,EAAEC,0CAAuB;AAChC,IAAA,KAAK,EAAEC,qCAAoB;AAC3B,IAAA,KAAK,EAAEC,sCAAqB;AAC5B,IAAA,EAA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