@zag-js/toast 1.17.0 → 1.17.2
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.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +10 -11
- package/dist/index.mjs +11 -12
- package/package.json +7 -7
package/dist/index.d.mts
CHANGED
|
@@ -275,7 +275,7 @@ interface ToastStore<V = any> {
|
|
|
275
275
|
}
|
|
276
276
|
type MaybeFunction<Value, Args> = Value | ((arg: Args) => Value);
|
|
277
277
|
interface PromiseOptions<V, O = any> {
|
|
278
|
-
loading
|
|
278
|
+
loading: Omit<Options<O>, "type">;
|
|
279
279
|
success?: MaybeFunction<Omit<Options<O>, "type">, V> | undefined;
|
|
280
280
|
error?: MaybeFunction<Omit<Options<O>, "type">, unknown> | undefined;
|
|
281
281
|
finally?: (() => void | Promise<void>) | undefined;
|
package/dist/index.d.ts
CHANGED
|
@@ -275,7 +275,7 @@ interface ToastStore<V = any> {
|
|
|
275
275
|
}
|
|
276
276
|
type MaybeFunction<Value, Args> = Value | ((arg: Args) => Value);
|
|
277
277
|
interface PromiseOptions<V, O = any> {
|
|
278
|
-
loading
|
|
278
|
+
loading: Omit<Options<O>, "type">;
|
|
279
279
|
success?: MaybeFunction<Omit<Options<O>, "type">, V> | undefined;
|
|
280
280
|
error?: MaybeFunction<Omit<Options<O>, "type">, unknown> | undefined;
|
|
281
281
|
finally?: (() => void | Promise<void>) | undefined;
|
package/dist/index.js
CHANGED
|
@@ -925,17 +925,17 @@ function createToastStore(props) {
|
|
|
925
925
|
return toasts.length;
|
|
926
926
|
};
|
|
927
927
|
const promise = (promise2, options, shared = {}) => {
|
|
928
|
-
if (!options)
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
id = create({
|
|
932
|
-
...shared,
|
|
933
|
-
...options.loading,
|
|
934
|
-
promise: promise2,
|
|
935
|
-
type: "loading"
|
|
936
|
-
});
|
|
928
|
+
if (!options || !options.loading) {
|
|
929
|
+
utils.warn("[zag-js > toast] toaster.promise() requires at least a 'loading' option to be specified");
|
|
930
|
+
return;
|
|
937
931
|
}
|
|
938
|
-
|
|
932
|
+
const id = create({
|
|
933
|
+
...shared,
|
|
934
|
+
...options.loading,
|
|
935
|
+
promise: promise2,
|
|
936
|
+
type: "loading"
|
|
937
|
+
});
|
|
938
|
+
let removable = true;
|
|
939
939
|
let result;
|
|
940
940
|
const prom = utils.runIfFn(promise2).then(async (response) => {
|
|
941
941
|
result = ["resolve", response];
|
|
@@ -958,7 +958,6 @@ function createToastStore(props) {
|
|
|
958
958
|
}).finally(() => {
|
|
959
959
|
if (removable) {
|
|
960
960
|
remove(id);
|
|
961
|
-
id = void 0;
|
|
962
961
|
}
|
|
963
962
|
options.finally?.();
|
|
964
963
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import { addDomEvent, raf, contains, dataAttr, MAX_Z_INDEX } from '@zag-js/dom-q
|
|
|
2
2
|
import { createAnatomy } from '@zag-js/anatomy';
|
|
3
3
|
import { createMachine, createGuards } from '@zag-js/core';
|
|
4
4
|
import { trackDismissableBranch } from '@zag-js/dismissable';
|
|
5
|
-
import { uuid, setRafTimeout, ensureProps, runIfFn, compact } from '@zag-js/utils';
|
|
5
|
+
import { uuid, setRafTimeout, ensureProps, warn, runIfFn, compact } from '@zag-js/utils';
|
|
6
6
|
|
|
7
7
|
// src/toast-group.connect.ts
|
|
8
8
|
var anatomy = createAnatomy("toast").parts(
|
|
@@ -923,17 +923,17 @@ function createToastStore(props) {
|
|
|
923
923
|
return toasts.length;
|
|
924
924
|
};
|
|
925
925
|
const promise = (promise2, options, shared = {}) => {
|
|
926
|
-
if (!options)
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
id = create({
|
|
930
|
-
...shared,
|
|
931
|
-
...options.loading,
|
|
932
|
-
promise: promise2,
|
|
933
|
-
type: "loading"
|
|
934
|
-
});
|
|
926
|
+
if (!options || !options.loading) {
|
|
927
|
+
warn("[zag-js > toast] toaster.promise() requires at least a 'loading' option to be specified");
|
|
928
|
+
return;
|
|
935
929
|
}
|
|
936
|
-
|
|
930
|
+
const id = create({
|
|
931
|
+
...shared,
|
|
932
|
+
...options.loading,
|
|
933
|
+
promise: promise2,
|
|
934
|
+
type: "loading"
|
|
935
|
+
});
|
|
936
|
+
let removable = true;
|
|
937
937
|
let result;
|
|
938
938
|
const prom = runIfFn(promise2).then(async (response) => {
|
|
939
939
|
result = ["resolve", response];
|
|
@@ -956,7 +956,6 @@ function createToastStore(props) {
|
|
|
956
956
|
}).finally(() => {
|
|
957
957
|
if (removable) {
|
|
958
958
|
remove(id);
|
|
959
|
-
id = void 0;
|
|
960
959
|
}
|
|
961
960
|
options.finally?.();
|
|
962
961
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zag-js/toast",
|
|
3
|
-
"version": "1.17.
|
|
3
|
+
"version": "1.17.2",
|
|
4
4
|
"description": "Core logic for the toast widget implemented as a state machine",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"js",
|
|
@@ -26,12 +26,12 @@
|
|
|
26
26
|
"url": "https://github.com/chakra-ui/zag/issues"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@zag-js/anatomy": "1.17.
|
|
30
|
-
"@zag-js/core": "1.17.
|
|
31
|
-
"@zag-js/dom-query": "1.17.
|
|
32
|
-
"@zag-js/dismissable": "1.17.
|
|
33
|
-
"@zag-js/utils": "1.17.
|
|
34
|
-
"@zag-js/types": "1.17.
|
|
29
|
+
"@zag-js/anatomy": "1.17.2",
|
|
30
|
+
"@zag-js/core": "1.17.2",
|
|
31
|
+
"@zag-js/dom-query": "1.17.2",
|
|
32
|
+
"@zag-js/dismissable": "1.17.2",
|
|
33
|
+
"@zag-js/utils": "1.17.2",
|
|
34
|
+
"@zag-js/types": "1.17.2"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"clean-package": "2.2.0"
|