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