@vdragon/vui-animate 0.0.0-stage → 0.0.1

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,92 @@
1
+ /**
2
+ * vUI - Free & Open-Source Tailwind UI vComponents
3
+ * Plugin: @vdragon/vui-animate
4
+ */
5
+ import { VComponent } from '@vdragon/vui/core';
6
+ import type { VPluginInterface } from '@vdragon/vui/core';
7
+ export type VAnimateTrigger = 'mount' | 'visible' | 'click' | 'hover' | 'manual';
8
+ export interface VAnimateConfig {
9
+ /** Animation name (e.g. 'fade-up' or 'v-anim-fade-up') */
10
+ animation?: string;
11
+ /** When to trigger animation automatically */
12
+ trigger?: VAnimateTrigger;
13
+ /** Optional selector or element to animate instead of the host element */
14
+ target?: string | HTMLElement | null;
15
+ /** CSS --v-anim-duration (e.g. '450ms', '0.6s', or number in ms) */
16
+ duration?: string | number;
17
+ /** CSS --v-anim-delay (e.g. '120ms', or number in ms) */
18
+ delay?: string | number;
19
+ /** Easing preset ('smooth' | 'spring' | 'snappy') or custom CSS timing function */
20
+ easing?: string;
21
+ /** CSS --v-anim-distance (e.g. '24px', or number in px) */
22
+ distance?: string | number;
23
+ /** CSS --v-anim-scale (e.g. 0.92) */
24
+ scale?: string | number;
25
+ /** CSS --v-anim-blur (e.g. '12px', or number in px) */
26
+ blur?: string | number;
27
+ /** CSS --v-anim-iterations (e.g. 1, 2, 'infinite') */
28
+ iterations?: string | number;
29
+ /** CSS --v-anim-accent color */
30
+ accent?: string;
31
+ /** For 'visible' trigger: only animate once when entering viewport */
32
+ once?: boolean;
33
+ /** For 'visible' trigger: IntersectionObserver threshold (0..1) */
34
+ threshold?: number;
35
+ /** Remove the animation class automatically after animationend */
36
+ cleanup?: boolean;
37
+ }
38
+ export interface VAnimateStaggerOptions extends VAnimateConfig {
39
+ /** Delay increment between consecutive items in ms (default: 70) */
40
+ step?: number;
41
+ /** Initial delay for the first item in ms (default: 0) */
42
+ startDelay?: number;
43
+ }
44
+ export interface VAnimateEventPayload {
45
+ element: HTMLElement;
46
+ target: HTMLElement;
47
+ animation: string;
48
+ className: string;
49
+ cancel?: boolean;
50
+ }
51
+ export declare class VAnimate extends VComponent {
52
+ protected _name: string;
53
+ protected _defaultConfig: VAnimateConfig;
54
+ protected _targetElement: HTMLElement | null;
55
+ protected _activeClass: string;
56
+ protected _observer: IntersectionObserver | null;
57
+ protected _pendingEndHandler: ((event: AnimationEvent) => void) | null;
58
+ protected _pendingResolve: ((el: HTMLElement | null) => void) | null;
59
+ constructor(element: HTMLElement, config?: VAnimateConfig);
60
+ protected _resolveTargetElement(): HTMLElement | null;
61
+ protected _applyCssVars(overrides?: Partial<VAnimateConfig>): void;
62
+ protected _bindTrigger(): void;
63
+ protected _observeVisibility(): void;
64
+ protected _clearPendingEnd(resolveResult?: HTMLElement | null): void;
65
+ getTargetElement(): HTMLElement | null;
66
+ setAnimation(animation: string): this;
67
+ play(animation?: string, options?: Partial<VAnimateConfig>): Promise<HTMLElement | null>;
68
+ replay(animation?: string, options?: Partial<VAnimateConfig>): Promise<HTMLElement | null>;
69
+ pause(): this;
70
+ resume(): this;
71
+ stop(): this;
72
+ dispose(): void;
73
+ static getInstance(element: HTMLElement | string | null): VAnimate | null;
74
+ static getOrCreateInstance(element: HTMLElement | string | null, config?: VAnimateConfig): VAnimate | null;
75
+ static createInstances(root?: ParentNode): void;
76
+ static init(): void;
77
+ /**
78
+ * Dynamically attach VAnimate to any element or selector at runtime.
79
+ */
80
+ static add(element: HTMLElement | string | null, animation: string, options?: VAnimateConfig): VAnimate | null;
81
+ /**
82
+ * One-liner to dynamically play/replay an animation on any element or selector.
83
+ */
84
+ static play(element: HTMLElement | string | null, animation: string, options?: VAnimateConfig): Promise<HTMLElement | null>;
85
+ /**
86
+ * Dynamically animate a list of elements or a container's direct children with stagger delay.
87
+ */
88
+ static stagger(elementsOrSelector: HTMLElement | NodeListOf<HTMLElement> | HTMLElement[] | string, animation: string, options?: VAnimateStaggerOptions): Promise<Array<HTMLElement | null>>;
89
+ }
90
+ export declare const vAnimatePlugin: VPluginInterface;
91
+ export default VAnimate;
92
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,431 @@
1
+ /*! vUI - Free & Open-Source Tailwind UI vComponents | @vdragon/vui-animate v0.0.1 | MIT License */
2
+ "use strict";
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+
21
+ // src/index.ts
22
+ var index_exports = {};
23
+ __export(index_exports, {
24
+ VAnimate: () => VAnimate,
25
+ default: () => index_default,
26
+ vAnimatePlugin: () => vAnimatePlugin
27
+ });
28
+ module.exports = __toCommonJS(index_exports);
29
+ var import_core = require("@vdragon/vui/core");
30
+ var EASING_PRESETS = {
31
+ smooth: "var(--v-anim-ease-smooth)",
32
+ spring: "var(--v-anim-ease-spring)",
33
+ snappy: "var(--v-anim-ease-snappy)"
34
+ };
35
+ var CSS_VAR_MAP = [
36
+ ["duration", "--v-anim-duration", "ms"],
37
+ ["delay", "--v-anim-delay", "ms"],
38
+ ["distance", "--v-anim-distance", "px"],
39
+ ["scale", "--v-anim-scale", ""],
40
+ ["blur", "--v-anim-blur", "px"],
41
+ ["iterations", "--v-anim-iterations", ""],
42
+ ["accent", "--v-anim-accent", ""]
43
+ ];
44
+ function normalizeAnimationClass(animation) {
45
+ const raw = String(animation ?? "").trim();
46
+ if (!raw || raw === "true" || raw === "false") {
47
+ return "";
48
+ }
49
+ return raw.startsWith("v-anim-") ? raw : `v-anim-${raw}`;
50
+ }
51
+ function formatCssValue(value, unit) {
52
+ if (value === void 0 || value === null || value === "") {
53
+ return "";
54
+ }
55
+ if (typeof value === "number") {
56
+ return `${value}${unit}`;
57
+ }
58
+ const trimmed = String(value).trim();
59
+ if (unit && /^-?\d+(\.\d+)?$/.test(trimmed)) {
60
+ return `${trimmed}${unit}`;
61
+ }
62
+ return trimmed;
63
+ }
64
+ function toBoolean(value, fallback) {
65
+ if (typeof value === "boolean") return value;
66
+ if (typeof value === "string") {
67
+ const lower = value.trim().toLowerCase();
68
+ if (lower === "true") return true;
69
+ if (lower === "false") return false;
70
+ }
71
+ return fallback;
72
+ }
73
+ function toNumber(value, fallback) {
74
+ const n = Number(value);
75
+ return Number.isFinite(n) ? n : fallback;
76
+ }
77
+ var VAnimate = class _VAnimate extends import_core.VComponent {
78
+ constructor(element, config) {
79
+ super();
80
+ this._name = "animate";
81
+ this._defaultConfig = {
82
+ animation: "",
83
+ trigger: "mount",
84
+ target: null,
85
+ duration: "",
86
+ delay: "",
87
+ easing: "",
88
+ distance: "",
89
+ scale: "",
90
+ blur: "",
91
+ iterations: "",
92
+ accent: "",
93
+ once: true,
94
+ threshold: 0.15,
95
+ cleanup: false
96
+ };
97
+ this._targetElement = null;
98
+ this._activeClass = "";
99
+ this._observer = null;
100
+ this._pendingEndHandler = null;
101
+ this._pendingResolve = null;
102
+ if (!element || this._shouldSkipInit(element)) {
103
+ return;
104
+ }
105
+ this._init(element);
106
+ this._buildConfig(config);
107
+ if (!this._element) {
108
+ return;
109
+ }
110
+ const attrValue = this._element.getAttribute("data-v-animate");
111
+ if (!this._getOption("animation") && attrValue && attrValue !== "true" && attrValue !== "false") {
112
+ this._mergeConfig({ animation: attrValue });
113
+ }
114
+ this._targetElement = this._resolveTargetElement();
115
+ this._applyCssVars();
116
+ this._bindTrigger();
117
+ }
118
+ _resolveTargetElement() {
119
+ const targetOpt = this._getOption("target");
120
+ if (targetOpt instanceof HTMLElement) {
121
+ return targetOpt;
122
+ }
123
+ if (typeof targetOpt === "string" && targetOpt.trim()) {
124
+ return import_core.vDom.getElement(targetOpt.trim());
125
+ }
126
+ return this._element;
127
+ }
128
+ _applyCssVars(overrides) {
129
+ const target = this._targetElement;
130
+ if (!target) return;
131
+ for (const [key, cssVar, unit] of CSS_VAR_MAP) {
132
+ const rawVal = overrides && overrides[key] !== void 0 ? overrides[key] : this._getOption(key);
133
+ const formatted = formatCssValue(rawVal, unit);
134
+ if (formatted) {
135
+ target.style.setProperty(cssVar, formatted);
136
+ }
137
+ }
138
+ const rawEasing = overrides && overrides.easing !== void 0 ? overrides.easing : this._getOption("easing");
139
+ if (rawEasing && String(rawEasing).trim()) {
140
+ const easingKey = String(rawEasing).trim();
141
+ target.style.setProperty(
142
+ "--v-anim-easing",
143
+ EASING_PRESETS[easingKey] ?? easingKey
144
+ );
145
+ }
146
+ }
147
+ _bindTrigger() {
148
+ if (!this._element) return;
149
+ const trigger = String(this._getOption("trigger") || "mount").toLowerCase();
150
+ if (trigger === "mount") {
151
+ void this.play();
152
+ return;
153
+ }
154
+ if (trigger === "click") {
155
+ this._addEventListener(this._element, "click", () => {
156
+ void this.play();
157
+ });
158
+ return;
159
+ }
160
+ if (trigger === "hover") {
161
+ this._addEventListener(this._element, "mouseenter", () => {
162
+ void this.play();
163
+ });
164
+ return;
165
+ }
166
+ if (trigger === "visible") {
167
+ this._observeVisibility();
168
+ }
169
+ }
170
+ _observeVisibility() {
171
+ const host = this._element;
172
+ if (!host) return;
173
+ if (typeof IntersectionObserver === "undefined") {
174
+ void this.play();
175
+ return;
176
+ }
177
+ const threshold = toNumber(this._getOption("threshold"), 0.15);
178
+ const once = toBoolean(this._getOption("once"), true);
179
+ this._observer = new IntersectionObserver(
180
+ (entries) => {
181
+ for (const entry of entries) {
182
+ if (entry.isIntersecting) {
183
+ void this.play();
184
+ if (once && this._observer) {
185
+ this._observer.disconnect();
186
+ this._observer = null;
187
+ }
188
+ }
189
+ }
190
+ },
191
+ { threshold }
192
+ );
193
+ this._observer.observe(host);
194
+ }
195
+ _clearPendingEnd(resolveResult = null) {
196
+ if (this._targetElement && this._pendingEndHandler) {
197
+ this._targetElement.removeEventListener(
198
+ "animationend",
199
+ this._pendingEndHandler
200
+ );
201
+ }
202
+ this._pendingEndHandler = null;
203
+ if (this._pendingResolve) {
204
+ const done = this._pendingResolve;
205
+ this._pendingResolve = null;
206
+ done(resolveResult);
207
+ }
208
+ }
209
+ getTargetElement() {
210
+ return this._targetElement;
211
+ }
212
+ setAnimation(animation) {
213
+ this._mergeConfig({ animation });
214
+ return this;
215
+ }
216
+ play(animation, options) {
217
+ if (!this._element) {
218
+ return Promise.resolve(null);
219
+ }
220
+ if (options) {
221
+ this._mergeConfig(options);
222
+ if (options.target !== void 0) {
223
+ this._targetElement = this._resolveTargetElement();
224
+ }
225
+ }
226
+ const target = this._targetElement ?? this._element;
227
+ if (!target) {
228
+ return Promise.resolve(null);
229
+ }
230
+ const animName = animation !== void 0 ? animation : String(this._getOption("animation") ?? "");
231
+ const className = normalizeAnimationClass(animName);
232
+ if (!className) {
233
+ return Promise.resolve(target);
234
+ }
235
+ if (animation !== void 0) {
236
+ this._mergeConfig({ animation });
237
+ }
238
+ const startPayload = {
239
+ element: this._element,
240
+ target,
241
+ animation: animName,
242
+ className,
243
+ cancel: false
244
+ };
245
+ void this._fireEvent("start", startPayload);
246
+ this._dispatchEvent("v.animate.start", startPayload);
247
+ if (startPayload.cancel === true) {
248
+ return Promise.resolve(target);
249
+ }
250
+ this._clearPendingEnd(target);
251
+ if (this._activeClass) {
252
+ target.classList.remove(this._activeClass);
253
+ }
254
+ target.classList.remove(className, "v-anim-paused");
255
+ this._applyCssVars(options);
256
+ import_core.vDom.reflow(target);
257
+ this._activeClass = className;
258
+ target.classList.add(className);
259
+ const shouldCleanup = toBoolean(
260
+ options?.cleanup ?? this._getOption("cleanup"),
261
+ false
262
+ );
263
+ return new Promise((resolve) => {
264
+ const finish = () => {
265
+ if (shouldCleanup) {
266
+ target.classList.remove(className);
267
+ if (this._activeClass === className) {
268
+ this._activeClass = "";
269
+ }
270
+ }
271
+ const endPayload = {
272
+ element: this._element ?? target,
273
+ target,
274
+ animation: animName,
275
+ className
276
+ };
277
+ void this._fireEvent("end", endPayload);
278
+ this._dispatchEvent("v.animate.end", endPayload);
279
+ resolve(target);
280
+ };
281
+ const onEnd = (event) => {
282
+ if (event.target !== target) return;
283
+ target.removeEventListener("animationend", onEnd);
284
+ this._pendingEndHandler = null;
285
+ this._pendingResolve = null;
286
+ finish();
287
+ };
288
+ this._pendingEndHandler = onEnd;
289
+ this._pendingResolve = resolve;
290
+ target.addEventListener("animationend", onEnd);
291
+ });
292
+ }
293
+ replay(animation, options) {
294
+ return this.play(animation, options);
295
+ }
296
+ pause() {
297
+ this._targetElement?.classList.add("v-anim-paused");
298
+ return this;
299
+ }
300
+ resume() {
301
+ this._targetElement?.classList.remove("v-anim-paused");
302
+ return this;
303
+ }
304
+ stop() {
305
+ this._clearPendingEnd(this._targetElement);
306
+ if (this._targetElement && this._activeClass) {
307
+ this._targetElement.classList.remove(this._activeClass, "v-anim-paused");
308
+ }
309
+ this._activeClass = "";
310
+ return this;
311
+ }
312
+ dispose() {
313
+ this._clearPendingEnd(null);
314
+ if (this._observer) {
315
+ this._observer.disconnect();
316
+ this._observer = null;
317
+ }
318
+ if (this._targetElement && this._activeClass) {
319
+ this._targetElement.classList.remove(this._activeClass, "v-anim-paused");
320
+ }
321
+ this._activeClass = "";
322
+ super.dispose();
323
+ }
324
+ static getInstance(element) {
325
+ return import_core.VComponent.getComponentInstance(element, "animate");
326
+ }
327
+ static getOrCreateInstance(element, config) {
328
+ return import_core.VComponent.getOrCreateComponentInstance(
329
+ element,
330
+ "animate",
331
+ _VAnimate,
332
+ config
333
+ );
334
+ }
335
+ static createInstances(root = document) {
336
+ import_core.VComponent.createComponentInstances(
337
+ "animate",
338
+ _VAnimate,
339
+ "[data-v-animate]",
340
+ root
341
+ );
342
+ }
343
+ static init() {
344
+ _VAnimate.createInstances();
345
+ }
346
+ /**
347
+ * Dynamically attach VAnimate to any element or selector at runtime.
348
+ */
349
+ static add(element, animation, options) {
350
+ const targetEl = import_core.vDom.getElement(element);
351
+ if (!targetEl) return null;
352
+ const existing = _VAnimate.getInstance(targetEl);
353
+ if (existing) {
354
+ if (options?.trigger && options.trigger !== existing.getOption("trigger")) {
355
+ existing.dispose();
356
+ } else {
357
+ existing.setAnimation(animation);
358
+ if (options) {
359
+ existing._mergeConfig(options);
360
+ existing._applyCssVars(options);
361
+ }
362
+ const trigger = options?.trigger ?? "mount";
363
+ if (trigger === "mount") {
364
+ void existing.play(animation, options);
365
+ }
366
+ return existing;
367
+ }
368
+ }
369
+ return new _VAnimate(targetEl, {
370
+ trigger: "mount",
371
+ ...options,
372
+ animation
373
+ });
374
+ }
375
+ /**
376
+ * One-liner to dynamically play/replay an animation on any element or selector.
377
+ */
378
+ static play(element, animation, options) {
379
+ const targetEl = import_core.vDom.getElement(element);
380
+ if (!targetEl) return Promise.resolve(null);
381
+ const instance = _VAnimate.getOrCreateInstance(targetEl, {
382
+ trigger: "manual",
383
+ ...options,
384
+ animation
385
+ });
386
+ if (!instance) return Promise.resolve(null);
387
+ return instance.play(animation, options);
388
+ }
389
+ /**
390
+ * Dynamically animate a list of elements or a container's direct children with stagger delay.
391
+ */
392
+ static stagger(elementsOrSelector, animation, options = {}) {
393
+ const { step = 70, startDelay = 0, ...animOptions } = options;
394
+ let items = [];
395
+ if (typeof elementsOrSelector === "string") {
396
+ items = Array.from(document.querySelectorAll(elementsOrSelector));
397
+ } else if (elementsOrSelector instanceof HTMLElement) {
398
+ items = Array.from(elementsOrSelector.children).filter(
399
+ (child) => child instanceof HTMLElement
400
+ );
401
+ } else {
402
+ items = Array.from(elementsOrSelector);
403
+ }
404
+ return Promise.all(
405
+ items.map(
406
+ (el, index) => _VAnimate.play(el, animation, {
407
+ ...animOptions,
408
+ delay: `${startDelay + index * step}ms`
409
+ })
410
+ )
411
+ );
412
+ }
413
+ };
414
+ var vAnimatePlugin = {
415
+ name: "animate",
416
+ component: VAnimate,
417
+ init: () => VAnimate.init(),
418
+ dispose: () => {
419
+ if (typeof document === "undefined") return;
420
+ document.querySelectorAll("[data-v-animate-initialized]").forEach((el) => {
421
+ VAnimate.getInstance(el)?.dispose();
422
+ });
423
+ }
424
+ };
425
+ if (import_core.vComponents && typeof import_core.vComponents.use === "function") {
426
+ import_core.vComponents.use(vAnimatePlugin, { globalName: "VAnimate" });
427
+ } else if (typeof window !== "undefined") {
428
+ window.VAnimate = VAnimate;
429
+ }
430
+ var index_default = VAnimate;
431
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/index.ts"],
4
+ "sourcesContent": ["/**\n * vUI - Free & Open-Source Tailwind UI vComponents\n * Plugin: @vdragon/vui-animate\n */\n\nimport { VComponent, vComponents, vDom } from '@vdragon/vui/core';\nimport type { VPluginInterface } from '@vdragon/vui/core';\n\nexport type VAnimateTrigger = 'mount' | 'visible' | 'click' | 'hover' | 'manual';\n\nexport interface VAnimateConfig {\n\t/** Animation name (e.g. 'fade-up' or 'v-anim-fade-up') */\n\tanimation?: string;\n\t/** When to trigger animation automatically */\n\ttrigger?: VAnimateTrigger;\n\t/** Optional selector or element to animate instead of the host element */\n\ttarget?: string | HTMLElement | null;\n\t/** CSS --v-anim-duration (e.g. '450ms', '0.6s', or number in ms) */\n\tduration?: string | number;\n\t/** CSS --v-anim-delay (e.g. '120ms', or number in ms) */\n\tdelay?: string | number;\n\t/** Easing preset ('smooth' | 'spring' | 'snappy') or custom CSS timing function */\n\teasing?: string;\n\t/** CSS --v-anim-distance (e.g. '24px', or number in px) */\n\tdistance?: string | number;\n\t/** CSS --v-anim-scale (e.g. 0.92) */\n\tscale?: string | number;\n\t/** CSS --v-anim-blur (e.g. '12px', or number in px) */\n\tblur?: string | number;\n\t/** CSS --v-anim-iterations (e.g. 1, 2, 'infinite') */\n\titerations?: string | number;\n\t/** CSS --v-anim-accent color */\n\taccent?: string;\n\t/** For 'visible' trigger: only animate once when entering viewport */\n\tonce?: boolean;\n\t/** For 'visible' trigger: IntersectionObserver threshold (0..1) */\n\tthreshold?: number;\n\t/** Remove the animation class automatically after animationend */\n\tcleanup?: boolean;\n}\n\nexport interface VAnimateStaggerOptions extends VAnimateConfig {\n\t/** Delay increment between consecutive items in ms (default: 70) */\n\tstep?: number;\n\t/** Initial delay for the first item in ms (default: 0) */\n\tstartDelay?: number;\n}\n\nexport interface VAnimateEventPayload {\n\telement: HTMLElement;\n\ttarget: HTMLElement;\n\tanimation: string;\n\tclassName: string;\n\tcancel?: boolean;\n}\n\nconst EASING_PRESETS: Record<string, string> = {\n\tsmooth: 'var(--v-anim-ease-smooth)',\n\tspring: 'var(--v-anim-ease-spring)',\n\tsnappy: 'var(--v-anim-ease-snappy)',\n};\n\nconst CSS_VAR_MAP: Array<[keyof VAnimateConfig, string, string]> = [\n\t['duration', '--v-anim-duration', 'ms'],\n\t['delay', '--v-anim-delay', 'ms'],\n\t['distance', '--v-anim-distance', 'px'],\n\t['scale', '--v-anim-scale', ''],\n\t['blur', '--v-anim-blur', 'px'],\n\t['iterations', '--v-anim-iterations', ''],\n\t['accent', '--v-anim-accent', ''],\n];\n\nfunction normalizeAnimationClass(animation?: string | null): string {\n\tconst raw = String(animation ?? '').trim();\n\tif (!raw || raw === 'true' || raw === 'false') {\n\t\treturn '';\n\t}\n\treturn raw.startsWith('v-anim-') ? raw : `v-anim-${raw}`;\n}\n\nfunction formatCssValue(value: string | number | undefined, unit: string): string {\n\tif (value === undefined || value === null || value === '') {\n\t\treturn '';\n\t}\n\tif (typeof value === 'number') {\n\t\treturn `${value}${unit}`;\n\t}\n\tconst trimmed = String(value).trim();\n\tif (unit && /^-?\\d+(\\.\\d+)?$/.test(trimmed)) {\n\t\treturn `${trimmed}${unit}`;\n\t}\n\treturn trimmed;\n}\n\nfunction toBoolean(value: unknown, fallback: boolean): boolean {\n\tif (typeof value === 'boolean') return value;\n\tif (typeof value === 'string') {\n\t\tconst lower = value.trim().toLowerCase();\n\t\tif (lower === 'true') return true;\n\t\tif (lower === 'false') return false;\n\t}\n\treturn fallback;\n}\n\nfunction toNumber(value: unknown, fallback: number): number {\n\tconst n = Number(value);\n\treturn Number.isFinite(n) ? n : fallback;\n}\n\nexport class VAnimate extends VComponent {\n\tprotected override _name: string = 'animate';\n\tprotected override _defaultConfig: VAnimateConfig = {\n\t\tanimation: '',\n\t\ttrigger: 'mount',\n\t\ttarget: null,\n\t\tduration: '',\n\t\tdelay: '',\n\t\teasing: '',\n\t\tdistance: '',\n\t\tscale: '',\n\t\tblur: '',\n\t\titerations: '',\n\t\taccent: '',\n\t\tonce: true,\n\t\tthreshold: 0.15,\n\t\tcleanup: false,\n\t};\n\n\tprotected _targetElement: HTMLElement | null = null;\n\tprotected _activeClass: string = '';\n\tprotected _observer: IntersectionObserver | null = null;\n\tprotected _pendingEndHandler: ((event: AnimationEvent) => void) | null = null;\n\tprotected _pendingResolve: ((el: HTMLElement | null) => void) | null = null;\n\n\tconstructor(element: HTMLElement, config?: VAnimateConfig) {\n\t\tsuper();\n\n\t\tif (!element || this._shouldSkipInit(element)) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis._init(element);\n\t\tthis._buildConfig(config);\n\n\t\tif (!this._element) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Support shorthand: data-v-animate=\"fade-up\"\n\t\tconst attrValue = this._element.getAttribute('data-v-animate');\n\t\tif (\n\t\t\t!this._getOption('animation') &&\n\t\t\tattrValue &&\n\t\t\tattrValue !== 'true' &&\n\t\t\tattrValue !== 'false'\n\t\t) {\n\t\t\tthis._mergeConfig({ animation: attrValue });\n\t\t}\n\n\t\tthis._targetElement = this._resolveTargetElement();\n\t\tthis._applyCssVars();\n\t\tthis._bindTrigger();\n\t}\n\n\tprotected _resolveTargetElement(): HTMLElement | null {\n\t\tconst targetOpt = this._getOption('target') as string | HTMLElement | null;\n\t\tif (targetOpt instanceof HTMLElement) {\n\t\t\treturn targetOpt;\n\t\t}\n\t\tif (typeof targetOpt === 'string' && targetOpt.trim()) {\n\t\t\treturn vDom.getElement(targetOpt.trim());\n\t\t}\n\t\treturn this._element;\n\t}\n\n\tprotected _applyCssVars(overrides?: Partial<VAnimateConfig>): void {\n\t\tconst target = this._targetElement;\n\t\tif (!target) return;\n\n\t\tfor (const [key, cssVar, unit] of CSS_VAR_MAP) {\n\t\t\tconst rawVal =\n\t\t\t\toverrides && overrides[key] !== undefined\n\t\t\t\t\t? overrides[key]\n\t\t\t\t\t: (this._getOption(key) as string | number | undefined);\n\t\t\tconst formatted = formatCssValue(rawVal as string | number | undefined, unit);\n\t\t\tif (formatted) {\n\t\t\t\ttarget.style.setProperty(cssVar, formatted);\n\t\t\t}\n\t\t}\n\n\t\tconst rawEasing =\n\t\t\toverrides && overrides.easing !== undefined\n\t\t\t\t? overrides.easing\n\t\t\t\t: (this._getOption('easing') as string | undefined);\n\t\tif (rawEasing && String(rawEasing).trim()) {\n\t\t\tconst easingKey = String(rawEasing).trim();\n\t\t\ttarget.style.setProperty(\n\t\t\t\t'--v-anim-easing',\n\t\t\t\tEASING_PRESETS[easingKey] ?? easingKey,\n\t\t\t);\n\t\t}\n\t}\n\n\tprotected _bindTrigger(): void {\n\t\tif (!this._element) return;\n\t\tconst trigger = String(this._getOption('trigger') || 'mount').toLowerCase();\n\n\t\tif (trigger === 'mount') {\n\t\t\tvoid this.play();\n\t\t\treturn;\n\t\t}\n\n\t\tif (trigger === 'click') {\n\t\t\tthis._addEventListener(this._element, 'click', () => {\n\t\t\t\tvoid this.play();\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\tif (trigger === 'hover') {\n\t\t\tthis._addEventListener(this._element, 'mouseenter', () => {\n\t\t\t\tvoid this.play();\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\tif (trigger === 'visible') {\n\t\t\tthis._observeVisibility();\n\t\t}\n\t}\n\n\tprotected _observeVisibility(): void {\n\t\tconst host = this._element;\n\t\tif (!host) return;\n\n\t\tif (typeof IntersectionObserver === 'undefined') {\n\t\t\tvoid this.play();\n\t\t\treturn;\n\t\t}\n\n\t\tconst threshold = toNumber(this._getOption('threshold'), 0.15);\n\t\tconst once = toBoolean(this._getOption('once'), true);\n\n\t\tthis._observer = new IntersectionObserver(\n\t\t\t(entries) => {\n\t\t\t\tfor (const entry of entries) {\n\t\t\t\t\tif (entry.isIntersecting) {\n\t\t\t\t\t\tvoid this.play();\n\t\t\t\t\t\tif (once && this._observer) {\n\t\t\t\t\t\t\tthis._observer.disconnect();\n\t\t\t\t\t\t\tthis._observer = null;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t\t{ threshold },\n\t\t);\n\n\t\tthis._observer.observe(host);\n\t}\n\n\tprotected _clearPendingEnd(resolveResult: HTMLElement | null = null): void {\n\t\tif (this._targetElement && this._pendingEndHandler) {\n\t\t\tthis._targetElement.removeEventListener(\n\t\t\t\t'animationend',\n\t\t\t\tthis._pendingEndHandler,\n\t\t\t);\n\t\t}\n\t\tthis._pendingEndHandler = null;\n\n\t\tif (this._pendingResolve) {\n\t\t\tconst done = this._pendingResolve;\n\t\t\tthis._pendingResolve = null;\n\t\t\tdone(resolveResult);\n\t\t}\n\t}\n\n\tpublic getTargetElement(): HTMLElement | null {\n\t\treturn this._targetElement;\n\t}\n\n\tpublic setAnimation(animation: string): this {\n\t\tthis._mergeConfig({ animation });\n\t\treturn this;\n\t}\n\n\tpublic play(\n\t\tanimation?: string,\n\t\toptions?: Partial<VAnimateConfig>,\n\t): Promise<HTMLElement | null> {\n\t\tif (!this._element) {\n\t\t\treturn Promise.resolve(null);\n\t\t}\n\n\t\tif (options) {\n\t\t\tthis._mergeConfig(options);\n\t\t\tif (options.target !== undefined) {\n\t\t\t\tthis._targetElement = this._resolveTargetElement();\n\t\t\t}\n\t\t}\n\n\t\tconst target = this._targetElement ?? this._element;\n\t\tif (!target) {\n\t\t\treturn Promise.resolve(null);\n\t\t}\n\n\t\tconst animName =\n\t\t\tanimation !== undefined\n\t\t\t\t? animation\n\t\t\t\t: String(this._getOption('animation') ?? '');\n\t\tconst className = normalizeAnimationClass(animName);\n\t\tif (!className) {\n\t\t\treturn Promise.resolve(target);\n\t\t}\n\n\t\tif (animation !== undefined) {\n\t\t\tthis._mergeConfig({ animation });\n\t\t}\n\n\t\tconst startPayload: VAnimateEventPayload = {\n\t\t\telement: this._element,\n\t\t\ttarget,\n\t\t\tanimation: animName,\n\t\t\tclassName,\n\t\t\tcancel: false,\n\t\t};\n\t\tvoid this._fireEvent('start', startPayload);\n\t\tthis._dispatchEvent('v.animate.start', startPayload);\n\t\tif (startPayload.cancel === true) {\n\t\t\treturn Promise.resolve(target);\n\t\t}\n\n\t\tthis._clearPendingEnd(target);\n\n\t\t// Remove previous or identical animation class, then force reflow to replay cleanly\n\t\tif (this._activeClass) {\n\t\t\ttarget.classList.remove(this._activeClass);\n\t\t}\n\t\ttarget.classList.remove(className, 'v-anim-paused');\n\t\tthis._applyCssVars(options);\n\t\tvDom.reflow(target);\n\n\t\tthis._activeClass = className;\n\t\ttarget.classList.add(className);\n\n\t\tconst shouldCleanup = toBoolean(\n\t\t\toptions?.cleanup ?? this._getOption('cleanup'),\n\t\t\tfalse,\n\t\t);\n\n\t\treturn new Promise<HTMLElement | null>((resolve) => {\n\t\t\tconst finish = () => {\n\t\t\t\tif (shouldCleanup) {\n\t\t\t\t\ttarget.classList.remove(className);\n\t\t\t\t\tif (this._activeClass === className) {\n\t\t\t\t\t\tthis._activeClass = '';\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tconst endPayload: VAnimateEventPayload = {\n\t\t\t\t\telement: this._element ?? target,\n\t\t\t\t\ttarget,\n\t\t\t\t\tanimation: animName,\n\t\t\t\t\tclassName,\n\t\t\t\t};\n\t\t\t\tvoid this._fireEvent('end', endPayload);\n\t\t\t\tthis._dispatchEvent('v.animate.end', endPayload);\n\t\t\t\tresolve(target);\n\t\t\t};\n\n\t\t\tconst onEnd = (event: AnimationEvent) => {\n\t\t\t\tif (event.target !== target) return;\n\t\t\t\ttarget.removeEventListener('animationend', onEnd);\n\t\t\t\tthis._pendingEndHandler = null;\n\t\t\t\tthis._pendingResolve = null;\n\t\t\t\tfinish();\n\t\t\t};\n\n\t\t\tthis._pendingEndHandler = onEnd;\n\t\t\tthis._pendingResolve = resolve;\n\t\t\ttarget.addEventListener('animationend', onEnd);\n\t\t});\n\t}\n\n\tpublic replay(\n\t\tanimation?: string,\n\t\toptions?: Partial<VAnimateConfig>,\n\t): Promise<HTMLElement | null> {\n\t\treturn this.play(animation, options);\n\t}\n\n\tpublic pause(): this {\n\t\tthis._targetElement?.classList.add('v-anim-paused');\n\t\treturn this;\n\t}\n\n\tpublic resume(): this {\n\t\tthis._targetElement?.classList.remove('v-anim-paused');\n\t\treturn this;\n\t}\n\n\tpublic stop(): this {\n\t\tthis._clearPendingEnd(this._targetElement);\n\t\tif (this._targetElement && this._activeClass) {\n\t\t\tthis._targetElement.classList.remove(this._activeClass, 'v-anim-paused');\n\t\t}\n\t\tthis._activeClass = '';\n\t\treturn this;\n\t}\n\n\tpublic override dispose(): void {\n\t\tthis._clearPendingEnd(null);\n\t\tif (this._observer) {\n\t\t\tthis._observer.disconnect();\n\t\t\tthis._observer = null;\n\t\t}\n\t\tif (this._targetElement && this._activeClass) {\n\t\t\tthis._targetElement.classList.remove(this._activeClass, 'v-anim-paused');\n\t\t}\n\t\tthis._activeClass = '';\n\t\tsuper.dispose();\n\t}\n\n\tpublic static getInstance(element: HTMLElement | string | null): VAnimate | null {\n\t\treturn VComponent.getComponentInstance<VAnimate>(element, 'animate');\n\t}\n\n\tpublic static getOrCreateInstance(\n\t\telement: HTMLElement | string | null,\n\t\tconfig?: VAnimateConfig,\n\t): VAnimate | null {\n\t\treturn VComponent.getOrCreateComponentInstance<VAnimate, VAnimateConfig>(\n\t\t\telement,\n\t\t\t'animate',\n\t\t\tVAnimate,\n\t\t\tconfig,\n\t\t);\n\t}\n\n\tpublic static createInstances(root: ParentNode = document): void {\n\t\tVComponent.createComponentInstances<VAnimate, VAnimateConfig>(\n\t\t\t'animate',\n\t\t\tVAnimate,\n\t\t\t'[data-v-animate]',\n\t\t\troot,\n\t\t);\n\t}\n\n\tpublic static init(): void {\n\t\tVAnimate.createInstances();\n\t}\n\n\t/**\n\t * Dynamically attach VAnimate to any element or selector at runtime.\n\t */\n\tpublic static add(\n\t\telement: HTMLElement | string | null,\n\t\tanimation: string,\n\t\toptions?: VAnimateConfig,\n\t): VAnimate | null {\n\t\tconst targetEl = vDom.getElement(element);\n\t\tif (!targetEl) return null;\n\n\t\tconst existing = VAnimate.getInstance(targetEl);\n\t\tif (existing) {\n\t\t\tif (options?.trigger && options.trigger !== existing.getOption('trigger')) {\n\t\t\t\texisting.dispose();\n\t\t\t} else {\n\t\t\t\texisting.setAnimation(animation);\n\t\t\t\tif (options) {\n\t\t\t\t\texisting._mergeConfig(options);\n\t\t\t\t\texisting._applyCssVars(options);\n\t\t\t\t}\n\t\t\t\tconst trigger = options?.trigger ?? 'mount';\n\t\t\t\tif (trigger === 'mount') {\n\t\t\t\t\tvoid existing.play(animation, options);\n\t\t\t\t}\n\t\t\t\treturn existing;\n\t\t\t}\n\t\t}\n\n\t\treturn new VAnimate(targetEl, {\n\t\t\ttrigger: 'mount',\n\t\t\t...options,\n\t\t\tanimation,\n\t\t});\n\t}\n\n\t/**\n\t * One-liner to dynamically play/replay an animation on any element or selector.\n\t */\n\tpublic static play(\n\t\telement: HTMLElement | string | null,\n\t\tanimation: string,\n\t\toptions?: VAnimateConfig,\n\t): Promise<HTMLElement | null> {\n\t\tconst targetEl = vDom.getElement(element);\n\t\tif (!targetEl) return Promise.resolve(null);\n\n\t\tconst instance = VAnimate.getOrCreateInstance(targetEl, {\n\t\t\ttrigger: 'manual',\n\t\t\t...options,\n\t\t\tanimation,\n\t\t});\n\t\tif (!instance) return Promise.resolve(null);\n\n\t\treturn instance.play(animation, options);\n\t}\n\n\t/**\n\t * Dynamically animate a list of elements or a container's direct children with stagger delay.\n\t */\n\tpublic static stagger(\n\t\telementsOrSelector: HTMLElement | NodeListOf<HTMLElement> | HTMLElement[] | string,\n\t\tanimation: string,\n\t\toptions: VAnimateStaggerOptions = {},\n\t): Promise<Array<HTMLElement | null>> {\n\t\tconst { step = 70, startDelay = 0, ...animOptions } = options;\n\n\t\tlet items: HTMLElement[] = [];\n\t\tif (typeof elementsOrSelector === 'string') {\n\t\t\titems = Array.from(document.querySelectorAll<HTMLElement>(elementsOrSelector));\n\t\t} else if (elementsOrSelector instanceof HTMLElement) {\n\t\t\titems = Array.from(elementsOrSelector.children).filter(\n\t\t\t\t(child): child is HTMLElement => child instanceof HTMLElement,\n\t\t\t);\n\t\t} else {\n\t\t\titems = Array.from(elementsOrSelector);\n\t\t}\n\n\t\treturn Promise.all(\n\t\t\titems.map((el, index) =>\n\t\t\t\tVAnimate.play(el, animation, {\n\t\t\t\t\t...animOptions,\n\t\t\t\t\tdelay: `${startDelay + index * step}ms`,\n\t\t\t\t}),\n\t\t\t),\n\t\t);\n\t}\n}\n\nexport const vAnimatePlugin: VPluginInterface = {\n\tname: 'animate',\n\tcomponent: VAnimate,\n\tinit: () => VAnimate.init(),\n\tdispose: () => {\n\t\tif (typeof document === 'undefined') return;\n\t\tdocument.querySelectorAll<HTMLElement>('[data-v-animate-initialized]').forEach((el) => {\n\t\t\tVAnimate.getInstance(el)?.dispose();\n\t\t});\n\t},\n};\n\n// Auto-register with @vdragon/vui plugin host SDK\nif (vComponents && typeof vComponents.use === 'function') {\n\tvComponents.use(vAnimatePlugin, { globalName: 'VAnimate' });\n} else if (typeof window !== 'undefined') {\n\t(window as unknown as Record<string, unknown>).VAnimate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AAG,YAAY,IAAI;AAEtD,QAAI,QAAuB,CAAC;AAC5B,QAAI,OAAO,uBAAuB,UAAU;AAC3C,cAAQ,MAAM,KAAK,SAAS,iBAA8B,kBAAkB,CAAC;AAAA,IAC9E,WAAW,8BAA8B,aAAa;AACrD,cAAQ,MAAM,KAAK,mBAAmB,QAAQ,EAAE;AAAA,QAC/C,CAAC,UAAgC,iBAAiB;AAAA,MACnD;AAAA,IACD,OAAO;AACN,cAAQ,MAAM,KAAK,kBAAkB;AAAA,IACtC;AAEA,WAAO,QAAQ;AAAA,MACd,MAAM;AAAA,QAAI,CAAC,IAAI,UACd,UAAS,KAAK,IAAI,WAAW;AAAA,UAC5B,GAAG;AAAA,UACH,OAAO,GAAG,aAAa,QAAQ,IAAI;AAAA,QACpC,CAAC;AAAA,MACF;AAAA,IACD;AAAA,EACD;AACD;AAEO,IAAM,iBAAmC;AAAA,EAC/C,MAAM;AAAA,EACN,WAAW;AAAA,EACX,MAAM,MAAM,SAAS,KAAK;AAAA,EAC1B,SAAS,MAAM;AACd,QAAI,OAAO,aAAa,YAAa;AACrC,aAAS,iBAA8B,8BAA8B,EAAE,QAAQ,CAAC,OAAO;AACtF,eAAS,YAAY,EAAE,GAAG,QAAQ;AAAA,IACnC,CAAC;AAAA,EACF;AACD;AAGA,IAAI,2BAAe,OAAO,wBAAY,QAAQ,YAAY;AACzD,0BAAY,IAAI,gBAAgB,EAAE,YAAY,WAAW,CAAC;AAC3D,WAAW,OAAO,WAAW,aAAa;AACzC,EAAC,OAA8C,WAAW;AAC3D;AAEA,IAAO,gBAAQ;",
6
+ "names": []
7
+ }
@@ -0,0 +1,92 @@
1
+ /**
2
+ * vUI - Free & Open-Source Tailwind UI vComponents
3
+ * Plugin: @vdragon/vui-animate
4
+ */
5
+ import { VComponent } from '@vdragon/vui/core';
6
+ import type { VPluginInterface } from '@vdragon/vui/core';
7
+ export type VAnimateTrigger = 'mount' | 'visible' | 'click' | 'hover' | 'manual';
8
+ export interface VAnimateConfig {
9
+ /** Animation name (e.g. 'fade-up' or 'v-anim-fade-up') */
10
+ animation?: string;
11
+ /** When to trigger animation automatically */
12
+ trigger?: VAnimateTrigger;
13
+ /** Optional selector or element to animate instead of the host element */
14
+ target?: string | HTMLElement | null;
15
+ /** CSS --v-anim-duration (e.g. '450ms', '0.6s', or number in ms) */
16
+ duration?: string | number;
17
+ /** CSS --v-anim-delay (e.g. '120ms', or number in ms) */
18
+ delay?: string | number;
19
+ /** Easing preset ('smooth' | 'spring' | 'snappy') or custom CSS timing function */
20
+ easing?: string;
21
+ /** CSS --v-anim-distance (e.g. '24px', or number in px) */
22
+ distance?: string | number;
23
+ /** CSS --v-anim-scale (e.g. 0.92) */
24
+ scale?: string | number;
25
+ /** CSS --v-anim-blur (e.g. '12px', or number in px) */
26
+ blur?: string | number;
27
+ /** CSS --v-anim-iterations (e.g. 1, 2, 'infinite') */
28
+ iterations?: string | number;
29
+ /** CSS --v-anim-accent color */
30
+ accent?: string;
31
+ /** For 'visible' trigger: only animate once when entering viewport */
32
+ once?: boolean;
33
+ /** For 'visible' trigger: IntersectionObserver threshold (0..1) */
34
+ threshold?: number;
35
+ /** Remove the animation class automatically after animationend */
36
+ cleanup?: boolean;
37
+ }
38
+ export interface VAnimateStaggerOptions extends VAnimateConfig {
39
+ /** Delay increment between consecutive items in ms (default: 70) */
40
+ step?: number;
41
+ /** Initial delay for the first item in ms (default: 0) */
42
+ startDelay?: number;
43
+ }
44
+ export interface VAnimateEventPayload {
45
+ element: HTMLElement;
46
+ target: HTMLElement;
47
+ animation: string;
48
+ className: string;
49
+ cancel?: boolean;
50
+ }
51
+ export declare class VAnimate extends VComponent {
52
+ protected _name: string;
53
+ protected _defaultConfig: VAnimateConfig;
54
+ protected _targetElement: HTMLElement | null;
55
+ protected _activeClass: string;
56
+ protected _observer: IntersectionObserver | null;
57
+ protected _pendingEndHandler: ((event: AnimationEvent) => void) | null;
58
+ protected _pendingResolve: ((el: HTMLElement | null) => void) | null;
59
+ constructor(element: HTMLElement, config?: VAnimateConfig);
60
+ protected _resolveTargetElement(): HTMLElement | null;
61
+ protected _applyCssVars(overrides?: Partial<VAnimateConfig>): void;
62
+ protected _bindTrigger(): void;
63
+ protected _observeVisibility(): void;
64
+ protected _clearPendingEnd(resolveResult?: HTMLElement | null): void;
65
+ getTargetElement(): HTMLElement | null;
66
+ setAnimation(animation: string): this;
67
+ play(animation?: string, options?: Partial<VAnimateConfig>): Promise<HTMLElement | null>;
68
+ replay(animation?: string, options?: Partial<VAnimateConfig>): Promise<HTMLElement | null>;
69
+ pause(): this;
70
+ resume(): this;
71
+ stop(): this;
72
+ dispose(): void;
73
+ static getInstance(element: HTMLElement | string | null): VAnimate | null;
74
+ static getOrCreateInstance(element: HTMLElement | string | null, config?: VAnimateConfig): VAnimate | null;
75
+ static createInstances(root?: ParentNode): void;
76
+ static init(): void;
77
+ /**
78
+ * Dynamically attach VAnimate to any element or selector at runtime.
79
+ */
80
+ static add(element: HTMLElement | string | null, animation: string, options?: VAnimateConfig): VAnimate | null;
81
+ /**
82
+ * One-liner to dynamically play/replay an animation on any element or selector.
83
+ */
84
+ static play(element: HTMLElement | string | null, animation: string, options?: VAnimateConfig): Promise<HTMLElement | null>;
85
+ /**
86
+ * Dynamically animate a list of elements or a container's direct children with stagger delay.
87
+ */
88
+ static stagger(elementsOrSelector: HTMLElement | NodeListOf<HTMLElement> | HTMLElement[] | string, animation: string, options?: VAnimateStaggerOptions): Promise<Array<HTMLElement | null>>;
89
+ }
90
+ export declare const vAnimatePlugin: VPluginInterface;
91
+ export default VAnimate;
92
+ //# sourceMappingURL=index.d.ts.map