@mci-ui/mci-ui 0.0.98 → 0.0.99
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/shared/ui/mciTabs/FilledTabs.js +40 -39
- package/dist/shared/ui/mciTabs/OutlinedTabs.js +27 -26
- package/dist/types/shared/types/ui/tabs.types.d.ts +1 -0
- package/dist/types/shared/ui/mciTabs/FilledTabs.d.ts +1 -1
- package/dist/types/shared/ui/mciTabs/OutlinedTabs.d.ts +1 -1
- package/package.json +1 -1
|
@@ -1,68 +1,69 @@
|
|
|
1
1
|
import { jsxs as m, jsx as l } from "react/jsx-runtime";
|
|
2
|
-
import { useState as
|
|
2
|
+
import { useState as y, useRef as S, useCallback as F, useEffect as v, useMemo as q } from "react";
|
|
3
3
|
import { cn as n } from "../../lib/utils.js";
|
|
4
|
-
import
|
|
5
|
-
const
|
|
4
|
+
import B from "./TabCountBadge.js";
|
|
5
|
+
const W = {
|
|
6
6
|
top: "flex-col",
|
|
7
7
|
bottom: "flex-col-reverse",
|
|
8
8
|
left: "flex-row",
|
|
9
9
|
right: "flex-row-reverse"
|
|
10
|
-
},
|
|
10
|
+
}, D = {
|
|
11
11
|
top: "flex-row",
|
|
12
12
|
bottom: "flex-row",
|
|
13
13
|
left: "flex-col",
|
|
14
14
|
right: "flex-col"
|
|
15
|
-
},
|
|
15
|
+
}, H = {
|
|
16
16
|
top: "mt-4",
|
|
17
17
|
bottom: "mb-4",
|
|
18
18
|
left: "ml-4",
|
|
19
19
|
right: "mr-4"
|
|
20
20
|
};
|
|
21
|
-
function
|
|
21
|
+
function Q({
|
|
22
22
|
tabs: t,
|
|
23
|
-
defaultTab:
|
|
24
|
-
|
|
23
|
+
defaultTab: C,
|
|
24
|
+
activeTab: w,
|
|
25
|
+
position: a = "top",
|
|
25
26
|
darkMode: u = !1,
|
|
26
|
-
className:
|
|
27
|
+
className: E,
|
|
27
28
|
width: r,
|
|
28
|
-
tabListClassName:
|
|
29
|
+
tabListClassName: T,
|
|
29
30
|
contentClassName: A,
|
|
30
|
-
extra:
|
|
31
|
-
onChange:
|
|
31
|
+
extra: h,
|
|
32
|
+
onChange: z
|
|
32
33
|
}) {
|
|
33
|
-
const [
|
|
34
|
+
const [L, I] = y(C || t[0]?.id), p = w !== void 0, s = p ? w : L, [R, O] = y({}), d = S([]), N = S(null), o = F(() => {
|
|
34
35
|
requestAnimationFrame(() => {
|
|
35
36
|
requestAnimationFrame(() => {
|
|
36
|
-
const e = t.findIndex((
|
|
37
|
+
const e = t.findIndex((k) => k?.id === s), i = d.current[e];
|
|
37
38
|
if (!i) return;
|
|
38
|
-
const { offsetLeft:
|
|
39
|
-
|
|
40
|
-
left: `${
|
|
39
|
+
const { offsetLeft: f, offsetTop: x, offsetWidth: _, offsetHeight: $ } = i;
|
|
40
|
+
O({
|
|
41
|
+
left: `${f}px`,
|
|
41
42
|
top: `${x}px`,
|
|
42
|
-
width: `${
|
|
43
|
-
height: `${
|
|
43
|
+
width: `${_}px`,
|
|
44
|
+
height: `${$}px`,
|
|
44
45
|
transition: "all 0.35s cubic-bezier(0.25, 1, 0.5, 1)"
|
|
45
46
|
});
|
|
46
47
|
});
|
|
47
48
|
});
|
|
48
49
|
}, [s, t]);
|
|
49
|
-
v(() => (o(), window.addEventListener("resize", o), "fonts" in document && document.fonts.ready.then(o), () => window.removeEventListener("resize", o)), [
|
|
50
|
-
const e =
|
|
50
|
+
v(() => (o(), window.addEventListener("resize", o), "fonts" in document && document.fonts.ready.then(o), () => window.removeEventListener("resize", o)), [a, o]), v(() => {
|
|
51
|
+
const e = N.current;
|
|
51
52
|
if (!e || typeof ResizeObserver > "u") return;
|
|
52
53
|
const i = new ResizeObserver(() => {
|
|
53
54
|
o();
|
|
54
55
|
});
|
|
55
|
-
return i.observe(e), d.current.forEach((
|
|
56
|
-
|
|
56
|
+
return i.observe(e), d.current.forEach((f) => {
|
|
57
|
+
f && i.observe(f);
|
|
57
58
|
}), () => i.disconnect();
|
|
58
59
|
}, [t, o]), v(() => {
|
|
59
60
|
d.current = d.current.slice(0, t.length);
|
|
60
61
|
}, [t]);
|
|
61
|
-
const c =
|
|
62
|
+
const c = a === "left" || a === "right", g = typeof r == "string" && r.startsWith("w-") ? r : void 0, b = g ? void 0 : r, j = q(
|
|
62
63
|
() => t.find((e) => e.id === s)?.content,
|
|
63
64
|
[s, t]
|
|
64
65
|
);
|
|
65
|
-
return /* @__PURE__ */ m("div", { className: n("flex w-full",
|
|
66
|
+
return /* @__PURE__ */ m("div", { className: n("flex w-full", W[a], E), children: [
|
|
66
67
|
/* @__PURE__ */ m(
|
|
67
68
|
"div",
|
|
68
69
|
{
|
|
@@ -77,20 +78,20 @@ function G({
|
|
|
77
78
|
className: n(
|
|
78
79
|
r ? "flex-none" : "flex-1",
|
|
79
80
|
c ? "w-full" : !r && "min-w-[520px]",
|
|
80
|
-
|
|
81
|
+
g
|
|
81
82
|
),
|
|
82
|
-
style:
|
|
83
|
+
style: b !== void 0 ? { width: b } : void 0,
|
|
83
84
|
children: /* @__PURE__ */ m(
|
|
84
85
|
"div",
|
|
85
86
|
{
|
|
86
|
-
ref:
|
|
87
|
+
ref: N,
|
|
87
88
|
className: n(
|
|
88
89
|
"relative flex rounded-xl p-1",
|
|
89
90
|
u ? "bg-neutral-300" : "bg-slate-100",
|
|
90
|
-
|
|
91
|
+
D[a],
|
|
91
92
|
!c && [!r && "w-full", "overflow-hidden"],
|
|
92
93
|
c ? "min-w-48" : "",
|
|
93
|
-
|
|
94
|
+
T
|
|
94
95
|
),
|
|
95
96
|
children: [
|
|
96
97
|
/* @__PURE__ */ l(
|
|
@@ -101,11 +102,11 @@ function G({
|
|
|
101
102
|
u ? "bg-black" : "bg-white",
|
|
102
103
|
c ? "w-full" : "h-full"
|
|
103
104
|
),
|
|
104
|
-
style:
|
|
105
|
+
style: R
|
|
105
106
|
}
|
|
106
107
|
),
|
|
107
108
|
t?.map((e, i) => {
|
|
108
|
-
const
|
|
109
|
+
const f = s === e.id;
|
|
109
110
|
return /* @__PURE__ */ m(
|
|
110
111
|
"button",
|
|
111
112
|
{
|
|
@@ -113,7 +114,7 @@ function G({
|
|
|
113
114
|
d.current[i] = x;
|
|
114
115
|
},
|
|
115
116
|
onClick: () => {
|
|
116
|
-
e?.disabled || (
|
|
117
|
+
e?.disabled || (p || I(e?.id), z?.(e?.id));
|
|
117
118
|
},
|
|
118
119
|
disabled: e?.disabled,
|
|
119
120
|
className: n(
|
|
@@ -128,13 +129,13 @@ function G({
|
|
|
128
129
|
{
|
|
129
130
|
className: n(
|
|
130
131
|
"shrink-0 transition-transform duration-200",
|
|
131
|
-
|
|
132
|
+
f && "scale-110"
|
|
132
133
|
),
|
|
133
134
|
children: e?.icon
|
|
134
135
|
}
|
|
135
136
|
),
|
|
136
137
|
/* @__PURE__ */ l("span", { className: "relative z-10 truncate", title: e?.label, children: e?.label }),
|
|
137
|
-
/* @__PURE__ */ l(
|
|
138
|
+
/* @__PURE__ */ l(B, { count: e?.count })
|
|
138
139
|
]
|
|
139
140
|
},
|
|
140
141
|
e?.id
|
|
@@ -145,16 +146,16 @@ function G({
|
|
|
145
146
|
)
|
|
146
147
|
}
|
|
147
148
|
),
|
|
148
|
-
|
|
149
|
+
h && /* @__PURE__ */ l("div", { className: n("ml-auto shrink-0", c ? "w-full" : "max-w-full"), children: /* @__PURE__ */ l("div", { className: "flex flex-wrap items-center justify-end gap-2", children: h }) })
|
|
149
150
|
]
|
|
150
151
|
}
|
|
151
152
|
),
|
|
152
|
-
|
|
153
|
+
j && /* @__PURE__ */ l(
|
|
153
154
|
"div",
|
|
154
155
|
{
|
|
155
156
|
className: n(
|
|
156
157
|
"w-full flex-1 overflow-hidden",
|
|
157
|
-
|
|
158
|
+
H[a],
|
|
158
159
|
A
|
|
159
160
|
),
|
|
160
161
|
children: /* @__PURE__ */ l(
|
|
@@ -171,5 +172,5 @@ function G({
|
|
|
171
172
|
] });
|
|
172
173
|
}
|
|
173
174
|
export {
|
|
174
|
-
|
|
175
|
+
Q as default
|
|
175
176
|
};
|
|
@@ -1,49 +1,50 @@
|
|
|
1
1
|
import { jsxs as c, jsx as a } from "react/jsx-runtime";
|
|
2
|
-
import { useState as
|
|
2
|
+
import { useState as b, useRef as T, useEffect as O, useMemo as j } from "react";
|
|
3
3
|
import { cn as i } from "../../lib/utils.js";
|
|
4
4
|
import A from "./TabCountBadge.js";
|
|
5
|
-
const
|
|
5
|
+
const z = ({
|
|
6
6
|
tabs: e,
|
|
7
|
-
className:
|
|
8
|
-
contentClassName:
|
|
7
|
+
className: p,
|
|
8
|
+
contentClassName: w,
|
|
9
9
|
darkMode: l,
|
|
10
|
-
defaultTab:
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
defaultTab: B,
|
|
11
|
+
activeTab: d,
|
|
12
|
+
onChange: v,
|
|
13
|
+
tabClassName: y,
|
|
14
|
+
tabListClassName: C,
|
|
14
15
|
color: r = "orange"
|
|
15
16
|
}) => {
|
|
16
|
-
const [
|
|
17
|
-
|
|
18
|
-
const t =
|
|
17
|
+
const [R, k] = b(B || e[0]?.id), g = d !== void 0, n = g ? d : R, [u, N] = b({ left: 0, width: 0 }), h = T({}), f = T(null);
|
|
18
|
+
O(() => {
|
|
19
|
+
const t = h.current[n], o = f.current;
|
|
19
20
|
if (t && o) {
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
left:
|
|
23
|
-
width:
|
|
21
|
+
const L = o.getBoundingClientRect().left, m = t.getBoundingClientRect();
|
|
22
|
+
N({
|
|
23
|
+
left: m.left - L,
|
|
24
|
+
width: m.width
|
|
24
25
|
});
|
|
25
26
|
}
|
|
26
27
|
}, [n, e]);
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
},
|
|
28
|
+
const S = (t) => {
|
|
29
|
+
g || k(t), v?.(t);
|
|
30
|
+
}, x = j(
|
|
30
31
|
() => e.find((t) => t.id === n)?.content,
|
|
31
32
|
[n, e]
|
|
32
33
|
);
|
|
33
|
-
return /* @__PURE__ */ c("div", { className: i("space-y-4",
|
|
34
|
-
/* @__PURE__ */ c("div", { ref:
|
|
34
|
+
return /* @__PURE__ */ c("div", { className: i("space-y-4", p), children: [
|
|
35
|
+
/* @__PURE__ */ c("div", { ref: f, className: i("relative flex", C), children: [
|
|
35
36
|
e.map((t) => /* @__PURE__ */ c(
|
|
36
37
|
"button",
|
|
37
38
|
{
|
|
38
39
|
ref: (o) => {
|
|
39
|
-
|
|
40
|
+
h.current[t.id] = o;
|
|
40
41
|
},
|
|
41
|
-
onClick: () =>
|
|
42
|
+
onClick: () => S(t.id),
|
|
42
43
|
className: i(
|
|
43
44
|
"flex cursor-pointer items-center truncate border-b-2 px-3 py-2 text-sm font-medium transition-colors",
|
|
44
45
|
l ? "border-slate-200/20" : "border-slate-200",
|
|
45
46
|
n === t.id ? l ? s[r].darkText : s[r].lightText : l ? "text-slate-200/70 hover:text-slate-100" : "hover:text-primary text-slate-400",
|
|
46
|
-
|
|
47
|
+
y
|
|
47
48
|
),
|
|
48
49
|
children: [
|
|
49
50
|
/* @__PURE__ */ a("span", { className: "truncate", children: t.label }),
|
|
@@ -59,11 +60,11 @@ const _ = ({
|
|
|
59
60
|
"pointer-events-none absolute bottom-0 h-0.5 transition-all duration-300 ease-in-out",
|
|
60
61
|
l ? s[r].darkBg : s[r].lightBg
|
|
61
62
|
),
|
|
62
|
-
style: { left:
|
|
63
|
+
style: { left: u.left, width: u.width }
|
|
63
64
|
}
|
|
64
65
|
)
|
|
65
66
|
] }),
|
|
66
|
-
|
|
67
|
+
x && /* @__PURE__ */ a("div", { className: i("mt-4", w), children: x })
|
|
67
68
|
] });
|
|
68
69
|
}, s = {
|
|
69
70
|
orange: {
|
|
@@ -86,5 +87,5 @@ const _ = ({
|
|
|
86
87
|
}
|
|
87
88
|
};
|
|
88
89
|
export {
|
|
89
|
-
|
|
90
|
+
z as default
|
|
90
91
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { TabsProps } from '../../types/ui/tabs.types';
|
|
2
|
-
export default function FilledTabs({ tabs, defaultTab, position, darkMode, className, width, tabListClassName, contentClassName, extra, onChange, }: TabsProps): import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
export default function FilledTabs({ tabs, defaultTab, activeTab: activeTabProp, position, darkMode, className, width, tabListClassName, contentClassName, extra, onChange, }: TabsProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { TabsProps } from '../../types/ui';
|
|
2
|
-
declare const OutlinedTabs: ({ tabs, className, contentClassName, darkMode, defaultTab, onChange, tabClassName, tabListClassName, color, }: TabsProps) => import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
declare const OutlinedTabs: ({ tabs, className, contentClassName, darkMode, defaultTab, activeTab: activeTabProp, onChange, tabClassName, tabListClassName, color, }: TabsProps) => import("react/jsx-runtime").JSX.Element;
|
|
3
3
|
export default OutlinedTabs;
|