@zag-js/toast 0.10.2 → 0.10.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,26 +1,12 @@
1
- import {
2
- groupConnect,
3
- toaster
4
- } from "./chunk-6TPPYHFP.mjs";
5
- import {
6
- groupMachine
7
- } from "./chunk-TCF4OLIQ.mjs";
8
- import {
9
- connect
10
- } from "./chunk-MUJMFD4Y.mjs";
11
- import {
12
- anatomy
13
- } from "./chunk-GQHI2OMI.mjs";
14
- import {
15
- createToastMachine
16
- } from "./chunk-EQTV3BNM.mjs";
17
- import "./chunk-DBPKSADW.mjs";
18
- import "./chunk-DUZD3NLM.mjs";
1
+ import { isDom } from '@zag-js/dom-query';
2
+ import { warn } from '@zag-js/utils';
3
+ import { groupConnect, toaster } from './toast-group.connect.mjs';
4
+ import { groupMachine } from './toast-group.machine.mjs';
5
+ export { createToastMachine as createMachine } from './toast.machine.mjs';
6
+ export { anatomy } from './toast.anatomy.mjs';
7
+ export { connect } from './toast.connect.mjs';
19
8
 
20
- // src/index.ts
21
- import { isDom } from "@zag-js/dom-query";
22
- import { warn } from "@zag-js/utils";
23
- var group = {
9
+ const group = {
24
10
  connect: groupConnect,
25
11
  machine: groupMachine
26
12
  };
@@ -31,10 +17,5 @@ function api() {
31
17
  return toaster;
32
18
  }
33
19
  }
34
- export {
35
- anatomy,
36
- api,
37
- connect,
38
- createToastMachine as createMachine,
39
- group
40
- };
20
+
21
+ export { api, group };
@@ -1,9 +1,7 @@
1
- import { Toaster, GroupState, GroupSend, Service, Placement, Options, PromiseOptions, GroupProps, GroupMachineContext } from './toast.types.js';
2
- import { PropTypes, NormalizeProps } from '@zag-js/types';
3
- import '@zag-js/core';
4
-
5
- declare let toaster: Toaster;
6
- declare function groupConnect<T extends PropTypes>(state: GroupState, send: GroupSend, normalize: NormalizeProps<T>): {
1
+ import type { NormalizeProps, PropTypes } from "@zag-js/types";
2
+ import { Service, 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>): {
7
5
  /**
8
6
  * The total number of toasts
9
7
  */
@@ -75,5 +73,3 @@ declare function groupConnect<T extends PropTypes>(state: GroupState, send: Grou
75
73
  getGroupProps(options: GroupProps): T["element"];
76
74
  subscribe(fn: (toasts: GroupMachineContext["toasts"]) => void): () => void;
77
75
  };
78
-
79
- export { groupConnect, toaster };
@@ -1,100 +1,14 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
1
+ 'use strict';
19
2
 
20
- // src/toast-group.connect.ts
21
- var toast_group_connect_exports = {};
22
- __export(toast_group_connect_exports, {
23
- groupConnect: () => groupConnect,
24
- toaster: () => toaster
25
- });
26
- module.exports = __toCommonJS(toast_group_connect_exports);
27
- var import_core = require("@zag-js/core");
28
- var import_utils = require("@zag-js/utils");
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
29
4
 
30
- // src/toast.anatomy.ts
31
- var import_anatomy = require("@zag-js/anatomy");
32
- var anatomy = (0, import_anatomy.createAnatomy)("toast").parts("group", "root", "title", "description", "closeTrigger");
33
- var parts = anatomy.build();
5
+ const core = require('@zag-js/core');
6
+ const utils = require('@zag-js/utils');
7
+ const toast_anatomy = require('./toast.anatomy.js');
8
+ const toast_dom = require('./toast.dom.js');
9
+ const toast_utils = require('./toast.utils.js');
34
10
 
35
- // src/toast.dom.ts
36
- var import_dom_query = require("@zag-js/dom-query");
37
- var dom = (0, import_dom_query.createScope)({
38
- getGroupId: (placement) => `toast-group:${placement}`,
39
- getRootId: (ctx) => `toast:${ctx.id}`,
40
- getTitleId: (ctx) => `toast:${ctx.id}:title`,
41
- getDescriptionId: (ctx) => `toast:${ctx.id}:description`,
42
- getCloseTriggerId: (ctx) => `toast${ctx.id}:close`,
43
- getPortalId: (ctx) => `toast-portal:${ctx.id}`
44
- });
45
-
46
- // src/toast.utils.ts
47
- function getToastsByPlacement(toasts) {
48
- const result = {};
49
- for (const toast of toasts) {
50
- const placement = toast.state.context.placement;
51
- result[placement] || (result[placement] = []);
52
- result[placement].push(toast);
53
- }
54
- return result;
55
- }
56
- function getGroupPlacementStyle(ctx, placement) {
57
- const offset = ctx.offsets;
58
- const computedOffset = typeof offset === "string" ? { left: offset, right: offset, bottom: offset, top: offset } : offset;
59
- const rtl = ctx.dir === "rtl";
60
- const computedPlacement = placement.replace("-start", rtl ? "-right" : "-left").replace("-end", rtl ? "-left" : "-right");
61
- const isRighty = computedPlacement.includes("right");
62
- const isLefty = computedPlacement.includes("left");
63
- const styles = {
64
- position: "fixed",
65
- pointerEvents: ctx.count > 0 ? void 0 : "none",
66
- display: "flex",
67
- flexDirection: "column",
68
- "--toast-gutter": ctx.gutter,
69
- zIndex: ctx.zIndex
70
- };
71
- let alignItems = "center";
72
- if (isRighty)
73
- alignItems = "flex-end";
74
- if (isLefty)
75
- alignItems = "flex-start";
76
- styles.alignItems = alignItems;
77
- if (computedPlacement.includes("top")) {
78
- const offset2 = computedOffset.top;
79
- styles.top = `calc(env(safe-area-inset-top, 0px) + ${offset2})`;
80
- }
81
- if (computedPlacement.includes("bottom")) {
82
- const offset2 = computedOffset.bottom;
83
- styles.bottom = `calc(env(safe-area-inset-bottom, 0px) + ${offset2})`;
84
- }
85
- if (!computedPlacement.includes("left")) {
86
- const offset2 = computedOffset.right;
87
- styles.right = `calc(env(safe-area-inset-right, 0px) + ${offset2})`;
88
- }
89
- if (!computedPlacement.includes("right")) {
90
- const offset2 = computedOffset.left;
91
- styles.left = `calc(env(safe-area-inset-left, 0px) + ${offset2})`;
92
- }
93
- return styles;
94
- }
95
-
96
- // src/toast-group.connect.ts
97
- var toaster = {};
11
+ let toaster = {};
98
12
  function groupConnect(state, send, normalize) {
99
13
  const group = {
100
14
  /**
@@ -108,7 +22,7 @@ function groupConnect(state, send, normalize) {
108
22
  /**
109
23
  * The active toasts by placement
110
24
  */
111
- toastsByPlacement: getToastsByPlacement(state.context.toasts),
25
+ toastsByPlacement: toast_utils.getToastsByPlacement(state.context.toasts),
112
26
  /**
113
27
  * Returns whether the toast id is visible
114
28
  */
@@ -121,7 +35,7 @@ function groupConnect(state, send, normalize) {
121
35
  * Function to create a toast.
122
36
  */
123
37
  create(options) {
124
- const uid = `toast:${(0, import_utils.uuid)()}`;
38
+ const uid = `toast:${utils.uuid()}`;
125
39
  const id = options.id ? options.id : uid;
126
40
  if (group.isVisible(id))
127
41
  return;
@@ -209,10 +123,10 @@ function groupConnect(state, send, normalize) {
209
123
  promise(promise, options, shared = {}) {
210
124
  const id = group.loading({ ...shared, ...options.loading });
211
125
  promise.then((response) => {
212
- const successOptions = (0, import_utils.runIfFn)(options.success, response);
126
+ const successOptions = utils.runIfFn(options.success, response);
213
127
  group.success({ ...shared, ...successOptions, id });
214
128
  }).catch((error) => {
215
- const errorOptions = (0, import_utils.runIfFn)(options.error, error);
129
+ const errorOptions = utils.runIfFn(options.error, error);
216
130
  group.error({ ...shared, ...errorOptions, id });
217
131
  });
218
132
  return promise;
@@ -240,25 +154,23 @@ function groupConnect(state, send, normalize) {
240
154
  getGroupProps(options) {
241
155
  const { placement, label = "Notifications" } = options;
242
156
  return normalize.element({
243
- ...parts.group.attrs,
157
+ ...toast_anatomy.parts.group.attrs,
244
158
  tabIndex: -1,
245
159
  "aria-label": label,
246
- id: dom.getGroupId(placement),
160
+ id: toast_dom.dom.getGroupId(placement),
247
161
  "data-placement": placement,
248
162
  "aria-live": "polite",
249
163
  role: "region",
250
- style: getGroupPlacementStyle(state.context, placement)
164
+ style: toast_utils.getGroupPlacementStyle(state.context, placement)
251
165
  });
252
166
  },
253
167
  subscribe(fn) {
254
- return (0, import_core.subscribe)(state.context.toasts, () => fn(state.context.toasts));
168
+ return core.subscribe(state.context.toasts, () => fn(state.context.toasts));
255
169
  }
256
170
  };
257
171
  Object.assign(toaster, group);
258
172
  return group;
259
173
  }
260
- // Annotate the CommonJS export names for ESM import in node:
261
- 0 && (module.exports = {
262
- groupConnect,
263
- toaster
264
- });
174
+
175
+ exports.groupConnect = groupConnect;
176
+ exports.toaster = toaster;
@@ -1,11 +1,171 @@
1
- import {
2
- groupConnect,
3
- toaster
4
- } from "./chunk-6TPPYHFP.mjs";
5
- import "./chunk-GQHI2OMI.mjs";
6
- import "./chunk-DBPKSADW.mjs";
7
- import "./chunk-DUZD3NLM.mjs";
8
- export {
9
- groupConnect,
10
- toaster
11
- };
1
+ import { subscribe } from '@zag-js/core';
2
+ import { uuid, runIfFn } from '@zag-js/utils';
3
+ import { parts } from './toast.anatomy.mjs';
4
+ import { dom } from './toast.dom.mjs';
5
+ import { getToastsByPlacement, getGroupPlacementStyle } from './toast.utils.mjs';
6
+
7
+ let toaster = {};
8
+ function groupConnect(state, send, normalize) {
9
+ const group = {
10
+ /**
11
+ * The total number of toasts
12
+ */
13
+ count: state.context.count,
14
+ /**
15
+ * The active toasts
16
+ */
17
+ toasts: state.context.toasts,
18
+ /**
19
+ * The active toasts by placement
20
+ */
21
+ toastsByPlacement: getToastsByPlacement(state.context.toasts),
22
+ /**
23
+ * Returns whether the toast id is visible
24
+ */
25
+ isVisible(id) {
26
+ if (!state.context.toasts.length)
27
+ return false;
28
+ return !!state.context.toasts.find((toast) => toast.id == id);
29
+ },
30
+ /**
31
+ * Function to create a toast.
32
+ */
33
+ create(options) {
34
+ const uid = `toast:${uuid()}`;
35
+ const id = options.id ? options.id : uid;
36
+ if (group.isVisible(id))
37
+ return;
38
+ send({ type: "ADD_TOAST", toast: { ...options, id } });
39
+ return id;
40
+ },
41
+ /**
42
+ * Function to create or update a toast.
43
+ */
44
+ upsert(options) {
45
+ const { id } = options;
46
+ const isVisible = id ? group.isVisible(id) : false;
47
+ if (isVisible && id != null) {
48
+ return group.update(id, options);
49
+ } else {
50
+ return group.create(options);
51
+ }
52
+ },
53
+ /**
54
+ * Function to dismiss a toast by id.
55
+ * If no id is provided, all toasts will be dismissed.
56
+ */
57
+ dismiss(id) {
58
+ if (id == null) {
59
+ send("DISMISS_ALL");
60
+ } else if (group.isVisible(id)) {
61
+ send({ type: "DISMISS_TOAST", id });
62
+ }
63
+ },
64
+ /**
65
+ * Function to remove a toast by id.
66
+ * If no id is provided, all toasts will be removed.
67
+ */
68
+ remove(id) {
69
+ if (id == null) {
70
+ send("REMOVE_ALL");
71
+ } else if (group.isVisible(id)) {
72
+ send({ type: "REMOVE_TOAST", id });
73
+ }
74
+ },
75
+ /**
76
+ * Function to dismiss all toasts by placement.
77
+ */
78
+ dismissByPlacement(placement) {
79
+ const toasts = group.toastsByPlacement[placement];
80
+ if (toasts) {
81
+ toasts.forEach((toast) => group.dismiss(toast.id));
82
+ }
83
+ },
84
+ /**
85
+ * Function to update a toast's options by id.
86
+ */
87
+ update(id, options) {
88
+ if (!group.isVisible(id))
89
+ return;
90
+ send({ type: "UPDATE_TOAST", id, toast: options });
91
+ return id;
92
+ },
93
+ /**
94
+ * Function to create a loading toast.
95
+ */
96
+ loading(options) {
97
+ options.type = "loading";
98
+ return group.upsert(options);
99
+ },
100
+ /**
101
+ * Function to create a success toast.
102
+ */
103
+ success(options) {
104
+ options.type = "success";
105
+ return group.upsert(options);
106
+ },
107
+ /**
108
+ * Function to create an error toast.
109
+ */
110
+ error(options) {
111
+ options.type = "error";
112
+ return group.upsert(options);
113
+ },
114
+ /**
115
+ * Function to create a toast from a promise.
116
+ * - When the promise resolves, the toast will be updated with the success options.
117
+ * - When the promise rejects, the toast will be updated with the error options.
118
+ */
119
+ promise(promise, options, shared = {}) {
120
+ const id = group.loading({ ...shared, ...options.loading });
121
+ promise.then((response) => {
122
+ const successOptions = runIfFn(options.success, response);
123
+ group.success({ ...shared, ...successOptions, id });
124
+ }).catch((error) => {
125
+ const errorOptions = runIfFn(options.error, error);
126
+ group.error({ ...shared, ...errorOptions, id });
127
+ });
128
+ return promise;
129
+ },
130
+ /**
131
+ * Function to pause a toast by id.
132
+ */
133
+ pause(id) {
134
+ if (id == null) {
135
+ send("PAUSE_ALL");
136
+ } else if (group.isVisible(id)) {
137
+ send({ type: "PAUSE_TOAST", id });
138
+ }
139
+ },
140
+ /**
141
+ * Function to resume a toast by id.
142
+ */
143
+ resume(id) {
144
+ if (id == null) {
145
+ send("RESUME_ALL");
146
+ } else if (group.isVisible(id)) {
147
+ send({ type: "RESUME_TOAST", id });
148
+ }
149
+ },
150
+ getGroupProps(options) {
151
+ const { placement, label = "Notifications" } = options;
152
+ return normalize.element({
153
+ ...parts.group.attrs,
154
+ tabIndex: -1,
155
+ "aria-label": label,
156
+ id: dom.getGroupId(placement),
157
+ "data-placement": placement,
158
+ "aria-live": "polite",
159
+ role: "region",
160
+ style: getGroupPlacementStyle(state.context, placement)
161
+ });
162
+ },
163
+ subscribe(fn) {
164
+ return subscribe(state.context.toasts, () => fn(state.context.toasts));
165
+ }
166
+ };
167
+ Object.assign(toaster, group);
168
+ return group;
169
+ }
170
+
171
+ export { groupConnect, toaster };
@@ -1,7 +1,3 @@
1
- import * as _zag_js_core from '@zag-js/core';
2
- import { UserDefinedGroupContext, GroupMachineContext } from './toast.types.js';
3
- import '@zag-js/types';
4
-
5
- declare function groupMachine(userContext: UserDefinedGroupContext): _zag_js_core.Machine<GroupMachineContext, _zag_js_core.StateMachine.StateSchema, _zag_js_core.StateMachine.AnyEventObject>;
6
-
7
- export { groupMachine };
1
+ import { Machine, StateMachine } from '@zag-js/core';
2
+ import type { GroupMachineContext, UserDefinedGroupContext } from "./toast.types";
3
+ export declare function groupMachine(userContext: UserDefinedGroupContext): Machine<GroupMachineContext, StateMachine.StateSchema, StateMachine.AnyEventObject>;
@@ -1,203 +1,15 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
1
+ 'use strict';
19
2
 
20
- // src/toast-group.machine.ts
21
- var toast_group_machine_exports = {};
22
- __export(toast_group_machine_exports, {
23
- groupMachine: () => groupMachine
24
- });
25
- module.exports = __toCommonJS(toast_group_machine_exports);
26
- var import_core2 = require("@zag-js/core");
27
- var import_dom_query2 = require("@zag-js/dom-query");
28
- var import_utils2 = require("@zag-js/utils");
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
29
4
 
30
- // src/toast.machine.ts
31
- var import_core = require("@zag-js/core");
32
- var import_dom_event = require("@zag-js/dom-event");
33
- var import_utils = require("@zag-js/utils");
5
+ const core = require('@zag-js/core');
6
+ const domQuery = require('@zag-js/dom-query');
7
+ const utils = require('@zag-js/utils');
8
+ const toast_machine = require('./toast.machine.js');
34
9
 
35
- // src/toast.dom.ts
36
- var import_dom_query = require("@zag-js/dom-query");
37
- var dom = (0, import_dom_query.createScope)({
38
- getGroupId: (placement) => `toast-group:${placement}`,
39
- getRootId: (ctx) => `toast:${ctx.id}`,
40
- getTitleId: (ctx) => `toast:${ctx.id}:title`,
41
- getDescriptionId: (ctx) => `toast:${ctx.id}:description`,
42
- getCloseTriggerId: (ctx) => `toast${ctx.id}:close`,
43
- getPortalId: (ctx) => `toast-portal:${ctx.id}`
44
- });
45
-
46
- // src/toast.utils.ts
47
- var defaultTimeouts = {
48
- info: 5e3,
49
- error: 5e3,
50
- success: 2e3,
51
- loading: Infinity,
52
- custom: 5e3
53
- };
54
- function getToastDuration(duration, type) {
55
- return duration ?? defaultTimeouts[type];
56
- }
57
-
58
- // src/toast.machine.ts
59
- var { not, and, or } = import_core.guards;
60
- function createToastMachine(options = {}) {
61
- const { type = "info", duration, id = "toast", placement = "bottom", removeDelay = 0, ...restProps } = options;
62
- const ctx = (0, import_utils.compact)(restProps);
63
- const computedDuration = getToastDuration(duration, type);
64
- return (0, import_core.createMachine)(
65
- {
66
- id,
67
- entry: "invokeOnOpen",
68
- initial: type === "loading" ? "persist" : "active",
69
- context: {
70
- id,
71
- type,
72
- remaining: computedDuration,
73
- duration: computedDuration,
74
- removeDelay,
75
- createdAt: Date.now(),
76
- placement,
77
- ...ctx
78
- },
79
- on: {
80
- UPDATE: [
81
- {
82
- guard: and("hasTypeChanged", "isChangingToLoading"),
83
- target: "persist",
84
- actions: ["setContext", "invokeOnUpdate"]
85
- },
86
- {
87
- guard: or("hasDurationChanged", "hasTypeChanged"),
88
- target: "active:temp",
89
- actions: ["setContext", "invokeOnUpdate"]
90
- },
91
- {
92
- actions: ["setContext", "invokeOnUpdate"]
93
- }
94
- ]
95
- },
96
- states: {
97
- "active:temp": {
98
- tags: ["visible", "updating"],
99
- after: {
100
- 0: "active"
101
- }
102
- },
103
- persist: {
104
- tags: ["visible", "paused"],
105
- activities: "trackDocumentVisibility",
106
- on: {
107
- RESUME: {
108
- guard: not("isLoadingType"),
109
- target: "active",
110
- actions: ["setCreatedAt"]
111
- },
112
- DISMISS: "dismissing"
113
- }
114
- },
115
- active: {
116
- tags: ["visible"],
117
- activities: "trackDocumentVisibility",
118
- after: {
119
- VISIBLE_DURATION: "dismissing"
120
- },
121
- on: {
122
- DISMISS: "dismissing",
123
- PAUSE: {
124
- target: "persist",
125
- actions: "setRemainingDuration"
126
- }
127
- }
128
- },
129
- dismissing: {
130
- entry: "invokeOnClosing",
131
- after: {
132
- REMOVE_DELAY: {
133
- target: "inactive",
134
- actions: "notifyParentToRemove"
135
- }
136
- }
137
- },
138
- inactive: {
139
- entry: "invokeOnClose",
140
- type: "final"
141
- }
142
- }
143
- },
144
- {
145
- activities: {
146
- trackDocumentVisibility(ctx2, _evt, { send }) {
147
- if (!ctx2.pauseOnPageIdle)
148
- return;
149
- const doc = dom.getDoc(ctx2);
150
- return (0, import_dom_event.addDomEvent)(doc, "visibilitychange", () => {
151
- send(doc.visibilityState === "hidden" ? "PAUSE" : "RESUME");
152
- });
153
- }
154
- },
155
- guards: {
156
- isChangingToLoading: (_, evt) => evt.toast?.type === "loading",
157
- isLoadingType: (ctx2) => ctx2.type === "loading",
158
- hasTypeChanged: (ctx2, evt) => evt.toast?.type !== ctx2.type,
159
- hasDurationChanged: (ctx2, evt) => evt.toast?.duration !== ctx2.duration
160
- },
161
- delays: {
162
- VISIBLE_DURATION: (ctx2) => ctx2.remaining,
163
- REMOVE_DELAY: (ctx2) => ctx2.removeDelay
164
- },
165
- actions: {
166
- setRemainingDuration(ctx2) {
167
- ctx2.remaining -= Date.now() - ctx2.createdAt;
168
- },
169
- setCreatedAt(ctx2) {
170
- ctx2.createdAt = Date.now();
171
- },
172
- notifyParentToRemove(_ctx, _evt, { self }) {
173
- self.sendParent({ type: "REMOVE_TOAST", id: self.id });
174
- },
175
- invokeOnClosing(ctx2) {
176
- ctx2.onClosing?.();
177
- },
178
- invokeOnClose(ctx2) {
179
- ctx2.onClose?.();
180
- },
181
- invokeOnOpen(ctx2) {
182
- ctx2.onOpen?.();
183
- },
184
- invokeOnUpdate(ctx2) {
185
- ctx2.onUpdate?.();
186
- },
187
- setContext(ctx2, evt) {
188
- const { duration: duration2, type: type2 } = evt.toast;
189
- const time = getToastDuration(duration2, type2);
190
- Object.assign(ctx2, { ...evt.toast, duration: time, remaining: time });
191
- }
192
- }
193
- }
194
- );
195
- }
196
-
197
- // src/toast-group.machine.ts
198
10
  function groupMachine(userContext) {
199
- const ctx = (0, import_utils2.compact)(userContext);
200
- return (0, import_core2.createMachine)({
11
+ const ctx = utils.compact(userContext);
12
+ return core.createMachine({
201
13
  id: "toaster",
202
14
  initial: "active",
203
15
  context: {
@@ -205,7 +17,7 @@ function groupMachine(userContext) {
205
17
  max: Number.MAX_SAFE_INTEGER,
206
18
  toasts: [],
207
19
  gutter: "1rem",
208
- zIndex: import_dom_query2.MAX_Z_INDEX,
20
+ zIndex: domQuery.MAX_Z_INDEX,
209
21
  pauseOnPageIdle: false,
210
22
  pauseOnInteraction: true,
211
23
  offsets: { left: "0px", right: "0px", top: "0px", bottom: "0px" },
@@ -246,7 +58,7 @@ function groupMachine(userContext) {
246
58
  dir: ctx2.dir,
247
59
  getRootNode: ctx2.getRootNode
248
60
  };
249
- const toast = createToastMachine(options);
61
+ const toast = toast_machine.createToastMachine(options);
250
62
  const actor = self.spawn(toast);
251
63
  ctx2.toasts.push(actor);
252
64
  }
@@ -283,7 +95,5 @@ function groupMachine(userContext) {
283
95
  }
284
96
  });
285
97
  }
286
- // Annotate the CommonJS export names for ESM import in node:
287
- 0 && (module.exports = {
288
- groupMachine
289
- });
98
+
99
+ exports.groupMachine = groupMachine;