@zag-js/toast 1.45.0 → 1.47.0
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/toast-group.machine.js +80 -22
- package/dist/toast-group.machine.mjs +81 -23
- package/dist/toast.connect.js +6 -5
- package/dist/toast.connect.mjs +6 -5
- package/dist/toast.dom.d.mts +12 -1
- package/dist/toast.dom.d.ts +12 -1
- package/dist/toast.dom.js +40 -2
- package/dist/toast.dom.mjs +35 -1
- package/dist/toast.machine.js +45 -33
- package/dist/toast.machine.mjs +46 -34
- package/dist/toast.store.js +107 -64
- package/dist/toast.store.mjs +108 -65
- package/dist/toast.types.d.mts +11 -4
- package/dist/toast.types.d.ts +11 -4
- package/dist/toast.utils.d.mts +3 -2
- package/dist/toast.utils.d.ts +3 -2
- package/dist/toast.utils.js +25 -4
- package/dist/toast.utils.mjs +23 -3
- package/package.json +7 -7
package/dist/toast.utils.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Service } from '@zag-js/core';
|
|
2
2
|
import { Style } from '@zag-js/types';
|
|
3
|
-
import { Type, ToastSchema, ToastGroupService, Placement } from './toast.types.js';
|
|
3
|
+
import { Type, ToastSchema, ToastGroupService, Placement, ToastGroupSchema, ToastHeight } from './toast.types.js';
|
|
4
4
|
import '@zag-js/dom-query';
|
|
5
5
|
|
|
6
6
|
declare const defaultTimeouts: Record<Type, number>;
|
|
@@ -9,5 +9,6 @@ declare function getGroupPlacementStyle(service: ToastGroupService, placement: P
|
|
|
9
9
|
declare function getPlacementStyle(service: Service<ToastSchema>, visible: boolean): Style;
|
|
10
10
|
declare function getGhostBeforeStyle(service: Service<ToastSchema>, visible: boolean): Style;
|
|
11
11
|
declare function getGhostAfterStyle(): Style;
|
|
12
|
+
declare function setHeight(parent: Service<ToastGroupSchema>, item: ToastHeight): void;
|
|
12
13
|
|
|
13
|
-
export { defaultTimeouts, getGhostAfterStyle, getGhostBeforeStyle, getGroupPlacementStyle, getPlacementStyle, getToastDuration };
|
|
14
|
+
export { defaultTimeouts, getGhostAfterStyle, getGhostBeforeStyle, getGroupPlacementStyle, getPlacementStyle, getToastDuration, setHeight };
|
package/dist/toast.utils.js
CHANGED
|
@@ -25,7 +25,8 @@ __export(toast_utils_exports, {
|
|
|
25
25
|
getGhostBeforeStyle: () => getGhostBeforeStyle,
|
|
26
26
|
getGroupPlacementStyle: () => getGroupPlacementStyle,
|
|
27
27
|
getPlacementStyle: () => getPlacementStyle,
|
|
28
|
-
getToastDuration: () => getToastDuration
|
|
28
|
+
getToastDuration: () => getToastDuration,
|
|
29
|
+
setHeight: () => setHeight
|
|
29
30
|
});
|
|
30
31
|
module.exports = __toCommonJS(toast_utils_exports);
|
|
31
32
|
var import_dom_query = require("@zag-js/dom-query");
|
|
@@ -96,8 +97,8 @@ function getPlacementStyle(service, visible) {
|
|
|
96
97
|
const height = computed("height");
|
|
97
98
|
const frontmost = computed("frontmost");
|
|
98
99
|
const sibling = !frontmost;
|
|
99
|
-
const
|
|
100
|
-
const
|
|
100
|
+
const stacked = prop("parent").state.matches("stack");
|
|
101
|
+
const overlap = !stacked;
|
|
101
102
|
const type = prop("type");
|
|
102
103
|
const duration = type === "loading" ? Number.MAX_SAFE_INTEGER : remainingTime;
|
|
103
104
|
const offset = computed("heightIndex") * gap + computed("heightBefore");
|
|
@@ -199,6 +200,25 @@ function getGhostAfterStyle() {
|
|
|
199
200
|
width: "100%"
|
|
200
201
|
};
|
|
201
202
|
}
|
|
203
|
+
function setHeight(parent, item) {
|
|
204
|
+
const { id, height } = item;
|
|
205
|
+
parent.context.set("heights", (prev) => {
|
|
206
|
+
const existing = prev.find((i) => i.id === id);
|
|
207
|
+
if (existing) {
|
|
208
|
+
if (existing.height === height) return prev;
|
|
209
|
+
return prev.map((i) => i.id === id ? { ...i, height } : i);
|
|
210
|
+
}
|
|
211
|
+
const toasts = parent.context.get("toasts");
|
|
212
|
+
const rank = (id2) => toasts.findIndex((t) => t.id === id2);
|
|
213
|
+
const index = rank(id);
|
|
214
|
+
let insertAt = prev.findIndex((i) => {
|
|
215
|
+
const r = rank(i.id);
|
|
216
|
+
return r === -1 || r > index;
|
|
217
|
+
});
|
|
218
|
+
if (insertAt === -1) insertAt = prev.length;
|
|
219
|
+
return [...prev.slice(0, insertAt), { id, height }, ...prev.slice(insertAt)];
|
|
220
|
+
});
|
|
221
|
+
}
|
|
202
222
|
// Annotate the CommonJS export names for ESM import in node:
|
|
203
223
|
0 && (module.exports = {
|
|
204
224
|
defaultTimeouts,
|
|
@@ -206,5 +226,6 @@ function getGhostAfterStyle() {
|
|
|
206
226
|
getGhostBeforeStyle,
|
|
207
227
|
getGroupPlacementStyle,
|
|
208
228
|
getPlacementStyle,
|
|
209
|
-
getToastDuration
|
|
229
|
+
getToastDuration,
|
|
230
|
+
setHeight
|
|
210
231
|
});
|
package/dist/toast.utils.mjs
CHANGED
|
@@ -67,8 +67,8 @@ function getPlacementStyle(service, visible) {
|
|
|
67
67
|
const height = computed("height");
|
|
68
68
|
const frontmost = computed("frontmost");
|
|
69
69
|
const sibling = !frontmost;
|
|
70
|
-
const
|
|
71
|
-
const
|
|
70
|
+
const stacked = prop("parent").state.matches("stack");
|
|
71
|
+
const overlap = !stacked;
|
|
72
72
|
const type = prop("type");
|
|
73
73
|
const duration = type === "loading" ? Number.MAX_SAFE_INTEGER : remainingTime;
|
|
74
74
|
const offset = computed("heightIndex") * gap + computed("heightBefore");
|
|
@@ -170,11 +170,31 @@ function getGhostAfterStyle() {
|
|
|
170
170
|
width: "100%"
|
|
171
171
|
};
|
|
172
172
|
}
|
|
173
|
+
function setHeight(parent, item) {
|
|
174
|
+
const { id, height } = item;
|
|
175
|
+
parent.context.set("heights", (prev) => {
|
|
176
|
+
const existing = prev.find((i) => i.id === id);
|
|
177
|
+
if (existing) {
|
|
178
|
+
if (existing.height === height) return prev;
|
|
179
|
+
return prev.map((i) => i.id === id ? { ...i, height } : i);
|
|
180
|
+
}
|
|
181
|
+
const toasts = parent.context.get("toasts");
|
|
182
|
+
const rank = (id2) => toasts.findIndex((t) => t.id === id2);
|
|
183
|
+
const index = rank(id);
|
|
184
|
+
let insertAt = prev.findIndex((i) => {
|
|
185
|
+
const r = rank(i.id);
|
|
186
|
+
return r === -1 || r > index;
|
|
187
|
+
});
|
|
188
|
+
if (insertAt === -1) insertAt = prev.length;
|
|
189
|
+
return [...prev.slice(0, insertAt), { id, height }, ...prev.slice(insertAt)];
|
|
190
|
+
});
|
|
191
|
+
}
|
|
173
192
|
export {
|
|
174
193
|
defaultTimeouts,
|
|
175
194
|
getGhostAfterStyle,
|
|
176
195
|
getGhostBeforeStyle,
|
|
177
196
|
getGroupPlacementStyle,
|
|
178
197
|
getPlacementStyle,
|
|
179
|
-
getToastDuration
|
|
198
|
+
getToastDuration,
|
|
199
|
+
setHeight
|
|
180
200
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zag-js/toast",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.47.0",
|
|
4
4
|
"description": "Core logic for the toast widget implemented as a state machine",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"js",
|
|
@@ -29,12 +29,12 @@
|
|
|
29
29
|
"url": "https://github.com/chakra-ui/zag/issues"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@zag-js/anatomy": "1.
|
|
33
|
-
"@zag-js/
|
|
34
|
-
"@zag-js/
|
|
35
|
-
"@zag-js/dismissable": "1.
|
|
36
|
-
"@zag-js/
|
|
37
|
-
"@zag-js/
|
|
32
|
+
"@zag-js/anatomy": "1.47.0",
|
|
33
|
+
"@zag-js/core": "1.47.0",
|
|
34
|
+
"@zag-js/dom-query": "1.47.0",
|
|
35
|
+
"@zag-js/dismissable": "1.47.0",
|
|
36
|
+
"@zag-js/utils": "1.47.0",
|
|
37
|
+
"@zag-js/types": "1.47.0"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"clean-package": "2.2.0"
|