@zag-js/toast 0.1.10 → 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021 Chakra UI
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/dist/index.d.ts CHANGED
@@ -1,11 +1,199 @@
1
- import { groupConnect } from "./toast-group.connect";
2
- import { groupMachine } from "./toast-group.machine";
3
- import { createToastMachine as createMachine } from "./toast.machine";
4
- export { connect } from "./toast.connect";
5
- export type { GroupMachineContext, MachineContext, MachineState, Placement, Service, Type } from "./toast.types";
6
- export { createMachine };
7
- export declare const group: {
1
+ import * as _zag_js_core from '@zag-js/core';
2
+ import { Machine, StateMachine } from '@zag-js/core';
3
+ import { RootProperties, CommonProperties, Direction, DirectionProperty, Context, RequiredBy, PropTypes, NormalizeProps } from '@zag-js/types';
4
+
5
+ declare type Type = "success" | "error" | "loading" | "info" | "custom";
6
+ declare type Placement = "top-start" | "top" | "top-end" | "bottom-start" | "bottom" | "bottom-end";
7
+ declare type SharedContext = {
8
+ /**
9
+ * Whether to pause toast when the user leaves the browser tab
10
+ */
11
+ pauseOnPageIdle?: boolean;
12
+ /**
13
+ * Whether to pause the toast when interacted with
14
+ */
15
+ pauseOnInteraction?: boolean;
16
+ };
17
+ declare type ToastOptions = {
18
+ /**
19
+ * The unique id of the toast
20
+ */
21
+ id: string;
22
+ /**
23
+ * The type of the toast
24
+ */
25
+ type: Type;
26
+ /**
27
+ * The placement of the toast
28
+ */
29
+ placement: Placement;
30
+ /**
31
+ * The message of the toast
32
+ */
33
+ title?: string;
34
+ /**
35
+ * The description of the toast
36
+ */
37
+ description?: string;
38
+ /**
39
+ * The duration the toast will be visible
40
+ */
41
+ duration: number;
42
+ /**
43
+ * Custom function to render the toast element.
44
+ */
45
+ render?: (options: RenderOptions) => any;
46
+ /**
47
+ * The duration for the toast to kept alive before it is removed.
48
+ * Useful for exit transitions.
49
+ */
50
+ removeDelay?: number;
51
+ /**
52
+ * Function called when the toast has been closed and removed
53
+ */
54
+ onClose?: VoidFunction;
55
+ /**
56
+ * Function called when the toast is leaving
57
+ */
58
+ onClosing?: VoidFunction;
59
+ /**
60
+ * Function called when the toast is shown
61
+ */
62
+ onOpen?: VoidFunction;
63
+ /**
64
+ * Function called when the toast is updated
65
+ */
66
+ onUpdate?: VoidFunction;
67
+ };
68
+ declare type Options = Partial<ToastOptions>;
69
+ declare type RenderOptions = Omit<ToastOptions, "render"> & {
70
+ dismiss(): void;
71
+ };
72
+ declare type MachineContext = SharedContext & RootProperties & CommonProperties & Omit<ToastOptions, "removeDelay"> & {
73
+ /**
74
+ * The duration for the toast to kept alive before it is removed.
75
+ * Useful for exit transitions.
76
+ */
77
+ removeDelay: number;
78
+ /**
79
+ * The document's text/writing direction.
80
+ */
81
+ dir?: Direction;
82
+ /**
83
+ * The time the toast was created
84
+ */
85
+ createdAt: number;
86
+ /**
87
+ * The time left before the toast is removed
88
+ */
89
+ remaining: number;
90
+ };
91
+ declare type MachineState = {
92
+ value: "active" | "active:temp" | "dismissing" | "inactive" | "persist";
93
+ tags: "visible" | "paused" | "updating";
94
+ };
95
+ declare type State = StateMachine.State<MachineContext, MachineState>;
96
+ declare type Send = StateMachine.Send;
97
+ declare type Service = Machine<MachineContext, MachineState>;
98
+ declare type GroupPublicContext = SharedContext & DirectionProperty & CommonProperties & {
99
+ /**
100
+ * The gutter or spacing between toasts
101
+ */
102
+ gutter: string;
103
+ /**
104
+ * The z-index applied to each toast group
105
+ */
106
+ zIndex: number;
107
+ /**
108
+ * The maximum number of toasts that can be shown at once
109
+ */
110
+ max: number;
111
+ /**
112
+ * The offset from the safe environment edge of the viewport
113
+ */
114
+ offsets: string | Record<"left" | "right" | "bottom" | "top", string>;
115
+ };
116
+ declare type UserDefinedGroupContext = RequiredBy<GroupPublicContext, "id">;
117
+ declare type GroupComputedContext = Readonly<{
118
+ /**
119
+ * @computed
120
+ * The total number of toasts in the group
121
+ */
122
+ readonly count: number;
123
+ }>;
124
+ declare type GroupPrivateContext = Context<{}>;
125
+ declare type GroupMachineContext = GroupPublicContext & GroupComputedContext & GroupPrivateContext;
126
+ declare type GroupState = StateMachine.State<GroupMachineContext>;
127
+ declare type GroupSend = (event: StateMachine.Event<StateMachine.AnyEventObject>) => void;
128
+ declare type MaybeFunction<Value, Args> = Value | ((arg: Args) => Value);
129
+ declare type PromiseOptions<Value> = {
130
+ loading: ToastOptions;
131
+ success: MaybeFunction<ToastOptions, Value>;
132
+ error: MaybeFunction<ToastOptions, Error>;
133
+ };
134
+ declare type GroupProps = {
135
+ placement: Placement;
136
+ label?: string;
137
+ };
138
+ declare type Toaster = {
139
+ count: number;
140
+ isVisible(id: string): boolean;
141
+ upsert(options: ToastOptions): string | undefined;
142
+ create(options: ToastOptions): string | undefined;
143
+ success(options: ToastOptions): string | undefined;
144
+ error(options: ToastOptions): string | undefined;
145
+ loading(options: ToastOptions): string | undefined;
146
+ dismiss(id?: string | undefined): void;
147
+ remove(id?: string | undefined): void;
148
+ promise<T>(promise: Promise<T>, options: PromiseOptions<T>, shared?: ToastOptions): Promise<T>;
149
+ };
150
+
151
+ declare function groupConnect<T extends PropTypes>(state: GroupState, send: GroupSend, normalize: NormalizeProps<T>): {
152
+ count: number;
153
+ toasts: Service[];
154
+ toastsByPlacement: Partial<Record<Placement, Service[]>>;
155
+ isVisible(id: string): boolean;
156
+ create(options: Options): string | undefined;
157
+ upsert(options: Options): string | undefined;
158
+ dismiss(id?: string): void;
159
+ remove(id?: string): void;
160
+ dismissByPlacement(placement: Placement): void;
161
+ update(id: string, options: Options): string | undefined;
162
+ loading(options: Options): string | undefined;
163
+ success(options: Options): string | undefined;
164
+ error(options: Options): string | undefined;
165
+ promise<T_1>(promise: Promise<T_1>, options: PromiseOptions<T_1>, shared?: Options): Promise<T_1>;
166
+ pause(id?: string): void;
167
+ resume(id?: string): void;
168
+ getGroupProps(options: GroupProps): T["element"];
169
+ createPortal(): HTMLElement;
170
+ subscribe(fn: (toasts: GroupMachineContext["toasts"]) => void): () => void;
171
+ };
172
+
173
+ declare function groupMachine(ctx: UserDefinedGroupContext): _zag_js_core.Machine<GroupMachineContext, _zag_js_core.StateMachine.StateSchema, _zag_js_core.StateMachine.AnyEventObject>;
174
+
175
+ declare function createToastMachine(options?: Options): _zag_js_core.Machine<MachineContext, MachineState, _zag_js_core.StateMachine.AnyEventObject>;
176
+
177
+ declare function connect<T extends PropTypes>(state: State, send: Send, normalize: NormalizeProps<T>): {
178
+ type: Type;
179
+ title: string | undefined;
180
+ placement: Placement;
181
+ isVisible: boolean;
182
+ isPaused: boolean;
183
+ pause(): void;
184
+ resume(): void;
185
+ dismiss(): void;
186
+ rootProps: T["element"];
187
+ progressbarProps: T["element"];
188
+ titleProps: T["element"];
189
+ closeButtonProps: T["button"];
190
+ render(): any;
191
+ };
192
+
193
+ declare const group: {
8
194
  connect: typeof groupConnect;
9
195
  machine: typeof groupMachine;
10
196
  };
11
- export declare function api(): import("./toast.types").Toaster;
197
+ declare function api(): Toaster | undefined;
198
+
199
+ export { GroupMachineContext, MachineContext, MachineState, Placement, Service, Type, api, connect, createToastMachine as createMachine, group };
package/dist/index.js CHANGED
@@ -1,37 +1,8 @@
1
1
  "use strict";
2
2
  var __defProp = Object.defineProperty;
3
- var __defProps = Object.defineProperties;
4
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
6
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
8
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
9
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
10
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
11
- var __spreadValues = (a, b) => {
12
- for (var prop in b || (b = {}))
13
- if (__hasOwnProp.call(b, prop))
14
- __defNormalProp(a, prop, b[prop]);
15
- if (__getOwnPropSymbols)
16
- for (var prop of __getOwnPropSymbols(b)) {
17
- if (__propIsEnum.call(b, prop))
18
- __defNormalProp(a, prop, b[prop]);
19
- }
20
- return a;
21
- };
22
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
23
- var __objRest = (source, exclude) => {
24
- var target = {};
25
- for (var prop in source)
26
- if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
27
- target[prop] = source[prop];
28
- if (source != null && __getOwnPropSymbols)
29
- for (var prop of __getOwnPropSymbols(source)) {
30
- if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
31
- target[prop] = source[prop];
32
- }
33
- return target;
34
- };
35
6
  var __export = (target, all) => {
36
7
  for (var name in all)
37
8
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -57,29 +28,13 @@ __export(src_exports, {
57
28
  module.exports = __toCommonJS(src_exports);
58
29
 
59
30
  // ../../utilities/dom/dist/index.mjs
60
- var __defProp2 = Object.defineProperty;
61
- var __getOwnPropSymbols2 = Object.getOwnPropertySymbols;
62
- var __hasOwnProp2 = Object.prototype.hasOwnProperty;
63
- var __propIsEnum2 = Object.prototype.propertyIsEnumerable;
64
- var __defNormalProp2 = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
65
- var __spreadValues2 = (a, b) => {
66
- for (var prop in b || (b = {}))
67
- if (__hasOwnProp2.call(b, prop))
68
- __defNormalProp2(a, prop, b[prop]);
69
- if (__getOwnPropSymbols2)
70
- for (var prop of __getOwnPropSymbols2(b)) {
71
- if (__propIsEnum2.call(b, prop))
72
- __defNormalProp2(a, prop, b[prop]);
73
- }
74
- return a;
75
- };
76
31
  var dataAttr = (guard) => {
77
32
  return guard ? "" : void 0;
78
33
  };
79
34
  var MAX_Z_INDEX = 2147483647;
80
35
  var runIfFn = (v, ...a) => {
81
36
  const res = typeof v === "function" ? v(...a) : v;
82
- return res != null ? res : void 0;
37
+ return res ?? void 0;
83
38
  };
84
39
  var cast = (v) => v;
85
40
  var hasProp = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
@@ -91,28 +46,27 @@ function isWindow(value) {
91
46
  return (value == null ? void 0 : value.toString()) === "[object Window]";
92
47
  }
93
48
  function getDocument(el) {
94
- var _a;
95
49
  if (isWindow(el))
96
50
  return el.document;
97
51
  if (isDocument(el))
98
52
  return el;
99
- return (_a = el == null ? void 0 : el.ownerDocument) != null ? _a : document;
53
+ return (el == null ? void 0 : el.ownerDocument) ?? document;
100
54
  }
101
55
  function defineDomHelpers(helpers) {
102
56
  const dom2 = {
103
57
  getRootNode: (ctx) => {
104
- var _a, _b;
105
- return (_b = (_a = ctx.getRootNode) == null ? void 0 : _a.call(ctx)) != null ? _b : document;
106
- },
107
- getDoc: (ctx) => getDocument(dom2.getRootNode(ctx)),
108
- getWin: (ctx) => {
109
58
  var _a;
110
- return (_a = dom2.getDoc(ctx).defaultView) != null ? _a : window;
59
+ return ((_a = ctx.getRootNode) == null ? void 0 : _a.call(ctx)) ?? document;
111
60
  },
61
+ getDoc: (ctx) => getDocument(dom2.getRootNode(ctx)),
62
+ getWin: (ctx) => dom2.getDoc(ctx).defaultView ?? window,
112
63
  getActiveElement: (ctx) => dom2.getDoc(ctx).activeElement,
113
64
  getById: (ctx, id) => dom2.getRootNode(ctx).getElementById(id)
114
65
  };
115
- return __spreadValues2(__spreadValues2({}, dom2), helpers);
66
+ return {
67
+ ...dom2,
68
+ ...helpers
69
+ };
116
70
  }
117
71
  var isRef = (v) => hasProp(v, "current");
118
72
  function addDomEvent(target, eventName, handler, options) {
@@ -133,7 +87,7 @@ function trackDocumentVisibility(_doc, callback) {
133
87
  // ../../utilities/core/dist/index.mjs
134
88
  var runIfFn2 = (v, ...a) => {
135
89
  const res = typeof v === "function" ? v(...a) : v;
136
- return res != null ? res : void 0;
90
+ return res ?? void 0;
137
91
  };
138
92
  var uuid = /* @__PURE__ */ (() => {
139
93
  let id = 0;
@@ -145,7 +99,7 @@ var uuid = /* @__PURE__ */ (() => {
145
99
  function warn(...a) {
146
100
  const m = a.length === 1 ? a[0] : a[1];
147
101
  const c = a.length === 2 ? a[0] : true;
148
- if (c && void 0 !== "production") {
102
+ if (c && process.env.NODE_ENV !== "production") {
149
103
  console.warn(m);
150
104
  }
151
105
  }
@@ -189,7 +143,7 @@ var defaultTimeouts = {
189
143
  custom: 5e3
190
144
  };
191
145
  function getToastDuration(duration, type) {
192
- return duration != null ? duration : defaultTimeouts[type];
146
+ return duration ?? defaultTimeouts[type];
193
147
  }
194
148
  function getGroupPlacementStyle(ctx, placement) {
195
149
  const offset = ctx.offsets;
@@ -248,7 +202,7 @@ function groupConnect(state, send, normalize) {
248
202
  const id = options.id ? options.id : uid;
249
203
  if (group2.isVisible(id))
250
204
  return;
251
- send({ type: "ADD_TOAST", toast: __spreadProps(__spreadValues({}, options), { id }) });
205
+ send({ type: "ADD_TOAST", toast: { ...options, id } });
252
206
  return id;
253
207
  },
254
208
  upsert(options) {
@@ -299,13 +253,13 @@ function groupConnect(state, send, normalize) {
299
253
  return group2.upsert(options);
300
254
  },
301
255
  promise(promise, options, shared = {}) {
302
- const id = group2.loading(__spreadValues(__spreadValues({}, shared), options.loading));
256
+ const id = group2.loading({ ...shared, ...options.loading });
303
257
  promise.then((response) => {
304
258
  const successOptions = runIfFn2(options.success, response);
305
- group2.success(__spreadProps(__spreadValues(__spreadValues({}, shared), successOptions), { id }));
259
+ group2.success({ ...shared, ...successOptions, id });
306
260
  }).catch((error) => {
307
261
  const errorOptions = runIfFn2(options.error, error);
308
- group2.error(__spreadProps(__spreadValues(__spreadValues({}, shared), errorOptions), { id }));
262
+ group2.error({ ...shared, ...errorOptions, id });
309
263
  });
310
264
  return promise;
311
265
  },
@@ -361,21 +315,22 @@ var import_core3 = require("@zag-js/core");
361
315
  var import_core2 = require("@zag-js/core");
362
316
  var { not, and, or } = import_core2.guards;
363
317
  function createToastMachine(options = {}) {
364
- const _a = options, { type = "info", duration, id = "toast", placement = "bottom", removeDelay = 500 } = _a, rest = __objRest(_a, ["type", "duration", "id", "placement", "removeDelay"]);
318
+ const { type = "info", duration, id = "toast", placement = "bottom", removeDelay = 500, ...rest } = options;
365
319
  const __duration = getToastDuration(duration, type);
366
320
  return (0, import_core2.createMachine)({
367
321
  id,
368
322
  entry: "invokeOnOpen",
369
323
  initial: type === "loading" ? "persist" : "active",
370
- context: __spreadValues({
324
+ context: {
371
325
  id,
372
326
  type,
373
327
  remaining: __duration,
374
328
  duration: __duration,
375
329
  removeDelay,
376
330
  createdAt: Date.now(),
377
- placement
378
- }, rest),
331
+ placement,
332
+ ...rest
333
+ },
379
334
  on: {
380
335
  UPDATE: [
381
336
  {
@@ -452,17 +407,17 @@ function createToastMachine(options = {}) {
452
407
  },
453
408
  guards: {
454
409
  isChangingToLoading: (_, evt) => {
455
- var _a2;
456
- return ((_a2 = evt.toast) == null ? void 0 : _a2.type) === "loading";
410
+ var _a;
411
+ return ((_a = evt.toast) == null ? void 0 : _a.type) === "loading";
457
412
  },
458
413
  isLoadingType: (ctx) => ctx.type === "loading",
459
414
  hasTypeChanged: (ctx, evt) => {
460
- var _a2;
461
- return ((_a2 = evt.toast) == null ? void 0 : _a2.type) !== ctx.type;
415
+ var _a;
416
+ return ((_a = evt.toast) == null ? void 0 : _a.type) !== ctx.type;
462
417
  },
463
418
  hasDurationChanged: (ctx, evt) => {
464
- var _a2;
465
- return ((_a2 = evt.toast) == null ? void 0 : _a2.duration) !== ctx.duration;
419
+ var _a;
420
+ return ((_a = evt.toast) == null ? void 0 : _a.duration) !== ctx.duration;
466
421
  }
467
422
  },
468
423
  delays: {
@@ -480,25 +435,25 @@ function createToastMachine(options = {}) {
480
435
  self.sendParent({ type: "REMOVE_TOAST", id: self.id });
481
436
  },
482
437
  invokeOnClosing(ctx) {
483
- var _a2;
484
- (_a2 = ctx.onClosing) == null ? void 0 : _a2.call(ctx);
438
+ var _a;
439
+ (_a = ctx.onClosing) == null ? void 0 : _a.call(ctx);
485
440
  },
486
441
  invokeOnClose(ctx) {
487
- var _a2;
488
- (_a2 = ctx.onClose) == null ? void 0 : _a2.call(ctx);
442
+ var _a;
443
+ (_a = ctx.onClose) == null ? void 0 : _a.call(ctx);
489
444
  },
490
445
  invokeOnOpen(ctx) {
491
- var _a2;
492
- (_a2 = ctx.onOpen) == null ? void 0 : _a2.call(ctx);
446
+ var _a;
447
+ (_a = ctx.onOpen) == null ? void 0 : _a.call(ctx);
493
448
  },
494
449
  invokeOnUpdate(ctx) {
495
- var _a2;
496
- (_a2 = ctx.onUpdate) == null ? void 0 : _a2.call(ctx);
450
+ var _a;
451
+ (_a = ctx.onUpdate) == null ? void 0 : _a.call(ctx);
497
452
  },
498
453
  setContext(ctx, evt) {
499
454
  const { duration: duration2, type: type2 } = evt.toast;
500
455
  const time = getToastDuration(duration2, type2);
501
- Object.assign(ctx, __spreadProps(__spreadValues({}, evt.toast), { duration: time, remaining: time }));
456
+ Object.assign(ctx, { ...evt.toast, duration: time, remaining: time });
502
457
  }
503
458
  }
504
459
  });
@@ -509,7 +464,7 @@ function groupMachine(ctx) {
509
464
  return (0, import_core3.createMachine)({
510
465
  id: "toaster",
511
466
  initial: "active",
512
- context: __spreadValues({
467
+ context: {
513
468
  dir: "ltr",
514
469
  max: Number.MAX_SAFE_INTEGER,
515
470
  toasts: [],
@@ -517,8 +472,9 @@ function groupMachine(ctx) {
517
472
  zIndex: MAX_Z_INDEX,
518
473
  pauseOnPageIdle: false,
519
474
  pauseOnInteraction: true,
520
- offsets: { left: "0px", right: "0px", top: "0px", bottom: "0px" }
521
- }, ctx),
475
+ offsets: { left: "0px", right: "0px", top: "0px", bottom: "0px" },
476
+ ...ctx
477
+ },
522
478
  computed: {
523
479
  count: (ctx2) => ctx2.toasts.length
524
480
  },
@@ -547,13 +503,13 @@ function groupMachine(ctx) {
547
503
  ADD_TOAST: {
548
504
  guard: (ctx2) => ctx2.toasts.length < ctx2.max,
549
505
  actions: (ctx2, evt, { self }) => {
550
- var _a;
551
- const options = __spreadProps(__spreadValues({}, evt.toast), {
506
+ const options = {
507
+ ...evt.toast,
552
508
  pauseOnPageIdle: ctx2.pauseOnPageIdle,
553
509
  pauseOnInteraction: ctx2.pauseOnInteraction,
554
510
  dir: ctx2.dir,
555
- doc: (0, import_core3.ref)((_a = ctx2.doc) != null ? _a : document)
556
- });
511
+ getRootNode: ctx2.getRootNode
512
+ };
557
513
  const toast = createToastMachine(options);
558
514
  const actor = self.spawn(toast);
559
515
  ctx2.toasts.push(actor);
@@ -714,3 +670,10 @@ function api() {
714
670
  return toaster;
715
671
  }
716
672
  }
673
+ // Annotate the CommonJS export names for ESM import in node:
674
+ 0 && (module.exports = {
675
+ api,
676
+ connect,
677
+ createMachine,
678
+ group
679
+ });
package/dist/index.mjs CHANGED
@@ -1,59 +1,11 @@
1
- var __defProp = Object.defineProperty;
2
- var __defProps = Object.defineProperties;
3
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
- var __spreadValues = (a, b) => {
9
- for (var prop in b || (b = {}))
10
- if (__hasOwnProp.call(b, prop))
11
- __defNormalProp(a, prop, b[prop]);
12
- if (__getOwnPropSymbols)
13
- for (var prop of __getOwnPropSymbols(b)) {
14
- if (__propIsEnum.call(b, prop))
15
- __defNormalProp(a, prop, b[prop]);
16
- }
17
- return a;
18
- };
19
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
- var __objRest = (source, exclude) => {
21
- var target = {};
22
- for (var prop in source)
23
- if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
24
- target[prop] = source[prop];
25
- if (source != null && __getOwnPropSymbols)
26
- for (var prop of __getOwnPropSymbols(source)) {
27
- if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
28
- target[prop] = source[prop];
29
- }
30
- return target;
31
- };
32
-
33
1
  // ../../utilities/dom/dist/index.mjs
34
- var __defProp2 = Object.defineProperty;
35
- var __getOwnPropSymbols2 = Object.getOwnPropertySymbols;
36
- var __hasOwnProp2 = Object.prototype.hasOwnProperty;
37
- var __propIsEnum2 = Object.prototype.propertyIsEnumerable;
38
- var __defNormalProp2 = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
39
- var __spreadValues2 = (a, b) => {
40
- for (var prop in b || (b = {}))
41
- if (__hasOwnProp2.call(b, prop))
42
- __defNormalProp2(a, prop, b[prop]);
43
- if (__getOwnPropSymbols2)
44
- for (var prop of __getOwnPropSymbols2(b)) {
45
- if (__propIsEnum2.call(b, prop))
46
- __defNormalProp2(a, prop, b[prop]);
47
- }
48
- return a;
49
- };
50
2
  var dataAttr = (guard) => {
51
3
  return guard ? "" : void 0;
52
4
  };
53
5
  var MAX_Z_INDEX = 2147483647;
54
6
  var runIfFn = (v, ...a) => {
55
7
  const res = typeof v === "function" ? v(...a) : v;
56
- return res != null ? res : void 0;
8
+ return res ?? void 0;
57
9
  };
58
10
  var cast = (v) => v;
59
11
  var hasProp = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
@@ -65,28 +17,27 @@ function isWindow(value) {
65
17
  return (value == null ? void 0 : value.toString()) === "[object Window]";
66
18
  }
67
19
  function getDocument(el) {
68
- var _a;
69
20
  if (isWindow(el))
70
21
  return el.document;
71
22
  if (isDocument(el))
72
23
  return el;
73
- return (_a = el == null ? void 0 : el.ownerDocument) != null ? _a : document;
24
+ return (el == null ? void 0 : el.ownerDocument) ?? document;
74
25
  }
75
26
  function defineDomHelpers(helpers) {
76
27
  const dom2 = {
77
28
  getRootNode: (ctx) => {
78
- var _a, _b;
79
- return (_b = (_a = ctx.getRootNode) == null ? void 0 : _a.call(ctx)) != null ? _b : document;
80
- },
81
- getDoc: (ctx) => getDocument(dom2.getRootNode(ctx)),
82
- getWin: (ctx) => {
83
29
  var _a;
84
- return (_a = dom2.getDoc(ctx).defaultView) != null ? _a : window;
30
+ return ((_a = ctx.getRootNode) == null ? void 0 : _a.call(ctx)) ?? document;
85
31
  },
32
+ getDoc: (ctx) => getDocument(dom2.getRootNode(ctx)),
33
+ getWin: (ctx) => dom2.getDoc(ctx).defaultView ?? window,
86
34
  getActiveElement: (ctx) => dom2.getDoc(ctx).activeElement,
87
35
  getById: (ctx, id) => dom2.getRootNode(ctx).getElementById(id)
88
36
  };
89
- return __spreadValues2(__spreadValues2({}, dom2), helpers);
37
+ return {
38
+ ...dom2,
39
+ ...helpers
40
+ };
90
41
  }
91
42
  var isRef = (v) => hasProp(v, "current");
92
43
  function addDomEvent(target, eventName, handler, options) {
@@ -107,7 +58,7 @@ function trackDocumentVisibility(_doc, callback) {
107
58
  // ../../utilities/core/dist/index.mjs
108
59
  var runIfFn2 = (v, ...a) => {
109
60
  const res = typeof v === "function" ? v(...a) : v;
110
- return res != null ? res : void 0;
61
+ return res ?? void 0;
111
62
  };
112
63
  var uuid = /* @__PURE__ */ (() => {
113
64
  let id = 0;
@@ -119,7 +70,7 @@ var uuid = /* @__PURE__ */ (() => {
119
70
  function warn(...a) {
120
71
  const m = a.length === 1 ? a[0] : a[1];
121
72
  const c = a.length === 2 ? a[0] : true;
122
- if (c && void 0 !== "production") {
73
+ if (c && process.env.NODE_ENV !== "production") {
123
74
  console.warn(m);
124
75
  }
125
76
  }
@@ -163,7 +114,7 @@ var defaultTimeouts = {
163
114
  custom: 5e3
164
115
  };
165
116
  function getToastDuration(duration, type) {
166
- return duration != null ? duration : defaultTimeouts[type];
117
+ return duration ?? defaultTimeouts[type];
167
118
  }
168
119
  function getGroupPlacementStyle(ctx, placement) {
169
120
  const offset = ctx.offsets;
@@ -222,7 +173,7 @@ function groupConnect(state, send, normalize) {
222
173
  const id = options.id ? options.id : uid;
223
174
  if (group2.isVisible(id))
224
175
  return;
225
- send({ type: "ADD_TOAST", toast: __spreadProps(__spreadValues({}, options), { id }) });
176
+ send({ type: "ADD_TOAST", toast: { ...options, id } });
226
177
  return id;
227
178
  },
228
179
  upsert(options) {
@@ -273,13 +224,13 @@ function groupConnect(state, send, normalize) {
273
224
  return group2.upsert(options);
274
225
  },
275
226
  promise(promise, options, shared = {}) {
276
- const id = group2.loading(__spreadValues(__spreadValues({}, shared), options.loading));
227
+ const id = group2.loading({ ...shared, ...options.loading });
277
228
  promise.then((response) => {
278
229
  const successOptions = runIfFn2(options.success, response);
279
- group2.success(__spreadProps(__spreadValues(__spreadValues({}, shared), successOptions), { id }));
230
+ group2.success({ ...shared, ...successOptions, id });
280
231
  }).catch((error) => {
281
232
  const errorOptions = runIfFn2(options.error, error);
282
- group2.error(__spreadProps(__spreadValues(__spreadValues({}, shared), errorOptions), { id }));
233
+ group2.error({ ...shared, ...errorOptions, id });
283
234
  });
284
235
  return promise;
285
236
  },
@@ -329,27 +280,28 @@ function groupConnect(state, send, normalize) {
329
280
  }
330
281
 
331
282
  // src/toast-group.machine.ts
332
- import { createMachine as createMachine2, ref } from "@zag-js/core";
283
+ import { createMachine as createMachine2 } from "@zag-js/core";
333
284
 
334
285
  // src/toast.machine.ts
335
286
  import { createMachine, guards } from "@zag-js/core";
336
287
  var { not, and, or } = guards;
337
288
  function createToastMachine(options = {}) {
338
- const _a = options, { type = "info", duration, id = "toast", placement = "bottom", removeDelay = 500 } = _a, rest = __objRest(_a, ["type", "duration", "id", "placement", "removeDelay"]);
289
+ const { type = "info", duration, id = "toast", placement = "bottom", removeDelay = 500, ...rest } = options;
339
290
  const __duration = getToastDuration(duration, type);
340
291
  return createMachine({
341
292
  id,
342
293
  entry: "invokeOnOpen",
343
294
  initial: type === "loading" ? "persist" : "active",
344
- context: __spreadValues({
295
+ context: {
345
296
  id,
346
297
  type,
347
298
  remaining: __duration,
348
299
  duration: __duration,
349
300
  removeDelay,
350
301
  createdAt: Date.now(),
351
- placement
352
- }, rest),
302
+ placement,
303
+ ...rest
304
+ },
353
305
  on: {
354
306
  UPDATE: [
355
307
  {
@@ -426,17 +378,17 @@ function createToastMachine(options = {}) {
426
378
  },
427
379
  guards: {
428
380
  isChangingToLoading: (_, evt) => {
429
- var _a2;
430
- return ((_a2 = evt.toast) == null ? void 0 : _a2.type) === "loading";
381
+ var _a;
382
+ return ((_a = evt.toast) == null ? void 0 : _a.type) === "loading";
431
383
  },
432
384
  isLoadingType: (ctx) => ctx.type === "loading",
433
385
  hasTypeChanged: (ctx, evt) => {
434
- var _a2;
435
- return ((_a2 = evt.toast) == null ? void 0 : _a2.type) !== ctx.type;
386
+ var _a;
387
+ return ((_a = evt.toast) == null ? void 0 : _a.type) !== ctx.type;
436
388
  },
437
389
  hasDurationChanged: (ctx, evt) => {
438
- var _a2;
439
- return ((_a2 = evt.toast) == null ? void 0 : _a2.duration) !== ctx.duration;
390
+ var _a;
391
+ return ((_a = evt.toast) == null ? void 0 : _a.duration) !== ctx.duration;
440
392
  }
441
393
  },
442
394
  delays: {
@@ -454,25 +406,25 @@ function createToastMachine(options = {}) {
454
406
  self.sendParent({ type: "REMOVE_TOAST", id: self.id });
455
407
  },
456
408
  invokeOnClosing(ctx) {
457
- var _a2;
458
- (_a2 = ctx.onClosing) == null ? void 0 : _a2.call(ctx);
409
+ var _a;
410
+ (_a = ctx.onClosing) == null ? void 0 : _a.call(ctx);
459
411
  },
460
412
  invokeOnClose(ctx) {
461
- var _a2;
462
- (_a2 = ctx.onClose) == null ? void 0 : _a2.call(ctx);
413
+ var _a;
414
+ (_a = ctx.onClose) == null ? void 0 : _a.call(ctx);
463
415
  },
464
416
  invokeOnOpen(ctx) {
465
- var _a2;
466
- (_a2 = ctx.onOpen) == null ? void 0 : _a2.call(ctx);
417
+ var _a;
418
+ (_a = ctx.onOpen) == null ? void 0 : _a.call(ctx);
467
419
  },
468
420
  invokeOnUpdate(ctx) {
469
- var _a2;
470
- (_a2 = ctx.onUpdate) == null ? void 0 : _a2.call(ctx);
421
+ var _a;
422
+ (_a = ctx.onUpdate) == null ? void 0 : _a.call(ctx);
471
423
  },
472
424
  setContext(ctx, evt) {
473
425
  const { duration: duration2, type: type2 } = evt.toast;
474
426
  const time = getToastDuration(duration2, type2);
475
- Object.assign(ctx, __spreadProps(__spreadValues({}, evt.toast), { duration: time, remaining: time }));
427
+ Object.assign(ctx, { ...evt.toast, duration: time, remaining: time });
476
428
  }
477
429
  }
478
430
  });
@@ -483,7 +435,7 @@ function groupMachine(ctx) {
483
435
  return createMachine2({
484
436
  id: "toaster",
485
437
  initial: "active",
486
- context: __spreadValues({
438
+ context: {
487
439
  dir: "ltr",
488
440
  max: Number.MAX_SAFE_INTEGER,
489
441
  toasts: [],
@@ -491,8 +443,9 @@ function groupMachine(ctx) {
491
443
  zIndex: MAX_Z_INDEX,
492
444
  pauseOnPageIdle: false,
493
445
  pauseOnInteraction: true,
494
- offsets: { left: "0px", right: "0px", top: "0px", bottom: "0px" }
495
- }, ctx),
446
+ offsets: { left: "0px", right: "0px", top: "0px", bottom: "0px" },
447
+ ...ctx
448
+ },
496
449
  computed: {
497
450
  count: (ctx2) => ctx2.toasts.length
498
451
  },
@@ -521,13 +474,13 @@ function groupMachine(ctx) {
521
474
  ADD_TOAST: {
522
475
  guard: (ctx2) => ctx2.toasts.length < ctx2.max,
523
476
  actions: (ctx2, evt, { self }) => {
524
- var _a;
525
- const options = __spreadProps(__spreadValues({}, evt.toast), {
477
+ const options = {
478
+ ...evt.toast,
526
479
  pauseOnPageIdle: ctx2.pauseOnPageIdle,
527
480
  pauseOnInteraction: ctx2.pauseOnInteraction,
528
481
  dir: ctx2.dir,
529
- doc: ref((_a = ctx2.doc) != null ? _a : document)
530
- });
482
+ getRootNode: ctx2.getRootNode
483
+ };
531
484
  const toast = createToastMachine(options);
532
485
  const actor = self.spawn(toast);
533
486
  ctx2.toasts.push(actor);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zag-js/toast",
3
- "version": "0.1.10",
3
+ "version": "0.1.11",
4
4
  "description": "Core logic for the toast widget implemented as a state machine",
5
5
  "keywords": [
6
6
  "js",
@@ -29,20 +29,21 @@
29
29
  "url": "https://github.com/chakra-ui/zag/issues"
30
30
  },
31
31
  "dependencies": {
32
- "@zag-js/core": "0.1.8",
33
- "@zag-js/types": "0.2.2"
32
+ "@zag-js/core": "0.1.9",
33
+ "@zag-js/types": "0.2.3"
34
34
  },
35
35
  "devDependencies": {
36
- "@zag-js/dom-utils": "0.1.7",
37
- "@zag-js/utils": "0.1.2"
36
+ "@zag-js/dom-utils": "0.1.8",
37
+ "@zag-js/utils": "0.1.3"
38
38
  },
39
39
  "scripts": {
40
- "build:fast": "zag build",
41
- "start": "zag build --watch",
42
- "build": "zag build --prod",
40
+ "build-fast": "tsup src/index.ts --format=esm,cjs",
41
+ "start": "pnpm build --watch",
42
+ "build": "tsup src/index.ts --format=esm,cjs --dts",
43
43
  "test": "jest --config ../../../jest.config.js --rootDir . --passWithNoTests",
44
44
  "lint": "eslint src --ext .ts,.tsx",
45
- "test:ci": "yarn test --ci --runInBand",
46
- "test:watch": "yarn test --watch --updateSnapshot"
45
+ "test-ci": "pnpm test --ci --runInBand",
46
+ "test-watch": "pnpm test --watch -u",
47
+ "typecheck": "tsc --noEmit"
47
48
  }
48
- }
49
+ }
@@ -1,24 +0,0 @@
1
- import type { NormalizeProps, PropTypes } from "@zag-js/types";
2
- import type { GroupMachineContext, GroupProps, GroupSend, GroupState, Placement, PromiseOptions, Toaster, Options } from "./toast.types";
3
- export declare let toaster: Toaster;
4
- export declare function groupConnect<T extends PropTypes>(state: GroupState, send: GroupSend, normalize: NormalizeProps<T>): {
5
- count: number;
6
- toasts: import("./toast.types").Service[];
7
- toastsByPlacement: Partial<Record<Placement, import("./toast.types").Service[]>>;
8
- isVisible(id: string): boolean;
9
- create(options: Options): string;
10
- upsert(options: Options): string;
11
- dismiss(id?: string): void;
12
- remove(id?: string): void;
13
- dismissByPlacement(placement: Placement): void;
14
- update(id: string, options: Options): string;
15
- loading(options: Options): string;
16
- success(options: Options): string;
17
- error(options: Options): string;
18
- promise<T_1>(promise: Promise<T_1>, options: PromiseOptions<T_1>, shared?: Options): Promise<T_1>;
19
- pause(id?: string): void;
20
- resume(id?: string): void;
21
- getGroupProps(options: GroupProps): T["element"];
22
- createPortal(): HTMLElement;
23
- subscribe(fn: (toasts: GroupMachineContext["toasts"]) => void): () => void;
24
- };
@@ -1,2 +0,0 @@
1
- import type { GroupMachineContext, UserDefinedGroupContext } from "./toast.types";
2
- export declare function groupMachine(ctx: UserDefinedGroupContext): import("@zag-js/core").Machine<GroupMachineContext, import("@zag-js/core").StateMachine.StateSchema, import("@zag-js/core").StateMachine.AnyEventObject>;
@@ -1,17 +0,0 @@
1
- import type { NormalizeProps, PropTypes } from "@zag-js/types";
2
- import type { Send, State } from "./toast.types";
3
- export declare function connect<T extends PropTypes>(state: State, send: Send, normalize: NormalizeProps<T>): {
4
- type: import("./toast.types").Type;
5
- title: string;
6
- placement: import("./toast.types").Placement;
7
- isVisible: boolean;
8
- isPaused: boolean;
9
- pause(): void;
10
- resume(): void;
11
- dismiss(): void;
12
- rootProps: T["element"];
13
- progressbarProps: T["element"];
14
- titleProps: T["element"];
15
- closeButtonProps: T["button"];
16
- render(): any;
17
- };
@@ -1,26 +0,0 @@
1
- import type { GroupMachineContext as GroupCtx, MachineContext as Ctx, Placement } from "./toast.types";
2
- export declare const dom: {
3
- getRootNode: (ctx: {
4
- getRootNode?: () => Node | Document | ShadowRoot;
5
- }) => Document | ShadowRoot;
6
- getDoc: (ctx: {
7
- getRootNode?: () => Node | Document | ShadowRoot;
8
- }) => Document;
9
- getWin: (ctx: {
10
- getRootNode?: () => Node | Document | ShadowRoot;
11
- }) => Window & typeof globalThis;
12
- getActiveElement: (ctx: {
13
- getRootNode?: () => Node | Document | ShadowRoot;
14
- }) => HTMLElement;
15
- getById: <T_1 = HTMLElement>(ctx: {
16
- getRootNode?: () => Node | Document | ShadowRoot;
17
- }, id: string) => T_1;
18
- } & {
19
- getGroupId: (placement: Placement) => string;
20
- getContainerId: (ctx: Ctx) => string;
21
- getTitleId: (ctx: Ctx) => string;
22
- getCloseButtonId: (ctx: Ctx) => string;
23
- getPortalId: (ctx: GroupCtx) => string;
24
- getPortalEl: (ctx: GroupCtx) => HTMLElement;
25
- createPortalEl: (ctx: GroupCtx) => HTMLElement;
26
- };
@@ -1,2 +0,0 @@
1
- import type { MachineContext, MachineState, Options } from "./toast.types";
2
- export declare function createToastMachine(options?: Options): import("@zag-js/core").Machine<MachineContext, MachineState, import("@zag-js/core").StateMachine.AnyEventObject>;
@@ -1,154 +0,0 @@
1
- import type { Machine, StateMachine as S } from "@zag-js/core";
2
- import type { CommonProperties, Context, Direction, DirectionProperty, RequiredBy, RootProperties } from "@zag-js/types";
3
- export declare type Type = "success" | "error" | "loading" | "info" | "custom";
4
- export declare type Placement = "top-start" | "top" | "top-end" | "bottom-start" | "bottom" | "bottom-end";
5
- declare type SharedContext = {
6
- /**
7
- * Whether to pause toast when the user leaves the browser tab
8
- */
9
- pauseOnPageIdle?: boolean;
10
- /**
11
- * Whether to pause the toast when interacted with
12
- */
13
- pauseOnInteraction?: boolean;
14
- };
15
- export declare type ToastOptions = {
16
- /**
17
- * The unique id of the toast
18
- */
19
- id: string;
20
- /**
21
- * The type of the toast
22
- */
23
- type: Type;
24
- /**
25
- * The placement of the toast
26
- */
27
- placement: Placement;
28
- /**
29
- * The message of the toast
30
- */
31
- title?: string;
32
- /**
33
- * The description of the toast
34
- */
35
- description?: string;
36
- /**
37
- * The duration the toast will be visible
38
- */
39
- duration: number;
40
- /**
41
- * Custom function to render the toast element.
42
- */
43
- render?: (options: RenderOptions) => any;
44
- /**
45
- * The duration for the toast to kept alive before it is removed.
46
- * Useful for exit transitions.
47
- */
48
- removeDelay?: number;
49
- /**
50
- * Function called when the toast has been closed and removed
51
- */
52
- onClose?: VoidFunction;
53
- /**
54
- * Function called when the toast is leaving
55
- */
56
- onClosing?: VoidFunction;
57
- /**
58
- * Function called when the toast is shown
59
- */
60
- onOpen?: VoidFunction;
61
- /**
62
- * Function called when the toast is updated
63
- */
64
- onUpdate?: VoidFunction;
65
- };
66
- export declare type Options = Partial<ToastOptions>;
67
- export declare type RenderOptions = Omit<ToastOptions, "render"> & {
68
- dismiss(): void;
69
- };
70
- export declare type MachineContext = SharedContext & RootProperties & CommonProperties & Omit<ToastOptions, "removeDelay"> & {
71
- /**
72
- * The duration for the toast to kept alive before it is removed.
73
- * Useful for exit transitions.
74
- */
75
- removeDelay: number;
76
- /**
77
- * The document's text/writing direction.
78
- */
79
- dir?: Direction;
80
- /**
81
- * The time the toast was created
82
- */
83
- createdAt: number;
84
- /**
85
- * The time left before the toast is removed
86
- */
87
- remaining: number;
88
- };
89
- export declare type MachineState = {
90
- value: "active" | "active:temp" | "dismissing" | "inactive" | "persist";
91
- tags: "visible" | "paused" | "updating";
92
- };
93
- export declare type State = S.State<MachineContext, MachineState>;
94
- export declare type Send = S.Send;
95
- export declare type Service = Machine<MachineContext, MachineState>;
96
- declare type GroupPublicContext = SharedContext & DirectionProperty & CommonProperties & {
97
- /**
98
- * The gutter or spacing between toasts
99
- */
100
- gutter: string;
101
- /**
102
- * The z-index applied to each toast group
103
- */
104
- zIndex: number;
105
- /**
106
- * The maximum number of toasts that can be shown at once
107
- */
108
- max: number;
109
- /**
110
- * The offset from the safe environment edge of the viewport
111
- */
112
- offsets: string | Record<"left" | "right" | "bottom" | "top", string>;
113
- };
114
- export declare type UserDefinedGroupContext = RequiredBy<GroupPublicContext, "id">;
115
- declare type GroupComputedContext = Readonly<{
116
- /**
117
- * @computed
118
- * The total number of toasts in the group
119
- */
120
- readonly count: number;
121
- }>;
122
- declare type GroupPrivateContext = Context<{
123
- /**
124
- * @internal
125
- * The child toast machines (spawned by the toast group)
126
- */
127
- toasts: Service[];
128
- }>;
129
- export declare type GroupMachineContext = GroupPublicContext & GroupComputedContext & GroupPrivateContext;
130
- export declare type GroupState = S.State<GroupMachineContext>;
131
- export declare type GroupSend = (event: S.Event<S.AnyEventObject>) => void;
132
- declare type MaybeFunction<Value, Args> = Value | ((arg: Args) => Value);
133
- export declare type PromiseOptions<Value> = {
134
- loading: ToastOptions;
135
- success: MaybeFunction<ToastOptions, Value>;
136
- error: MaybeFunction<ToastOptions, Error>;
137
- };
138
- export declare type GroupProps = {
139
- placement: Placement;
140
- label?: string;
141
- };
142
- export declare type Toaster = {
143
- count: number;
144
- isVisible(id: string): boolean;
145
- upsert(options: ToastOptions): string | undefined;
146
- create(options: ToastOptions): string | undefined;
147
- success(options: ToastOptions): string | undefined;
148
- error(options: ToastOptions): string | undefined;
149
- loading(options: ToastOptions): string | undefined;
150
- dismiss(id?: string | undefined): void;
151
- remove(id?: string | undefined): void;
152
- promise<T>(promise: Promise<T>, options: PromiseOptions<T>, shared?: ToastOptions): Promise<T>;
153
- };
154
- export {};
@@ -1,6 +0,0 @@
1
- import type { Style } from "@zag-js/types";
2
- import type { GroupMachineContext, MachineContext, Placement, Service, Type } from "./toast.types";
3
- export declare function getToastsByPlacement(toasts: Service[]): Partial<Record<Placement, Service[]>>;
4
- export declare const defaultTimeouts: Record<Type, number>;
5
- export declare function getToastDuration(duration: number | undefined, type: MachineContext["type"]): number;
6
- export declare function getGroupPlacementStyle(ctx: GroupMachineContext, placement: Placement): Style;