@serendie/ui 2.0.0 → 2.1.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/components/CheckBox/CheckBox.js +36 -35
- package/dist/components/ChoiceBox/ChoiceBox.js +41 -41
- package/dist/components/DataTable/DataTableComponent.d.ts +3 -20
- package/dist/components/DataTable/DataTableComponent.js +38 -36
- package/dist/components/DataTable/table/HeaderCheckbox.js +29 -19
- package/dist/components/Search/Search.d.ts +3 -1
- package/dist/components/Search/Search.js +34 -33
- package/dist/components/Select/Select.d.ts +2 -1
- package/dist/components/Select/Select.js +47 -41
- package/dist/components/Tooltip/Tooltip.d.ts +14 -0
- package/dist/components/Tooltip/Tooltip.js +70 -0
- package/dist/components/Tooltip/index.d.ts +1 -0
- package/dist/components/Tooltip/index.js +4 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +12 -10
- package/dist/node_modules/@ark-ui/react/dist/components/accordion/accordion-item-content.js +4 -6
- package/dist/node_modules/@ark-ui/react/dist/components/accordion/accordion-item-indicator.js +4 -6
- package/dist/node_modules/@ark-ui/react/dist/components/accordion/accordion-item-trigger.js +10 -12
- package/dist/node_modules/@ark-ui/react/dist/components/accordion/accordion-item.js +16 -16
- package/dist/node_modules/@ark-ui/react/dist/components/accordion/use-accordion.js +13 -20
- package/dist/node_modules/@ark-ui/react/dist/components/avatar/avatar-root.js +1 -5
- package/dist/node_modules/@ark-ui/react/dist/components/avatar/use-avatar.js +14 -18
- package/dist/node_modules/@ark-ui/react/dist/components/checkbox/checkbox-hidden-input.js +4 -6
- package/dist/node_modules/@ark-ui/react/dist/components/checkbox/use-checkbox.js +22 -28
- package/dist/node_modules/@ark-ui/react/dist/components/collapsible/collapsible-content.js +7 -9
- package/dist/node_modules/@ark-ui/react/dist/components/collapsible/use-collapsible.js +14 -21
- package/dist/node_modules/@ark-ui/react/dist/components/collection/list-collection.js +5 -0
- package/dist/node_modules/@ark-ui/react/dist/components/combobox/combobox-content.js +9 -8
- package/dist/node_modules/@ark-ui/react/dist/components/combobox/combobox-item-group.js +4 -6
- package/dist/node_modules/@ark-ui/react/dist/components/combobox/combobox-positioner.js +4 -6
- package/dist/node_modules/@ark-ui/react/dist/components/combobox/combobox-root.js +17 -18
- package/dist/node_modules/@ark-ui/react/dist/components/combobox/combobox-trigger.js +10 -9
- package/dist/node_modules/@ark-ui/react/dist/components/combobox/use-combobox-item-context.js +5 -7
- package/dist/node_modules/@ark-ui/react/dist/components/combobox/use-combobox.js +21 -45
- package/dist/node_modules/@ark-ui/react/dist/components/dialog/dialog-backdrop.js +10 -9
- package/dist/node_modules/@ark-ui/react/dist/components/dialog/dialog-close-trigger.js +4 -6
- package/dist/node_modules/@ark-ui/react/dist/components/dialog/dialog-content.js +6 -5
- package/dist/node_modules/@ark-ui/react/dist/components/dialog/dialog-description.js +4 -6
- package/dist/node_modules/@ark-ui/react/dist/components/dialog/use-dialog.js +13 -22
- package/dist/node_modules/@ark-ui/react/dist/components/factory.js +26 -24
- package/dist/node_modules/@ark-ui/react/dist/components/menu/menu-content.js +9 -8
- package/dist/node_modules/@ark-ui/react/dist/components/menu/menu-item-group.js +1 -3
- package/dist/node_modules/@ark-ui/react/dist/components/menu/menu-item.js +15 -13
- package/dist/node_modules/@ark-ui/react/dist/components/menu/menu-root.js +13 -14
- package/dist/node_modules/@ark-ui/react/dist/components/menu/use-menu-option-item-props-context.js +10 -0
- package/dist/node_modules/@ark-ui/react/dist/components/menu/use-menu.js +14 -21
- package/dist/node_modules/@ark-ui/react/dist/components/pagination/pagination-ellipsis.js +4 -6
- package/dist/node_modules/@ark-ui/react/dist/components/pagination/pagination-next-trigger.js +4 -6
- package/dist/node_modules/@ark-ui/react/dist/components/pagination/pagination-prev-trigger.js +4 -6
- package/dist/node_modules/@ark-ui/react/dist/components/pagination/pagination-root.js +5 -4
- package/dist/node_modules/@ark-ui/react/dist/components/pagination/use-pagination.js +13 -19
- package/dist/node_modules/@ark-ui/react/dist/components/portal/portal.js +25 -16
- package/dist/node_modules/@ark-ui/react/dist/components/presence/split-presence-props.js +3 -2
- package/dist/node_modules/@ark-ui/react/dist/components/presence/use-presence.js +18 -18
- package/dist/node_modules/@ark-ui/react/dist/components/radio-group/radio-group-item-control.js +4 -6
- package/dist/node_modules/@ark-ui/react/dist/components/radio-group/radio-group-item-text.js +4 -6
- package/dist/node_modules/@ark-ui/react/dist/components/radio-group/radio-group-item.js +1 -5
- package/dist/node_modules/@ark-ui/react/dist/components/radio-group/use-radio-group.js +14 -22
- package/dist/node_modules/@ark-ui/react/dist/components/select/select-content.js +9 -8
- package/dist/node_modules/@ark-ui/react/dist/components/select/select-root.js +11 -12
- package/dist/node_modules/@ark-ui/react/dist/components/select/use-select.js +20 -47
- package/dist/node_modules/@ark-ui/react/dist/components/switch/switch-hidden-input.js +4 -6
- package/dist/node_modules/@ark-ui/react/dist/components/switch/use-switch.js +20 -26
- package/dist/node_modules/@ark-ui/react/dist/components/tabs/tabs-root.js +9 -8
- package/dist/node_modules/@ark-ui/react/dist/components/tabs/use-tabs.js +14 -21
- package/dist/node_modules/@ark-ui/react/dist/components/toast/create-toaster.js +3 -7
- package/dist/node_modules/@ark-ui/react/dist/components/toast/toaster.js +28 -15
- package/dist/node_modules/@ark-ui/react/dist/components/tooltip/tooltip-arrow-tip.js +13 -0
- package/dist/node_modules/@ark-ui/react/dist/components/tooltip/tooltip-arrow.js +13 -0
- package/dist/node_modules/@ark-ui/react/dist/components/tooltip/tooltip-content.js +15 -0
- package/dist/node_modules/@ark-ui/react/dist/components/tooltip/tooltip-positioner.js +14 -0
- package/dist/node_modules/@ark-ui/react/dist/components/tooltip/tooltip-root.js +14 -0
- package/dist/node_modules/@ark-ui/react/dist/components/tooltip/tooltip-trigger.js +13 -0
- package/dist/node_modules/@ark-ui/react/dist/components/tooltip/use-tooltip-context.js +10 -0
- package/dist/node_modules/@ark-ui/react/dist/components/tooltip/use-tooltip.js +17 -0
- package/dist/node_modules/@ark-ui/react/dist/utils/compose-refs.js +13 -7
- package/dist/node_modules/@floating-ui/core/dist/floating-ui.core.js +92 -90
- package/dist/node_modules/@floating-ui/dom/dist/floating-ui.dom.js +230 -216
- package/dist/node_modules/@zag-js/accordion/dist/index.js +210 -227
- package/dist/node_modules/@zag-js/aria-hidden/dist/index.js +49 -12
- package/dist/node_modules/@zag-js/avatar/dist/index.js +119 -134
- package/dist/node_modules/@zag-js/checkbox/dist/index.js +196 -197
- package/dist/node_modules/@zag-js/collapsible/dist/index.js +250 -198
- package/dist/node_modules/@zag-js/collection/dist/index.js +172 -179
- package/dist/node_modules/@zag-js/combobox/dist/index.js +1176 -1082
- package/dist/node_modules/@zag-js/core/dist/index.js +77 -496
- package/dist/node_modules/@zag-js/dialog/dist/index.js +243 -270
- package/dist/node_modules/@zag-js/dismissable/dist/index.js +62 -60
- package/dist/node_modules/@zag-js/dom-query/dist/index.js +465 -253
- package/dist/node_modules/@zag-js/focus-trap/dist/index.js +307 -0
- package/dist/node_modules/@zag-js/focus-visible/dist/index.js +48 -47
- package/dist/node_modules/@zag-js/interact-outside/dist/index.js +112 -80
- package/dist/node_modules/@zag-js/menu/dist/index.js +998 -884
- package/dist/node_modules/@zag-js/pagination/dist/index.js +207 -213
- package/dist/node_modules/@zag-js/popper/dist/index.js +130 -129
- package/dist/node_modules/@zag-js/presence/dist/index.js +139 -122
- package/dist/node_modules/@zag-js/radio-group/dist/index.js +297 -302
- package/dist/node_modules/@zag-js/react/dist/index.js +255 -103
- package/dist/node_modules/@zag-js/remove-scroll/dist/index.js +18 -31
- package/dist/node_modules/@zag-js/select/dist/index.js +889 -885
- package/dist/node_modules/@zag-js/store/dist/index.js +98 -137
- package/dist/node_modules/@zag-js/switch/dist/index.js +199 -191
- package/dist/node_modules/@zag-js/tabs/dist/index.js +383 -386
- package/dist/node_modules/@zag-js/toast/dist/index.js +646 -633
- package/dist/node_modules/@zag-js/tooltip/dist/index.js +459 -0
- package/dist/node_modules/@zag-js/types/dist/index.js +6 -6
- package/dist/node_modules/@zag-js/utils/dist/index.js +112 -99
- package/dist/node_modules/proxy-compare/dist/index.js +4 -106
- package/dist/styles.css +1 -1
- package/package.json +5 -5
- package/dist/node_modules/@ark-ui/react/dist/utils/use-is-server.js +0 -10
- package/dist/node_modules/@zag-js/dom-event/dist/index.js +0 -130
- package/dist/node_modules/@zag-js/element-rect/dist/index.js +0 -32
- package/dist/node_modules/@zag-js/form-utils/dist/index.js +0 -51
- package/dist/node_modules/aria-hidden/dist/es2015/index.js +0 -52
- package/dist/node_modules/focus-trap/dist/focus-trap.esm.js +0 -431
- package/dist/node_modules/klona/full/index.js +0 -21
- package/dist/node_modules/tabbable/dist/index.esm.js +0 -202
|
@@ -1,128 +1,115 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
import { ref as w, subscribe as x } from "../../store/dist/index.js";
|
|
8
|
-
var K = $("toast").parts(
|
|
1
|
+
import { addDomEvent as N, contains as q, MAX_Z_INDEX as X, raf as L, dataAttr as D } from "../../dom-query/dist/index.js";
|
|
2
|
+
import { createAnatomy as Q } from "../../anatomy/dist/index.js";
|
|
3
|
+
import { createMachine as K, createGuards as Y } from "../../core/dist/index.js";
|
|
4
|
+
import { trackDismissableBranch as Z } from "../../dismissable/dist/index.js";
|
|
5
|
+
import { compact as J, runIfFn as C, uuid as _, setRafTimeout as w, ensureProps as z } from "../../utils/dist/index.js";
|
|
6
|
+
var tt = Q("toast").parts(
|
|
9
7
|
"group",
|
|
10
8
|
"root",
|
|
11
9
|
"title",
|
|
12
10
|
"description",
|
|
13
11
|
"actionTrigger",
|
|
14
12
|
"closeTrigger"
|
|
15
|
-
),
|
|
16
|
-
getRegionId: (o) => `toast-group:${o}`,
|
|
17
|
-
getRegionEl: (o, r) => f.getById(o, `toast-group:${r}`),
|
|
18
|
-
getRootId: (o) => `toast:${o.id}`,
|
|
19
|
-
getRootEl: (o) => f.getById(o, f.getRootId(o)),
|
|
20
|
-
getTitleId: (o) => `toast:${o.id}:title`,
|
|
21
|
-
getDescriptionId: (o) => `toast:${o.id}:description`,
|
|
22
|
-
getCloseTriggerId: (o) => `toast${o.id}:close`
|
|
23
|
-
});
|
|
24
|
-
function b(o, r) {
|
|
25
|
-
return o.filter((t) => t.state.context.placement === r);
|
|
26
|
-
}
|
|
27
|
-
var O = {
|
|
13
|
+
), O = tt.build(), et = (t) => `toast-group:${t}`, H = (t, e) => t.getById(`toast-group:${e}`), W = (t) => `toast:${t.id}`, U = (t) => t.getById(W(t)), V = (t) => `toast:${t.id}:title`, G = (t) => `toast:${t.id}:description`, st = (t) => `toast${t.id}:close`, $ = {
|
|
28
14
|
info: 5e3,
|
|
29
15
|
error: 5e3,
|
|
30
16
|
success: 2e3,
|
|
31
17
|
loading: 1 / 0,
|
|
32
18
|
DEFAULT: 5e3
|
|
33
19
|
};
|
|
34
|
-
function
|
|
35
|
-
return
|
|
20
|
+
function A(t, e) {
|
|
21
|
+
return t ?? $[e] ?? $.DEFAULT;
|
|
36
22
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
23
|
+
var it = (t) => typeof t == "string" ? { left: t, right: t, bottom: t, top: t } : t;
|
|
24
|
+
function nt(t, e) {
|
|
25
|
+
var b;
|
|
26
|
+
const { prop: i, computed: s, context: r } = t, { offsets: a, gap: c } = i("store").attrs, l = r.get("heights"), d = it(a), m = i("dir") === "rtl", u = e.replace("-start", m ? "-right" : "-left").replace("-end", m ? "-left" : "-right"), p = u.includes("right"), v = u.includes("left"), f = {
|
|
40
27
|
position: "fixed",
|
|
41
|
-
pointerEvents:
|
|
28
|
+
pointerEvents: s("count") > 0 ? void 0 : "none",
|
|
42
29
|
display: "flex",
|
|
43
30
|
flexDirection: "column",
|
|
44
|
-
"--gap": `${
|
|
45
|
-
"--first-height": `${((
|
|
46
|
-
zIndex:
|
|
31
|
+
"--gap": `${c}px`,
|
|
32
|
+
"--first-height": `${((b = l[0]) == null ? void 0 : b.height) || 0}px`,
|
|
33
|
+
zIndex: X
|
|
47
34
|
};
|
|
48
|
-
let
|
|
49
|
-
if (
|
|
50
|
-
const
|
|
51
|
-
|
|
35
|
+
let h = "center";
|
|
36
|
+
if (p && (h = "flex-end"), v && (h = "flex-start"), f.alignItems = h, u.includes("top")) {
|
|
37
|
+
const E = d.top;
|
|
38
|
+
f.top = `max(env(safe-area-inset-top, 0px), ${E})`;
|
|
52
39
|
}
|
|
53
|
-
if (
|
|
54
|
-
const
|
|
55
|
-
|
|
40
|
+
if (u.includes("bottom")) {
|
|
41
|
+
const E = d.bottom;
|
|
42
|
+
f.bottom = `max(env(safe-area-inset-bottom, 0px), ${E})`;
|
|
56
43
|
}
|
|
57
|
-
if (!
|
|
58
|
-
const
|
|
59
|
-
|
|
44
|
+
if (!u.includes("left")) {
|
|
45
|
+
const E = d.right;
|
|
46
|
+
f.insetInlineEnd = `calc(env(safe-area-inset-right, 0px) + ${E})`;
|
|
60
47
|
}
|
|
61
|
-
if (!
|
|
62
|
-
const
|
|
63
|
-
|
|
48
|
+
if (!u.includes("right")) {
|
|
49
|
+
const E = d.left;
|
|
50
|
+
f.insetInlineStart = `calc(env(safe-area-inset-left, 0px) + ${E})`;
|
|
64
51
|
}
|
|
65
|
-
return
|
|
52
|
+
return f;
|
|
66
53
|
}
|
|
67
|
-
function
|
|
68
|
-
const
|
|
54
|
+
function rt(t, e) {
|
|
55
|
+
const { prop: i, context: s, computed: r } = t, a = i("parent"), c = a.computed("placement"), { gap: l } = a.prop("store").attrs, [d] = c.split("-"), m = s.get("mounted"), u = s.get("remainingTime"), p = r("height"), v = r("frontmost"), f = !v, h = !i("stacked"), b = i("stacked"), S = i("type") === "loading" ? Number.MAX_SAFE_INTEGER : u, F = r("heightIndex") * l + r("heightBefore"), R = {
|
|
69
56
|
position: "absolute",
|
|
70
57
|
pointerEvents: "auto",
|
|
71
58
|
"--opacity": "0",
|
|
72
|
-
"--remove-delay": `${
|
|
73
|
-
"--duration": `${
|
|
74
|
-
"--initial-height": `${
|
|
75
|
-
"--offset": `${
|
|
76
|
-
"--index":
|
|
77
|
-
"--z-index":
|
|
59
|
+
"--remove-delay": `${i("removeDelay")}ms`,
|
|
60
|
+
"--duration": `${S}ms`,
|
|
61
|
+
"--initial-height": `${p}px`,
|
|
62
|
+
"--offset": `${F}px`,
|
|
63
|
+
"--index": i("index"),
|
|
64
|
+
"--z-index": r("zIndex"),
|
|
78
65
|
"--lift-amount": "calc(var(--lift) * var(--gap))",
|
|
79
66
|
"--y": "100%",
|
|
80
67
|
"--x": "0"
|
|
81
|
-
},
|
|
82
|
-
return
|
|
68
|
+
}, g = (k) => Object.assign(R, k);
|
|
69
|
+
return d === "top" ? g({
|
|
83
70
|
top: "0",
|
|
84
71
|
"--sign": "-1",
|
|
85
72
|
"--y": "-100%",
|
|
86
73
|
"--lift": "1"
|
|
87
|
-
}) :
|
|
74
|
+
}) : d === "bottom" && g({
|
|
88
75
|
bottom: "0",
|
|
89
76
|
"--sign": "1",
|
|
90
77
|
"--y": "100%",
|
|
91
78
|
"--lift": "-1"
|
|
92
|
-
}),
|
|
79
|
+
}), m && (g({
|
|
93
80
|
"--y": "0",
|
|
94
81
|
"--opacity": "1"
|
|
95
|
-
}),
|
|
82
|
+
}), b && g({
|
|
96
83
|
"--y": "calc(var(--lift) * var(--offset))",
|
|
97
84
|
"--height": "var(--initial-height)"
|
|
98
|
-
})),
|
|
85
|
+
})), e || g({
|
|
99
86
|
"--opacity": "0",
|
|
100
87
|
pointerEvents: "none"
|
|
101
|
-
}),
|
|
88
|
+
}), f && h && (g({
|
|
102
89
|
"--base-scale": "var(--index) * 0.05 + 1",
|
|
103
90
|
"--y": "calc(var(--lift-amount) * var(--index))",
|
|
104
91
|
"--scale": "calc(-1 * var(--base-scale))",
|
|
105
92
|
"--height": "var(--first-height)"
|
|
106
|
-
}),
|
|
93
|
+
}), e || g({
|
|
107
94
|
"--y": "calc(var(--sign) * 40%)"
|
|
108
|
-
})),
|
|
95
|
+
})), f && b && !e && g({
|
|
109
96
|
"--y": "calc(var(--lift) * var(--offset) + var(--lift) * -100%)"
|
|
110
|
-
}),
|
|
97
|
+
}), v && !e && g({
|
|
111
98
|
"--y": "calc(var(--lift) * -100%)"
|
|
112
|
-
}),
|
|
99
|
+
}), R;
|
|
113
100
|
}
|
|
114
|
-
function
|
|
115
|
-
const t = {
|
|
101
|
+
function ot(t, e) {
|
|
102
|
+
const { computed: i } = t, s = {
|
|
116
103
|
position: "absolute",
|
|
117
104
|
inset: "0",
|
|
118
105
|
scale: "1 2",
|
|
119
|
-
pointerEvents:
|
|
120
|
-
},
|
|
121
|
-
return
|
|
106
|
+
pointerEvents: e ? "none" : "auto"
|
|
107
|
+
}, r = (a) => Object.assign(s, a);
|
|
108
|
+
return i("frontmost") && !e && r({
|
|
122
109
|
height: "calc(var(--initial-height) + 80%)"
|
|
123
|
-
}),
|
|
110
|
+
}), s;
|
|
124
111
|
}
|
|
125
|
-
function
|
|
112
|
+
function at() {
|
|
126
113
|
return {
|
|
127
114
|
position: "absolute",
|
|
128
115
|
left: "0",
|
|
@@ -131,656 +118,682 @@ function Y(o, r) {
|
|
|
131
118
|
width: "100%"
|
|
132
119
|
};
|
|
133
120
|
}
|
|
134
|
-
function
|
|
135
|
-
|
|
136
|
-
return C(o) ? o.getState() : o;
|
|
137
|
-
}
|
|
138
|
-
function i(e) {
|
|
139
|
-
return b(s().context.toasts, e);
|
|
140
|
-
}
|
|
141
|
-
function c(e) {
|
|
142
|
-
const n = s().context.toasts;
|
|
143
|
-
return n.length ? !!n.find((l) => l.id == e) : !1;
|
|
144
|
-
}
|
|
145
|
-
function u(e) {
|
|
146
|
-
const n = `toast:${G()}`, l = e.id ? e.id : n;
|
|
147
|
-
return c(l) || r({ type: "ADD_TOAST", toast: { ...e, id: l } }), l;
|
|
148
|
-
}
|
|
149
|
-
function h(e, n) {
|
|
150
|
-
return c(e) && r({ type: "UPDATE_TOAST", id: e, toast: n }), e;
|
|
151
|
-
}
|
|
152
|
-
function d(e) {
|
|
153
|
-
const { id: n } = e;
|
|
154
|
-
return (n ? c(n) : !1) && n != null ? h(n, e) : u(e);
|
|
155
|
-
}
|
|
156
|
-
function a(e) {
|
|
157
|
-
e == null ? r("DISMISS_ALL") : c(e) && r({ type: "DISMISS_TOAST", id: e });
|
|
158
|
-
}
|
|
121
|
+
function ct(t, e) {
|
|
122
|
+
const { context: i, prop: s, send: r, refs: a, computed: c } = t;
|
|
159
123
|
return {
|
|
160
124
|
getCount() {
|
|
161
|
-
return
|
|
162
|
-
},
|
|
163
|
-
getPlacements() {
|
|
164
|
-
const n = s().context.toasts.map((l) => l.state.context.placement);
|
|
165
|
-
return Array.from(new Set(n));
|
|
166
|
-
},
|
|
167
|
-
getToastsByPlacement: i,
|
|
168
|
-
isVisible: c,
|
|
169
|
-
create: u,
|
|
170
|
-
update: h,
|
|
171
|
-
upsert: d,
|
|
172
|
-
dismiss: a,
|
|
173
|
-
remove(e) {
|
|
174
|
-
e == null ? r("REMOVE_ALL") : c(e) && r({ type: "REMOVE_TOAST", id: e });
|
|
175
|
-
},
|
|
176
|
-
dismissByPlacement(e) {
|
|
177
|
-
i(e).forEach((l) => a(l.id));
|
|
125
|
+
return i.get("toasts").length;
|
|
178
126
|
},
|
|
179
|
-
|
|
180
|
-
return
|
|
127
|
+
getToasts() {
|
|
128
|
+
return i.get("toasts");
|
|
181
129
|
},
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
},
|
|
188
|
-
promise(e, n, l = {}) {
|
|
189
|
-
const g = d({ ...l, ...n.loading, type: "loading" });
|
|
190
|
-
return v(e).then((p) => {
|
|
191
|
-
const m = v(n.success, p);
|
|
192
|
-
d({ ...l, ...m, id: g, type: "success" });
|
|
193
|
-
}).catch((p) => {
|
|
194
|
-
const m = v(n.error, p);
|
|
195
|
-
d({ ...l, ...m, id: g, type: "error" });
|
|
196
|
-
}).finally(() => {
|
|
197
|
-
var p;
|
|
198
|
-
(p = n.finally) == null || p.call(n);
|
|
199
|
-
}), g;
|
|
200
|
-
},
|
|
201
|
-
pause(e) {
|
|
202
|
-
e == null ? r("PAUSE_ALL") : c(e) && r({ type: "PAUSE_TOAST", id: e });
|
|
203
|
-
},
|
|
204
|
-
resume(e) {
|
|
205
|
-
e == null ? r("RESUME_ALL") : c(e) && r({ type: "RESUME_TOAST", id: e });
|
|
206
|
-
},
|
|
207
|
-
getGroupProps(e) {
|
|
208
|
-
const { placement: n, label: l = "Notifications" } = e, g = s(), p = g.context.hotkey.join("+").replace(/Key/g, "").replace(/Digit/g, ""), [m, S = "center"] = n.split("-");
|
|
209
|
-
return t.element({
|
|
210
|
-
...T.group.attrs,
|
|
211
|
-
dir: g.context.dir,
|
|
130
|
+
getGroupProps(l = {}) {
|
|
131
|
+
const { label: d = "Notifications" } = l, { hotkey: m } = s("store").attrs, u = m.join("+").replace(/Key/g, "").replace(/Digit/g, ""), p = c("placement"), [v, f = "center"] = p.split("-");
|
|
132
|
+
return e.element({
|
|
133
|
+
...O.group.attrs,
|
|
134
|
+
dir: s("dir"),
|
|
212
135
|
tabIndex: -1,
|
|
213
|
-
"aria-label": `${
|
|
214
|
-
id:
|
|
215
|
-
"data-placement":
|
|
216
|
-
"data-side":
|
|
217
|
-
"data-align":
|
|
136
|
+
"aria-label": `${p} ${d} ${u}`,
|
|
137
|
+
id: et(p),
|
|
138
|
+
"data-placement": p,
|
|
139
|
+
"data-side": v,
|
|
140
|
+
"data-align": f,
|
|
218
141
|
"aria-live": "polite",
|
|
219
142
|
role: "region",
|
|
220
|
-
style:
|
|
143
|
+
style: nt(t, p),
|
|
221
144
|
onMouseMove() {
|
|
222
|
-
r({ type: "REGION.POINTER_ENTER", placement:
|
|
145
|
+
r({ type: "REGION.POINTER_ENTER", placement: p });
|
|
223
146
|
},
|
|
224
147
|
onMouseLeave() {
|
|
225
|
-
r({ type: "REGION.POINTER_LEAVE", placement:
|
|
148
|
+
r({ type: "REGION.POINTER_LEAVE", placement: p });
|
|
226
149
|
},
|
|
227
|
-
onFocus(
|
|
228
|
-
r({ type: "REGION.FOCUS", target:
|
|
150
|
+
onFocus(h) {
|
|
151
|
+
r({ type: "REGION.FOCUS", target: h.relatedTarget });
|
|
229
152
|
},
|
|
230
|
-
onBlur(
|
|
231
|
-
|
|
153
|
+
onBlur(h) {
|
|
154
|
+
a.get("isFocusWithin") && !q(h.currentTarget, h.relatedTarget) && queueMicrotask(() => r({ type: "REGION.BLUR" }));
|
|
232
155
|
}
|
|
233
156
|
});
|
|
234
157
|
},
|
|
235
|
-
subscribe(
|
|
236
|
-
|
|
237
|
-
return x(n.context.toasts, () => {
|
|
238
|
-
const g = i(n.context.placement).map((p) => p.getState().context);
|
|
239
|
-
e(g);
|
|
240
|
-
});
|
|
158
|
+
subscribe(l) {
|
|
159
|
+
return s("store").subscribe(() => l(i.get("toasts")));
|
|
241
160
|
}
|
|
242
161
|
};
|
|
243
162
|
}
|
|
244
|
-
var
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
163
|
+
var lt = K({
|
|
164
|
+
props({ props: t }) {
|
|
165
|
+
return {
|
|
166
|
+
dir: "ltr",
|
|
167
|
+
id: _(),
|
|
168
|
+
...t,
|
|
169
|
+
store: t.store
|
|
170
|
+
};
|
|
171
|
+
},
|
|
172
|
+
initialState({ prop: t }) {
|
|
173
|
+
return t("store").attrs.overlap ? "overlap" : "stack";
|
|
174
|
+
},
|
|
175
|
+
refs() {
|
|
176
|
+
return {
|
|
177
|
+
lastFocusedEl: null,
|
|
178
|
+
isFocusWithin: !1,
|
|
179
|
+
dismissableCleanup: void 0
|
|
180
|
+
};
|
|
181
|
+
},
|
|
182
|
+
context({ bindable: t }) {
|
|
183
|
+
return {
|
|
184
|
+
toasts: t(() => ({
|
|
185
|
+
defaultValue: [],
|
|
186
|
+
sync: !0,
|
|
187
|
+
hash: (e) => e.map((i) => i.id).join(",")
|
|
188
|
+
})),
|
|
189
|
+
heights: t(() => ({
|
|
190
|
+
defaultValue: [],
|
|
191
|
+
sync: !0
|
|
192
|
+
}))
|
|
193
|
+
};
|
|
194
|
+
},
|
|
195
|
+
computed: {
|
|
196
|
+
count: ({ context: t }) => t.get("toasts").length,
|
|
197
|
+
overlap: ({ prop: t }) => t("store").attrs.overlap,
|
|
198
|
+
placement: ({ prop: t }) => t("store").attrs.placement
|
|
199
|
+
},
|
|
200
|
+
effects: ["subscribeToStore", "trackDocumentVisibility", "trackHotKeyPress"],
|
|
201
|
+
watch({ track: t, context: e, action: i }) {
|
|
202
|
+
t([() => e.hash("toasts")], () => {
|
|
203
|
+
queueMicrotask(() => {
|
|
204
|
+
i(["collapsedIfEmpty", "setDismissableBranch"]);
|
|
205
|
+
});
|
|
206
|
+
});
|
|
207
|
+
},
|
|
208
|
+
exit: ["clearDismissableBranch", "clearLastFocusedEl"],
|
|
209
|
+
on: {
|
|
210
|
+
"DOC.HOTKEY": {
|
|
211
|
+
actions: ["focusRegionEl"]
|
|
212
|
+
},
|
|
213
|
+
"REGION.BLUR": [
|
|
214
|
+
{
|
|
215
|
+
guard: "isOverlapping",
|
|
216
|
+
target: "overlap",
|
|
217
|
+
actions: ["collapseToasts", "resumeToasts", "restoreLastFocusedEl"]
|
|
265
218
|
},
|
|
266
|
-
|
|
219
|
+
{
|
|
220
|
+
target: "stack",
|
|
221
|
+
actions: ["resumeToasts", "restoreLastFocusedEl"]
|
|
222
|
+
}
|
|
223
|
+
],
|
|
224
|
+
"TOAST.REMOVE": {
|
|
225
|
+
actions: ["removeToast", "removeHeight"]
|
|
226
|
+
},
|
|
227
|
+
"TOAST.PAUSE": {
|
|
228
|
+
actions: ["pauseToasts"]
|
|
229
|
+
}
|
|
230
|
+
},
|
|
231
|
+
states: {
|
|
232
|
+
stack: {
|
|
267
233
|
on: {
|
|
268
|
-
|
|
234
|
+
"REGION.POINTER_LEAVE": [
|
|
269
235
|
{
|
|
270
|
-
guard:
|
|
271
|
-
target: "
|
|
272
|
-
actions: ["
|
|
273
|
-
},
|
|
274
|
-
{
|
|
275
|
-
guard: Q("hasDurationChanged", "hasTypeChanged"),
|
|
276
|
-
target: "visible:updating",
|
|
277
|
-
actions: ["setContext"]
|
|
236
|
+
guard: "isOverlapping",
|
|
237
|
+
target: "overlap",
|
|
238
|
+
actions: ["resumeToasts", "collapseToasts"]
|
|
278
239
|
},
|
|
279
240
|
{
|
|
280
|
-
actions: ["
|
|
241
|
+
actions: ["resumeToasts"]
|
|
281
242
|
}
|
|
282
243
|
],
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
},
|
|
287
|
-
entry: ["invokeOnVisible"],
|
|
288
|
-
activities: ["trackHeight"],
|
|
289
|
-
states: {
|
|
290
|
-
"visible:updating": {
|
|
291
|
-
tags: ["visible", "updating"],
|
|
292
|
-
after: {
|
|
293
|
-
0: "visible"
|
|
294
|
-
}
|
|
295
|
-
},
|
|
296
|
-
"visible:persist": {
|
|
297
|
-
tags: ["visible", "paused"],
|
|
298
|
-
on: {
|
|
299
|
-
RESUME: {
|
|
300
|
-
guard: Z("isLoadingType"),
|
|
301
|
-
target: "visible",
|
|
302
|
-
actions: ["setCreatedAt"]
|
|
303
|
-
},
|
|
304
|
-
DISMISS: "dismissing"
|
|
305
|
-
}
|
|
306
|
-
},
|
|
307
|
-
visible: {
|
|
308
|
-
tags: ["visible"],
|
|
309
|
-
after: {
|
|
310
|
-
VISIBLE_DURATION: "dismissing"
|
|
311
|
-
},
|
|
312
|
-
on: {
|
|
313
|
-
DISMISS: "dismissing",
|
|
314
|
-
PAUSE: {
|
|
315
|
-
target: "visible:persist",
|
|
316
|
-
actions: "setRemainingDuration"
|
|
317
|
-
}
|
|
318
|
-
}
|
|
244
|
+
"REGION.OVERLAP": {
|
|
245
|
+
target: "overlap",
|
|
246
|
+
actions: ["collapseToasts"]
|
|
319
247
|
},
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
after: {
|
|
323
|
-
REMOVE_DELAY: {
|
|
324
|
-
target: "unmounted",
|
|
325
|
-
actions: "notifyParentToRemove"
|
|
326
|
-
}
|
|
327
|
-
}
|
|
248
|
+
"REGION.FOCUS": {
|
|
249
|
+
actions: ["setLastFocusedEl", "pauseToasts"]
|
|
328
250
|
},
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
type: "final"
|
|
251
|
+
"REGION.POINTER_ENTER": {
|
|
252
|
+
actions: ["pauseToasts"]
|
|
332
253
|
}
|
|
333
254
|
}
|
|
334
255
|
},
|
|
335
|
-
{
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
const g = f.getRootEl(a);
|
|
341
|
-
if (!g) return;
|
|
342
|
-
a.mounted = !0;
|
|
343
|
-
const p = H(g, "[data-ghost]");
|
|
344
|
-
B(
|
|
345
|
-
p.length !== 2,
|
|
346
|
-
"[toast] No ghost element found in toast. Render the `ghostBefore` and `ghostAfter` elements"
|
|
347
|
-
);
|
|
348
|
-
const m = () => {
|
|
349
|
-
const M = g.style.height;
|
|
350
|
-
g.style.height = "auto";
|
|
351
|
-
const R = g.getBoundingClientRect().height;
|
|
352
|
-
g.style.height = M, a.height = R, n.sendParent({ type: "UPDATE_HEIGHT", id: n.id, height: R, placement: a.placement });
|
|
353
|
-
};
|
|
354
|
-
m();
|
|
355
|
-
const S = f.getWin(a), E = new S.MutationObserver(m);
|
|
356
|
-
E.observe(g, { childList: !0, subtree: !0, characterData: !0 }), l = () => E.disconnect();
|
|
357
|
-
}), () => l == null ? void 0 : l();
|
|
358
|
-
}
|
|
359
|
-
},
|
|
360
|
-
guards: {
|
|
361
|
-
isChangingToLoading: (a, e) => {
|
|
362
|
-
var n;
|
|
363
|
-
return ((n = e.toast) == null ? void 0 : n.type) === "loading";
|
|
256
|
+
overlap: {
|
|
257
|
+
on: {
|
|
258
|
+
"REGION.STACK": {
|
|
259
|
+
target: "stack",
|
|
260
|
+
actions: ["expandToasts"]
|
|
364
261
|
},
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
return ((n = e.toast) == null ? void 0 : n.type) != null && e.toast.type !== a.type;
|
|
262
|
+
"REGION.POINTER_ENTER": {
|
|
263
|
+
target: "stack",
|
|
264
|
+
actions: ["pauseToasts", "expandToasts"]
|
|
369
265
|
},
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
266
|
+
"REGION.FOCUS": {
|
|
267
|
+
target: "stack",
|
|
268
|
+
actions: ["setLastFocusedEl", "pauseToasts", "expandToasts"]
|
|
373
269
|
}
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
},
|
|
273
|
+
implementations: {
|
|
274
|
+
guards: {
|
|
275
|
+
isOverlapping: ({ computed: t }) => t("overlap")
|
|
276
|
+
},
|
|
277
|
+
effects: {
|
|
278
|
+
subscribeToStore({ context: t, prop: e }) {
|
|
279
|
+
return e("store").subscribe((i) => {
|
|
280
|
+
if (i.dismiss) {
|
|
281
|
+
t.set("toasts", (s) => s.filter((r) => r.id !== i.id));
|
|
282
|
+
return;
|
|
283
|
+
}
|
|
284
|
+
t.set("toasts", (s) => {
|
|
285
|
+
const r = s.findIndex((a) => a.id === i.id);
|
|
286
|
+
return r !== -1 ? [...s.slice(0, r), { ...s[r], ...i }, ...s.slice(r + 1)] : [i, ...s];
|
|
287
|
+
});
|
|
288
|
+
});
|
|
374
289
|
},
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
290
|
+
trackHotKeyPress({ prop: t, send: e }) {
|
|
291
|
+
return N(document, "keydown", (s) => {
|
|
292
|
+
const { hotkey: r } = t("store").attrs;
|
|
293
|
+
r.every((c) => s[c] || s.code === c) && e({ type: "DOC.HOTKEY" });
|
|
294
|
+
}, { capture: !0 });
|
|
378
295
|
},
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
const p = l.getBoundingClientRect().height;
|
|
388
|
-
l.style.height = g, a.height = p, n.sendParent({ type: "UPDATE_HEIGHT", id: n.id, height: p, placement: a.placement });
|
|
389
|
-
});
|
|
390
|
-
},
|
|
391
|
-
setRemainingDuration(a) {
|
|
392
|
-
a.remaining -= Date.now() - a.createdAt;
|
|
393
|
-
},
|
|
394
|
-
setCreatedAt(a) {
|
|
395
|
-
a.createdAt = Date.now();
|
|
396
|
-
},
|
|
397
|
-
notifyParentToRemove(a, e, { self: n }) {
|
|
398
|
-
n.sendParent({ type: "REMOVE_TOAST", id: n.id });
|
|
399
|
-
},
|
|
400
|
-
invokeOnDismiss(a) {
|
|
401
|
-
var e;
|
|
402
|
-
(e = a.onStatusChange) == null || e.call(a, { status: "dismissing" });
|
|
403
|
-
},
|
|
404
|
-
invokeOnUnmount(a) {
|
|
405
|
-
var e;
|
|
406
|
-
(e = a.onStatusChange) == null || e.call(a, { status: "unmounted" });
|
|
407
|
-
},
|
|
408
|
-
invokeOnVisible(a) {
|
|
409
|
-
var e;
|
|
410
|
-
(e = a.onStatusChange) == null || e.call(a, { status: "visible" });
|
|
411
|
-
},
|
|
412
|
-
setContext(a, e) {
|
|
413
|
-
var p, m;
|
|
414
|
-
const n = (p = e.toast) == null ? void 0 : p.duration, l = ((m = e.toast) == null ? void 0 : m.type) ?? a.type, g = _(n, l);
|
|
415
|
-
Object.assign(a, {
|
|
416
|
-
...e.toast,
|
|
417
|
-
duration: g,
|
|
418
|
-
remaining: g
|
|
419
|
-
});
|
|
420
|
-
}
|
|
296
|
+
trackDocumentVisibility({ prop: t, send: e, scope: i }) {
|
|
297
|
+
const { pauseOnPageIdle: s } = t("store").attrs;
|
|
298
|
+
if (!s) return;
|
|
299
|
+
const r = i.getDoc();
|
|
300
|
+
return N(r, "visibilitychange", () => {
|
|
301
|
+
const a = r.visibilityState === "hidden";
|
|
302
|
+
e({ type: a ? "PAUSE_ALL" : "RESUME_ALL" });
|
|
303
|
+
});
|
|
421
304
|
}
|
|
422
|
-
}
|
|
423
|
-
|
|
424
|
-
}
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
pauseOnPageIdle: !1,
|
|
436
|
-
hotkey: ["altKey", "KeyT"],
|
|
437
|
-
offsets: "1rem",
|
|
438
|
-
placement: "bottom",
|
|
439
|
-
removeDelay: 200,
|
|
440
|
-
...r,
|
|
441
|
-
toasts: [],
|
|
442
|
-
lastFocusedEl: null,
|
|
443
|
-
isFocusWithin: !1,
|
|
444
|
-
heights: []
|
|
305
|
+
},
|
|
306
|
+
actions: {
|
|
307
|
+
setDismissableBranch({ refs: t, context: e, computed: i, scope: s }) {
|
|
308
|
+
var m;
|
|
309
|
+
const r = e.get("toasts"), a = i("placement"), c = r.length > 0;
|
|
310
|
+
if (!c) {
|
|
311
|
+
(m = t.get("dismissableCleanup")) == null || m();
|
|
312
|
+
return;
|
|
313
|
+
}
|
|
314
|
+
if (c && t.get("dismissableCleanup"))
|
|
315
|
+
return;
|
|
316
|
+
const d = Z(() => H(s, a), { defer: !0 });
|
|
317
|
+
t.set("dismissableCleanup", d);
|
|
445
318
|
},
|
|
446
|
-
|
|
447
|
-
|
|
319
|
+
clearDismissableBranch({ refs: t }) {
|
|
320
|
+
var e;
|
|
321
|
+
(e = t.get("dismissableCleanup")) == null || e();
|
|
448
322
|
},
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
323
|
+
focusRegionEl({ scope: t, computed: e }) {
|
|
324
|
+
queueMicrotask(() => {
|
|
325
|
+
var i;
|
|
326
|
+
(i = H(t, e("placement"))) == null || i.focus();
|
|
327
|
+
});
|
|
452
328
|
},
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
PAUSE_TOAST: {
|
|
456
|
-
actions: ["pauseToast"]
|
|
457
|
-
},
|
|
458
|
-
PAUSE_ALL: {
|
|
459
|
-
actions: ["pauseToasts"]
|
|
460
|
-
},
|
|
461
|
-
RESUME_TOAST: {
|
|
462
|
-
actions: ["resumeToast"]
|
|
463
|
-
},
|
|
464
|
-
RESUME_ALL: {
|
|
465
|
-
actions: ["resumeToasts"]
|
|
466
|
-
},
|
|
467
|
-
ADD_TOAST: {
|
|
468
|
-
guard: "isWithinRange",
|
|
469
|
-
actions: ["createToast", "syncToastIndex"]
|
|
470
|
-
},
|
|
471
|
-
UPDATE_TOAST: {
|
|
472
|
-
actions: ["updateToast"]
|
|
473
|
-
},
|
|
474
|
-
DISMISS_TOAST: {
|
|
475
|
-
actions: ["dismissToast"]
|
|
476
|
-
},
|
|
477
|
-
DISMISS_ALL: {
|
|
478
|
-
actions: ["dismissToasts"]
|
|
479
|
-
},
|
|
480
|
-
REMOVE_TOAST: {
|
|
481
|
-
actions: ["removeToast", "syncToastIndex", "syncToastOffset"]
|
|
482
|
-
},
|
|
483
|
-
REMOVE_ALL: {
|
|
484
|
-
actions: ["removeToasts"]
|
|
485
|
-
},
|
|
486
|
-
UPDATE_HEIGHT: {
|
|
487
|
-
actions: ["syncHeights", "syncToastOffset"]
|
|
488
|
-
},
|
|
489
|
-
"DOC.HOTKEY": {
|
|
490
|
-
actions: ["focusRegionEl"]
|
|
491
|
-
},
|
|
492
|
-
"REGION.BLUR": [
|
|
493
|
-
{
|
|
494
|
-
guard: "isOverlapping",
|
|
495
|
-
target: "overlap",
|
|
496
|
-
actions: ["resumeToasts", "restoreLastFocusedEl"]
|
|
497
|
-
},
|
|
498
|
-
{
|
|
499
|
-
actions: ["resumeToasts", "restoreLastFocusedEl"]
|
|
500
|
-
}
|
|
501
|
-
]
|
|
329
|
+
pauseToasts({ prop: t }) {
|
|
330
|
+
t("store").pause();
|
|
502
331
|
},
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
entry: ["expandToasts"],
|
|
506
|
-
on: {
|
|
507
|
-
"REGION.POINTER_LEAVE": [
|
|
508
|
-
{
|
|
509
|
-
guard: "isOverlapping",
|
|
510
|
-
target: "overlap",
|
|
511
|
-
actions: ["resumeToasts"]
|
|
512
|
-
},
|
|
513
|
-
{
|
|
514
|
-
actions: ["resumeToasts"]
|
|
515
|
-
}
|
|
516
|
-
],
|
|
517
|
-
"REGION.OVERLAP": {
|
|
518
|
-
target: "overlap"
|
|
519
|
-
},
|
|
520
|
-
"REGION.FOCUS": {
|
|
521
|
-
actions: ["setLastFocusedEl", "pauseToasts"]
|
|
522
|
-
},
|
|
523
|
-
"REGION.POINTER_ENTER": {
|
|
524
|
-
actions: ["pauseToasts"]
|
|
525
|
-
}
|
|
526
|
-
}
|
|
527
|
-
},
|
|
528
|
-
overlap: {
|
|
529
|
-
entry: ["collapseToasts"],
|
|
530
|
-
on: {
|
|
531
|
-
"REGION.STACK": {
|
|
532
|
-
target: "stack"
|
|
533
|
-
},
|
|
534
|
-
"REGION.POINTER_ENTER": {
|
|
535
|
-
target: "stack",
|
|
536
|
-
actions: ["pauseToasts"]
|
|
537
|
-
},
|
|
538
|
-
"REGION.FOCUS": {
|
|
539
|
-
target: "stack",
|
|
540
|
-
actions: ["setLastFocusedEl", "pauseToasts"]
|
|
541
|
-
}
|
|
542
|
-
}
|
|
543
|
-
}
|
|
544
|
-
}
|
|
545
|
-
},
|
|
546
|
-
{
|
|
547
|
-
guards: {
|
|
548
|
-
isWithinRange: (t) => t.toasts.length < t.max,
|
|
549
|
-
isOverlapping: (t) => !!t.overlap
|
|
332
|
+
resumeToasts({ prop: t }) {
|
|
333
|
+
t("store").resume();
|
|
550
334
|
},
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
return D(document, "keydown", (u) => {
|
|
554
|
-
t.hotkey.every((d) => u[d] || u.code === d) && i({ type: "DOC.HOTKEY" });
|
|
555
|
-
}, { capture: !0 });
|
|
556
|
-
},
|
|
557
|
-
trackDocumentVisibility(t, s, { send: i }) {
|
|
558
|
-
if (!t.pauseOnPageIdle) return;
|
|
559
|
-
const c = f.getDoc(t);
|
|
560
|
-
return D(c, "visibilitychange", () => {
|
|
561
|
-
i(c.visibilityState === "hidden" ? "PAUSE_ALL" : "RESUME_ALL");
|
|
562
|
-
});
|
|
563
|
-
}
|
|
335
|
+
expandToasts({ prop: t }) {
|
|
336
|
+
t("store").expand();
|
|
564
337
|
},
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
}
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
I(t, (s) => {
|
|
590
|
-
s.state.context.stacked = !0;
|
|
591
|
-
});
|
|
592
|
-
},
|
|
593
|
-
collapseToasts(t) {
|
|
594
|
-
I(t, (s) => {
|
|
595
|
-
s.state.context.stacked = !1;
|
|
596
|
-
});
|
|
597
|
-
},
|
|
598
|
-
collapsedIfEmpty(t, s, { send: i }) {
|
|
599
|
-
!t.overlap || t.toasts.length > 1 || i("REGION.OVERLAP");
|
|
600
|
-
},
|
|
601
|
-
pauseToast(t, s, { self: i }) {
|
|
602
|
-
i.sendChild("PAUSE", s.id);
|
|
603
|
-
},
|
|
604
|
-
pauseToasts(t) {
|
|
605
|
-
t.toasts.forEach((s) => s.send("PAUSE"));
|
|
606
|
-
},
|
|
607
|
-
resumeToast(t, s, { self: i }) {
|
|
608
|
-
i.sendChild("RESUME", s.id);
|
|
609
|
-
},
|
|
610
|
-
resumeToasts(t) {
|
|
611
|
-
t.toasts.forEach((s) => s.send("RESUME"));
|
|
612
|
-
},
|
|
613
|
-
measureToasts(t) {
|
|
614
|
-
t.toasts.forEach((s) => s.send("MEASURE"));
|
|
615
|
-
},
|
|
616
|
-
createToast(t, s, { self: i, getState: c }) {
|
|
617
|
-
const u = {
|
|
618
|
-
placement: t.placement,
|
|
619
|
-
duration: t.duration,
|
|
620
|
-
removeDelay: t.removeDelay,
|
|
621
|
-
...s.toast,
|
|
622
|
-
dir: t.dir,
|
|
623
|
-
getRootNode: t.getRootNode,
|
|
624
|
-
stacked: c().matches("stack")
|
|
625
|
-
}, h = z(u), d = i.spawn(h);
|
|
626
|
-
t.toasts = [d, ...t.toasts];
|
|
627
|
-
},
|
|
628
|
-
updateToast(t, s, { self: i }) {
|
|
629
|
-
i.sendChild({ type: "UPDATE", toast: s.toast }, s.id);
|
|
630
|
-
},
|
|
631
|
-
dismissToast(t, s, { self: i }) {
|
|
632
|
-
i.sendChild("DISMISS", s.id);
|
|
633
|
-
},
|
|
634
|
-
dismissToasts(t) {
|
|
635
|
-
t.toasts.forEach((s) => s.send("DISMISS"));
|
|
636
|
-
},
|
|
637
|
-
removeToast(t, s, { self: i }) {
|
|
638
|
-
i.stopChild(s.id), t.toasts = t.toasts.filter((c) => c.id !== s.id), t.heights = t.heights.filter((c) => c.id !== s.id);
|
|
639
|
-
},
|
|
640
|
-
removeToasts(t, s, { self: i }) {
|
|
641
|
-
t.toasts.forEach((c) => i.stopChild(c.id)), t.toasts = [], t.heights = [];
|
|
642
|
-
},
|
|
643
|
-
syncHeights(t, s) {
|
|
644
|
-
const i = t.heights.find((c) => c.id === s.id);
|
|
645
|
-
if (i)
|
|
646
|
-
i.height = s.height, i.placement = s.placement;
|
|
647
|
-
else {
|
|
648
|
-
const c = { id: s.id, height: s.height, placement: s.placement };
|
|
649
|
-
t.heights = [c, ...t.heights];
|
|
650
|
-
}
|
|
651
|
-
},
|
|
652
|
-
syncToastIndex(t) {
|
|
653
|
-
I(t, (s, i, c) => {
|
|
654
|
-
s.state.context.index = i, s.state.context.frontmost = i === 0, s.state.context.zIndex = c.length - i;
|
|
655
|
-
});
|
|
656
|
-
},
|
|
657
|
-
syncToastOffset(t, s) {
|
|
658
|
-
const i = s.placement ?? t.placement;
|
|
659
|
-
I({ ...t, placement: i }, (c) => {
|
|
660
|
-
const u = Math.max(
|
|
661
|
-
t.heights.findIndex((d) => d.id === c.id),
|
|
662
|
-
0
|
|
663
|
-
), h = t.heights.reduce((d, a, e) => e >= u ? d : d + a.height, 0);
|
|
664
|
-
c.state.context.offset = u * t.gap + h;
|
|
665
|
-
});
|
|
666
|
-
},
|
|
667
|
-
setLastFocusedEl(t, s) {
|
|
668
|
-
t.isFocusWithin || !s.target || (t.isFocusWithin = !0, t.lastFocusedEl = w(s.target));
|
|
669
|
-
},
|
|
670
|
-
restoreLastFocusedEl(t) {
|
|
671
|
-
t.isFocusWithin = !1, t.lastFocusedEl && (t.lastFocusedEl.focus({ preventScroll: !0 }), t.lastFocusedEl = null);
|
|
672
|
-
},
|
|
673
|
-
clearLastFocusedEl(t) {
|
|
674
|
-
t.lastFocusedEl && (t.lastFocusedEl.focus({ preventScroll: !0 }), t.lastFocusedEl = null, t.isFocusWithin = !1);
|
|
675
|
-
}
|
|
338
|
+
collapseToasts({ prop: t }) {
|
|
339
|
+
t("store").collapse();
|
|
340
|
+
},
|
|
341
|
+
removeToast({ prop: t, event: e }) {
|
|
342
|
+
t("store").remove(e.id);
|
|
343
|
+
},
|
|
344
|
+
removeHeight({ event: t, context: e }) {
|
|
345
|
+
(t == null ? void 0 : t.id) != null && queueMicrotask(() => {
|
|
346
|
+
e.set("heights", (i) => i.filter((s) => s.id !== t.id));
|
|
347
|
+
});
|
|
348
|
+
},
|
|
349
|
+
collapsedIfEmpty({ send: t, computed: e }) {
|
|
350
|
+
!e("overlap") || e("count") > 1 || t({ type: "REGION.OVERLAP" });
|
|
351
|
+
},
|
|
352
|
+
setLastFocusedEl({ refs: t, event: e }) {
|
|
353
|
+
t.get("isFocusWithin") || !e.target || (t.set("isFocusWithin", !0), t.set("lastFocusedEl", e.target));
|
|
354
|
+
},
|
|
355
|
+
restoreLastFocusedEl({ refs: t }) {
|
|
356
|
+
var e;
|
|
357
|
+
t.get("lastFocusedEl") && ((e = t.get("lastFocusedEl")) == null || e.focus({ preventScroll: !0 }), t.set("lastFocusedEl", null), t.set("isFocusWithin", !1));
|
|
358
|
+
},
|
|
359
|
+
clearLastFocusedEl({ refs: t }) {
|
|
360
|
+
var e;
|
|
361
|
+
t.get("lastFocusedEl") && ((e = t.get("lastFocusedEl")) == null || e.focus({ preventScroll: !0 }), t.set("lastFocusedEl", null), t.set("isFocusWithin", !1));
|
|
676
362
|
}
|
|
677
363
|
}
|
|
678
|
-
|
|
679
|
-
}
|
|
680
|
-
function
|
|
681
|
-
|
|
682
|
-
}
|
|
683
|
-
function ct(o, r, t) {
|
|
684
|
-
const s = o.hasTag("visible"), i = o.hasTag("paused"), c = o.context.placement, u = o.context.type, [h, d = "center"] = c.split("-");
|
|
364
|
+
}
|
|
365
|
+
});
|
|
366
|
+
function Dt(t, e) {
|
|
367
|
+
const { state: i, send: s, prop: r, scope: a, context: c, computed: l } = t, d = i.hasTag("visible"), m = i.hasTag("paused"), u = c.get("mounted"), p = l("frontmost"), v = r("parent").computed("placement"), f = r("type"), h = r("stacked"), b = r("title"), E = r("description"), S = r("action"), [F, R = "center"] = v.split("-");
|
|
685
368
|
return {
|
|
686
|
-
type:
|
|
687
|
-
title:
|
|
688
|
-
description:
|
|
689
|
-
placement:
|
|
690
|
-
visible:
|
|
691
|
-
paused:
|
|
369
|
+
type: f,
|
|
370
|
+
title: b,
|
|
371
|
+
description: E,
|
|
372
|
+
placement: v,
|
|
373
|
+
visible: d,
|
|
374
|
+
paused: m,
|
|
375
|
+
closable: !!r("closable"),
|
|
692
376
|
pause() {
|
|
693
|
-
|
|
377
|
+
s({ type: "PAUSE" });
|
|
694
378
|
},
|
|
695
379
|
resume() {
|
|
696
|
-
|
|
380
|
+
s({ type: "RESUME" });
|
|
697
381
|
},
|
|
698
382
|
dismiss() {
|
|
699
|
-
|
|
383
|
+
s({ type: "DISMISS", src: "programmatic" });
|
|
700
384
|
},
|
|
701
385
|
getRootProps() {
|
|
702
|
-
return
|
|
703
|
-
...
|
|
704
|
-
dir:
|
|
705
|
-
id:
|
|
706
|
-
"data-state":
|
|
707
|
-
"data-type":
|
|
708
|
-
"data-placement":
|
|
709
|
-
"data-align":
|
|
710
|
-
"data-side":
|
|
711
|
-
"data-mounted":
|
|
712
|
-
"data-paused":
|
|
713
|
-
"data-first":
|
|
714
|
-
"data-sibling":
|
|
715
|
-
"data-stack":
|
|
716
|
-
"data-overlap":
|
|
386
|
+
return e.element({
|
|
387
|
+
...O.root.attrs,
|
|
388
|
+
dir: r("dir"),
|
|
389
|
+
id: W(a),
|
|
390
|
+
"data-state": d ? "open" : "closed",
|
|
391
|
+
"data-type": f,
|
|
392
|
+
"data-placement": v,
|
|
393
|
+
"data-align": R,
|
|
394
|
+
"data-side": F,
|
|
395
|
+
"data-mounted": D(u),
|
|
396
|
+
"data-paused": D(m),
|
|
397
|
+
"data-first": D(p),
|
|
398
|
+
"data-sibling": D(!p),
|
|
399
|
+
"data-stack": D(h),
|
|
400
|
+
"data-overlap": D(!h),
|
|
717
401
|
role: "status",
|
|
718
402
|
"aria-atomic": "true",
|
|
719
|
-
"aria-describedby":
|
|
720
|
-
"aria-labelledby":
|
|
403
|
+
"aria-describedby": E ? G(a) : void 0,
|
|
404
|
+
"aria-labelledby": b ? V(a) : void 0,
|
|
721
405
|
tabIndex: 0,
|
|
722
|
-
style:
|
|
723
|
-
onKeyDown(
|
|
724
|
-
|
|
406
|
+
style: rt(t, d),
|
|
407
|
+
onKeyDown(g) {
|
|
408
|
+
g.defaultPrevented || g.key == "Escape" && (s({ type: "DISMISS", src: "keyboard" }), g.preventDefault());
|
|
725
409
|
}
|
|
726
410
|
});
|
|
727
411
|
},
|
|
728
412
|
/* Leave a ghost div to avoid setting hover to false when transitioning out */
|
|
729
413
|
getGhostBeforeProps() {
|
|
730
|
-
return
|
|
414
|
+
return e.element({
|
|
731
415
|
"data-ghost": "before",
|
|
732
|
-
style:
|
|
416
|
+
style: ot(t, d)
|
|
733
417
|
});
|
|
734
418
|
},
|
|
735
419
|
/* Needed to avoid setting hover to false when in between toasts */
|
|
736
420
|
getGhostAfterProps() {
|
|
737
|
-
return
|
|
421
|
+
return e.element({
|
|
738
422
|
"data-ghost": "after",
|
|
739
|
-
style:
|
|
423
|
+
style: at()
|
|
740
424
|
});
|
|
741
425
|
},
|
|
742
426
|
getTitleProps() {
|
|
743
|
-
return
|
|
744
|
-
...
|
|
745
|
-
id:
|
|
427
|
+
return e.element({
|
|
428
|
+
...O.title.attrs,
|
|
429
|
+
id: V(a)
|
|
746
430
|
});
|
|
747
431
|
},
|
|
748
432
|
getDescriptionProps() {
|
|
749
|
-
return
|
|
750
|
-
...
|
|
751
|
-
id:
|
|
433
|
+
return e.element({
|
|
434
|
+
...O.description.attrs,
|
|
435
|
+
id: G(a)
|
|
752
436
|
});
|
|
753
437
|
},
|
|
754
438
|
getActionTriggerProps() {
|
|
755
|
-
return
|
|
756
|
-
...
|
|
439
|
+
return e.button({
|
|
440
|
+
...O.actionTrigger.attrs,
|
|
757
441
|
type: "button",
|
|
758
|
-
onClick(
|
|
759
|
-
var
|
|
760
|
-
|
|
442
|
+
onClick(g) {
|
|
443
|
+
var k;
|
|
444
|
+
g.defaultPrevented || ((k = S == null ? void 0 : S.onClick) == null || k.call(S), s({ type: "DISMISS", src: "user" }));
|
|
761
445
|
}
|
|
762
446
|
});
|
|
763
447
|
},
|
|
764
448
|
getCloseTriggerProps() {
|
|
765
|
-
return
|
|
766
|
-
id:
|
|
767
|
-
...
|
|
449
|
+
return e.button({
|
|
450
|
+
id: st(a),
|
|
451
|
+
...O.closeTrigger.attrs,
|
|
768
452
|
type: "button",
|
|
769
453
|
"aria-label": "Dismiss notification",
|
|
770
|
-
onClick(
|
|
771
|
-
|
|
454
|
+
onClick(g) {
|
|
455
|
+
g.defaultPrevented || s({ type: "DISMISS", src: "user" });
|
|
456
|
+
}
|
|
457
|
+
});
|
|
458
|
+
}
|
|
459
|
+
};
|
|
460
|
+
}
|
|
461
|
+
var { not: ut } = Y(), Ot = K({
|
|
462
|
+
props({ props: t }) {
|
|
463
|
+
return z(t, ["id", "type", "parent", "removeDelay"], "toast"), {
|
|
464
|
+
closable: !0,
|
|
465
|
+
...t,
|
|
466
|
+
duration: A(t.duration, t.type)
|
|
467
|
+
};
|
|
468
|
+
},
|
|
469
|
+
initialState({ prop: t }) {
|
|
470
|
+
return t("type") === "loading" || t("duration") === 1 / 0 ? "visible:persist" : "visible";
|
|
471
|
+
},
|
|
472
|
+
context({ prop: t, bindable: e }) {
|
|
473
|
+
return {
|
|
474
|
+
remainingTime: e(() => ({
|
|
475
|
+
defaultValue: A(t("duration"), t("type"))
|
|
476
|
+
})),
|
|
477
|
+
createdAt: e(() => ({
|
|
478
|
+
defaultValue: Date.now()
|
|
479
|
+
})),
|
|
480
|
+
mounted: e(() => ({
|
|
481
|
+
defaultValue: !1
|
|
482
|
+
})),
|
|
483
|
+
initialHeight: e(() => ({
|
|
484
|
+
defaultValue: 0
|
|
485
|
+
}))
|
|
486
|
+
};
|
|
487
|
+
},
|
|
488
|
+
refs() {
|
|
489
|
+
return {
|
|
490
|
+
closeTimerStartTime: Date.now(),
|
|
491
|
+
lastCloseStartTimerStartTime: 0
|
|
492
|
+
};
|
|
493
|
+
},
|
|
494
|
+
computed: {
|
|
495
|
+
zIndex: ({ prop: t }) => {
|
|
496
|
+
const e = t("parent").context.get("toasts"), i = e.findIndex((s) => s.id === t("id"));
|
|
497
|
+
return e.length - i;
|
|
498
|
+
},
|
|
499
|
+
height: ({ prop: t }) => {
|
|
500
|
+
const i = t("parent").context.get("heights").find((s) => s.id === t("id"));
|
|
501
|
+
return (i == null ? void 0 : i.height) ?? 0;
|
|
502
|
+
},
|
|
503
|
+
heightIndex: ({ prop: t }) => t("parent").context.get("heights").findIndex((i) => i.id === t("id")),
|
|
504
|
+
frontmost: ({ prop: t }) => t("index") === 0,
|
|
505
|
+
heightBefore: ({ prop: t }) => {
|
|
506
|
+
const e = t("parent").context.get("heights"), i = e.findIndex((s) => s.id === t("id"));
|
|
507
|
+
return e.reduce((s, r, a) => a >= i ? s : s + r.height, 0);
|
|
508
|
+
},
|
|
509
|
+
shouldPersist: ({ prop: t }) => t("type") === "loading" || t("duration") === 1 / 0
|
|
510
|
+
},
|
|
511
|
+
watch({ track: t, prop: e, send: i }) {
|
|
512
|
+
t([() => e("message")], () => {
|
|
513
|
+
const s = e("message");
|
|
514
|
+
s && i({ type: s, src: "programmatic" });
|
|
515
|
+
}), t([() => e("type"), () => e("duration")], () => {
|
|
516
|
+
i({ type: "UPDATE" });
|
|
517
|
+
});
|
|
518
|
+
},
|
|
519
|
+
on: {
|
|
520
|
+
UPDATE: [
|
|
521
|
+
{
|
|
522
|
+
guard: "shouldPersist",
|
|
523
|
+
target: "visible:persist",
|
|
524
|
+
actions: ["resetCloseTimer"]
|
|
525
|
+
},
|
|
526
|
+
{
|
|
527
|
+
target: "visible:updating",
|
|
528
|
+
actions: ["resetCloseTimer"]
|
|
529
|
+
}
|
|
530
|
+
],
|
|
531
|
+
MEASURE: {
|
|
532
|
+
actions: ["measureHeight"]
|
|
533
|
+
}
|
|
534
|
+
},
|
|
535
|
+
entry: ["setMounted", "measureHeight", "invokeOnVisible"],
|
|
536
|
+
effects: ["trackHeight"],
|
|
537
|
+
states: {
|
|
538
|
+
"visible:updating": {
|
|
539
|
+
tags: ["visible", "updating"],
|
|
540
|
+
effects: ["waitForNextTick"],
|
|
541
|
+
on: {
|
|
542
|
+
SHOW: {
|
|
543
|
+
target: "visible"
|
|
772
544
|
}
|
|
545
|
+
}
|
|
546
|
+
},
|
|
547
|
+
"visible:persist": {
|
|
548
|
+
tags: ["visible", "paused"],
|
|
549
|
+
on: {
|
|
550
|
+
RESUME: {
|
|
551
|
+
guard: ut("isLoadingType"),
|
|
552
|
+
target: "visible",
|
|
553
|
+
actions: ["setCloseTimer"]
|
|
554
|
+
},
|
|
555
|
+
DISMISS: {
|
|
556
|
+
target: "dismissing"
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
},
|
|
560
|
+
visible: {
|
|
561
|
+
tags: ["visible"],
|
|
562
|
+
effects: ["waitForDuration"],
|
|
563
|
+
on: {
|
|
564
|
+
DISMISS: {
|
|
565
|
+
target: "dismissing"
|
|
566
|
+
},
|
|
567
|
+
PAUSE: {
|
|
568
|
+
target: "visible:persist",
|
|
569
|
+
actions: ["syncRemainingTime"]
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
},
|
|
573
|
+
dismissing: {
|
|
574
|
+
entry: ["invokeOnDismiss"],
|
|
575
|
+
effects: ["waitForRemoveDelay"],
|
|
576
|
+
on: {
|
|
577
|
+
REMOVE: {
|
|
578
|
+
target: "unmounted",
|
|
579
|
+
actions: ["notifyParentToRemove"]
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
},
|
|
583
|
+
unmounted: {
|
|
584
|
+
entry: ["invokeOnUnmount"]
|
|
585
|
+
}
|
|
586
|
+
},
|
|
587
|
+
implementations: {
|
|
588
|
+
effects: {
|
|
589
|
+
waitForRemoveDelay({ prop: t, send: e }) {
|
|
590
|
+
return w(() => {
|
|
591
|
+
e({ type: "REMOVE", src: "timer" });
|
|
592
|
+
}, t("removeDelay"));
|
|
593
|
+
},
|
|
594
|
+
waitForDuration({ send: t, context: e, computed: i }) {
|
|
595
|
+
if (!i("shouldPersist"))
|
|
596
|
+
return w(() => {
|
|
597
|
+
t({ type: "DISMISS", src: "timer" });
|
|
598
|
+
}, e.get("remainingTime"));
|
|
599
|
+
},
|
|
600
|
+
waitForNextTick({ send: t }) {
|
|
601
|
+
return w(() => {
|
|
602
|
+
t({ type: "SHOW", src: "timer" });
|
|
603
|
+
}, 0);
|
|
604
|
+
},
|
|
605
|
+
trackHeight({ scope: t, prop: e }) {
|
|
606
|
+
let i;
|
|
607
|
+
return L(() => {
|
|
608
|
+
const s = U(t);
|
|
609
|
+
if (!s) return;
|
|
610
|
+
const r = () => {
|
|
611
|
+
const l = s.style.height;
|
|
612
|
+
s.style.height = "auto";
|
|
613
|
+
const d = s.getBoundingClientRect().height;
|
|
614
|
+
s.style.height = l;
|
|
615
|
+
const m = { id: e("id"), height: d };
|
|
616
|
+
B(e("parent"), m);
|
|
617
|
+
}, a = t.getWin(), c = new a.MutationObserver(r);
|
|
618
|
+
c.observe(s, {
|
|
619
|
+
childList: !0,
|
|
620
|
+
subtree: !0,
|
|
621
|
+
characterData: !0
|
|
622
|
+
}), i = () => c.disconnect();
|
|
623
|
+
}), () => i == null ? void 0 : i();
|
|
624
|
+
}
|
|
625
|
+
},
|
|
626
|
+
guards: {
|
|
627
|
+
isLoadingType: ({ prop: t }) => t("type") === "loading",
|
|
628
|
+
shouldPersist: ({ computed: t }) => t("shouldPersist")
|
|
629
|
+
},
|
|
630
|
+
actions: {
|
|
631
|
+
setMounted({ context: t }) {
|
|
632
|
+
L(() => {
|
|
633
|
+
t.set("mounted", !0);
|
|
634
|
+
});
|
|
635
|
+
},
|
|
636
|
+
measureHeight({ scope: t, prop: e, context: i }) {
|
|
637
|
+
queueMicrotask(() => {
|
|
638
|
+
const s = U(t);
|
|
639
|
+
if (!s) return;
|
|
640
|
+
const r = s.style.height;
|
|
641
|
+
s.style.height = "auto";
|
|
642
|
+
const a = s.getBoundingClientRect().height;
|
|
643
|
+
s.style.height = r, i.set("initialHeight", a);
|
|
644
|
+
const c = { id: e("id"), height: a };
|
|
645
|
+
B(e("parent"), c);
|
|
646
|
+
});
|
|
647
|
+
},
|
|
648
|
+
setCloseTimer({ refs: t }) {
|
|
649
|
+
t.set("closeTimerStartTime", Date.now());
|
|
650
|
+
},
|
|
651
|
+
resetCloseTimer({ context: t, refs: e, prop: i }) {
|
|
652
|
+
e.set("closeTimerStartTime", Date.now()), t.set("remainingTime", A(i("duration"), i("type")));
|
|
653
|
+
},
|
|
654
|
+
syncRemainingTime({ context: t, refs: e }) {
|
|
655
|
+
t.set("remainingTime", (i) => {
|
|
656
|
+
const s = e.get("closeTimerStartTime"), r = Date.now() - s;
|
|
657
|
+
return e.set("lastCloseStartTimerStartTime", Date.now()), i - r;
|
|
658
|
+
});
|
|
659
|
+
},
|
|
660
|
+
notifyParentToRemove({ prop: t }) {
|
|
661
|
+
t("parent").send({ type: "TOAST.REMOVE", id: t("id") });
|
|
662
|
+
},
|
|
663
|
+
invokeOnDismiss({ prop: t, event: e }) {
|
|
664
|
+
var i;
|
|
665
|
+
(i = t("onStatusChange")) == null || i({ status: "dismissing", src: e.src });
|
|
666
|
+
},
|
|
667
|
+
invokeOnUnmount({ prop: t }) {
|
|
668
|
+
var e;
|
|
669
|
+
(e = t("onStatusChange")) == null || e({ status: "unmounted" });
|
|
670
|
+
},
|
|
671
|
+
invokeOnVisible({ prop: t }) {
|
|
672
|
+
var e;
|
|
673
|
+
(e = t("onStatusChange")) == null || e({ status: "visible" });
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
});
|
|
678
|
+
function B(t, e) {
|
|
679
|
+
const { id: i, height: s } = e;
|
|
680
|
+
t.context.set("heights", (r) => r.find((c) => c.id === i) ? r.map((c) => c.id === i ? { ...c, height: s } : c) : [{ id: i, height: s }, ...r]);
|
|
681
|
+
}
|
|
682
|
+
var dt = (t, e) => ({ ...e, ...J(t) });
|
|
683
|
+
function Rt(t) {
|
|
684
|
+
const e = dt(t, {
|
|
685
|
+
placement: "bottom",
|
|
686
|
+
overlap: !1,
|
|
687
|
+
max: 24,
|
|
688
|
+
gap: 16,
|
|
689
|
+
offsets: "1rem",
|
|
690
|
+
hotkey: ["altKey", "KeyT"],
|
|
691
|
+
removeDelay: 200,
|
|
692
|
+
pauseOnPageIdle: !0
|
|
693
|
+
});
|
|
694
|
+
let i = [], s = [], r = /* @__PURE__ */ new Set(), a = [];
|
|
695
|
+
const c = (n) => (i.push(n), () => {
|
|
696
|
+
const o = i.indexOf(n);
|
|
697
|
+
i.splice(o, 1);
|
|
698
|
+
}), l = (n) => (i.forEach((o) => o(n)), n), d = (n) => {
|
|
699
|
+
if (s.length >= e.max) {
|
|
700
|
+
a.push(n);
|
|
701
|
+
return;
|
|
702
|
+
}
|
|
703
|
+
l(n), s.unshift(n);
|
|
704
|
+
}, m = () => {
|
|
705
|
+
for (; a.length > 0 && s.length < e.max; ) {
|
|
706
|
+
const n = a.shift();
|
|
707
|
+
n && (l(n), s.unshift(n));
|
|
708
|
+
}
|
|
709
|
+
}, u = (n) => {
|
|
710
|
+
const o = n.id ?? `toast:${_()}`, I = s.find((y) => y.id === o);
|
|
711
|
+
return r.has(o) && r.delete(o), I ? s = s.map((y) => y.id === o ? l({ ...y, ...n, id: o }) : y) : d({
|
|
712
|
+
id: o,
|
|
713
|
+
duration: e.duration,
|
|
714
|
+
removeDelay: e.removeDelay,
|
|
715
|
+
type: "info",
|
|
716
|
+
...n,
|
|
717
|
+
stacked: !e.overlap,
|
|
718
|
+
gap: e.gap
|
|
719
|
+
}), o;
|
|
720
|
+
}, p = (n) => (r.add(n), n ? (i.forEach((o) => o({ id: n, dismiss: !0 })), s = s.filter((o) => o.id !== n), m()) : (s.forEach((o) => {
|
|
721
|
+
i.forEach((I) => I({ id: o.id, dismiss: !0 }));
|
|
722
|
+
}), s = [], a = []), n);
|
|
723
|
+
return {
|
|
724
|
+
attrs: e,
|
|
725
|
+
subscribe: c,
|
|
726
|
+
create: u,
|
|
727
|
+
update: (n, o) => u({ id: n, ...o }),
|
|
728
|
+
remove: p,
|
|
729
|
+
dismiss: (n) => {
|
|
730
|
+
n != null ? s = s.map((o) => o.id === n ? l({ ...o, message: "DISMISS" }) : o) : s = s.map((o) => l({ ...o, message: "DISMISS" }));
|
|
731
|
+
},
|
|
732
|
+
error: (n) => u({ ...n, type: "error" }),
|
|
733
|
+
success: (n) => u({ ...n, type: "success" }),
|
|
734
|
+
info: (n) => u({ ...n, type: "info" }),
|
|
735
|
+
warning: (n) => u({ ...n, type: "warning" }),
|
|
736
|
+
loading: (n) => u({ ...n, type: "loading" }),
|
|
737
|
+
getVisibleToasts: () => s.filter((n) => !r.has(n.id)),
|
|
738
|
+
getCount: () => s.length,
|
|
739
|
+
promise: (n, o, I = {}) => {
|
|
740
|
+
if (!o) return;
|
|
741
|
+
let y;
|
|
742
|
+
o.loading !== void 0 && (y = u({
|
|
743
|
+
...I,
|
|
744
|
+
...o.loading,
|
|
745
|
+
promise: n,
|
|
746
|
+
type: "loading"
|
|
747
|
+
}));
|
|
748
|
+
let M = y !== void 0, P;
|
|
749
|
+
const j = C(n).then(async (T) => {
|
|
750
|
+
if (P = ["resolve", T], gt(T) && !T.ok) {
|
|
751
|
+
M = !1;
|
|
752
|
+
const x = C(o.error, `HTTP Error! status: ${T.status}`);
|
|
753
|
+
u({ ...I, ...x, id: y, type: "error" });
|
|
754
|
+
} else if (o.success !== void 0) {
|
|
755
|
+
M = !1;
|
|
756
|
+
const x = C(o.success, T);
|
|
757
|
+
u({ ...I, ...x, id: y, type: "success" });
|
|
758
|
+
}
|
|
759
|
+
}).catch(async (T) => {
|
|
760
|
+
if (P = ["reject", T], o.error !== void 0) {
|
|
761
|
+
M = !1;
|
|
762
|
+
const x = C(o.error, T);
|
|
763
|
+
u({ ...I, ...x, id: y, type: "error" });
|
|
764
|
+
}
|
|
765
|
+
}).finally(() => {
|
|
766
|
+
var T;
|
|
767
|
+
M && (p(y), y = void 0), (T = o.finally) == null || T.call(o);
|
|
773
768
|
});
|
|
769
|
+
return { id: y, unwrap: () => new Promise(
|
|
770
|
+
(T, x) => j.then(() => P[0] === "reject" ? x(P[1]) : T(P[1])).catch(x)
|
|
771
|
+
) };
|
|
772
|
+
},
|
|
773
|
+
pause: (n) => {
|
|
774
|
+
n != null ? s = s.map((o) => o.id === n ? l({ ...o, message: "PAUSE" }) : o) : s = s.map((o) => l({ ...o, message: "PAUSE" }));
|
|
775
|
+
},
|
|
776
|
+
resume: (n) => {
|
|
777
|
+
n != null ? s = s.map((o) => o.id === n ? l({ ...o, message: "RESUME" }) : o) : s = s.map((o) => l({ ...o, message: "RESUME" }));
|
|
778
|
+
},
|
|
779
|
+
isVisible: (n) => !r.has(n) && !!s.find((o) => o.id === n),
|
|
780
|
+
isDismissed: (n) => r.has(n),
|
|
781
|
+
expand: () => {
|
|
782
|
+
s = s.map((n) => l({ ...n, stacked: !0 }));
|
|
783
|
+
},
|
|
784
|
+
collapse: () => {
|
|
785
|
+
s = s.map((n) => l({ ...n, stacked: !1 }));
|
|
774
786
|
}
|
|
775
787
|
};
|
|
776
788
|
}
|
|
777
|
-
var
|
|
778
|
-
connect:
|
|
779
|
-
machine:
|
|
789
|
+
var gt = (t) => t && typeof t == "object" && "ok" in t && typeof t.ok == "boolean" && "status" in t && typeof t.status == "number", kt = {
|
|
790
|
+
connect: ct,
|
|
791
|
+
machine: lt
|
|
780
792
|
};
|
|
781
793
|
export {
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
794
|
+
tt as anatomy,
|
|
795
|
+
Dt as connect,
|
|
796
|
+
Rt as createStore,
|
|
797
|
+
kt as group,
|
|
798
|
+
Ot as machine
|
|
786
799
|
};
|