@konstructio/ui 0.1.2-alpha.111 → 0.1.2-alpha.112
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Toast-CRPLONv9.js +77 -0
- package/dist/components/Toast/Toast.js +1 -1
- package/dist/components/Toast/components/ToastCard/ToastCard.js +30 -30
- package/dist/components/index.js +1 -1
- package/dist/index.js +1 -1
- package/dist/lib/components/Toast/Toast.types.d.ts +5 -0
- package/dist/lib/components/Toast/components/ToastCard/ToastCard.types.d.ts +1 -0
- package/dist/package.json +1 -1
- package/package.json +1 -1
- package/dist/Toast-frCWQhFC.js +0 -76
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { t as O } from "./utils-DnIJruo0.js";
|
|
3
|
+
import { useIsHydrated as b } from "./hooks/useIsHydrated/useIsHydrated.js";
|
|
4
|
+
import { a as D, c as L, i as w, o as C, t as P } from "./react-C685EsYG.js";
|
|
5
|
+
import { t as k } from "./AnimatePresence-BsUYG9bm.js";
|
|
6
|
+
import { TOAST_TRANSITION as B } from "./components/Toast/constants/index.js";
|
|
7
|
+
import { useStackExpansion as G } from "./components/Toast/hooks/useStackExpansion/useStackExpansion.js";
|
|
8
|
+
import { useToastHeights as j } from "./components/Toast/hooks/useToastHeights/useToastHeights.js";
|
|
9
|
+
import { useToastSource as z } from "./components/Toast/hooks/useToastSource/useToastSource.js";
|
|
10
|
+
import { ToastCard as F } from "./components/Toast/components/ToastCard/ToastCard.js";
|
|
11
|
+
import { computeStackLayout as K } from "./components/Toast/utils/compute-stack-layout/compute-stack-layout.js";
|
|
12
|
+
import { useEffect as U, useState as V } from "react";
|
|
13
|
+
import { createPortal as X } from "react-dom";
|
|
14
|
+
import { jsx as s } from "react/jsx-runtime";
|
|
15
|
+
function Y() {
|
|
16
|
+
!D.current && w();
|
|
17
|
+
const [t] = V(C.current);
|
|
18
|
+
return process.env.NODE_ENV !== "production" && L(t !== !0, "You have Reduced Motion enabled on your device. Animations may not appear as expected.", "reduced-motion-disabled"), t;
|
|
19
|
+
}
|
|
20
|
+
var q = ({ autoWidth: t = !1, className: p, closeLabel: l = "Close toast", container: h, duration: a, hoverBehavior: g = "resume", isPortal: S = !0, label: T = "Notifications", limit: c, maxVisible: d = 3, theme: v, toasts: n, onDismiss: M }) => {
|
|
21
|
+
const m = Y(), E = b(), { heights: y, setHeight: A, removeHeight: H } = j(), { expanded: R, regionHandlers: N } = G(), o = z({
|
|
22
|
+
toasts: n,
|
|
23
|
+
onDismiss: M
|
|
24
|
+
});
|
|
25
|
+
U(() => {
|
|
26
|
+
n || o.configure({
|
|
27
|
+
duration: a,
|
|
28
|
+
limit: c
|
|
29
|
+
});
|
|
30
|
+
}, [
|
|
31
|
+
n,
|
|
32
|
+
o.configure,
|
|
33
|
+
a,
|
|
34
|
+
c
|
|
35
|
+
]);
|
|
36
|
+
const e = o.toasts.slice().reverse(), u = R && e.length > 0, { offsets: _, frontHeight: x, regionHeight: I } = K({
|
|
37
|
+
toasts: e,
|
|
38
|
+
heights: y,
|
|
39
|
+
expanded: u,
|
|
40
|
+
maxVisible: d
|
|
41
|
+
}), f = /* @__PURE__ */ s("section", {
|
|
42
|
+
"aria-label": T,
|
|
43
|
+
"data-theme": v,
|
|
44
|
+
className: O("fixed right-6 bottom-6 z-100 w-97.5 max-w-[calc(100vw-3rem)]", p),
|
|
45
|
+
style: { pointerEvents: e.length > 0 ? void 0 : "none" },
|
|
46
|
+
...N,
|
|
47
|
+
children: /* @__PURE__ */ s(P.ol, {
|
|
48
|
+
className: "relative m-0 list-none p-0",
|
|
49
|
+
animate: { height: I },
|
|
50
|
+
transition: m ? { duration: 0 } : B,
|
|
51
|
+
children: /* @__PURE__ */ s(k, { children: e.map((i, r) => /* @__PURE__ */ s(F, {
|
|
52
|
+
autoWidth: t,
|
|
53
|
+
closeLabel: l,
|
|
54
|
+
expanded: u,
|
|
55
|
+
frontHeight: x,
|
|
56
|
+
index: r,
|
|
57
|
+
offset: _[r] ?? 0,
|
|
58
|
+
reducedMotion: !!m,
|
|
59
|
+
restartOnLeave: g === "restart",
|
|
60
|
+
resumeDelay: (e.length - 1 - r) * 300,
|
|
61
|
+
toast: i,
|
|
62
|
+
total: e.length,
|
|
63
|
+
visible: r < d,
|
|
64
|
+
onDismiss: () => {
|
|
65
|
+
o.dismiss(i.id);
|
|
66
|
+
},
|
|
67
|
+
onExited: H,
|
|
68
|
+
onHeightChange: A
|
|
69
|
+
}, i.id)) })
|
|
70
|
+
})
|
|
71
|
+
});
|
|
72
|
+
return S ? E ? X(f, h ?? document.body) : null : f;
|
|
73
|
+
};
|
|
74
|
+
q.displayName = "KonstructToast";
|
|
75
|
+
export {
|
|
76
|
+
q as t
|
|
77
|
+
};
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import { t as r } from "../../../../utils-DnIJruo0.js";
|
|
2
|
-
import { t as
|
|
3
|
-
import { n as
|
|
2
|
+
import { t as L } from "../../../../x-C8O1IsaM.js";
|
|
3
|
+
import { n as P, t as h } from "../../../../react-C685EsYG.js";
|
|
4
4
|
import { Typography as A } from "../../../Typography/Typography.js";
|
|
5
|
-
import { COLLAPSED_SCALE_STEP as
|
|
6
|
-
import { useToastTimer as
|
|
7
|
-
import { toastCloseButtonVariants as
|
|
8
|
-
import { useEffect as
|
|
5
|
+
import { COLLAPSED_SCALE_STEP as D, DEFAULT_TOAST_DURATION as j, TOAST_ENTER_TRANSITION as B, TOAST_EXIT_TRANSITION as F, TOAST_ICONS as U, TOAST_TRANSITION as X } from "../../constants/index.js";
|
|
6
|
+
import { useToastTimer as k } from "../../hooks/useToastTimer/useToastTimer.js";
|
|
7
|
+
import { toastCloseButtonVariants as K, toastDescriptionVariants as q, toastFrameVariants as G, toastIconVariants as J, toastTitleVariants as M, toastVariants as Q } from "../../Toast.variants.js";
|
|
8
|
+
import { useEffect as W, useRef as Y } from "react";
|
|
9
9
|
import { jsx as t, jsxs as o } from "react/jsx-runtime";
|
|
10
|
-
var
|
|
11
|
-
const T =
|
|
12
|
-
|
|
10
|
+
var Z = ({ autoWidth: x, closeLabel: I, expanded: i, frontHeight: l, index: n, offset: O, reducedMotion: S, restartOnLeave: v, resumeDelay: b, toast: _, total: w, visible: m, onDismiss: p, onExited: E, onHeightChange: d }) => {
|
|
11
|
+
const T = Y(null), [C] = P(), { description: s, duration: R = j, id: c, showCloseButton: V = !0, title: g, type: a = "info" } = _;
|
|
12
|
+
k({
|
|
13
13
|
duration: R,
|
|
14
14
|
paused: i,
|
|
15
|
-
restart:
|
|
16
|
-
resumeDelay:
|
|
15
|
+
restart: v,
|
|
16
|
+
resumeDelay: b,
|
|
17
17
|
onExpire: p
|
|
18
|
-
}),
|
|
18
|
+
}), W(() => {
|
|
19
19
|
const e = T.current;
|
|
20
20
|
if (!e) return;
|
|
21
21
|
const N = () => {
|
|
@@ -27,14 +27,14 @@ var Y = ({ closeLabel: I, expanded: i, frontHeight: l, index: n, offset: O, redu
|
|
|
27
27
|
y.disconnect();
|
|
28
28
|
};
|
|
29
29
|
}, [c, d]);
|
|
30
|
-
const
|
|
31
|
-
...
|
|
32
|
-
x:
|
|
33
|
-
opacity:
|
|
30
|
+
const z = U[a], u = !i && n !== 0 && l !== 0, f = S ? { duration: 0 } : {
|
|
31
|
+
...X,
|
|
32
|
+
x: B,
|
|
33
|
+
opacity: F
|
|
34
34
|
};
|
|
35
35
|
return /* @__PURE__ */ t(h.li, {
|
|
36
|
-
className: r("absolute right-0 bottom-0
|
|
37
|
-
style: { zIndex: C ?
|
|
36
|
+
className: r("absolute right-0 bottom-0 origin-bottom will-change-transform", x ? "w-max max-w-[calc(100vw-3rem)]" : "max-w-full", G({ type: a })),
|
|
37
|
+
style: { zIndex: C ? w - n : 0 },
|
|
38
38
|
initial: {
|
|
39
39
|
x: "110%",
|
|
40
40
|
opacity: 1,
|
|
@@ -45,7 +45,7 @@ var Y = ({ closeLabel: I, expanded: i, frontHeight: l, index: n, offset: O, redu
|
|
|
45
45
|
x: 0,
|
|
46
46
|
opacity: m ? 1 : 0,
|
|
47
47
|
y: -O,
|
|
48
|
-
scale: i ? 1 : 1 - n *
|
|
48
|
+
scale: i ? 1 : 1 - n * D,
|
|
49
49
|
height: u ? l : "auto"
|
|
50
50
|
},
|
|
51
51
|
exit: { opacity: 0 },
|
|
@@ -59,24 +59,24 @@ var Y = ({ closeLabel: I, expanded: i, frontHeight: l, index: n, offset: O, redu
|
|
|
59
59
|
role: "status",
|
|
60
60
|
"aria-live": "polite",
|
|
61
61
|
"aria-atomic": "true",
|
|
62
|
-
className:
|
|
62
|
+
className: Q(),
|
|
63
63
|
children: [/* @__PURE__ */ o("div", {
|
|
64
64
|
className: "flex items-center gap-8",
|
|
65
65
|
children: [/* @__PURE__ */ o("div", {
|
|
66
66
|
className: "flex min-w-0 flex-1 items-center gap-2",
|
|
67
|
-
children: [/* @__PURE__ */ t(
|
|
67
|
+
children: [/* @__PURE__ */ t(z, {
|
|
68
68
|
size: s ? 20 : 24,
|
|
69
|
-
className: r(
|
|
69
|
+
className: r(J({ type: a }))
|
|
70
70
|
}), /* @__PURE__ */ t(A, {
|
|
71
71
|
variant: s ? "body2" : "body1",
|
|
72
|
-
className: r("min-w-0",
|
|
73
|
-
children:
|
|
72
|
+
className: r("min-w-0", M({ type: a })),
|
|
73
|
+
children: g
|
|
74
74
|
})]
|
|
75
|
-
}),
|
|
75
|
+
}), V ? /* @__PURE__ */ o("button", {
|
|
76
76
|
type: "button",
|
|
77
|
-
className: r(
|
|
77
|
+
className: r(K({ type: a })),
|
|
78
78
|
onClick: p,
|
|
79
|
-
children: [/* @__PURE__ */ t(
|
|
79
|
+
children: [/* @__PURE__ */ t(L, {
|
|
80
80
|
className: "size-5",
|
|
81
81
|
"aria-hidden": !0
|
|
82
82
|
}), /* @__PURE__ */ t("span", {
|
|
@@ -90,14 +90,14 @@ var Y = ({ closeLabel: I, expanded: i, frontHeight: l, index: n, offset: O, redu
|
|
|
90
90
|
transition: f,
|
|
91
91
|
children: /* @__PURE__ */ t(A, {
|
|
92
92
|
variant: "body2",
|
|
93
|
-
className: r(
|
|
93
|
+
className: r(q({ type: a })),
|
|
94
94
|
children: s
|
|
95
95
|
})
|
|
96
96
|
}) : null]
|
|
97
97
|
})
|
|
98
98
|
});
|
|
99
99
|
};
|
|
100
|
-
|
|
100
|
+
Z.displayName = "KonstructToastCard";
|
|
101
101
|
export {
|
|
102
|
-
|
|
102
|
+
Z as ToastCard
|
|
103
103
|
};
|
package/dist/components/index.js
CHANGED
|
@@ -9,7 +9,7 @@ import { AlertDialog as g } from "./AlertDialog/AlertDialog.js";
|
|
|
9
9
|
import { Autocomplete as S } from "./Autocomplete/Autocomplete.js";
|
|
10
10
|
import { t as C } from "../Loading-u8hXrFJR.js";
|
|
11
11
|
import { Badge as A } from "./Badge/Badge.js";
|
|
12
|
-
import { t as v } from "../Toast-
|
|
12
|
+
import { t as v } from "../Toast-CRPLONv9.js";
|
|
13
13
|
import { Typography as L } from "./Typography/Typography.js";
|
|
14
14
|
import { ButtonGroup as E } from "./ButtonGroup/ButtonGroup.js";
|
|
15
15
|
import { Card as F } from "./Card/Card.js";
|
package/dist/index.js
CHANGED
|
@@ -14,7 +14,7 @@ import { useToggle as L } from "./hooks/useToggle.js";
|
|
|
14
14
|
import { Autocomplete as h } from "./components/Autocomplete/Autocomplete.js";
|
|
15
15
|
import { t as F } from "./Loading-u8hXrFJR.js";
|
|
16
16
|
import { Badge as P } from "./components/Badge/Badge.js";
|
|
17
|
-
import { t as M } from "./Toast-
|
|
17
|
+
import { t as M } from "./Toast-CRPLONv9.js";
|
|
18
18
|
import { Typography as _ } from "./components/Typography/Typography.js";
|
|
19
19
|
import { ButtonGroup as k } from "./components/ButtonGroup/ButtonGroup.js";
|
|
20
20
|
import { Card as U } from "./components/Card/Card.js";
|
|
@@ -30,6 +30,11 @@ export type ToastHeights = Record<string, number>;
|
|
|
30
30
|
* ```
|
|
31
31
|
*/
|
|
32
32
|
export type Props = {
|
|
33
|
+
/**
|
|
34
|
+
* Size each toast to its content, growing leftwards up to the viewport
|
|
35
|
+
* width, instead of the region's fixed width (default: false)
|
|
36
|
+
*/
|
|
37
|
+
autoWidth?: boolean;
|
|
33
38
|
/** Additional CSS classes for the fixed region */
|
|
34
39
|
className?: string;
|
|
35
40
|
/** Accessible name of every close button (default: 'Close toast') */
|
package/dist/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@konstructio/ui",
|
|
3
3
|
"description": "A set of reusable and customizable React components built for konstruct.io",
|
|
4
4
|
"private": false,
|
|
5
|
-
"version": "0.1.2-alpha.
|
|
5
|
+
"version": "0.1.2-alpha.111",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"main": "dist/index.js",
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@konstructio/ui",
|
|
3
3
|
"description": "A set of reusable and customizable React components built for konstruct.io",
|
|
4
4
|
"private": false,
|
|
5
|
-
"version": "0.1.2-alpha.
|
|
5
|
+
"version": "0.1.2-alpha.112",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"main": "dist/index.js",
|
package/dist/Toast-frCWQhFC.js
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { t as I } from "./utils-DnIJruo0.js";
|
|
3
|
-
import { useIsHydrated as O } from "./hooks/useIsHydrated/useIsHydrated.js";
|
|
4
|
-
import { a as b, c as D, i as L, o as w, t as C } from "./react-C685EsYG.js";
|
|
5
|
-
import { t as P } from "./AnimatePresence-BsUYG9bm.js";
|
|
6
|
-
import { TOAST_TRANSITION as k } from "./components/Toast/constants/index.js";
|
|
7
|
-
import { useStackExpansion as B } from "./components/Toast/hooks/useStackExpansion/useStackExpansion.js";
|
|
8
|
-
import { useToastHeights as G } from "./components/Toast/hooks/useToastHeights/useToastHeights.js";
|
|
9
|
-
import { useToastSource as j } from "./components/Toast/hooks/useToastSource/useToastSource.js";
|
|
10
|
-
import { ToastCard as z } from "./components/Toast/components/ToastCard/ToastCard.js";
|
|
11
|
-
import { computeStackLayout as F } from "./components/Toast/utils/compute-stack-layout/compute-stack-layout.js";
|
|
12
|
-
import { useEffect as K, useState as U } from "react";
|
|
13
|
-
import { createPortal as V } from "react-dom";
|
|
14
|
-
import { jsx as n } from "react/jsx-runtime";
|
|
15
|
-
function X() {
|
|
16
|
-
!b.current && L();
|
|
17
|
-
const [t] = U(w.current);
|
|
18
|
-
return process.env.NODE_ENV !== "production" && D(t !== !0, "You have Reduced Motion enabled on your device. Animations may not appear as expected.", "reduced-motion-disabled"), t;
|
|
19
|
-
}
|
|
20
|
-
var Y = ({ className: t, closeLabel: p = "Close toast", container: l, duration: a, hoverBehavior: h = "resume", isPortal: g = !0, label: S = "Notifications", limit: c, maxVisible: d = 3, theme: T, toasts: s, onDismiss: v }) => {
|
|
21
|
-
const m = X(), M = O(), { heights: E, setHeight: y, removeHeight: A } = G(), { expanded: H, regionHandlers: R } = B(), o = j({
|
|
22
|
-
toasts: s,
|
|
23
|
-
onDismiss: v
|
|
24
|
-
});
|
|
25
|
-
K(() => {
|
|
26
|
-
s || o.configure({
|
|
27
|
-
duration: a,
|
|
28
|
-
limit: c
|
|
29
|
-
});
|
|
30
|
-
}, [
|
|
31
|
-
s,
|
|
32
|
-
o.configure,
|
|
33
|
-
a,
|
|
34
|
-
c
|
|
35
|
-
]);
|
|
36
|
-
const e = o.toasts.slice().reverse(), u = H && e.length > 0, { offsets: N, frontHeight: _, regionHeight: x } = F({
|
|
37
|
-
toasts: e,
|
|
38
|
-
heights: E,
|
|
39
|
-
expanded: u,
|
|
40
|
-
maxVisible: d
|
|
41
|
-
}), f = /* @__PURE__ */ n("section", {
|
|
42
|
-
"aria-label": S,
|
|
43
|
-
"data-theme": T,
|
|
44
|
-
className: I("fixed right-6 bottom-6 z-100 w-97.5 max-w-[calc(100vw-3rem)]", t),
|
|
45
|
-
style: { pointerEvents: e.length > 0 ? void 0 : "none" },
|
|
46
|
-
...R,
|
|
47
|
-
children: /* @__PURE__ */ n(C.ol, {
|
|
48
|
-
className: "relative m-0 list-none p-0",
|
|
49
|
-
animate: { height: x },
|
|
50
|
-
transition: m ? { duration: 0 } : k,
|
|
51
|
-
children: /* @__PURE__ */ n(P, { children: e.map((i, r) => /* @__PURE__ */ n(z, {
|
|
52
|
-
closeLabel: p,
|
|
53
|
-
expanded: u,
|
|
54
|
-
frontHeight: _,
|
|
55
|
-
index: r,
|
|
56
|
-
offset: N[r] ?? 0,
|
|
57
|
-
reducedMotion: !!m,
|
|
58
|
-
restartOnLeave: h === "restart",
|
|
59
|
-
resumeDelay: (e.length - 1 - r) * 300,
|
|
60
|
-
toast: i,
|
|
61
|
-
total: e.length,
|
|
62
|
-
visible: r < d,
|
|
63
|
-
onDismiss: () => {
|
|
64
|
-
o.dismiss(i.id);
|
|
65
|
-
},
|
|
66
|
-
onExited: A,
|
|
67
|
-
onHeightChange: y
|
|
68
|
-
}, i.id)) })
|
|
69
|
-
})
|
|
70
|
-
});
|
|
71
|
-
return g ? M ? V(f, l ?? document.body) : null : f;
|
|
72
|
-
};
|
|
73
|
-
Y.displayName = "KonstructToast";
|
|
74
|
-
export {
|
|
75
|
-
Y as t
|
|
76
|
-
};
|