@zag-js/toast 0.0.0-dev-20230222120620 → 0.0.0-dev-20230223072304

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.
@@ -15,14 +15,29 @@ import { runIfFn, uuid } from "@zag-js/utils";
15
15
  var toaster = {};
16
16
  function groupConnect(state, send, normalize) {
17
17
  const group = {
18
+ /**
19
+ * The total number of toasts
20
+ */
18
21
  count: state.context.count,
22
+ /**
23
+ * The active toasts
24
+ */
19
25
  toasts: state.context.toasts,
26
+ /**
27
+ * The active toasts by placement
28
+ */
20
29
  toastsByPlacement: getToastsByPlacement(state.context.toasts),
30
+ /**
31
+ * Returns whether the toast id is visible
32
+ */
21
33
  isVisible(id) {
22
34
  if (!state.context.toasts.length)
23
35
  return false;
24
36
  return !!state.context.toasts.find((toast) => toast.id == id);
25
37
  },
38
+ /**
39
+ * Function to create a toast.
40
+ */
26
41
  create(options) {
27
42
  const uid = `toast:${uuid()}`;
28
43
  const id = options.id ? options.id : uid;
@@ -31,6 +46,9 @@ function groupConnect(state, send, normalize) {
31
46
  send({ type: "ADD_TOAST", toast: { ...options, id } });
32
47
  return id;
33
48
  },
49
+ /**
50
+ * Function to create or update a toast.
51
+ */
34
52
  upsert(options) {
35
53
  const { id } = options;
36
54
  const isVisible = id ? group.isVisible(id) : false;
@@ -40,6 +58,10 @@ function groupConnect(state, send, normalize) {
40
58
  return group.create(options);
41
59
  }
42
60
  },
61
+ /**
62
+ * Function to dismiss a toast by id.
63
+ * If no id is provided, all toasts will be dismissed.
64
+ */
43
65
  dismiss(id) {
44
66
  if (id == null) {
45
67
  send("DISMISS_ALL");
@@ -47,6 +69,10 @@ function groupConnect(state, send, normalize) {
47
69
  send({ type: "DISMISS_TOAST", id });
48
70
  }
49
71
  },
72
+ /**
73
+ * Function to remove a toast by id.
74
+ * If no id is provided, all toasts will be removed.
75
+ */
50
76
  remove(id) {
51
77
  if (id == null) {
52
78
  send("REMOVE_ALL");
@@ -54,30 +80,50 @@ function groupConnect(state, send, normalize) {
54
80
  send({ type: "REMOVE_TOAST", id });
55
81
  }
56
82
  },
83
+ /**
84
+ * Function to dismiss all toasts by placement.
85
+ */
57
86
  dismissByPlacement(placement) {
58
87
  const toasts = group.toastsByPlacement[placement];
59
88
  if (toasts) {
60
89
  toasts.forEach((toast) => group.dismiss(toast.id));
61
90
  }
62
91
  },
92
+ /**
93
+ * Function to update a toast's options by id.
94
+ */
63
95
  update(id, options) {
64
96
  if (!group.isVisible(id))
65
97
  return;
66
98
  send({ type: "UPDATE_TOAST", id, toast: options });
67
99
  return id;
68
100
  },
101
+ /**
102
+ * Function to create a loading toast.
103
+ */
69
104
  loading(options) {
70
105
  options.type = "loading";
71
106
  return group.upsert(options);
72
107
  },
108
+ /**
109
+ * Function to create a success toast.
110
+ */
73
111
  success(options) {
74
112
  options.type = "success";
75
113
  return group.upsert(options);
76
114
  },
115
+ /**
116
+ * Function to create an error toast.
117
+ */
77
118
  error(options) {
78
119
  options.type = "error";
79
120
  return group.upsert(options);
80
121
  },
122
+ /**
123
+ * Function to create a toast from a promise.
124
+ * - When the promise resolves, the toast will be updated with the success options.
125
+ * - When the promise rejects, the toast will be updated with the error options.
126
+ */
81
127
  promise(promise, options, shared = {}) {
82
128
  const id = group.loading({ ...shared, ...options.loading });
83
129
  promise.then((response) => {
@@ -89,6 +135,9 @@ function groupConnect(state, send, normalize) {
89
135
  });
90
136
  return promise;
91
137
  },
138
+ /**
139
+ * Function to pause a toast by id.
140
+ */
92
141
  pause(id) {
93
142
  if (id == null) {
94
143
  send("PAUSE_ALL");
@@ -96,6 +145,9 @@ function groupConnect(state, send, normalize) {
96
145
  send({ type: "PAUSE_TOAST", id });
97
146
  }
98
147
  },
148
+ /**
149
+ * Function to resume a toast by id.
150
+ */
99
151
  resume(id) {
100
152
  if (id == null) {
101
153
  send("RESUME_ALL");
@@ -13,22 +13,68 @@ function connect(state, send, normalize) {
13
13
  const pauseOnInteraction = state.context.pauseOnInteraction;
14
14
  const placement = state.context.placement;
15
15
  return {
16
+ /**
17
+ * The type of the toast.
18
+ */
16
19
  type: state.context.type,
20
+ /**
21
+ * The title of the toast.
22
+ */
17
23
  title: state.context.title,
24
+ /**
25
+ * The description of the toast.
26
+ */
18
27
  description: state.context.description,
28
+ /**
29
+ * The current placement of the toast.
30
+ */
19
31
  placement,
32
+ /**
33
+ * Whether the toast is visible.
34
+ */
20
35
  isVisible,
36
+ /**
37
+ * Whether the toast is paused.
38
+ */
21
39
  isPaused,
40
+ /**
41
+ * Whether the toast is in RTL mode.
42
+ */
22
43
  isRtl: state.context.dir === "rtl",
44
+ /**
45
+ * Function to pause the toast (keeping it visible).
46
+ */
23
47
  pause() {
24
48
  send("PAUSE");
25
49
  },
50
+ /**
51
+ * Function to resume the toast dismissing.
52
+ */
26
53
  resume() {
27
54
  send("RESUME");
28
55
  },
56
+ /**
57
+ * Function to instantly dismiss the toast.
58
+ */
29
59
  dismiss() {
30
60
  send("DISMISS");
31
61
  },
62
+ /**
63
+ * Function render the toast in the DOM (based on the defined `render` property)
64
+ */
65
+ render() {
66
+ return state.context.render?.({
67
+ id: state.context.id,
68
+ type: state.context.type,
69
+ duration: state.context.duration,
70
+ title: state.context.title,
71
+ placement: state.context.placement,
72
+ description: state.context.description,
73
+ dismiss() {
74
+ send("DISMISS");
75
+ }
76
+ });
77
+ },
32
78
  rootProps: normalize.element({
33
79
  ...parts.root.attrs,
34
80
  dir: state.context.dir,
@@ -89,20 +135,7 @@ function connect(state, send, normalize) {
89
135
  onClick() {
90
136
  send("DISMISS");
91
137
  }
92
- }),
93
- render() {
94
- return state.context.render?.({
95
- id: state.context.id,
96
- type: state.context.type,
97
- duration: state.context.duration,
98
- title: state.context.title,
99
- placement: state.context.placement,
100
- description: state.context.description,
101
- dismiss() {
102
- send("DISMISS");
103
- }
104
- });
105
- }
138
+ })
106
139
  };
107
140
  }
108
141
 
package/dist/index.js CHANGED
@@ -114,14 +114,29 @@ function getGroupPlacementStyle(ctx, placement) {
114
114
  var toaster = {};
115
115
  function groupConnect(state, send, normalize) {
116
116
  const group2 = {
117
+ /**
118
+ * The total number of toasts
119
+ */
117
120
  count: state.context.count,
121
+ /**
122
+ * The active toasts
123
+ */
118
124
  toasts: state.context.toasts,
125
+ /**
126
+ * The active toasts by placement
127
+ */
119
128
  toastsByPlacement: getToastsByPlacement(state.context.toasts),
129
+ /**
130
+ * Returns whether the toast id is visible
131
+ */
120
132
  isVisible(id) {
121
133
  if (!state.context.toasts.length)
122
134
  return false;
123
135
  return !!state.context.toasts.find((toast) => toast.id == id);
124
136
  },
137
+ /**
138
+ * Function to create a toast.
139
+ */
125
140
  create(options) {
126
141
  const uid = `toast:${(0, import_utils.uuid)()}`;
127
142
  const id = options.id ? options.id : uid;
@@ -130,6 +145,9 @@ function groupConnect(state, send, normalize) {
130
145
  send({ type: "ADD_TOAST", toast: { ...options, id } });
131
146
  return id;
132
147
  },
148
+ /**
149
+ * Function to create or update a toast.
150
+ */
133
151
  upsert(options) {
134
152
  const { id } = options;
135
153
  const isVisible = id ? group2.isVisible(id) : false;
@@ -139,6 +157,10 @@ function groupConnect(state, send, normalize) {
139
157
  return group2.create(options);
140
158
  }
141
159
  },
160
+ /**
161
+ * Function to dismiss a toast by id.
162
+ * If no id is provided, all toasts will be dismissed.
163
+ */
142
164
  dismiss(id) {
143
165
  if (id == null) {
144
166
  send("DISMISS_ALL");
@@ -146,6 +168,10 @@ function groupConnect(state, send, normalize) {
146
168
  send({ type: "DISMISS_TOAST", id });
147
169
  }
148
170
  },
171
+ /**
172
+ * Function to remove a toast by id.
173
+ * If no id is provided, all toasts will be removed.
174
+ */
149
175
  remove(id) {
150
176
  if (id == null) {
151
177
  send("REMOVE_ALL");
@@ -153,30 +179,50 @@ function groupConnect(state, send, normalize) {
153
179
  send({ type: "REMOVE_TOAST", id });
154
180
  }
155
181
  },
182
+ /**
183
+ * Function to dismiss all toasts by placement.
184
+ */
156
185
  dismissByPlacement(placement) {
157
186
  const toasts = group2.toastsByPlacement[placement];
158
187
  if (toasts) {
159
188
  toasts.forEach((toast) => group2.dismiss(toast.id));
160
189
  }
161
190
  },
191
+ /**
192
+ * Function to update a toast's options by id.
193
+ */
162
194
  update(id, options) {
163
195
  if (!group2.isVisible(id))
164
196
  return;
165
197
  send({ type: "UPDATE_TOAST", id, toast: options });
166
198
  return id;
167
199
  },
200
+ /**
201
+ * Function to create a loading toast.
202
+ */
168
203
  loading(options) {
169
204
  options.type = "loading";
170
205
  return group2.upsert(options);
171
206
  },
207
+ /**
208
+ * Function to create a success toast.
209
+ */
172
210
  success(options) {
173
211
  options.type = "success";
174
212
  return group2.upsert(options);
175
213
  },
214
+ /**
215
+ * Function to create an error toast.
216
+ */
176
217
  error(options) {
177
218
  options.type = "error";
178
219
  return group2.upsert(options);
179
220
  },
221
+ /**
222
+ * Function to create a toast from a promise.
223
+ * - When the promise resolves, the toast will be updated with the success options.
224
+ * - When the promise rejects, the toast will be updated with the error options.
225
+ */
180
226
  promise(promise, options, shared = {}) {
181
227
  const id = group2.loading({ ...shared, ...options.loading });
182
228
  promise.then((response) => {
@@ -188,6 +234,9 @@ function groupConnect(state, send, normalize) {
188
234
  });
189
235
  return promise;
190
236
  },
237
+ /**
238
+ * Function to pause a toast by id.
239
+ */
191
240
  pause(id) {
192
241
  if (id == null) {
193
242
  send("PAUSE_ALL");
@@ -195,6 +244,9 @@ function groupConnect(state, send, normalize) {
195
244
  send({ type: "PAUSE_TOAST", id });
196
245
  }
197
246
  },
247
+ /**
248
+ * Function to resume a toast by id.
249
+ */
198
250
  resume(id) {
199
251
  if (id == null) {
200
252
  send("RESUME_ALL");
@@ -468,22 +520,68 @@ function connect(state, send, normalize) {
468
520
  const pauseOnInteraction = state.context.pauseOnInteraction;
469
521
  const placement = state.context.placement;
470
522
  return {
523
+ /**
524
+ * The type of the toast.
525
+ */
471
526
  type: state.context.type,
527
+ /**
528
+ * The title of the toast.
529
+ */
472
530
  title: state.context.title,
531
+ /**
532
+ * The description of the toast.
533
+ */
473
534
  description: state.context.description,
535
+ /**
536
+ * The current placement of the toast.
537
+ */
474
538
  placement,
539
+ /**
540
+ * Whether the toast is visible.
541
+ */
475
542
  isVisible,
543
+ /**
544
+ * Whether the toast is paused.
545
+ */
476
546
  isPaused,
547
+ /**
548
+ * Whether the toast is in RTL mode.
549
+ */
477
550
  isRtl: state.context.dir === "rtl",
551
+ /**
552
+ * Function to pause the toast (keeping it visible).
553
+ */
478
554
  pause() {
479
555
  send("PAUSE");
480
556
  },
557
+ /**
558
+ * Function to resume the toast dismissing.
559
+ */
481
560
  resume() {
482
561
  send("RESUME");
483
562
  },
563
+ /**
564
+ * Function to instantly dismiss the toast.
565
+ */
484
566
  dismiss() {
485
567
  send("DISMISS");
486
568
  },
569
+ /**
570
+ * Function render the toast in the DOM (based on the defined `render` property)
571
+ */
572
+ render() {
573
+ return state.context.render?.({
574
+ id: state.context.id,
575
+ type: state.context.type,
576
+ duration: state.context.duration,
577
+ title: state.context.title,
578
+ placement: state.context.placement,
579
+ description: state.context.description,
580
+ dismiss() {
581
+ send("DISMISS");
582
+ }
583
+ });
584
+ },
487
585
  rootProps: normalize.element({
488
586
  ...parts.root.attrs,
489
587
  dir: state.context.dir,
@@ -544,20 +642,7 @@ function connect(state, send, normalize) {
544
642
  onClick() {
545
643
  send("DISMISS");
546
644
  }
547
- }),
548
- render() {
549
- return state.context.render?.({
550
- id: state.context.id,
551
- type: state.context.type,
552
- duration: state.context.duration,
553
- title: state.context.title,
554
- placement: state.context.placement,
555
- description: state.context.description,
556
- dismiss() {
557
- send("DISMISS");
558
- }
559
- });
560
- }
645
+ })
561
646
  };
562
647
  }
563
648
 
package/dist/index.mjs CHANGED
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  groupConnect,
3
3
  toaster
4
- } from "./chunk-4WKKWZRA.mjs";
4
+ } from "./chunk-6TPPYHFP.mjs";
5
5
  import {
6
6
  groupMachine
7
7
  } from "./chunk-TCF4OLIQ.mjs";
8
8
  import {
9
9
  connect
10
- } from "./chunk-GMSHIBCW.mjs";
10
+ } from "./chunk-MUJMFD4Y.mjs";
11
11
  import {
12
12
  anatomy
13
13
  } from "./chunk-GQHI2OMI.mjs";
@@ -4,21 +4,73 @@ import '@zag-js/core';
4
4
 
5
5
  declare let toaster: Toaster;
6
6
  declare function groupConnect<T extends PropTypes>(state: GroupState, send: GroupSend, normalize: NormalizeProps<T>): {
7
+ /**
8
+ * The total number of toasts
9
+ */
7
10
  count: number;
11
+ /**
12
+ * The active toasts
13
+ */
8
14
  toasts: Service[];
15
+ /**
16
+ * The active toasts by placement
17
+ */
9
18
  toastsByPlacement: Partial<Record<Placement, Service[]>>;
19
+ /**
20
+ * Returns whether the toast id is visible
21
+ */
10
22
  isVisible(id: string): boolean;
23
+ /**
24
+ * Function to create a toast.
25
+ */
11
26
  create(options: Options): string | undefined;
27
+ /**
28
+ * Function to create or update a toast.
29
+ */
12
30
  upsert(options: Options): string | undefined;
31
+ /**
32
+ * Function to dismiss a toast by id.
33
+ * If no id is provided, all toasts will be dismissed.
34
+ */
13
35
  dismiss(id?: string): void;
36
+ /**
37
+ * Function to remove a toast by id.
38
+ * If no id is provided, all toasts will be removed.
39
+ */
14
40
  remove(id?: string): void;
41
+ /**
42
+ * Function to dismiss all toasts by placement.
43
+ */
15
44
  dismissByPlacement(placement: Placement): void;
45
+ /**
46
+ * Function to update a toast's options by id.
47
+ */
16
48
  update(id: string, options: Options): string | undefined;
49
+ /**
50
+ * Function to create a loading toast.
51
+ */
17
52
  loading(options: Options): string | undefined;
53
+ /**
54
+ * Function to create a success toast.
55
+ */
18
56
  success(options: Options): string | undefined;
57
+ /**
58
+ * Function to create an error toast.
59
+ */
19
60
  error(options: Options): string | undefined;
61
+ /**
62
+ * Function to create a toast from a promise.
63
+ * - When the promise resolves, the toast will be updated with the success options.
64
+ * - When the promise rejects, the toast will be updated with the error options.
65
+ */
20
66
  promise<T_1>(promise: Promise<T_1>, options: PromiseOptions<T_1>, shared?: Options): Promise<T_1>;
67
+ /**
68
+ * Function to pause a toast by id.
69
+ */
21
70
  pause(id?: string): void;
71
+ /**
72
+ * Function to resume a toast by id.
73
+ */
22
74
  resume(id?: string): void;
23
75
  getGroupProps(options: GroupProps): T["element"];
24
76
  subscribe(fn: (toasts: GroupMachineContext["toasts"]) => void): () => void;
@@ -97,14 +97,29 @@ function getGroupPlacementStyle(ctx, placement) {
97
97
  var toaster = {};
98
98
  function groupConnect(state, send, normalize) {
99
99
  const group = {
100
+ /**
101
+ * The total number of toasts
102
+ */
100
103
  count: state.context.count,
104
+ /**
105
+ * The active toasts
106
+ */
101
107
  toasts: state.context.toasts,
108
+ /**
109
+ * The active toasts by placement
110
+ */
102
111
  toastsByPlacement: getToastsByPlacement(state.context.toasts),
112
+ /**
113
+ * Returns whether the toast id is visible
114
+ */
103
115
  isVisible(id) {
104
116
  if (!state.context.toasts.length)
105
117
  return false;
106
118
  return !!state.context.toasts.find((toast) => toast.id == id);
107
119
  },
120
+ /**
121
+ * Function to create a toast.
122
+ */
108
123
  create(options) {
109
124
  const uid = `toast:${(0, import_utils.uuid)()}`;
110
125
  const id = options.id ? options.id : uid;
@@ -113,6 +128,9 @@ function groupConnect(state, send, normalize) {
113
128
  send({ type: "ADD_TOAST", toast: { ...options, id } });
114
129
  return id;
115
130
  },
131
+ /**
132
+ * Function to create or update a toast.
133
+ */
116
134
  upsert(options) {
117
135
  const { id } = options;
118
136
  const isVisible = id ? group.isVisible(id) : false;
@@ -122,6 +140,10 @@ function groupConnect(state, send, normalize) {
122
140
  return group.create(options);
123
141
  }
124
142
  },
143
+ /**
144
+ * Function to dismiss a toast by id.
145
+ * If no id is provided, all toasts will be dismissed.
146
+ */
125
147
  dismiss(id) {
126
148
  if (id == null) {
127
149
  send("DISMISS_ALL");
@@ -129,6 +151,10 @@ function groupConnect(state, send, normalize) {
129
151
  send({ type: "DISMISS_TOAST", id });
130
152
  }
131
153
  },
154
+ /**
155
+ * Function to remove a toast by id.
156
+ * If no id is provided, all toasts will be removed.
157
+ */
132
158
  remove(id) {
133
159
  if (id == null) {
134
160
  send("REMOVE_ALL");
@@ -136,30 +162,50 @@ function groupConnect(state, send, normalize) {
136
162
  send({ type: "REMOVE_TOAST", id });
137
163
  }
138
164
  },
165
+ /**
166
+ * Function to dismiss all toasts by placement.
167
+ */
139
168
  dismissByPlacement(placement) {
140
169
  const toasts = group.toastsByPlacement[placement];
141
170
  if (toasts) {
142
171
  toasts.forEach((toast) => group.dismiss(toast.id));
143
172
  }
144
173
  },
174
+ /**
175
+ * Function to update a toast's options by id.
176
+ */
145
177
  update(id, options) {
146
178
  if (!group.isVisible(id))
147
179
  return;
148
180
  send({ type: "UPDATE_TOAST", id, toast: options });
149
181
  return id;
150
182
  },
183
+ /**
184
+ * Function to create a loading toast.
185
+ */
151
186
  loading(options) {
152
187
  options.type = "loading";
153
188
  return group.upsert(options);
154
189
  },
190
+ /**
191
+ * Function to create a success toast.
192
+ */
155
193
  success(options) {
156
194
  options.type = "success";
157
195
  return group.upsert(options);
158
196
  },
197
+ /**
198
+ * Function to create an error toast.
199
+ */
159
200
  error(options) {
160
201
  options.type = "error";
161
202
  return group.upsert(options);
162
203
  },
204
+ /**
205
+ * Function to create a toast from a promise.
206
+ * - When the promise resolves, the toast will be updated with the success options.
207
+ * - When the promise rejects, the toast will be updated with the error options.
208
+ */
163
209
  promise(promise, options, shared = {}) {
164
210
  const id = group.loading({ ...shared, ...options.loading });
165
211
  promise.then((response) => {
@@ -171,6 +217,9 @@ function groupConnect(state, send, normalize) {
171
217
  });
172
218
  return promise;
173
219
  },
220
+ /**
221
+ * Function to pause a toast by id.
222
+ */
174
223
  pause(id) {
175
224
  if (id == null) {
176
225
  send("PAUSE_ALL");
@@ -178,6 +227,9 @@ function groupConnect(state, send, normalize) {
178
227
  send({ type: "PAUSE_TOAST", id });
179
228
  }
180
229
  },
230
+ /**
231
+ * Function to resume a toast by id.
232
+ */
181
233
  resume(id) {
182
234
  if (id == null) {
183
235
  send("RESUME_ALL");
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  groupConnect,
3
3
  toaster
4
- } from "./chunk-4WKKWZRA.mjs";
4
+ } from "./chunk-6TPPYHFP.mjs";
5
5
  import "./chunk-GQHI2OMI.mjs";
6
6
  import "./chunk-DBPKSADW.mjs";
7
7
  import "./chunk-DUZD3NLM.mjs";
@@ -3,21 +3,54 @@ import { PropTypes, NormalizeProps } from '@zag-js/types';
3
3
  import '@zag-js/core';
4
4
 
5
5
  declare function connect<T extends PropTypes>(state: State, send: Send, normalize: NormalizeProps<T>): {
6
+ /**
7
+ * The type of the toast.
8
+ */
6
9
  type: Type;
10
+ /**
11
+ * The title of the toast.
12
+ */
7
13
  title: string | undefined;
14
+ /**
15
+ * The description of the toast.
16
+ */
8
17
  description: string | undefined;
18
+ /**
19
+ * The current placement of the toast.
20
+ */
9
21
  placement: Placement;
22
+ /**
23
+ * Whether the toast is visible.
24
+ */
10
25
  isVisible: boolean;
26
+ /**
27
+ * Whether the toast is paused.
28
+ */
11
29
  isPaused: boolean;
30
+ /**
31
+ * Whether the toast is in RTL mode.
32
+ */
12
33
  isRtl: boolean;
34
+ /**
35
+ * Function to pause the toast (keeping it visible).
36
+ */
13
37
  pause(): void;
38
+ /**
39
+ * Function to resume the toast dismissing.
40
+ */
14
41
  resume(): void;
42
+ /**
43
+ * Function to instantly dismiss the toast.
44
+ */
15
45
  dismiss(): void;
46
+ /**
47
+ * Function render the toast in the DOM (based on the defined `render` property)
48
+ */
49
+ render(): any;
16
50
  rootProps: T["element"];
17
51
  titleProps: T["element"];
18
52
  descriptionProps: T["element"];
19
53
  closeTriggerProps: T["button"];
20
- render(): any;
21
54
  };
22
55
 
23
56
  export { connect };
@@ -48,22 +48,68 @@ function connect(state, send, normalize) {
48
48
  const pauseOnInteraction = state.context.pauseOnInteraction;
49
49
  const placement = state.context.placement;
50
50
  return {
51
+ /**
52
+ * The type of the toast.
53
+ */
51
54
  type: state.context.type,
55
+ /**
56
+ * The title of the toast.
57
+ */
52
58
  title: state.context.title,
59
+ /**
60
+ * The description of the toast.
61
+ */
53
62
  description: state.context.description,
63
+ /**
64
+ * The current placement of the toast.
65
+ */
54
66
  placement,
67
+ /**
68
+ * Whether the toast is visible.
69
+ */
55
70
  isVisible,
71
+ /**
72
+ * Whether the toast is paused.
73
+ */
56
74
  isPaused,
75
+ /**
76
+ * Whether the toast is in RTL mode.
77
+ */
57
78
  isRtl: state.context.dir === "rtl",
79
+ /**
80
+ * Function to pause the toast (keeping it visible).
81
+ */
58
82
  pause() {
59
83
  send("PAUSE");
60
84
  },
85
+ /**
86
+ * Function to resume the toast dismissing.
87
+ */
61
88
  resume() {
62
89
  send("RESUME");
63
90
  },
91
+ /**
92
+ * Function to instantly dismiss the toast.
93
+ */
64
94
  dismiss() {
65
95
  send("DISMISS");
66
96
  },
97
+ /**
98
+ * Function render the toast in the DOM (based on the defined `render` property)
99
+ */
100
+ render() {
101
+ return state.context.render?.({
102
+ id: state.context.id,
103
+ type: state.context.type,
104
+ duration: state.context.duration,
105
+ title: state.context.title,
106
+ placement: state.context.placement,
107
+ description: state.context.description,
108
+ dismiss() {
109
+ send("DISMISS");
110
+ }
111
+ });
112
+ },
67
113
  rootProps: normalize.element({
68
114
  ...parts.root.attrs,
69
115
  dir: state.context.dir,
@@ -124,20 +170,7 @@ function connect(state, send, normalize) {
124
170
  onClick() {
125
171
  send("DISMISS");
126
172
  }
127
- }),
128
- render() {
129
- return state.context.render?.({
130
- id: state.context.id,
131
- type: state.context.type,
132
- duration: state.context.duration,
133
- title: state.context.title,
134
- placement: state.context.placement,
135
- description: state.context.description,
136
- dismiss() {
137
- send("DISMISS");
138
- }
139
- });
140
- }
173
+ })
141
174
  };
142
175
  }
143
176
  // Annotate the CommonJS export names for ESM import in node:
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  connect
3
- } from "./chunk-GMSHIBCW.mjs";
3
+ } from "./chunk-MUJMFD4Y.mjs";
4
4
  import "./chunk-GQHI2OMI.mjs";
5
5
  import "./chunk-DUZD3NLM.mjs";
6
6
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zag-js/toast",
3
- "version": "0.0.0-dev-20230222120620",
3
+ "version": "0.0.0-dev-20230223072304",
4
4
  "description": "Core logic for the toast widget implemented as a state machine",
5
5
  "keywords": [
6
6
  "js",
@@ -27,9 +27,9 @@
27
27
  },
28
28
  "dependencies": {
29
29
  "@zag-js/anatomy": "0.1.4",
30
- "@zag-js/core": "0.0.0-dev-20230222120620",
31
- "@zag-js/dom-query": "0.0.0-dev-20230222120620",
32
- "@zag-js/dom-event": "0.0.0-dev-20230222120620",
30
+ "@zag-js/core": "0.0.0-dev-20230223072304",
31
+ "@zag-js/dom-query": "0.0.0-dev-20230223072304",
32
+ "@zag-js/dom-event": "0.0.0-dev-20230223072304",
33
33
  "@zag-js/utils": "0.3.3",
34
34
  "@zag-js/types": "0.3.4"
35
35
  },