@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 i, jsx as n } from "react/jsx-runtime";
2
- import { useRef as G, useEffect as Y, useMemo as z, useState as f, useCallback as g } from "react";
3
- import { TransferVertical as q } from "@solar-icons/react";
4
- import { useClickOutside as H, cn as b } from "../../lib/utils.js";
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 J from "../mciCheck/MciCheck.js";
7
- function Z({
8
- open: m,
9
- onClose: w,
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: A,
12
- onToggle: N,
27
+ hidden: w,
28
+ onToggle: C,
13
29
  onMove: y,
14
- onMoveByKey: h,
15
- minVisible: C = 5
30
+ onMoveByKey: p,
31
+ minVisible: T = 5,
32
+ locale: F = "ru"
16
33
  }) {
17
- const T = G(null), { handleClick: p } = H(T, w);
18
- Y(() => {
19
- if (m)
20
- return document.addEventListener("mousedown", p), () => document.removeEventListener("mousedown", p);
21
- }, [m, p]);
22
- const x = z(() => new Set(A), [A]), I = z(() => {
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]), [v, S] = f(null), [O, k] = f(null), [F, E] = f(null), [u, D] = f("before"), L = g(
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
- ), d = g(() => {
33
- S(null), E(null), k(null), D("before");
34
- }, []), R = g(
49
+ ), g = b(() => {
50
+ O(null), L(null), A(null), N("before");
51
+ }, []), Y = b(
35
52
  (e, t, r) => {
36
- S(t), E(String(r)), k(null), D("before"), e.dataTransfer.effectAllowed = "move", e.dataTransfer.setData("text/plain", String(t));
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
- ), Q = g(
58
+ ), $ = b(
42
59
  (e, t) => {
43
60
  e.preventDefault();
44
- const r = v ?? Number.parseInt(e.dataTransfer.getData("text/plain") || "-1", 10);
61
+ const r = k ?? Number.parseInt(e.dataTransfer.getData("text/plain") || "-1", 10);
45
62
  if (!Number.isFinite(r) || r < 0) {
46
- d();
63
+ g();
47
64
  return;
48
65
  }
49
66
  const a = s[r], c = s[t];
50
67
  if (!a || !c) {
51
- d();
68
+ g();
52
69
  return;
53
70
  }
54
- const l = L(r, t, u);
55
- l !== r && (h ? h(a.key, c.key, u) : y(r, l)), d();
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, L, v, u, y, h, d]
58
- ), B = g(
74
+ [s, z, k, m, y, p, g]
75
+ ), B = b(
59
76
  (e, t) => {
60
- t || N(e);
77
+ t || C(e);
61
78
  },
62
- [N]
79
+ [C]
63
80
  );
64
- return m ? /* @__PURE__ */ i(
81
+ return i ? /* @__PURE__ */ u(
65
82
  "div",
66
83
  {
67
- ref: T,
68
- className: b(
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__ */ i("div", { className: "flex items-center justify-between gap-4", children: [
75
- /* @__PURE__ */ n("h4", { className: "text-slate-600 text-large font-normal", children: "Settings" }),
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: w,
97
+ onClick: D,
81
98
  className: "rounded-lg px-2 py-1 text-slate-500 hover:bg-slate-100",
82
- "aria-label": "Close",
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__ */ i("p", { className: "mb-3 text-xs text-slate-500", children: [
89
- "Active columns: ",
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: b(
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 <= C, c = O === t, l = F === e.key;
107
- return /* @__PURE__ */ i("div", { className: "relative", children: [
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: b(
129
+ className: f(
112
130
  "pointer-events-none absolute left-2 right-2 z-10 h-0.5 rounded-full bg-blue-300",
113
- u === "before" ? "top-0" : "bottom-0"
131
+ m === "before" ? "top-0" : "bottom-0"
114
132
  )
115
133
  }
116
134
  ),
117
- /* @__PURE__ */ i(
135
+ /* @__PURE__ */ u(
118
136
  "div",
119
137
  {
120
138
  draggable: !0,
121
- onDragStart: (o) => R(o, t, e.key),
139
+ onDragStart: (o) => Y(o, t, e.key),
122
140
  onDragOver: (o) => {
123
- if (v == null) return;
141
+ if (k == null) return;
124
142
  o.preventDefault(), o.dataTransfer.dropEffect = "move";
125
- const P = o.currentTarget.getBoundingClientRect(), j = o.clientY - P.top > P.height / 2 ? "after" : "before";
126
- O !== t && k(t), u !== j && D(j);
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) => Q(o, t),
129
- onDragEnd: d,
130
- className: b(
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: b(
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": "Drag",
150
- children: /* @__PURE__ */ n(q, { weight: "Linear", size: 20 })
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
- J,
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__ */ i("div", { className: "min-w-0 flex-1", children: [
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__ */ i("p", { className: "text-xs text-slate-400 mt-0.5", children: [
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
- Z as default
197
+ ee as default
184
198
  };
@@ -1,6 +1,7 @@
1
1
  import { ReactNode } from 'react';
2
2
  export type Align = 'left' | 'center' | 'right';
3
3
  export type ColumnKey<T> = Extract<keyof T, string>;
4
+ export type MciTablePanelLocale = 'ru' | 'uz';
4
5
  export type MciTableColumn<T> = {
5
6
  key: ColumnKey<T>;
6
7
  title: string;
@@ -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 {};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mci-ui/mci-ui",
3
3
  "private": false,
4
- "version": "0.0.85",
4
+ "version": "0.0.86",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "module": "./dist/index.js",