@mci-ui/mci-ui 0.0.86 → 0.0.88
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/index.css +1 -1
- package/dist/shared/ui/MciModal/MciModal.js +107 -59
- package/dist/shared/ui/mciAccordion/MciAccordion.js +97 -64
- package/dist/shared/ui/mciBreadcrumb/MciBreadcrumb.js +23 -21
- package/dist/shared/ui/mciButton/MciButton.js +47 -32
- package/dist/shared/ui/mciCheck/MciCheck.js +116 -92
- package/dist/shared/ui/mciCollapse/MciCollapse.js +86 -54
- package/dist/shared/ui/mciDrawer/MciDrawer.js +82 -59
- package/dist/shared/ui/mciInput/MciInput.js +143 -130
- package/dist/shared/ui/mciInput/mci-input.utils.js +10 -10
- package/dist/shared/ui/mciPagination/MciPagination.js +85 -63
- package/dist/shared/ui/mciPhone/MciPhone.js +59 -54
- package/dist/shared/ui/mciPhone/mci-phone.utils.js +10 -10
- package/dist/shared/ui/mciPicker/MciPicker.js +349 -181
- package/dist/shared/ui/mciSelect/MciSelect.js +150 -131
- package/dist/shared/ui/mciSelect/mci-select.utils.js +12 -12
- package/dist/shared/ui/mciSkeleton/MciSkeleton.js +16 -14
- package/dist/shared/ui/mciTable/MciTable.js +165 -126
- package/dist/shared/ui/mciTable/MciTableColumnsPanel.js +113 -106
- package/dist/shared/ui/mciTabs/MciTabs.js +73 -55
- package/dist/shared/ui/mciTag/MciTag.js +27 -18
- package/dist/shared/ui/mciTextarea/MciTextarea.js +47 -35
- package/dist/shared/ui/mciToast/MciToast.js +118 -72
- package/dist/shared/ui/mciToast/mci-toast.utils.js +40 -12
- package/dist/shared/ui/mciToggle/MciToggle.js +58 -36
- package/dist/shared/ui/mciTooltip/MciTooltip.js +2 -2
- package/dist/shared/ui/mciUpload/MciUpload.js +172 -149
- package/dist/types/shared/types/mci-table.types.d.ts +1 -0
- package/dist/types/shared/types/ui/accordion.types.d.ts +1 -0
- package/dist/types/shared/types/ui/breadcrumb.types.d.ts +1 -0
- package/dist/types/shared/types/ui/button.types.d.ts +3 -7
- package/dist/types/shared/types/ui/check.types.d.ts +4 -9
- package/dist/types/shared/types/ui/collapse.types.d.ts +1 -0
- package/dist/types/shared/types/ui/drawer.types.d.ts +2 -0
- package/dist/types/shared/types/ui/input.types.d.ts +4 -15
- package/dist/types/shared/types/ui/modal.types.d.ts +1 -0
- package/dist/types/shared/types/ui/pagination.types.d.ts +1 -0
- package/dist/types/shared/types/ui/phone.types.d.ts +1 -0
- package/dist/types/shared/types/ui/picker.types.d.ts +1 -0
- package/dist/types/shared/types/ui/select.types.d.ts +1 -0
- package/dist/types/shared/types/ui/skeleton.types.d.ts +1 -0
- package/dist/types/shared/types/ui/tabs.types.d.ts +1 -0
- package/dist/types/shared/types/ui/tag.types.d.ts +1 -0
- package/dist/types/shared/types/ui/textarea.types.d.ts +3 -7
- package/dist/types/shared/types/ui/toast.types.d.ts +1 -0
- package/dist/types/shared/types/ui/toggle.types.d.ts +3 -2
- package/dist/types/shared/types/ui/upload.types.d.ts +1 -0
- package/dist/types/shared/ui/MciModal/MciModal.d.ts +1 -1
- package/dist/types/shared/ui/mciAccordion/MciAccordion.d.ts +5 -3
- package/dist/types/shared/ui/mciBreadcrumb/MciBreadcrumb.d.ts +1 -1
- package/dist/types/shared/ui/mciButton/MciButton.d.ts +1 -1
- package/dist/types/shared/ui/mciCollapse/MciCollapse.d.ts +1 -1
- package/dist/types/shared/ui/mciDrawer/MciDrawer.d.ts +1 -1
- package/dist/types/shared/ui/mciInput/MciInput.d.ts +13 -2
- package/dist/types/shared/ui/mciInput/mci-input.utils.d.ts +2 -2
- package/dist/types/shared/ui/mciPagination/MciPagination.d.ts +1 -1
- package/dist/types/shared/ui/mciPhone/mci-phone.utils.d.ts +2 -2
- package/dist/types/shared/ui/mciSelect/mci-select.utils.d.ts +2 -2
- package/dist/types/shared/ui/mciSkeleton/MciSkeleton.d.ts +1 -1
- package/dist/types/shared/ui/mciTable/MciTable.d.ts +1 -1
- package/dist/types/shared/ui/mciTable/MciTableColumnsPanel.d.ts +2 -1
- package/dist/types/shared/ui/mciTabs/MciTabs.d.ts +1 -1
- package/dist/types/shared/ui/mciTag/MciTag.d.ts +1 -1
- package/dist/types/shared/ui/mciTextarea/MciTextarea.d.ts +7 -2
- package/dist/types/shared/ui/mciToast/mci-toast.utils.d.ts +32 -4
- package/dist/types/shared/ui/mciToggle/MciToggle.d.ts +1 -1
- package/package.json +1 -1
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useState as
|
|
1
|
+
import { jsxs as u, jsx as i } from "react/jsx-runtime";
|
|
2
|
+
import { useState as v, useRef as p, useCallback as R, useEffect as x } from "react";
|
|
3
3
|
import { cn as t } from "../../lib/utils.js";
|
|
4
4
|
const I = {
|
|
5
5
|
top: "flex-col",
|
|
6
6
|
bottom: "flex-col-reverse",
|
|
7
7
|
left: "flex-row",
|
|
8
8
|
right: "flex-row-reverse"
|
|
9
|
-
},
|
|
9
|
+
}, O = {
|
|
10
10
|
top: "flex-row",
|
|
11
11
|
bottom: "flex-row",
|
|
12
12
|
left: "flex-col",
|
|
@@ -17,89 +17,107 @@ const I = {
|
|
|
17
17
|
left: "ml-4",
|
|
18
18
|
right: "mr-4"
|
|
19
19
|
};
|
|
20
|
-
function
|
|
21
|
-
tabs:
|
|
22
|
-
defaultTab:
|
|
23
|
-
position:
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
20
|
+
function q({
|
|
21
|
+
tabs: l,
|
|
22
|
+
defaultTab: N,
|
|
23
|
+
position: c = "top",
|
|
24
|
+
darkMode: d = !1,
|
|
25
|
+
className: b,
|
|
26
|
+
tabListClassName: g,
|
|
27
|
+
contentClassName: S,
|
|
28
|
+
extra: w,
|
|
29
|
+
onChange: y
|
|
29
30
|
}) {
|
|
30
|
-
const [
|
|
31
|
+
const [a, E] = v(N || l[0]?.id), [A, T] = v({}), f = p([]), h = p(null), n = R(() => {
|
|
31
32
|
requestAnimationFrame(() => {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
33
|
+
requestAnimationFrame(() => {
|
|
34
|
+
const e = l.findIndex((L) => L?.id === a), r = f.current[e];
|
|
35
|
+
if (!r) return;
|
|
36
|
+
const { offsetLeft: o, offsetTop: m, offsetWidth: z, offsetHeight: C } = r;
|
|
37
|
+
T({
|
|
38
|
+
left: `${o}px`,
|
|
37
39
|
top: `${m}px`,
|
|
38
|
-
width: `${
|
|
39
|
-
height: `${
|
|
40
|
+
width: `${z}px`,
|
|
41
|
+
height: `${C}px`,
|
|
40
42
|
transition: "all 0.35s cubic-bezier(0.25, 1, 0.5, 1)"
|
|
41
43
|
});
|
|
42
|
-
}
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
}, [a, l]);
|
|
47
|
+
x(() => (n(), window.addEventListener("resize", n), "fonts" in document && document.fonts.ready.then(n), () => window.removeEventListener("resize", n)), [c, n]), x(() => {
|
|
48
|
+
const e = h.current;
|
|
49
|
+
if (!e || typeof ResizeObserver > "u") return;
|
|
50
|
+
const r = new ResizeObserver(() => {
|
|
51
|
+
n();
|
|
43
52
|
});
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}, [
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
53
|
+
return r.observe(e), f.current.forEach((o) => {
|
|
54
|
+
o && r.observe(o);
|
|
55
|
+
}), () => r.disconnect();
|
|
56
|
+
}, [l, n]), x(() => {
|
|
57
|
+
f.current = f.current.slice(0, l.length);
|
|
58
|
+
}, [l]);
|
|
59
|
+
const s = c === "left" || c === "right";
|
|
60
|
+
return /* @__PURE__ */ u("div", { className: t("flex w-full", I[c], b), children: [
|
|
61
|
+
/* @__PURE__ */ u(
|
|
51
62
|
"div",
|
|
52
63
|
{
|
|
53
64
|
className: t(
|
|
54
65
|
"flex w-full gap-4",
|
|
55
|
-
|
|
66
|
+
s ? "flex-col items-start" : "flex-row flex-wrap items-center"
|
|
56
67
|
),
|
|
57
68
|
children: [
|
|
58
|
-
/* @__PURE__ */
|
|
69
|
+
/* @__PURE__ */ i(
|
|
59
70
|
"div",
|
|
60
71
|
{
|
|
61
72
|
className: t(
|
|
62
73
|
"flex-1",
|
|
63
|
-
|
|
74
|
+
s ? "w-full" : "min-w-[520px]"
|
|
64
75
|
),
|
|
65
|
-
children: /* @__PURE__ */
|
|
76
|
+
children: /* @__PURE__ */ u(
|
|
66
77
|
"div",
|
|
67
78
|
{
|
|
79
|
+
ref: h,
|
|
68
80
|
className: t(
|
|
69
|
-
"relative flex rounded-xl
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
81
|
+
"relative flex rounded-xl p-1",
|
|
82
|
+
d ? "bg-neutral-300" : "bg-slate-100",
|
|
83
|
+
O[c],
|
|
84
|
+
!s && "w-full overflow-hidden",
|
|
85
|
+
s ? "min-w-48" : "",
|
|
86
|
+
g
|
|
74
87
|
),
|
|
75
88
|
children: [
|
|
76
|
-
/* @__PURE__ */
|
|
89
|
+
/* @__PURE__ */ i(
|
|
77
90
|
"div",
|
|
78
91
|
{
|
|
79
|
-
className: t(
|
|
80
|
-
|
|
92
|
+
className: t(
|
|
93
|
+
"absolute rounded-lg",
|
|
94
|
+
d ? "bg-black" : "bg-white",
|
|
95
|
+
s ? "w-full" : "h-full"
|
|
96
|
+
),
|
|
97
|
+
style: A
|
|
81
98
|
}
|
|
82
99
|
),
|
|
83
|
-
|
|
84
|
-
const
|
|
85
|
-
return /* @__PURE__ */
|
|
100
|
+
l?.map((e, r) => {
|
|
101
|
+
const o = a === e.id;
|
|
102
|
+
return /* @__PURE__ */ u(
|
|
86
103
|
"button",
|
|
87
104
|
{
|
|
88
105
|
ref: (m) => {
|
|
89
|
-
|
|
106
|
+
f.current[r] = m;
|
|
90
107
|
},
|
|
91
108
|
onClick: () => {
|
|
92
|
-
e?.disabled || (
|
|
109
|
+
e?.disabled || (E(e?.id), y?.(e?.id));
|
|
93
110
|
},
|
|
94
111
|
disabled: e?.disabled,
|
|
95
112
|
className: t(
|
|
96
|
-
"relative z-10 flex items-center justify-center whitespace-nowrap px-3 py-2 text-base font-normal
|
|
97
|
-
|
|
98
|
-
|
|
113
|
+
"relative z-10 flex items-center justify-center whitespace-nowrap px-3 py-2 text-base font-normal transition-colors duration-300 hover:cursor-pointer",
|
|
114
|
+
d ? "text-white" : "text-black",
|
|
115
|
+
e?.disabled && (d ? "cursor-not-allowed text-neutral-100/50 opacity-60" : "cursor-not-allowed opacity-50"),
|
|
116
|
+
s ? "w-full justify-start" : "flex-1 min-w-0"
|
|
99
117
|
),
|
|
100
118
|
children: [
|
|
101
|
-
e?.icon && /* @__PURE__ */
|
|
102
|
-
/* @__PURE__ */
|
|
119
|
+
e?.icon && /* @__PURE__ */ i("span", { className: t("shrink-0 transition-transform duration-200", o && "scale-110"), children: e?.icon }),
|
|
120
|
+
/* @__PURE__ */ i("span", { className: "relative z-10 truncate", title: e?.label, children: e?.label })
|
|
103
121
|
]
|
|
104
122
|
},
|
|
105
123
|
e?.id
|
|
@@ -110,22 +128,22 @@ function _({
|
|
|
110
128
|
)
|
|
111
129
|
}
|
|
112
130
|
),
|
|
113
|
-
|
|
131
|
+
w && /* @__PURE__ */ i(
|
|
114
132
|
"div",
|
|
115
133
|
{
|
|
116
134
|
className: t(
|
|
117
135
|
"shrink-0 ml-auto",
|
|
118
|
-
|
|
136
|
+
s ? "w-full" : "max-w-full"
|
|
119
137
|
),
|
|
120
|
-
children: /* @__PURE__ */
|
|
138
|
+
children: /* @__PURE__ */ i("div", { className: "flex flex-wrap items-center justify-end gap-2", children: w })
|
|
121
139
|
}
|
|
122
140
|
)
|
|
123
141
|
]
|
|
124
142
|
}
|
|
125
143
|
),
|
|
126
|
-
/* @__PURE__ */
|
|
144
|
+
/* @__PURE__ */ i("div", { className: t("w-full flex-1 overflow-hidden", j[c], S), children: /* @__PURE__ */ i("div", { className: "animate-fade-in w-full", style: { animationDuration: "0.35s" }, children: l?.find((e) => e.id === a)?.content }, a) })
|
|
127
145
|
] });
|
|
128
146
|
}
|
|
129
147
|
export {
|
|
130
|
-
|
|
148
|
+
q as default
|
|
131
149
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { cn as
|
|
3
|
-
const
|
|
1
|
+
import { jsxs as m, jsx as l } from "react/jsx-runtime";
|
|
2
|
+
import { cn as s } from "../../lib/utils.js";
|
|
3
|
+
const d = {
|
|
4
4
|
sm: "px-2 py-0.5",
|
|
5
5
|
md: "px-2 py-1",
|
|
6
6
|
lg: "px-3 py-2"
|
|
@@ -8,35 +8,44 @@ const c = {
|
|
|
8
8
|
sm: "w-3 h-3",
|
|
9
9
|
md: "w-3 h-3",
|
|
10
10
|
lg: "w-3 h-3"
|
|
11
|
-
},
|
|
11
|
+
}, b = {
|
|
12
12
|
success: "bg-green-50 text-green-600",
|
|
13
|
-
warning: "bg-
|
|
13
|
+
warning: "bg-yellow-50 text-yellow-600",
|
|
14
14
|
error: "bg-red-50 text-red-600",
|
|
15
15
|
gray: "bg-slate-200 text-slate-700",
|
|
16
16
|
blue: "bg-blue-50 text-blue-600"
|
|
17
|
+
}, p = {
|
|
18
|
+
success: "bg-green-950 text-green-400",
|
|
19
|
+
warning: "bg-yellow-900 text-yellow-400",
|
|
20
|
+
error: "bg-red-950 text-red-400",
|
|
21
|
+
gray: "bg-neutral-200 text-neutral-50",
|
|
22
|
+
blue: "bg-blue-900 text-blue-400"
|
|
17
23
|
};
|
|
18
24
|
function i({
|
|
19
|
-
children:
|
|
20
|
-
variant:
|
|
25
|
+
children: g,
|
|
26
|
+
variant: r = "success",
|
|
21
27
|
size: t = "lg",
|
|
28
|
+
darkMode: x = !1,
|
|
22
29
|
icon: e,
|
|
23
|
-
iconPosition:
|
|
24
|
-
|
|
30
|
+
iconPosition: a = "left",
|
|
31
|
+
rounded: u = !1,
|
|
32
|
+
className: c
|
|
25
33
|
}) {
|
|
26
|
-
return /* @__PURE__ */
|
|
34
|
+
return /* @__PURE__ */ m(
|
|
27
35
|
"span",
|
|
28
36
|
{
|
|
29
|
-
className:
|
|
30
|
-
"inline-flex animate-[fadeIn_0.3s_ease-out] items-center
|
|
31
|
-
|
|
32
|
-
|
|
37
|
+
className: s(
|
|
38
|
+
"inline-flex animate-[fadeIn_0.3s_ease-out] items-center text-extra-small font-medium",
|
|
39
|
+
u ? "rounded-full" : "rounded-lg",
|
|
40
|
+
d[t],
|
|
41
|
+
x ? p[r] : b[r],
|
|
33
42
|
e && "gap-[2px]",
|
|
34
|
-
|
|
43
|
+
c
|
|
35
44
|
),
|
|
36
45
|
children: [
|
|
37
|
-
e &&
|
|
38
|
-
/* @__PURE__ */
|
|
39
|
-
e &&
|
|
46
|
+
e && a === "left" && /* @__PURE__ */ l("span", { className: `flex items-center ${s(n[t])}`, children: e }),
|
|
47
|
+
/* @__PURE__ */ l("span", { children: g }),
|
|
48
|
+
e && a === "right" && /* @__PURE__ */ l("span", { className: `flex items-center ${s(n[t])}`, children: e })
|
|
40
49
|
]
|
|
41
50
|
}
|
|
42
51
|
);
|
|
@@ -1,56 +1,68 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { forwardRef as
|
|
3
|
-
import { cn as
|
|
4
|
-
const
|
|
1
|
+
import { jsxs as s, jsx as a } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as w, useMemo as _ } from "react";
|
|
3
|
+
import { cn as r } from "../../lib/utils.js";
|
|
4
|
+
const g = w(
|
|
5
5
|
({
|
|
6
|
-
label:
|
|
7
|
-
placeholder:
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
label: l,
|
|
7
|
+
placeholder: o,
|
|
8
|
+
darkMode: e = !1,
|
|
9
|
+
value: d = "",
|
|
10
|
+
onChange: n,
|
|
11
|
+
required: u = !1,
|
|
11
12
|
disabled: i = !1,
|
|
12
|
-
error:
|
|
13
|
-
className:
|
|
14
|
-
rows:
|
|
15
|
-
name:
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
13
|
+
error: t,
|
|
14
|
+
className: b,
|
|
15
|
+
rows: c = 4,
|
|
16
|
+
name: f,
|
|
17
|
+
...x
|
|
18
|
+
}, m) => {
|
|
19
|
+
const h = _(() => e ? t ? "border-red-500 hover:border-red-500 focus:border-red-500 focus:shadow-[0_0_0_2px_rgba(231,0,11,0.25)]" : "border-neutral-200 hover:border-neutral-100 focus:border-blue-500 focus:shadow-[0_0_0_2px_var(--opacity-25,rgba(21,93,252,0.25))]" : t ? "border-red-600 focus:border-red-600 shadow-red" : "border-slate-200 hover:border-slate-400 focus:shadow-blue focus:border-blue-600", [e, t]);
|
|
20
|
+
return /* @__PURE__ */ s("div", { className: r("relative w-full", b), children: [
|
|
21
|
+
l && /* @__PURE__ */ s(
|
|
20
22
|
"label",
|
|
21
23
|
{
|
|
22
|
-
className:
|
|
24
|
+
className: r(
|
|
23
25
|
"mb-2 block text-base font-medium",
|
|
24
|
-
e ? "text-red-600" : "text-slate-700"
|
|
26
|
+
t ? e ? "text-red-500" : "text-red-600" : e ? "text-neutral-50" : "text-slate-700"
|
|
25
27
|
),
|
|
26
28
|
children: [
|
|
27
|
-
|
|
28
|
-
|
|
29
|
+
l,
|
|
30
|
+
u && /* @__PURE__ */ a("span", { className: "ml-1 text-red-600", children: "*" })
|
|
29
31
|
]
|
|
30
32
|
}
|
|
31
33
|
),
|
|
32
|
-
/* @__PURE__ */
|
|
34
|
+
/* @__PURE__ */ a(
|
|
33
35
|
"textarea",
|
|
34
36
|
{
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
...x,
|
|
38
|
+
ref: m,
|
|
39
|
+
name: f,
|
|
40
|
+
rows: c,
|
|
41
|
+
value: d,
|
|
42
|
+
onChange: (p) => n?.(p.target.value),
|
|
40
43
|
disabled: i,
|
|
41
|
-
placeholder:
|
|
42
|
-
className:
|
|
43
|
-
"w-full resize-none rounded-xl border
|
|
44
|
-
"p-3 disabled:cursor-not-allowed disabled:border-slate-200 disabled:bg-slate-100 disabled:text-slate-400",
|
|
45
|
-
|
|
44
|
+
placeholder: o,
|
|
45
|
+
className: r(
|
|
46
|
+
"w-full resize-none rounded-xl border text-base font-normal transition-all duration-300 ease-in-out outline-none",
|
|
47
|
+
e ? "p-3 text-neutral-50 placeholder:text-neutral-100 focus:text-white disabled:cursor-not-allowed disabled:border-neutral-200 disabled:bg-neutral-300 disabled:text-neutral-100/50 disabled:placeholder:text-neutral-100/50" : "bg-white p-3 disabled:cursor-not-allowed disabled:border-slate-200 disabled:bg-slate-100 disabled:text-slate-400",
|
|
48
|
+
h
|
|
46
49
|
)
|
|
47
50
|
}
|
|
48
51
|
),
|
|
49
|
-
|
|
52
|
+
t && /* @__PURE__ */ a(
|
|
53
|
+
"p",
|
|
54
|
+
{
|
|
55
|
+
className: r(
|
|
56
|
+
"mt-2 animate-[slideDown_0.3s_ease-out] text-sm font-normal",
|
|
57
|
+
e ? "text-red-500" : "text-red-600"
|
|
58
|
+
),
|
|
59
|
+
children: t
|
|
60
|
+
}
|
|
61
|
+
)
|
|
50
62
|
] });
|
|
51
63
|
}
|
|
52
64
|
);
|
|
53
|
-
|
|
65
|
+
g.displayName = "MciTextarea";
|
|
54
66
|
export {
|
|
55
|
-
|
|
67
|
+
g as default
|
|
56
68
|
};
|
|
@@ -1,69 +1,105 @@
|
|
|
1
|
-
import { jsx as s, jsxs as
|
|
2
|
-
import { useState as
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import { TOAST_STYLES as
|
|
7
|
-
const O =
|
|
8
|
-
let p = null,
|
|
9
|
-
const
|
|
10
|
-
p || (p =
|
|
11
|
-
/* @__PURE__ */ s("div", { className: "flex flex-col gap-3", children:
|
|
1
|
+
import { jsx as s, jsxs as u } from "react/jsx-runtime";
|
|
2
|
+
import { useState as b, useEffect as C } from "react";
|
|
3
|
+
import { createRoot as I } from "react-dom/client";
|
|
4
|
+
import S from "../../../assets/icons/close.svg.js";
|
|
5
|
+
import { cn as a } from "../../lib/utils.js";
|
|
6
|
+
import { TOAST_STYLES as r, TOAST_ICONS as A, getOrCreateToastContainer as D } from "./mci-toast.utils.js";
|
|
7
|
+
const O = D();
|
|
8
|
+
let p = null, F = 0;
|
|
9
|
+
const m = [], N = () => {
|
|
10
|
+
p || (p = I(O)), p.render(
|
|
11
|
+
/* @__PURE__ */ s("div", { className: "flex flex-col gap-3", children: m.map(({ id: e, element: t }) => /* @__PURE__ */ s("div", { className: "pointer-events-auto", children: t }, e)) })
|
|
12
12
|
);
|
|
13
13
|
};
|
|
14
|
-
function
|
|
14
|
+
function j({
|
|
15
15
|
title: e,
|
|
16
|
-
description:
|
|
17
|
-
type:
|
|
18
|
-
duration:
|
|
19
|
-
action:
|
|
20
|
-
|
|
16
|
+
description: t,
|
|
17
|
+
type: n = "info",
|
|
18
|
+
duration: o = 3e3,
|
|
19
|
+
action: c,
|
|
20
|
+
darkMode: i = !1,
|
|
21
|
+
onClose: d
|
|
21
22
|
}) {
|
|
22
|
-
const [
|
|
23
|
+
const [T, h] = b(100);
|
|
23
24
|
return C(() => {
|
|
24
|
-
if (
|
|
25
|
-
|
|
25
|
+
if (o === 1 / 0) {
|
|
26
|
+
h(100);
|
|
26
27
|
return;
|
|
27
28
|
}
|
|
28
|
-
let
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
},
|
|
34
|
-
return () => cancelAnimationFrame(
|
|
35
|
-
}, [
|
|
29
|
+
let f = null;
|
|
30
|
+
const x = (g) => {
|
|
31
|
+
f || (f = g);
|
|
32
|
+
const y = g - f, v = Math.max(0, (o - y) / o * 100);
|
|
33
|
+
h(v), v > 0 ? requestAnimationFrame(x) : d?.();
|
|
34
|
+
}, w = requestAnimationFrame(x);
|
|
35
|
+
return () => cancelAnimationFrame(w);
|
|
36
|
+
}, [o, d]), /* @__PURE__ */ u(
|
|
36
37
|
"div",
|
|
37
38
|
{
|
|
38
|
-
className:
|
|
39
|
-
"relative w-[300px] max-w-full overflow-hidden shadow-md
|
|
39
|
+
className: a(
|
|
40
|
+
"relative w-[300px] max-w-full overflow-hidden rounded-lg shadow-md",
|
|
40
41
|
"animate-in fade-in slide-in-from-top-2 duration-300",
|
|
41
|
-
|
|
42
|
+
i ? r.bgDark[n] : r.bg[n]
|
|
42
43
|
),
|
|
43
44
|
children: [
|
|
44
45
|
/* @__PURE__ */ s(
|
|
45
46
|
"div",
|
|
46
47
|
{
|
|
47
|
-
className:
|
|
48
|
+
className: a(
|
|
49
|
+
"absolute bottom-0 left-0 h-1",
|
|
50
|
+
i ? r.lineDark[n] : r.line[n]
|
|
51
|
+
),
|
|
48
52
|
style: {
|
|
49
|
-
width: `${
|
|
53
|
+
width: `${T}%`,
|
|
50
54
|
transition: "none"
|
|
51
55
|
}
|
|
52
56
|
}
|
|
53
57
|
),
|
|
54
|
-
/* @__PURE__ */ s("div", { className: "p-4", children: /* @__PURE__ */
|
|
55
|
-
/* @__PURE__ */ s(
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
/* @__PURE__ */ s("div", { className: "p-4", children: /* @__PURE__ */ u("div", { className: "flex items-start gap-2", children: [
|
|
59
|
+
/* @__PURE__ */ s(
|
|
60
|
+
"div",
|
|
61
|
+
{
|
|
62
|
+
className: a(
|
|
63
|
+
"shrink-0",
|
|
64
|
+
i ? r.textDark[n] : r.text[n]
|
|
65
|
+
),
|
|
66
|
+
children: A[n]
|
|
67
|
+
}
|
|
68
|
+
),
|
|
69
|
+
/* @__PURE__ */ u("div", { className: "min-w-0 flex-1", children: [
|
|
70
|
+
/* @__PURE__ */ s(
|
|
71
|
+
"h4",
|
|
72
|
+
{
|
|
73
|
+
className: a(
|
|
74
|
+
"mb-1 text-base font-medium",
|
|
75
|
+
i && r.textDark[n]
|
|
76
|
+
),
|
|
77
|
+
children: e
|
|
78
|
+
}
|
|
79
|
+
),
|
|
80
|
+
t && /* @__PURE__ */ s("p", { className: a("text-sm", i ? "text-slate-400" : "text-[#82828C]"), children: t }),
|
|
81
|
+
c && /* @__PURE__ */ s("div", { className: "mt-3", children: /* @__PURE__ */ s(
|
|
82
|
+
"div",
|
|
83
|
+
{
|
|
84
|
+
className: a(
|
|
85
|
+
"text-sm font-medium underline",
|
|
86
|
+
i ? r.actionDark[n] : r.action[n]
|
|
87
|
+
),
|
|
88
|
+
children: c
|
|
89
|
+
}
|
|
90
|
+
) })
|
|
60
91
|
] }),
|
|
61
92
|
/* @__PURE__ */ s(
|
|
62
93
|
"button",
|
|
63
94
|
{
|
|
64
|
-
onClick:
|
|
65
|
-
className: "
|
|
66
|
-
children: /* @__PURE__ */ s(
|
|
95
|
+
onClick: d,
|
|
96
|
+
className: "shrink-0 cursor-pointer rounded-full transition active:animate-spin",
|
|
97
|
+
children: /* @__PURE__ */ s(
|
|
98
|
+
S,
|
|
99
|
+
{
|
|
100
|
+
className: a("h-6 w-6", i ? "text-slate-400" : "text-slate-base")
|
|
101
|
+
}
|
|
102
|
+
)
|
|
67
103
|
}
|
|
68
104
|
)
|
|
69
105
|
] }) })
|
|
@@ -71,36 +107,46 @@ function F({
|
|
|
71
107
|
}
|
|
72
108
|
);
|
|
73
109
|
}
|
|
74
|
-
const
|
|
75
|
-
const
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
},
|
|
79
|
-
return
|
|
80
|
-
},
|
|
81
|
-
success: (e,
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
type: "
|
|
101
|
-
|
|
102
|
-
|
|
110
|
+
const l = (e) => {
|
|
111
|
+
const t = F++, n = () => {
|
|
112
|
+
const c = m.findIndex((i) => i?.id === t);
|
|
113
|
+
c !== -1 && (m.splice(c, 1), N());
|
|
114
|
+
}, o = /* @__PURE__ */ s(j, { ...e, onClose: n });
|
|
115
|
+
return m.push({ id: t, element: o }), N(), e.duration !== 1 / 0 && setTimeout(n, (e.duration || 3e3) + 300), { close: n };
|
|
116
|
+
}, R = {
|
|
117
|
+
success: (e, t, n) => l(
|
|
118
|
+
typeof e == "string" ? { title: e, description: t, type: "success", action: n } : {
|
|
119
|
+
...e,
|
|
120
|
+
type: "success"
|
|
121
|
+
}
|
|
122
|
+
),
|
|
123
|
+
error: (e, t, n) => l(
|
|
124
|
+
typeof e == "string" ? { title: e, description: t, type: "error", action: n } : {
|
|
125
|
+
...e,
|
|
126
|
+
type: "error"
|
|
127
|
+
}
|
|
128
|
+
),
|
|
129
|
+
warning: (e, t, n) => l(
|
|
130
|
+
typeof e == "string" ? { title: e, description: t, type: "warning", action: n } : {
|
|
131
|
+
...e,
|
|
132
|
+
type: "warning"
|
|
133
|
+
}
|
|
134
|
+
),
|
|
135
|
+
info: (e, t, n) => l(
|
|
136
|
+
typeof e == "string" ? { title: e, description: t, type: "info", action: n } : {
|
|
137
|
+
...e,
|
|
138
|
+
type: "info"
|
|
139
|
+
}
|
|
140
|
+
),
|
|
141
|
+
loading: (e, t) => l(
|
|
142
|
+
typeof e == "string" ? {
|
|
143
|
+
title: e,
|
|
144
|
+
description: t,
|
|
145
|
+
type: "loading",
|
|
146
|
+
duration: 1 / 0
|
|
147
|
+
} : { ...e, type: "loading", duration: 1 / 0 }
|
|
148
|
+
)
|
|
103
149
|
};
|
|
104
150
|
export {
|
|
105
|
-
|
|
151
|
+
R as default
|
|
106
152
|
};
|