@mci-ui/mci-ui 0.0.84 → 0.0.86
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/assets/icons/check.svg.js +5 -0
- package/dist/assets/icons/close.svg.js +5 -0
- package/dist/assets/icons/loaderIcon.svg.js +5 -0
- package/dist/index.js +53 -0
- package/dist/shared/lib/hooks/useTableColumnSettings.js +132 -0
- package/dist/shared/lib/locales.js +101 -0
- package/dist/shared/lib/uploadLanguage.js +80 -0
- package/dist/shared/lib/utils.js +20 -0
- package/dist/shared/ui/MciModal/MciModal.js +97 -0
- package/dist/shared/ui/mciAccordion/MciAccordion.js +74 -0
- package/dist/shared/ui/mciBreadcrumb/MciBreadcrumb.js +39 -0
- package/dist/shared/ui/mciButton/MciButton.js +63 -0
- package/dist/shared/ui/mciCheck/MciCheck.js +170 -0
- package/dist/shared/ui/mciCollapse/MciCollapse.js +60 -0
- package/dist/shared/ui/mciDrawer/MciDrawer.js +108 -0
- package/dist/shared/ui/mciIdentityInput/MciIdentityInput.js +30 -0
- package/dist/shared/ui/mciIdentityInput/mci-identity-input.utils.js +32 -0
- package/dist/shared/ui/mciInput/MciInput.js +225 -0
- package/dist/shared/ui/mciInput/mci-input.utils.js +49 -0
- package/dist/shared/ui/mciLoader/MciLoader.js +38 -0
- package/dist/shared/ui/mciPagination/MciPagination.js +135 -0
- package/dist/shared/ui/mciPagination/mci-pagination.utils.js +12 -0
- package/dist/shared/ui/mciPhone/MciPhone.js +83 -0
- package/dist/shared/ui/mciPhone/mci-phone.utils.js +47 -0
- package/dist/shared/ui/mciPicker/MciPicker.js +256 -0
- package/dist/shared/ui/mciPicker/mci-picker.utils.js +62 -0
- package/dist/shared/ui/mciSelect/MciSelect.js +226 -0
- package/dist/shared/ui/mciSelect/mci-select.utils.js +52 -0
- package/dist/shared/ui/mciSkeleton/MciSkeleton.js +29 -0
- package/dist/shared/ui/mciTable/MciTable.js +153 -0
- package/dist/shared/ui/mciTable/MciTableClamp2.js +7 -0
- package/dist/shared/ui/mciTable/MciTableColumnsPanel.js +198 -0
- package/dist/shared/ui/mciTable/mci-table.utils.js +14 -0
- package/dist/shared/ui/mciTabs/MciTabs.js +131 -0
- package/dist/shared/ui/mciTag/MciTag.js +46 -0
- package/dist/shared/ui/mciTextarea/MciTextarea.js +56 -0
- package/dist/shared/ui/mciToast/MciToast.js +106 -0
- package/dist/shared/ui/mciToast/mci-toast.utils.js +47 -0
- package/dist/shared/ui/mciToggle/MciToggle.js +77 -0
- package/dist/shared/ui/mciTooltip/MciTooltip.js +52 -0
- package/dist/shared/ui/mciUpload/MciUpload.js +337 -0
- package/dist/shared/ui/mciUpload/mci-upload.utils.js +186 -0
- package/dist/types/shared/types/mci-table.types.d.ts +1 -0
- package/dist/types/shared/ui/mciTable/MciTableColumnsPanel.d.ts +3 -2
- package/package.json +15 -12
- package/dist/index.es.js +0 -3387
- package/dist/index.umd.js +0 -2
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
function s(e) {
|
|
2
|
+
if (!e) return null;
|
|
3
|
+
const t = new Date(e);
|
|
4
|
+
return Number.isNaN(t.getTime()) ? null : t;
|
|
5
|
+
}
|
|
6
|
+
function l(e) {
|
|
7
|
+
return new Date(e.getFullYear(), e.getMonth(), e.getDate());
|
|
8
|
+
}
|
|
9
|
+
function c(e, t) {
|
|
10
|
+
if (!e) return "";
|
|
11
|
+
const n = e.getDate().toString().padStart(2, "0"), r = (e.getMonth() + 1).toString().padStart(2, "0"), i = e.getFullYear().toString();
|
|
12
|
+
return t.replace("DD", n).replace("MM", r).replace("YYYY", i);
|
|
13
|
+
}
|
|
14
|
+
function g(e) {
|
|
15
|
+
if (!e || e.length !== 10) return null;
|
|
16
|
+
const t = e.replace(/\D/g, "");
|
|
17
|
+
if (t.length !== 8) return null;
|
|
18
|
+
const n = parseInt(t.slice(0, 2), 10), r = parseInt(t.slice(2, 4), 10), i = parseInt(t.slice(4, 8), 10);
|
|
19
|
+
if (i < 1e3 || r < 1 || r > 12 || n < 1 || n > 31) return null;
|
|
20
|
+
const u = new Date(i, r - 1, n);
|
|
21
|
+
return u.getFullYear() !== i || u.getMonth() !== r - 1 || u.getDate() !== n ? null : u;
|
|
22
|
+
}
|
|
23
|
+
function f(e) {
|
|
24
|
+
let t = e.replace(/\D/g, "");
|
|
25
|
+
return t.length > 8 && (t = t.slice(0, 8)), t.length > 4 ? `${t.slice(0, 2)}.${t.slice(2, 4)}.${t.slice(4)}` : t.length > 2 ? `${t.slice(0, 2)}.${t.slice(2)}` : t;
|
|
26
|
+
}
|
|
27
|
+
function D(e, t, n) {
|
|
28
|
+
const r = l(e);
|
|
29
|
+
return !!(t && r < l(t) || n && r > l(n));
|
|
30
|
+
}
|
|
31
|
+
function h(e, t) {
|
|
32
|
+
return new Date(e.getFullYear(), e.getMonth() + t, 1);
|
|
33
|
+
}
|
|
34
|
+
function p(e, t) {
|
|
35
|
+
return new Date(e.getFullYear() + t, e.getMonth(), 1);
|
|
36
|
+
}
|
|
37
|
+
function M(e) {
|
|
38
|
+
const t = e.getFullYear(), n = e.getMonth(), r = new Date(t, n, 1).getDay(), i = new Date(t, n + 1, 0).getDate(), u = [];
|
|
39
|
+
for (let a = r; a > 0; a -= 1)
|
|
40
|
+
u.push({ date: new Date(t, n, 1 - a), isCurrentMonth: !1 });
|
|
41
|
+
for (let a = 1; a <= i; a += 1)
|
|
42
|
+
u.push({ date: new Date(t, n, a), isCurrentMonth: !0 });
|
|
43
|
+
const o = 42 - u.length;
|
|
44
|
+
for (let a = 1; a <= o; a += 1)
|
|
45
|
+
u.push({ date: new Date(t, n + 1, a), isCurrentMonth: !1 });
|
|
46
|
+
return u;
|
|
47
|
+
}
|
|
48
|
+
function m(e, t) {
|
|
49
|
+
return l(e).getTime() === l(t).getTime();
|
|
50
|
+
}
|
|
51
|
+
export {
|
|
52
|
+
c as formatDateByPattern,
|
|
53
|
+
f as formatManualDateInput,
|
|
54
|
+
M as getCalendarDays,
|
|
55
|
+
D as isDateOutsideBounds,
|
|
56
|
+
m as isSameCalendarDay,
|
|
57
|
+
l as normalizeDate,
|
|
58
|
+
g as parseDateFromInput,
|
|
59
|
+
h as shiftMonth,
|
|
60
|
+
p as shiftYear,
|
|
61
|
+
s as toSafeDate
|
|
62
|
+
};
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
import { jsxs as C, jsx as l } from "react/jsx-runtime";
|
|
2
|
+
import { AltArrowDown as ae } from "@solar-icons/react";
|
|
3
|
+
import oe from "../../../assets/icons/close.svg.js";
|
|
4
|
+
import { forwardRef as se, useState as g, useRef as q, useMemo as E, useCallback as d, useEffect as B } from "react";
|
|
5
|
+
import { useClickOutside as ce, useEscapeKey as ie, cn as o } from "../../lib/utils.js";
|
|
6
|
+
import { getFilteredOptions as ue, getSelectStateStyles as de, getSelectIconColor as fe, SELECT_SIZES as me } from "./mci-select.utils.js";
|
|
7
|
+
const pe = se(
|
|
8
|
+
({
|
|
9
|
+
label: _,
|
|
10
|
+
placeholder: D = "Выберите...",
|
|
11
|
+
options: I = [],
|
|
12
|
+
icon: x,
|
|
13
|
+
iconPosition: O = "left",
|
|
14
|
+
size: r = "base",
|
|
15
|
+
error: s,
|
|
16
|
+
disabled: t = !1,
|
|
17
|
+
required: G = !1,
|
|
18
|
+
value: u,
|
|
19
|
+
onChange: v,
|
|
20
|
+
onFocus: j,
|
|
21
|
+
onBlur: w,
|
|
22
|
+
className: J,
|
|
23
|
+
clearable: Q = !1,
|
|
24
|
+
searchable: f = !1,
|
|
25
|
+
onSearch: b,
|
|
26
|
+
name: A
|
|
27
|
+
}, X) => {
|
|
28
|
+
const [n, k] = g(!1), [L, R] = g(!1), [Y, P] = g(""), [T, m] = g(""), [y, c] = g(-1), U = q(null), F = q(null), p = u !== void 0 ? u : Y, W = I.find((e) => e.value === p), $ = p !== "" && p !== void 0, N = Q && $ && !t, S = !!(x && O === "right"), a = me[r], z = E(() => S && N ? r === "sm" || r === "md" ? "pr-16" : "pr-20" : S || N ? r === "sm" ? "pr-11" : r === "md" ? "pr-12" : "pr-14" : r === "sm" ? "pr-8" : r === "md" ? "pr-9" : "pr-10", [S, N, r]), i = E(() => ue(I, T, f, !!b), [I, T, f, b]), H = d(() => {
|
|
29
|
+
k(!1), R(!1), m(""), c(-1), w?.();
|
|
30
|
+
}, [w]), { handleClick: K } = ce(U, H), { handleEscape: M } = ie(H);
|
|
31
|
+
B(() => {
|
|
32
|
+
if (n)
|
|
33
|
+
return document.addEventListener("mousedown", K), document.addEventListener("keydown", M), () => {
|
|
34
|
+
document.removeEventListener("mousedown", K), document.removeEventListener("keydown", M);
|
|
35
|
+
};
|
|
36
|
+
}, [n, K, M]), B(() => {
|
|
37
|
+
n && f && F.current && F.current.focus();
|
|
38
|
+
}, [n, f]);
|
|
39
|
+
const ee = d(() => {
|
|
40
|
+
t || (k((e) => !e), n ? (m(""), c(-1)) : (R(!0), j?.()));
|
|
41
|
+
}, [t, n, j]), V = d(
|
|
42
|
+
(e) => {
|
|
43
|
+
u === void 0 && P(e), v?.(e), k(!1), R(!1), m(""), c(-1), w?.();
|
|
44
|
+
},
|
|
45
|
+
[u, v, w]
|
|
46
|
+
), te = d(
|
|
47
|
+
(e) => {
|
|
48
|
+
if (!t) {
|
|
49
|
+
if (!n && (e.key === "ArrowDown" || e.key === "ArrowUp" || e.key === "Enter")) {
|
|
50
|
+
e.preventDefault(), k(!0);
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
if (n)
|
|
54
|
+
switch (e.key) {
|
|
55
|
+
case "ArrowDown":
|
|
56
|
+
e.preventDefault(), c(
|
|
57
|
+
(h) => h < i.length - 1 ? h + 1 : 0
|
|
58
|
+
);
|
|
59
|
+
break;
|
|
60
|
+
case "ArrowUp":
|
|
61
|
+
e.preventDefault(), c(
|
|
62
|
+
(h) => h > 0 ? h - 1 : i.length - 1
|
|
63
|
+
);
|
|
64
|
+
break;
|
|
65
|
+
case "Enter":
|
|
66
|
+
e.preventDefault(), y >= 0 && i[y] && V(i[y].value);
|
|
67
|
+
break;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
[n, i, y, t, V]
|
|
72
|
+
), ne = d(
|
|
73
|
+
(e) => {
|
|
74
|
+
e.stopPropagation(), !t && (u === void 0 && P(""), v?.(""), m(""), c(-1));
|
|
75
|
+
},
|
|
76
|
+
[u, v, t]
|
|
77
|
+
), re = d(
|
|
78
|
+
(e) => {
|
|
79
|
+
m(e), b?.(e), c(0);
|
|
80
|
+
},
|
|
81
|
+
[b]
|
|
82
|
+
), le = E(() => de(t, s), [s, t]), Z = E(
|
|
83
|
+
() => fe(t, s, n, L),
|
|
84
|
+
[t, s, n, L]
|
|
85
|
+
);
|
|
86
|
+
return /* @__PURE__ */ C("div", { className: o("w-full", J), ref: X, children: [
|
|
87
|
+
_ && /* @__PURE__ */ C(
|
|
88
|
+
"label",
|
|
89
|
+
{
|
|
90
|
+
htmlFor: A,
|
|
91
|
+
className: o(
|
|
92
|
+
"mb-2 block text-base font-medium",
|
|
93
|
+
s ? "text-red-600" : "text-slate-700",
|
|
94
|
+
a.label
|
|
95
|
+
),
|
|
96
|
+
children: [
|
|
97
|
+
_,
|
|
98
|
+
G && /* @__PURE__ */ l("span", { className: "ml-1 text-red-600", children: "*" })
|
|
99
|
+
]
|
|
100
|
+
}
|
|
101
|
+
),
|
|
102
|
+
/* @__PURE__ */ C(
|
|
103
|
+
"div",
|
|
104
|
+
{
|
|
105
|
+
ref: U,
|
|
106
|
+
className: "relative",
|
|
107
|
+
onKeyDown: te,
|
|
108
|
+
children: [
|
|
109
|
+
/* @__PURE__ */ C(
|
|
110
|
+
"div",
|
|
111
|
+
{
|
|
112
|
+
role: "combobox",
|
|
113
|
+
"aria-expanded": n,
|
|
114
|
+
"aria-haspopup": "listbox",
|
|
115
|
+
"aria-controls": `${A}-listbox`,
|
|
116
|
+
"aria-disabled": t,
|
|
117
|
+
tabIndex: t ? -1 : 0,
|
|
118
|
+
onClick: ee,
|
|
119
|
+
className: o(
|
|
120
|
+
"flex w-full items-center border font-normal transition-all duration-300 ease-in-out",
|
|
121
|
+
r === "base" ? "rounded-xl" : "rounded-lg",
|
|
122
|
+
a.container,
|
|
123
|
+
x && O === "left" ? a.iconPaddingLeft : a.padding,
|
|
124
|
+
z,
|
|
125
|
+
le,
|
|
126
|
+
!t && L && "shadow-blue border-blue-600"
|
|
127
|
+
),
|
|
128
|
+
children: [
|
|
129
|
+
x && /* @__PURE__ */ l(
|
|
130
|
+
"div",
|
|
131
|
+
{
|
|
132
|
+
className: o(
|
|
133
|
+
"absolute top-1/2 -translate-y-1/2 pointer-events-none transition-colors duration-300",
|
|
134
|
+
O === "left" ? a.iconWrapper : a.rightIconWrapper,
|
|
135
|
+
Z
|
|
136
|
+
),
|
|
137
|
+
children: x
|
|
138
|
+
}
|
|
139
|
+
),
|
|
140
|
+
f && n ? /* @__PURE__ */ l(
|
|
141
|
+
"input",
|
|
142
|
+
{
|
|
143
|
+
ref: F,
|
|
144
|
+
type: "text",
|
|
145
|
+
value: T,
|
|
146
|
+
onChange: (e) => re(e.target.value),
|
|
147
|
+
placeholder: D,
|
|
148
|
+
className: "w-full min-w-0 flex-1 bg-transparent outline-none",
|
|
149
|
+
onClick: (e) => e.stopPropagation()
|
|
150
|
+
}
|
|
151
|
+
) : /* @__PURE__ */ l(
|
|
152
|
+
"span",
|
|
153
|
+
{
|
|
154
|
+
title: W?.label || D,
|
|
155
|
+
className: o(
|
|
156
|
+
"block min-w-0 flex-1 truncate select-none",
|
|
157
|
+
!$ && !t && "text-slate-400"
|
|
158
|
+
),
|
|
159
|
+
children: W?.label || D
|
|
160
|
+
}
|
|
161
|
+
),
|
|
162
|
+
N && /* @__PURE__ */ l(
|
|
163
|
+
"button",
|
|
164
|
+
{
|
|
165
|
+
type: "button",
|
|
166
|
+
onClick: ne,
|
|
167
|
+
className: o(
|
|
168
|
+
"absolute top-1/2 -translate-y-1/2 text-slate-400 hover:text-black transition-colors cursor-pointer",
|
|
169
|
+
S ? r === "sm" ? "right-8" : r === "md" ? "right-9" : "right-10" : r === "sm" ? "right-7" : r === "md" ? "right-8" : "right-9"
|
|
170
|
+
),
|
|
171
|
+
"aria-label": "Очистить",
|
|
172
|
+
children: /* @__PURE__ */ l(oe, { className: a.iconSize })
|
|
173
|
+
}
|
|
174
|
+
),
|
|
175
|
+
/* @__PURE__ */ l(
|
|
176
|
+
"div",
|
|
177
|
+
{
|
|
178
|
+
className: o(
|
|
179
|
+
"absolute top-1/2 -translate-y-1/2 pointer-events-none transition-all duration-300",
|
|
180
|
+
r === "sm" ? "right-2" : "right-3",
|
|
181
|
+
n && "rotate-180",
|
|
182
|
+
Z
|
|
183
|
+
),
|
|
184
|
+
children: /* @__PURE__ */ l(ae, { className: a.iconSize })
|
|
185
|
+
}
|
|
186
|
+
)
|
|
187
|
+
]
|
|
188
|
+
}
|
|
189
|
+
),
|
|
190
|
+
n && !t && /* @__PURE__ */ l(
|
|
191
|
+
"div",
|
|
192
|
+
{
|
|
193
|
+
id: `${A}-listbox`,
|
|
194
|
+
role: "listbox",
|
|
195
|
+
className: o(
|
|
196
|
+
"absolute z-50 mt-1 max-h-60 w-full overflow-y-auto rounded-lg border border-slate-200 bg-white shadow-md p-1 text-black",
|
|
197
|
+
a.dropdown
|
|
198
|
+
),
|
|
199
|
+
children: i.length === 0 ? /* @__PURE__ */ l("div", { className: "px-3 py-2 text-center text-base font-normal text-slate-500", children: "Ничего не найдено" }) : i.map((e) => /* @__PURE__ */ l(
|
|
200
|
+
"div",
|
|
201
|
+
{
|
|
202
|
+
role: "option",
|
|
203
|
+
"aria-selected": p === e.value,
|
|
204
|
+
onClick: () => V(e.value),
|
|
205
|
+
title: e.label,
|
|
206
|
+
className: o(
|
|
207
|
+
"cursor-pointer truncate px-3 py-2 font-normal transition-colors hover:bg-slate-100 rounded-sm",
|
|
208
|
+
p === e.value ? "bg-slate-100" : ""
|
|
209
|
+
),
|
|
210
|
+
children: e.label
|
|
211
|
+
},
|
|
212
|
+
e.value
|
|
213
|
+
))
|
|
214
|
+
}
|
|
215
|
+
)
|
|
216
|
+
]
|
|
217
|
+
}
|
|
218
|
+
),
|
|
219
|
+
s && /* @__PURE__ */ l("p", { className: "mt-2 animate-[slideDown_0.3s_ease-out] text-sm font-normal text-red-600", children: s })
|
|
220
|
+
] });
|
|
221
|
+
}
|
|
222
|
+
);
|
|
223
|
+
pe.displayName = "MciSelect";
|
|
224
|
+
export {
|
|
225
|
+
pe as default
|
|
226
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
const a = {
|
|
2
|
+
sm: {
|
|
3
|
+
container: "h-9 text-sm",
|
|
4
|
+
padding: "px-2",
|
|
5
|
+
iconPaddingLeft: "pl-7",
|
|
6
|
+
iconPaddingRight: "pr-7",
|
|
7
|
+
iconSize: "w-4 h-4",
|
|
8
|
+
iconWrapper: "left-2",
|
|
9
|
+
rightIconWrapper: "right-2",
|
|
10
|
+
label: "text-sm",
|
|
11
|
+
dropdown: "text-sm"
|
|
12
|
+
},
|
|
13
|
+
md: {
|
|
14
|
+
container: "h-10 text-sm",
|
|
15
|
+
padding: "px-4",
|
|
16
|
+
iconPaddingLeft: "pl-8",
|
|
17
|
+
iconPaddingRight: "pr-8",
|
|
18
|
+
iconSize: "w-5 h-5",
|
|
19
|
+
iconWrapper: "left-3",
|
|
20
|
+
rightIconWrapper: "right-3",
|
|
21
|
+
label: "text-sm",
|
|
22
|
+
dropdown: "text-sm"
|
|
23
|
+
},
|
|
24
|
+
base: {
|
|
25
|
+
container: "h-12 text-base",
|
|
26
|
+
padding: "px-4",
|
|
27
|
+
iconPaddingLeft: "pl-10",
|
|
28
|
+
iconPaddingRight: "pr-10",
|
|
29
|
+
iconSize: "w-5 h-5",
|
|
30
|
+
iconWrapper: "left-4",
|
|
31
|
+
rightIconWrapper: "right-16",
|
|
32
|
+
label: "text-base",
|
|
33
|
+
dropdown: "text-base"
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
function d(e, t, r, n) {
|
|
37
|
+
if (!r || n) return e;
|
|
38
|
+
const i = t.toLowerCase();
|
|
39
|
+
return e.filter((o) => o.label.toLowerCase().includes(i));
|
|
40
|
+
}
|
|
41
|
+
function l(e, t) {
|
|
42
|
+
return e ? "border-slate-200 bg-slate-100 text-slate-400 cursor-not-allowed" : t ? "border-red-600 focus:border-red-600 shadow-red bg-white" : "border-slate-200 hover:border-slate-400 focus:shadow-blue focus:border-blue-600 bg-white";
|
|
43
|
+
}
|
|
44
|
+
function c(e, t, r, n) {
|
|
45
|
+
return e ? "text-slate-400" : t ? "text-red-600" : r || n ? "text-black" : "text-slate-400";
|
|
46
|
+
}
|
|
47
|
+
export {
|
|
48
|
+
a as SELECT_SIZES,
|
|
49
|
+
d as getFilteredOptions,
|
|
50
|
+
c as getSelectIconColor,
|
|
51
|
+
l as getSelectStateStyles
|
|
52
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { jsx as d } from "react/jsx-runtime";
|
|
2
|
+
import { cn as m } from "../../lib/utils.js";
|
|
3
|
+
function t({
|
|
4
|
+
className: l,
|
|
5
|
+
variant: o = "default",
|
|
6
|
+
width: e = "100%",
|
|
7
|
+
height: r = "1rem"
|
|
8
|
+
}) {
|
|
9
|
+
return /* @__PURE__ */ d(
|
|
10
|
+
"div",
|
|
11
|
+
{
|
|
12
|
+
className: m(
|
|
13
|
+
"relative overflow-hidden bg-slate-200",
|
|
14
|
+
"rounded-lg",
|
|
15
|
+
o === "circle" && "rounded-full",
|
|
16
|
+
o === "rounded" && "rounded-md",
|
|
17
|
+
l
|
|
18
|
+
),
|
|
19
|
+
style: {
|
|
20
|
+
width: typeof e == "number" ? `${e}px` : e,
|
|
21
|
+
height: typeof r == "number" ? `${r}px` : r
|
|
22
|
+
},
|
|
23
|
+
children: /* @__PURE__ */ d("div", { className: "shimmer-mask absolute inset-0" })
|
|
24
|
+
}
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
export {
|
|
28
|
+
t as default
|
|
29
|
+
};
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { jsx as t, jsxs as r } from "react/jsx-runtime";
|
|
2
|
+
import { ConfoundedSquare as E, SortVertical as G, SortFromTopToBottom as I, SortFromBottomToTop as W } from "@solar-icons/react";
|
|
3
|
+
import { useState as _, useMemo as k, useEffect as H, useCallback as J } from "react";
|
|
4
|
+
import { cn as h } from "../../lib/utils.js";
|
|
5
|
+
/* empty css */
|
|
6
|
+
import T from "../mciCheck/MciCheck.js";
|
|
7
|
+
import z from "../mciSkeleton/MciSkeleton.js";
|
|
8
|
+
import K from "./MciTableClamp2.js";
|
|
9
|
+
import { sortRows as O, normalizeColWidth as Q } from "./mci-table.utils.js";
|
|
10
|
+
function le({
|
|
11
|
+
columns: m,
|
|
12
|
+
data: y = [],
|
|
13
|
+
loading: b = !1,
|
|
14
|
+
skeletonRows: A = 5,
|
|
15
|
+
noDataText: M = "",
|
|
16
|
+
sort: a,
|
|
17
|
+
onSortChange: v,
|
|
18
|
+
className: B,
|
|
19
|
+
headerClassName: N,
|
|
20
|
+
bodyClassName: w,
|
|
21
|
+
rowKey: f = "id",
|
|
22
|
+
rowSelection: l
|
|
23
|
+
}) {
|
|
24
|
+
const [D, C] = _(null), n = a ?? D, u = k(() => Array.isArray(y) ? y : [], [y]), R = k(() => O(u, n, !!a), [u, n, a]);
|
|
25
|
+
H(() => {
|
|
26
|
+
a !== void 0 && C(null);
|
|
27
|
+
}, [a]);
|
|
28
|
+
const o = k(
|
|
29
|
+
() => b ? [] : a ? u : R,
|
|
30
|
+
[b, a, u, R]
|
|
31
|
+
), L = J(
|
|
32
|
+
(e) => {
|
|
33
|
+
if (!e.sortable) return;
|
|
34
|
+
let s = null;
|
|
35
|
+
n?.key !== e.key ? s = { key: e.key, direction: "asc" } : n.direction === "asc" && (s = { key: e.key, direction: "desc" }), a !== void 0 ? v?.(s) : C(s);
|
|
36
|
+
},
|
|
37
|
+
[n, a, v]
|
|
38
|
+
), P = (e) => {
|
|
39
|
+
if (!l) return;
|
|
40
|
+
const { onChange: s, getCheckboxProps: c } = l;
|
|
41
|
+
if (e.target.checked) {
|
|
42
|
+
const i = o.filter((d) => !c?.(d)?.disabled).map((d) => d[f]);
|
|
43
|
+
s(i);
|
|
44
|
+
} else
|
|
45
|
+
s([]);
|
|
46
|
+
}, F = (e, s) => {
|
|
47
|
+
if (!l) return;
|
|
48
|
+
const { selectedRowKeys: c, onChange: g } = l, p = e[f], i = s ? [...c, p] : c.filter((d) => d !== p);
|
|
49
|
+
g(i);
|
|
50
|
+
}, V = k(() => {
|
|
51
|
+
if (!l || o.length === 0) return !1;
|
|
52
|
+
const e = o.filter((s) => !l.getCheckboxProps?.(s)?.disabled);
|
|
53
|
+
return e.length === 0 ? !1 : e.every(
|
|
54
|
+
(s) => l.selectedRowKeys.includes(s[f])
|
|
55
|
+
);
|
|
56
|
+
}, [l, o, f]), q = (e) => e.sortable ? !n || n.key !== e.key ? /* @__PURE__ */ t(G, { weight: "Linear", size: 20, className: "text-slate-base shrink-0" }) : n.direction === "asc" ? /* @__PURE__ */ t(I, { weight: "Linear", size: 20, className: "text-slate-base shrink-0" }) : /* @__PURE__ */ t(W, { weight: "Linear", size: 20, className: "text-slate-base shrink-0" }) : null, j = () => /* @__PURE__ */ r("colgroup", { children: [
|
|
57
|
+
l && /* @__PURE__ */ t("col", { style: { width: 48 } }),
|
|
58
|
+
m.map((e) => /* @__PURE__ */ t("col", { style: { width: Q(e.width) ?? "auto" } }, e.key))
|
|
59
|
+
] });
|
|
60
|
+
return /* @__PURE__ */ t(
|
|
61
|
+
"div",
|
|
62
|
+
{
|
|
63
|
+
className: h(
|
|
64
|
+
"w-full overflow-x-auto pb-0.5",
|
|
65
|
+
"[&::-webkit-scrollbar]:h-1",
|
|
66
|
+
"[&::-webkit-scrollbar-track]:bg-transparent",
|
|
67
|
+
"[&::-webkit-scrollbar-thumb]:bg-slate-200",
|
|
68
|
+
"[&::-webkit-scrollbar-thumb]:rounded-full",
|
|
69
|
+
"hover:[&::-webkit-scrollbar-thumb]:bg-slate-300",
|
|
70
|
+
B
|
|
71
|
+
),
|
|
72
|
+
children: /* @__PURE__ */ r("div", { className: "inline-block min-w-full align-middle", children: [
|
|
73
|
+
/* @__PURE__ */ t("div", { className: "overflow-hidden rounded-xl border border-slate-200 bg-slate-100", children: /* @__PURE__ */ r("table", { className: "w-full table-fixed", children: [
|
|
74
|
+
j(),
|
|
75
|
+
/* @__PURE__ */ t("thead", { children: /* @__PURE__ */ r("tr", { children: [
|
|
76
|
+
l && /* @__PURE__ */ t("th", { className: h("w-12 px-4 py-3", N), children: /* @__PURE__ */ t("div", { className: "flex items-center justify-center", children: /* @__PURE__ */ t(
|
|
77
|
+
T,
|
|
78
|
+
{
|
|
79
|
+
checked: V,
|
|
80
|
+
onChange: P,
|
|
81
|
+
variant: "yellow",
|
|
82
|
+
disabled: b || o.length === 0
|
|
83
|
+
}
|
|
84
|
+
) }) }),
|
|
85
|
+
m.map((e) => /* @__PURE__ */ t(
|
|
86
|
+
"th",
|
|
87
|
+
{
|
|
88
|
+
onClick: () => L(e),
|
|
89
|
+
className: h(
|
|
90
|
+
"px-4 py-3 text-left text-sm font-medium text-slate-700 transition-colors",
|
|
91
|
+
"whitespace-nowrap overflow-hidden text-ellipsis",
|
|
92
|
+
e.align === "center" && "text-center",
|
|
93
|
+
e.align === "right" && "text-right",
|
|
94
|
+
e.sortable && "cursor-pointer hover:bg-slate-200",
|
|
95
|
+
N
|
|
96
|
+
),
|
|
97
|
+
children: /* @__PURE__ */ r("div", { className: h("flex items-center gap-2 min-w-0", e.align === "right" && "justify-end"), children: [
|
|
98
|
+
/* @__PURE__ */ t("span", { className: "min-w-0 flex-1 truncate", title: e.title, children: e.title }),
|
|
99
|
+
q(e)
|
|
100
|
+
] })
|
|
101
|
+
},
|
|
102
|
+
e.key
|
|
103
|
+
))
|
|
104
|
+
] }) })
|
|
105
|
+
] }) }),
|
|
106
|
+
/* @__PURE__ */ t("div", { className: "rounded-xl border border-t-0 border-slate-200 bg-white overflow-hidden", children: /* @__PURE__ */ r("table", { className: "w-full table-fixed", children: [
|
|
107
|
+
j(),
|
|
108
|
+
/* @__PURE__ */ t("tbody", { className: "divide-y divide-slate-200", children: b ? Array.from({ length: A }).map((e, s) => /* @__PURE__ */ r("tr", { children: [
|
|
109
|
+
l && /* @__PURE__ */ t("td", { className: "w-12 px-4 py-3", children: /* @__PURE__ */ t(z, { height: 20, width: 20, variant: "rounded" }) }),
|
|
110
|
+
m.map((c) => /* @__PURE__ */ t("td", { className: "px-4 py-3", children: /* @__PURE__ */ t(z, { height: 30, variant: "rounded" }) }, c.key))
|
|
111
|
+
] }, s)) : o.length === 0 ? /* @__PURE__ */ t("tr", { children: /* @__PURE__ */ t("td", { colSpan: m.length + (l ? 1 : 0), className: "py-20", children: /* @__PURE__ */ r("div", { className: "flex flex-col items-center justify-center", children: [
|
|
112
|
+
/* @__PURE__ */ t("div", { className: "relative mb-4", children: /* @__PURE__ */ t(E, { weight: "Bold", size: 64, className: "animate-float text-slate-400" }) }),
|
|
113
|
+
/* @__PURE__ */ t("p", { className: "text-sm font-medium text-slate-400", children: M })
|
|
114
|
+
] }) }) }) : o.map((e, s) => {
|
|
115
|
+
const c = e[f], g = l?.selectedRowKeys.includes(c), p = l?.getCheckboxProps?.(e)?.disabled;
|
|
116
|
+
return /* @__PURE__ */ r("tr", { className: "group transition-colors hover:bg-slate-50", children: [
|
|
117
|
+
l && /* @__PURE__ */ t("td", { className: h("w-12 px-4 py-3 align-top", w), children: /* @__PURE__ */ t("div", { className: "flex items-center justify-center pt-1", children: /* @__PURE__ */ t(
|
|
118
|
+
T,
|
|
119
|
+
{
|
|
120
|
+
checked: g,
|
|
121
|
+
disabled: p,
|
|
122
|
+
variant: "yellow",
|
|
123
|
+
onChange: (i) => F(e, i.target.checked)
|
|
124
|
+
}
|
|
125
|
+
) }) }),
|
|
126
|
+
m.map((i) => {
|
|
127
|
+
const d = e[i.key], x = i.render ? i.render(d, e) : String(d ?? "-");
|
|
128
|
+
return /* @__PURE__ */ t(
|
|
129
|
+
"td",
|
|
130
|
+
{
|
|
131
|
+
className: h(
|
|
132
|
+
"align-top px-4 py-3 text-sm font-normal text-black",
|
|
133
|
+
"min-w-0 whitespace-normal",
|
|
134
|
+
i.align === "center" && "text-center",
|
|
135
|
+
i.align === "right" && "text-right",
|
|
136
|
+
w,
|
|
137
|
+
i.className
|
|
138
|
+
),
|
|
139
|
+
children: /* @__PURE__ */ t(K, { title: typeof x == "string" ? x : void 0, children: x })
|
|
140
|
+
},
|
|
141
|
+
i.key
|
|
142
|
+
);
|
|
143
|
+
})
|
|
144
|
+
] }, s);
|
|
145
|
+
}) })
|
|
146
|
+
] }) })
|
|
147
|
+
] })
|
|
148
|
+
}
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
export {
|
|
152
|
+
le as default
|
|
153
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsx as e } from "react/jsx-runtime";
|
|
2
|
+
function l({ children: t, title: a }) {
|
|
3
|
+
return /* @__PURE__ */ e("div", { className: "min-w-0", children: /* @__PURE__ */ e("div", { className: "clamp-2 break-words", title: a ?? (typeof t == "string" ? t : void 0), children: t }) });
|
|
4
|
+
}
|
|
5
|
+
export {
|
|
6
|
+
l as default
|
|
7
|
+
};
|