@phillips/seldon 1.145.0 → 1.146.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/_virtual/index5.js +2 -2
- package/dist/_virtual/index6.js +2 -2
- package/dist/_virtual/index7.js +2 -2
- package/dist/_virtual/index8.js +2 -2
- package/dist/components/Loader/Loader.test.d.ts +1 -0
- package/dist/components/Toast/Toast.d.ts +39 -0
- package/dist/components/Toast/Toast.js +24 -0
- package/dist/components/Toast/Toast.stories.d.ts +16 -0
- package/dist/components/Toast/Toast.test.d.ts +1 -0
- package/dist/components/Toast/ToastContextProvider.d.ts +19 -0
- package/dist/components/Toast/ToastContextProvider.js +35 -0
- package/dist/components/Toast/ToastContextProvider.test.d.ts +1 -0
- package/dist/components/Toast/index.d.ts +3 -0
- package/dist/components/Toast/useToast.d.ts +3 -0
- package/dist/components/Toast/useToast.js +10 -0
- package/dist/components/Toast/useToast.test.d.ts +1 -0
- package/dist/components/Toast/useToastContext.d.ts +7 -0
- package/dist/components/Toast/useToastContext.js +16 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +50 -44
- package/dist/node_modules/@radix-ui/react-toast/dist/index.js +447 -0
- package/dist/node_modules/@radix-ui/react-toast/node_modules/@radix-ui/primitive/dist/index.js +9 -0
- package/dist/node_modules/@radix-ui/react-toast/node_modules/@radix-ui/react-collection/dist/index.js +48 -0
- package/dist/node_modules/@radix-ui/react-toast/node_modules/@radix-ui/react-compose-refs/dist/index.js +29 -0
- package/dist/node_modules/@radix-ui/react-toast/node_modules/@radix-ui/react-context/dist/index.js +53 -0
- package/dist/node_modules/@radix-ui/react-toast/node_modules/@radix-ui/react-dismissable-layer/dist/index.js +130 -0
- package/dist/node_modules/@radix-ui/react-toast/node_modules/@radix-ui/react-portal/dist/index.js +15 -0
- package/dist/node_modules/@radix-ui/react-toast/node_modules/@radix-ui/react-presence/dist/index.js +70 -0
- package/dist/node_modules/@radix-ui/react-toast/node_modules/@radix-ui/react-primitive/dist/index.js +36 -0
- package/dist/node_modules/@radix-ui/react-toast/node_modules/@radix-ui/react-slot/dist/index.js +48 -0
- package/dist/node_modules/@radix-ui/react-toast/node_modules/@radix-ui/react-use-callback-ref/dist/index.js +10 -0
- package/dist/node_modules/@radix-ui/react-toast/node_modules/@radix-ui/react-use-controllable-state/dist/index.js +52 -0
- package/dist/node_modules/@radix-ui/react-toast/node_modules/@radix-ui/react-use-escape-keydown/dist/index.js +14 -0
- package/dist/node_modules/@radix-ui/react-toast/node_modules/@radix-ui/react-use-layout-effect/dist/index.js +6 -0
- package/dist/node_modules/@radix-ui/react-toast/node_modules/@radix-ui/react-visually-hidden/dist/index.js +30 -0
- package/dist/node_modules/exenv/index.js +1 -1
- package/dist/node_modules/ics/dist/index.js +2 -2
- package/dist/node_modules/ics/dist/pipeline/index.js +1 -1
- package/dist/node_modules/prop-types/node_modules/react-is/index.js +1 -1
- package/dist/node_modules/uuid/dist/esm-browser/native.js +4 -0
- package/dist/node_modules/uuid/dist/esm-browser/rng.js +13 -0
- package/dist/node_modules/uuid/dist/esm-browser/stringify.js +9 -0
- package/dist/node_modules/uuid/dist/esm-browser/v4.js +15 -0
- package/dist/patterns/AccountPageHeader/AccountPageHeader.d.ts +2 -2
- package/dist/patterns/AccountPageHeader/AccountPageHeader.js +21 -21
- package/dist/patterns/AccountPageHeader/AccountPageHeader.stories.d.ts +1 -1
- package/dist/scss/componentStyles.scss +1 -0
- package/dist/scss/components/Toast/_toast.scss +95 -0
- package/dist/scss/patterns/AccountPageHeader/_accountPageHeader.scss +6 -1
- package/package.json +5 -2
|
@@ -0,0 +1,447 @@
|
|
|
1
|
+
import * as n from "react";
|
|
2
|
+
import * as ye from "react-dom";
|
|
3
|
+
import { composeEventHandlers as h } from "../node_modules/@radix-ui/primitive/dist/index.js";
|
|
4
|
+
import { useComposedRefs as oe } from "../node_modules/@radix-ui/react-compose-refs/dist/index.js";
|
|
5
|
+
import { createCollection as Pe } from "../node_modules/@radix-ui/react-collection/dist/index.js";
|
|
6
|
+
import { createContextScope as Ce } from "../node_modules/@radix-ui/react-context/dist/index.js";
|
|
7
|
+
import { Branch as xe, Root as he } from "../node_modules/@radix-ui/react-dismissable-layer/dist/index.js";
|
|
8
|
+
import { Portal as Re } from "../node_modules/@radix-ui/react-portal/dist/index.js";
|
|
9
|
+
import { Presence as be } from "../node_modules/@radix-ui/react-presence/dist/index.js";
|
|
10
|
+
import { Primitive as A, dispatchDiscreteCustomEvent as ge } from "../node_modules/@radix-ui/react-primitive/dist/index.js";
|
|
11
|
+
import { useCallbackRef as U } from "../node_modules/@radix-ui/react-use-callback-ref/dist/index.js";
|
|
12
|
+
import { useControllableState as Se } from "../node_modules/@radix-ui/react-use-controllable-state/dist/index.js";
|
|
13
|
+
import { useLayoutEffect as Ie } from "../node_modules/@radix-ui/react-use-layout-effect/dist/index.js";
|
|
14
|
+
import { VisuallyHidden as re } from "../node_modules/@radix-ui/react-visually-hidden/dist/index.js";
|
|
15
|
+
import { jsxs as z, jsx as l, Fragment as ne } from "react/jsx-runtime";
|
|
16
|
+
var G = "ToastProvider", [J, Ae, Fe] = Pe("Toast"), [se, at] = Ce("Toast", [Fe]), [_e, X] = se(G), ae = (e) => {
|
|
17
|
+
const {
|
|
18
|
+
__scopeToast: o,
|
|
19
|
+
label: r = "Notification",
|
|
20
|
+
duration: t = 5e3,
|
|
21
|
+
swipeDirection: c = "right",
|
|
22
|
+
swipeThreshold: d = 50,
|
|
23
|
+
children: p
|
|
24
|
+
} = e, [T, v] = n.useState(null), [i, x] = n.useState(0), E = n.useRef(!1), F = n.useRef(!1);
|
|
25
|
+
return r.trim() || console.error(
|
|
26
|
+
`Invalid prop \`label\` supplied to \`${G}\`. Expected non-empty \`string\`.`
|
|
27
|
+
), /* @__PURE__ */ l(J.Provider, { scope: o, children: /* @__PURE__ */ l(
|
|
28
|
+
_e,
|
|
29
|
+
{
|
|
30
|
+
scope: o,
|
|
31
|
+
label: r,
|
|
32
|
+
duration: t,
|
|
33
|
+
swipeDirection: c,
|
|
34
|
+
swipeThreshold: d,
|
|
35
|
+
toastCount: i,
|
|
36
|
+
viewport: T,
|
|
37
|
+
onViewportChange: v,
|
|
38
|
+
onToastAdd: n.useCallback(() => x((g) => g + 1), []),
|
|
39
|
+
onToastRemove: n.useCallback(() => x((g) => g - 1), []),
|
|
40
|
+
isFocusedToastEscapeKeyDownRef: E,
|
|
41
|
+
isClosePausedRef: F,
|
|
42
|
+
children: p
|
|
43
|
+
}
|
|
44
|
+
) });
|
|
45
|
+
};
|
|
46
|
+
ae.displayName = G;
|
|
47
|
+
var ie = "ToastViewport", De = ["F8"], B = "toast.viewportPause", j = "toast.viewportResume", ce = n.forwardRef(
|
|
48
|
+
(e, o) => {
|
|
49
|
+
const {
|
|
50
|
+
__scopeToast: r,
|
|
51
|
+
hotkey: t = De,
|
|
52
|
+
label: c = "Notifications ({hotkey})",
|
|
53
|
+
...d
|
|
54
|
+
} = e, p = X(ie, r), T = Ae(r), v = n.useRef(null), i = n.useRef(null), x = n.useRef(null), E = n.useRef(null), F = oe(o, E, p.onViewportChange), g = t.join("+").replace(/Key/g, "").replace(/Digit/g, ""), S = p.toastCount > 0;
|
|
55
|
+
n.useEffect(() => {
|
|
56
|
+
const a = (y) => {
|
|
57
|
+
t.length !== 0 && t.every((m) => y[m] || y.code === m) && E.current?.focus();
|
|
58
|
+
};
|
|
59
|
+
return document.addEventListener("keydown", a), () => document.removeEventListener("keydown", a);
|
|
60
|
+
}, [t]), n.useEffect(() => {
|
|
61
|
+
const a = v.current, y = E.current;
|
|
62
|
+
if (S && a && y) {
|
|
63
|
+
const f = () => {
|
|
64
|
+
if (!p.isClosePausedRef.current) {
|
|
65
|
+
const w = new CustomEvent(B);
|
|
66
|
+
y.dispatchEvent(w), p.isClosePausedRef.current = !0;
|
|
67
|
+
}
|
|
68
|
+
}, m = () => {
|
|
69
|
+
if (p.isClosePausedRef.current) {
|
|
70
|
+
const w = new CustomEvent(j);
|
|
71
|
+
y.dispatchEvent(w), p.isClosePausedRef.current = !1;
|
|
72
|
+
}
|
|
73
|
+
}, P = (w) => {
|
|
74
|
+
!a.contains(w.relatedTarget) && m();
|
|
75
|
+
}, C = () => {
|
|
76
|
+
a.contains(document.activeElement) || m();
|
|
77
|
+
};
|
|
78
|
+
return a.addEventListener("focusin", f), a.addEventListener("focusout", P), a.addEventListener("pointermove", f), a.addEventListener("pointerleave", C), window.addEventListener("blur", f), window.addEventListener("focus", m), () => {
|
|
79
|
+
a.removeEventListener("focusin", f), a.removeEventListener("focusout", P), a.removeEventListener("pointermove", f), a.removeEventListener("pointerleave", C), window.removeEventListener("blur", f), window.removeEventListener("focus", m);
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
}, [S, p.isClosePausedRef]);
|
|
83
|
+
const u = n.useCallback(
|
|
84
|
+
({ tabbingDirection: a }) => {
|
|
85
|
+
const f = T().map((m) => {
|
|
86
|
+
const P = m.ref.current, C = [P, ...Be(P)];
|
|
87
|
+
return a === "forwards" ? C : C.reverse();
|
|
88
|
+
});
|
|
89
|
+
return (a === "forwards" ? f.reverse() : f).flat();
|
|
90
|
+
},
|
|
91
|
+
[T]
|
|
92
|
+
);
|
|
93
|
+
return n.useEffect(() => {
|
|
94
|
+
const a = E.current;
|
|
95
|
+
if (a) {
|
|
96
|
+
const y = (f) => {
|
|
97
|
+
const m = f.altKey || f.ctrlKey || f.metaKey;
|
|
98
|
+
if (f.key === "Tab" && !m) {
|
|
99
|
+
const C = document.activeElement, w = f.shiftKey;
|
|
100
|
+
if (f.target === a && w) {
|
|
101
|
+
i.current?.focus();
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
const D = u({ tabbingDirection: w ? "backwards" : "forwards" }), k = D.findIndex((I) => I === C);
|
|
105
|
+
$(D.slice(k + 1)) ? f.preventDefault() : w ? i.current?.focus() : x.current?.focus();
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
return a.addEventListener("keydown", y), () => a.removeEventListener("keydown", y);
|
|
109
|
+
}
|
|
110
|
+
}, [T, u]), /* @__PURE__ */ z(
|
|
111
|
+
xe,
|
|
112
|
+
{
|
|
113
|
+
ref: v,
|
|
114
|
+
role: "region",
|
|
115
|
+
"aria-label": c.replace("{hotkey}", g),
|
|
116
|
+
tabIndex: -1,
|
|
117
|
+
style: { pointerEvents: S ? void 0 : "none" },
|
|
118
|
+
children: [
|
|
119
|
+
S && /* @__PURE__ */ l(
|
|
120
|
+
q,
|
|
121
|
+
{
|
|
122
|
+
ref: i,
|
|
123
|
+
onFocusFromOutsideViewport: () => {
|
|
124
|
+
const a = u({
|
|
125
|
+
tabbingDirection: "forwards"
|
|
126
|
+
});
|
|
127
|
+
$(a);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
),
|
|
131
|
+
/* @__PURE__ */ l(J.Slot, { scope: r, children: /* @__PURE__ */ l(A.ol, { tabIndex: -1, ...d, ref: F }) }),
|
|
132
|
+
S && /* @__PURE__ */ l(
|
|
133
|
+
q,
|
|
134
|
+
{
|
|
135
|
+
ref: x,
|
|
136
|
+
onFocusFromOutsideViewport: () => {
|
|
137
|
+
const a = u({
|
|
138
|
+
tabbingDirection: "backwards"
|
|
139
|
+
});
|
|
140
|
+
$(a);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
)
|
|
144
|
+
]
|
|
145
|
+
}
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
);
|
|
149
|
+
ce.displayName = ie;
|
|
150
|
+
var ue = "ToastFocusProxy", q = n.forwardRef(
|
|
151
|
+
(e, o) => {
|
|
152
|
+
const { __scopeToast: r, onFocusFromOutsideViewport: t, ...c } = e, d = X(ue, r);
|
|
153
|
+
return /* @__PURE__ */ l(
|
|
154
|
+
re,
|
|
155
|
+
{
|
|
156
|
+
"aria-hidden": !0,
|
|
157
|
+
tabIndex: 0,
|
|
158
|
+
...c,
|
|
159
|
+
ref: o,
|
|
160
|
+
style: { position: "fixed" },
|
|
161
|
+
onFocus: (p) => {
|
|
162
|
+
const T = p.relatedTarget;
|
|
163
|
+
!d.viewport?.contains(T) && t();
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
);
|
|
169
|
+
q.displayName = ue;
|
|
170
|
+
var M = "Toast", Ne = "toast.swipeStart", Le = "toast.swipeMove", Me = "toast.swipeCancel", Oe = "toast.swipeEnd", le = n.forwardRef(
|
|
171
|
+
(e, o) => {
|
|
172
|
+
const { forceMount: r, open: t, defaultOpen: c, onOpenChange: d, ...p } = e, [T, v] = Se({
|
|
173
|
+
prop: t,
|
|
174
|
+
defaultProp: c ?? !0,
|
|
175
|
+
onChange: d,
|
|
176
|
+
caller: M
|
|
177
|
+
});
|
|
178
|
+
return /* @__PURE__ */ l(be, { present: r || T, children: /* @__PURE__ */ l(
|
|
179
|
+
Ve,
|
|
180
|
+
{
|
|
181
|
+
open: T,
|
|
182
|
+
...p,
|
|
183
|
+
ref: o,
|
|
184
|
+
onClose: () => v(!1),
|
|
185
|
+
onPause: U(e.onPause),
|
|
186
|
+
onResume: U(e.onResume),
|
|
187
|
+
onSwipeStart: h(e.onSwipeStart, (i) => {
|
|
188
|
+
i.currentTarget.setAttribute("data-swipe", "start");
|
|
189
|
+
}),
|
|
190
|
+
onSwipeMove: h(e.onSwipeMove, (i) => {
|
|
191
|
+
const { x, y: E } = i.detail.delta;
|
|
192
|
+
i.currentTarget.setAttribute("data-swipe", "move"), i.currentTarget.style.setProperty("--radix-toast-swipe-move-x", `${x}px`), i.currentTarget.style.setProperty("--radix-toast-swipe-move-y", `${E}px`);
|
|
193
|
+
}),
|
|
194
|
+
onSwipeCancel: h(e.onSwipeCancel, (i) => {
|
|
195
|
+
i.currentTarget.setAttribute("data-swipe", "cancel"), i.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"), i.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"), i.currentTarget.style.removeProperty("--radix-toast-swipe-end-x"), i.currentTarget.style.removeProperty("--radix-toast-swipe-end-y");
|
|
196
|
+
}),
|
|
197
|
+
onSwipeEnd: h(e.onSwipeEnd, (i) => {
|
|
198
|
+
const { x, y: E } = i.detail.delta;
|
|
199
|
+
i.currentTarget.setAttribute("data-swipe", "end"), i.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"), i.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"), i.currentTarget.style.setProperty("--radix-toast-swipe-end-x", `${x}px`), i.currentTarget.style.setProperty("--radix-toast-swipe-end-y", `${E}px`), v(!1);
|
|
200
|
+
})
|
|
201
|
+
}
|
|
202
|
+
) });
|
|
203
|
+
}
|
|
204
|
+
);
|
|
205
|
+
le.displayName = M;
|
|
206
|
+
var [ke, Ke] = se(M, {
|
|
207
|
+
onClose() {
|
|
208
|
+
}
|
|
209
|
+
}), Ve = n.forwardRef(
|
|
210
|
+
(e, o) => {
|
|
211
|
+
const {
|
|
212
|
+
__scopeToast: r,
|
|
213
|
+
type: t = "foreground",
|
|
214
|
+
duration: c,
|
|
215
|
+
open: d,
|
|
216
|
+
onClose: p,
|
|
217
|
+
onEscapeKeyDown: T,
|
|
218
|
+
onPause: v,
|
|
219
|
+
onResume: i,
|
|
220
|
+
onSwipeStart: x,
|
|
221
|
+
onSwipeMove: E,
|
|
222
|
+
onSwipeCancel: F,
|
|
223
|
+
onSwipeEnd: g,
|
|
224
|
+
...S
|
|
225
|
+
} = e, u = X(M, r), [a, y] = n.useState(null), f = oe(o, (s) => y(s)), m = n.useRef(null), P = n.useRef(null), C = c || u.duration, w = n.useRef(0), _ = n.useRef(C), O = n.useRef(0), { onToastAdd: D, onToastRemove: k } = u, I = U(() => {
|
|
226
|
+
a?.contains(document.activeElement) && u.viewport?.focus(), p();
|
|
227
|
+
}), K = n.useCallback(
|
|
228
|
+
(s) => {
|
|
229
|
+
!s || s === 1 / 0 || (window.clearTimeout(O.current), w.current = (/* @__PURE__ */ new Date()).getTime(), O.current = window.setTimeout(I, s));
|
|
230
|
+
},
|
|
231
|
+
[I]
|
|
232
|
+
);
|
|
233
|
+
n.useEffect(() => {
|
|
234
|
+
const s = u.viewport;
|
|
235
|
+
if (s) {
|
|
236
|
+
const R = () => {
|
|
237
|
+
K(_.current), i?.();
|
|
238
|
+
}, b = () => {
|
|
239
|
+
const N = (/* @__PURE__ */ new Date()).getTime() - w.current;
|
|
240
|
+
_.current = _.current - N, window.clearTimeout(O.current), v?.();
|
|
241
|
+
};
|
|
242
|
+
return s.addEventListener(B, b), s.addEventListener(j, R), () => {
|
|
243
|
+
s.removeEventListener(B, b), s.removeEventListener(j, R);
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
}, [u.viewport, C, v, i, K]), n.useEffect(() => {
|
|
247
|
+
d && !u.isClosePausedRef.current && K(C);
|
|
248
|
+
}, [d, C, u.isClosePausedRef, K]), n.useEffect(() => (D(), () => k()), [D, k]);
|
|
249
|
+
const Z = n.useMemo(() => a ? ve(a) : null, [a]);
|
|
250
|
+
return u.viewport ? /* @__PURE__ */ z(ne, { children: [
|
|
251
|
+
Z && /* @__PURE__ */ l(
|
|
252
|
+
He,
|
|
253
|
+
{
|
|
254
|
+
__scopeToast: r,
|
|
255
|
+
role: "status",
|
|
256
|
+
"aria-live": t === "foreground" ? "assertive" : "polite",
|
|
257
|
+
"aria-atomic": !0,
|
|
258
|
+
children: Z
|
|
259
|
+
}
|
|
260
|
+
),
|
|
261
|
+
/* @__PURE__ */ l(ke, { scope: r, onClose: I, children: ye.createPortal(
|
|
262
|
+
/* @__PURE__ */ l(J.ItemSlot, { scope: r, children: /* @__PURE__ */ l(
|
|
263
|
+
he,
|
|
264
|
+
{
|
|
265
|
+
asChild: !0,
|
|
266
|
+
onEscapeKeyDown: h(T, () => {
|
|
267
|
+
u.isFocusedToastEscapeKeyDownRef.current || I(), u.isFocusedToastEscapeKeyDownRef.current = !1;
|
|
268
|
+
}),
|
|
269
|
+
children: /* @__PURE__ */ l(
|
|
270
|
+
A.li,
|
|
271
|
+
{
|
|
272
|
+
role: "status",
|
|
273
|
+
"aria-live": "off",
|
|
274
|
+
"aria-atomic": !0,
|
|
275
|
+
tabIndex: 0,
|
|
276
|
+
"data-state": d ? "open" : "closed",
|
|
277
|
+
"data-swipe-direction": u.swipeDirection,
|
|
278
|
+
...S,
|
|
279
|
+
ref: f,
|
|
280
|
+
style: { userSelect: "none", touchAction: "none", ...e.style },
|
|
281
|
+
onKeyDown: h(e.onKeyDown, (s) => {
|
|
282
|
+
s.key === "Escape" && (T?.(s.nativeEvent), s.nativeEvent.defaultPrevented || (u.isFocusedToastEscapeKeyDownRef.current = !0, I()));
|
|
283
|
+
}),
|
|
284
|
+
onPointerDown: h(e.onPointerDown, (s) => {
|
|
285
|
+
s.button === 0 && (m.current = { x: s.clientX, y: s.clientY });
|
|
286
|
+
}),
|
|
287
|
+
onPointerMove: h(e.onPointerMove, (s) => {
|
|
288
|
+
if (!m.current) return;
|
|
289
|
+
const R = s.clientX - m.current.x, b = s.clientY - m.current.y, N = !!P.current, L = ["left", "right"].includes(u.swipeDirection), V = ["left", "up"].includes(u.swipeDirection) ? Math.min : Math.max, we = L ? V(0, R) : 0, Ee = L ? 0 : V(0, b), Y = s.pointerType === "touch" ? 10 : 2, H = { x: we, y: Ee }, ee = { originalEvent: s, delta: H };
|
|
290
|
+
N ? (P.current = H, W(Le, E, ee, {
|
|
291
|
+
discrete: !1
|
|
292
|
+
})) : te(H, u.swipeDirection, Y) ? (P.current = H, W(Ne, x, ee, {
|
|
293
|
+
discrete: !1
|
|
294
|
+
}), s.target.setPointerCapture(s.pointerId)) : (Math.abs(R) > Y || Math.abs(b) > Y) && (m.current = null);
|
|
295
|
+
}),
|
|
296
|
+
onPointerUp: h(e.onPointerUp, (s) => {
|
|
297
|
+
const R = P.current, b = s.target;
|
|
298
|
+
if (b.hasPointerCapture(s.pointerId) && b.releasePointerCapture(s.pointerId), P.current = null, m.current = null, R) {
|
|
299
|
+
const N = s.currentTarget, L = { originalEvent: s, delta: R };
|
|
300
|
+
te(R, u.swipeDirection, u.swipeThreshold) ? W(Oe, g, L, {
|
|
301
|
+
discrete: !0
|
|
302
|
+
}) : W(
|
|
303
|
+
Me,
|
|
304
|
+
F,
|
|
305
|
+
L,
|
|
306
|
+
{
|
|
307
|
+
discrete: !0
|
|
308
|
+
}
|
|
309
|
+
), N.addEventListener("click", (V) => V.preventDefault(), {
|
|
310
|
+
once: !0
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
})
|
|
314
|
+
}
|
|
315
|
+
)
|
|
316
|
+
}
|
|
317
|
+
) }),
|
|
318
|
+
u.viewport
|
|
319
|
+
) })
|
|
320
|
+
] }) : null;
|
|
321
|
+
}
|
|
322
|
+
), He = (e) => {
|
|
323
|
+
const { __scopeToast: o, children: r, ...t } = e, c = X(M, o), [d, p] = n.useState(!1), [T, v] = n.useState(!1);
|
|
324
|
+
return Ye(() => p(!0)), n.useEffect(() => {
|
|
325
|
+
const i = window.setTimeout(() => v(!0), 1e3);
|
|
326
|
+
return () => window.clearTimeout(i);
|
|
327
|
+
}, []), T ? null : /* @__PURE__ */ l(Re, { asChild: !0, children: /* @__PURE__ */ l(re, { ...t, children: d && /* @__PURE__ */ z(ne, { children: [
|
|
328
|
+
c.label,
|
|
329
|
+
" ",
|
|
330
|
+
r
|
|
331
|
+
] }) }) });
|
|
332
|
+
}, We = "ToastTitle", de = n.forwardRef(
|
|
333
|
+
(e, o) => {
|
|
334
|
+
const { __scopeToast: r, ...t } = e;
|
|
335
|
+
return /* @__PURE__ */ l(A.div, { ...t, ref: o });
|
|
336
|
+
}
|
|
337
|
+
);
|
|
338
|
+
de.displayName = We;
|
|
339
|
+
var Ue = "ToastDescription", Xe = n.forwardRef(
|
|
340
|
+
(e, o) => {
|
|
341
|
+
const { __scopeToast: r, ...t } = e;
|
|
342
|
+
return /* @__PURE__ */ l(A.div, { ...t, ref: o });
|
|
343
|
+
}
|
|
344
|
+
);
|
|
345
|
+
Xe.displayName = Ue;
|
|
346
|
+
var pe = "ToastAction", fe = n.forwardRef(
|
|
347
|
+
(e, o) => {
|
|
348
|
+
const { altText: r, ...t } = e;
|
|
349
|
+
return r.trim() ? /* @__PURE__ */ l(Te, { altText: r, asChild: !0, children: /* @__PURE__ */ l(Q, { ...t, ref: o }) }) : (console.error(
|
|
350
|
+
`Invalid prop \`altText\` supplied to \`${pe}\`. Expected non-empty \`string\`.`
|
|
351
|
+
), null);
|
|
352
|
+
}
|
|
353
|
+
);
|
|
354
|
+
fe.displayName = pe;
|
|
355
|
+
var me = "ToastClose", Q = n.forwardRef(
|
|
356
|
+
(e, o) => {
|
|
357
|
+
const { __scopeToast: r, ...t } = e, c = Ke(me, r);
|
|
358
|
+
return /* @__PURE__ */ l(Te, { asChild: !0, children: /* @__PURE__ */ l(
|
|
359
|
+
A.button,
|
|
360
|
+
{
|
|
361
|
+
type: "button",
|
|
362
|
+
...t,
|
|
363
|
+
ref: o,
|
|
364
|
+
onClick: h(e.onClick, c.onClose)
|
|
365
|
+
}
|
|
366
|
+
) });
|
|
367
|
+
}
|
|
368
|
+
);
|
|
369
|
+
Q.displayName = me;
|
|
370
|
+
var Te = n.forwardRef((e, o) => {
|
|
371
|
+
const { __scopeToast: r, altText: t, ...c } = e;
|
|
372
|
+
return /* @__PURE__ */ l(
|
|
373
|
+
A.div,
|
|
374
|
+
{
|
|
375
|
+
"data-radix-toast-announce-exclude": "",
|
|
376
|
+
"data-radix-toast-announce-alt": t || void 0,
|
|
377
|
+
...c,
|
|
378
|
+
ref: o
|
|
379
|
+
}
|
|
380
|
+
);
|
|
381
|
+
});
|
|
382
|
+
function ve(e) {
|
|
383
|
+
const o = [];
|
|
384
|
+
return Array.from(e.childNodes).forEach((t) => {
|
|
385
|
+
if (t.nodeType === t.TEXT_NODE && t.textContent && o.push(t.textContent), $e(t)) {
|
|
386
|
+
const c = t.ariaHidden || t.hidden || t.style.display === "none", d = t.dataset.radixToastAnnounceExclude === "";
|
|
387
|
+
if (!c)
|
|
388
|
+
if (d) {
|
|
389
|
+
const p = t.dataset.radixToastAnnounceAlt;
|
|
390
|
+
p && o.push(p);
|
|
391
|
+
} else
|
|
392
|
+
o.push(...ve(t));
|
|
393
|
+
}
|
|
394
|
+
}), o;
|
|
395
|
+
}
|
|
396
|
+
function W(e, o, r, { discrete: t }) {
|
|
397
|
+
const c = r.originalEvent.currentTarget, d = new CustomEvent(e, { bubbles: !0, cancelable: !0, detail: r });
|
|
398
|
+
o && c.addEventListener(e, o, { once: !0 }), t ? ge(c, d) : c.dispatchEvent(d);
|
|
399
|
+
}
|
|
400
|
+
var te = (e, o, r = 0) => {
|
|
401
|
+
const t = Math.abs(e.x), c = Math.abs(e.y), d = t > c;
|
|
402
|
+
return o === "left" || o === "right" ? d && t > r : !d && c > r;
|
|
403
|
+
};
|
|
404
|
+
function Ye(e = () => {
|
|
405
|
+
}) {
|
|
406
|
+
const o = U(e);
|
|
407
|
+
Ie(() => {
|
|
408
|
+
let r = 0, t = 0;
|
|
409
|
+
return r = window.requestAnimationFrame(() => t = window.requestAnimationFrame(o)), () => {
|
|
410
|
+
window.cancelAnimationFrame(r), window.cancelAnimationFrame(t);
|
|
411
|
+
};
|
|
412
|
+
}, [o]);
|
|
413
|
+
}
|
|
414
|
+
function $e(e) {
|
|
415
|
+
return e.nodeType === e.ELEMENT_NODE;
|
|
416
|
+
}
|
|
417
|
+
function Be(e) {
|
|
418
|
+
const o = [], r = document.createTreeWalker(e, NodeFilter.SHOW_ELEMENT, {
|
|
419
|
+
acceptNode: (t) => {
|
|
420
|
+
const c = t.tagName === "INPUT" && t.type === "hidden";
|
|
421
|
+
return t.disabled || t.hidden || c ? NodeFilter.FILTER_SKIP : t.tabIndex >= 0 ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
|
|
422
|
+
}
|
|
423
|
+
});
|
|
424
|
+
for (; r.nextNode(); ) o.push(r.currentNode);
|
|
425
|
+
return o;
|
|
426
|
+
}
|
|
427
|
+
function $(e) {
|
|
428
|
+
const o = document.activeElement;
|
|
429
|
+
return e.some((r) => r === o ? !0 : (r.focus(), document.activeElement !== o));
|
|
430
|
+
}
|
|
431
|
+
var it = ae, ct = ce, ut = le, lt = de, dt = fe, pt = Q;
|
|
432
|
+
export {
|
|
433
|
+
dt as Action,
|
|
434
|
+
pt as Close,
|
|
435
|
+
it as Provider,
|
|
436
|
+
ut as Root,
|
|
437
|
+
lt as Title,
|
|
438
|
+
le as Toast,
|
|
439
|
+
fe as ToastAction,
|
|
440
|
+
Q as ToastClose,
|
|
441
|
+
Xe as ToastDescription,
|
|
442
|
+
ae as ToastProvider,
|
|
443
|
+
de as ToastTitle,
|
|
444
|
+
ce as ToastViewport,
|
|
445
|
+
ct as Viewport,
|
|
446
|
+
at as createToastScope
|
|
447
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import r from "react";
|
|
2
|
+
import { createContextScope as y } from "../../react-context/dist/index.js";
|
|
3
|
+
import { useComposedRefs as M } from "../../react-compose-refs/dist/index.js";
|
|
4
|
+
import { createSlot as x } from "../../react-slot/dist/index.js";
|
|
5
|
+
import { jsx as u } from "react/jsx-runtime";
|
|
6
|
+
function g(s) {
|
|
7
|
+
const m = s + "CollectionProvider", [A, N] = y(m), [_, f] = A(
|
|
8
|
+
m,
|
|
9
|
+
{ collectionRef: { current: null }, itemMap: /* @__PURE__ */ new Map() }
|
|
10
|
+
), p = (c) => {
|
|
11
|
+
const { scope: e, children: l } = c, o = r.useRef(null), t = r.useRef(/* @__PURE__ */ new Map()).current;
|
|
12
|
+
return /* @__PURE__ */ u(_, { scope: e, itemMap: t, collectionRef: o, children: l });
|
|
13
|
+
};
|
|
14
|
+
p.displayName = m;
|
|
15
|
+
const a = s + "CollectionSlot", E = x(a), C = r.forwardRef(
|
|
16
|
+
(c, e) => {
|
|
17
|
+
const { scope: l, children: o } = c, t = f(a, l), n = M(e, t.collectionRef);
|
|
18
|
+
return /* @__PURE__ */ u(E, { ref: n, children: o });
|
|
19
|
+
}
|
|
20
|
+
);
|
|
21
|
+
C.displayName = a;
|
|
22
|
+
const d = s + "CollectionItemSlot", R = "data-radix-collection-item", T = x(d), I = r.forwardRef(
|
|
23
|
+
(c, e) => {
|
|
24
|
+
const { scope: l, children: o, ...t } = c, n = r.useRef(null), S = M(e, n), i = f(d, l);
|
|
25
|
+
return r.useEffect(() => (i.itemMap.set(n, { ref: n, ...t }), () => void i.itemMap.delete(n))), /* @__PURE__ */ u(T, { [R]: "", ref: S, children: o });
|
|
26
|
+
}
|
|
27
|
+
);
|
|
28
|
+
I.displayName = d;
|
|
29
|
+
function O(c) {
|
|
30
|
+
const e = f(s + "CollectionConsumer", c);
|
|
31
|
+
return r.useCallback(() => {
|
|
32
|
+
const o = e.collectionRef.current;
|
|
33
|
+
if (!o) return [];
|
|
34
|
+
const t = Array.from(o.querySelectorAll(`[${R}]`));
|
|
35
|
+
return Array.from(e.itemMap.values()).sort(
|
|
36
|
+
(i, v) => t.indexOf(i.ref.current) - t.indexOf(v.ref.current)
|
|
37
|
+
);
|
|
38
|
+
}, [e.collectionRef, e.itemMap]);
|
|
39
|
+
}
|
|
40
|
+
return [
|
|
41
|
+
{ Provider: p, Slot: C, ItemSlot: I },
|
|
42
|
+
O,
|
|
43
|
+
N
|
|
44
|
+
];
|
|
45
|
+
}
|
|
46
|
+
export {
|
|
47
|
+
g as createCollection
|
|
48
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import * as f from "react";
|
|
2
|
+
function l(n, o) {
|
|
3
|
+
if (typeof n == "function")
|
|
4
|
+
return n(o);
|
|
5
|
+
n != null && (n.current = o);
|
|
6
|
+
}
|
|
7
|
+
function i(...n) {
|
|
8
|
+
return (o) => {
|
|
9
|
+
let u = !1;
|
|
10
|
+
const c = n.map((t) => {
|
|
11
|
+
const e = l(t, o);
|
|
12
|
+
return !u && typeof e == "function" && (u = !0), e;
|
|
13
|
+
});
|
|
14
|
+
if (u)
|
|
15
|
+
return () => {
|
|
16
|
+
for (let t = 0; t < c.length; t++) {
|
|
17
|
+
const e = c[t];
|
|
18
|
+
typeof e == "function" ? e() : l(n[t], null);
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
function s(...n) {
|
|
24
|
+
return f.useCallback(i(...n), n);
|
|
25
|
+
}
|
|
26
|
+
export {
|
|
27
|
+
i as composeRefs,
|
|
28
|
+
s as useComposedRefs
|
|
29
|
+
};
|
package/dist/node_modules/@radix-ui/react-toast/node_modules/@radix-ui/react-context/dist/index.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import * as u from "react";
|
|
2
|
+
import { jsx as _ } from "react/jsx-runtime";
|
|
3
|
+
function P(e, p = []) {
|
|
4
|
+
let n = [];
|
|
5
|
+
function m(s, t) {
|
|
6
|
+
const o = u.createContext(t), c = n.length;
|
|
7
|
+
n = [...n, t];
|
|
8
|
+
const a = (i) => {
|
|
9
|
+
const { scope: f, children: C, ...x } = i, d = f?.[e]?.[c] || o, v = u.useMemo(() => x, Object.values(x));
|
|
10
|
+
return /* @__PURE__ */ _(d.Provider, { value: v, children: C });
|
|
11
|
+
};
|
|
12
|
+
a.displayName = s + "Provider";
|
|
13
|
+
function S(i, f) {
|
|
14
|
+
const C = f?.[e]?.[c] || o, x = u.useContext(C);
|
|
15
|
+
if (x) return x;
|
|
16
|
+
if (t !== void 0) return t;
|
|
17
|
+
throw new Error(`\`${i}\` must be used within \`${s}\``);
|
|
18
|
+
}
|
|
19
|
+
return [a, S];
|
|
20
|
+
}
|
|
21
|
+
const r = () => {
|
|
22
|
+
const s = n.map((t) => u.createContext(t));
|
|
23
|
+
return function(o) {
|
|
24
|
+
const c = o?.[e] || s;
|
|
25
|
+
return u.useMemo(
|
|
26
|
+
() => ({ [`__scope${e}`]: { ...o, [e]: c } }),
|
|
27
|
+
[o, c]
|
|
28
|
+
);
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
return r.scopeName = e, [m, h(r, ...p)];
|
|
32
|
+
}
|
|
33
|
+
function h(...e) {
|
|
34
|
+
const p = e[0];
|
|
35
|
+
if (e.length === 1) return p;
|
|
36
|
+
const n = () => {
|
|
37
|
+
const m = e.map((r) => ({
|
|
38
|
+
useScope: r(),
|
|
39
|
+
scopeName: r.scopeName
|
|
40
|
+
}));
|
|
41
|
+
return function(s) {
|
|
42
|
+
const t = m.reduce((o, { useScope: c, scopeName: a }) => {
|
|
43
|
+
const i = c(s)[`__scope${a}`];
|
|
44
|
+
return { ...o, ...i };
|
|
45
|
+
}, {});
|
|
46
|
+
return u.useMemo(() => ({ [`__scope${p.scopeName}`]: t }), [t]);
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
return n.scopeName = p.scopeName, n;
|
|
50
|
+
}
|
|
51
|
+
export {
|
|
52
|
+
P as createContextScope
|
|
53
|
+
};
|