@mci-ui/mci-ui 0.0.85 → 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.
|
@@ -1,92 +1,110 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useRef as G, useEffect as
|
|
3
|
-
import { TransferVertical as
|
|
4
|
-
import { useClickOutside as
|
|
1
|
+
import { jsxs as u, jsx as n } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as G, useEffect as K, useMemo as j, useState as h, useCallback as b } from "react";
|
|
3
|
+
import { TransferVertical as _ } from "@solar-icons/react";
|
|
4
|
+
import { useClickOutside as q, cn as f } from "../../lib/utils.js";
|
|
5
5
|
/* empty css */
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
import H from "../mciCheck/MciCheck.js";
|
|
7
|
+
const J = {
|
|
8
|
+
ru: {
|
|
9
|
+
title: "Настройки",
|
|
10
|
+
close: "Закрыть",
|
|
11
|
+
activeColumns: "Активные колонки",
|
|
12
|
+
minColumns: (i) => `Минимум ${i} колонок`,
|
|
13
|
+
drag: "Перетащить"
|
|
14
|
+
},
|
|
15
|
+
uz: {
|
|
16
|
+
title: "Sozlamalar",
|
|
17
|
+
close: "Yopish",
|
|
18
|
+
activeColumns: "Aktiv ustunlar",
|
|
19
|
+
minColumns: (i) => `Kamida ${i} ta ustun`,
|
|
20
|
+
drag: "Sudrash"
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
function ee({
|
|
24
|
+
open: i,
|
|
25
|
+
onClose: D,
|
|
10
26
|
columns: s,
|
|
11
|
-
hidden:
|
|
12
|
-
onToggle:
|
|
27
|
+
hidden: w,
|
|
28
|
+
onToggle: C,
|
|
13
29
|
onMove: y,
|
|
14
|
-
onMoveByKey:
|
|
15
|
-
minVisible:
|
|
30
|
+
onMoveByKey: p,
|
|
31
|
+
minVisible: T = 5,
|
|
32
|
+
locale: F = "ru"
|
|
16
33
|
}) {
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
if (
|
|
20
|
-
return document.addEventListener("mousedown",
|
|
21
|
-
}, [
|
|
22
|
-
const x =
|
|
34
|
+
const S = G(null), { handleClick: v } = q(S, D), d = J[F];
|
|
35
|
+
K(() => {
|
|
36
|
+
if (i)
|
|
37
|
+
return document.addEventListener("mousedown", v), () => document.removeEventListener("mousedown", v);
|
|
38
|
+
}, [i, v]);
|
|
39
|
+
const x = j(() => new Set(w), [w]), I = j(() => {
|
|
23
40
|
let e = 0;
|
|
24
41
|
for (const t of s) x.has(t.key) || e++;
|
|
25
42
|
return e;
|
|
26
|
-
}, [s, x]), [
|
|
43
|
+
}, [s, x]), [k, O] = h(null), [E, A] = h(null), [Q, L] = h(null), [m, N] = h("before"), z = b(
|
|
27
44
|
(e, t, r) => {
|
|
28
45
|
let a = r === "after" ? t + 1 : t;
|
|
29
46
|
return e < a && (a -= 1), a;
|
|
30
47
|
},
|
|
31
48
|
[]
|
|
32
|
-
),
|
|
33
|
-
|
|
34
|
-
}, []),
|
|
49
|
+
), g = b(() => {
|
|
50
|
+
O(null), L(null), A(null), N("before");
|
|
51
|
+
}, []), Y = b(
|
|
35
52
|
(e, t, r) => {
|
|
36
|
-
|
|
53
|
+
O(t), L(String(r)), A(null), N("before"), e.dataTransfer.effectAllowed = "move", e.dataTransfer.setData("text/plain", String(t));
|
|
37
54
|
const a = new Image();
|
|
38
55
|
a.src = "data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=", e.dataTransfer.setDragImage(a, 0, 0);
|
|
39
56
|
},
|
|
40
57
|
[]
|
|
41
|
-
),
|
|
58
|
+
), $ = b(
|
|
42
59
|
(e, t) => {
|
|
43
60
|
e.preventDefault();
|
|
44
|
-
const r =
|
|
61
|
+
const r = k ?? Number.parseInt(e.dataTransfer.getData("text/plain") || "-1", 10);
|
|
45
62
|
if (!Number.isFinite(r) || r < 0) {
|
|
46
|
-
|
|
63
|
+
g();
|
|
47
64
|
return;
|
|
48
65
|
}
|
|
49
66
|
const a = s[r], c = s[t];
|
|
50
67
|
if (!a || !c) {
|
|
51
|
-
|
|
68
|
+
g();
|
|
52
69
|
return;
|
|
53
70
|
}
|
|
54
|
-
const l =
|
|
55
|
-
l !== r && (
|
|
71
|
+
const l = z(r, t, m);
|
|
72
|
+
l !== r && (p ? p(a.key, c.key, m) : y(r, l)), g();
|
|
56
73
|
},
|
|
57
|
-
[s,
|
|
58
|
-
), B =
|
|
74
|
+
[s, z, k, m, y, p, g]
|
|
75
|
+
), B = b(
|
|
59
76
|
(e, t) => {
|
|
60
|
-
t ||
|
|
77
|
+
t || C(e);
|
|
61
78
|
},
|
|
62
|
-
[
|
|
79
|
+
[C]
|
|
63
80
|
);
|
|
64
|
-
return
|
|
81
|
+
return i ? /* @__PURE__ */ u(
|
|
65
82
|
"div",
|
|
66
83
|
{
|
|
67
|
-
ref:
|
|
68
|
-
className:
|
|
84
|
+
ref: S,
|
|
85
|
+
className: f(
|
|
69
86
|
"absolute right-0 top-full z-50 mt-2 w-[320px]",
|
|
70
87
|
"rounded-2xl p-4 bg-white",
|
|
71
88
|
"border border-slate-200"
|
|
72
89
|
),
|
|
73
90
|
children: [
|
|
74
|
-
/* @__PURE__ */
|
|
75
|
-
/* @__PURE__ */ n("h4", { className: "text-slate-600 text-large font-normal", children:
|
|
91
|
+
/* @__PURE__ */ u("div", { className: "flex items-center justify-between gap-4", children: [
|
|
92
|
+
/* @__PURE__ */ n("h4", { className: "text-slate-600 text-large font-normal", children: d.title }),
|
|
76
93
|
/* @__PURE__ */ n(
|
|
77
94
|
"button",
|
|
78
95
|
{
|
|
79
96
|
type: "button",
|
|
80
|
-
onClick:
|
|
97
|
+
onClick: D,
|
|
81
98
|
className: "rounded-lg px-2 py-1 text-slate-500 hover:bg-slate-100",
|
|
82
|
-
"aria-label":
|
|
99
|
+
"aria-label": d.close,
|
|
83
100
|
children: "✕"
|
|
84
101
|
}
|
|
85
102
|
)
|
|
86
103
|
] }),
|
|
87
104
|
/* @__PURE__ */ n("div", { className: "my-4 h-px bg-slate-100" }),
|
|
88
|
-
/* @__PURE__ */
|
|
89
|
-
|
|
105
|
+
/* @__PURE__ */ u("p", { className: "mb-3 text-xs text-slate-500", children: [
|
|
106
|
+
d.activeColumns,
|
|
107
|
+
": ",
|
|
90
108
|
I,
|
|
91
109
|
"/",
|
|
92
110
|
s.length
|
|
@@ -94,7 +112,7 @@ function Z({
|
|
|
94
112
|
/* @__PURE__ */ n(
|
|
95
113
|
"div",
|
|
96
114
|
{
|
|
97
|
-
className:
|
|
115
|
+
className: f(
|
|
98
116
|
"max-h-[275px] overflow-auto",
|
|
99
117
|
"[&::-webkit-scrollbar]:w-1.5",
|
|
100
118
|
"[&::-webkit-scrollbar-track]:bg-transparent",
|
|
@@ -103,31 +121,31 @@ function Z({
|
|
|
103
121
|
"hover:[&::-webkit-scrollbar-thumb]:bg-slate-300"
|
|
104
122
|
),
|
|
105
123
|
children: s.map((e, t) => {
|
|
106
|
-
const r = !x.has(e.key), a = r && I <=
|
|
107
|
-
return /* @__PURE__ */
|
|
124
|
+
const r = !x.has(e.key), a = r && I <= T, c = E === t, l = Q === e.key;
|
|
125
|
+
return /* @__PURE__ */ u("div", { className: "relative", children: [
|
|
108
126
|
c && !l && /* @__PURE__ */ n(
|
|
109
127
|
"div",
|
|
110
128
|
{
|
|
111
|
-
className:
|
|
129
|
+
className: f(
|
|
112
130
|
"pointer-events-none absolute left-2 right-2 z-10 h-0.5 rounded-full bg-blue-300",
|
|
113
|
-
|
|
131
|
+
m === "before" ? "top-0" : "bottom-0"
|
|
114
132
|
)
|
|
115
133
|
}
|
|
116
134
|
),
|
|
117
|
-
/* @__PURE__ */
|
|
135
|
+
/* @__PURE__ */ u(
|
|
118
136
|
"div",
|
|
119
137
|
{
|
|
120
138
|
draggable: !0,
|
|
121
|
-
onDragStart: (o) =>
|
|
139
|
+
onDragStart: (o) => Y(o, t, e.key),
|
|
122
140
|
onDragOver: (o) => {
|
|
123
|
-
if (
|
|
141
|
+
if (k == null) return;
|
|
124
142
|
o.preventDefault(), o.dataTransfer.dropEffect = "move";
|
|
125
|
-
const P = o.currentTarget.getBoundingClientRect(),
|
|
126
|
-
|
|
143
|
+
const P = o.currentTarget.getBoundingClientRect(), R = o.clientY - P.top > P.height / 2 ? "after" : "before";
|
|
144
|
+
E !== t && A(t), m !== R && N(R);
|
|
127
145
|
},
|
|
128
|
-
onDrop: (o) =>
|
|
129
|
-
onDragEnd:
|
|
130
|
-
className:
|
|
146
|
+
onDrop: (o) => $(o, t),
|
|
147
|
+
onDragEnd: g,
|
|
148
|
+
className: f(
|
|
131
149
|
"group flex items-center py-2 px-1 gap-4",
|
|
132
150
|
"rounded-md box-border overflow-visible",
|
|
133
151
|
"transition-[background,transform] duration-150",
|
|
@@ -140,18 +158,18 @@ function Z({
|
|
|
140
158
|
"button",
|
|
141
159
|
{
|
|
142
160
|
type: "button",
|
|
143
|
-
className:
|
|
161
|
+
className: f(
|
|
144
162
|
"shrink-0 text-slate-400",
|
|
145
163
|
"cursor-grab active:cursor-grabbing",
|
|
146
164
|
"rounded-lg p-1 hover:bg-slate-100",
|
|
147
165
|
l && "cursor-grabbing"
|
|
148
166
|
),
|
|
149
|
-
"aria-label":
|
|
150
|
-
children: /* @__PURE__ */ n(
|
|
167
|
+
"aria-label": d.drag,
|
|
168
|
+
children: /* @__PURE__ */ n(_, { weight: "Linear", size: 20 })
|
|
151
169
|
}
|
|
152
170
|
),
|
|
153
171
|
/* @__PURE__ */ n("div", { className: "shrink-0", children: /* @__PURE__ */ n(
|
|
154
|
-
|
|
172
|
+
H,
|
|
155
173
|
{
|
|
156
174
|
checked: r,
|
|
157
175
|
disabled: a,
|
|
@@ -159,13 +177,9 @@ function Z({
|
|
|
159
177
|
variant: "blue"
|
|
160
178
|
}
|
|
161
179
|
) }),
|
|
162
|
-
/* @__PURE__ */
|
|
180
|
+
/* @__PURE__ */ u("div", { className: "min-w-0 flex-1", children: [
|
|
163
181
|
/* @__PURE__ */ n("h4", { className: "truncate text-slate-700 text-base font-medium", title: e.title, children: e.title }),
|
|
164
|
-
a && /* @__PURE__ */
|
|
165
|
-
"Минимум ",
|
|
166
|
-
C,
|
|
167
|
-
" колонок"
|
|
168
|
-
] })
|
|
182
|
+
a && /* @__PURE__ */ n("p", { className: "text-xs text-slate-400 mt-0.5", children: d.minColumns(T) })
|
|
169
183
|
] })
|
|
170
184
|
]
|
|
171
185
|
}
|
|
@@ -180,5 +194,5 @@ function Z({
|
|
|
180
194
|
) : null;
|
|
181
195
|
}
|
|
182
196
|
export {
|
|
183
|
-
|
|
197
|
+
ee as default
|
|
184
198
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ColumnKey, MciTableColumn } from '../../types/mci-table.types.ts';
|
|
1
|
+
import { ColumnKey, MciTableColumn, MciTablePanelLocale } from '../../types/mci-table.types.ts';
|
|
2
2
|
type DropPosition = 'before' | 'after';
|
|
3
3
|
type Props<T extends Record<string, unknown>> = {
|
|
4
4
|
open: boolean;
|
|
@@ -9,6 +9,7 @@ type Props<T extends Record<string, unknown>> = {
|
|
|
9
9
|
onMove: (from: number, to: number) => void;
|
|
10
10
|
onMoveByKey?: (from: ColumnKey<T>, to: ColumnKey<T>, position: DropPosition) => void;
|
|
11
11
|
minVisible?: number;
|
|
12
|
+
locale?: MciTablePanelLocale;
|
|
12
13
|
};
|
|
13
|
-
export default function MciTableColumnsPanel<T extends Record<string, unknown>>({ open, onClose, columns, hidden, onToggle, onMove, onMoveByKey, minVisible, }: Props<T>): import("react/jsx-runtime").JSX.Element | null;
|
|
14
|
+
export default function MciTableColumnsPanel<T extends Record<string, unknown>>({ open, onClose, columns, hidden, onToggle, onMove, onMoveByKey, minVisible, locale, }: Props<T>): import("react/jsx-runtime").JSX.Element | null;
|
|
14
15
|
export {};
|