@zag-js/toast 0.2.6 → 0.2.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-EMY6MMVS.mjs +116 -0
- package/dist/chunk-GQHI2OMI.mjs +9 -0
- package/dist/chunk-KJLVUGML.mjs +202 -0
- package/dist/chunk-LOJTIJID.mjs +66 -0
- package/dist/chunk-LOTG5P4K.mjs +104 -0
- package/dist/chunk-MCVNSXDU.mjs +144 -0
- package/dist/chunk-SMQXX7JA.mjs +57 -0
- package/dist/chunk-YVYADWQR.mjs +19 -0
- package/dist/index.d.ts +11 -1043
- package/dist/index.js +45 -51
- package/dist/index.mjs +23 -656
- package/dist/toast-group.connect.d.ts +28 -0
- package/dist/toast-group.connect.js +278 -0
- package/dist/toast-group.connect.mjs +12 -0
- package/dist/toast-group.machine.d.ts +7 -0
- package/dist/toast-group.machine.js +383 -0
- package/dist/toast-group.machine.mjs +10 -0
- package/dist/toast.anatomy.d.ts +6 -0
- package/dist/toast.anatomy.js +34 -0
- package/dist/toast.anatomy.mjs +8 -0
- package/dist/toast.connect.d.ts +23 -0
- package/dist/toast.connect.js +194 -0
- package/dist/toast.connect.mjs +8 -0
- package/dist/toast.dom.d.ts +32 -0
- package/dist/toast.dom.js +83 -0
- package/dist/toast.dom.mjs +6 -0
- package/dist/toast.machine.d.ts +7 -0
- package/dist/toast.machine.js +287 -0
- package/dist/toast.machine.mjs +9 -0
- package/dist/toast.types.d.ts +150 -0
- package/dist/toast.types.js +18 -0
- package/dist/toast.types.mjs +0 -0
- package/dist/toast.utils.d.ts +10 -0
- package/dist/toast.utils.js +93 -0
- package/dist/toast.utils.mjs +12 -0
- package/package.json +21 -11
package/dist/index.js
CHANGED
|
@@ -28,18 +28,55 @@ __export(src_exports, {
|
|
|
28
28
|
});
|
|
29
29
|
module.exports = __toCommonJS(src_exports);
|
|
30
30
|
|
|
31
|
-
// ../../utilities/dom/
|
|
31
|
+
// ../../utilities/dom/src/attrs.ts
|
|
32
32
|
var dataAttr = (guard) => {
|
|
33
33
|
return guard ? "" : void 0;
|
|
34
34
|
};
|
|
35
|
+
|
|
36
|
+
// ../../utilities/dom/src/constants.ts
|
|
35
37
|
var MAX_Z_INDEX = 2147483647;
|
|
38
|
+
|
|
39
|
+
// ../../utilities/core/src/functions.ts
|
|
36
40
|
var runIfFn = (v, ...a) => {
|
|
37
41
|
const res = typeof v === "function" ? v(...a) : v;
|
|
38
42
|
return res != null ? res : void 0;
|
|
39
43
|
};
|
|
40
44
|
var cast = (v) => v;
|
|
45
|
+
var uuid = /* @__PURE__ */ (() => {
|
|
46
|
+
let id = 0;
|
|
47
|
+
return () => {
|
|
48
|
+
id++;
|
|
49
|
+
return id.toString(36);
|
|
50
|
+
};
|
|
51
|
+
})();
|
|
52
|
+
|
|
53
|
+
// ../../utilities/core/src/guard.ts
|
|
54
|
+
var isArray = (v) => Array.isArray(v);
|
|
55
|
+
var isObject = (v) => !(v == null || typeof v !== "object" || isArray(v));
|
|
41
56
|
var hasProp = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
|
|
57
|
+
|
|
58
|
+
// ../../utilities/core/src/object.ts
|
|
59
|
+
function compact(obj) {
|
|
60
|
+
if (obj === void 0)
|
|
61
|
+
return obj;
|
|
62
|
+
return Object.fromEntries(
|
|
63
|
+
Object.entries(obj).filter(([, value]) => value !== void 0).map(([key, value]) => [key, isObject(value) ? compact(value) : value])
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// ../../utilities/core/src/warning.ts
|
|
68
|
+
function warn(...a) {
|
|
69
|
+
const m = a.length === 1 ? a[0] : a[1];
|
|
70
|
+
const c = a.length === 2 ? a[0] : true;
|
|
71
|
+
if (c && process.env.NODE_ENV !== "production") {
|
|
72
|
+
console.warn(m);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// ../../utilities/dom/src/platform.ts
|
|
42
77
|
var isDom = () => typeof window !== "undefined";
|
|
78
|
+
|
|
79
|
+
// ../../utilities/dom/src/query.ts
|
|
43
80
|
function isDocument(el) {
|
|
44
81
|
return el.nodeType === Node.DOCUMENT_NODE;
|
|
45
82
|
}
|
|
@@ -66,31 +103,15 @@ function defineDomHelpers(helpers) {
|
|
|
66
103
|
return (_a = dom2.getDoc(ctx).defaultView) != null ? _a : window;
|
|
67
104
|
},
|
|
68
105
|
getActiveElement: (ctx) => dom2.getDoc(ctx).activeElement,
|
|
69
|
-
getById: (ctx, id) => dom2.getRootNode(ctx).getElementById(id)
|
|
70
|
-
createEmitter: (ctx, target) => {
|
|
71
|
-
const win = dom2.getWin(ctx);
|
|
72
|
-
return function emit(evt, detail, options) {
|
|
73
|
-
const { bubbles = true, cancelable, composed = true } = options != null ? options : {};
|
|
74
|
-
const eventName = `zag:${evt}`;
|
|
75
|
-
const init = { bubbles, cancelable, composed, detail };
|
|
76
|
-
const event = new win.CustomEvent(eventName, init);
|
|
77
|
-
target.dispatchEvent(event);
|
|
78
|
-
};
|
|
79
|
-
},
|
|
80
|
-
createListener: (target) => {
|
|
81
|
-
return function listen(evt, handler) {
|
|
82
|
-
const eventName = `zag:${evt}`;
|
|
83
|
-
const listener = (e) => handler(e);
|
|
84
|
-
target.addEventListener(eventName, listener);
|
|
85
|
-
return () => target.removeEventListener(eventName, listener);
|
|
86
|
-
};
|
|
87
|
-
}
|
|
106
|
+
getById: (ctx, id) => dom2.getRootNode(ctx).getElementById(id)
|
|
88
107
|
};
|
|
89
108
|
return {
|
|
90
109
|
...dom2,
|
|
91
110
|
...helpers
|
|
92
111
|
};
|
|
93
112
|
}
|
|
113
|
+
|
|
114
|
+
// ../../utilities/dom/src/listener.ts
|
|
94
115
|
var isRef = (v) => hasProp(v, "current");
|
|
95
116
|
function addDomEvent(target, eventName, handler, options) {
|
|
96
117
|
const node = isRef(target) ? target.current : runIfFn(target);
|
|
@@ -99,6 +120,8 @@ function addDomEvent(target, eventName, handler, options) {
|
|
|
99
120
|
node == null ? void 0 : node.removeEventListener(eventName, handler, options);
|
|
100
121
|
};
|
|
101
122
|
}
|
|
123
|
+
|
|
124
|
+
// ../../utilities/dom/src/visibility-event.ts
|
|
102
125
|
function trackDocumentVisibility(_doc, callback) {
|
|
103
126
|
const doc = cast(_doc);
|
|
104
127
|
return addDomEvent(doc, "visibilitychange", () => {
|
|
@@ -107,35 +130,6 @@ function trackDocumentVisibility(_doc, callback) {
|
|
|
107
130
|
});
|
|
108
131
|
}
|
|
109
132
|
|
|
110
|
-
// ../../utilities/core/dist/index.mjs
|
|
111
|
-
var runIfFn2 = (v, ...a) => {
|
|
112
|
-
const res = typeof v === "function" ? v(...a) : v;
|
|
113
|
-
return res != null ? res : void 0;
|
|
114
|
-
};
|
|
115
|
-
var uuid = /* @__PURE__ */ (() => {
|
|
116
|
-
let id = 0;
|
|
117
|
-
return () => {
|
|
118
|
-
id++;
|
|
119
|
-
return id.toString(36);
|
|
120
|
-
};
|
|
121
|
-
})();
|
|
122
|
-
var isArray = (v) => Array.isArray(v);
|
|
123
|
-
var isObject = (v) => !(v == null || typeof v !== "object" || isArray(v));
|
|
124
|
-
function compact(obj) {
|
|
125
|
-
if (obj === void 0)
|
|
126
|
-
return obj;
|
|
127
|
-
return Object.fromEntries(
|
|
128
|
-
Object.entries(obj).filter(([, value]) => value !== void 0).map(([key, value]) => [key, isObject(value) ? compact(value) : value])
|
|
129
|
-
);
|
|
130
|
-
}
|
|
131
|
-
function warn(...a) {
|
|
132
|
-
const m = a.length === 1 ? a[0] : a[1];
|
|
133
|
-
const c = a.length === 2 ? a[0] : true;
|
|
134
|
-
if (c && process.env.NODE_ENV !== "production") {
|
|
135
|
-
console.warn(m);
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
|
|
139
133
|
// src/toast-group.connect.ts
|
|
140
134
|
var import_core = require("@zag-js/core");
|
|
141
135
|
|
|
@@ -293,10 +287,10 @@ function groupConnect(state, send, normalize) {
|
|
|
293
287
|
promise(promise, options, shared = {}) {
|
|
294
288
|
const id = group2.loading({ ...shared, ...options.loading });
|
|
295
289
|
promise.then((response) => {
|
|
296
|
-
const successOptions =
|
|
290
|
+
const successOptions = runIfFn(options.success, response);
|
|
297
291
|
group2.success({ ...shared, ...successOptions, id });
|
|
298
292
|
}).catch((error) => {
|
|
299
|
-
const errorOptions =
|
|
293
|
+
const errorOptions = runIfFn(options.error, error);
|
|
300
294
|
group2.error({ ...shared, ...errorOptions, id });
|
|
301
295
|
});
|
|
302
296
|
return promise;
|