kitzo 2.4.0 → 2.5.1
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/fns.js +2 -2
- package/dist/functions/copy/{copy.js → index.js} +7 -7
- package/dist/index.d.ts +14 -12
- package/dist/index.js +13 -13
- package/dist/react/components/toast/Toaster.js +55 -50
- package/dist/react/components/toast/partials/Toast.js +45 -44
- package/dist/react/components/toast/partials/ToastContainer.js +32 -29
- package/dist/react/components/toast/{helpers → service}/addToastStyles.js +46 -27
- package/dist/react/components/toast/service/manageToasts/swipeClose.js +71 -0
- package/dist/react/components/toast/{helpers → service}/triggerToasts.js +28 -28
- package/dist/react/components/toast/service/utils.js +6 -0
- package/dist/react/components/tooltip/Tooltip.js +10 -10
- package/dist/react/hooks/useCopy.js +6 -6
- package/dist/react/hooks/useDebounce.js +4 -4
- package/dist/react/hooks/useThrottle.js +2 -2
- package/dist/react/hooks/useWindowSize.js +2 -2
- package/package.json +1 -1
- package/dist/react/components/toast/helpers/manageToasts/swipeClose.js +0 -76
- /package/dist/react/components/toast/{helpers → service}/createToast.js +0 -0
- /package/dist/react/components/toast/{helpers → service}/listenars.js +0 -0
- /package/dist/react/components/toast/{helpers → service}/manageToasts/addToasts.js +0 -0
- /package/dist/react/components/toast/{helpers → service}/manageToasts/dismissToasts.js +0 -0
- /package/dist/react/components/toast/{helpers → service}/manageToasts/manageToasts.js +0 -0
- /package/dist/react/components/toast/{helpers → service}/manageToasts/timers.js +0 -0
- /package/dist/react/components/toast/{helpers → service}/manageToasts/updateToasts.js +0 -0
package/dist/fns.js
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
function
|
|
1
|
+
function o(e) {
|
|
2
2
|
const t = document.createElement("textarea");
|
|
3
3
|
t.value = e, document.body.appendChild(t), t.select(), document.execCommand("copy"), document.body.removeChild(t);
|
|
4
4
|
}
|
|
5
|
-
async function
|
|
5
|
+
async function r(e) {
|
|
6
6
|
if (!navigator.clipboard?.writeText) {
|
|
7
|
-
|
|
7
|
+
o(e);
|
|
8
8
|
return;
|
|
9
9
|
}
|
|
10
10
|
try {
|
|
11
11
|
await navigator.clipboard.writeText(e);
|
|
12
12
|
} catch (t) {
|
|
13
|
-
|
|
13
|
+
o(e), console.error(t);
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
|
-
async function
|
|
16
|
+
async function a(e) {
|
|
17
17
|
let t;
|
|
18
18
|
try {
|
|
19
19
|
t = typeof e == "string" || typeof e == "number" || typeof e == "boolean" ? String(e) : JSON.stringify(e);
|
|
20
20
|
} catch {
|
|
21
21
|
t = "[Cannot copy circular object]";
|
|
22
22
|
}
|
|
23
|
-
await
|
|
23
|
+
await r(t);
|
|
24
24
|
}
|
|
25
25
|
export {
|
|
26
|
-
|
|
26
|
+
a as copy
|
|
27
27
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -15,10 +15,6 @@ declare type CopyStatus = 'standby' | 'copying' | 'copied' | 'error';
|
|
|
15
15
|
|
|
16
16
|
declare type Options = ToastOptionsWithoutType;
|
|
17
17
|
|
|
18
|
-
declare type Position = 'top' | 'top-start' | 'top-end' | 'right' | 'right-start' | 'right-end' | 'bottom' | 'bottom-start' | 'bottom-end' | 'left' | 'left-start' | 'left-end';
|
|
19
|
-
|
|
20
|
-
declare type Positions = 'top-left' | 'top-center' | 'top-right' | 'bottom-left' | 'bottom-center' | 'bottom-right';
|
|
21
|
-
|
|
22
18
|
declare type PromiseToastFn = <T, E = unknown>(promise: Promise<T>, msgs: PromiseToastMsgs<T, E>, options?: PromiseToastOptions) => Promise<T>;
|
|
23
19
|
|
|
24
20
|
declare type PromiseToastMsgs<T, E = unknown> = {
|
|
@@ -35,16 +31,18 @@ declare type ToastContent = ((dismiss: () => void) => ReactNode) | ReactNode;
|
|
|
35
31
|
|
|
36
32
|
export declare function Toaster(props: ToasterProps): JSX.Element | null;
|
|
37
33
|
|
|
38
|
-
declare type ToasterProps = {
|
|
39
|
-
position?:
|
|
40
|
-
richColors?: boolean;
|
|
41
|
-
animateTransformOrigin?: boolean;
|
|
34
|
+
export declare type ToasterProps = {
|
|
35
|
+
position?: ToastPositions;
|
|
42
36
|
gap?: number | `${number}`;
|
|
43
37
|
edgeOffset?: number | `${number}`;
|
|
44
|
-
|
|
38
|
+
toasterId?: string | number;
|
|
39
|
+
dark?: boolean;
|
|
40
|
+
compact?: boolean;
|
|
41
|
+
richColors?: boolean;
|
|
45
42
|
pauseOnHover?: boolean;
|
|
46
43
|
swipeToClose?: boolean;
|
|
47
|
-
|
|
44
|
+
animateTransformOrigin?: boolean;
|
|
45
|
+
animateScale?: boolean;
|
|
48
46
|
};
|
|
49
47
|
|
|
50
48
|
declare type ToastFn = {
|
|
@@ -64,7 +62,7 @@ declare type ToastOptions = {
|
|
|
64
62
|
duration?: number;
|
|
65
63
|
showIcon?: boolean;
|
|
66
64
|
icon?: ReactNode;
|
|
67
|
-
position?:
|
|
65
|
+
position?: ToastPositions;
|
|
68
66
|
animateTransformOrigin?: boolean;
|
|
69
67
|
id?: string | number;
|
|
70
68
|
type?: ToastType;
|
|
@@ -74,6 +72,8 @@ declare type ToastOptions = {
|
|
|
74
72
|
|
|
75
73
|
declare type ToastOptionsWithoutType = Omit<ToastOptions, 'type'>;
|
|
76
74
|
|
|
75
|
+
export declare type ToastPositions = 'top-left' | 'top-center' | 'top-right' | 'bottom-left' | 'bottom-center' | 'bottom-right';
|
|
76
|
+
|
|
77
77
|
declare type ToastType = 'default' | 'success' | 'warning' | 'error' | 'info' | 'custom' | 'loading';
|
|
78
78
|
|
|
79
79
|
export declare function Tooltip(props: TooltipProps): ReactNode;
|
|
@@ -85,7 +85,7 @@ declare type TooltipCoreProps = {
|
|
|
85
85
|
* content is necessary
|
|
86
86
|
*/
|
|
87
87
|
content: ReactNode;
|
|
88
|
-
position?:
|
|
88
|
+
position?: TooltipPosition;
|
|
89
89
|
offset?: number;
|
|
90
90
|
smartHover?: boolean;
|
|
91
91
|
hideOnTouch?: boolean;
|
|
@@ -94,6 +94,8 @@ declare type TooltipCoreProps = {
|
|
|
94
94
|
isDark?: boolean;
|
|
95
95
|
};
|
|
96
96
|
|
|
97
|
+
export declare type TooltipPosition = 'top' | 'top-start' | 'top-end' | 'right' | 'right-start' | 'right-end' | 'bottom' | 'bottom-start' | 'bottom-end' | 'left' | 'left-start' | 'left-end';
|
|
98
|
+
|
|
97
99
|
declare type TooltipProps = PropsWithChildren<TooltipCoreProps>;
|
|
98
100
|
|
|
99
101
|
declare type UpdateToastOptions = Omit<ToastOptions, 'id'>;
|
package/dist/index.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
1
|
+
import { Toaster as r } from "./react/components/toast/Toaster.js";
|
|
2
|
+
import { Tooltip as p } from "./react/components/tooltip/Tooltip.js";
|
|
3
|
+
import { toast as m } from "./react/components/toast/service/triggerToasts.js";
|
|
4
|
+
import { useCopy as s } from "./react/hooks/useCopy.js";
|
|
5
|
+
import { useDebounce as i } from "./react/hooks/useDebounce.js";
|
|
6
|
+
import { useThrottle as a } from "./react/hooks/useThrottle.js";
|
|
7
|
+
import { useWindowSize as n } from "./react/hooks/useWindowSize.js";
|
|
8
8
|
export {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
r as Toaster,
|
|
10
|
+
p as Tooltip,
|
|
11
|
+
m as toast,
|
|
12
12
|
s as useCopy,
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
i as useDebounce,
|
|
14
|
+
a as useThrottle,
|
|
15
|
+
n as useWindowSize
|
|
16
16
|
};
|
|
@@ -1,37 +1,40 @@
|
|
|
1
|
-
import { jsx as
|
|
1
|
+
import { jsx as i } from "react/jsx-runtime";
|
|
2
2
|
import t from "react";
|
|
3
|
-
import { subscribe as
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import { ToasterContext as
|
|
7
|
-
import { initSwipeToClose as
|
|
8
|
-
|
|
3
|
+
import { subscribe as w } from "./service/listenars.js";
|
|
4
|
+
import z from "./service/manageToasts/manageToasts.js";
|
|
5
|
+
import O from "./partials/ToastContainer.js";
|
|
6
|
+
import { ToasterContext as I } from "./context/ToasterContext.js";
|
|
7
|
+
import { initSwipeToClose as $ } from "./service/manageToasts/swipeClose.js";
|
|
8
|
+
import { clampedValue as h } from "./service/utils.js";
|
|
9
|
+
function F(e) {
|
|
9
10
|
const {
|
|
10
|
-
position:
|
|
11
|
-
|
|
12
|
-
animateTransformOrigin: g = !0,
|
|
13
|
-
gap: s = 8,
|
|
11
|
+
position: b = "top-center",
|
|
12
|
+
gap: r = e?.compact ? 8 : 12,
|
|
14
13
|
edgeOffset: n = 16,
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
dark: c,
|
|
15
|
+
compact: g = !1,
|
|
16
|
+
richColors: u = !1,
|
|
17
|
+
pauseOnHover: k = !0,
|
|
18
|
+
swipeToClose: y = !0,
|
|
19
|
+
animateScale: T = !1,
|
|
20
|
+
animateTransformOrigin: v = !0
|
|
21
|
+
} = e, [x, C] = t.useState(!1);
|
|
19
22
|
t.useEffect(() => {
|
|
20
|
-
|
|
23
|
+
C(!0);
|
|
21
24
|
}, []);
|
|
22
|
-
const [
|
|
25
|
+
const [m, p] = t.useState([]);
|
|
23
26
|
t.useEffect(() => {
|
|
24
|
-
const
|
|
25
|
-
(
|
|
26
|
-
|
|
27
|
-
),
|
|
27
|
+
const o = w(
|
|
28
|
+
(s) => z({ toast: s, setToasts: p }),
|
|
29
|
+
e.toasterId
|
|
30
|
+
), a = $();
|
|
28
31
|
return () => {
|
|
29
|
-
|
|
32
|
+
o(), a();
|
|
30
33
|
};
|
|
31
|
-
}, [
|
|
32
|
-
const f = t.useRef(null),
|
|
34
|
+
}, [e.toasterId]);
|
|
35
|
+
const f = t.useRef(null), l = t.useCallback(() => {
|
|
33
36
|
if (!f.current) return;
|
|
34
|
-
const
|
|
37
|
+
const o = f.current.querySelectorAll("[data-kitzo-toast-container]"), a = {
|
|
35
38
|
"top-left": 0,
|
|
36
39
|
"top-center": 0,
|
|
37
40
|
"top-right": 0,
|
|
@@ -39,18 +42,18 @@ function D(i) {
|
|
|
39
42
|
"bottom-center": 0,
|
|
40
43
|
"bottom-right": 0
|
|
41
44
|
};
|
|
42
|
-
|
|
43
|
-
const d =
|
|
44
|
-
|
|
45
|
-
const
|
|
46
|
-
|
|
45
|
+
o.forEach((s) => {
|
|
46
|
+
const d = s.getAttribute("data-toast-position") || "top-center", N = parseFloat(s.style.getPropertyValue("--toast-height")) || 0;
|
|
47
|
+
s.style.setProperty("--toast-offset-y", `${a[d]}px`);
|
|
48
|
+
const S = isNaN(Number(r)) ? e?.compact ? 8 : 12 : Number(r);
|
|
49
|
+
a[d] += N + h(S, 0, 32);
|
|
47
50
|
});
|
|
48
|
-
}, [
|
|
51
|
+
}, [r, e?.compact]);
|
|
49
52
|
if (t.useLayoutEffect(() => {
|
|
50
|
-
|
|
51
|
-
}, [
|
|
52
|
-
const
|
|
53
|
-
return /* @__PURE__ */
|
|
53
|
+
l();
|
|
54
|
+
}, [m, l]), !x) return null;
|
|
55
|
+
const E = typeof c == "boolean" ? c : window.matchMedia("(prefers-color-scheme: dark)").matches;
|
|
56
|
+
return /* @__PURE__ */ i(
|
|
54
57
|
"div",
|
|
55
58
|
{
|
|
56
59
|
ref: f,
|
|
@@ -60,31 +63,33 @@ function D(i) {
|
|
|
60
63
|
zIndex: 2147483647,
|
|
61
64
|
pointerEvents: "none",
|
|
62
65
|
display: "grid",
|
|
63
|
-
padding: n != null ? `${
|
|
66
|
+
padding: n != null ? `${h(Number(n), 0, 32)}px` : 16
|
|
64
67
|
},
|
|
65
|
-
className: `kitzo-toaster ${
|
|
66
|
-
children: /* @__PURE__ */
|
|
68
|
+
className: `kitzo-toaster ${u ? "kitzo-toaster-rich-colors" : ""} ${E ? "dark kitzo-toaster-dark" : ""}`,
|
|
69
|
+
children: /* @__PURE__ */ i(
|
|
67
70
|
"div",
|
|
68
71
|
{
|
|
69
72
|
style: {
|
|
70
73
|
position: "relative"
|
|
71
74
|
},
|
|
72
|
-
children: /* @__PURE__ */
|
|
73
|
-
|
|
75
|
+
children: /* @__PURE__ */ i(
|
|
76
|
+
I.Provider,
|
|
74
77
|
{
|
|
75
78
|
value: {
|
|
76
|
-
position:
|
|
77
|
-
|
|
78
|
-
isDark: c,
|
|
79
|
-
gap: s,
|
|
79
|
+
position: b,
|
|
80
|
+
gap: r,
|
|
80
81
|
edgeOffset: n,
|
|
81
|
-
|
|
82
|
-
|
|
82
|
+
setToasts: p,
|
|
83
|
+
updateOffsets: l,
|
|
84
|
+
dark: c,
|
|
85
|
+
compact: g,
|
|
86
|
+
richColors: u,
|
|
83
87
|
swipeToClose: y,
|
|
84
|
-
|
|
85
|
-
|
|
88
|
+
pauseOnHover: k,
|
|
89
|
+
animateScale: T,
|
|
90
|
+
animateTransformOrigin: v
|
|
86
91
|
},
|
|
87
|
-
children:
|
|
92
|
+
children: m.map((o) => /* @__PURE__ */ i(O, { t: o }, o.id))
|
|
88
93
|
}
|
|
89
94
|
)
|
|
90
95
|
}
|
|
@@ -93,5 +98,5 @@ function D(i) {
|
|
|
93
98
|
);
|
|
94
99
|
}
|
|
95
100
|
export {
|
|
96
|
-
|
|
101
|
+
F as Toaster
|
|
97
102
|
};
|
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
import { jsxs as x, jsx as t, Fragment as
|
|
2
|
-
import { resumeToast as
|
|
3
|
-
import
|
|
4
|
-
import { InfoSvg as
|
|
5
|
-
import { useToasterContext as
|
|
6
|
-
function
|
|
7
|
-
t:
|
|
8
|
-
position:
|
|
9
|
-
shouldAnimateTransformOrigin:
|
|
10
|
-
swipeToClose:
|
|
1
|
+
import { jsxs as x, jsx as t, Fragment as n } from "react/jsx-runtime";
|
|
2
|
+
import { resumeToast as S, pauseToast as I } from "../service/manageToasts/timers.js";
|
|
3
|
+
import { toast as T } from "../service/triggerToasts.js";
|
|
4
|
+
import { InfoSvg as k, ErrorSvg as w, WarningSvg as E, SuccessSvg as N, LoadingSvg as b } from "./Svgs.js";
|
|
5
|
+
import { useToasterContext as j } from "../context/ToasterContext.js";
|
|
6
|
+
function H({
|
|
7
|
+
t: i,
|
|
8
|
+
position: o,
|
|
9
|
+
shouldAnimateTransformOrigin: l,
|
|
10
|
+
swipeToClose: p
|
|
11
11
|
}) {
|
|
12
|
-
const { pauseOnHover:
|
|
12
|
+
const { pauseOnHover: d, compact: m } = j(), {
|
|
13
13
|
id: e,
|
|
14
|
-
type:
|
|
15
|
-
action:
|
|
16
|
-
content:
|
|
17
|
-
status:
|
|
18
|
-
showIcon:
|
|
14
|
+
type: s,
|
|
15
|
+
action: u,
|
|
16
|
+
content: r,
|
|
17
|
+
status: f,
|
|
18
|
+
showIcon: g,
|
|
19
19
|
icon: a,
|
|
20
|
-
toasterId:
|
|
21
|
-
updateState:
|
|
22
|
-
} =
|
|
23
|
-
loading: /* @__PURE__ */ t(
|
|
24
|
-
success: /* @__PURE__ */ t(
|
|
20
|
+
toasterId: v,
|
|
21
|
+
updateState: h
|
|
22
|
+
} = i, c = {
|
|
23
|
+
loading: /* @__PURE__ */ t(b, {}),
|
|
24
|
+
success: /* @__PURE__ */ t(N, {}),
|
|
25
25
|
warning: /* @__PURE__ */ t(E, {}),
|
|
26
|
-
error: /* @__PURE__ */ t(
|
|
27
|
-
info: /* @__PURE__ */ t(
|
|
26
|
+
error: /* @__PURE__ */ t(w, {}),
|
|
27
|
+
info: /* @__PURE__ */ t(k, {}),
|
|
28
28
|
default: null,
|
|
29
29
|
custom: null
|
|
30
30
|
};
|
|
@@ -36,27 +36,28 @@ function P({
|
|
|
36
36
|
pointerEvents: "all",
|
|
37
37
|
display: "flex",
|
|
38
38
|
alignItems: "center",
|
|
39
|
-
gap: 8
|
|
40
|
-
whiteSpace: "pre-wrap"
|
|
39
|
+
gap: 8
|
|
41
40
|
},
|
|
42
|
-
"data-toaster-id":
|
|
43
|
-
"data-action":
|
|
44
|
-
"data-status":
|
|
45
|
-
"data-type":
|
|
46
|
-
"data-position":
|
|
47
|
-
"data-screen-x":
|
|
48
|
-
"data-screen-y":
|
|
41
|
+
"data-toaster-id": v,
|
|
42
|
+
"data-action": u,
|
|
43
|
+
"data-status": f,
|
|
44
|
+
"data-type": s,
|
|
45
|
+
"data-position": o,
|
|
46
|
+
"data-screen-x": o.split("-")[1],
|
|
47
|
+
"data-screen-y": o.split("-")[0],
|
|
49
48
|
"data-exit": "auto",
|
|
50
|
-
"data-swipeable":
|
|
51
|
-
"data-animate-transform-origin":
|
|
52
|
-
"data-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
49
|
+
"data-swipeable": p,
|
|
50
|
+
"data-animate-transform-origin": l,
|
|
51
|
+
"data-compact": m,
|
|
52
|
+
"data-update-state": h,
|
|
53
|
+
"data-pause-on-hover": d,
|
|
54
|
+
onPointerEnter: (y) => {
|
|
55
|
+
d && y.pointerType === "mouse" && I(e);
|
|
56
|
+
},
|
|
57
|
+
onPointerLeave: () => S(e),
|
|
58
|
+
className: "kitzo-toast",
|
|
58
59
|
children: [
|
|
59
|
-
|
|
60
|
+
g && /* @__PURE__ */ t(n, { children: a ? /* @__PURE__ */ t(n, { children: typeof a == "string" || typeof a == "number" ? /* @__PURE__ */ t(
|
|
60
61
|
"div",
|
|
61
62
|
{
|
|
62
63
|
style: {
|
|
@@ -65,14 +66,14 @@ function P({
|
|
|
65
66
|
className: "svg-container",
|
|
66
67
|
children: a
|
|
67
68
|
}
|
|
68
|
-
) : /* @__PURE__ */ t(
|
|
69
|
+
) : /* @__PURE__ */ t(n, { children: a }) }) : /* @__PURE__ */ t(n, { children: c[s] && /* @__PURE__ */ t("div", { style: { flexShrink: 0 }, className: "svg-container", children: c[s] }) }) }),
|
|
69
70
|
/* @__PURE__ */ t(
|
|
70
71
|
"div",
|
|
71
72
|
{
|
|
72
73
|
style: {
|
|
73
74
|
flex: 1
|
|
74
75
|
},
|
|
75
|
-
children: typeof
|
|
76
|
+
children: typeof r == "function" ? r(() => T.dismiss(e, i.toasterId)) : r
|
|
76
77
|
}
|
|
77
78
|
)
|
|
78
79
|
]
|
|
@@ -80,5 +81,5 @@ function P({
|
|
|
80
81
|
);
|
|
81
82
|
}
|
|
82
83
|
export {
|
|
83
|
-
|
|
84
|
+
H as default
|
|
84
85
|
};
|
|
@@ -1,61 +1,64 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useRef as
|
|
3
|
-
import
|
|
4
|
-
import { useToasterContext as
|
|
5
|
-
function
|
|
1
|
+
import { jsx as c } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as g, useLayoutEffect as h } from "react";
|
|
3
|
+
import x from "./Toast.js";
|
|
4
|
+
import { useToasterContext as y } from "../context/ToasterContext.js";
|
|
5
|
+
function z({ t }) {
|
|
6
6
|
const {
|
|
7
|
-
updateOffsets:
|
|
7
|
+
updateOffsets: n,
|
|
8
8
|
position: f,
|
|
9
|
-
|
|
9
|
+
animateScale: i,
|
|
10
|
+
animateTransformOrigin: m,
|
|
10
11
|
swipeToClose: p
|
|
11
|
-
} =
|
|
12
|
-
|
|
13
|
-
const e =
|
|
12
|
+
} = y(), r = g(null);
|
|
13
|
+
h(() => {
|
|
14
|
+
const e = r.current;
|
|
14
15
|
if (!e) return;
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
e.style.setProperty("--toast-height", `${
|
|
16
|
+
const l = new ResizeObserver(() => {
|
|
17
|
+
const b = e.offsetHeight;
|
|
18
|
+
e.style.setProperty("--toast-height", `${b}px`), n();
|
|
18
19
|
});
|
|
19
|
-
return
|
|
20
|
-
}, [
|
|
21
|
-
const
|
|
20
|
+
return l.observe(e), () => l.disconnect();
|
|
21
|
+
}, [n]);
|
|
22
|
+
const u = [
|
|
22
23
|
"top-left",
|
|
23
24
|
"top-center",
|
|
24
25
|
"top-right",
|
|
25
26
|
"bottom-left",
|
|
26
27
|
"bottom-center",
|
|
27
28
|
"bottom-right"
|
|
28
|
-
],
|
|
29
|
-
return /* @__PURE__ */
|
|
29
|
+
], a = t.position || f, o = u.includes(a) ? a : "top-center", s = o?.includes("bottom"), d = typeof t.animateTransformOrigin == "boolean" ? t.animateTransformOrigin : !!m, T = typeof t.swipeToClose == "boolean" ? t.swipeToClose : !!p;
|
|
30
|
+
return /* @__PURE__ */ c(
|
|
30
31
|
"div",
|
|
31
32
|
{
|
|
32
|
-
ref:
|
|
33
|
-
"data-toast-container": !0,
|
|
33
|
+
ref: r,
|
|
34
|
+
"data-kitzo-toast-container": !0,
|
|
34
35
|
"data-toast-position": o,
|
|
36
|
+
"data-animate-scale": i,
|
|
37
|
+
className: "kitzo-toast-container",
|
|
35
38
|
style: {
|
|
36
39
|
position: "absolute",
|
|
37
40
|
zIndex: t.zIndex,
|
|
38
41
|
left: 0,
|
|
39
42
|
right: 0,
|
|
40
|
-
transition:
|
|
43
|
+
transition: `transform ${i ? "220ms" : "280ms"}`,
|
|
41
44
|
display: "flex",
|
|
42
45
|
justifyContent: o?.includes("left") ? "flex-start" : o?.includes("center") ? "center" : "flex-end",
|
|
43
|
-
top:
|
|
44
|
-
bottom:
|
|
45
|
-
transform: `translateY(calc(var(--toast-offset-y, 0px) * ${
|
|
46
|
+
top: s ? "auto" : 0,
|
|
47
|
+
bottom: s ? 0 : "auto",
|
|
48
|
+
transform: `translateY(calc(var(--toast-offset-y, 0px) * ${s ? -1 : 1}))`
|
|
46
49
|
},
|
|
47
|
-
children: /* @__PURE__ */
|
|
48
|
-
|
|
50
|
+
children: /* @__PURE__ */ c(
|
|
51
|
+
x,
|
|
49
52
|
{
|
|
50
53
|
t,
|
|
51
54
|
position: o,
|
|
52
|
-
shouldAnimateTransformOrigin:
|
|
53
|
-
swipeToClose:
|
|
55
|
+
shouldAnimateTransformOrigin: d,
|
|
56
|
+
swipeToClose: T
|
|
54
57
|
}
|
|
55
58
|
)
|
|
56
59
|
}
|
|
57
60
|
);
|
|
58
61
|
}
|
|
59
62
|
export {
|
|
60
|
-
|
|
63
|
+
z as default
|
|
61
64
|
};
|
|
@@ -85,13 +85,15 @@ const a = `.kitzo-toaster {
|
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
.kitzo-toast {
|
|
88
|
-
font-family: inherit;
|
|
89
|
-
font-size: 0.875rem;
|
|
90
88
|
transition:
|
|
91
89
|
transform 280ms,
|
|
92
90
|
opacity 280ms;
|
|
93
91
|
will-change: transform, opacity;
|
|
94
92
|
touch-action: pan-y;
|
|
93
|
+
|
|
94
|
+
font-family: inherit;
|
|
95
|
+
font-size: 0.875rem;
|
|
96
|
+
white-space: pre-wrap;
|
|
95
97
|
}
|
|
96
98
|
|
|
97
99
|
.kitzo-toast.is-swiping {
|
|
@@ -140,25 +142,41 @@ const a = `.kitzo-toaster {
|
|
|
140
142
|
.kitzo-toast[data-type='warning'],
|
|
141
143
|
.kitzo-toast[data-type='error'],
|
|
142
144
|
.kitzo-toast[data-type='info'] {
|
|
143
|
-
border-radius: 0.
|
|
145
|
+
border-radius: 0.5525rem;
|
|
144
146
|
padding: 0.375rem 0.625rem;
|
|
145
147
|
box-shadow: 0 3px 8px -3px hsl(0, 0%, 0%, 0.15);
|
|
146
148
|
}
|
|
147
149
|
|
|
150
|
+
/*! toast size */
|
|
151
|
+
.kitzo-toast[data-compact='false']:not([data-type='custom']) {
|
|
152
|
+
flex: 1;
|
|
153
|
+
min-height: 40px;
|
|
154
|
+
|
|
155
|
+
@media (width > 380px) {
|
|
156
|
+
max-width: 250px;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
148
160
|
/*! toast transition styles */
|
|
149
161
|
.kitzo-toast {
|
|
150
162
|
--swipe-x: 0px;
|
|
151
163
|
--motion-y: 0%;
|
|
152
|
-
--scale:
|
|
164
|
+
--scale: 1;
|
|
153
165
|
--exit-x: 0px;
|
|
154
166
|
}
|
|
155
167
|
|
|
168
|
+
.kitzo-toast-container[data-animate-scale='true'] {
|
|
169
|
+
.kitzo-toast {
|
|
170
|
+
--scale: 0.6;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
156
174
|
.kitzo-toast[data-screen-y='top'] {
|
|
157
|
-
--motion-y: -
|
|
175
|
+
--motion-y: -100%;
|
|
158
176
|
}
|
|
159
177
|
|
|
160
178
|
.kitzo-toast[data-screen-y='bottom'] {
|
|
161
|
-
--motion-y:
|
|
179
|
+
--motion-y: 100%;
|
|
162
180
|
}
|
|
163
181
|
|
|
164
182
|
.kitzo-toast[data-status='leaving'][data-exit='swipe'] {
|
|
@@ -183,10 +201,10 @@ const a = `.kitzo-toaster {
|
|
|
183
201
|
}
|
|
184
202
|
|
|
185
203
|
.kitzo-toast[data-update-state='updated'] {
|
|
186
|
-
animation: update
|
|
204
|
+
animation: update 280ms ease;
|
|
187
205
|
}
|
|
188
206
|
.kitzo-toast[data-update-state='updated-again'] {
|
|
189
|
-
animation: update-again
|
|
207
|
+
animation: update-again 280ms ease;
|
|
190
208
|
}
|
|
191
209
|
|
|
192
210
|
@keyframes update {
|
|
@@ -210,31 +228,32 @@ const a = `.kitzo-toaster {
|
|
|
210
228
|
}
|
|
211
229
|
}
|
|
212
230
|
|
|
213
|
-
/*! toast
|
|
231
|
+
/*! toast transform origin */
|
|
214
232
|
.kitzo-toast[data-position^='top'] {
|
|
215
233
|
transform-origin: top;
|
|
216
234
|
}
|
|
217
235
|
.kitzo-toast[data-position^='bottom'] {
|
|
218
236
|
transform-origin: bottom;
|
|
219
237
|
}
|
|
220
|
-
|
|
221
|
-
.kitzo-toast[data-animate-transform-origin='true'][data-position='top-left'] {
|
|
222
|
-
|
|
223
|
-
}
|
|
224
|
-
.kitzo-toast[data-animate-transform-origin='true'][data-position='top-center'] {
|
|
225
|
-
|
|
226
|
-
}
|
|
227
|
-
.kitzo-toast[data-animate-transform-origin='true'][data-position='top-right'] {
|
|
228
|
-
|
|
229
|
-
}
|
|
230
|
-
.kitzo-toast[data-animate-transform-origin='true'][data-position='bottom-left'] {
|
|
231
|
-
|
|
232
|
-
}
|
|
233
|
-
.kitzo-toast[data-animate-transform-origin='true'][data-position='bottom-center'] {
|
|
234
|
-
|
|
235
|
-
}
|
|
236
|
-
.kitzo-toast[data-animate-transform-origin='true'][data-position='bottom-right'] {
|
|
237
|
-
|
|
238
|
+
@media (width > 380px) {
|
|
239
|
+
.kitzo-toast[data-animate-transform-origin='true'][data-position='top-left'] {
|
|
240
|
+
transform-origin: top left;
|
|
241
|
+
}
|
|
242
|
+
.kitzo-toast[data-animate-transform-origin='true'][data-position='top-center'] {
|
|
243
|
+
transform-origin: top;
|
|
244
|
+
}
|
|
245
|
+
.kitzo-toast[data-animate-transform-origin='true'][data-position='top-right'] {
|
|
246
|
+
transform-origin: top right;
|
|
247
|
+
}
|
|
248
|
+
.kitzo-toast[data-animate-transform-origin='true'][data-position='bottom-left'] {
|
|
249
|
+
transform-origin: bottom left;
|
|
250
|
+
}
|
|
251
|
+
.kitzo-toast[data-animate-transform-origin='true'][data-position='bottom-center'] {
|
|
252
|
+
transform-origin: bottom;
|
|
253
|
+
}
|
|
254
|
+
.kitzo-toast[data-animate-transform-origin='true'][data-position='bottom-right'] {
|
|
255
|
+
transform-origin: bottom right;
|
|
256
|
+
}
|
|
238
257
|
}
|
|
239
258
|
|
|
240
259
|
.kitzo-toast[data-status='leaving'][data-position^='top'] {
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { toast as y } from "../triggerToasts.js";
|
|
2
|
+
import { pauseToast as g, resumeToast as L } from "./timers.js";
|
|
3
|
+
let r = !1, e = null, i = null, h = 0, s = 0, l = !1, u = null;
|
|
4
|
+
const b = 2, P = 65, S = 25;
|
|
5
|
+
function x(t) {
|
|
6
|
+
if (!e) return;
|
|
7
|
+
const n = Math.sign(t) || 1, o = Math.abs(t), c = S * (1 - Math.exp(-o / 400 * 0.75));
|
|
8
|
+
return n * c;
|
|
9
|
+
}
|
|
10
|
+
function E(t) {
|
|
11
|
+
return t ? t.dataset.swipeable === "true" : !1;
|
|
12
|
+
}
|
|
13
|
+
function a(t = !0) {
|
|
14
|
+
if (!e) return;
|
|
15
|
+
if (document.body.style.userSelect = "auto", t && u != null)
|
|
16
|
+
try {
|
|
17
|
+
e.releasePointerCapture(u);
|
|
18
|
+
} catch {
|
|
19
|
+
console.log("Failed to release pointer");
|
|
20
|
+
}
|
|
21
|
+
e.style.setProperty("--swipe-x", "0px"), e.classList.remove("is-swiping");
|
|
22
|
+
const n = e, o = e.id, c = n.dataset.pauseOnHover === "true";
|
|
23
|
+
e = null, i = null, u = null, l = !1, r = !1, s = 0, n && document.body.contains(n) && (n.matches(":hover") && c || L(o));
|
|
24
|
+
}
|
|
25
|
+
function p(t) {
|
|
26
|
+
const o = t.target.closest(".kitzo-toast");
|
|
27
|
+
o && (e = o, i = o.id, h = t.clientX, s = 0, l = !0, r = !1, u = t.pointerId);
|
|
28
|
+
}
|
|
29
|
+
function f(t) {
|
|
30
|
+
if (!l || !e || i == null) return;
|
|
31
|
+
if (s = t.clientX - h, !r && Math.abs(s) > b) {
|
|
32
|
+
r = !0, g(i), e.classList.add("is-swiping");
|
|
33
|
+
try {
|
|
34
|
+
e.setPointerCapture(t.pointerId), document.body.style.userSelect = "none";
|
|
35
|
+
} catch {
|
|
36
|
+
console.error("Failed to capture pointer");
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
if (!r) return;
|
|
40
|
+
const o = E(e) ? s : x(s);
|
|
41
|
+
e.style.setProperty("--swipe-x", `${o}px`);
|
|
42
|
+
}
|
|
43
|
+
function m() {
|
|
44
|
+
if (!l || !e || i == null) {
|
|
45
|
+
a();
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
const t = E(e);
|
|
49
|
+
if (r && t && Math.abs(s) > P) {
|
|
50
|
+
const n = s > 0 ? 1 : -1, o = Math.abs(s) + 220;
|
|
51
|
+
e.style.setProperty("--exit-x", `${n * o}px`), e.dataset.exit = "swipe", y.dismiss(i, e.dataset.toasterId);
|
|
52
|
+
}
|
|
53
|
+
a();
|
|
54
|
+
}
|
|
55
|
+
function v() {
|
|
56
|
+
a();
|
|
57
|
+
}
|
|
58
|
+
function w() {
|
|
59
|
+
l && a();
|
|
60
|
+
}
|
|
61
|
+
let d = !1;
|
|
62
|
+
function C() {
|
|
63
|
+
return d ? () => {
|
|
64
|
+
} : (d = !0, document.addEventListener("pointerdown", p), document.addEventListener("pointermove", f), document.addEventListener("pointerup", m), document.addEventListener("pointercancel", v), window.addEventListener("blur", w), () => {
|
|
65
|
+
a(), d = !1, document.removeEventListener("pointerdown", p), document.removeEventListener("pointermove", f), document.removeEventListener("pointerup", m), document.removeEventListener("pointercancel", v), window.removeEventListener("blur", w);
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
export {
|
|
69
|
+
r as dragStarted,
|
|
70
|
+
C as initSwipeToClose
|
|
71
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createToast as n, updateToast as s, genId as c } from "./createToast.js";
|
|
2
|
-
import { notify as
|
|
3
|
-
const
|
|
4
|
-
r != null &&
|
|
2
|
+
import { notify as e } from "./listenars.js";
|
|
3
|
+
const i = (r, t) => {
|
|
4
|
+
r != null && e(
|
|
5
5
|
n({
|
|
6
6
|
type: "default",
|
|
7
7
|
action: "add",
|
|
@@ -10,15 +10,15 @@ const e = (r, t) => {
|
|
|
10
10
|
})
|
|
11
11
|
);
|
|
12
12
|
};
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
i.dismiss = (r, t) => {
|
|
14
|
+
e({
|
|
15
15
|
action: "dismiss",
|
|
16
16
|
id: r,
|
|
17
17
|
toasterId: t
|
|
18
18
|
});
|
|
19
19
|
};
|
|
20
|
-
|
|
21
|
-
r != null &&
|
|
20
|
+
i.info = (r, t) => {
|
|
21
|
+
r != null && e(
|
|
22
22
|
n({
|
|
23
23
|
action: "add",
|
|
24
24
|
type: "info",
|
|
@@ -27,8 +27,8 @@ e.info = (r, t) => {
|
|
|
27
27
|
})
|
|
28
28
|
);
|
|
29
29
|
};
|
|
30
|
-
|
|
31
|
-
r != null &&
|
|
30
|
+
i.success = (r, t) => {
|
|
31
|
+
r != null && e(
|
|
32
32
|
n({
|
|
33
33
|
action: "add",
|
|
34
34
|
type: "success",
|
|
@@ -37,8 +37,8 @@ e.success = (r, t) => {
|
|
|
37
37
|
})
|
|
38
38
|
);
|
|
39
39
|
};
|
|
40
|
-
|
|
41
|
-
r != null &&
|
|
40
|
+
i.warning = (r, t) => {
|
|
41
|
+
r != null && e(
|
|
42
42
|
n({
|
|
43
43
|
action: "add",
|
|
44
44
|
type: "warning",
|
|
@@ -47,8 +47,8 @@ e.warning = (r, t) => {
|
|
|
47
47
|
})
|
|
48
48
|
);
|
|
49
49
|
};
|
|
50
|
-
|
|
51
|
-
r != null &&
|
|
50
|
+
i.error = (r, t) => {
|
|
51
|
+
r != null && e(
|
|
52
52
|
n({
|
|
53
53
|
action: "add",
|
|
54
54
|
type: "error",
|
|
@@ -57,8 +57,8 @@ e.error = (r, t) => {
|
|
|
57
57
|
})
|
|
58
58
|
);
|
|
59
59
|
};
|
|
60
|
-
|
|
61
|
-
r != null &&
|
|
60
|
+
i.loading = (r, t) => {
|
|
61
|
+
r != null && e(
|
|
62
62
|
n({
|
|
63
63
|
action: "add",
|
|
64
64
|
type: "loading",
|
|
@@ -67,8 +67,8 @@ e.loading = (r, t) => {
|
|
|
67
67
|
})
|
|
68
68
|
);
|
|
69
69
|
};
|
|
70
|
-
|
|
71
|
-
r != null &&
|
|
70
|
+
i.custom = (r, t) => {
|
|
71
|
+
r != null && e(
|
|
72
72
|
n({
|
|
73
73
|
action: "add",
|
|
74
74
|
type: "custom",
|
|
@@ -77,27 +77,27 @@ e.custom = (r, t) => {
|
|
|
77
77
|
})
|
|
78
78
|
);
|
|
79
79
|
};
|
|
80
|
-
|
|
81
|
-
r != null && t != null &&
|
|
80
|
+
i.update = (r, t, o) => {
|
|
81
|
+
r != null && t != null && e(s({ id: `${r}`, content: t, options: o }));
|
|
82
82
|
};
|
|
83
|
-
|
|
83
|
+
i.promise = (async (r, t, o) => {
|
|
84
84
|
const u = c();
|
|
85
|
-
|
|
85
|
+
e(
|
|
86
86
|
n({
|
|
87
87
|
action: "add",
|
|
88
88
|
type: "loading",
|
|
89
89
|
content: t.loading,
|
|
90
|
-
options: { ...
|
|
90
|
+
options: { ...o, id: u, duration: 1 / 0, swipeToClose: !1 }
|
|
91
91
|
})
|
|
92
92
|
);
|
|
93
93
|
try {
|
|
94
|
-
const
|
|
95
|
-
return
|
|
96
|
-
} catch (
|
|
97
|
-
const d = typeof t.error == "function" ? await t.error(
|
|
98
|
-
throw
|
|
94
|
+
const a = await r, d = typeof t.success == "function" ? await t.success(a) : t.success;
|
|
95
|
+
return i.update(u, d, { ...o, type: "success" }), a;
|
|
96
|
+
} catch (a) {
|
|
97
|
+
const d = typeof t.error == "function" ? await t.error(a) : t.error;
|
|
98
|
+
throw i.update(u, d, { ...o, type: "error" }), a;
|
|
99
99
|
}
|
|
100
100
|
});
|
|
101
101
|
export {
|
|
102
|
-
|
|
102
|
+
i as toast
|
|
103
103
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as a, Fragment as r, jsxs as T } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
2
|
+
import d from "react";
|
|
3
3
|
import v from "./helpers/addTooltipStyles.js";
|
|
4
4
|
import w from "./helpers/getPositionClass.js";
|
|
5
5
|
import O from "./partials/TooltipWrapper.js";
|
|
@@ -11,24 +11,24 @@ function C(h) {
|
|
|
11
11
|
position: y = "top",
|
|
12
12
|
animation: i = !0,
|
|
13
13
|
isHidden: s = !1,
|
|
14
|
-
offset:
|
|
15
|
-
smartHover:
|
|
14
|
+
offset: m = 8,
|
|
15
|
+
smartHover: f = !0,
|
|
16
16
|
hideOnTouch: l = !0,
|
|
17
17
|
isDark: u
|
|
18
|
-
} = h, [D, b] =
|
|
19
|
-
if (
|
|
18
|
+
} = h, [D, b] = d.useState(!1);
|
|
19
|
+
if (d.useEffect(() => {
|
|
20
20
|
b(!0), v();
|
|
21
21
|
}, []), !D) return /* @__PURE__ */ a(r, { children: t });
|
|
22
22
|
if (typeof s == "boolean" && s) return /* @__PURE__ */ a(r, { children: t });
|
|
23
23
|
if (n == null)
|
|
24
24
|
return /* @__PURE__ */ a(r, { children: t });
|
|
25
25
|
const o = {
|
|
26
|
-
offset: isNaN(Number(
|
|
27
|
-
smartHover: typeof
|
|
26
|
+
offset: isNaN(Number(m)) ? 8 : Number(m),
|
|
27
|
+
smartHover: typeof f == "boolean" ? f : !0,
|
|
28
28
|
hideOnTouch: typeof l == "boolean" ? l : !0
|
|
29
29
|
};
|
|
30
|
-
let p = !1,
|
|
31
|
-
if (typeof window < "u" && (
|
|
30
|
+
let p = !1, c = !1;
|
|
31
|
+
if (typeof window < "u" && (c = window.matchMedia("(pointer: coarse)").matches || navigator.maxTouchPoints > 0, p = typeof u == "boolean" ? u : window.matchMedia("(prefers-color-scheme: dark)").matches), c && o.hideOnTouch) return t;
|
|
32
32
|
const x = w(y), M = !!i, e = k(
|
|
33
33
|
i === !0 ? {} : i
|
|
34
34
|
);
|
|
@@ -63,5 +63,5 @@ function C(h) {
|
|
|
63
63
|
);
|
|
64
64
|
}
|
|
65
65
|
export {
|
|
66
|
-
C as
|
|
66
|
+
C as Tooltip
|
|
67
67
|
};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { useState as u, useRef as i, useCallback as
|
|
2
|
-
import m from "../../functions/copy/
|
|
1
|
+
import { useState as u, useRef as i, useCallback as l, useEffect as p } from "react";
|
|
2
|
+
import { copy as m } from "../../functions/copy/index.js";
|
|
3
3
|
function E(c = 1500) {
|
|
4
|
-
const [r, e] = u("standby"), [a, s] = u(null), t = i(null), n = i(!1), f =
|
|
5
|
-
async (
|
|
4
|
+
const [r, e] = u("standby"), [a, s] = u(null), t = i(null), n = i(!1), f = l(
|
|
5
|
+
async (y) => {
|
|
6
6
|
if (!n.current) {
|
|
7
7
|
t.current && clearTimeout(t.current);
|
|
8
8
|
try {
|
|
9
|
-
n.current = !0, s(null), e("copying"), await m(
|
|
9
|
+
n.current = !0, s(null), e("copying"), await m(y), e("copied");
|
|
10
10
|
} catch (o) {
|
|
11
11
|
s(o instanceof Error ? o : new Error(String(o))), e("error");
|
|
12
12
|
} finally {
|
|
@@ -34,5 +34,5 @@ function E(c = 1500) {
|
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
36
|
export {
|
|
37
|
-
E as
|
|
37
|
+
E as useCopy
|
|
38
38
|
};
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { useState as r, useEffect as c } from "react";
|
|
2
2
|
function f(e, t) {
|
|
3
3
|
t ??= 500;
|
|
4
|
-
const [
|
|
4
|
+
const [o, u] = r(e);
|
|
5
5
|
return c(() => {
|
|
6
6
|
const n = setTimeout(() => {
|
|
7
|
-
|
|
7
|
+
u(e);
|
|
8
8
|
}, t);
|
|
9
9
|
return () => {
|
|
10
10
|
clearTimeout(n);
|
|
11
11
|
};
|
|
12
|
-
}, [e, t]),
|
|
12
|
+
}, [e, t]), o;
|
|
13
13
|
}
|
|
14
14
|
export {
|
|
15
|
-
f as
|
|
15
|
+
f as useDebounce
|
|
16
16
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useState as c, useRef as f, useEffect as i } from "react";
|
|
2
|
-
function
|
|
2
|
+
function l(t, e = 500) {
|
|
3
3
|
const [n, u] = c(t), r = f(0);
|
|
4
4
|
return i(() => {
|
|
5
5
|
function s() {
|
|
@@ -10,5 +10,5 @@ function a(t, e = 500) {
|
|
|
10
10
|
}, [t, e]), n;
|
|
11
11
|
}
|
|
12
12
|
export {
|
|
13
|
-
|
|
13
|
+
l as useThrottle
|
|
14
14
|
};
|
package/package.json
CHANGED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import b from "../triggerToasts.js";
|
|
2
|
-
let s = !1, e = null, c = null, m = 0, r = 0, a = !1, l = null;
|
|
3
|
-
const L = 2, y = 65, S = 20, g = 100;
|
|
4
|
-
function x(t) {
|
|
5
|
-
const o = Math.sign(t) || 1, n = Math.abs(t), h = S * (1 - Math.exp(-n / g));
|
|
6
|
-
return o * h;
|
|
7
|
-
}
|
|
8
|
-
function E(t) {
|
|
9
|
-
return t ? t.dataset.swipeable === "true" : !1;
|
|
10
|
-
}
|
|
11
|
-
function i(t = !0) {
|
|
12
|
-
if (!e) return;
|
|
13
|
-
if (document.body.style.userSelect = "auto", t && l != null)
|
|
14
|
-
try {
|
|
15
|
-
e.releasePointerCapture(l);
|
|
16
|
-
} catch {
|
|
17
|
-
console.error("");
|
|
18
|
-
}
|
|
19
|
-
e.style.setProperty("--swipe-x", "0px"), e.classList.remove("is-swiping");
|
|
20
|
-
const o = e;
|
|
21
|
-
if (e = null, c = null, l = null, a = !1, s = !1, r = 0, !o.matches(":hover")) {
|
|
22
|
-
const n = new MouseEvent("mouseleave", {
|
|
23
|
-
bubbles: !0,
|
|
24
|
-
cancelable: !0,
|
|
25
|
-
view: window
|
|
26
|
-
});
|
|
27
|
-
o.dispatchEvent(n);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
function d(t) {
|
|
31
|
-
const n = t.target.closest(".kitzo-toast");
|
|
32
|
-
n && (e = n, c = n.id, m = t.clientX, r = 0, a = !0, s = !1, l = t.pointerId);
|
|
33
|
-
}
|
|
34
|
-
function p(t) {
|
|
35
|
-
if (!a || !e) return;
|
|
36
|
-
if (r = t.clientX - m, !s && Math.abs(r) > L) {
|
|
37
|
-
s = !0, e.classList.add("is-swiping");
|
|
38
|
-
try {
|
|
39
|
-
e.setPointerCapture(t.pointerId), document.body.style.userSelect = "none";
|
|
40
|
-
} catch {
|
|
41
|
-
console.error("Failed to capture pointer");
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
if (!s) return;
|
|
45
|
-
const n = E(e) ? r : x(r);
|
|
46
|
-
e.style.setProperty("--swipe-x", `${n}px`);
|
|
47
|
-
}
|
|
48
|
-
function f() {
|
|
49
|
-
if (!a || !e || c == null) {
|
|
50
|
-
i();
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
const t = E(e);
|
|
54
|
-
if (s && t && Math.abs(r) > y) {
|
|
55
|
-
const o = r > 0 ? 1 : -1, n = Math.abs(r) + 220;
|
|
56
|
-
e.style.setProperty("--exit-x", `${o * n}px`), e.dataset.exit = "swipe", b.dismiss(c, e.dataset.toasterId);
|
|
57
|
-
}
|
|
58
|
-
i();
|
|
59
|
-
}
|
|
60
|
-
function v() {
|
|
61
|
-
i();
|
|
62
|
-
}
|
|
63
|
-
function w() {
|
|
64
|
-
a && i();
|
|
65
|
-
}
|
|
66
|
-
let u = !1;
|
|
67
|
-
function P() {
|
|
68
|
-
return u ? () => {
|
|
69
|
-
} : (u = !0, document.addEventListener("pointerdown", d), document.addEventListener("pointermove", p), document.addEventListener("pointerup", f), document.addEventListener("pointercancel", v), window.addEventListener("blur", w), () => {
|
|
70
|
-
i(), u = !1, document.removeEventListener("pointerdown", d), document.removeEventListener("pointermove", p), document.removeEventListener("pointerup", f), document.removeEventListener("pointercancel", v), window.removeEventListener("blur", w);
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
export {
|
|
74
|
-
s as dragStarted,
|
|
75
|
-
P as initSwipeToClose
|
|
76
|
-
};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|