dynaura 0.0.0-stage → 0.1.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.
package/dist/vue.cjs ADDED
@@ -0,0 +1,613 @@
1
+ "use client";
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/vue.ts
22
+ var vue_exports = {};
23
+ __export(vue_exports, {
24
+ Toaster: () => Toaster,
25
+ dynaura: () => dynaura
26
+ });
27
+ module.exports = __toCommonJS(vue_exports);
28
+ var import_vue = require("vue");
29
+
30
+ // src/confetti.ts
31
+ function burst(x, y, color) {
32
+ const c = document.createElement("canvas");
33
+ const dpr = window.devicePixelRatio || 1;
34
+ const W = innerWidth, H = innerHeight;
35
+ c.width = W * dpr;
36
+ c.height = H * dpr;
37
+ c.style.cssText = `position:fixed;top:0;left:0;width:${W}px;height:${H}px;pointer-events:none;z-index:2147483647`;
38
+ document.body.append(c);
39
+ const ctx = c.getContext("2d");
40
+ if (!ctx) return c.remove();
41
+ ctx.scale(dpr, dpr);
42
+ const colors = [color, "#fff", color, "#ffd60a", "#0a84ff"];
43
+ const ps = Array.from({ length: 36 }, () => {
44
+ const a = Math.random() * Math.PI * 2, s = 3 + Math.random() * 6;
45
+ return { x, y, vx: Math.cos(a) * s, vy: Math.sin(a) * s - 3, r: 2 + Math.random() * 3, rot: Math.random() * 6, c: colors[Math.random() * colors.length | 0] };
46
+ });
47
+ const t0 = performance.now();
48
+ const frame = (t) => {
49
+ const k = (t - t0) / 1e3;
50
+ if (k >= 1) return c.remove();
51
+ ctx.clearRect(0, 0, W, H);
52
+ for (const p of ps) {
53
+ p.x += p.vx;
54
+ p.y += p.vy;
55
+ p.vy += 0.28;
56
+ p.vx *= 0.985;
57
+ p.rot += 0.2;
58
+ ctx.globalAlpha = 1 - k * k;
59
+ ctx.fillStyle = p.c;
60
+ ctx.save();
61
+ ctx.translate(p.x, p.y);
62
+ ctx.rotate(p.rot);
63
+ ctx.fillRect(-p.r, -p.r / 2, p.r * 2, p.r);
64
+ ctx.restore();
65
+ }
66
+ requestAnimationFrame(frame);
67
+ };
68
+ requestAnimationFrame(frame);
69
+ }
70
+
71
+ // src/store.ts
72
+ var g = globalThis;
73
+ var _a;
74
+ var S = (_a = g.__dynaura) != null ? _a : g.__dynaura = { current: null, queue: [], n: 0, subs: /* @__PURE__ */ new Set(), useQueue: false };
75
+ var set = (t) => {
76
+ S.current = t;
77
+ S.subs.forEach((f) => f());
78
+ };
79
+ var subscribe = (f) => {
80
+ S.subs.add(f);
81
+ return () => {
82
+ S.subs.delete(f);
83
+ };
84
+ };
85
+ var getCurrent = () => S.current;
86
+ var setQueue = (v) => {
87
+ S.useQueue = v;
88
+ };
89
+ var norm = (o) => typeof o === "string" ? { title: o } : o;
90
+ var make = (type) => (o) => {
91
+ var _a2;
92
+ const id = String(++S.n);
93
+ const sticky = type === "loading" || type === "live";
94
+ const t = { duration: sticky ? null : 4e3, ...type === "live" ? { kind: "timer" } : {}, ...norm(o), id, type };
95
+ if (S.current && ((_a2 = t.queue) != null ? _a2 : S.useQueue)) S.queue.push(t);
96
+ else set(t);
97
+ return id;
98
+ };
99
+ var update = (id, patch) => {
100
+ var _a2;
101
+ if (((_a2 = S.current) == null ? void 0 : _a2.id) === id) return set({ ...S.current, ...patch });
102
+ const i = S.queue.findIndex((t) => t.id === id);
103
+ if (i >= 0) S.queue[i] = { ...S.queue[i], ...patch };
104
+ };
105
+ var pick = (r, v) => norm(typeof r === "function" ? r(v) : r);
106
+ var dynaura = {
107
+ success: make("success"),
108
+ error: make("error"),
109
+ warning: make("warning"),
110
+ info: make("info"),
111
+ loading: make("loading"),
112
+ /** Live activity: sticky island with a running timer (default) or waveform. */
113
+ live: make("live"),
114
+ update,
115
+ /** dismiss the current toast (next queued one shows) or a specific id */
116
+ dismiss: (id) => {
117
+ var _a2, _b;
118
+ if (id && ((_a2 = S.current) == null ? void 0 : _a2.id) !== id) {
119
+ S.queue = S.queue.filter((t) => t.id !== id);
120
+ return;
121
+ }
122
+ set((_b = S.queue.shift()) != null ? _b : null);
123
+ },
124
+ clear: () => {
125
+ S.queue = [];
126
+ set(null);
127
+ },
128
+ promise(p, o) {
129
+ const id = make("loading")(o.loading);
130
+ p.then(
131
+ (v) => update(id, { duration: 4e3, ...pick(o.success, v), type: "success" }),
132
+ (e) => update(id, { duration: 4e3, ...pick(o.error, e), type: "error" })
133
+ );
134
+ return p;
135
+ }
136
+ };
137
+
138
+ // src/core.ts
139
+ var VAR = {
140
+ background: "bg",
141
+ foreground: "fg",
142
+ muted: "muted",
143
+ ring: "ring",
144
+ button: "btn",
145
+ success: "success",
146
+ error: "error",
147
+ warning: "warning",
148
+ info: "info",
149
+ loading: "loading",
150
+ live: "live"
151
+ };
152
+ var svg = (d) => `<svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round">${d}</svg>`;
153
+ var ICON = {
154
+ success: svg('<path class="dynaura-draw" d="M5 12.5l4.5 4.5L19 7.5"/>'),
155
+ error: svg('<path class="dynaura-draw" d="M7 7l10 10M17 7L7 17"/>'),
156
+ warning: svg('<path class="dynaura-draw" d="M12 6v7M12 17.5v.01"/>'),
157
+ info: svg('<path class="dynaura-draw" d="M12 11v6M12 7.5v.01"/>'),
158
+ loading: svg('<circle class="dynaura-spin" cx="12" cy="12" r="8" stroke-dasharray="30 50"/>')
159
+ };
160
+ var DOT = '<span class="dynaura-dot"></span>';
161
+ var WAVE = '<span class="dynaura-wave"><i></i><i></i><i></i><i></i></span>';
162
+ var VIBRATE = { success: [12], error: [24, 40, 24], warning: [30], info: [8], loading: [], live: [8] };
163
+ var f2 = (n) => +n.toFixed(2);
164
+ function outline(w, h2, cw, ch, hx) {
165
+ if (h2 <= ch + 1 || w <= cw + 1) {
166
+ const q = f2(Math.min(h2 / 2, w / 2, 32));
167
+ return `M${q} 0H${f2(w - q)}A${q} ${q} 0 0 1 ${f2(w)} ${q}V${f2(h2 - q)}A${q} ${q} 0 0 1 ${f2(w - q)} ${f2(h2)}H${q}A${q} ${q} 0 0 1 0 ${f2(h2 - q)}V${q}A${q} ${q} 0 0 1 ${q} 0Z`;
168
+ }
169
+ const r = f2(Math.min(ch / 2, 32));
170
+ const b = f2(Math.max(0, Math.min(28, (h2 - ch) / 2, (w - cw) / 2)));
171
+ const f = f2(Math.min(16, b));
172
+ const x0 = f2(hx), x1 = f2(hx + cw);
173
+ const flushL = hx < 1, flushR = hx + cw > w - 1;
174
+ let d = `M${f2(x0 + r)} 0H${f2(x1 - r)}A${r} ${r} 0 0 1 ${x1} ${r}`;
175
+ d += flushR ? `V${f2(h2 - b)}` : `V${f2(ch - f)}A${f} ${f} 0 0 0 ${f2(x1 + f)} ${f2(ch)}H${f2(w - b)}A${b} ${b} 0 0 1 ${f2(w)} ${f2(ch + b)}V${f2(h2 - b)}`;
176
+ d += `A${b} ${b} 0 0 1 ${f2(w - b)} ${f2(h2)}H${b}A${b} ${b} 0 0 1 0 ${f2(h2 - b)}`;
177
+ d += flushL ? `V${r}` : `V${f2(ch + b)}A${b} ${b} 0 0 1 ${b} ${f2(ch)}H${f2(x0 - f)}A${f} ${f} 0 0 0 ${x0} ${f2(ch - f)}V${r}`;
178
+ return d + `A${r} ${r} 0 0 1 ${f2(x0 + r)} 0Z`;
179
+ }
180
+ var h = (tag, cls, parent) => {
181
+ const e = document.createElement(tag);
182
+ e.className = cls;
183
+ parent == null ? void 0 : parent.append(e);
184
+ return e;
185
+ };
186
+ var restart = (e) => {
187
+ e.style.animation = "none";
188
+ void e.offsetWidth;
189
+ e.style.animation = "";
190
+ };
191
+ function roll(e, s) {
192
+ const sig = s.replace(/\d/g, "0");
193
+ if (e.dataset.sig !== sig) {
194
+ e.dataset.sig = sig;
195
+ e.replaceChildren();
196
+ e.setAttribute("role", "img");
197
+ for (const ch of s) {
198
+ if (/\d/.test(ch)) {
199
+ const d = h("span", "dynaura-digit", e);
200
+ d.setAttribute("aria-hidden", "true");
201
+ h("span", "dynaura-strip", d).innerHTML = "0123456789".replace(/\d/g, "<i>$&</i>");
202
+ } else h("span", "dynaura-char", e).textContent = ch;
203
+ }
204
+ }
205
+ e.setAttribute("aria-label", s);
206
+ [...s].forEach((ch, i) => {
207
+ if (/\d/.test(ch)) e.children[i].style.setProperty("--d", ch);
208
+ });
209
+ }
210
+ function createToaster(initial = {}) {
211
+ const o = { position: "top", offset: 12, theme: "dark", timer: true, haptics: true, queue: false };
212
+ const merge = (n) => {
213
+ for (const k in n) if (n[k] !== void 0) o[k] = n[k];
214
+ };
215
+ merge(initial);
216
+ const root = h("div", "dynaura-root");
217
+ const drag = h("div", "dynaura-drag", root);
218
+ const island = h("div", "dynaura-island", drag);
219
+ island.setAttribute("role", "status");
220
+ island.setAttribute("aria-live", "polite");
221
+ const inner = h("div", "dynaura-inner", island);
222
+ const row = h("div", "dynaura-row", inner);
223
+ const badge = h("span", "dynaura-badge", row);
224
+ const title = h("span", "dynaura-title", row);
225
+ const trail = h("span", "dynaura-trailing", row);
226
+ const body = h("div", "dynaura-body", inner);
227
+ const desc = h("div", "dynaura-desc", body);
228
+ const btn = h("button", "dynaura-button", body);
229
+ const bar = h("div", "dynaura-bar", island);
230
+ island.hidden = true;
231
+ island.dataset.expanded = "false";
232
+ island.dataset.paused = "false";
233
+ document.body.append(root);
234
+ let t = null;
235
+ let expanded = false, hovered = false, pinned = false, dragging = false, ready = false;
236
+ let hideT, expandT, collapseT, dismissT, liveI, lp;
237
+ let remaining = 0, startedAt = 0, liveStart = 0;
238
+ let sz = { cw: 0, ch: 0, ew: 0, eh: 0 };
239
+ let applied = [];
240
+ const hosts = /* @__PURE__ */ new Map();
241
+ const dir = () => o.position.startsWith("bottom") ? 1 : -1;
242
+ const hasBody = () => !!t && (t.description != null && typeof t.description !== "boolean" || !!t.button);
243
+ const paused = () => hovered || pinned || dragging;
244
+ function put(slot, c) {
245
+ var _a2;
246
+ const old = hosts.get(slot);
247
+ if (old) {
248
+ (_a2 = o.render) == null ? void 0 : _a2.call(o, old, null);
249
+ hosts.delete(slot);
250
+ }
251
+ slot.replaceChildren();
252
+ if (c == null || typeof c === "boolean") return;
253
+ if (typeof c === "string" || typeof c === "number") slot.textContent = String(c);
254
+ else if (c instanceof Node) slot.append(c);
255
+ else if (o.render) {
256
+ const host = h("span", "dynaura-host", slot);
257
+ hosts.set(slot, host);
258
+ o.render(host, c);
259
+ }
260
+ }
261
+ let raf = 0;
262
+ const isCard = () => island.dataset.variant === "card";
263
+ function shape() {
264
+ if (!isCard()) {
265
+ island.style.clipPath = "";
266
+ row.style.transform = "";
267
+ return;
268
+ }
269
+ const cs = getComputedStyle(island);
270
+ const w = parseFloat(cs.width), hh = parseFloat(cs.height);
271
+ if (!isFinite(w) || !isFinite(hh) || w <= 0) return;
272
+ const x = o.position.split("-")[1];
273
+ const hx = x === "left" ? 0 : x === "right" ? Math.max(0, w - sz.cw) : Math.max(0, (w - sz.cw) / 2);
274
+ row.style.transform = `translateX(${f2(hx)}px)`;
275
+ island.style.clipPath = `path('${outline(w, hh, sz.cw, sz.ch, hx)}')`;
276
+ }
277
+ function shapeLoop() {
278
+ cancelAnimationFrame(raf);
279
+ const end = performance.now() + 1300;
280
+ const f = () => {
281
+ shape();
282
+ if (performance.now() < end) raf = requestAnimationFrame(f);
283
+ };
284
+ f();
285
+ }
286
+ function size() {
287
+ if (!sz.cw) return;
288
+ const w = expanded ? sz.ew : sz.cw, hh = expanded ? sz.eh : sz.ch;
289
+ island.style.width = w + "px";
290
+ island.style.height = hh + "px";
291
+ island.style.borderRadius = isCard() ? "0" : Math.min(hh / 2, 32) + "px";
292
+ if (isCard()) shapeLoop();
293
+ else {
294
+ cancelAnimationFrame(raf);
295
+ island.style.clipPath = "";
296
+ row.style.transform = "";
297
+ }
298
+ }
299
+ function measure() {
300
+ if (island.hidden) return;
301
+ sz = { cw: row.offsetWidth, ch: row.offsetHeight, ew: inner.offsetWidth, eh: inner.offsetHeight };
302
+ size();
303
+ if (!ready && sz.cw) requestAnimationFrame(() => {
304
+ ready = true;
305
+ island.dataset.ready = "true";
306
+ });
307
+ }
308
+ const ro = new ResizeObserver(measure);
309
+ ro.observe(row);
310
+ ro.observe(inner);
311
+ function setExpanded(v) {
312
+ v = v && hasBody();
313
+ if (v === expanded) return;
314
+ expanded = v;
315
+ island.dataset.expanded = String(v);
316
+ size();
317
+ }
318
+ function clear() {
319
+ if (startedAt) {
320
+ remaining -= Date.now() - startedAt;
321
+ startedAt = 0;
322
+ }
323
+ clearTimeout(collapseT);
324
+ clearTimeout(dismissT);
325
+ }
326
+ function arm() {
327
+ clear();
328
+ if (!t || t.duration == null || paused()) return;
329
+ const id = t.id;
330
+ startedAt = Date.now();
331
+ collapseT = setTimeout(() => {
332
+ if (!pinned) setExpanded(false);
333
+ }, Math.max(0, remaining - 500));
334
+ dismissT = setTimeout(() => dynaura.dismiss(id), remaining);
335
+ }
336
+ function sync() {
337
+ island.dataset.paused = String(paused());
338
+ if (paused()) {
339
+ clear();
340
+ if (hovered || pinned) setExpanded(true);
341
+ } else arm();
342
+ }
343
+ function tick() {
344
+ var _a2;
345
+ if (!t || t.trailing != null) return;
346
+ if (t.progress != null) roll(trail, Math.round(t.progress * 100) + "%");
347
+ else if (t.type === "live" && ((_a2 = t.kind) != null ? _a2 : "timer") === "timer") {
348
+ const s = Math.floor((Date.now() - liveStart) / 1e3);
349
+ roll(trail, `${Math.floor(s / 60)}:${String(s % 60).padStart(2, "0")}`);
350
+ }
351
+ }
352
+ const hasTrail = (n) => {
353
+ var _a2;
354
+ return n.trailing != null || n.progress != null || n.type === "live" && ((_a2 = n.kind) != null ? _a2 : "timer") === "timer";
355
+ };
356
+ function apply(n, p) {
357
+ var _a2, _b, _c;
358
+ const ch = (k) => !p || n[k] !== p[k];
359
+ island.dataset.type = n.type;
360
+ island.dataset.variant = drag.dataset.variant = (_a2 = n.variant) != null ? _a2 : "default";
361
+ if (ch("type") || ch("icon") || ch("kind")) {
362
+ put(badge, void 0);
363
+ if (n.icon != null) put(badge, n.icon);
364
+ else badge.innerHTML = n.type === "live" ? ((_b = n.kind) != null ? _b : "timer") === "wave" ? WAVE : DOT : ICON[n.type];
365
+ restart(badge);
366
+ }
367
+ if (ch("title")) {
368
+ title.textContent = n.title;
369
+ restart(title);
370
+ }
371
+ if (ch("trailing") || ch("progress") || ch("type") || ch("kind")) {
372
+ trail.hidden = !hasTrail(n);
373
+ if (n.trailing != null) {
374
+ delete trail.dataset.sig;
375
+ trail.removeAttribute("aria-label");
376
+ put(trail, n.trailing);
377
+ } else if (!hasTrail(n)) {
378
+ delete trail.dataset.sig;
379
+ put(trail, void 0);
380
+ }
381
+ }
382
+ if (ch("description")) put(desc, n.description);
383
+ desc.hidden = n.description == null || typeof n.description === "boolean";
384
+ btn.hidden = !n.button;
385
+ if (n.button) btn.textContent = n.button.title;
386
+ body.hidden = !(n.description != null && typeof n.description !== "boolean") && !n.button;
387
+ bar.dataset.mode = n.progress != null ? "value" : n.duration != null ? "time" : "none";
388
+ bar.style.setProperty("--p", String((_c = n.progress) != null ? _c : 0));
389
+ }
390
+ function feedback(n) {
391
+ var _a2, _b;
392
+ const active = (_b = (_a2 = navigator.userActivation) == null ? void 0 : _a2.hasBeenActive) != null ? _b : true;
393
+ if (o.haptics && typeof navigator !== "undefined" && navigator.vibrate && active && VIBRATE[n.type].length) navigator.vibrate(VIBRATE[n.type]);
394
+ if (n.confetti && !matchMedia("(prefers-reduced-motion: reduce)").matches) {
395
+ requestAnimationFrame(() => {
396
+ const r = island.getBoundingClientRect();
397
+ burst(r.left + r.width / 2, r.top + r.height / 2, getComputedStyle(island).getPropertyValue("--state").trim() || "#30d158");
398
+ });
399
+ }
400
+ }
401
+ const onlyProgress = (p, n) => p.progress == null === (n.progress == null) && [.../* @__PURE__ */ new Set([...Object.keys(n), ...Object.keys(p)])].every((k) => k === "progress" || n[k] === p[k]);
402
+ function render() {
403
+ var _a2, _b, _c;
404
+ const n = getCurrent();
405
+ const p = t;
406
+ if (!n) {
407
+ if (p) leave();
408
+ return;
409
+ }
410
+ const same = !!p && p.id === n.id;
411
+ if (same && onlyProgress(p, n)) {
412
+ t = n;
413
+ bar.style.setProperty("--p", String((_a2 = n.progress) != null ? _a2 : 0));
414
+ tick();
415
+ return;
416
+ }
417
+ t = n;
418
+ clearTimeout(hideT);
419
+ if (island.hidden) {
420
+ island.hidden = false;
421
+ drag.style.transform = "";
422
+ drag.style.opacity = "";
423
+ restart(island);
424
+ }
425
+ island.dataset.open = "true";
426
+ if (!same) {
427
+ liveStart = Date.now();
428
+ pinned = false;
429
+ }
430
+ apply(n, same ? p : null);
431
+ measure();
432
+ if (!same || n.type !== p.type) feedback(n);
433
+ clearInterval(liveI);
434
+ if (n.type === "live") liveI = setInterval(tick, 1e3);
435
+ tick();
436
+ clear();
437
+ startedAt = 0;
438
+ remaining = (_b = n.duration) != null ? _b : 0;
439
+ restart(bar);
440
+ bar.style.animationDuration = ((_c = n.duration) != null ? _c : 0) + "ms";
441
+ if (!pinned) setExpanded(false);
442
+ clearTimeout(expandT);
443
+ if (hasBody()) expandT = setTimeout(() => setExpanded(true), 450);
444
+ sync();
445
+ }
446
+ function leave() {
447
+ clear();
448
+ startedAt = 0;
449
+ clearTimeout(expandT);
450
+ clearInterval(liveI);
451
+ hovered = pinned = dragging = false;
452
+ t = null;
453
+ island.dataset.open = "false";
454
+ hideT = setTimeout(() => {
455
+ cancelAnimationFrame(raf);
456
+ island.style.clipPath = "";
457
+ island.hidden = true;
458
+ ready = false;
459
+ expanded = false;
460
+ row.style.transform = "";
461
+ delete island.dataset.ready;
462
+ island.dataset.expanded = "false";
463
+ island.style.width = island.style.height = island.style.borderRadius = "";
464
+ [badge, trail, desc].forEach((s) => put(s, void 0));
465
+ delete trail.dataset.sig;
466
+ }, 450);
467
+ }
468
+ btn.onclick = () => {
469
+ const c = t;
470
+ if (c == null ? void 0 : c.button) {
471
+ c.button.onClick();
472
+ dynaura.dismiss(c.id);
473
+ }
474
+ };
475
+ let sy = 0, t0 = 0, moved = false, longed = false;
476
+ island.addEventListener("pointerenter", (e) => {
477
+ if (e.pointerType === "mouse") {
478
+ hovered = true;
479
+ sync();
480
+ }
481
+ });
482
+ island.addEventListener("pointerleave", (e) => {
483
+ if (e.pointerType !== "mouse") return;
484
+ hovered = false;
485
+ if (!pinned) setExpanded(false);
486
+ sync();
487
+ });
488
+ drag.addEventListener("pointerdown", (e) => {
489
+ var _a2;
490
+ if (!t || e.target.closest("button")) return;
491
+ dragging = true;
492
+ moved = longed = false;
493
+ sy = e.clientY;
494
+ t0 = Date.now();
495
+ (_a2 = drag.setPointerCapture) == null ? void 0 : _a2.call(drag, e.pointerId);
496
+ drag.style.transition = "none";
497
+ lp = setTimeout(() => {
498
+ var _a3;
499
+ if (!moved) {
500
+ longed = true;
501
+ pinned = true;
502
+ if (o.haptics) (_a3 = navigator.vibrate) == null ? void 0 : _a3.call(navigator, 8);
503
+ sync();
504
+ }
505
+ }, 450);
506
+ sync();
507
+ });
508
+ drag.addEventListener("pointermove", (e) => {
509
+ if (!dragging) return;
510
+ const dy = e.clientY - sy;
511
+ if (Math.abs(dy) > 6) {
512
+ moved = true;
513
+ clearTimeout(lp);
514
+ }
515
+ if (!moved) return;
516
+ const d = dy * dir();
517
+ const off = d > 0 ? d : -Math.sqrt(-d) * 4;
518
+ drag.style.transform = `translateY(${off * dir()}px)`;
519
+ });
520
+ const up = (e) => {
521
+ if (!dragging) return;
522
+ dragging = false;
523
+ clearTimeout(lp);
524
+ drag.style.transition = "";
525
+ const d = (e.clientY - sy) * dir();
526
+ const v = d / Math.max(1, Date.now() - t0);
527
+ if (e.type === "pointerup" && moved && (d > 40 || v > 0.5 && d > 10) && t) {
528
+ dynaura.dismiss(t.id);
529
+ return;
530
+ }
531
+ drag.style.transform = "";
532
+ if (e.type === "pointerup" && !moved && !longed && hasBody()) {
533
+ pinned = !pinned;
534
+ if (!pinned && !hovered) setExpanded(false);
535
+ }
536
+ sync();
537
+ };
538
+ drag.addEventListener("pointerup", up);
539
+ drag.addEventListener("pointercancel", up);
540
+ const outside = (e) => {
541
+ if (pinned && !island.contains(e.target)) {
542
+ pinned = false;
543
+ if (!hovered) setExpanded(false);
544
+ sync();
545
+ }
546
+ };
547
+ document.addEventListener("pointerdown", outside);
548
+ function set2(n) {
549
+ merge(n);
550
+ setQueue(o.queue);
551
+ const [y, x = "center"] = o.position.split("-");
552
+ root.dataset.y = y;
553
+ root.dataset.x = x;
554
+ root.dataset.timer = String(o.timer);
555
+ root.dataset.theme = typeof o.theme === "object" ? "custom" : o.theme;
556
+ root.style.setProperty("--dynaura-offset", o.offset + "px");
557
+ applied.forEach((v) => root.style.removeProperty(v));
558
+ applied = [];
559
+ if (typeof o.theme === "object")
560
+ for (const k in o.theme) {
561
+ const v = `--dynaura-${VAR[k]}`;
562
+ root.style.setProperty(v, o.theme[k]);
563
+ applied.push(v);
564
+ }
565
+ }
566
+ set2({});
567
+ const unsub = subscribe(render);
568
+ render();
569
+ return {
570
+ set: set2,
571
+ destroy() {
572
+ unsub();
573
+ ro.disconnect();
574
+ cancelAnimationFrame(raf);
575
+ document.removeEventListener("pointerdown", outside);
576
+ clear();
577
+ [hideT, expandT, liveI, lp].forEach((x) => {
578
+ clearTimeout(x);
579
+ clearInterval(x);
580
+ });
581
+ [badge, trail, desc].forEach((s) => put(s, void 0));
582
+ root.remove();
583
+ }
584
+ };
585
+ }
586
+
587
+ // src/vue.ts
588
+ var clean = (p) => Object.fromEntries(Object.entries(p).filter(([, v]) => v !== void 0));
589
+ var Toaster = (0, import_vue.defineComponent)({
590
+ name: "DynauraToaster",
591
+ props: {
592
+ position: String,
593
+ offset: Number,
594
+ theme: [String, Object],
595
+ timer: { type: Boolean, default: void 0 },
596
+ haptics: { type: Boolean, default: void 0 },
597
+ queue: { type: Boolean, default: void 0 }
598
+ },
599
+ setup(props) {
600
+ let c;
601
+ (0, import_vue.onMounted)(() => {
602
+ c = createToaster(clean({ ...props }));
603
+ });
604
+ (0, import_vue.watch)(() => ({ ...props }), (p) => c == null ? void 0 : c.set(clean(p)), { deep: true });
605
+ (0, import_vue.onBeforeUnmount)(() => c == null ? void 0 : c.destroy());
606
+ return () => null;
607
+ }
608
+ });
609
+ // Annotate the CommonJS export names for ESM import in node:
610
+ 0 && (module.exports = {
611
+ Toaster,
612
+ dynaura
613
+ });
package/dist/vue.d.cts ADDED
@@ -0,0 +1,43 @@
1
+ import * as vue from 'vue';
2
+ export { CustomTheme, Position, ToasterOptions, dynaura } from './vanilla.cjs';
3
+
4
+ /** <Toaster position="top" theme="system" /> — mount once. Content is string or DOM Node. */
5
+ declare const Toaster: vue.DefineComponent<vue.ExtractPropTypes<{
6
+ position: StringConstructor;
7
+ offset: NumberConstructor;
8
+ theme: (StringConstructor | ObjectConstructor)[];
9
+ timer: {
10
+ type: BooleanConstructor;
11
+ default: undefined;
12
+ };
13
+ haptics: {
14
+ type: BooleanConstructor;
15
+ default: undefined;
16
+ };
17
+ queue: {
18
+ type: BooleanConstructor;
19
+ default: undefined;
20
+ };
21
+ }>, () => null, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
22
+ position: StringConstructor;
23
+ offset: NumberConstructor;
24
+ theme: (StringConstructor | ObjectConstructor)[];
25
+ timer: {
26
+ type: BooleanConstructor;
27
+ default: undefined;
28
+ };
29
+ haptics: {
30
+ type: BooleanConstructor;
31
+ default: undefined;
32
+ };
33
+ queue: {
34
+ type: BooleanConstructor;
35
+ default: undefined;
36
+ };
37
+ }>> & Readonly<{}>, {
38
+ timer: boolean;
39
+ queue: boolean;
40
+ haptics: boolean;
41
+ }, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
42
+
43
+ export { Toaster };
package/dist/vue.d.ts ADDED
@@ -0,0 +1,43 @@
1
+ import * as vue from 'vue';
2
+ export { CustomTheme, Position, ToasterOptions, dynaura } from './vanilla.js';
3
+
4
+ /** <Toaster position="top" theme="system" /> — mount once. Content is string or DOM Node. */
5
+ declare const Toaster: vue.DefineComponent<vue.ExtractPropTypes<{
6
+ position: StringConstructor;
7
+ offset: NumberConstructor;
8
+ theme: (StringConstructor | ObjectConstructor)[];
9
+ timer: {
10
+ type: BooleanConstructor;
11
+ default: undefined;
12
+ };
13
+ haptics: {
14
+ type: BooleanConstructor;
15
+ default: undefined;
16
+ };
17
+ queue: {
18
+ type: BooleanConstructor;
19
+ default: undefined;
20
+ };
21
+ }>, () => null, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
22
+ position: StringConstructor;
23
+ offset: NumberConstructor;
24
+ theme: (StringConstructor | ObjectConstructor)[];
25
+ timer: {
26
+ type: BooleanConstructor;
27
+ default: undefined;
28
+ };
29
+ haptics: {
30
+ type: BooleanConstructor;
31
+ default: undefined;
32
+ };
33
+ queue: {
34
+ type: BooleanConstructor;
35
+ default: undefined;
36
+ };
37
+ }>> & Readonly<{}>, {
38
+ timer: boolean;
39
+ queue: boolean;
40
+ haptics: boolean;
41
+ }, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
42
+
43
+ export { Toaster };