@zag-js/toast 0.2.9 → 0.2.11
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/{chunk-LN72PBJ5.mjs → chunk-AZ32UDL3.mjs} +5 -21
- package/dist/{chunk-2Q3XCA25.mjs → chunk-GKMHTDAP.mjs} +1 -1
- package/dist/{chunk-MD6LFB2J.mjs → chunk-GQHI2OMI.mjs} +0 -0
- package/dist/{chunk-FL23ZLLA.mjs → chunk-HDTOIF42.mjs} +3 -4
- package/dist/{chunk-PIVIE75R.mjs → chunk-HRZITBY3.mjs} +5 -16
- package/dist/{chunk-6HWLSJDV.mjs → chunk-LHAZKBRJ.mjs} +1 -1
- package/dist/{chunk-5IFVCHQS.mjs → chunk-SSV22S55.mjs} +12 -25
- package/dist/{chunk-FBM2PYRD.mjs → chunk-XQSCE3HI.mjs} +1 -1
- package/dist/index.js +19 -60
- package/dist/index.mjs +9 -9
- package/dist/toast-group.connect.d.ts +0 -1
- package/dist/toast-group.connect.js +7 -34
- package/dist/toast-group.connect.mjs +5 -5
- package/dist/toast-group.machine.js +16 -45
- package/dist/toast-group.machine.mjs +5 -5
- package/dist/toast.anatomy.mjs +1 -1
- package/dist/toast.connect.js +6 -23
- package/dist/toast.connect.mjs +3 -3
- package/dist/toast.dom.d.ts +0 -2
- package/dist/toast.dom.js +5 -21
- package/dist/toast.dom.mjs +1 -1
- package/dist/toast.machine.js +16 -45
- package/dist/toast.machine.mjs +4 -4
- package/dist/toast.utils.js +1 -1
- package/dist/toast.utils.mjs +1 -1
- package/package.json +6 -6
|
@@ -3,27 +3,20 @@ function isDocument(el) {
|
|
|
3
3
|
return el.nodeType === Node.DOCUMENT_NODE;
|
|
4
4
|
}
|
|
5
5
|
function isWindow(value) {
|
|
6
|
-
return
|
|
6
|
+
return value?.toString() === "[object Window]";
|
|
7
7
|
}
|
|
8
8
|
function getDocument(el) {
|
|
9
|
-
var _a;
|
|
10
9
|
if (isWindow(el))
|
|
11
10
|
return el.document;
|
|
12
11
|
if (isDocument(el))
|
|
13
12
|
return el;
|
|
14
|
-
return
|
|
13
|
+
return el?.ownerDocument ?? document;
|
|
15
14
|
}
|
|
16
15
|
function defineDomHelpers(helpers) {
|
|
17
16
|
const dom2 = {
|
|
18
|
-
getRootNode: (ctx) =>
|
|
19
|
-
var _a, _b;
|
|
20
|
-
return (_b = (_a = ctx.getRootNode) == null ? void 0 : _a.call(ctx)) != null ? _b : document;
|
|
21
|
-
},
|
|
17
|
+
getRootNode: (ctx) => ctx.getRootNode?.() ?? document,
|
|
22
18
|
getDoc: (ctx) => getDocument(dom2.getRootNode(ctx)),
|
|
23
|
-
getWin: (ctx) =>
|
|
24
|
-
var _a;
|
|
25
|
-
return (_a = dom2.getDoc(ctx).defaultView) != null ? _a : window;
|
|
26
|
-
},
|
|
19
|
+
getWin: (ctx) => dom2.getDoc(ctx).defaultView ?? window,
|
|
27
20
|
getActiveElement: (ctx) => dom2.getDoc(ctx).activeElement,
|
|
28
21
|
getById: (ctx, id) => dom2.getRootNode(ctx).getElementById(id)
|
|
29
22
|
};
|
|
@@ -40,16 +33,7 @@ var dom = defineDomHelpers({
|
|
|
40
33
|
getTitleId: (ctx) => `toast:${ctx.id}:title`,
|
|
41
34
|
getDescriptionId: (ctx) => `toast:${ctx.id}:description`,
|
|
42
35
|
getCloseTriggerId: (ctx) => `toast${ctx.id}:close`,
|
|
43
|
-
getPortalId: (ctx) => `toast-portal:${ctx.id}
|
|
44
|
-
getPortalEl: (ctx) => dom.getDoc(ctx).getElementById(dom.getPortalId(ctx)),
|
|
45
|
-
createPortalEl: (ctx) => {
|
|
46
|
-
const existing = dom.getPortalEl(ctx);
|
|
47
|
-
if (existing)
|
|
48
|
-
return existing;
|
|
49
|
-
const portal = dom.getDoc(ctx).createElement("toast-portal");
|
|
50
|
-
portal.id = dom.getPortalId(ctx);
|
|
51
|
-
return portal;
|
|
52
|
-
}
|
|
36
|
+
getPortalId: (ctx) => `toast-portal:${ctx.id}`
|
|
53
37
|
});
|
|
54
38
|
|
|
55
39
|
export {
|
|
File without changes
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
parts
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-GQHI2OMI.mjs";
|
|
4
4
|
import {
|
|
5
5
|
dom
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-AZ32UDL3.mjs";
|
|
7
7
|
|
|
8
8
|
// ../../utilities/dom/src/attrs.ts
|
|
9
9
|
var dataAttr = (guard) => {
|
|
@@ -95,8 +95,7 @@ function connect(state, send, normalize) {
|
|
|
95
95
|
}
|
|
96
96
|
}),
|
|
97
97
|
render() {
|
|
98
|
-
|
|
99
|
-
return (_b = (_a = state.context).render) == null ? void 0 : _b.call(_a, {
|
|
98
|
+
return state.context.render?.({
|
|
100
99
|
id: state.context.id,
|
|
101
100
|
type: state.context.type,
|
|
102
101
|
duration: state.context.duration,
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import {
|
|
2
2
|
parts
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-GQHI2OMI.mjs";
|
|
4
4
|
import {
|
|
5
5
|
runIfFn,
|
|
6
6
|
uuid
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-LHAZKBRJ.mjs";
|
|
8
8
|
import {
|
|
9
9
|
getGroupPlacementStyle,
|
|
10
10
|
getToastsByPlacement
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-XQSCE3HI.mjs";
|
|
12
12
|
import {
|
|
13
13
|
dom
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-AZ32UDL3.mjs";
|
|
15
15
|
|
|
16
16
|
// src/toast-group.connect.ts
|
|
17
17
|
import { subscribe } from "@zag-js/core";
|
|
@@ -119,22 +119,11 @@ function groupConnect(state, send, normalize) {
|
|
|
119
119
|
style: getGroupPlacementStyle(state.context, placement)
|
|
120
120
|
});
|
|
121
121
|
},
|
|
122
|
-
createPortal() {
|
|
123
|
-
const doc = dom.getDoc(state.context);
|
|
124
|
-
const exist = dom.getPortalEl(state.context);
|
|
125
|
-
if (exist)
|
|
126
|
-
return exist;
|
|
127
|
-
const portal = dom.createPortalEl(state.context);
|
|
128
|
-
doc.body.appendChild(portal);
|
|
129
|
-
return portal;
|
|
130
|
-
},
|
|
131
122
|
subscribe(fn) {
|
|
132
123
|
return subscribe(state.context.toasts, () => fn(state.context.toasts));
|
|
133
124
|
}
|
|
134
125
|
};
|
|
135
|
-
|
|
136
|
-
Object.assign(toaster, group);
|
|
137
|
-
}
|
|
126
|
+
Object.assign(toaster, group);
|
|
138
127
|
return group;
|
|
139
128
|
}
|
|
140
129
|
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
cast,
|
|
3
3
|
runIfFn
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-LHAZKBRJ.mjs";
|
|
5
5
|
import {
|
|
6
6
|
getToastDuration
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-XQSCE3HI.mjs";
|
|
8
8
|
import {
|
|
9
9
|
dom
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-AZ32UDL3.mjs";
|
|
11
11
|
|
|
12
12
|
// src/toast.machine.ts
|
|
13
13
|
import { createMachine, guards } from "@zag-js/core";
|
|
@@ -30,9 +30,9 @@ function compact(obj) {
|
|
|
30
30
|
var isRef = (v) => hasProp(v, "current");
|
|
31
31
|
function addDomEvent(target, eventName, handler, options) {
|
|
32
32
|
const node = isRef(target) ? target.current : runIfFn(target);
|
|
33
|
-
node
|
|
33
|
+
node?.addEventListener(eventName, handler, options);
|
|
34
34
|
return () => {
|
|
35
|
-
node
|
|
35
|
+
node?.removeEventListener(eventName, handler, options);
|
|
36
36
|
};
|
|
37
37
|
}
|
|
38
38
|
|
|
@@ -142,19 +142,10 @@ function createToastMachine(options = {}) {
|
|
|
142
142
|
}
|
|
143
143
|
},
|
|
144
144
|
guards: {
|
|
145
|
-
isChangingToLoading: (_, evt) =>
|
|
146
|
-
var _a;
|
|
147
|
-
return ((_a = evt.toast) == null ? void 0 : _a.type) === "loading";
|
|
148
|
-
},
|
|
145
|
+
isChangingToLoading: (_, evt) => evt.toast?.type === "loading",
|
|
149
146
|
isLoadingType: (ctx2) => ctx2.type === "loading",
|
|
150
|
-
hasTypeChanged: (ctx2, evt) =>
|
|
151
|
-
|
|
152
|
-
return ((_a = evt.toast) == null ? void 0 : _a.type) !== ctx2.type;
|
|
153
|
-
},
|
|
154
|
-
hasDurationChanged: (ctx2, evt) => {
|
|
155
|
-
var _a;
|
|
156
|
-
return ((_a = evt.toast) == null ? void 0 : _a.duration) !== ctx2.duration;
|
|
157
|
-
}
|
|
147
|
+
hasTypeChanged: (ctx2, evt) => evt.toast?.type !== ctx2.type,
|
|
148
|
+
hasDurationChanged: (ctx2, evt) => evt.toast?.duration !== ctx2.duration
|
|
158
149
|
},
|
|
159
150
|
delays: {
|
|
160
151
|
VISIBLE_DURATION: (ctx2) => ctx2.remaining,
|
|
@@ -171,20 +162,16 @@ function createToastMachine(options = {}) {
|
|
|
171
162
|
self.sendParent({ type: "REMOVE_TOAST", id: self.id });
|
|
172
163
|
},
|
|
173
164
|
invokeOnClosing(ctx2) {
|
|
174
|
-
|
|
175
|
-
(_a = ctx2.onClosing) == null ? void 0 : _a.call(ctx2);
|
|
165
|
+
ctx2.onClosing?.();
|
|
176
166
|
},
|
|
177
167
|
invokeOnClose(ctx2) {
|
|
178
|
-
|
|
179
|
-
(_a = ctx2.onClose) == null ? void 0 : _a.call(ctx2);
|
|
168
|
+
ctx2.onClose?.();
|
|
180
169
|
},
|
|
181
170
|
invokeOnOpen(ctx2) {
|
|
182
|
-
|
|
183
|
-
(_a = ctx2.onOpen) == null ? void 0 : _a.call(ctx2);
|
|
171
|
+
ctx2.onOpen?.();
|
|
184
172
|
},
|
|
185
173
|
invokeOnUpdate(ctx2) {
|
|
186
|
-
|
|
187
|
-
(_a = ctx2.onUpdate) == null ? void 0 : _a.call(ctx2);
|
|
174
|
+
ctx2.onUpdate?.();
|
|
188
175
|
},
|
|
189
176
|
setContext(ctx2, evt) {
|
|
190
177
|
const { duration: duration2, type: type2 } = evt.toast;
|
|
@@ -16,7 +16,7 @@ var defaultTimeouts = {
|
|
|
16
16
|
custom: 5e3
|
|
17
17
|
};
|
|
18
18
|
function getToastDuration(duration, type) {
|
|
19
|
-
return duration
|
|
19
|
+
return duration ?? defaultTimeouts[type];
|
|
20
20
|
}
|
|
21
21
|
function getGroupPlacementStyle(ctx, placement) {
|
|
22
22
|
const offset = ctx.offsets;
|
package/dist/index.js
CHANGED
|
@@ -39,7 +39,7 @@ var MAX_Z_INDEX = 2147483647;
|
|
|
39
39
|
// ../../utilities/core/src/functions.ts
|
|
40
40
|
var runIfFn = (v, ...a) => {
|
|
41
41
|
const res = typeof v === "function" ? v(...a) : v;
|
|
42
|
-
return res
|
|
42
|
+
return res ?? void 0;
|
|
43
43
|
};
|
|
44
44
|
var cast = (v) => v;
|
|
45
45
|
var uuid = /* @__PURE__ */ (() => {
|
|
@@ -68,7 +68,7 @@ function compact(obj) {
|
|
|
68
68
|
function warn(...a) {
|
|
69
69
|
const m = a.length === 1 ? a[0] : a[1];
|
|
70
70
|
const c = a.length === 2 ? a[0] : true;
|
|
71
|
-
if (c &&
|
|
71
|
+
if (c && process.env.NODE_ENV !== "production") {
|
|
72
72
|
console.warn(m);
|
|
73
73
|
}
|
|
74
74
|
}
|
|
@@ -81,27 +81,20 @@ function isDocument(el) {
|
|
|
81
81
|
return el.nodeType === Node.DOCUMENT_NODE;
|
|
82
82
|
}
|
|
83
83
|
function isWindow(value) {
|
|
84
|
-
return
|
|
84
|
+
return value?.toString() === "[object Window]";
|
|
85
85
|
}
|
|
86
86
|
function getDocument(el) {
|
|
87
|
-
var _a;
|
|
88
87
|
if (isWindow(el))
|
|
89
88
|
return el.document;
|
|
90
89
|
if (isDocument(el))
|
|
91
90
|
return el;
|
|
92
|
-
return
|
|
91
|
+
return el?.ownerDocument ?? document;
|
|
93
92
|
}
|
|
94
93
|
function defineDomHelpers(helpers) {
|
|
95
94
|
const dom2 = {
|
|
96
|
-
getRootNode: (ctx) =>
|
|
97
|
-
var _a, _b;
|
|
98
|
-
return (_b = (_a = ctx.getRootNode) == null ? void 0 : _a.call(ctx)) != null ? _b : document;
|
|
99
|
-
},
|
|
95
|
+
getRootNode: (ctx) => ctx.getRootNode?.() ?? document,
|
|
100
96
|
getDoc: (ctx) => getDocument(dom2.getRootNode(ctx)),
|
|
101
|
-
getWin: (ctx) =>
|
|
102
|
-
var _a;
|
|
103
|
-
return (_a = dom2.getDoc(ctx).defaultView) != null ? _a : window;
|
|
104
|
-
},
|
|
97
|
+
getWin: (ctx) => dom2.getDoc(ctx).defaultView ?? window,
|
|
105
98
|
getActiveElement: (ctx) => dom2.getDoc(ctx).activeElement,
|
|
106
99
|
getById: (ctx, id) => dom2.getRootNode(ctx).getElementById(id)
|
|
107
100
|
};
|
|
@@ -115,9 +108,9 @@ function defineDomHelpers(helpers) {
|
|
|
115
108
|
var isRef = (v) => hasProp(v, "current");
|
|
116
109
|
function addDomEvent(target, eventName, handler, options) {
|
|
117
110
|
const node = isRef(target) ? target.current : runIfFn(target);
|
|
118
|
-
node
|
|
111
|
+
node?.addEventListener(eventName, handler, options);
|
|
119
112
|
return () => {
|
|
120
|
-
node
|
|
113
|
+
node?.removeEventListener(eventName, handler, options);
|
|
121
114
|
};
|
|
122
115
|
}
|
|
123
116
|
|
|
@@ -145,16 +138,7 @@ var dom = defineDomHelpers({
|
|
|
145
138
|
getTitleId: (ctx) => `toast:${ctx.id}:title`,
|
|
146
139
|
getDescriptionId: (ctx) => `toast:${ctx.id}:description`,
|
|
147
140
|
getCloseTriggerId: (ctx) => `toast${ctx.id}:close`,
|
|
148
|
-
getPortalId: (ctx) => `toast-portal:${ctx.id}
|
|
149
|
-
getPortalEl: (ctx) => dom.getDoc(ctx).getElementById(dom.getPortalId(ctx)),
|
|
150
|
-
createPortalEl: (ctx) => {
|
|
151
|
-
const existing = dom.getPortalEl(ctx);
|
|
152
|
-
if (existing)
|
|
153
|
-
return existing;
|
|
154
|
-
const portal = dom.getDoc(ctx).createElement("toast-portal");
|
|
155
|
-
portal.id = dom.getPortalId(ctx);
|
|
156
|
-
return portal;
|
|
157
|
-
}
|
|
141
|
+
getPortalId: (ctx) => `toast-portal:${ctx.id}`
|
|
158
142
|
});
|
|
159
143
|
|
|
160
144
|
// src/toast.utils.ts
|
|
@@ -175,7 +159,7 @@ var defaultTimeouts = {
|
|
|
175
159
|
custom: 5e3
|
|
176
160
|
};
|
|
177
161
|
function getToastDuration(duration, type) {
|
|
178
|
-
return duration
|
|
162
|
+
return duration ?? defaultTimeouts[type];
|
|
179
163
|
}
|
|
180
164
|
function getGroupPlacementStyle(ctx, placement) {
|
|
181
165
|
const offset = ctx.offsets;
|
|
@@ -322,22 +306,11 @@ function groupConnect(state, send, normalize) {
|
|
|
322
306
|
style: getGroupPlacementStyle(state.context, placement)
|
|
323
307
|
});
|
|
324
308
|
},
|
|
325
|
-
createPortal() {
|
|
326
|
-
const doc = dom.getDoc(state.context);
|
|
327
|
-
const exist = dom.getPortalEl(state.context);
|
|
328
|
-
if (exist)
|
|
329
|
-
return exist;
|
|
330
|
-
const portal = dom.createPortalEl(state.context);
|
|
331
|
-
doc.body.appendChild(portal);
|
|
332
|
-
return portal;
|
|
333
|
-
},
|
|
334
309
|
subscribe(fn) {
|
|
335
310
|
return (0, import_core.subscribe)(state.context.toasts, () => fn(state.context.toasts));
|
|
336
311
|
}
|
|
337
312
|
};
|
|
338
|
-
|
|
339
|
-
Object.assign(toaster, group2);
|
|
340
|
-
}
|
|
313
|
+
Object.assign(toaster, group2);
|
|
341
314
|
return group2;
|
|
342
315
|
}
|
|
343
316
|
|
|
@@ -442,19 +415,10 @@ function createToastMachine(options = {}) {
|
|
|
442
415
|
}
|
|
443
416
|
},
|
|
444
417
|
guards: {
|
|
445
|
-
isChangingToLoading: (_, evt) =>
|
|
446
|
-
var _a;
|
|
447
|
-
return ((_a = evt.toast) == null ? void 0 : _a.type) === "loading";
|
|
448
|
-
},
|
|
418
|
+
isChangingToLoading: (_, evt) => evt.toast?.type === "loading",
|
|
449
419
|
isLoadingType: (ctx2) => ctx2.type === "loading",
|
|
450
|
-
hasTypeChanged: (ctx2, evt) =>
|
|
451
|
-
|
|
452
|
-
return ((_a = evt.toast) == null ? void 0 : _a.type) !== ctx2.type;
|
|
453
|
-
},
|
|
454
|
-
hasDurationChanged: (ctx2, evt) => {
|
|
455
|
-
var _a;
|
|
456
|
-
return ((_a = evt.toast) == null ? void 0 : _a.duration) !== ctx2.duration;
|
|
457
|
-
}
|
|
420
|
+
hasTypeChanged: (ctx2, evt) => evt.toast?.type !== ctx2.type,
|
|
421
|
+
hasDurationChanged: (ctx2, evt) => evt.toast?.duration !== ctx2.duration
|
|
458
422
|
},
|
|
459
423
|
delays: {
|
|
460
424
|
VISIBLE_DURATION: (ctx2) => ctx2.remaining,
|
|
@@ -471,20 +435,16 @@ function createToastMachine(options = {}) {
|
|
|
471
435
|
self.sendParent({ type: "REMOVE_TOAST", id: self.id });
|
|
472
436
|
},
|
|
473
437
|
invokeOnClosing(ctx2) {
|
|
474
|
-
|
|
475
|
-
(_a = ctx2.onClosing) == null ? void 0 : _a.call(ctx2);
|
|
438
|
+
ctx2.onClosing?.();
|
|
476
439
|
},
|
|
477
440
|
invokeOnClose(ctx2) {
|
|
478
|
-
|
|
479
|
-
(_a = ctx2.onClose) == null ? void 0 : _a.call(ctx2);
|
|
441
|
+
ctx2.onClose?.();
|
|
480
442
|
},
|
|
481
443
|
invokeOnOpen(ctx2) {
|
|
482
|
-
|
|
483
|
-
(_a = ctx2.onOpen) == null ? void 0 : _a.call(ctx2);
|
|
444
|
+
ctx2.onOpen?.();
|
|
484
445
|
},
|
|
485
446
|
invokeOnUpdate(ctx2) {
|
|
486
|
-
|
|
487
|
-
(_a = ctx2.onUpdate) == null ? void 0 : _a.call(ctx2);
|
|
447
|
+
ctx2.onUpdate?.();
|
|
488
448
|
},
|
|
489
449
|
setContext(ctx2, evt) {
|
|
490
450
|
const { duration: duration2, type: type2 } = evt.toast;
|
|
@@ -671,8 +631,7 @@ function connect(state, send, normalize) {
|
|
|
671
631
|
}
|
|
672
632
|
}),
|
|
673
633
|
render() {
|
|
674
|
-
|
|
675
|
-
return (_b = (_a = state.context).render) == null ? void 0 : _b.call(_a, {
|
|
634
|
+
return state.context.render?.({
|
|
676
635
|
id: state.context.id,
|
|
677
636
|
type: state.context.type,
|
|
678
637
|
duration: state.context.duration,
|
package/dist/index.mjs
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
import {
|
|
2
2
|
groupConnect,
|
|
3
3
|
toaster
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-HRZITBY3.mjs";
|
|
5
5
|
import {
|
|
6
6
|
groupMachine
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-GKMHTDAP.mjs";
|
|
8
8
|
import {
|
|
9
9
|
connect
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-HDTOIF42.mjs";
|
|
11
11
|
import {
|
|
12
12
|
anatomy
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-GQHI2OMI.mjs";
|
|
14
14
|
import {
|
|
15
15
|
createToastMachine
|
|
16
|
-
} from "./chunk-
|
|
17
|
-
import "./chunk-
|
|
18
|
-
import "./chunk-
|
|
19
|
-
import "./chunk-
|
|
16
|
+
} from "./chunk-SSV22S55.mjs";
|
|
17
|
+
import "./chunk-LHAZKBRJ.mjs";
|
|
18
|
+
import "./chunk-XQSCE3HI.mjs";
|
|
19
|
+
import "./chunk-AZ32UDL3.mjs";
|
|
20
20
|
|
|
21
21
|
// ../../utilities/core/src/warning.ts
|
|
22
22
|
function warn(...a) {
|
|
23
23
|
const m = a.length === 1 ? a[0] : a[1];
|
|
24
24
|
const c = a.length === 2 ? a[0] : true;
|
|
25
|
-
if (c &&
|
|
25
|
+
if (c && process.env.NODE_ENV !== "production") {
|
|
26
26
|
console.warn(m);
|
|
27
27
|
}
|
|
28
28
|
}
|
|
@@ -21,7 +21,6 @@ declare function groupConnect<T extends PropTypes>(state: GroupState, send: Grou
|
|
|
21
21
|
pause(id?: string): void;
|
|
22
22
|
resume(id?: string): void;
|
|
23
23
|
getGroupProps(options: GroupProps): T["element"];
|
|
24
|
-
createPortal(): HTMLElement;
|
|
25
24
|
subscribe(fn: (toasts: GroupMachineContext["toasts"]) => void): () => void;
|
|
26
25
|
};
|
|
27
26
|
|
|
@@ -29,7 +29,7 @@ var import_core = require("@zag-js/core");
|
|
|
29
29
|
// ../../utilities/core/src/functions.ts
|
|
30
30
|
var runIfFn = (v, ...a) => {
|
|
31
31
|
const res = typeof v === "function" ? v(...a) : v;
|
|
32
|
-
return res
|
|
32
|
+
return res ?? void 0;
|
|
33
33
|
};
|
|
34
34
|
var uuid = /* @__PURE__ */ (() => {
|
|
35
35
|
let id = 0;
|
|
@@ -49,27 +49,20 @@ function isDocument(el) {
|
|
|
49
49
|
return el.nodeType === Node.DOCUMENT_NODE;
|
|
50
50
|
}
|
|
51
51
|
function isWindow(value) {
|
|
52
|
-
return
|
|
52
|
+
return value?.toString() === "[object Window]";
|
|
53
53
|
}
|
|
54
54
|
function getDocument(el) {
|
|
55
|
-
var _a;
|
|
56
55
|
if (isWindow(el))
|
|
57
56
|
return el.document;
|
|
58
57
|
if (isDocument(el))
|
|
59
58
|
return el;
|
|
60
|
-
return
|
|
59
|
+
return el?.ownerDocument ?? document;
|
|
61
60
|
}
|
|
62
61
|
function defineDomHelpers(helpers) {
|
|
63
62
|
const dom2 = {
|
|
64
|
-
getRootNode: (ctx) =>
|
|
65
|
-
var _a, _b;
|
|
66
|
-
return (_b = (_a = ctx.getRootNode) == null ? void 0 : _a.call(ctx)) != null ? _b : document;
|
|
67
|
-
},
|
|
63
|
+
getRootNode: (ctx) => ctx.getRootNode?.() ?? document,
|
|
68
64
|
getDoc: (ctx) => getDocument(dom2.getRootNode(ctx)),
|
|
69
|
-
getWin: (ctx) =>
|
|
70
|
-
var _a;
|
|
71
|
-
return (_a = dom2.getDoc(ctx).defaultView) != null ? _a : window;
|
|
72
|
-
},
|
|
65
|
+
getWin: (ctx) => dom2.getDoc(ctx).defaultView ?? window,
|
|
73
66
|
getActiveElement: (ctx) => dom2.getDoc(ctx).activeElement,
|
|
74
67
|
getById: (ctx, id) => dom2.getRootNode(ctx).getElementById(id)
|
|
75
68
|
};
|
|
@@ -86,16 +79,7 @@ var dom = defineDomHelpers({
|
|
|
86
79
|
getTitleId: (ctx) => `toast:${ctx.id}:title`,
|
|
87
80
|
getDescriptionId: (ctx) => `toast:${ctx.id}:description`,
|
|
88
81
|
getCloseTriggerId: (ctx) => `toast${ctx.id}:close`,
|
|
89
|
-
getPortalId: (ctx) => `toast-portal:${ctx.id}
|
|
90
|
-
getPortalEl: (ctx) => dom.getDoc(ctx).getElementById(dom.getPortalId(ctx)),
|
|
91
|
-
createPortalEl: (ctx) => {
|
|
92
|
-
const existing = dom.getPortalEl(ctx);
|
|
93
|
-
if (existing)
|
|
94
|
-
return existing;
|
|
95
|
-
const portal = dom.getDoc(ctx).createElement("toast-portal");
|
|
96
|
-
portal.id = dom.getPortalId(ctx);
|
|
97
|
-
return portal;
|
|
98
|
-
}
|
|
82
|
+
getPortalId: (ctx) => `toast-portal:${ctx.id}`
|
|
99
83
|
});
|
|
100
84
|
|
|
101
85
|
// src/toast.utils.ts
|
|
@@ -253,22 +237,11 @@ function groupConnect(state, send, normalize) {
|
|
|
253
237
|
style: getGroupPlacementStyle(state.context, placement)
|
|
254
238
|
});
|
|
255
239
|
},
|
|
256
|
-
createPortal() {
|
|
257
|
-
const doc = dom.getDoc(state.context);
|
|
258
|
-
const exist = dom.getPortalEl(state.context);
|
|
259
|
-
if (exist)
|
|
260
|
-
return exist;
|
|
261
|
-
const portal = dom.createPortalEl(state.context);
|
|
262
|
-
doc.body.appendChild(portal);
|
|
263
|
-
return portal;
|
|
264
|
-
},
|
|
265
240
|
subscribe(fn) {
|
|
266
241
|
return (0, import_core.subscribe)(state.context.toasts, () => fn(state.context.toasts));
|
|
267
242
|
}
|
|
268
243
|
};
|
|
269
|
-
|
|
270
|
-
Object.assign(toaster, group);
|
|
271
|
-
}
|
|
244
|
+
Object.assign(toaster, group);
|
|
272
245
|
return group;
|
|
273
246
|
}
|
|
274
247
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
groupConnect,
|
|
3
3
|
toaster
|
|
4
|
-
} from "./chunk-
|
|
5
|
-
import "./chunk-
|
|
6
|
-
import "./chunk-
|
|
7
|
-
import "./chunk-
|
|
8
|
-
import "./chunk-
|
|
4
|
+
} from "./chunk-HRZITBY3.mjs";
|
|
5
|
+
import "./chunk-GQHI2OMI.mjs";
|
|
6
|
+
import "./chunk-LHAZKBRJ.mjs";
|
|
7
|
+
import "./chunk-XQSCE3HI.mjs";
|
|
8
|
+
import "./chunk-AZ32UDL3.mjs";
|
|
9
9
|
export {
|
|
10
10
|
groupConnect,
|
|
11
11
|
toaster
|
|
@@ -31,7 +31,7 @@ var MAX_Z_INDEX = 2147483647;
|
|
|
31
31
|
// ../../utilities/core/src/functions.ts
|
|
32
32
|
var runIfFn = (v, ...a) => {
|
|
33
33
|
const res = typeof v === "function" ? v(...a) : v;
|
|
34
|
-
return res
|
|
34
|
+
return res ?? void 0;
|
|
35
35
|
};
|
|
36
36
|
var cast = (v) => v;
|
|
37
37
|
|
|
@@ -54,27 +54,20 @@ function isDocument(el) {
|
|
|
54
54
|
return el.nodeType === Node.DOCUMENT_NODE;
|
|
55
55
|
}
|
|
56
56
|
function isWindow(value) {
|
|
57
|
-
return
|
|
57
|
+
return value?.toString() === "[object Window]";
|
|
58
58
|
}
|
|
59
59
|
function getDocument(el) {
|
|
60
|
-
var _a;
|
|
61
60
|
if (isWindow(el))
|
|
62
61
|
return el.document;
|
|
63
62
|
if (isDocument(el))
|
|
64
63
|
return el;
|
|
65
|
-
return
|
|
64
|
+
return el?.ownerDocument ?? document;
|
|
66
65
|
}
|
|
67
66
|
function defineDomHelpers(helpers) {
|
|
68
67
|
const dom2 = {
|
|
69
|
-
getRootNode: (ctx) =>
|
|
70
|
-
var _a, _b;
|
|
71
|
-
return (_b = (_a = ctx.getRootNode) == null ? void 0 : _a.call(ctx)) != null ? _b : document;
|
|
72
|
-
},
|
|
68
|
+
getRootNode: (ctx) => ctx.getRootNode?.() ?? document,
|
|
73
69
|
getDoc: (ctx) => getDocument(dom2.getRootNode(ctx)),
|
|
74
|
-
getWin: (ctx) =>
|
|
75
|
-
var _a;
|
|
76
|
-
return (_a = dom2.getDoc(ctx).defaultView) != null ? _a : window;
|
|
77
|
-
},
|
|
70
|
+
getWin: (ctx) => dom2.getDoc(ctx).defaultView ?? window,
|
|
78
71
|
getActiveElement: (ctx) => dom2.getDoc(ctx).activeElement,
|
|
79
72
|
getById: (ctx, id) => dom2.getRootNode(ctx).getElementById(id)
|
|
80
73
|
};
|
|
@@ -88,9 +81,9 @@ function defineDomHelpers(helpers) {
|
|
|
88
81
|
var isRef = (v) => hasProp(v, "current");
|
|
89
82
|
function addDomEvent(target, eventName, handler, options) {
|
|
90
83
|
const node = isRef(target) ? target.current : runIfFn(target);
|
|
91
|
-
node
|
|
84
|
+
node?.addEventListener(eventName, handler, options);
|
|
92
85
|
return () => {
|
|
93
|
-
node
|
|
86
|
+
node?.removeEventListener(eventName, handler, options);
|
|
94
87
|
};
|
|
95
88
|
}
|
|
96
89
|
|
|
@@ -113,16 +106,7 @@ var dom = defineDomHelpers({
|
|
|
113
106
|
getTitleId: (ctx) => `toast:${ctx.id}:title`,
|
|
114
107
|
getDescriptionId: (ctx) => `toast:${ctx.id}:description`,
|
|
115
108
|
getCloseTriggerId: (ctx) => `toast${ctx.id}:close`,
|
|
116
|
-
getPortalId: (ctx) => `toast-portal:${ctx.id}
|
|
117
|
-
getPortalEl: (ctx) => dom.getDoc(ctx).getElementById(dom.getPortalId(ctx)),
|
|
118
|
-
createPortalEl: (ctx) => {
|
|
119
|
-
const existing = dom.getPortalEl(ctx);
|
|
120
|
-
if (existing)
|
|
121
|
-
return existing;
|
|
122
|
-
const portal = dom.getDoc(ctx).createElement("toast-portal");
|
|
123
|
-
portal.id = dom.getPortalId(ctx);
|
|
124
|
-
return portal;
|
|
125
|
-
}
|
|
109
|
+
getPortalId: (ctx) => `toast-portal:${ctx.id}`
|
|
126
110
|
});
|
|
127
111
|
|
|
128
112
|
// src/toast.utils.ts
|
|
@@ -134,7 +118,7 @@ var defaultTimeouts = {
|
|
|
134
118
|
custom: 5e3
|
|
135
119
|
};
|
|
136
120
|
function getToastDuration(duration, type) {
|
|
137
|
-
return duration
|
|
121
|
+
return duration ?? defaultTimeouts[type];
|
|
138
122
|
}
|
|
139
123
|
|
|
140
124
|
// src/toast.machine.ts
|
|
@@ -234,19 +218,10 @@ function createToastMachine(options = {}) {
|
|
|
234
218
|
}
|
|
235
219
|
},
|
|
236
220
|
guards: {
|
|
237
|
-
isChangingToLoading: (_, evt) =>
|
|
238
|
-
var _a;
|
|
239
|
-
return ((_a = evt.toast) == null ? void 0 : _a.type) === "loading";
|
|
240
|
-
},
|
|
221
|
+
isChangingToLoading: (_, evt) => evt.toast?.type === "loading",
|
|
241
222
|
isLoadingType: (ctx2) => ctx2.type === "loading",
|
|
242
|
-
hasTypeChanged: (ctx2, evt) =>
|
|
243
|
-
|
|
244
|
-
return ((_a = evt.toast) == null ? void 0 : _a.type) !== ctx2.type;
|
|
245
|
-
},
|
|
246
|
-
hasDurationChanged: (ctx2, evt) => {
|
|
247
|
-
var _a;
|
|
248
|
-
return ((_a = evt.toast) == null ? void 0 : _a.duration) !== ctx2.duration;
|
|
249
|
-
}
|
|
223
|
+
hasTypeChanged: (ctx2, evt) => evt.toast?.type !== ctx2.type,
|
|
224
|
+
hasDurationChanged: (ctx2, evt) => evt.toast?.duration !== ctx2.duration
|
|
250
225
|
},
|
|
251
226
|
delays: {
|
|
252
227
|
VISIBLE_DURATION: (ctx2) => ctx2.remaining,
|
|
@@ -263,20 +238,16 @@ function createToastMachine(options = {}) {
|
|
|
263
238
|
self.sendParent({ type: "REMOVE_TOAST", id: self.id });
|
|
264
239
|
},
|
|
265
240
|
invokeOnClosing(ctx2) {
|
|
266
|
-
|
|
267
|
-
(_a = ctx2.onClosing) == null ? void 0 : _a.call(ctx2);
|
|
241
|
+
ctx2.onClosing?.();
|
|
268
242
|
},
|
|
269
243
|
invokeOnClose(ctx2) {
|
|
270
|
-
|
|
271
|
-
(_a = ctx2.onClose) == null ? void 0 : _a.call(ctx2);
|
|
244
|
+
ctx2.onClose?.();
|
|
272
245
|
},
|
|
273
246
|
invokeOnOpen(ctx2) {
|
|
274
|
-
|
|
275
|
-
(_a = ctx2.onOpen) == null ? void 0 : _a.call(ctx2);
|
|
247
|
+
ctx2.onOpen?.();
|
|
276
248
|
},
|
|
277
249
|
invokeOnUpdate(ctx2) {
|
|
278
|
-
|
|
279
|
-
(_a = ctx2.onUpdate) == null ? void 0 : _a.call(ctx2);
|
|
250
|
+
ctx2.onUpdate?.();
|
|
280
251
|
},
|
|
281
252
|
setContext(ctx2, evt) {
|
|
282
253
|
const { duration: duration2, type: type2 } = evt.toast;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
groupMachine
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
5
|
-
import "./chunk-
|
|
6
|
-
import "./chunk-
|
|
7
|
-
import "./chunk-
|
|
3
|
+
} from "./chunk-GKMHTDAP.mjs";
|
|
4
|
+
import "./chunk-SSV22S55.mjs";
|
|
5
|
+
import "./chunk-LHAZKBRJ.mjs";
|
|
6
|
+
import "./chunk-XQSCE3HI.mjs";
|
|
7
|
+
import "./chunk-AZ32UDL3.mjs";
|
|
8
8
|
export {
|
|
9
9
|
groupMachine
|
|
10
10
|
};
|
package/dist/toast.anatomy.mjs
CHANGED
package/dist/toast.connect.js
CHANGED
|
@@ -34,27 +34,20 @@ function isDocument(el) {
|
|
|
34
34
|
return el.nodeType === Node.DOCUMENT_NODE;
|
|
35
35
|
}
|
|
36
36
|
function isWindow(value) {
|
|
37
|
-
return
|
|
37
|
+
return value?.toString() === "[object Window]";
|
|
38
38
|
}
|
|
39
39
|
function getDocument(el) {
|
|
40
|
-
var _a;
|
|
41
40
|
if (isWindow(el))
|
|
42
41
|
return el.document;
|
|
43
42
|
if (isDocument(el))
|
|
44
43
|
return el;
|
|
45
|
-
return
|
|
44
|
+
return el?.ownerDocument ?? document;
|
|
46
45
|
}
|
|
47
46
|
function defineDomHelpers(helpers) {
|
|
48
47
|
const dom2 = {
|
|
49
|
-
getRootNode: (ctx) =>
|
|
50
|
-
var _a, _b;
|
|
51
|
-
return (_b = (_a = ctx.getRootNode) == null ? void 0 : _a.call(ctx)) != null ? _b : document;
|
|
52
|
-
},
|
|
48
|
+
getRootNode: (ctx) => ctx.getRootNode?.() ?? document,
|
|
53
49
|
getDoc: (ctx) => getDocument(dom2.getRootNode(ctx)),
|
|
54
|
-
getWin: (ctx) =>
|
|
55
|
-
var _a;
|
|
56
|
-
return (_a = dom2.getDoc(ctx).defaultView) != null ? _a : window;
|
|
57
|
-
},
|
|
50
|
+
getWin: (ctx) => dom2.getDoc(ctx).defaultView ?? window,
|
|
58
51
|
getActiveElement: (ctx) => dom2.getDoc(ctx).activeElement,
|
|
59
52
|
getById: (ctx, id) => dom2.getRootNode(ctx).getElementById(id)
|
|
60
53
|
};
|
|
@@ -76,16 +69,7 @@ var dom = defineDomHelpers({
|
|
|
76
69
|
getTitleId: (ctx) => `toast:${ctx.id}:title`,
|
|
77
70
|
getDescriptionId: (ctx) => `toast:${ctx.id}:description`,
|
|
78
71
|
getCloseTriggerId: (ctx) => `toast${ctx.id}:close`,
|
|
79
|
-
getPortalId: (ctx) => `toast-portal:${ctx.id}
|
|
80
|
-
getPortalEl: (ctx) => dom.getDoc(ctx).getElementById(dom.getPortalId(ctx)),
|
|
81
|
-
createPortalEl: (ctx) => {
|
|
82
|
-
const existing = dom.getPortalEl(ctx);
|
|
83
|
-
if (existing)
|
|
84
|
-
return existing;
|
|
85
|
-
const portal = dom.getDoc(ctx).createElement("toast-portal");
|
|
86
|
-
portal.id = dom.getPortalId(ctx);
|
|
87
|
-
return portal;
|
|
88
|
-
}
|
|
72
|
+
getPortalId: (ctx) => `toast-portal:${ctx.id}`
|
|
89
73
|
});
|
|
90
74
|
|
|
91
75
|
// src/toast.connect.ts
|
|
@@ -173,8 +157,7 @@ function connect(state, send, normalize) {
|
|
|
173
157
|
}
|
|
174
158
|
}),
|
|
175
159
|
render() {
|
|
176
|
-
|
|
177
|
-
return (_b = (_a = state.context).render) == null ? void 0 : _b.call(_a, {
|
|
160
|
+
return state.context.render?.({
|
|
178
161
|
id: state.context.id,
|
|
179
162
|
type: state.context.type,
|
|
180
163
|
duration: state.context.duration,
|
package/dist/toast.connect.mjs
CHANGED
package/dist/toast.dom.d.ts
CHANGED
|
@@ -25,8 +25,6 @@ declare const dom: {
|
|
|
25
25
|
getDescriptionId: (ctx: MachineContext) => string;
|
|
26
26
|
getCloseTriggerId: (ctx: MachineContext) => string;
|
|
27
27
|
getPortalId: (ctx: GroupMachineContext) => string;
|
|
28
|
-
getPortalEl: (ctx: GroupMachineContext) => HTMLElement | null;
|
|
29
|
-
createPortalEl: (ctx: GroupMachineContext) => HTMLElement;
|
|
30
28
|
};
|
|
31
29
|
|
|
32
30
|
export { dom };
|
package/dist/toast.dom.js
CHANGED
|
@@ -29,27 +29,20 @@ function isDocument(el) {
|
|
|
29
29
|
return el.nodeType === Node.DOCUMENT_NODE;
|
|
30
30
|
}
|
|
31
31
|
function isWindow(value) {
|
|
32
|
-
return
|
|
32
|
+
return value?.toString() === "[object Window]";
|
|
33
33
|
}
|
|
34
34
|
function getDocument(el) {
|
|
35
|
-
var _a;
|
|
36
35
|
if (isWindow(el))
|
|
37
36
|
return el.document;
|
|
38
37
|
if (isDocument(el))
|
|
39
38
|
return el;
|
|
40
|
-
return
|
|
39
|
+
return el?.ownerDocument ?? document;
|
|
41
40
|
}
|
|
42
41
|
function defineDomHelpers(helpers) {
|
|
43
42
|
const dom2 = {
|
|
44
|
-
getRootNode: (ctx) =>
|
|
45
|
-
var _a, _b;
|
|
46
|
-
return (_b = (_a = ctx.getRootNode) == null ? void 0 : _a.call(ctx)) != null ? _b : document;
|
|
47
|
-
},
|
|
43
|
+
getRootNode: (ctx) => ctx.getRootNode?.() ?? document,
|
|
48
44
|
getDoc: (ctx) => getDocument(dom2.getRootNode(ctx)),
|
|
49
|
-
getWin: (ctx) =>
|
|
50
|
-
var _a;
|
|
51
|
-
return (_a = dom2.getDoc(ctx).defaultView) != null ? _a : window;
|
|
52
|
-
},
|
|
45
|
+
getWin: (ctx) => dom2.getDoc(ctx).defaultView ?? window,
|
|
53
46
|
getActiveElement: (ctx) => dom2.getDoc(ctx).activeElement,
|
|
54
47
|
getById: (ctx, id) => dom2.getRootNode(ctx).getElementById(id)
|
|
55
48
|
};
|
|
@@ -66,16 +59,7 @@ var dom = defineDomHelpers({
|
|
|
66
59
|
getTitleId: (ctx) => `toast:${ctx.id}:title`,
|
|
67
60
|
getDescriptionId: (ctx) => `toast:${ctx.id}:description`,
|
|
68
61
|
getCloseTriggerId: (ctx) => `toast${ctx.id}:close`,
|
|
69
|
-
getPortalId: (ctx) => `toast-portal:${ctx.id}
|
|
70
|
-
getPortalEl: (ctx) => dom.getDoc(ctx).getElementById(dom.getPortalId(ctx)),
|
|
71
|
-
createPortalEl: (ctx) => {
|
|
72
|
-
const existing = dom.getPortalEl(ctx);
|
|
73
|
-
if (existing)
|
|
74
|
-
return existing;
|
|
75
|
-
const portal = dom.getDoc(ctx).createElement("toast-portal");
|
|
76
|
-
portal.id = dom.getPortalId(ctx);
|
|
77
|
-
return portal;
|
|
78
|
-
}
|
|
62
|
+
getPortalId: (ctx) => `toast-portal:${ctx.id}`
|
|
79
63
|
});
|
|
80
64
|
// Annotate the CommonJS export names for ESM import in node:
|
|
81
65
|
0 && (module.exports = {
|
package/dist/toast.dom.mjs
CHANGED
package/dist/toast.machine.js
CHANGED
|
@@ -28,7 +28,7 @@ var import_core = require("@zag-js/core");
|
|
|
28
28
|
// ../../utilities/core/src/functions.ts
|
|
29
29
|
var runIfFn = (v, ...a) => {
|
|
30
30
|
const res = typeof v === "function" ? v(...a) : v;
|
|
31
|
-
return res
|
|
31
|
+
return res ?? void 0;
|
|
32
32
|
};
|
|
33
33
|
var cast = (v) => v;
|
|
34
34
|
|
|
@@ -51,27 +51,20 @@ function isDocument(el) {
|
|
|
51
51
|
return el.nodeType === Node.DOCUMENT_NODE;
|
|
52
52
|
}
|
|
53
53
|
function isWindow(value) {
|
|
54
|
-
return
|
|
54
|
+
return value?.toString() === "[object Window]";
|
|
55
55
|
}
|
|
56
56
|
function getDocument(el) {
|
|
57
|
-
var _a;
|
|
58
57
|
if (isWindow(el))
|
|
59
58
|
return el.document;
|
|
60
59
|
if (isDocument(el))
|
|
61
60
|
return el;
|
|
62
|
-
return
|
|
61
|
+
return el?.ownerDocument ?? document;
|
|
63
62
|
}
|
|
64
63
|
function defineDomHelpers(helpers) {
|
|
65
64
|
const dom2 = {
|
|
66
|
-
getRootNode: (ctx) =>
|
|
67
|
-
var _a, _b;
|
|
68
|
-
return (_b = (_a = ctx.getRootNode) == null ? void 0 : _a.call(ctx)) != null ? _b : document;
|
|
69
|
-
},
|
|
65
|
+
getRootNode: (ctx) => ctx.getRootNode?.() ?? document,
|
|
70
66
|
getDoc: (ctx) => getDocument(dom2.getRootNode(ctx)),
|
|
71
|
-
getWin: (ctx) =>
|
|
72
|
-
var _a;
|
|
73
|
-
return (_a = dom2.getDoc(ctx).defaultView) != null ? _a : window;
|
|
74
|
-
},
|
|
67
|
+
getWin: (ctx) => dom2.getDoc(ctx).defaultView ?? window,
|
|
75
68
|
getActiveElement: (ctx) => dom2.getDoc(ctx).activeElement,
|
|
76
69
|
getById: (ctx, id) => dom2.getRootNode(ctx).getElementById(id)
|
|
77
70
|
};
|
|
@@ -85,9 +78,9 @@ function defineDomHelpers(helpers) {
|
|
|
85
78
|
var isRef = (v) => hasProp(v, "current");
|
|
86
79
|
function addDomEvent(target, eventName, handler, options) {
|
|
87
80
|
const node = isRef(target) ? target.current : runIfFn(target);
|
|
88
|
-
node
|
|
81
|
+
node?.addEventListener(eventName, handler, options);
|
|
89
82
|
return () => {
|
|
90
|
-
node
|
|
83
|
+
node?.removeEventListener(eventName, handler, options);
|
|
91
84
|
};
|
|
92
85
|
}
|
|
93
86
|
|
|
@@ -107,16 +100,7 @@ var dom = defineDomHelpers({
|
|
|
107
100
|
getTitleId: (ctx) => `toast:${ctx.id}:title`,
|
|
108
101
|
getDescriptionId: (ctx) => `toast:${ctx.id}:description`,
|
|
109
102
|
getCloseTriggerId: (ctx) => `toast${ctx.id}:close`,
|
|
110
|
-
getPortalId: (ctx) => `toast-portal:${ctx.id}
|
|
111
|
-
getPortalEl: (ctx) => dom.getDoc(ctx).getElementById(dom.getPortalId(ctx)),
|
|
112
|
-
createPortalEl: (ctx) => {
|
|
113
|
-
const existing = dom.getPortalEl(ctx);
|
|
114
|
-
if (existing)
|
|
115
|
-
return existing;
|
|
116
|
-
const portal = dom.getDoc(ctx).createElement("toast-portal");
|
|
117
|
-
portal.id = dom.getPortalId(ctx);
|
|
118
|
-
return portal;
|
|
119
|
-
}
|
|
103
|
+
getPortalId: (ctx) => `toast-portal:${ctx.id}`
|
|
120
104
|
});
|
|
121
105
|
|
|
122
106
|
// src/toast.utils.ts
|
|
@@ -128,7 +112,7 @@ var defaultTimeouts = {
|
|
|
128
112
|
custom: 5e3
|
|
129
113
|
};
|
|
130
114
|
function getToastDuration(duration, type) {
|
|
131
|
-
return duration
|
|
115
|
+
return duration ?? defaultTimeouts[type];
|
|
132
116
|
}
|
|
133
117
|
|
|
134
118
|
// src/toast.machine.ts
|
|
@@ -228,19 +212,10 @@ function createToastMachine(options = {}) {
|
|
|
228
212
|
}
|
|
229
213
|
},
|
|
230
214
|
guards: {
|
|
231
|
-
isChangingToLoading: (_, evt) =>
|
|
232
|
-
var _a;
|
|
233
|
-
return ((_a = evt.toast) == null ? void 0 : _a.type) === "loading";
|
|
234
|
-
},
|
|
215
|
+
isChangingToLoading: (_, evt) => evt.toast?.type === "loading",
|
|
235
216
|
isLoadingType: (ctx2) => ctx2.type === "loading",
|
|
236
|
-
hasTypeChanged: (ctx2, evt) =>
|
|
237
|
-
|
|
238
|
-
return ((_a = evt.toast) == null ? void 0 : _a.type) !== ctx2.type;
|
|
239
|
-
},
|
|
240
|
-
hasDurationChanged: (ctx2, evt) => {
|
|
241
|
-
var _a;
|
|
242
|
-
return ((_a = evt.toast) == null ? void 0 : _a.duration) !== ctx2.duration;
|
|
243
|
-
}
|
|
217
|
+
hasTypeChanged: (ctx2, evt) => evt.toast?.type !== ctx2.type,
|
|
218
|
+
hasDurationChanged: (ctx2, evt) => evt.toast?.duration !== ctx2.duration
|
|
244
219
|
},
|
|
245
220
|
delays: {
|
|
246
221
|
VISIBLE_DURATION: (ctx2) => ctx2.remaining,
|
|
@@ -257,20 +232,16 @@ function createToastMachine(options = {}) {
|
|
|
257
232
|
self.sendParent({ type: "REMOVE_TOAST", id: self.id });
|
|
258
233
|
},
|
|
259
234
|
invokeOnClosing(ctx2) {
|
|
260
|
-
|
|
261
|
-
(_a = ctx2.onClosing) == null ? void 0 : _a.call(ctx2);
|
|
235
|
+
ctx2.onClosing?.();
|
|
262
236
|
},
|
|
263
237
|
invokeOnClose(ctx2) {
|
|
264
|
-
|
|
265
|
-
(_a = ctx2.onClose) == null ? void 0 : _a.call(ctx2);
|
|
238
|
+
ctx2.onClose?.();
|
|
266
239
|
},
|
|
267
240
|
invokeOnOpen(ctx2) {
|
|
268
|
-
|
|
269
|
-
(_a = ctx2.onOpen) == null ? void 0 : _a.call(ctx2);
|
|
241
|
+
ctx2.onOpen?.();
|
|
270
242
|
},
|
|
271
243
|
invokeOnUpdate(ctx2) {
|
|
272
|
-
|
|
273
|
-
(_a = ctx2.onUpdate) == null ? void 0 : _a.call(ctx2);
|
|
244
|
+
ctx2.onUpdate?.();
|
|
274
245
|
},
|
|
275
246
|
setContext(ctx2, evt) {
|
|
276
247
|
const { duration: duration2, type: type2 } = evt.toast;
|
package/dist/toast.machine.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createToastMachine
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
5
|
-
import "./chunk-
|
|
6
|
-
import "./chunk-
|
|
3
|
+
} from "./chunk-SSV22S55.mjs";
|
|
4
|
+
import "./chunk-LHAZKBRJ.mjs";
|
|
5
|
+
import "./chunk-XQSCE3HI.mjs";
|
|
6
|
+
import "./chunk-AZ32UDL3.mjs";
|
|
7
7
|
export {
|
|
8
8
|
createToastMachine
|
|
9
9
|
};
|
package/dist/toast.utils.js
CHANGED
|
@@ -43,7 +43,7 @@ var defaultTimeouts = {
|
|
|
43
43
|
custom: 5e3
|
|
44
44
|
};
|
|
45
45
|
function getToastDuration(duration, type) {
|
|
46
|
-
return duration
|
|
46
|
+
return duration ?? defaultTimeouts[type];
|
|
47
47
|
}
|
|
48
48
|
function getGroupPlacementStyle(ctx, placement) {
|
|
49
49
|
const offset = ctx.offsets;
|
package/dist/toast.utils.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zag-js/toast",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.11",
|
|
4
4
|
"description": "Core logic for the toast widget implemented as a state machine",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"js",
|
|
@@ -26,14 +26,14 @@
|
|
|
26
26
|
"url": "https://github.com/chakra-ui/zag/issues"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@zag-js/anatomy": "0.1.
|
|
30
|
-
"@zag-js/core": "0.2.
|
|
31
|
-
"@zag-js/types": "0.3.
|
|
29
|
+
"@zag-js/anatomy": "0.1.4",
|
|
30
|
+
"@zag-js/core": "0.2.8",
|
|
31
|
+
"@zag-js/types": "0.3.4"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"clean-package": "2.2.0",
|
|
35
|
-
"@zag-js/dom-utils": "0.2.
|
|
36
|
-
"@zag-js/utils": "0.3.
|
|
35
|
+
"@zag-js/dom-utils": "0.2.4",
|
|
36
|
+
"@zag-js/utils": "0.3.3"
|
|
37
37
|
},
|
|
38
38
|
"clean-package": "../../../clean-package.config.json",
|
|
39
39
|
"main": "dist/index.js",
|