@zag-js/toast 0.0.0-dev-20230201173529 → 0.0.0-dev-20230201181615

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.
@@ -1,17 +1,17 @@
1
1
  import {
2
2
  parts
3
- } from "./chunk-MD6LFB2J.mjs";
3
+ } from "./chunk-GQHI2OMI.mjs";
4
4
  import {
5
5
  runIfFn,
6
6
  uuid
7
- } from "./chunk-6HWLSJDV.mjs";
7
+ } from "./chunk-LHAZKBRJ.mjs";
8
8
  import {
9
9
  getGroupPlacementStyle,
10
10
  getToastsByPlacement
11
- } from "./chunk-FBM2PYRD.mjs";
11
+ } from "./chunk-XQSCE3HI.mjs";
12
12
  import {
13
13
  dom
14
- } from "./chunk-LN72PBJ5.mjs";
14
+ } from "./chunk-BF5R6LHY.mjs";
15
15
 
16
16
  // src/toast-group.connect.ts
17
17
  import { subscribe } from "@zag-js/core";
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  parts
3
- } from "./chunk-MD6LFB2J.mjs";
3
+ } from "./chunk-GQHI2OMI.mjs";
4
4
  import {
5
5
  dom
6
- } from "./chunk-LN72PBJ5.mjs";
6
+ } from "./chunk-BF5R6LHY.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
- var _a, _b;
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,
@@ -3,27 +3,20 @@ function isDocument(el) {
3
3
  return el.nodeType === Node.DOCUMENT_NODE;
4
4
  }
5
5
  function isWindow(value) {
6
- return (value == null ? void 0 : value.toString()) === "[object Window]";
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 (_a = el == null ? void 0 : el.ownerDocument) != null ? _a : document;
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
  };
File without changes
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  compact,
3
3
  createToastMachine
4
- } from "./chunk-5IFVCHQS.mjs";
4
+ } from "./chunk-OA575KTP.mjs";
5
5
 
6
6
  // src/toast-group.machine.ts
7
7
  import { createMachine } from "@zag-js/core";
@@ -1,7 +1,7 @@
1
1
  // ../../utilities/core/src/functions.ts
2
2
  var runIfFn = (v, ...a) => {
3
3
  const res = typeof v === "function" ? v(...a) : v;
4
- return res != null ? res : void 0;
4
+ return res ?? void 0;
5
5
  };
6
6
  var cast = (v) => v;
7
7
  var uuid = /* @__PURE__ */ (() => {
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  cast,
3
3
  runIfFn
4
- } from "./chunk-6HWLSJDV.mjs";
4
+ } from "./chunk-LHAZKBRJ.mjs";
5
5
  import {
6
6
  getToastDuration
7
- } from "./chunk-FBM2PYRD.mjs";
7
+ } from "./chunk-XQSCE3HI.mjs";
8
8
  import {
9
9
  dom
10
- } from "./chunk-LN72PBJ5.mjs";
10
+ } from "./chunk-BF5R6LHY.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 == null ? void 0 : node.addEventListener(eventName, handler, options);
33
+ node?.addEventListener(eventName, handler, options);
34
34
  return () => {
35
- node == null ? void 0 : node.removeEventListener(eventName, handler, options);
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
- var _a;
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
- var _a;
175
- (_a = ctx2.onClosing) == null ? void 0 : _a.call(ctx2);
165
+ ctx2.onClosing?.();
176
166
  },
177
167
  invokeOnClose(ctx2) {
178
- var _a;
179
- (_a = ctx2.onClose) == null ? void 0 : _a.call(ctx2);
168
+ ctx2.onClose?.();
180
169
  },
181
170
  invokeOnOpen(ctx2) {
182
- var _a;
183
- (_a = ctx2.onOpen) == null ? void 0 : _a.call(ctx2);
171
+ ctx2.onOpen?.();
184
172
  },
185
173
  invokeOnUpdate(ctx2) {
186
- var _a;
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 != null ? duration : defaultTimeouts[type];
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 != null ? res : void 0;
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 && true) {
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 (value == null ? void 0 : value.toString()) === "[object Window]";
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 (_a = el == null ? void 0 : el.ownerDocument) != null ? _a : document;
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 == null ? void 0 : node.addEventListener(eventName, handler, options);
111
+ node?.addEventListener(eventName, handler, options);
119
112
  return () => {
120
- node == null ? void 0 : node.removeEventListener(eventName, handler, options);
113
+ node?.removeEventListener(eventName, handler, options);
121
114
  };
122
115
  }
123
116
 
@@ -175,7 +168,7 @@ var defaultTimeouts = {
175
168
  custom: 5e3
176
169
  };
177
170
  function getToastDuration(duration, type) {
178
- return duration != null ? duration : defaultTimeouts[type];
171
+ return duration ?? defaultTimeouts[type];
179
172
  }
180
173
  function getGroupPlacementStyle(ctx, placement) {
181
174
  const offset = ctx.offsets;
@@ -442,19 +435,10 @@ function createToastMachine(options = {}) {
442
435
  }
443
436
  },
444
437
  guards: {
445
- isChangingToLoading: (_, evt) => {
446
- var _a;
447
- return ((_a = evt.toast) == null ? void 0 : _a.type) === "loading";
448
- },
438
+ isChangingToLoading: (_, evt) => evt.toast?.type === "loading",
449
439
  isLoadingType: (ctx2) => ctx2.type === "loading",
450
- hasTypeChanged: (ctx2, evt) => {
451
- var _a;
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
- }
440
+ hasTypeChanged: (ctx2, evt) => evt.toast?.type !== ctx2.type,
441
+ hasDurationChanged: (ctx2, evt) => evt.toast?.duration !== ctx2.duration
458
442
  },
459
443
  delays: {
460
444
  VISIBLE_DURATION: (ctx2) => ctx2.remaining,
@@ -471,20 +455,16 @@ function createToastMachine(options = {}) {
471
455
  self.sendParent({ type: "REMOVE_TOAST", id: self.id });
472
456
  },
473
457
  invokeOnClosing(ctx2) {
474
- var _a;
475
- (_a = ctx2.onClosing) == null ? void 0 : _a.call(ctx2);
458
+ ctx2.onClosing?.();
476
459
  },
477
460
  invokeOnClose(ctx2) {
478
- var _a;
479
- (_a = ctx2.onClose) == null ? void 0 : _a.call(ctx2);
461
+ ctx2.onClose?.();
480
462
  },
481
463
  invokeOnOpen(ctx2) {
482
- var _a;
483
- (_a = ctx2.onOpen) == null ? void 0 : _a.call(ctx2);
464
+ ctx2.onOpen?.();
484
465
  },
485
466
  invokeOnUpdate(ctx2) {
486
- var _a;
487
- (_a = ctx2.onUpdate) == null ? void 0 : _a.call(ctx2);
467
+ ctx2.onUpdate?.();
488
468
  },
489
469
  setContext(ctx2, evt) {
490
470
  const { duration: duration2, type: type2 } = evt.toast;
@@ -671,8 +651,7 @@ function connect(state, send, normalize) {
671
651
  }
672
652
  }),
673
653
  render() {
674
- var _a, _b;
675
- return (_b = (_a = state.context).render) == null ? void 0 : _b.call(_a, {
654
+ return state.context.render?.({
676
655
  id: state.context.id,
677
656
  type: state.context.type,
678
657
  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-PIVIE75R.mjs";
4
+ } from "./chunk-2TE4H5B5.mjs";
5
5
  import {
6
6
  groupMachine
7
- } from "./chunk-2Q3XCA25.mjs";
7
+ } from "./chunk-JPNOOB66.mjs";
8
8
  import {
9
9
  connect
10
- } from "./chunk-FL23ZLLA.mjs";
10
+ } from "./chunk-7CNVO66P.mjs";
11
11
  import {
12
12
  anatomy
13
- } from "./chunk-MD6LFB2J.mjs";
13
+ } from "./chunk-GQHI2OMI.mjs";
14
14
  import {
15
15
  createToastMachine
16
- } from "./chunk-5IFVCHQS.mjs";
17
- import "./chunk-6HWLSJDV.mjs";
18
- import "./chunk-FBM2PYRD.mjs";
19
- import "./chunk-LN72PBJ5.mjs";
16
+ } from "./chunk-OA575KTP.mjs";
17
+ import "./chunk-LHAZKBRJ.mjs";
18
+ import "./chunk-XQSCE3HI.mjs";
19
+ import "./chunk-BF5R6LHY.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 && true) {
25
+ if (c && process.env.NODE_ENV !== "production") {
26
26
  console.warn(m);
27
27
  }
28
28
  }
@@ -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 != null ? res : void 0;
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 (value == null ? void 0 : value.toString()) === "[object Window]";
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 (_a = el == null ? void 0 : el.ownerDocument) != null ? _a : document;
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
  };
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  groupConnect,
3
3
  toaster
4
- } from "./chunk-PIVIE75R.mjs";
5
- import "./chunk-MD6LFB2J.mjs";
6
- import "./chunk-6HWLSJDV.mjs";
7
- import "./chunk-FBM2PYRD.mjs";
8
- import "./chunk-LN72PBJ5.mjs";
4
+ } from "./chunk-2TE4H5B5.mjs";
5
+ import "./chunk-GQHI2OMI.mjs";
6
+ import "./chunk-LHAZKBRJ.mjs";
7
+ import "./chunk-XQSCE3HI.mjs";
8
+ import "./chunk-BF5R6LHY.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 != null ? res : void 0;
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 (value == null ? void 0 : value.toString()) === "[object Window]";
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 (_a = el == null ? void 0 : el.ownerDocument) != null ? _a : document;
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 == null ? void 0 : node.addEventListener(eventName, handler, options);
84
+ node?.addEventListener(eventName, handler, options);
92
85
  return () => {
93
- node == null ? void 0 : node.removeEventListener(eventName, handler, options);
86
+ node?.removeEventListener(eventName, handler, options);
94
87
  };
95
88
  }
96
89
 
@@ -134,7 +127,7 @@ var defaultTimeouts = {
134
127
  custom: 5e3
135
128
  };
136
129
  function getToastDuration(duration, type) {
137
- return duration != null ? duration : defaultTimeouts[type];
130
+ return duration ?? defaultTimeouts[type];
138
131
  }
139
132
 
140
133
  // src/toast.machine.ts
@@ -234,19 +227,10 @@ function createToastMachine(options = {}) {
234
227
  }
235
228
  },
236
229
  guards: {
237
- isChangingToLoading: (_, evt) => {
238
- var _a;
239
- return ((_a = evt.toast) == null ? void 0 : _a.type) === "loading";
240
- },
230
+ isChangingToLoading: (_, evt) => evt.toast?.type === "loading",
241
231
  isLoadingType: (ctx2) => ctx2.type === "loading",
242
- hasTypeChanged: (ctx2, evt) => {
243
- var _a;
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
- }
232
+ hasTypeChanged: (ctx2, evt) => evt.toast?.type !== ctx2.type,
233
+ hasDurationChanged: (ctx2, evt) => evt.toast?.duration !== ctx2.duration
250
234
  },
251
235
  delays: {
252
236
  VISIBLE_DURATION: (ctx2) => ctx2.remaining,
@@ -263,20 +247,16 @@ function createToastMachine(options = {}) {
263
247
  self.sendParent({ type: "REMOVE_TOAST", id: self.id });
264
248
  },
265
249
  invokeOnClosing(ctx2) {
266
- var _a;
267
- (_a = ctx2.onClosing) == null ? void 0 : _a.call(ctx2);
250
+ ctx2.onClosing?.();
268
251
  },
269
252
  invokeOnClose(ctx2) {
270
- var _a;
271
- (_a = ctx2.onClose) == null ? void 0 : _a.call(ctx2);
253
+ ctx2.onClose?.();
272
254
  },
273
255
  invokeOnOpen(ctx2) {
274
- var _a;
275
- (_a = ctx2.onOpen) == null ? void 0 : _a.call(ctx2);
256
+ ctx2.onOpen?.();
276
257
  },
277
258
  invokeOnUpdate(ctx2) {
278
- var _a;
279
- (_a = ctx2.onUpdate) == null ? void 0 : _a.call(ctx2);
259
+ ctx2.onUpdate?.();
280
260
  },
281
261
  setContext(ctx2, evt) {
282
262
  const { duration: duration2, type: type2 } = evt.toast;
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  groupMachine
3
- } from "./chunk-2Q3XCA25.mjs";
4
- import "./chunk-5IFVCHQS.mjs";
5
- import "./chunk-6HWLSJDV.mjs";
6
- import "./chunk-FBM2PYRD.mjs";
7
- import "./chunk-LN72PBJ5.mjs";
3
+ } from "./chunk-JPNOOB66.mjs";
4
+ import "./chunk-OA575KTP.mjs";
5
+ import "./chunk-LHAZKBRJ.mjs";
6
+ import "./chunk-XQSCE3HI.mjs";
7
+ import "./chunk-BF5R6LHY.mjs";
8
8
  export {
9
9
  groupMachine
10
10
  };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  anatomy,
3
3
  parts
4
- } from "./chunk-MD6LFB2J.mjs";
4
+ } from "./chunk-GQHI2OMI.mjs";
5
5
  export {
6
6
  anatomy,
7
7
  parts
@@ -34,27 +34,20 @@ function isDocument(el) {
34
34
  return el.nodeType === Node.DOCUMENT_NODE;
35
35
  }
36
36
  function isWindow(value) {
37
- return (value == null ? void 0 : value.toString()) === "[object Window]";
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 (_a = el == null ? void 0 : el.ownerDocument) != null ? _a : document;
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
  };
@@ -173,8 +166,7 @@ function connect(state, send, normalize) {
173
166
  }
174
167
  }),
175
168
  render() {
176
- var _a, _b;
177
- return (_b = (_a = state.context).render) == null ? void 0 : _b.call(_a, {
169
+ return state.context.render?.({
178
170
  id: state.context.id,
179
171
  type: state.context.type,
180
172
  duration: state.context.duration,
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  connect
3
- } from "./chunk-FL23ZLLA.mjs";
4
- import "./chunk-MD6LFB2J.mjs";
5
- import "./chunk-LN72PBJ5.mjs";
3
+ } from "./chunk-7CNVO66P.mjs";
4
+ import "./chunk-GQHI2OMI.mjs";
5
+ import "./chunk-BF5R6LHY.mjs";
6
6
  export {
7
7
  connect
8
8
  };
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 (value == null ? void 0 : value.toString()) === "[object Window]";
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 (_a = el == null ? void 0 : el.ownerDocument) != null ? _a : document;
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
  };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  dom
3
- } from "./chunk-LN72PBJ5.mjs";
3
+ } from "./chunk-BF5R6LHY.mjs";
4
4
  export {
5
5
  dom
6
6
  };
@@ -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 != null ? res : void 0;
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 (value == null ? void 0 : value.toString()) === "[object Window]";
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 (_a = el == null ? void 0 : el.ownerDocument) != null ? _a : document;
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 == null ? void 0 : node.addEventListener(eventName, handler, options);
81
+ node?.addEventListener(eventName, handler, options);
89
82
  return () => {
90
- node == null ? void 0 : node.removeEventListener(eventName, handler, options);
83
+ node?.removeEventListener(eventName, handler, options);
91
84
  };
92
85
  }
93
86
 
@@ -128,7 +121,7 @@ var defaultTimeouts = {
128
121
  custom: 5e3
129
122
  };
130
123
  function getToastDuration(duration, type) {
131
- return duration != null ? duration : defaultTimeouts[type];
124
+ return duration ?? defaultTimeouts[type];
132
125
  }
133
126
 
134
127
  // src/toast.machine.ts
@@ -228,19 +221,10 @@ function createToastMachine(options = {}) {
228
221
  }
229
222
  },
230
223
  guards: {
231
- isChangingToLoading: (_, evt) => {
232
- var _a;
233
- return ((_a = evt.toast) == null ? void 0 : _a.type) === "loading";
234
- },
224
+ isChangingToLoading: (_, evt) => evt.toast?.type === "loading",
235
225
  isLoadingType: (ctx2) => ctx2.type === "loading",
236
- hasTypeChanged: (ctx2, evt) => {
237
- var _a;
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
- }
226
+ hasTypeChanged: (ctx2, evt) => evt.toast?.type !== ctx2.type,
227
+ hasDurationChanged: (ctx2, evt) => evt.toast?.duration !== ctx2.duration
244
228
  },
245
229
  delays: {
246
230
  VISIBLE_DURATION: (ctx2) => ctx2.remaining,
@@ -257,20 +241,16 @@ function createToastMachine(options = {}) {
257
241
  self.sendParent({ type: "REMOVE_TOAST", id: self.id });
258
242
  },
259
243
  invokeOnClosing(ctx2) {
260
- var _a;
261
- (_a = ctx2.onClosing) == null ? void 0 : _a.call(ctx2);
244
+ ctx2.onClosing?.();
262
245
  },
263
246
  invokeOnClose(ctx2) {
264
- var _a;
265
- (_a = ctx2.onClose) == null ? void 0 : _a.call(ctx2);
247
+ ctx2.onClose?.();
266
248
  },
267
249
  invokeOnOpen(ctx2) {
268
- var _a;
269
- (_a = ctx2.onOpen) == null ? void 0 : _a.call(ctx2);
250
+ ctx2.onOpen?.();
270
251
  },
271
252
  invokeOnUpdate(ctx2) {
272
- var _a;
273
- (_a = ctx2.onUpdate) == null ? void 0 : _a.call(ctx2);
253
+ ctx2.onUpdate?.();
274
254
  },
275
255
  setContext(ctx2, evt) {
276
256
  const { duration: duration2, type: type2 } = evt.toast;
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  createToastMachine
3
- } from "./chunk-5IFVCHQS.mjs";
4
- import "./chunk-6HWLSJDV.mjs";
5
- import "./chunk-FBM2PYRD.mjs";
6
- import "./chunk-LN72PBJ5.mjs";
3
+ } from "./chunk-OA575KTP.mjs";
4
+ import "./chunk-LHAZKBRJ.mjs";
5
+ import "./chunk-XQSCE3HI.mjs";
6
+ import "./chunk-BF5R6LHY.mjs";
7
7
  export {
8
8
  createToastMachine
9
9
  };
@@ -43,7 +43,7 @@ var defaultTimeouts = {
43
43
  custom: 5e3
44
44
  };
45
45
  function getToastDuration(duration, type) {
46
- return duration != null ? duration : defaultTimeouts[type];
46
+ return duration ?? defaultTimeouts[type];
47
47
  }
48
48
  function getGroupPlacementStyle(ctx, placement) {
49
49
  const offset = ctx.offsets;
@@ -3,7 +3,7 @@ import {
3
3
  getGroupPlacementStyle,
4
4
  getToastDuration,
5
5
  getToastsByPlacement
6
- } from "./chunk-FBM2PYRD.mjs";
6
+ } from "./chunk-XQSCE3HI.mjs";
7
7
  export {
8
8
  defaultTimeouts,
9
9
  getGroupPlacementStyle,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zag-js/toast",
3
- "version": "0.0.0-dev-20230201173529",
3
+ "version": "0.0.0-dev-20230201181615",
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.3",
30
- "@zag-js/core": "0.0.0-dev-20230201173529",
31
- "@zag-js/types": "0.0.0-dev-20230201173529"
29
+ "@zag-js/anatomy": "0.0.0-dev-20230201181615",
30
+ "@zag-js/core": "0.0.0-dev-20230201181615",
31
+ "@zag-js/types": "0.0.0-dev-20230201181615"
32
32
  },
33
33
  "devDependencies": {
34
34
  "clean-package": "2.2.0",
35
- "@zag-js/dom-utils": "0.0.0-dev-20230201173529",
36
- "@zag-js/utils": "0.3.2"
35
+ "@zag-js/dom-utils": "0.0.0-dev-20230201181615",
36
+ "@zag-js/utils": "0.0.0-dev-20230201181615"
37
37
  },
38
38
  "clean-package": "../../../clean-package.config.json",
39
39
  "main": "dist/index.js",