@mci-ui/mci-ui 0.0.96 → 0.0.98
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.
|
@@ -1,95 +1,96 @@
|
|
|
1
1
|
import { jsxs as m, jsx as l } from "react/jsx-runtime";
|
|
2
|
-
import { useState as
|
|
2
|
+
import { useState as g, useRef as y, useCallback as _, useEffect as v, useMemo as $ } from "react";
|
|
3
3
|
import { cn as n } from "../../lib/utils.js";
|
|
4
|
-
import
|
|
5
|
-
const
|
|
4
|
+
import k from "./TabCountBadge.js";
|
|
5
|
+
const F = {
|
|
6
6
|
top: "flex-col",
|
|
7
7
|
bottom: "flex-col-reverse",
|
|
8
8
|
left: "flex-row",
|
|
9
9
|
right: "flex-row-reverse"
|
|
10
|
-
},
|
|
10
|
+
}, q = {
|
|
11
11
|
top: "flex-row",
|
|
12
12
|
bottom: "flex-row",
|
|
13
13
|
left: "flex-col",
|
|
14
14
|
right: "flex-col"
|
|
15
|
-
},
|
|
15
|
+
}, B = {
|
|
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 G({
|
|
22
22
|
tabs: t,
|
|
23
|
-
defaultTab:
|
|
24
|
-
position:
|
|
25
|
-
darkMode:
|
|
26
|
-
className:
|
|
27
|
-
width:
|
|
28
|
-
tabListClassName:
|
|
29
|
-
contentClassName:
|
|
23
|
+
defaultTab: b,
|
|
24
|
+
position: f = "top",
|
|
25
|
+
darkMode: u = !1,
|
|
26
|
+
className: S,
|
|
27
|
+
width: r,
|
|
28
|
+
tabListClassName: E,
|
|
29
|
+
contentClassName: A,
|
|
30
30
|
extra: w,
|
|
31
|
-
onChange:
|
|
31
|
+
onChange: C
|
|
32
32
|
}) {
|
|
33
|
-
const [
|
|
33
|
+
const [s, T] = g(b || t[0]?.id), [z, L] = g({}), d = y([]), h = y(null), o = _(() => {
|
|
34
34
|
requestAnimationFrame(() => {
|
|
35
35
|
requestAnimationFrame(() => {
|
|
36
|
-
const e = t.findIndex((
|
|
37
|
-
if (!
|
|
38
|
-
const { offsetLeft:
|
|
39
|
-
|
|
40
|
-
left: `${
|
|
36
|
+
const e = t.findIndex((j) => j?.id === s), i = d.current[e];
|
|
37
|
+
if (!i) return;
|
|
38
|
+
const { offsetLeft: a, offsetTop: x, offsetWidth: I, offsetHeight: O } = i;
|
|
39
|
+
L({
|
|
40
|
+
left: `${a}px`,
|
|
41
41
|
top: `${x}px`,
|
|
42
|
-
width: `${
|
|
43
|
-
height: `${
|
|
42
|
+
width: `${I}px`,
|
|
43
|
+
height: `${O}px`,
|
|
44
44
|
transition: "all 0.35s cubic-bezier(0.25, 1, 0.5, 1)"
|
|
45
45
|
});
|
|
46
46
|
});
|
|
47
47
|
});
|
|
48
|
-
}, [
|
|
49
|
-
v(() => (
|
|
48
|
+
}, [s, t]);
|
|
49
|
+
v(() => (o(), window.addEventListener("resize", o), "fonts" in document && document.fonts.ready.then(o), () => window.removeEventListener("resize", o)), [f, o]), v(() => {
|
|
50
50
|
const e = h.current;
|
|
51
51
|
if (!e || typeof ResizeObserver > "u") return;
|
|
52
|
-
const
|
|
53
|
-
|
|
52
|
+
const i = new ResizeObserver(() => {
|
|
53
|
+
o();
|
|
54
54
|
});
|
|
55
|
-
return
|
|
56
|
-
|
|
57
|
-
}), () =>
|
|
58
|
-
}, [t,
|
|
59
|
-
|
|
55
|
+
return i.observe(e), d.current.forEach((a) => {
|
|
56
|
+
a && i.observe(a);
|
|
57
|
+
}), () => i.disconnect();
|
|
58
|
+
}, [t, o]), v(() => {
|
|
59
|
+
d.current = d.current.slice(0, t.length);
|
|
60
60
|
}, [t]);
|
|
61
|
-
const
|
|
62
|
-
() => t.find((e) => e.id ===
|
|
63
|
-
[
|
|
61
|
+
const c = f === "left" || f === "right", p = typeof r == "string" && r.startsWith("w-") ? r : void 0, N = p ? void 0 : r, R = $(
|
|
62
|
+
() => t.find((e) => e.id === s)?.content,
|
|
63
|
+
[s, t]
|
|
64
64
|
);
|
|
65
|
-
return /* @__PURE__ */ m("div", { className: n("flex w-full",
|
|
65
|
+
return /* @__PURE__ */ m("div", { className: n("flex w-full", F[f], S), children: [
|
|
66
66
|
/* @__PURE__ */ m(
|
|
67
67
|
"div",
|
|
68
68
|
{
|
|
69
69
|
className: n(
|
|
70
70
|
"flex w-full gap-4",
|
|
71
|
-
|
|
71
|
+
c ? "flex-col items-start" : "flex-row flex-wrap items-center"
|
|
72
72
|
),
|
|
73
73
|
children: [
|
|
74
74
|
/* @__PURE__ */ l(
|
|
75
75
|
"div",
|
|
76
76
|
{
|
|
77
77
|
className: n(
|
|
78
|
-
|
|
79
|
-
|
|
78
|
+
r ? "flex-none" : "flex-1",
|
|
79
|
+
c ? "w-full" : !r && "min-w-[520px]",
|
|
80
|
+
p
|
|
80
81
|
),
|
|
81
|
-
style:
|
|
82
|
+
style: N !== void 0 ? { width: N } : void 0,
|
|
82
83
|
children: /* @__PURE__ */ m(
|
|
83
84
|
"div",
|
|
84
85
|
{
|
|
85
86
|
ref: h,
|
|
86
87
|
className: n(
|
|
87
88
|
"relative flex rounded-xl p-1",
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
!
|
|
91
|
-
|
|
92
|
-
|
|
89
|
+
u ? "bg-neutral-300" : "bg-slate-100",
|
|
90
|
+
q[f],
|
|
91
|
+
!c && [!r && "w-full", "overflow-hidden"],
|
|
92
|
+
c ? "min-w-48" : "",
|
|
93
|
+
E
|
|
93
94
|
),
|
|
94
95
|
children: [
|
|
95
96
|
/* @__PURE__ */ l(
|
|
@@ -97,29 +98,29 @@ function V({
|
|
|
97
98
|
{
|
|
98
99
|
className: n(
|
|
99
100
|
"absolute rounded-lg",
|
|
100
|
-
|
|
101
|
-
|
|
101
|
+
u ? "bg-black" : "bg-white",
|
|
102
|
+
c ? "w-full" : "h-full"
|
|
102
103
|
),
|
|
103
|
-
style:
|
|
104
|
+
style: z
|
|
104
105
|
}
|
|
105
106
|
),
|
|
106
|
-
t?.map((e,
|
|
107
|
-
const
|
|
107
|
+
t?.map((e, i) => {
|
|
108
|
+
const a = s === e.id;
|
|
108
109
|
return /* @__PURE__ */ m(
|
|
109
110
|
"button",
|
|
110
111
|
{
|
|
111
112
|
ref: (x) => {
|
|
112
|
-
|
|
113
|
+
d.current[i] = x;
|
|
113
114
|
},
|
|
114
115
|
onClick: () => {
|
|
115
|
-
e?.disabled || (
|
|
116
|
+
e?.disabled || (T(e?.id), C?.(e?.id));
|
|
116
117
|
},
|
|
117
118
|
disabled: e?.disabled,
|
|
118
119
|
className: n(
|
|
119
120
|
"relative z-10 flex cursor-pointer items-center justify-center px-3 py-2 text-base font-normal whitespace-nowrap transition-colors duration-300",
|
|
120
|
-
|
|
121
|
-
e?.disabled && (
|
|
122
|
-
|
|
121
|
+
u ? "text-white" : "text-black",
|
|
122
|
+
e?.disabled && (u ? "cursor-not-allowed text-neutral-100/50 opacity-60" : "cursor-not-allowed opacity-50"),
|
|
123
|
+
c ? "w-full justify-start" : "min-w-0 flex-1"
|
|
123
124
|
),
|
|
124
125
|
children: [
|
|
125
126
|
e?.icon && /* @__PURE__ */ l(
|
|
@@ -127,13 +128,13 @@ function V({
|
|
|
127
128
|
{
|
|
128
129
|
className: n(
|
|
129
130
|
"shrink-0 transition-transform duration-200",
|
|
130
|
-
|
|
131
|
+
a && "scale-110"
|
|
131
132
|
),
|
|
132
133
|
children: e?.icon
|
|
133
134
|
}
|
|
134
135
|
),
|
|
135
136
|
/* @__PURE__ */ l("span", { className: "relative z-10 truncate", title: e?.label, children: e?.label }),
|
|
136
|
-
/* @__PURE__ */ l(
|
|
137
|
+
/* @__PURE__ */ l(k, { count: e?.count })
|
|
137
138
|
]
|
|
138
139
|
},
|
|
139
140
|
e?.id
|
|
@@ -144,31 +145,31 @@ function V({
|
|
|
144
145
|
)
|
|
145
146
|
}
|
|
146
147
|
),
|
|
147
|
-
w && /* @__PURE__ */ l("div", { className: n("ml-auto shrink-0",
|
|
148
|
+
w && /* @__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: w }) })
|
|
148
149
|
]
|
|
149
150
|
}
|
|
150
151
|
),
|
|
151
|
-
|
|
152
|
+
R && /* @__PURE__ */ l(
|
|
152
153
|
"div",
|
|
153
154
|
{
|
|
154
155
|
className: n(
|
|
155
156
|
"w-full flex-1 overflow-hidden",
|
|
156
|
-
|
|
157
|
-
|
|
157
|
+
B[f],
|
|
158
|
+
A
|
|
158
159
|
),
|
|
159
160
|
children: /* @__PURE__ */ l(
|
|
160
161
|
"div",
|
|
161
162
|
{
|
|
162
163
|
className: "w-full animate-fade-in",
|
|
163
164
|
style: { animationDuration: "0.35s" },
|
|
164
|
-
children: t?.find((e) => e.id ===
|
|
165
|
+
children: t?.find((e) => e.id === s)?.content
|
|
165
166
|
},
|
|
166
|
-
|
|
167
|
+
s
|
|
167
168
|
)
|
|
168
169
|
}
|
|
169
170
|
)
|
|
170
171
|
] });
|
|
171
172
|
}
|
|
172
173
|
export {
|
|
173
|
-
|
|
174
|
+
G as default
|
|
174
175
|
};
|