motionwind-vanilla 2.1.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.
@@ -0,0 +1,25 @@
1
+ // src/adapter.ts
2
+ import { defineMotionwindAdapter } from "motionwind-core";
3
+ var VANILLA_CAPABILITIES = {
4
+ gestures: true,
5
+ scroll: true,
6
+ layout: false,
7
+ drag: false,
8
+ variants: true,
9
+ svg: true,
10
+ "reduced-motion": true
11
+ };
12
+ var vanillaAdapter = defineMotionwindAdapter({
13
+ name: "motionwind-vanilla",
14
+ version: "2.0.0",
15
+ capabilities: VANILLA_CAPABILITIES,
16
+ compile(parsed) {
17
+ return parsed;
18
+ }
19
+ });
20
+
21
+ export {
22
+ VANILLA_CAPABILITIES,
23
+ vanillaAdapter
24
+ };
25
+ //# sourceMappingURL=chunk-PXUTG4VI.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/adapter.ts"],"sourcesContent":["import { defineMotionwindAdapter } from \"motionwind-core\";\n\nexport const VANILLA_CAPABILITIES = {\n gestures: true,\n scroll: true,\n layout: false,\n drag: false,\n variants: true,\n svg: true,\n \"reduced-motion\": true,\n} as const;\n\nexport const vanillaAdapter = defineMotionwindAdapter({\n name: \"motionwind-vanilla\",\n version: \"2.0.0\",\n capabilities: VANILLA_CAPABILITIES,\n compile(parsed) {\n return parsed;\n },\n});\n"],"mappings":";AAAA,SAAS,+BAA+B;AAEjC,IAAM,uBAAuB;AAAA,EAClC,UAAU;AAAA,EACV,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,UAAU;AAAA,EACV,KAAK;AAAA,EACL,kBAAkB;AACpB;AAEO,IAAM,iBAAiB,wBAAwB;AAAA,EACpD,MAAM;AAAA,EACN,SAAS;AAAA,EACT,cAAc;AAAA,EACd,QAAQ,QAAQ;AACd,WAAO;AAAA,EACT;AACF,CAAC;","names":[]}
package/dist/index.cjs ADDED
@@ -0,0 +1,317 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var src_exports = {};
22
+ __export(src_exports, {
23
+ MOTIONWIND_RECIPES: () => import_motionwind_core3.MOTIONWIND_RECIPES,
24
+ VANILLA_CAPABILITIES: () => VANILLA_CAPABILITIES,
25
+ defineConfig: () => import_motionwind_core3.defineConfig,
26
+ defineMotionwindPlugin: () => import_motionwind_core3.defineMotionwindPlugin,
27
+ definePreset: () => import_motionwind_core3.definePreset,
28
+ motionwind: () => motionwind,
29
+ parseMotionClasses: () => import_motionwind_core3.parseMotionClasses,
30
+ vanillaAdapter: () => vanillaAdapter
31
+ });
32
+ module.exports = __toCommonJS(src_exports);
33
+ var import_motion = require("motion");
34
+ var import_motionwind_core2 = require("motionwind-core");
35
+
36
+ // src/map.ts
37
+ var RESET_DEFAULTS = {
38
+ scale: 1,
39
+ scaleX: 1,
40
+ scaleY: 1,
41
+ opacity: 1,
42
+ x: 0,
43
+ y: 0,
44
+ z: 0,
45
+ rotate: 0,
46
+ rotateX: 0,
47
+ rotateY: 0,
48
+ skewX: 0,
49
+ skewY: 0
50
+ };
51
+ var OPTION_KEYS = [
52
+ "duration",
53
+ "delay",
54
+ "ease",
55
+ "type",
56
+ "stiffness",
57
+ "damping",
58
+ "mass",
59
+ "bounce",
60
+ "repeat",
61
+ "repeatType",
62
+ "repeatDelay",
63
+ "times"
64
+ ];
65
+ function toAnimateOptions(transition) {
66
+ const opts = {};
67
+ for (const key of OPTION_KEYS) {
68
+ if (transition[key] !== void 0) opts[key] = transition[key];
69
+ }
70
+ return opts;
71
+ }
72
+ function baseValues(parsed) {
73
+ const keys = /* @__PURE__ */ new Set();
74
+ for (const g of [
75
+ parsed.gestures.whileHover,
76
+ parsed.gestures.whileTap,
77
+ parsed.gestures.whileFocus,
78
+ parsed.gestures.whileInView
79
+ ]) {
80
+ if (g) Object.keys(g).forEach((k) => keys.add(k));
81
+ }
82
+ const base = {};
83
+ const enter = parsed.gestures.animate;
84
+ const initial = parsed.gestures.initial;
85
+ for (const k of keys) {
86
+ const v = enter?.[k] ?? initial?.[k] ?? RESET_DEFAULTS[k] ?? 0;
87
+ base[k] = v;
88
+ }
89
+ return base;
90
+ }
91
+ function subset(values, shape) {
92
+ const out = {};
93
+ for (const k of Object.keys(shape)) {
94
+ if (values[k] !== void 0) out[k] = values[k];
95
+ }
96
+ return out;
97
+ }
98
+ function interactiveValues(parsed, state) {
99
+ return {
100
+ ...baseValues(parsed),
101
+ ...state.focused ? parsed.gestures.whileFocus : void 0,
102
+ ...state.hovered ? parsed.gestures.whileHover : void 0,
103
+ ...state.pressed ? parsed.gestures.whileTap : void 0
104
+ };
105
+ }
106
+
107
+ // src/adapter.ts
108
+ var import_motionwind_core = require("motionwind-core");
109
+ var VANILLA_CAPABILITIES = {
110
+ gestures: true,
111
+ scroll: true,
112
+ layout: false,
113
+ drag: false,
114
+ variants: true,
115
+ svg: true,
116
+ "reduced-motion": true
117
+ };
118
+ var vanillaAdapter = (0, import_motionwind_core.defineMotionwindAdapter)({
119
+ name: "motionwind-vanilla",
120
+ version: "2.0.0",
121
+ capabilities: VANILLA_CAPABILITIES,
122
+ compile(parsed) {
123
+ return parsed;
124
+ }
125
+ });
126
+
127
+ // src/index.ts
128
+ var import_motionwind_core3 = require("motionwind-core");
129
+ var anim = import_motion.animate;
130
+ function prefersReducedMotion() {
131
+ return typeof window !== "undefined" && typeof window.matchMedia === "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
132
+ }
133
+ function resolveGestures(parsed) {
134
+ const { variants, variantState, gestures } = parsed;
135
+ const hasVariants = Object.keys(variants).length > 0;
136
+ return {
137
+ initial: (hasVariants && variantState.initial ? variants[variantState.initial] : void 0) ?? gestures.initial,
138
+ animate: (hasVariants && variantState.animate ? variants[variantState.animate] : void 0) ?? gestures.animate,
139
+ exit: (hasVariants && variantState.exit ? variants[variantState.exit] : void 0) ?? gestures.exit
140
+ };
141
+ }
142
+ function wireElement(el, parsed, reduce) {
143
+ const opts = toAnimateOptions(parsed.transition);
144
+ const base = baseValues(parsed);
145
+ const cleanups = [];
146
+ const resolved = resolveGestures(parsed);
147
+ const whileHover = parsed.gestures.whileHover;
148
+ const whileTap = parsed.gestures.whileTap;
149
+ const whileFocus = parsed.gestures.whileFocus;
150
+ let hovered = false;
151
+ let pressed = false;
152
+ let focused = false;
153
+ const updateInteractive = () => {
154
+ const target = interactiveValues(parsed, { focused, hovered, pressed });
155
+ if (Object.keys(target).length > 0) anim(el, target, opts);
156
+ };
157
+ if (parsed.tailwindClasses) {
158
+ el.setAttribute("class", parsed.tailwindClasses);
159
+ } else {
160
+ el.removeAttribute("class");
161
+ }
162
+ if (reduce) {
163
+ const rest = {
164
+ ...resolved.animate ?? {},
165
+ ...parsed.gestures.whileInView ?? {}
166
+ };
167
+ if (Object.keys(rest).length > 0) anim(el, rest, { duration: 0 });
168
+ return () => {
169
+ };
170
+ }
171
+ if (resolved.initial) anim(el, resolved.initial, { duration: 0 });
172
+ if (resolved.animate) anim(el, resolved.animate, opts);
173
+ const exitValues = resolved.exit;
174
+ if (exitValues && Object.keys(exitValues).length > 0) {
175
+ const handleRemove = () => {
176
+ anim(el, exitValues, {
177
+ ...opts,
178
+ onComplete: () => el.remove()
179
+ });
180
+ };
181
+ el.addEventListener("motionwind:remove", handleRemove);
182
+ cleanups.push(
183
+ () => el.removeEventListener(
184
+ "motionwind:remove",
185
+ handleRemove
186
+ )
187
+ );
188
+ }
189
+ if (whileHover) {
190
+ cleanups.push(
191
+ (0, import_motion.hover)(el, () => {
192
+ hovered = true;
193
+ updateInteractive();
194
+ return () => {
195
+ hovered = false;
196
+ updateInteractive();
197
+ };
198
+ })
199
+ );
200
+ }
201
+ if (whileTap) {
202
+ cleanups.push(
203
+ (0, import_motion.press)(el, () => {
204
+ pressed = true;
205
+ updateInteractive();
206
+ return () => {
207
+ pressed = false;
208
+ updateInteractive();
209
+ };
210
+ })
211
+ );
212
+ }
213
+ if (whileFocus) {
214
+ const onFocus = () => {
215
+ focused = true;
216
+ updateInteractive();
217
+ };
218
+ const onBlur = () => {
219
+ focused = false;
220
+ updateInteractive();
221
+ };
222
+ el.addEventListener("focus", onFocus);
223
+ el.addEventListener("blur", onBlur);
224
+ cleanups.push(() => {
225
+ el.removeEventListener("focus", onFocus);
226
+ el.removeEventListener("blur", onBlur);
227
+ });
228
+ }
229
+ const whileInView = parsed.gestures.whileInView;
230
+ if (whileInView) {
231
+ const viewportOpts = {};
232
+ if (parsed.viewport.amount !== void 0)
233
+ viewportOpts.amount = parsed.viewport.amount;
234
+ if (parsed.viewport.margin !== void 0)
235
+ viewportOpts.margin = parsed.viewport.margin;
236
+ cleanups.push(
237
+ (0, import_motion.inView)(
238
+ el,
239
+ () => {
240
+ anim(el, whileInView, opts);
241
+ if (parsed.viewport.once) return;
242
+ return () => anim(el, subset(base, whileInView), opts);
243
+ },
244
+ viewportOpts
245
+ )
246
+ );
247
+ }
248
+ if (Object.keys(parsed.scroll.values).length > 0) {
249
+ const scrollOpts = parsed.scroll.container ? { axis: parsed.scroll.axis } : { target: el, axis: parsed.scroll.axis, offset: parsed.scroll.offset };
250
+ const stop = (0, import_motion.scroll)(
251
+ anim(el, parsed.scroll.values, { ease: "linear" }),
252
+ scrollOpts
253
+ );
254
+ if (typeof stop === "function") cleanups.push(stop);
255
+ }
256
+ return () => cleanups.forEach((fn) => fn());
257
+ }
258
+ function motionwind(options = {}) {
259
+ const root = options.root ?? (typeof document !== "undefined" ? document : null);
260
+ if (!root) return () => {
261
+ };
262
+ const selector = options.selector ?? '[class*="animate-"]';
263
+ const reduce = (options.respectReducedMotion ?? true) && prefersReducedMotion();
264
+ const cleanups = [];
265
+ const wire = (el) => {
266
+ try {
267
+ const parsed = (0, import_motionwind_core2.parseMotionClasses)(
268
+ el.getAttribute("class") ?? "",
269
+ options.config
270
+ );
271
+ const unsupported = (0, import_motionwind_core2.unsupportedCapabilities)(parsed, VANILLA_CAPABILITIES);
272
+ if (unsupported.length && typeof console !== "undefined") {
273
+ console.warn(
274
+ `[motionwind-vanilla] Unsupported capabilities: ${unsupported.join(", ")}.`,
275
+ el
276
+ );
277
+ }
278
+ if (parsed.hasMotion) cleanups.push(wireElement(el, parsed, reduce));
279
+ } catch (err) {
280
+ if (typeof console !== "undefined") {
281
+ console.warn(
282
+ "[motionwind-vanilla] failed to animate an element; skipping it.",
283
+ el,
284
+ err
285
+ );
286
+ }
287
+ }
288
+ };
289
+ root.querySelectorAll(selector).forEach(wire);
290
+ if (options.observe && typeof MutationObserver !== "undefined") {
291
+ const target = root instanceof Document ? root.body ?? root.documentElement : root;
292
+ const observer = new MutationObserver((mutations) => {
293
+ for (const m of mutations) {
294
+ m.addedNodes.forEach((node) => {
295
+ if (!(node instanceof Element)) return;
296
+ if (node.matches(selector)) wire(node);
297
+ node.querySelectorAll(selector).forEach(wire);
298
+ });
299
+ }
300
+ });
301
+ observer.observe(target, { childList: true, subtree: true });
302
+ cleanups.push(() => observer.disconnect());
303
+ }
304
+ return () => cleanups.forEach((fn) => fn());
305
+ }
306
+ // Annotate the CommonJS export names for ESM import in node:
307
+ 0 && (module.exports = {
308
+ MOTIONWIND_RECIPES,
309
+ VANILLA_CAPABILITIES,
310
+ defineConfig,
311
+ defineMotionwindPlugin,
312
+ definePreset,
313
+ motionwind,
314
+ parseMotionClasses,
315
+ vanillaAdapter
316
+ });
317
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts","../src/map.ts","../src/adapter.ts"],"sourcesContent":["import { animate, hover, press, inView, scroll } from \"motion\";\nimport {\n parseMotionClasses,\n unsupportedCapabilities,\n type MotionwindConfig,\n type ParsedResult,\n type AnimatableValues,\n} from \"motionwind-core\";\nimport {\n toAnimateOptions,\n baseValues,\n interactiveValues,\n subset,\n} from \"./map.js\";\nimport { VANILLA_CAPABILITIES } from \"./adapter.js\";\n\nexport { vanillaAdapter, VANILLA_CAPABILITIES } from \"./adapter.js\";\n\nexport interface MotionwindOptions {\n /** Where to scan for motion elements. Defaults to `document`. */\n root?: ParentNode;\n /** Selector for candidate elements. Defaults to `[class*=\"animate-\"]`. */\n selector?: string;\n /** Honor `prefers-reduced-motion` (jump to final state, no motion). Default true. */\n respectReducedMotion?: boolean;\n /** Watch the DOM and wire elements added after init (SPA/HTMX). Default false. */\n observe?: boolean;\n /** Project tokens, presets, plugins, and strictness. */\n config?: MotionwindConfig;\n}\n\nconst anim = animate as any;\n\nfunction prefersReducedMotion(): boolean {\n return (\n typeof window !== \"undefined\" &&\n typeof window.matchMedia === \"function\" &&\n window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches\n );\n}\n\n/**\n * Resolve the initial/animate/exit gesture values for an element, preferring\n * named-variant values from `parsed.variants` when `parsed.variantState`\n * references them, and falling back to the inline gesture values otherwise.\n */\nfunction resolveGestures(parsed: ParsedResult): {\n initial?: AnimatableValues;\n animate?: AnimatableValues;\n exit?: AnimatableValues;\n} {\n const { variants, variantState, gestures } = parsed;\n const hasVariants = Object.keys(variants).length > 0;\n return {\n initial:\n (hasVariants && variantState.initial\n ? variants[variantState.initial]\n : undefined) ?? gestures.initial,\n animate:\n (hasVariants && variantState.animate\n ? variants[variantState.animate]\n : undefined) ?? gestures.animate,\n exit:\n (hasVariants && variantState.exit\n ? variants[variantState.exit]\n : undefined) ?? gestures.exit,\n };\n}\n\n/** Wire a single element's gestures/enter/scroll animations. Returns cleanup. */\nfunction wireElement(\n el: Element,\n parsed: ParsedResult,\n reduce: boolean,\n): () => void {\n const opts = toAnimateOptions(parsed.transition);\n const base = baseValues(parsed);\n const cleanups: Array<() => void> = [];\n const resolved = resolveGestures(parsed);\n const whileHover = parsed.gestures.whileHover;\n const whileTap = parsed.gestures.whileTap;\n const whileFocus = parsed.gestures.whileFocus;\n let hovered = false;\n let pressed = false;\n let focused = false;\n const updateInteractive = () => {\n const target = interactiveValues(parsed, { focused, hovered, pressed });\n if (Object.keys(target).length > 0) anim(el, target, opts);\n };\n\n // Strip animate-* classes; keep the passthrough (Tailwind/util) classes. This\n // also makes re-scans idempotent — a wired element no longer matches the\n // `animate-*` selector.\n if (parsed.tailwindClasses) {\n el.setAttribute(\"class\", parsed.tailwindClasses);\n } else {\n el.removeAttribute(\"class\");\n }\n\n // Reduced motion: jump straight to the final resting/visible state with no\n // animation, and skip all interactive + scroll wiring.\n if (reduce) {\n const rest = {\n ...(resolved.animate ?? {}),\n ...(parsed.gestures.whileInView ?? {}),\n };\n if (Object.keys(rest).length > 0) anim(el, rest, { duration: 0 });\n return () => {};\n }\n\n // Initial state (applied instantly), then enter animation.\n // Use resolved values so that named variants are applied correctly.\n if (resolved.initial) anim(el, resolved.initial, { duration: 0 });\n if (resolved.animate) anim(el, resolved.animate, opts);\n\n // Exit animation: when a consumer dispatches a custom \"motionwind:remove\"\n // event on the element, we play the exit keyframes and remove it afterwards.\n const exitValues = resolved.exit;\n if (exitValues && Object.keys(exitValues).length > 0) {\n const handleRemove = () => {\n anim(el, exitValues, {\n ...opts,\n onComplete: () => el.remove(),\n });\n };\n el.addEventListener(\"motionwind:remove\", handleRemove as EventListener);\n cleanups.push(() =>\n el.removeEventListener(\n \"motionwind:remove\",\n handleRemove as EventListener,\n ),\n );\n }\n\n // Hover\n if (whileHover) {\n cleanups.push(\n hover(el, () => {\n hovered = true;\n updateInteractive();\n return () => {\n hovered = false;\n updateInteractive();\n };\n }),\n );\n }\n\n // Tap / press\n if (whileTap) {\n cleanups.push(\n press(el, () => {\n pressed = true;\n updateInteractive();\n return () => {\n pressed = false;\n updateInteractive();\n };\n }),\n );\n }\n\n // Focus\n if (whileFocus) {\n const onFocus = () => {\n focused = true;\n updateInteractive();\n };\n const onBlur = () => {\n focused = false;\n updateInteractive();\n };\n el.addEventListener(\"focus\", onFocus);\n el.addEventListener(\"blur\", onBlur);\n cleanups.push(() => {\n el.removeEventListener(\"focus\", onFocus);\n el.removeEventListener(\"blur\", onBlur);\n });\n }\n\n // In view\n const whileInView = parsed.gestures.whileInView;\n if (whileInView) {\n const viewportOpts: Record<string, unknown> = {};\n if (parsed.viewport.amount !== undefined)\n viewportOpts.amount = parsed.viewport.amount;\n if (parsed.viewport.margin !== undefined)\n viewportOpts.margin = parsed.viewport.margin;\n cleanups.push(\n inView(\n el,\n () => {\n anim(el, whileInView, opts);\n if (parsed.viewport.once) return;\n return () => anim(el, subset(base, whileInView), opts);\n },\n viewportOpts,\n ),\n );\n }\n\n // Scroll-linked: drive style values from scroll progress.\n if (Object.keys(parsed.scroll.values).length > 0) {\n // Motion's ScrollOptions.offset is a strict string union; our offset is\n // user-provided, so cast the options bag.\n const scrollOpts: any = parsed.scroll.container\n ? { axis: parsed.scroll.axis }\n : { target: el, axis: parsed.scroll.axis, offset: parsed.scroll.offset };\n const stop = scroll(\n anim(el, parsed.scroll.values, { ease: \"linear\" }),\n scrollOpts,\n );\n if (typeof stop === \"function\") cleanups.push(stop);\n }\n\n return () => cleanups.forEach((fn) => fn());\n}\n\n/**\n * Scan the DOM for elements with `animate-*` classes and wire up their\n * animations using the vanilla Motion API. Returns a cleanup function.\n *\n * Supports: initial/enter, hover, tap, focus, in-view, scroll-linked, named\n * variants (resolved at wire-up time), and exit animations (triggered by\n * dispatching a `\"motionwind:remove\"` custom event on the element).\n * Honors `prefers-reduced-motion`, is idempotent across re-runs, and can watch\n * for dynamically-added elements via `{ observe: true }`.\n * (drag and layout are React/Vue-only.)\n *\n * @example\n * ```js\n * import { motionwind } from \"motionwind-vanilla\";\n * const stop = motionwind({ observe: true });\n * ```\n */\nexport function motionwind(options: MotionwindOptions = {}): () => void {\n const root =\n options.root ?? (typeof document !== \"undefined\" ? document : null);\n if (!root) return () => {};\n\n const selector = options.selector ?? '[class*=\"animate-\"]';\n const reduce =\n (options.respectReducedMotion ?? true) && prefersReducedMotion();\n const cleanups: Array<() => void> = [];\n\n const wire = (el: Element) => {\n try {\n // SVGElement.className is SVGAnimatedString rather than a string, so the\n // attribute is the portable source for both HTML and SVG elements.\n const parsed = parseMotionClasses(\n el.getAttribute(\"class\") ?? \"\",\n options.config,\n );\n const unsupported = unsupportedCapabilities(parsed, VANILLA_CAPABILITIES);\n if (unsupported.length && typeof console !== \"undefined\") {\n console.warn(\n `[motionwind-vanilla] Unsupported capabilities: ${unsupported.join(\", \")}.`,\n el,\n );\n }\n if (parsed.hasMotion) cleanups.push(wireElement(el, parsed, reduce));\n } catch (err) {\n // A single malformed element/class must never break the whole page.\n if (typeof console !== \"undefined\") {\n console.warn(\n \"[motionwind-vanilla] failed to animate an element; skipping it.\",\n el,\n err,\n );\n }\n }\n };\n\n root.querySelectorAll<Element>(selector).forEach(wire);\n\n if (options.observe && typeof MutationObserver !== \"undefined\") {\n const target =\n root instanceof Document ? (root.body ?? root.documentElement) : root;\n const observer = new MutationObserver((mutations) => {\n for (const m of mutations) {\n m.addedNodes.forEach((node) => {\n if (!(node instanceof Element)) return;\n if (node.matches(selector)) wire(node);\n node.querySelectorAll<Element>(selector).forEach(wire);\n });\n }\n });\n observer.observe(target as Node, { childList: true, subtree: true });\n cleanups.push(() => observer.disconnect());\n }\n\n return () => cleanups.forEach((fn) => fn());\n}\n\nexport {\n parseMotionClasses,\n defineConfig,\n definePreset,\n defineMotionwindPlugin,\n MOTIONWIND_RECIPES,\n} from \"motionwind-core\";\nexport type { ParsedResult, MotionwindConfig } from \"motionwind-core\";\n","import type {\n AnimatableValues,\n ParsedResult,\n TransitionConfig,\n} from \"motionwind-core\";\n\n/** Resting values used to animate back after a gesture ends. */\nconst RESET_DEFAULTS: Record<string, number | string> = {\n scale: 1,\n scaleX: 1,\n scaleY: 1,\n opacity: 1,\n x: 0,\n y: 0,\n z: 0,\n rotate: 0,\n rotateX: 0,\n rotateY: 0,\n skewX: 0,\n skewY: 0,\n};\n\n/** Transition keys that apply to a single vanilla `animate()` call. */\nconst OPTION_KEYS: (keyof TransitionConfig)[] = [\n \"duration\",\n \"delay\",\n \"ease\",\n \"type\",\n \"stiffness\",\n \"damping\",\n \"mass\",\n \"bounce\",\n \"repeat\",\n \"repeatType\",\n \"repeatDelay\",\n \"times\",\n];\n\n/** Project our TransitionConfig onto vanilla Motion's animate() options. */\nexport function toAnimateOptions(\n transition: TransitionConfig,\n): Record<string, unknown> {\n const opts: Record<string, unknown> = {};\n for (const key of OPTION_KEYS) {\n if (transition[key] !== undefined) opts[key] = transition[key];\n }\n return opts;\n}\n\n/**\n * Build the resting values to animate back to when a gesture (hover/tap/focus)\n * ends. Prefers the enter (`animate`) value, then `initial`, then a sensible\n * default, for each key the gestures touch.\n */\nexport function baseValues(parsed: ParsedResult): AnimatableValues {\n const keys = new Set<string>();\n for (const g of [\n parsed.gestures.whileHover,\n parsed.gestures.whileTap,\n parsed.gestures.whileFocus,\n parsed.gestures.whileInView,\n ]) {\n if (g) Object.keys(g).forEach((k) => keys.add(k));\n }\n\n const base: AnimatableValues = {};\n const enter = parsed.gestures.animate;\n const initial = parsed.gestures.initial;\n for (const k of keys) {\n const v =\n (enter as Record<string, AnimatableValues[string]> | undefined)?.[k] ??\n (initial as Record<string, AnimatableValues[string]> | undefined)?.[k] ??\n RESET_DEFAULTS[k] ??\n 0;\n base[k] = v;\n }\n return base;\n}\n\n/** Pick a subset of `values` limited to the keys present in `shape`. */\nexport function subset(\n values: AnimatableValues,\n shape: AnimatableValues,\n): AnimatableValues {\n const out: AnimatableValues = {};\n for (const k of Object.keys(shape)) {\n if (values[k] !== undefined) out[k] = values[k]!;\n }\n return out;\n}\n\n/** Merge concurrent gesture states using Motion's interaction priority. */\nexport function interactiveValues(\n parsed: ParsedResult,\n state: { focused: boolean; hovered: boolean; pressed: boolean },\n): AnimatableValues {\n return {\n ...baseValues(parsed),\n ...(state.focused ? parsed.gestures.whileFocus : undefined),\n ...(state.hovered ? parsed.gestures.whileHover : undefined),\n ...(state.pressed ? parsed.gestures.whileTap : undefined),\n };\n}\n","import { defineMotionwindAdapter } from \"motionwind-core\";\n\nexport const VANILLA_CAPABILITIES = {\n gestures: true,\n scroll: true,\n layout: false,\n drag: false,\n variants: true,\n svg: true,\n \"reduced-motion\": true,\n} as const;\n\nexport const vanillaAdapter = defineMotionwindAdapter({\n name: \"motionwind-vanilla\",\n version: \"2.0.0\",\n capabilities: VANILLA_CAPABILITIES,\n compile(parsed) {\n return parsed;\n },\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAsD;AACtD,IAAAA,0BAMO;;;ACAP,IAAM,iBAAkD;AAAA,EACtD,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,SAAS;AAAA,EACT,OAAO;AAAA,EACP,OAAO;AACT;AAGA,IAAM,cAA0C;AAAA,EAC9C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAGO,SAAS,iBACd,YACyB;AACzB,QAAM,OAAgC,CAAC;AACvC,aAAW,OAAO,aAAa;AAC7B,QAAI,WAAW,GAAG,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core';
2
+ export { MOTIONWIND_RECIPES, MotionwindConfig, ParsedResult, defineConfig, defineMotionwindPlugin, definePreset, parseMotionClasses } from 'motionwind-core';
3
+ export { VANILLA_CAPABILITIES, vanillaAdapter } from './adapter.cjs';
4
+
5
+ interface MotionwindOptions {
6
+ /** Where to scan for motion elements. Defaults to `document`. */
7
+ root?: ParentNode;
8
+ /** Selector for candidate elements. Defaults to `[class*="animate-"]`. */
9
+ selector?: string;
10
+ /** Honor `prefers-reduced-motion` (jump to final state, no motion). Default true. */
11
+ respectReducedMotion?: boolean;
12
+ /** Watch the DOM and wire elements added after init (SPA/HTMX). Default false. */
13
+ observe?: boolean;
14
+ /** Project tokens, presets, plugins, and strictness. */
15
+ config?: MotionwindConfig;
16
+ }
17
+ /**
18
+ * Scan the DOM for elements with `animate-*` classes and wire up their
19
+ * animations using the vanilla Motion API. Returns a cleanup function.
20
+ *
21
+ * Supports: initial/enter, hover, tap, focus, in-view, scroll-linked, named
22
+ * variants (resolved at wire-up time), and exit animations (triggered by
23
+ * dispatching a `"motionwind:remove"` custom event on the element).
24
+ * Honors `prefers-reduced-motion`, is idempotent across re-runs, and can watch
25
+ * for dynamically-added elements via `{ observe: true }`.
26
+ * (drag and layout are React/Vue-only.)
27
+ *
28
+ * @example
29
+ * ```js
30
+ * import { motionwind } from "motionwind-vanilla";
31
+ * const stop = motionwind({ observe: true });
32
+ * ```
33
+ */
34
+ declare function motionwind(options?: MotionwindOptions): () => void;
35
+
36
+ export { type MotionwindOptions, motionwind };
@@ -0,0 +1,36 @@
1
+ import { MotionwindConfig } from 'motionwind-core';
2
+ export { MOTIONWIND_RECIPES, MotionwindConfig, ParsedResult, defineConfig, defineMotionwindPlugin, definePreset, parseMotionClasses } from 'motionwind-core';
3
+ export { VANILLA_CAPABILITIES, vanillaAdapter } from './adapter.js';
4
+
5
+ interface MotionwindOptions {
6
+ /** Where to scan for motion elements. Defaults to `document`. */
7
+ root?: ParentNode;
8
+ /** Selector for candidate elements. Defaults to `[class*="animate-"]`. */
9
+ selector?: string;
10
+ /** Honor `prefers-reduced-motion` (jump to final state, no motion). Default true. */
11
+ respectReducedMotion?: boolean;
12
+ /** Watch the DOM and wire elements added after init (SPA/HTMX). Default false. */
13
+ observe?: boolean;
14
+ /** Project tokens, presets, plugins, and strictness. */
15
+ config?: MotionwindConfig;
16
+ }
17
+ /**
18
+ * Scan the DOM for elements with `animate-*` classes and wire up their
19
+ * animations using the vanilla Motion API. Returns a cleanup function.
20
+ *
21
+ * Supports: initial/enter, hover, tap, focus, in-view, scroll-linked, named
22
+ * variants (resolved at wire-up time), and exit animations (triggered by
23
+ * dispatching a `"motionwind:remove"` custom event on the element).
24
+ * Honors `prefers-reduced-motion`, is idempotent across re-runs, and can watch
25
+ * for dynamically-added elements via `{ observe: true }`.
26
+ * (drag and layout are React/Vue-only.)
27
+ *
28
+ * @example
29
+ * ```js
30
+ * import { motionwind } from "motionwind-vanilla";
31
+ * const stop = motionwind({ observe: true });
32
+ * ```
33
+ */
34
+ declare function motionwind(options?: MotionwindOptions): () => void;
35
+
36
+ export { type MotionwindOptions, motionwind };