@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.
Files changed (47) hide show
  1. package/dist/assets/icons/check.svg.js +5 -0
  2. package/dist/assets/icons/close.svg.js +5 -0
  3. package/dist/assets/icons/loaderIcon.svg.js +5 -0
  4. package/dist/index.js +53 -0
  5. package/dist/shared/lib/hooks/useTableColumnSettings.js +132 -0
  6. package/dist/shared/lib/locales.js +101 -0
  7. package/dist/shared/lib/uploadLanguage.js +80 -0
  8. package/dist/shared/lib/utils.js +20 -0
  9. package/dist/shared/ui/MciModal/MciModal.js +97 -0
  10. package/dist/shared/ui/mciAccordion/MciAccordion.js +74 -0
  11. package/dist/shared/ui/mciBreadcrumb/MciBreadcrumb.js +39 -0
  12. package/dist/shared/ui/mciButton/MciButton.js +63 -0
  13. package/dist/shared/ui/mciCheck/MciCheck.js +170 -0
  14. package/dist/shared/ui/mciCollapse/MciCollapse.js +60 -0
  15. package/dist/shared/ui/mciDrawer/MciDrawer.js +108 -0
  16. package/dist/shared/ui/mciIdentityInput/MciIdentityInput.js +30 -0
  17. package/dist/shared/ui/mciIdentityInput/mci-identity-input.utils.js +32 -0
  18. package/dist/shared/ui/mciInput/MciInput.js +225 -0
  19. package/dist/shared/ui/mciInput/mci-input.utils.js +49 -0
  20. package/dist/shared/ui/mciLoader/MciLoader.js +38 -0
  21. package/dist/shared/ui/mciPagination/MciPagination.js +135 -0
  22. package/dist/shared/ui/mciPagination/mci-pagination.utils.js +12 -0
  23. package/dist/shared/ui/mciPhone/MciPhone.js +83 -0
  24. package/dist/shared/ui/mciPhone/mci-phone.utils.js +47 -0
  25. package/dist/shared/ui/mciPicker/MciPicker.js +256 -0
  26. package/dist/shared/ui/mciPicker/mci-picker.utils.js +62 -0
  27. package/dist/shared/ui/mciSelect/MciSelect.js +226 -0
  28. package/dist/shared/ui/mciSelect/mci-select.utils.js +52 -0
  29. package/dist/shared/ui/mciSkeleton/MciSkeleton.js +29 -0
  30. package/dist/shared/ui/mciTable/MciTable.js +153 -0
  31. package/dist/shared/ui/mciTable/MciTableClamp2.js +7 -0
  32. package/dist/shared/ui/mciTable/MciTableColumnsPanel.js +198 -0
  33. package/dist/shared/ui/mciTable/mci-table.utils.js +14 -0
  34. package/dist/shared/ui/mciTabs/MciTabs.js +131 -0
  35. package/dist/shared/ui/mciTag/MciTag.js +46 -0
  36. package/dist/shared/ui/mciTextarea/MciTextarea.js +56 -0
  37. package/dist/shared/ui/mciToast/MciToast.js +106 -0
  38. package/dist/shared/ui/mciToast/mci-toast.utils.js +47 -0
  39. package/dist/shared/ui/mciToggle/MciToggle.js +77 -0
  40. package/dist/shared/ui/mciTooltip/MciTooltip.js +52 -0
  41. package/dist/shared/ui/mciUpload/MciUpload.js +337 -0
  42. package/dist/shared/ui/mciUpload/mci-upload.utils.js +186 -0
  43. package/dist/types/shared/types/mci-table.types.d.ts +1 -0
  44. package/dist/types/shared/ui/mciTable/MciTableColumnsPanel.d.ts +3 -2
  45. package/package.json +15 -12
  46. package/dist/index.es.js +0 -3387
  47. package/dist/index.umd.js +0 -2
package/dist/index.es.js DELETED
@@ -1,3387 +0,0 @@
1
- import { jsx as r, jsxs as d, Fragment as he } from "react/jsx-runtime";
2
- import { AltArrowRight as Ne, Star2 as nt, AltArrowDown as Fe, EyeClosed as bt, Eye as lt, Calendar as gt, AltArrowLeft as Me, DoubleAltArrowLeft as xt, DoubleAltArrowRight as wt, ConfoundedSquare as yt, SortVertical as vt, SortFromTopToBottom as Nt, SortFromBottomToTop as kt, FileText as je, File as st, MusicNote as Ct, VideoFramePlayHorizontal as St, Gallery as Et, Upload as At, MenuDots as Dt, Refresh as Mt, InfoCircle as Tt, DangerCircle as It, CloseCircle as Ft, CheckCircle as Lt, Phone as jt, TransferVertical as Ot } from "@solar-icons/react";
3
- import { clsx as Rt } from "clsx";
4
- import { twMerge as $t } from "tailwind-merge";
5
- import * as ee from "react";
6
- import Xe, { memo as _t, useState as P, useMemo as z, useCallback as $, useRef as ae, useEffect as J, useId as Bt, forwardRef as be } from "react";
7
- import { createRoot as Pt } from "react-dom/client";
8
- function s(...e) {
9
- return $t(Rt(e));
10
- }
11
- function _e(e) {
12
- return { handleEscape: (n) => {
13
- n.key === "Escape" && e();
14
- } };
15
- }
16
- function Le(e, t) {
17
- return { handleClick: (l) => {
18
- e.current && !e.current.contains(l.target) && t();
19
- } };
20
- }
21
- function pn({
22
- items: e,
23
- variant: t = "blue",
24
- className: n
25
- }) {
26
- const l = t === "blue", o = l ? "hover:text-blue-600" : "hover:text-yellow-500", a = l ? "text-blue-600" : "text-yellow-500";
27
- return /* @__PURE__ */ r("nav", { className: s("flex items-center", n), "aria-label": "Breadcrumb", children: e.map((i, c) => {
28
- const p = c === e.length - 1;
29
- return /* @__PURE__ */ d("div", { className: "flex items-center", children: [
30
- p ? /* @__PURE__ */ d("span", { className: s("flex items-center gap-x-2 font-medium", a), children: [
31
- i.icon,
32
- /* @__PURE__ */ r("span", { children: i.label })
33
- ] }) : /* @__PURE__ */ d(
34
- "a",
35
- {
36
- href: i.href ?? "#",
37
- onClick: (b) => {
38
- i.onClick && (b.preventDefault(), i.onClick());
39
- },
40
- className: s(
41
- "flex items-center gap-x-2 transition-all text-sm font-normal text-slate-500",
42
- o
43
- ),
44
- children: [
45
- i.icon,
46
- /* @__PURE__ */ r("span", { children: i.label })
47
- ]
48
- }
49
- ),
50
- !p && /* @__PURE__ */ r("span", { className: "mx-2 flex items-center", children: /* @__PURE__ */ r(Ne, { weight: "Linear", size: 20, className: "text-slate-500" }) })
51
- ] }, c);
52
- }) });
53
- }
54
- const zt = {
55
- sm: "h-9 px-2 text-sm gap-1.5 rounded-lg leading-9 min-w-9",
56
- md: "h-10 px-2 text-base gap-2 rounded-lg leading-10 min-w-10",
57
- base: "h-12 px-4 text-base gap-2 rounded-xl leading-12 min-w-12"
58
- }, Wt = {
59
- blue: {
60
- primary: "bg-blue-600 text-white hover:bg-blue-700 active:bg-blue-800 focus:ring-2 focus:ring-[rgba(21,93,252,0.25)]",
61
- secondary: "bg-blue-100 text-blue-600 hover:bg-blue-200 active:bg-blue-200 active:border active:border-blue-600 focus:ring-2 focus:ring-[rgba(21,93,252,0.25)]",
62
- outline: "border border-blue-600 text-blue-600 hover:border-blue-700 hover:text-blue-700 active:border-blue-800 active:text-blue-800 focus:ring-2 focus:ring-blue-200"
63
- },
64
- yellow: {
65
- primary: "bg-yellow-500 text-white hover:bg-yellow-600 active:bg-yellow-700 focus:ring-2 focus:ring-yellow-300",
66
- secondary: "bg-yellow-50 text-yellow-500 hover:bg-yellow-100 active:bg-yellow-100 active:border active:border-yellow-500 focus:ring-2 focus:ring-yellow-200",
67
- outline: "border border-yellow-500 text-yellow-500 hover:border-yellow-600 hover:text-yellow-600 active:border-yellow-700 active:text-yellow-700 focus:ring-2 focus:ring-yellow-200"
68
- }
69
- }, Yt = {
70
- danger: "bg-red-600 text-white hover:bg-red-700 active:bg-red-800 focus:ring-2 focus:shadow-red",
71
- tertiary: "bg-slate-100 text-black hover:bg-slate-200 active:bg-slate-300 focus:ring-2 focus:shadow-slate"
72
- };
73
- function bn({
74
- children: e,
75
- text: t,
76
- icon: n,
77
- iconPosition: l = "left",
78
- size: o = "base",
79
- variant: a = "primary",
80
- color: i = "yellow",
81
- loading: c = !1,
82
- disabled: p = !1,
83
- onClick: b,
84
- className: y,
85
- type: S = "button"
86
- }) {
87
- const I = e ?? t, T = a === "primary" || a === "secondary" || a === "outline" ? Wt[i][a] : Yt[a], E = p || c, h = E ? a === "outline" ? "border-slate-200 bg-white text-slate-400 cursor-not-allowed hover:bg-transparent hover:border-slate-200 hover:text-slate-400 active:border-slate-200 active:text-slate-400 active:bg-transparent focus:bg-transparent focus:ring-0" : "bg-slate-200 text-slate-400 cursor-not-allowed hover:bg-slate-200 active:bg-slate-200 focus:ring-0" : "";
88
- return /* @__PURE__ */ d(
89
- "button",
90
- {
91
- type: S,
92
- onClick: b,
93
- disabled: E,
94
- className: s(
95
- "inline-flex w-fit shrink-0 items-center justify-center whitespace-nowrap text-center font-medium transition-all duration-200 cursor-pointer",
96
- zt[o],
97
- T,
98
- !E && T,
99
- h,
100
- y
101
- ),
102
- children: [
103
- n && l === "left" && !c && /* @__PURE__ */ r("span", { className: "flex items-center", children: n }),
104
- I && /* @__PURE__ */ r("span", { className: "whitespace-nowrap", children: I }),
105
- n && l === "right" && !c && /* @__PURE__ */ r("span", { className: "flex items-center", children: n }),
106
- c && /* @__PURE__ */ r(nt, { weight: "Linear", size: 20, className: "animate-spin" })
107
- ]
108
- }
109
- );
110
- }
111
- const Vt = (e) => /* @__PURE__ */ ee.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 11, height: 8, viewBox: "0 0 11 8", fill: "none", ...e }, /* @__PURE__ */ ee.createElement("path", { d: "M0.625 3.76944L3.76944 6.91389L10.0694 0.625", stroke: "currentColor", strokeWidth: 1.25, strokeLinecap: "round", strokeLinejoin: "round" })), Ht = {
112
- blue: {
113
- border: "border-blue-600",
114
- bg: "bg-blue-600",
115
- hover: "hover:border-blue-600 hover:bg-blue-100",
116
- focus: "focus:shadow-blue"
117
- },
118
- yellow: {
119
- border: "border-yellow-500",
120
- bg: "bg-yellow-500",
121
- hover: "hover:border-yellow-500 hover:bg-yello-100",
122
- focus: "focus:ring-2 focus:ring-yellow-300"
123
- }
124
- }, Ie = _t(function({
125
- type: t = "checkbox",
126
- label: n,
127
- supportText: l,
128
- checked: o,
129
- onChange: a,
130
- error: i,
131
- disabled: c = !1,
132
- required: p = !1,
133
- className: b,
134
- variant: y = "yellow",
135
- name: S,
136
- value: I
137
- }) {
138
- const [T, E] = P(!1), h = t === "radio", w = z(
139
- () => o ?? T,
140
- [o, T]
141
- ), M = $(
142
- (f) => {
143
- c || (o === void 0 && E(f.target.checked), a?.(f));
144
- },
145
- [o, a, c]
146
- ), O = z(() => {
147
- if (c) {
148
- const v = "border-slate-200 bg-slate-100";
149
- return h ? {
150
- container: v,
151
- dot: w ? "bg-slate-300" : "bg-transparent",
152
- check: "text-slate-400"
153
- } : {
154
- container: v,
155
- dot: "",
156
- check: w ? "text-slate-400" : "text-transparent"
157
- };
158
- }
159
- const f = Ht[y];
160
- if (h) {
161
- const v = s(
162
- "border transition-all duration-200",
163
- w ? f.border : "border-slate-400",
164
- !w && f.hover,
165
- f.focus,
166
- w && ""
167
- ), A = s(
168
- "transition-all duration-200 rounded-full",
169
- w ? f.bg : "bg-transparent"
170
- );
171
- return {
172
- container: v,
173
- dot: A,
174
- check: ""
175
- };
176
- }
177
- return {
178
- container: s(
179
- "border transition-all duration-200",
180
- w ? s(f.bg, f.border) : "border-slate-400",
181
- !w && f.hover,
182
- f.focus
183
- ),
184
- dot: "",
185
- check: w ? "text-white" : "text-transparent"
186
- };
187
- }, [h, w, c, y]), k = z(() => !n && !l ? null : /* @__PURE__ */ d("div", { className: "flex flex-col", children: [
188
- n && /* @__PURE__ */ d(
189
- "span",
190
- {
191
- className: s(
192
- "text-base font-medium text-slate-700",
193
- i && "text-red-600",
194
- c && "text-slate-400"
195
- ),
196
- children: [
197
- n,
198
- p && /* @__PURE__ */ r("span", { className: "text-extra-small text-red-600 ml-1", children: "*" })
199
- ]
200
- }
201
- ),
202
- l && /* @__PURE__ */ r(
203
- "span",
204
- {
205
- className: s(
206
- "text-slate-500 text-base font-normal",
207
- c && "text-slate-400"
208
- ),
209
- children: l
210
- }
211
- )
212
- ] }), [n, l, i, c, p]);
213
- return /* @__PURE__ */ d("div", { className: s("flex items-start", b), children: [
214
- /* @__PURE__ */ d(
215
- "label",
216
- {
217
- className: s(
218
- "flex items-start gap-2 select-none",
219
- c ? "cursor-not-allowed" : "cursor-pointer"
220
- ),
221
- children: [
222
- /* @__PURE__ */ r(
223
- "input",
224
- {
225
- type: t,
226
- checked: w,
227
- onChange: M,
228
- disabled: c,
229
- required: p,
230
- className: "sr-only",
231
- "aria-invalid": !!i,
232
- "aria-describedby": i ? `${S}-error` : void 0,
233
- name: S,
234
- value: I
235
- }
236
- ),
237
- /* @__PURE__ */ r(
238
- "div",
239
- {
240
- className: s(
241
- "relative flex items-center justify-center",
242
- h ? "w-5 h-5 rounded-full" : "w-5 h-5 rounded",
243
- O.container
244
- ),
245
- children: h ? /* @__PURE__ */ r("div", { className: "absolute inset-0 flex items-center justify-center", children: /* @__PURE__ */ r(
246
- "span",
247
- {
248
- className: s(
249
- "w-3 h-3 rounded-full transition-all duration-200",
250
- O.dot,
251
- w ? "opacity-100 scale-100" : "opacity-0 scale-50"
252
- )
253
- }
254
- ) }) : /* @__PURE__ */ r(
255
- Vt,
256
- {
257
- className: s(
258
- "w-4 h-4 stroke-[2.5px] transition-opacity duration-200",
259
- O.check,
260
- w ? "opacity-100" : "opacity-0"
261
- )
262
- }
263
- )
264
- }
265
- ),
266
- k
267
- ]
268
- }
269
- ),
270
- i && /* @__PURE__ */ r("p", { id: `${S}-error`, className: "mt-1 text-extra-small text-red-600", children: i })
271
- ] });
272
- });
273
- Ie.displayName = "MciCheck";
274
- function gn({
275
- title: e,
276
- children: t,
277
- defaultOpen: n = !1,
278
- icon: l,
279
- className: o,
280
- contentClassName: a
281
- }) {
282
- const [i, c] = P(n), [p, b] = P(0), y = ae(null);
283
- return J(() => {
284
- y.current && b(i ? y.current.scrollHeight : 0);
285
- }, [i]), /* @__PURE__ */ d("div", { className: s("overflow-hidden rounded-xl border border-slate-200", o), children: [
286
- /* @__PURE__ */ d(
287
- "button",
288
- {
289
- onClick: () => c(!i),
290
- className: s(
291
- "flex w-full items-center justify-between p-5 transition-all duration-300 hover:cursor-pointer",
292
- i ? "border-b border-slate-200" : "border-b border-transparent"
293
- ),
294
- children: [
295
- /* @__PURE__ */ d("div", { className: "flex items-center gap-2", children: [
296
- l && /* @__PURE__ */ r("span", { className: "shrink-0", children: l }),
297
- /* @__PURE__ */ r("div", { className: s("text-base font-medium text-black"), children: e })
298
- ] }),
299
- /* @__PURE__ */ r(
300
- Fe,
301
- {
302
- weight: "Linear",
303
- size: 20,
304
- className: s(
305
- "shrink-0 transition-transform duration-300 text-slate-400",
306
- i && "rotate-180"
307
- )
308
- }
309
- )
310
- ]
311
- }
312
- ),
313
- /* @__PURE__ */ r(
314
- "div",
315
- {
316
- className: s(
317
- "overflow-hidden transition-all duration-300 ease-out"
318
- ),
319
- style: {
320
- height: `${p}px`
321
- },
322
- children: /* @__PURE__ */ r("div", { ref: y, className: s("p-5", a), children: t })
323
- }
324
- )
325
- ] });
326
- }
327
- const Ut = (e) => e.type.displayName, Ke = (e, t, n) => Xe.Children.toArray(e).find(
328
- (l) => Xe.isValidElement(l) && (Ut(l) === t || l.type === n)
329
- ) ?? null;
330
- function Be({
331
- children: e,
332
- className: t
333
- }) {
334
- return /* @__PURE__ */ r("div", { className: s("text-base font-medium text-black", t), children: e });
335
- }
336
- Be.displayName = "AccordionTitle";
337
- function Pe({
338
- children: e,
339
- className: t
340
- }) {
341
- return /* @__PURE__ */ r("div", { className: s("p-5 text-base", t), children: e });
342
- }
343
- Pe.displayName = "AccordionContent";
344
- function at({ children: e, defaultValue: t = !1, icon: n, className: l }) {
345
- const [o, a] = P(t), i = ae(null), c = Bt(), p = () => a((b) => !b);
346
- return /* @__PURE__ */ d("div", { className: s("overflow-hidden rounded-xl border border-slate-200", l), children: [
347
- /* @__PURE__ */ d(
348
- "button",
349
- {
350
- type: "button",
351
- onClick: p,
352
- "aria-expanded": o,
353
- "aria-controls": c,
354
- className: s(
355
- "flex w-full items-center justify-between gap-2 p-5 transition-all duration-300 hover:cursor-pointer",
356
- o ? "border-b border-slate-200" : "border-b border-transparent"
357
- ),
358
- children: [
359
- /* @__PURE__ */ d("div", { className: "flex w-full items-center gap-2", children: [
360
- n && /* @__PURE__ */ r("span", { className: "shrink-0", children: n }),
361
- Ke(e, "AccordionTitle", Be)
362
- ] }),
363
- /* @__PURE__ */ r(
364
- Fe,
365
- {
366
- weight: "Linear",
367
- size: 20,
368
- className: s(
369
- "shrink-0 text-slate-400 transition-transform duration-300",
370
- o && "rotate-180"
371
- )
372
- }
373
- )
374
- ]
375
- }
376
- ),
377
- /* @__PURE__ */ r(
378
- "div",
379
- {
380
- id: c,
381
- role: "region",
382
- "aria-labelledby": c,
383
- className: s(
384
- "grid transition-[grid-template-rows] duration-300 ease-out",
385
- o ? "grid-rows-[1fr]" : "grid-rows-[0fr]"
386
- ),
387
- children: /* @__PURE__ */ r("div", { ref: i, className: "min-h-0 overflow-hidden", children: Ke(e, "AccordionContent", Pe) })
388
- }
389
- )
390
- ] });
391
- }
392
- at.Title = Be;
393
- at.Content = Pe;
394
- const ge = (e) => /* @__PURE__ */ ee.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 24, height: 24, viewBox: "0 0 24 24", fill: "none", ...e }, /* @__PURE__ */ ee.createElement("path", { d: "M7.75739 7.75735L16.2427 16.2426", stroke: "currentColor", strokeWidth: 1.5, strokeLinecap: "round", strokeLinejoin: "round" }), /* @__PURE__ */ ee.createElement("path", { d: "M7.75733 16.2426L16.2426 7.75735", stroke: "currentColor", strokeWidth: 1.5, strokeLinecap: "round", strokeLinejoin: "round" }));
395
- function xn({
396
- isOpen: e,
397
- onClose: t,
398
- position: n = "right",
399
- children: l,
400
- footer: o,
401
- title: a,
402
- description: i,
403
- showCloseButton: c = !0,
404
- drawerClassName: p,
405
- contentClassName: b,
406
- closeOnOverlayClick: y = !0,
407
- closeOnEscape: S = !0,
408
- width: I = 572
409
- }) {
410
- const T = ae(null), E = ae(null), h = $(() => t(), [t]);
411
- J(() => {
412
- e ? (E.current = document.activeElement, T.current?.focus()) : E.current?.focus();
413
- }, [e]), J(() => (e && (document.body.style.overflow = "hidden"), () => {
414
- document.body.style.overflow = "unset";
415
- }), [e]);
416
- const w = z(
417
- () => ({
418
- "--drawer-w": typeof I == "number" ? `${I}px` : I,
419
- transform: e ? "translateX(0)" : n === "right" ? "translateX(calc(100% + 48px))" : "translateX(calc(-100% - 48px))"
420
- }),
421
- [e, I, n]
422
- ), M = !!(a || i || c), O = n === "right" ? "top-0 bottom-0 right-0 left-3 rounded-l-3xl rounded-r-none" : "top-0 bottom-0 left-0 right-3 rounded-r-3xl rounded-l-none", k = n === "right" ? "sm:top-6 sm:bottom-6 sm:right-6 sm:left-auto" : "sm:top-6 sm:bottom-6 sm:left-6 sm:right-auto";
423
- return /* @__PURE__ */ d(he, { children: [
424
- /* @__PURE__ */ r(
425
- "div",
426
- {
427
- className: s(
428
- "fixed inset-0 z-50 bg-black/40 transition-opacity duration-300",
429
- e ? "opacity-100 visible cursor-pointer" : "opacity-0 invisible pointer-events-none"
430
- ),
431
- onClick: y ? h : void 0,
432
- "aria-hidden": "true"
433
- }
434
- ),
435
- /* @__PURE__ */ d(
436
- "div",
437
- {
438
- ref: T,
439
- tabIndex: -1,
440
- style: w,
441
- className: s(
442
- "fixed z-50 flex flex-col bg-white outline-none min-h-0",
443
- "transition-[transform,opacity,visibility] duration-300 ease-in-out",
444
- e ? "opacity-100 visible pointer-events-auto shadow-2xl" : "opacity-0 invisible pointer-events-none shadow-none",
445
- O,
446
- "h-[100dvh]",
447
- "pb-[env(safe-area-inset-bottom)]",
448
- k,
449
- "sm:h-auto sm:rounded-2xl sm:pb-0",
450
- "sm:w-[var(--drawer-w)]",
451
- p
452
- ),
453
- role: "dialog",
454
- "aria-modal": "true",
455
- "aria-hidden": !e,
456
- "aria-labelledby": a ? "drawer-title" : void 0,
457
- children: [
458
- M && /* @__PURE__ */ d("div", { className: "flex items-start justify-between border-b border-slate-200 shrink-0 px-4 py-4 sm:p-6", children: [
459
- (a || i) && /* @__PURE__ */ d("div", { className: "block pr-3", children: [
460
- a && /* @__PURE__ */ r(
461
- "h2",
462
- {
463
- id: "drawer-title",
464
- className: "font-semibold text-black text-xl leading-tight sm:text-h3",
465
- children: a
466
- }
467
- ),
468
- i && /* @__PURE__ */ r("p", { className: "text-sm sm:text-base text-slate-base font-normal mt-2", children: i })
469
- ] }),
470
- c && /* @__PURE__ */ r(
471
- "button",
472
- {
473
- type: "button",
474
- onClick: h,
475
- className: "bg-slate-100 rounded-xl w-11 h-11 sm:w-12 sm:h-12 hover:cursor-pointer text-black transition flex items-center justify-center group active:scale-95",
476
- children: /* @__PURE__ */ r(ge, { className: "h-5 w-5 sm:h-6 sm:w-6 transition-transform duration-300 group-hover:rotate-180" })
477
- }
478
- )
479
- ] }),
480
- /* @__PURE__ */ r(
481
- "div",
482
- {
483
- className: s(
484
- "flex-1 min-h-0 overflow-y-auto scrollbar-thin scrollbar-thumb-slate-200 px-4 py-4 sm:p-6",
485
- b
486
- ),
487
- children: l
488
- }
489
- ),
490
- o && /* @__PURE__ */ r("div", { className: "shrink-0 flex items-center justify-end border-t border-slate-200 px-4 py-4 sm:p-6 gap-3 [&>*]:w-fit [&>*]:shrink-0 [&>*]:whitespace-nowrap", children: o })
491
- ]
492
- }
493
- )
494
- ] });
495
- }
496
- const Oe = {
497
- sm: {
498
- input: "h-9 text-sm",
499
- icon: "w-4 h-4",
500
- leftIcon: "left-2",
501
- rightIcon: "right-2",
502
- labelFont: "text-sm",
503
- iconWrapper: "h-4"
504
- },
505
- md: {
506
- input: "h-10 text-sm",
507
- icon: "w-4 h-4",
508
- leftIcon: "left-2",
509
- rightIcon: "right-2",
510
- labelFont: "text-base",
511
- iconWrapper: "h-4"
512
- },
513
- base: {
514
- input: "h-12 text-base",
515
- icon: "w-5 h-5",
516
- leftIcon: "left-3",
517
- rightIcon: "right-3",
518
- labelFont: "text-base",
519
- iconWrapper: "h-5"
520
- }
521
- };
522
- function Zt(e, t) {
523
- const n = (l) => l === "sm" ? e && t ? "pl-7 pr-7" : e ? "pl-7 pr-2" : t ? "pl-2 pr-7" : "px-2" : l === "md" ? e && t ? "pl-8 pr-8" : e ? "pl-8 pr-2" : t ? "pl-2 pr-8" : "px-4" : e && t ? "pl-9 pr-9" : e ? "pl-9 pr-3" : t ? "pl-3 pr-9" : "px-4";
524
- return {
525
- sm: { ...Oe.sm, padding: n("sm") },
526
- md: { ...Oe.md, padding: n("md") },
527
- base: { ...Oe.base, padding: n("base") }
528
- };
529
- }
530
- function Xt(e) {
531
- return e ? "border-red-600 focus:border-red-600 shadow-red" : "border-slate-200 hover:border-slate-400 focus:shadow-blue focus:border-blue-600";
532
- }
533
- function Kt(e, t, n) {
534
- return e ? "text-slate-400" : t ? "text-red-600" : n ? "text-black" : "text-slate-400";
535
- }
536
- function qt(e, t) {
537
- return t <= 0 ? "" : e === "sm" ? t >= 3 ? "pr-14" : t === 2 ? "pr-11" : "pr-7" : e === "md" ? t >= 3 ? "pr-16" : t === 2 ? "pr-12" : "pr-8" : t >= 3 ? "pr-20" : t === 2 ? "pr-16" : "pr-10";
538
- }
539
- const ze = be(
540
- ({
541
- label: e,
542
- placeholder: t,
543
- type: n = "text",
544
- icon: l,
545
- rightIcon: o,
546
- iconPosition: a = "left",
547
- size: i = "base",
548
- error: c,
549
- disabled: p = !1,
550
- required: b = !1,
551
- value: y,
552
- onChange: S,
553
- onFocus: I,
554
- onBlur: T,
555
- className: E,
556
- name: h,
557
- maxLength: w = 250,
558
- onClear: M,
559
- showClearButton: O = !1,
560
- step: k,
561
- autoComplete: f = "off"
562
- }, L) => {
563
- const [v, A] = P(!1), [m, u] = P(""), [x, j] = P(!1), F = y ?? m, R = n === "password", W = O && !!F && !p, V = l && a === "left", X = l && a === "right" || o || R, re = X || W, ne = z(() => {
564
- let Z = 0;
565
- return W && (Z += 1), R ? (Z += 1, o && (Z += 1), Z) : (o && (Z += 1), l && a === "right" && (Z += 1), Z);
566
- }, [W, R, o, l, a]), le = () => {
567
- A(!0), I?.();
568
- }, te = () => {
569
- A(!1), T?.();
570
- }, ie = (Z) => {
571
- let G = Z.target.value;
572
- n === "number" && w && G.length > w && (G = G.slice(0, w), Z.target.value = G), y === void 0 && u(G), S?.(Z);
573
- }, K = () => j((Z) => !Z), D = () => {
574
- y === void 0 && u(""), M?.();
575
- }, C = z(
576
- () => Zt(!!V, !!X),
577
- [V, X]
578
- ), q = z(() => Xt(c), [c]), B = z(
579
- () => Kt(p, c, v),
580
- [c, v, p]
581
- ), H = z(
582
- () => qt(i, ne),
583
- [i, ne]
584
- );
585
- return /* @__PURE__ */ d("div", { className: s("w-full", E), children: [
586
- e && /* @__PURE__ */ d(
587
- "label",
588
- {
589
- htmlFor: h,
590
- className: s(
591
- "mb-2 block text-base font-medium",
592
- c ? "text-red-600" : "text-slate-700",
593
- C[i].labelFont
594
- ),
595
- children: [
596
- e,
597
- b && /* @__PURE__ */ r("span", { className: "text-extra-small text-red-600 ml-1", children: "*" })
598
- ]
599
- }
600
- ),
601
- /* @__PURE__ */ d("div", { className: "relative flex items-center", children: [
602
- /* @__PURE__ */ r(
603
- "input",
604
- {
605
- ref: L,
606
- name: h,
607
- type: R && x ? "text" : n,
608
- value: F,
609
- onChange: ie,
610
- onFocus: le,
611
- onBlur: te,
612
- disabled: p,
613
- required: b,
614
- autoComplete: f,
615
- placeholder: t,
616
- step: k,
617
- className: s(
618
- "w-full border bg-white font-normal transition-all duration-300 ease-in-out outline-none",
619
- i === "base" ? "rounded-xl" : "rounded-lg",
620
- "disabled:cursor-not-allowed disabled:border-slate-200 disabled:bg-slate-100 disabled:text-slate-400",
621
- "[appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none",
622
- C[i].input,
623
- C[i].padding,
624
- H,
625
- q
626
- ),
627
- maxLength: w
628
- }
629
- ),
630
- V && /* @__PURE__ */ r(
631
- "div",
632
- {
633
- className: s(
634
- "absolute top-1/2 flex -translate-y-1/2 items-center justify-center",
635
- "transition-all duration-300",
636
- C[i].leftIcon,
637
- B
638
- ),
639
- children: /* @__PURE__ */ r(
640
- "div",
641
- {
642
- className: s("flex items-center justify-center", C[i].iconWrapper),
643
- children: /* @__PURE__ */ r("span", { className: s("flex items-center justify-center", C[i].icon), children: l })
644
- }
645
- )
646
- }
647
- ),
648
- re && /* @__PURE__ */ d(
649
- "div",
650
- {
651
- className: s(
652
- "absolute top-1/2 flex -translate-y-1/2 items-center justify-center gap-2",
653
- "transition-all duration-300",
654
- C[i].rightIcon
655
- ),
656
- children: [
657
- W && /* @__PURE__ */ r(
658
- "button",
659
- {
660
- type: "button",
661
- onClick: D,
662
- className: s(
663
- "flex items-center justify-center",
664
- C[i].iconWrapper,
665
- "text-slate-base hover:text-black"
666
- ),
667
- style: { cursor: "pointer" },
668
- children: /* @__PURE__ */ r("span", { className: s("flex items-center justify-center", C[i].icon), children: /* @__PURE__ */ r(ge, { className: s("h-full w-full") }) })
669
- }
670
- ),
671
- o && !R && /* @__PURE__ */ r(
672
- "div",
673
- {
674
- className: s("flex items-center justify-center", C[i].iconWrapper),
675
- children: /* @__PURE__ */ r(
676
- "span",
677
- {
678
- className: s(
679
- "flex items-center justify-center",
680
- C[i].icon,
681
- B
682
- ),
683
- children: o
684
- }
685
- )
686
- }
687
- ),
688
- R && /* @__PURE__ */ d(he, { children: [
689
- o && /* @__PURE__ */ r(
690
- "div",
691
- {
692
- className: s(
693
- "flex items-center justify-center",
694
- C[i].iconWrapper
695
- ),
696
- children: /* @__PURE__ */ r(
697
- "span",
698
- {
699
- className: s(
700
- "flex items-center justify-center",
701
- C[i].icon,
702
- B
703
- ),
704
- children: o
705
- }
706
- )
707
- }
708
- ),
709
- /* @__PURE__ */ r(
710
- "button",
711
- {
712
- type: "button",
713
- onClick: K,
714
- className: s(
715
- "flex items-center justify-center",
716
- C[i].iconWrapper,
717
- B
718
- ),
719
- children: /* @__PURE__ */ r(
720
- "span",
721
- {
722
- className: s("flex items-center justify-center cursor-pointer", C[i].icon),
723
- children: x ? /* @__PURE__ */ r(bt, { weight: "Linear", className: s("h-full w-full") }) : /* @__PURE__ */ r(lt, { weight: "Linear", className: s("h-full w-full") })
724
- }
725
- )
726
- }
727
- )
728
- ] }),
729
- l && a === "right" && !R && /* @__PURE__ */ r(
730
- "div",
731
- {
732
- className: s("flex items-center justify-center", C[i].iconWrapper),
733
- children: /* @__PURE__ */ r(
734
- "span",
735
- {
736
- className: s(
737
- "flex items-center justify-center",
738
- C[i].icon,
739
- B
740
- ),
741
- children: l
742
- }
743
- )
744
- }
745
- )
746
- ]
747
- }
748
- )
749
- ] }),
750
- c && /* @__PURE__ */ r("p", { className: "mt-2 animate-[slideDown_0.3s_ease-out] text-sm font-normal text-red-600", children: c })
751
- ] });
752
- }
753
- );
754
- ze.displayName = "MciInput";
755
- const Gt = {
756
- uz: {
757
- months: [
758
- "Yanvar",
759
- "Fevral",
760
- "Mart",
761
- "Aprel",
762
- "May",
763
- "Iyun",
764
- "Iyul",
765
- "Avgust",
766
- "Sentabr",
767
- "Oktabr",
768
- "Noyabr",
769
- "Dekabr"
770
- ],
771
- monthsShort: [
772
- "Yan",
773
- "Fev",
774
- "Mar",
775
- "Apr",
776
- "May",
777
- "Iyn",
778
- "Iyl",
779
- "Avg",
780
- "Sen",
781
- "Okt",
782
- "Noy",
783
- "Dek"
784
- ],
785
- weekdays: ["Yakshanba", "Dushanba", "Seshanba", "Chorshanba", "Payshanba", "Juma", "Shanba"],
786
- weekdaysShort: ["Ya", "Du", "Se", "Ch", "Pa", "Ju", "Sh"]
787
- },
788
- ru: {
789
- months: [
790
- "Январь",
791
- "Февраль",
792
- "Март",
793
- "Апрель",
794
- "Май",
795
- "Июнь",
796
- "Июль",
797
- "Август",
798
- "Сентябрь",
799
- "Октябрь",
800
- "Ноябрь",
801
- "Декабрь"
802
- ],
803
- monthsShort: [
804
- "Янв",
805
- "Фев",
806
- "Мар",
807
- "Апр",
808
- "Май",
809
- "Июн",
810
- "Июл",
811
- "Авг",
812
- "Сен",
813
- "Окт",
814
- "Ноя",
815
- "Дек"
816
- ],
817
- weekdays: ["Воскресенье", "Понедельник", "Вторник", "Среда", "Четверг", "Пятница", "Суббота"],
818
- weekdaysShort: ["Вс", "Пн", "Вт", "Ср", "Чт", "Пт", "Сб"]
819
- },
820
- en: {
821
- months: [
822
- "January",
823
- "February",
824
- "March",
825
- "April",
826
- "May",
827
- "June",
828
- "July",
829
- "August",
830
- "September",
831
- "October",
832
- "November",
833
- "December"
834
- ],
835
- monthsShort: [
836
- "Jan",
837
- "Feb",
838
- "Mar",
839
- "Apr",
840
- "May",
841
- "Jun",
842
- "Jul",
843
- "Aug",
844
- "Sep",
845
- "Oct",
846
- "Nov",
847
- "Dec"
848
- ],
849
- weekdays: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
850
- weekdaysShort: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]
851
- }
852
- };
853
- function ce(e) {
854
- if (!e) return null;
855
- const t = new Date(e);
856
- return Number.isNaN(t.getTime()) ? null : t;
857
- }
858
- function se(e) {
859
- return new Date(e.getFullYear(), e.getMonth(), e.getDate());
860
- }
861
- function Jt(e, t) {
862
- if (!e) return "";
863
- const n = e.getDate().toString().padStart(2, "0"), l = (e.getMonth() + 1).toString().padStart(2, "0"), o = e.getFullYear().toString();
864
- return t.replace("DD", n).replace("MM", l).replace("YYYY", o);
865
- }
866
- function qe(e) {
867
- if (!e || e.length !== 10) return null;
868
- const t = e.replace(/\D/g, "");
869
- if (t.length !== 8) return null;
870
- const n = parseInt(t.slice(0, 2), 10), l = parseInt(t.slice(2, 4), 10), o = parseInt(t.slice(4, 8), 10);
871
- if (o < 1e3 || l < 1 || l > 12 || n < 1 || n > 31) return null;
872
- const a = new Date(o, l - 1, n);
873
- return a.getFullYear() !== o || a.getMonth() !== l - 1 || a.getDate() !== n ? null : a;
874
- }
875
- function Qt(e) {
876
- let t = e.replace(/\D/g, "");
877
- 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;
878
- }
879
- function er(e, t, n) {
880
- const l = se(e);
881
- return !!(t && l < se(t) || n && l > se(n));
882
- }
883
- function tr(e, t) {
884
- return new Date(e.getFullYear(), e.getMonth() + t, 1);
885
- }
886
- function rr(e, t) {
887
- return new Date(e.getFullYear() + t, e.getMonth(), 1);
888
- }
889
- function nr(e) {
890
- const t = e.getFullYear(), n = e.getMonth(), l = new Date(t, n, 1).getDay(), o = new Date(t, n + 1, 0).getDate(), a = [];
891
- for (let c = l; c > 0; c -= 1)
892
- a.push({ date: new Date(t, n, 1 - c), isCurrentMonth: !1 });
893
- for (let c = 1; c <= o; c += 1)
894
- a.push({ date: new Date(t, n, c), isCurrentMonth: !0 });
895
- const i = 42 - a.length;
896
- for (let c = 1; c <= i; c += 1)
897
- a.push({ date: new Date(t, n + 1, c), isCurrentMonth: !1 });
898
- return a;
899
- }
900
- function lr(e, t) {
901
- return se(e).getTime() === se(t).getTime();
902
- }
903
- const sr = be(
904
- ({
905
- type: e = "date",
906
- value: t,
907
- onChange: n,
908
- placeholder: l,
909
- label: o,
910
- disabled: a = !1,
911
- required: i = !1,
912
- className: c,
913
- format: p = "DD.MM.YYYY",
914
- minDate: b,
915
- maxDate: y,
916
- error: S,
917
- showClear: I = !0,
918
- allowManualInput: T = !0,
919
- locale: E = "uz",
920
- startView: h = "day",
921
- iconPosition: w = "left",
922
- align: M = "auto"
923
- }, O) => {
924
- const [k, f] = P(!1), [L, v] = P(
925
- e === "range" ? [null, null] : null
926
- ), [A, m] = P([null, null]), [u, x] = P(/* @__PURE__ */ new Date()), [j, F] = P(h), [R, W] = P(0), [V, X] = P(""), [re, ne] = P(!1), [le, te] = P(M), ie = ae(null), K = z(() => {
927
- const g = t !== void 0 ? t : L;
928
- if (e === "date") return ce(g);
929
- const N = g;
930
- return [ce(N[0]), ce(N[1])];
931
- }, [t, L, e]), D = Gt[E], C = $(
932
- (g) => Jt(g, p),
933
- [p]
934
- ), q = $(
935
- (g) => er(g, b, y),
936
- [b, y]
937
- ), B = z(() => {
938
- if (e === "date") return C(K);
939
- const [g, N] = K;
940
- return !g && !N ? "" : g && N ? `${C(g)} - ${C(N)}` : g ? `${C(g)} - ...` : "...";
941
- }, [e, K, C]);
942
- J(() => {
943
- (!k && !re || V === "" && B !== "") && X(B);
944
- }, [B, k, V, re]), J(() => {
945
- if (k)
946
- if (e === "range") {
947
- const g = K;
948
- m(g), g[0] ? x(g[0]) : g[1] ? x(g[1]) : x(/* @__PURE__ */ new Date());
949
- } else {
950
- const g = K;
951
- x(g || /* @__PURE__ */ new Date());
952
- }
953
- }, [k, e, K]), J(() => {
954
- if (k && M === "auto" && ie.current) {
955
- const g = ie.current.getBoundingClientRect(), N = window.innerWidth - g.right, _ = g.left;
956
- N < 300 && _ > 300 ? te("right") : te("left");
957
- }
958
- }, [k, M]);
959
- const H = $(() => {
960
- f(!1), F(h), W(0), X(B);
961
- }, [h, B]), Z = $((g) => {
962
- a || (g.preventDefault(), g.stopPropagation(), f((N) => !N));
963
- }, [a]), { handleClick: G } = Le(ie, H), { handleEscape: de } = _e(H);
964
- J(() => {
965
- if (k)
966
- return document.addEventListener("mousedown", G), document.addEventListener("keydown", de), () => {
967
- document.removeEventListener("mousedown", G), document.removeEventListener("keydown", de);
968
- };
969
- }, [k, G, de]);
970
- const pe = () => {
971
- ne(!0), !(a || k) && (e === "range" || !T) && (f(!0), F(h));
972
- }, ke = () => {
973
- if (ne(!1), e !== "date") return;
974
- const g = V.trim();
975
- if (!g) {
976
- v(null), n?.(null);
977
- return;
978
- }
979
- const N = qe(g);
980
- if (N && !q(N)) {
981
- const _ = se(N);
982
- v(_), n?.(_), X(C(_)), x(_);
983
- return;
984
- }
985
- X(B);
986
- }, Y = (g) => {
987
- if (e !== "date") return;
988
- const N = g.target.value, _ = Qt(N), Q = _.replace(/\D/g, "");
989
- if (!(Q.length >= 1 && Number.parseInt(Q[0] ?? "0", 10) > 3)) {
990
- if (Q.length >= 2) {
991
- const U = Number.parseInt(Q.slice(0, 2), 10);
992
- if (U < 1 || U > 31) return;
993
- }
994
- if (!(Q.length >= 3 && Number.parseInt(Q[2] ?? "0", 10) > 1)) {
995
- if (Q.length >= 4) {
996
- const U = Number.parseInt(Q.slice(2, 4), 10);
997
- if (U < 1 || U > 12) return;
998
- }
999
- if (X(_), _.length === 10) {
1000
- const U = qe(_);
1001
- U && !q(U) && (v(U), n?.(U), x(U));
1002
- } else _ === "" && (v(null), n?.(null));
1003
- }
1004
- }
1005
- }, ue = $(() => {
1006
- const g = e === "range" ? [null, null] : null;
1007
- v(g), m([null, null]), n?.(g), X("");
1008
- }, [e, n]), it = $(
1009
- (g) => {
1010
- if (q(g)) return;
1011
- const N = se(g);
1012
- if (e === "date")
1013
- v(N), n?.(N), X(C(N)), H();
1014
- else {
1015
- const [_, Q] = A;
1016
- if (!_ && !Q || _ && Q)
1017
- m([N, null]), X(`${C(N)} - ...`);
1018
- else if (_ && !Q) {
1019
- const U = N < _ ? [N, _] : [_, N];
1020
- m(U), v(U), n?.(U);
1021
- const [fe, oe] = U;
1022
- X(`${C(fe)} - ${C(oe)}`), H();
1023
- }
1024
- }
1025
- },
1026
- [e, A, q, n, H, C]
1027
- ), ot = $((g) => {
1028
- const N = new Date(u.getFullYear(), g, 1);
1029
- x(N), h === "month" && e === "date" ? (v(N), n?.(N), X(C(N)), H()) : F("day");
1030
- }, [u, h, n, H, e, C]), ct = $((g) => {
1031
- const N = new Date(g, u.getMonth(), 1);
1032
- x(N), h === "year" && e === "date" ? (v(N), n?.(N), X(C(N)), H()) : F("month");
1033
- }, [u, h, n, H, e, C]), Ve = (g) => {
1034
- x((N) => tr(N, g));
1035
- }, Ce = (g) => {
1036
- x((N) => rr(N, g));
1037
- }, Se = $((g, N) => lr(g, N), []), dt = (g) => {
1038
- const N = se(g);
1039
- if (e === "date") return K && Se(N, K);
1040
- const [_] = A[0] ? A : K;
1041
- return ce(_) && Se(N, ce(_));
1042
- }, ut = (g) => {
1043
- if (e !== "range") return !1;
1044
- const N = se(g), [, _] = A[1] ? A : K;
1045
- return ce(_) && Se(N, ce(_));
1046
- }, ft = (g) => {
1047
- if (e !== "range") return !1;
1048
- const N = se(g), [_, Q] = A[0] ? A : K, U = ce(_), fe = ce(Q);
1049
- return U && !fe ? !1 : U && fe && N > se(U) && N < se(fe);
1050
- }, He = (g, N, _) => {
1051
- const Q = nr(g);
1052
- return /* @__PURE__ */ d("div", { className: "w-[300px] p-2 select-none", children: [
1053
- /* @__PURE__ */ d("div", { className: "flex items-center justify-between mb-4 py-1", children: [
1054
- /* @__PURE__ */ r("div", { className: "flex gap-2 w-16", children: N && /* @__PURE__ */ d(he, { children: [
1055
- /* @__PURE__ */ r("button", { onClick: () => Ce(-1), type: "button", className: "hover:bg-slate-100 p-1 rounded transition-colors text-slate-500", children: /* @__PURE__ */ r(xt, { size: 18 }) }),
1056
- /* @__PURE__ */ r("button", { onClick: () => Ve(-1), type: "button", className: "hover:bg-slate-100 p-1 rounded transition-colors text-slate-500", children: /* @__PURE__ */ r(Me, { size: 18 }) })
1057
- ] }) }),
1058
- /* @__PURE__ */ d("div", { className: "flex gap-1 font-semibold text-slate-700 text-sm whitespace-nowrap", children: [
1059
- /* @__PURE__ */ r("span", { className: "cursor-pointer hover:text-blue-600 transition-colors p-1 rounded hover:bg-slate-50", onClick: () => F("month"), children: D.months[g.getMonth()] }),
1060
- /* @__PURE__ */ r("span", { className: "cursor-pointer hover:text-blue-600 transition-colors p-1 rounded hover:bg-slate-50", onClick: () => F("year"), children: g.getFullYear() })
1061
- ] }),
1062
- /* @__PURE__ */ r("div", { className: "flex gap-2 w-16 justify-end", children: _ && /* @__PURE__ */ d(he, { children: [
1063
- /* @__PURE__ */ r("button", { onClick: () => Ve(1), type: "button", className: "hover:bg-slate-100 p-1 rounded transition-colors text-slate-500", children: /* @__PURE__ */ r(Ne, { size: 18 }) }),
1064
- /* @__PURE__ */ r("button", { onClick: () => Ce(1), type: "button", className: "hover:bg-slate-100 p-1 rounded transition-colors text-slate-500", children: /* @__PURE__ */ r(wt, { size: 18 }) })
1065
- ] }) })
1066
- ] }),
1067
- /* @__PURE__ */ r("div", { className: "grid grid-cols-7 mb-1 text-center text-[11px] font-bold text-blue-600 uppercase", children: D.weekdaysShort.map((U) => /* @__PURE__ */ r("div", { className: "py-1", children: U }, U)) }),
1068
- /* @__PURE__ */ r("div", { className: "grid grid-cols-7 gap-y-1 relative", children: Q.map((U, fe) => {
1069
- const oe = U.date, Ze = q(oe), Ee = dt(oe), Ae = ut(oe), pt = ft(oe);
1070
- return /* @__PURE__ */ r("div", { className: s("h-10 flex items-center justify-center relative", pt && "bg-blue-50", Ee && e === "range" && Ae ? "bg-blue-50 rounded-full" : Ee && e === "range" ? "bg-gradient-to-r from-transparent to-blue-50 rounded-l-full" : "", Ae && e === "range" ? "bg-gradient-to-l from-transparent to-blue-50 rounded-r-full" : ""), children: /* @__PURE__ */ r("button", { type: "button", onClick: () => it(oe), disabled: Ze, className: s("w-9 h-9 cursor-pointer rounded-full flex items-center justify-center text-sm font-medium transition-all z-10", U.isCurrentMonth ? "text-slate-700" : "text-slate-300", Ze && "opacity-20 cursor-not-allowed", Ee || Ae ? "bg-blue-600 text-white shadow-md shadow-blue-200 hover:bg-blue-700" : "hover:bg-blue-50", Se(oe, /* @__PURE__ */ new Date()) && !Ee && !Ae && "text-blue-600 border border-blue-600"), children: oe.getDate() }) }, fe);
1071
- }) })
1072
- ] });
1073
- }, mt = () => /* @__PURE__ */ d("div", { className: "w-[300px] p-3", children: [
1074
- /* @__PURE__ */ d("div", { className: "flex justify-between items-center mb-4 px-2", children: [
1075
- /* @__PURE__ */ r("button", { type: "button", onClick: () => Ce(-1), className: "p-1 hover:bg-slate-100 rounded text-slate-500", children: /* @__PURE__ */ r(Me, { size: 20 }) }),
1076
- /* @__PURE__ */ r("span", { className: "font-bold text-slate-800", children: u.getFullYear() }),
1077
- /* @__PURE__ */ r("button", { type: "button", onClick: () => Ce(1), className: "p-1 hover:bg-slate-100 rounded text-slate-500", children: /* @__PURE__ */ r(Ne, { size: 20 }) })
1078
- ] }),
1079
- /* @__PURE__ */ r("div", { className: "grid grid-cols-3 gap-2", children: D.monthsShort.map((g, N) => /* @__PURE__ */ r("button", { type: "button", onClick: () => ot(N), className: s("hover:cursor-pointer py-3 rounded-lg text-sm font-semibold transition-colors", u.getMonth() === N ? "bg-blue-600 text-white" : "hover:bg-blue-50 text-slate-600"), children: g }, g)) })
1080
- ] }), ht = () => {
1081
- const g = Math.floor(u.getFullYear() / 12) * 12 + R * 12, N = Array.from({ length: 12 }, (_, Q) => g + Q);
1082
- return /* @__PURE__ */ d("div", { className: "w-[300px] p-3", children: [
1083
- /* @__PURE__ */ d("div", { className: "flex justify-between items-center mb-4 px-2", children: [
1084
- /* @__PURE__ */ r("button", { type: "button", onClick: () => W((_) => _ - 1), className: "p-1 hover:bg-slate-100 rounded text-slate-500", children: /* @__PURE__ */ r(Me, { size: 20 }) }),
1085
- /* @__PURE__ */ d("span", { className: "font-bold text-slate-800", children: [
1086
- N[0],
1087
- " - ",
1088
- N[11]
1089
- ] }),
1090
- /* @__PURE__ */ r("button", { type: "button", onClick: () => W((_) => _ + 1), className: "p-1 hover:bg-slate-100 rounded text-slate-500", children: /* @__PURE__ */ r(Ne, { size: 20 }) })
1091
- ] }),
1092
- /* @__PURE__ */ r("div", { className: "grid grid-cols-3 gap-2", children: N.map((_) => /* @__PURE__ */ r("button", { type: "button", onClick: () => ct(_), className: s("hover:cursor-pointer py-3 rounded-lg text-sm font-semibold transition-colors", u.getFullYear() === _ ? "bg-blue-600 text-white" : "hover:bg-blue-50 text-slate-600"), children: _ }, _)) })
1093
- ] });
1094
- }, Ue = /* @__PURE__ */ r(
1095
- "div",
1096
- {
1097
- onClick: Z,
1098
- className: s(
1099
- "cursor-pointer flex items-center justify-center p-1 rounded-md transition-colors",
1100
- a ? "pointer-events-none opacity-50" : "hover:bg-slate-100 active:bg-slate-200"
1101
- ),
1102
- children: /* @__PURE__ */ r(gt, { weight: "Linear", size: 20, className: "text-slate-400" })
1103
- }
1104
- );
1105
- return /* @__PURE__ */ d("div", { ref: ie, className: s("relative w-full group", c), children: [
1106
- /* @__PURE__ */ r("div", { ref: O, children: /* @__PURE__ */ r(
1107
- ze,
1108
- {
1109
- label: o,
1110
- placeholder: Array.isArray(l) ? l[0] : l,
1111
- value: V,
1112
- onChange: Y,
1113
- icon: w === "left" ? Ue : void 0,
1114
- rightIcon: w === "right" ? Ue : void 0,
1115
- disabled: a,
1116
- required: i,
1117
- error: S,
1118
- maxLength: e === "date" ? 10 : void 0,
1119
- onFocus: pe,
1120
- onBlur: ke,
1121
- readOnly: !T || e === "range",
1122
- showClearButton: I,
1123
- onClear: ue
1124
- }
1125
- ) }),
1126
- k && /* @__PURE__ */ r(
1127
- "div",
1128
- {
1129
- className: s(
1130
- "absolute top-[calc(100%+4px)] z-[100] bg-white rounded-xl shadow-xl border border-slate-200",
1131
- "flex flex-col md:flex-row overflow-hidden animate-in fade-in zoom-in-95 duration-200",
1132
- le === "right" && "right-0 origin-top-right",
1133
- le === "left" && "left-0 origin-top-left",
1134
- le === "center" && "left-1/2 -translate-x-1/2 origin-top"
1135
- ),
1136
- style: { width: "max-content" },
1137
- onMouseDown: (g) => g.stopPropagation(),
1138
- children: j === "day" ? /* @__PURE__ */ d(he, { children: [
1139
- He(u, !0, e !== "range"),
1140
- e === "range" && /* @__PURE__ */ r("div", { className: "hidden md:block border-l border-slate-100", children: He(new Date(u.getFullYear(), u.getMonth() + 1, 1), !1, !0) })
1141
- ] }) : j === "month" ? mt() : ht()
1142
- }
1143
- )
1144
- ] });
1145
- }
1146
- );
1147
- sr.displayName = "MciPicker";
1148
- const ar = {
1149
- sm: {
1150
- container: "h-9 text-sm",
1151
- padding: "px-2",
1152
- iconPaddingLeft: "pl-7",
1153
- iconPaddingRight: "pr-7",
1154
- iconSize: "w-4 h-4",
1155
- iconWrapper: "left-2",
1156
- rightIconWrapper: "right-2",
1157
- label: "text-sm",
1158
- dropdown: "text-sm"
1159
- },
1160
- md: {
1161
- container: "h-10 text-sm",
1162
- padding: "px-4",
1163
- iconPaddingLeft: "pl-8",
1164
- iconPaddingRight: "pr-8",
1165
- iconSize: "w-5 h-5",
1166
- iconWrapper: "left-3",
1167
- rightIconWrapper: "right-3",
1168
- label: "text-sm",
1169
- dropdown: "text-sm"
1170
- },
1171
- base: {
1172
- container: "h-12 text-base",
1173
- padding: "px-4",
1174
- iconPaddingLeft: "pl-10",
1175
- iconPaddingRight: "pr-10",
1176
- iconSize: "w-5 h-5",
1177
- iconWrapper: "left-4",
1178
- rightIconWrapper: "right-16",
1179
- label: "text-base",
1180
- dropdown: "text-base"
1181
- }
1182
- };
1183
- function ir(e, t, n, l) {
1184
- if (!n || l) return e;
1185
- const o = t.toLowerCase();
1186
- return e.filter((a) => a.label.toLowerCase().includes(o));
1187
- }
1188
- function or(e, t) {
1189
- 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";
1190
- }
1191
- function cr(e, t, n, l) {
1192
- return e ? "text-slate-400" : t ? "text-red-600" : n || l ? "text-black" : "text-slate-400";
1193
- }
1194
- const dr = be(
1195
- ({
1196
- label: e,
1197
- placeholder: t = "Выберите...",
1198
- options: n = [],
1199
- icon: l,
1200
- iconPosition: o = "left",
1201
- size: a = "base",
1202
- error: i,
1203
- disabled: c = !1,
1204
- required: p = !1,
1205
- value: b,
1206
- onChange: y,
1207
- onFocus: S,
1208
- onBlur: I,
1209
- className: T,
1210
- clearable: E = !1,
1211
- searchable: h = !1,
1212
- onSearch: w,
1213
- name: M
1214
- }, O) => {
1215
- const [k, f] = P(!1), [L, v] = P(!1), [A, m] = P(""), [u, x] = P(""), [j, F] = P(-1), R = ae(null), W = ae(null), V = b !== void 0 ? b : A, X = n.find((Y) => Y.value === V), re = V !== "" && V !== void 0, ne = E && re && !c, le = !!(l && o === "right"), te = ar[a], ie = z(() => le && ne ? a === "sm" || a === "md" ? "pr-16" : "pr-20" : le || ne ? a === "sm" ? "pr-11" : a === "md" ? "pr-12" : "pr-14" : a === "sm" ? "pr-8" : a === "md" ? "pr-9" : "pr-10", [le, ne, a]), K = z(() => ir(n, u, h, !!w), [n, u, h, w]), D = $(() => {
1216
- f(!1), v(!1), x(""), F(-1), I?.();
1217
- }, [I]), { handleClick: C } = Le(R, D), { handleEscape: q } = _e(D);
1218
- J(() => {
1219
- if (k)
1220
- return document.addEventListener("mousedown", C), document.addEventListener("keydown", q), () => {
1221
- document.removeEventListener("mousedown", C), document.removeEventListener("keydown", q);
1222
- };
1223
- }, [k, C, q]), J(() => {
1224
- k && h && W.current && W.current.focus();
1225
- }, [k, h]);
1226
- const B = $(() => {
1227
- c || (f((Y) => !Y), k ? (x(""), F(-1)) : (v(!0), S?.()));
1228
- }, [c, k, S]), H = $(
1229
- (Y) => {
1230
- b === void 0 && m(Y), y?.(Y), f(!1), v(!1), x(""), F(-1), I?.();
1231
- },
1232
- [b, y, I]
1233
- ), Z = $(
1234
- (Y) => {
1235
- if (!c) {
1236
- if (!k && (Y.key === "ArrowDown" || Y.key === "ArrowUp" || Y.key === "Enter")) {
1237
- Y.preventDefault(), f(!0);
1238
- return;
1239
- }
1240
- if (k)
1241
- switch (Y.key) {
1242
- case "ArrowDown":
1243
- Y.preventDefault(), F(
1244
- (ue) => ue < K.length - 1 ? ue + 1 : 0
1245
- );
1246
- break;
1247
- case "ArrowUp":
1248
- Y.preventDefault(), F(
1249
- (ue) => ue > 0 ? ue - 1 : K.length - 1
1250
- );
1251
- break;
1252
- case "Enter":
1253
- Y.preventDefault(), j >= 0 && K[j] && H(K[j].value);
1254
- break;
1255
- }
1256
- }
1257
- },
1258
- [k, K, j, c, H]
1259
- ), G = $(
1260
- (Y) => {
1261
- Y.stopPropagation(), !c && (b === void 0 && m(""), y?.(""), x(""), F(-1));
1262
- },
1263
- [b, y, c]
1264
- ), de = $(
1265
- (Y) => {
1266
- x(Y), w?.(Y), F(0);
1267
- },
1268
- [w]
1269
- ), pe = z(() => or(c, i), [i, c]), ke = z(
1270
- () => cr(c, i, k, L),
1271
- [c, i, k, L]
1272
- );
1273
- return /* @__PURE__ */ d("div", { className: s("w-full", T), ref: O, children: [
1274
- e && /* @__PURE__ */ d(
1275
- "label",
1276
- {
1277
- htmlFor: M,
1278
- className: s(
1279
- "mb-2 block text-base font-medium",
1280
- i ? "text-red-600" : "text-slate-700",
1281
- te.label
1282
- ),
1283
- children: [
1284
- e,
1285
- p && /* @__PURE__ */ r("span", { className: "ml-1 text-red-600", children: "*" })
1286
- ]
1287
- }
1288
- ),
1289
- /* @__PURE__ */ d(
1290
- "div",
1291
- {
1292
- ref: R,
1293
- className: "relative",
1294
- onKeyDown: Z,
1295
- children: [
1296
- /* @__PURE__ */ d(
1297
- "div",
1298
- {
1299
- role: "combobox",
1300
- "aria-expanded": k,
1301
- "aria-haspopup": "listbox",
1302
- "aria-controls": `${M}-listbox`,
1303
- "aria-disabled": c,
1304
- tabIndex: c ? -1 : 0,
1305
- onClick: B,
1306
- className: s(
1307
- "flex w-full items-center border font-normal transition-all duration-300 ease-in-out",
1308
- a === "base" ? "rounded-xl" : "rounded-lg",
1309
- te.container,
1310
- l && o === "left" ? te.iconPaddingLeft : te.padding,
1311
- ie,
1312
- pe,
1313
- !c && L && "shadow-blue border-blue-600"
1314
- ),
1315
- children: [
1316
- l && /* @__PURE__ */ r(
1317
- "div",
1318
- {
1319
- className: s(
1320
- "absolute top-1/2 -translate-y-1/2 pointer-events-none transition-colors duration-300",
1321
- o === "left" ? te.iconWrapper : te.rightIconWrapper,
1322
- ke
1323
- ),
1324
- children: l
1325
- }
1326
- ),
1327
- h && k ? /* @__PURE__ */ r(
1328
- "input",
1329
- {
1330
- ref: W,
1331
- type: "text",
1332
- value: u,
1333
- onChange: (Y) => de(Y.target.value),
1334
- placeholder: t,
1335
- className: "w-full min-w-0 flex-1 bg-transparent outline-none",
1336
- onClick: (Y) => Y.stopPropagation()
1337
- }
1338
- ) : /* @__PURE__ */ r(
1339
- "span",
1340
- {
1341
- title: X?.label || t,
1342
- className: s(
1343
- "block min-w-0 flex-1 truncate select-none",
1344
- !re && !c && "text-slate-400"
1345
- ),
1346
- children: X?.label || t
1347
- }
1348
- ),
1349
- ne && /* @__PURE__ */ r(
1350
- "button",
1351
- {
1352
- type: "button",
1353
- onClick: G,
1354
- className: s(
1355
- "absolute top-1/2 -translate-y-1/2 text-slate-400 hover:text-black transition-colors cursor-pointer",
1356
- le ? a === "sm" ? "right-8" : a === "md" ? "right-9" : "right-10" : a === "sm" ? "right-7" : a === "md" ? "right-8" : "right-9"
1357
- ),
1358
- "aria-label": "Очистить",
1359
- children: /* @__PURE__ */ r(ge, { className: te.iconSize })
1360
- }
1361
- ),
1362
- /* @__PURE__ */ r(
1363
- "div",
1364
- {
1365
- className: s(
1366
- "absolute top-1/2 -translate-y-1/2 pointer-events-none transition-all duration-300",
1367
- a === "sm" ? "right-2" : "right-3",
1368
- k && "rotate-180",
1369
- ke
1370
- ),
1371
- children: /* @__PURE__ */ r(Fe, { className: te.iconSize })
1372
- }
1373
- )
1374
- ]
1375
- }
1376
- ),
1377
- k && !c && /* @__PURE__ */ r(
1378
- "div",
1379
- {
1380
- id: `${M}-listbox`,
1381
- role: "listbox",
1382
- className: s(
1383
- "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",
1384
- te.dropdown
1385
- ),
1386
- children: K.length === 0 ? /* @__PURE__ */ r("div", { className: "px-3 py-2 text-center text-base font-normal text-slate-500", children: "Ничего не найдено" }) : K.map((Y) => /* @__PURE__ */ r(
1387
- "div",
1388
- {
1389
- role: "option",
1390
- "aria-selected": V === Y.value,
1391
- onClick: () => H(Y.value),
1392
- title: Y.label,
1393
- className: s(
1394
- "cursor-pointer truncate px-3 py-2 font-normal transition-colors hover:bg-slate-100 rounded-sm",
1395
- V === Y.value ? "bg-slate-100" : ""
1396
- ),
1397
- children: Y.label
1398
- },
1399
- Y.value
1400
- ))
1401
- }
1402
- )
1403
- ]
1404
- }
1405
- ),
1406
- i && /* @__PURE__ */ r("p", { className: "mt-2 animate-[slideDown_0.3s_ease-out] text-sm font-normal text-red-600", children: i })
1407
- ] });
1408
- }
1409
- );
1410
- dr.displayName = "MciSelect";
1411
- function ur({ children: e, title: t }) {
1412
- return /* @__PURE__ */ r("div", { className: "min-w-0", children: /* @__PURE__ */ r("div", { className: "clamp-2 break-words", title: t ?? (typeof e == "string" ? e : void 0), children: e }) });
1413
- }
1414
- function fr(e) {
1415
- if (e != null)
1416
- return typeof e == "number" ? `${e}px` : e;
1417
- }
1418
- function mr(e, t, n) {
1419
- return !t || n ? e : [...e].sort((l, o) => {
1420
- const a = l[t.key], i = o[t.key];
1421
- return a == null ? 1 : i == null ? -1 : a < i ? t.direction === "asc" ? -1 : 1 : a > i ? t.direction === "asc" ? 1 : -1 : 0;
1422
- });
1423
- }
1424
- function wn({
1425
- columns: e,
1426
- data: t = [],
1427
- loading: n = !1,
1428
- skeletonRows: l = 5,
1429
- noDataText: o = "",
1430
- sort: a,
1431
- onSortChange: i,
1432
- className: c,
1433
- headerClassName: p,
1434
- bodyClassName: b,
1435
- rowKey: y = "id",
1436
- rowSelection: S
1437
- }) {
1438
- const [I, T] = P(null), E = a ?? I, h = z(() => Array.isArray(t) ? t : [], [t]), w = z(() => mr(h, E, !!a), [h, E, a]);
1439
- J(() => {
1440
- a !== void 0 && T(null);
1441
- }, [a]);
1442
- const M = z(
1443
- () => n ? [] : a ? h : w,
1444
- [n, a, h, w]
1445
- ), O = $(
1446
- (m) => {
1447
- if (!m.sortable) return;
1448
- let u = null;
1449
- E?.key !== m.key ? u = { key: m.key, direction: "asc" } : E.direction === "asc" && (u = { key: m.key, direction: "desc" }), a !== void 0 ? i?.(u) : T(u);
1450
- },
1451
- [E, a, i]
1452
- ), k = (m) => {
1453
- if (!S) return;
1454
- const { onChange: u, getCheckboxProps: x } = S;
1455
- if (m.target.checked) {
1456
- const R = M.filter((W) => !x?.(W)?.disabled).map((W) => W[y]);
1457
- u(R);
1458
- } else
1459
- u([]);
1460
- }, f = (m, u) => {
1461
- if (!S) return;
1462
- const { selectedRowKeys: x, onChange: j } = S, F = m[y], R = u ? [...x, F] : x.filter((W) => W !== F);
1463
- j(R);
1464
- }, L = z(() => {
1465
- if (!S || M.length === 0) return !1;
1466
- const m = M.filter((u) => !S.getCheckboxProps?.(u)?.disabled);
1467
- return m.length === 0 ? !1 : m.every(
1468
- (u) => S.selectedRowKeys.includes(u[y])
1469
- );
1470
- }, [S, M, y]), v = (m) => m.sortable ? !E || E.key !== m.key ? /* @__PURE__ */ r(vt, { weight: "Linear", size: 20, className: "text-slate-base shrink-0" }) : E.direction === "asc" ? /* @__PURE__ */ r(Nt, { weight: "Linear", size: 20, className: "text-slate-base shrink-0" }) : /* @__PURE__ */ r(kt, { weight: "Linear", size: 20, className: "text-slate-base shrink-0" }) : null, A = () => /* @__PURE__ */ d("colgroup", { children: [
1471
- S && /* @__PURE__ */ r("col", { style: { width: 48 } }),
1472
- e.map((m) => /* @__PURE__ */ r("col", { style: { width: fr(m.width) ?? "auto" } }, m.key))
1473
- ] });
1474
- return /* @__PURE__ */ r(
1475
- "div",
1476
- {
1477
- className: s(
1478
- "w-full overflow-x-auto pb-0.5",
1479
- "[&::-webkit-scrollbar]:h-1",
1480
- "[&::-webkit-scrollbar-track]:bg-transparent",
1481
- "[&::-webkit-scrollbar-thumb]:bg-slate-200",
1482
- "[&::-webkit-scrollbar-thumb]:rounded-full",
1483
- "hover:[&::-webkit-scrollbar-thumb]:bg-slate-300",
1484
- c
1485
- ),
1486
- children: /* @__PURE__ */ d("div", { className: "inline-block min-w-full align-middle", children: [
1487
- /* @__PURE__ */ r("div", { className: "overflow-hidden rounded-xl border border-slate-200 bg-slate-100", children: /* @__PURE__ */ d("table", { className: "w-full table-fixed", children: [
1488
- A(),
1489
- /* @__PURE__ */ r("thead", { children: /* @__PURE__ */ d("tr", { children: [
1490
- S && /* @__PURE__ */ r("th", { className: s("w-12 px-4 py-3", p), children: /* @__PURE__ */ r("div", { className: "flex items-center justify-center", children: /* @__PURE__ */ r(
1491
- Ie,
1492
- {
1493
- checked: L,
1494
- onChange: k,
1495
- variant: "yellow",
1496
- disabled: n || M.length === 0
1497
- }
1498
- ) }) }),
1499
- e.map((m) => /* @__PURE__ */ r(
1500
- "th",
1501
- {
1502
- onClick: () => O(m),
1503
- className: s(
1504
- "px-4 py-3 text-left text-sm font-medium text-slate-700 transition-colors",
1505
- "whitespace-nowrap overflow-hidden text-ellipsis",
1506
- m.align === "center" && "text-center",
1507
- m.align === "right" && "text-right",
1508
- m.sortable && "cursor-pointer hover:bg-slate-200",
1509
- p
1510
- ),
1511
- children: /* @__PURE__ */ d("div", { className: s("flex items-center gap-2 min-w-0", m.align === "right" && "justify-end"), children: [
1512
- /* @__PURE__ */ r("span", { className: "min-w-0 flex-1 truncate", title: m.title, children: m.title }),
1513
- v(m)
1514
- ] })
1515
- },
1516
- m.key
1517
- ))
1518
- ] }) })
1519
- ] }) }),
1520
- /* @__PURE__ */ r("div", { className: "rounded-xl border border-t-0 border-slate-200 bg-white overflow-hidden", children: /* @__PURE__ */ d("table", { className: "w-full table-fixed", children: [
1521
- A(),
1522
- /* @__PURE__ */ r("tbody", { className: "divide-y divide-slate-200", children: n ? Array.from({ length: l }).map((m, u) => /* @__PURE__ */ d("tr", { children: [
1523
- S && /* @__PURE__ */ r("td", { className: "w-12 px-4 py-3", children: /* @__PURE__ */ r(Ge, { height: 20, width: 20, variant: "rounded" }) }),
1524
- e.map((x) => /* @__PURE__ */ r("td", { className: "px-4 py-3", children: /* @__PURE__ */ r(Ge, { height: 30, variant: "rounded" }) }, x.key))
1525
- ] }, u)) : M.length === 0 ? /* @__PURE__ */ r("tr", { children: /* @__PURE__ */ r("td", { colSpan: e.length + (S ? 1 : 0), className: "py-20", children: /* @__PURE__ */ d("div", { className: "flex flex-col items-center justify-center", children: [
1526
- /* @__PURE__ */ r("div", { className: "relative mb-4", children: /* @__PURE__ */ r(yt, { weight: "Bold", size: 64, className: "animate-float text-slate-400" }) }),
1527
- /* @__PURE__ */ r("p", { className: "text-sm font-medium text-slate-400", children: o })
1528
- ] }) }) }) : M.map((m, u) => {
1529
- const x = m[y], j = S?.selectedRowKeys.includes(x), F = S?.getCheckboxProps?.(m)?.disabled;
1530
- return /* @__PURE__ */ d("tr", { className: "group transition-colors hover:bg-slate-50", children: [
1531
- S && /* @__PURE__ */ r("td", { className: s("w-12 px-4 py-3 align-top", b), children: /* @__PURE__ */ r("div", { className: "flex items-center justify-center pt-1", children: /* @__PURE__ */ r(
1532
- Ie,
1533
- {
1534
- checked: j,
1535
- disabled: F,
1536
- variant: "yellow",
1537
- onChange: (R) => f(m, R.target.checked)
1538
- }
1539
- ) }) }),
1540
- e.map((R) => {
1541
- const W = m[R.key], V = R.render ? R.render(W, m) : String(W ?? "-");
1542
- return /* @__PURE__ */ r(
1543
- "td",
1544
- {
1545
- className: s(
1546
- "align-top px-4 py-3 text-sm font-normal text-black",
1547
- "min-w-0 whitespace-normal",
1548
- R.align === "center" && "text-center",
1549
- R.align === "right" && "text-right",
1550
- b,
1551
- R.className
1552
- ),
1553
- children: /* @__PURE__ */ r(ur, { title: typeof V == "string" ? V : void 0, children: V })
1554
- },
1555
- R.key
1556
- );
1557
- })
1558
- ] }, u);
1559
- }) })
1560
- ] }) })
1561
- ] })
1562
- }
1563
- );
1564
- }
1565
- const hr = {
1566
- uz: {
1567
- dragAndDrop: "Faylni bu yerga torting",
1568
- clickToUpload: "yoki bosib tanlang",
1569
- or: "yoki",
1570
- dropHereTitle: "Faylni shu yerga yuklang",
1571
- fileRequirements: (e, t, n, l) => `${e ? `Maksimum ${t} ta fayl` : "1 ta fayl"} • ${n}MB gacha • ${l !== "*/*" ? `Format: ${l}` : "Barcha formatlar"}`,
1572
- selectedFiles: "Tanlangan fayllar",
1573
- clearAll: "Barchasini o‘chirish",
1574
- uploading: "Yuklanmoqda...",
1575
- success: "Yuklandi",
1576
- error: "Xatolik",
1577
- preview: "Ko‘rish",
1578
- download: "Yuklab olish",
1579
- remove: "O‘chirish",
1580
- maxFilesError: (e) => `Maksimum ${e} ta fayl yuklash mumkin`,
1581
- fileSizeError: (e, t) => `"${e}" fayl hajmi ${t}MB dan kichik bo‘lishi kerak`,
1582
- fileTypeError: (e) => `"${e}" fayl turi qabul qilinmaydi`,
1583
- blockedFileTypeError: (e) => `"${e}" fayli xavfsizlik sabab bloklandi (arxiv yoki bajariladigan fayl)`,
1584
- uploadFailed: "Yuklash muvaffaqiyatsiz tugadi",
1585
- file: "Fayl",
1586
- image: "Rasm",
1587
- video: "Video",
1588
- audio: "Audio",
1589
- document: "Hujjat"
1590
- },
1591
- ru: {
1592
- dragAndDrop: "Перетащите файл сюда",
1593
- clickToUpload: "или выберите нажатием",
1594
- or: "или",
1595
- dropHereTitle: "Загрузите свой файл сюда",
1596
- fileRequirements: (e, t, n, l) => `${e ? `Максимум ${t} файлов` : "1 файл"} • До ${n}MB • ${l !== "*/*" ? `Формат: ${l}` : "Все форматы"}`,
1597
- selectedFiles: "Выбранные файлы",
1598
- clearAll: "Очистить все",
1599
- uploading: "Загружается...",
1600
- success: "Загружено",
1601
- error: "Ошибка",
1602
- preview: "Просмотр",
1603
- download: "Скачать",
1604
- remove: "Удалить",
1605
- maxFilesError: (e) => `Можно загрузить максимум ${e} файлов`,
1606
- fileSizeError: (e, t) => `Размер файла "${e}" должен быть меньше ${t}MB`,
1607
- fileTypeError: (e) => `Тип файла "${e}" не поддерживается`,
1608
- blockedFileTypeError: (e) => `Файл "${e}" заблокирован политикой безопасности (архив или исполняемый тип)`,
1609
- uploadFailed: "Не удалось загрузить файл",
1610
- file: "Файл",
1611
- image: "Изображение",
1612
- video: "Видео",
1613
- audio: "Аудио",
1614
- document: "Документ"
1615
- },
1616
- en: {
1617
- dragAndDrop: "Drag and drop a file here",
1618
- clickToUpload: "or click to select",
1619
- or: "or",
1620
- dropHereTitle: "Upload your file here",
1621
- fileRequirements: (e, t, n, l) => `${e ? `Up to ${t} files` : "1 file"} • Up to ${n}MB • ${l !== "*/*" ? `Format: ${l}` : "All formats"}`,
1622
- selectedFiles: "Selected files",
1623
- clearAll: "Clear all",
1624
- uploading: "Uploading...",
1625
- success: "Uploaded",
1626
- error: "Error",
1627
- preview: "Preview",
1628
- download: "Download",
1629
- remove: "Remove",
1630
- maxFilesError: (e) => `You can upload up to ${e} files`,
1631
- fileSizeError: (e, t) => `File "${e}" must be smaller than ${t}MB`,
1632
- fileTypeError: (e) => `File type "${e}" is not supported`,
1633
- blockedFileTypeError: (e) => `File "${e}" is blocked by security policy (archive or executable type)`,
1634
- uploadFailed: "Upload failed",
1635
- file: "File",
1636
- image: "Image",
1637
- video: "Video",
1638
- audio: "Audio",
1639
- document: "Document"
1640
- }
1641
- }, We = [
1642
- "pdf",
1643
- "doc",
1644
- "docx",
1645
- "xls",
1646
- "xlsx",
1647
- "ppt",
1648
- "pptx",
1649
- "txt",
1650
- "jpg",
1651
- "jpeg",
1652
- "png",
1653
- "bmp",
1654
- "tiff"
1655
- ], pr = [
1656
- "zip",
1657
- "rar",
1658
- "7z",
1659
- "tar",
1660
- "gz",
1661
- "bz2",
1662
- "xz",
1663
- "tgz",
1664
- "tbz2",
1665
- "txz",
1666
- "iso",
1667
- "cab",
1668
- "arj",
1669
- "lz",
1670
- "lzh",
1671
- "z",
1672
- "exe",
1673
- "bat",
1674
- "cmd",
1675
- "com",
1676
- "msi",
1677
- "scr",
1678
- "pif",
1679
- "js",
1680
- "mjs",
1681
- "cjs",
1682
- "jse",
1683
- "vbs",
1684
- "vbe",
1685
- "wsf",
1686
- "wsh",
1687
- "ps1",
1688
- "psm1",
1689
- "sh",
1690
- "bash",
1691
- "zsh",
1692
- "ksh",
1693
- "csh",
1694
- "fish"
1695
- ], ye = new Set(We), ve = new Set(pr), br = We.map((e) => `.${e}`).join(","), gr = {
1696
- "image/*": ["jpg", "jpeg", "png", "bmp", "tiff"],
1697
- "text/*": ["txt"]
1698
- }, xr = {
1699
- "application/pdf": ["pdf"],
1700
- "application/msword": ["doc"],
1701
- "application/vnd.openxmlformats-officedocument.wordprocessingml.document": ["docx"],
1702
- "application/vnd.ms-excel": ["xls"],
1703
- "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": ["xlsx"],
1704
- "application/vnd.ms-powerpoint": ["ppt"],
1705
- "application/vnd.openxmlformats-officedocument.presentationml.presentation": ["pptx"],
1706
- "text/plain": ["txt"],
1707
- "image/jpg": ["jpg"],
1708
- "image/jpeg": ["jpg", "jpeg"],
1709
- "image/png": ["png"],
1710
- "image/bmp": ["bmp"],
1711
- "image/tiff": ["tiff"]
1712
- }, wr = /* @__PURE__ */ new Set([
1713
- "application/zip",
1714
- "application/x-zip-compressed",
1715
- "application/x-rar-compressed",
1716
- "application/vnd.rar",
1717
- "application/x-7z-compressed",
1718
- "application/x-msdownload",
1719
- "application/x-msdos-program",
1720
- "application/x-executable",
1721
- "application/x-bat",
1722
- "application/x-msi",
1723
- "application/javascript",
1724
- "text/javascript",
1725
- "application/x-javascript",
1726
- "application/x-sh",
1727
- "application/x-csh",
1728
- "text/x-shellscript",
1729
- "application/x-powershell"
1730
- ]);
1731
- function yr(e) {
1732
- const t = e.trim().toLowerCase(), n = t.lastIndexOf(".");
1733
- return n <= 0 || n === t.length - 1 ? "" : t.slice(n + 1);
1734
- }
1735
- function vr(e) {
1736
- return e.split(",").map((t) => t.trim().toLowerCase()).filter(Boolean);
1737
- }
1738
- function Ye(e) {
1739
- if (!e || e === "*/*") return null;
1740
- const t = vr(e), n = /* @__PURE__ */ new Set();
1741
- for (const l of t)
1742
- if (l !== "*/*") {
1743
- if (l.endsWith("/*")) {
1744
- const o = gr[l];
1745
- if (!o) continue;
1746
- for (const a of o)
1747
- ye.has(a) && !ve.has(a) && n.add(a);
1748
- continue;
1749
- }
1750
- if (l.startsWith(".")) {
1751
- const o = l.slice(1);
1752
- ye.has(o) && !ve.has(o) && n.add(o);
1753
- continue;
1754
- }
1755
- if (l.includes("/")) {
1756
- const o = xr[l];
1757
- if (!o) continue;
1758
- for (const a of o)
1759
- ye.has(a) && !ve.has(a) && n.add(a);
1760
- continue;
1761
- }
1762
- ye.has(l) && !ve.has(l) && n.add(l);
1763
- }
1764
- return n.size > 0 ? n : null;
1765
- }
1766
- function Nr(e) {
1767
- const t = Ye(e);
1768
- return t ? Array.from(t).map((n) => `.${n}`).join(",") : br;
1769
- }
1770
- function kr(e) {
1771
- const t = Ye(e);
1772
- return t ? Array.from(t).join(", ") : We.join(", ");
1773
- }
1774
- function Cr(e) {
1775
- switch (e.type.split("/")[0]) {
1776
- case "image":
1777
- return /* @__PURE__ */ r(Et, { className: "h-5 w-5 text-blue-500" });
1778
- case "video":
1779
- return /* @__PURE__ */ r(St, { className: "h-5 w-5 text-purple-500" });
1780
- case "audio":
1781
- return /* @__PURE__ */ r(Ct, { className: "h-5 w-5 text-green-500" });
1782
- default:
1783
- return e.type.includes("pdf") ? /* @__PURE__ */ r(je, { className: "h-5 w-5 text-red-500" }) : e.type.includes("word") || e.type.includes("document") ? /* @__PURE__ */ r(je, { className: "h-5 w-5 text-blue-600" }) : e.type.includes("excel") || e.type.includes("spreadsheet") ? /* @__PURE__ */ r(je, { className: "h-5 w-5 text-green-600" }) : /* @__PURE__ */ r(st, { className: "h-5 w-5 text-gray-500" });
1784
- }
1785
- }
1786
- function Sr(e) {
1787
- if (e === 0) return "0 Bytes";
1788
- const t = 1024, n = ["Bytes", "KB", "MB", "GB"], l = Math.floor(Math.log(e) / Math.log(t));
1789
- return parseFloat((e / Math.pow(t, l)).toFixed(2)) + " " + n[l];
1790
- }
1791
- function Er(e, t) {
1792
- const n = t * 1024 * 1024;
1793
- return e.size <= n;
1794
- }
1795
- function Ar(e, t) {
1796
- const n = yr(e.name), l = e.type.trim().toLowerCase();
1797
- if (l && wr.has(l))
1798
- return { isValid: !1, reason: "blocked" };
1799
- if (!n) return { isValid: !1, reason: "not-allowed" };
1800
- if (ve.has(n)) return { isValid: !1, reason: "blocked" };
1801
- if (!ye.has(n)) return { isValid: !1, reason: "not-allowed" };
1802
- const o = Ye(t);
1803
- return o && !o.has(n) ? { isValid: !1, reason: "not-allowed" } : { isValid: !0 };
1804
- }
1805
- function Dr(e) {
1806
- return new Promise((t) => {
1807
- if (e.type.startsWith("image/")) {
1808
- const n = new FileReader();
1809
- n.onload = (l) => t(l.target?.result ?? ""), n.readAsDataURL(e);
1810
- } else
1811
- t("");
1812
- });
1813
- }
1814
- const Mr = {
1815
- blue: {
1816
- dropBorder: "border-blue-200 hover:border-blue-300",
1817
- dropBg: "bg-blue-50/40 hover:bg-blue-50/60",
1818
- dropActive: "border-blue-600 bg-blue-50",
1819
- iconWrap: "text-blue-600",
1820
- title: "text-blue-600",
1821
- hint: "text-slate-500",
1822
- progress: "bg-blue-600/30",
1823
- progressFill: "bg-blue-600",
1824
- fileIconImg: "bg-blue-50 text-blue-600",
1825
- fileIconDoc: "bg-green-50 text-green-600"
1826
- },
1827
- yellow: {
1828
- dropBorder: "border-yellow-200 hover:border-yellow-300",
1829
- dropBg: "bg-yellow-50/40 hover:bg-yellow-50/60",
1830
- dropActive: "border-yellow-500 bg-yellow-50",
1831
- iconWrap: "text-yellow-700",
1832
- title: "text-yellow-700",
1833
- hint: "text-slate-500",
1834
- progress: "bg-yellow-600/25",
1835
- progressFill: "bg-yellow-600",
1836
- fileIconImg: "bg-blue-50 text-blue-600",
1837
- fileIconDoc: "bg-green-50 text-green-600"
1838
- }
1839
- }, yn = ({
1840
- multiple: e = !1,
1841
- accept: t = "*/*",
1842
- maxSize: n = 10,
1843
- maxFiles: l = 5,
1844
- disabled: o = !1,
1845
- label: a,
1846
- required: i = !1,
1847
- error: c,
1848
- className: p,
1849
- onFilesChange: b,
1850
- onUpload: y,
1851
- showPreview: S = !0,
1852
- locale: I = "uz",
1853
- showFileTypeIcon: T = !0,
1854
- variant: E = "yellow",
1855
- customValidator: h
1856
- }) => {
1857
- const [w, M] = P([]), [O, k] = P(!1), [f, L] = P(!1), v = ae(null), A = hr[I], m = z(() => Mr[E], [E]), u = z(() => Nr(t), [t]), x = z(() => kr(t), [t]), j = ae(/* @__PURE__ */ new Map()), F = $((D) => {
1858
- const C = j.current.get(D);
1859
- C && (URL.revokeObjectURL(C), j.current.delete(D));
1860
- }, []), R = $(() => {
1861
- for (const D of j.current.values())
1862
- URL.revokeObjectURL(D);
1863
- j.current.clear();
1864
- }, []);
1865
- J(() => () => {
1866
- R();
1867
- }, [R]);
1868
- const W = $((D) => {
1869
- let C = j.current.get(D.id);
1870
- C || (C = URL.createObjectURL(D.file), j.current.set(D.id, C), setTimeout(() => F(D.id), 5 * 6e4)), window.open(C, "_blank", "noopener,noreferrer");
1871
- }, [F]), V = $(
1872
- async (D) => {
1873
- const C = Array.from(D), q = [];
1874
- for (const B of C) {
1875
- if (w.length + q.length >= l) {
1876
- alert(A.maxFilesError(l));
1877
- break;
1878
- }
1879
- if (!Er(B, n)) {
1880
- alert(A.fileSizeError(B.name, n));
1881
- continue;
1882
- }
1883
- const H = Ar(B, t);
1884
- if (!H.isValid) {
1885
- H.reason === "blocked" ? alert(A.blockedFileTypeError(B.name)) : alert(A.fileTypeError(B.name));
1886
- continue;
1887
- }
1888
- if (h) {
1889
- const pe = h(B);
1890
- if (pe) {
1891
- alert(pe);
1892
- continue;
1893
- }
1894
- }
1895
- const Z = await Dr(B), G = y ? "uploading" : "success", de = y ? 0 : 100;
1896
- q.push({
1897
- id: Math.random().toString(36).substr(2, 9),
1898
- file: B,
1899
- preview: Z,
1900
- progress: de,
1901
- status: G
1902
- });
1903
- }
1904
- if (q.length > 0) {
1905
- const B = e ? [...w, ...q] : q;
1906
- if (M(B), b?.(B.map((H) => H.file)), y) {
1907
- L(!0);
1908
- try {
1909
- const H = B.map((Z, G) => ({
1910
- ...Z,
1911
- progress: Math.min(100, (G + 1) / B.length * 100)
1912
- }));
1913
- M(H), await y(H), M(
1914
- (Z) => Z.map((G) => ({
1915
- ...G,
1916
- status: "success",
1917
- progress: 100
1918
- }))
1919
- );
1920
- } catch (H) {
1921
- M(
1922
- (Z) => Z.map((G) => ({
1923
- ...G,
1924
- status: "error",
1925
- error: H instanceof Error ? H.message : A.uploadFailed
1926
- }))
1927
- );
1928
- } finally {
1929
- L(!1);
1930
- }
1931
- }
1932
- }
1933
- },
1934
- [
1935
- w,
1936
- l,
1937
- h,
1938
- A,
1939
- t,
1940
- n,
1941
- e,
1942
- b,
1943
- y
1944
- ]
1945
- ), X = $(
1946
- (D) => {
1947
- D.preventDefault(), o || k(!0);
1948
- },
1949
- [o]
1950
- ), re = $((D) => {
1951
- D.preventDefault(), k(!1);
1952
- }, []), ne = $(
1953
- (D) => {
1954
- if (D.preventDefault(), k(!1), o) return;
1955
- const C = D.dataTransfer.files;
1956
- C.length > 0 && V(C);
1957
- },
1958
- [o, V]
1959
- ), le = $(
1960
- (D) => {
1961
- const C = D.target.files;
1962
- C && C.length > 0 && (V(C), v.current && (v.current.value = ""));
1963
- },
1964
- [V]
1965
- ), te = $(
1966
- (D) => {
1967
- F(D), M((C) => {
1968
- const q = C.filter((B) => B.id !== D);
1969
- return b?.(q.map((B) => B.file)), q;
1970
- });
1971
- },
1972
- [b, F]
1973
- ), ie = $(() => {
1974
- R(), M([]), b?.([]);
1975
- }, [b, R]), K = $(() => {
1976
- v.current?.click();
1977
- }, []);
1978
- return /* @__PURE__ */ d("div", { className: s("w-full", p), children: [
1979
- a && /* @__PURE__ */ d(
1980
- "label",
1981
- {
1982
- className: s(
1983
- "mb-2 block text-base font-medium",
1984
- c ? "text-red-600" : "text-slate-700"
1985
- ),
1986
- children: [
1987
- a,
1988
- i && /* @__PURE__ */ r("span", { className: "ml-1 text-extra-small text-red-600", children: "*" })
1989
- ]
1990
- }
1991
- ),
1992
- /* @__PURE__ */ d(
1993
- "div",
1994
- {
1995
- className: s(
1996
- "group relative flex min-h-[180px] w-full cursor-pointer items-center justify-center rounded-2xl border border-dashed p-6 text-center transition-all duration-300",
1997
- m.dropBorder,
1998
- m.dropBg,
1999
- O && m.dropActive,
2000
- o && "cursor-not-allowed opacity-60",
2001
- c && "border-red-600 bg-red-50/30"
2002
- ),
2003
- onDragOver: X,
2004
- onDragLeave: re,
2005
- onDrop: ne,
2006
- onClick: K,
2007
- children: [
2008
- /* @__PURE__ */ r(
2009
- "input",
2010
- {
2011
- ref: v,
2012
- type: "file",
2013
- multiple: e,
2014
- accept: u,
2015
- onChange: le,
2016
- disabled: o,
2017
- className: "hidden"
2018
- }
2019
- ),
2020
- /* @__PURE__ */ d("div", { className: "flex flex-col items-center gap-3", children: [
2021
- /* @__PURE__ */ r("div", { className: s("flex h-12 w-12 items-center justify-center rounded-xl", m.iconWrap), children: /* @__PURE__ */ r(At, { size: 20 }) }),
2022
- /* @__PURE__ */ r("p", { className: s("text-base font-medium", m.title), children: A.dropHereTitle }),
2023
- /* @__PURE__ */ r("p", { className: s("text-sm font-normal", m.hint), children: A.fileRequirements(e, l, n, x) })
2024
- ] })
2025
- ]
2026
- }
2027
- ),
2028
- w.length > 0 && /* @__PURE__ */ d("div", { className: "mt-4 space-y-3", children: [
2029
- /* @__PURE__ */ d("div", { className: "flex items-center justify-between", children: [
2030
- /* @__PURE__ */ d("span", { className: "text-sm font-medium text-slate-700", children: [
2031
- A.selectedFiles,
2032
- " (",
2033
- w.length,
2034
- ")"
2035
- ] }),
2036
- w.length > 1 && /* @__PURE__ */ r(
2037
- "button",
2038
- {
2039
- type: "button",
2040
- onClick: ie,
2041
- disabled: o || f,
2042
- className: "text-sm font-medium text-red-600 disabled:opacity-50",
2043
- children: A.clearAll
2044
- }
2045
- )
2046
- ] }),
2047
- /* @__PURE__ */ r("div", { className: "space-y-3", children: w.map((D) => {
2048
- const q = !!D.preview ? m.fileIconImg : m.fileIconDoc, B = o || f || D.status === "uploading";
2049
- return /* @__PURE__ */ d(
2050
- "div",
2051
- {
2052
- className: s(
2053
- "flex items-center justify-between rounded-2xl border border-slate-200 p-4",
2054
- D.status === "error" && "border-red-600"
2055
- ),
2056
- children: [
2057
- /* @__PURE__ */ d("div", { className: "flex min-w-0 items-center gap-4", children: [
2058
- /* @__PURE__ */ r(
2059
- "div",
2060
- {
2061
- className: s(
2062
- "flex h-14 w-14 items-center justify-center rounded-2xl",
2063
- q
2064
- ),
2065
- children: S && D.preview ? /* @__PURE__ */ r(
2066
- "img",
2067
- {
2068
- src: D.preview,
2069
- alt: D.file.name,
2070
- className: "h-10 w-10 rounded-xl object-cover"
2071
- }
2072
- ) : T ? Cr(D.file) : /* @__PURE__ */ r(st, { className: "h-6 w-6 text-slate-500" })
2073
- }
2074
- ),
2075
- /* @__PURE__ */ d("div", { className: "min-w-0", children: [
2076
- /* @__PURE__ */ r("p", { className: "truncate text-lg font-semibold text-primary", children: D.file.name }),
2077
- /* @__PURE__ */ d("div", { className: "mt-1 flex flex-wrap items-center gap-2 text-sm text-slate-500", children: [
2078
- /* @__PURE__ */ r("span", { children: Sr(D.file.size) }),
2079
- D.status === "uploading" && /* @__PURE__ */ d(he, { children: [
2080
- /* @__PURE__ */ r("span", { children: "•" }),
2081
- /* @__PURE__ */ d("span", { className: "inline-flex items-center", children: [
2082
- /* @__PURE__ */ r(nt, { className: "mr-1 h-5 w-5 animate-spin" }),
2083
- A.uploading
2084
- ] })
2085
- ] }),
2086
- D.status === "success" && /* @__PURE__ */ d(he, { children: [
2087
- /* @__PURE__ */ r("span", { children: "•" }),
2088
- /* @__PURE__ */ r("span", { className: "font-normal text-green-600", children: A.success })
2089
- ] })
2090
- ] }),
2091
- D.status === "uploading" && /* @__PURE__ */ r("div", { className: s("mt-2 h-1.5 w-full rounded-full bg-slate-200"), children: /* @__PURE__ */ r(
2092
- "div",
2093
- {
2094
- className: s(
2095
- "h-1.5 rounded-full transition-all duration-300",
2096
- m.progressFill
2097
- ),
2098
- style: { width: `${D.progress}%` }
2099
- }
2100
- ) }),
2101
- D.status === "error" && D.error && /* @__PURE__ */ r("p", { className: "mt-2 text-sm font-normal text-red-600", children: D.error })
2102
- ] })
2103
- ] }),
2104
- /* @__PURE__ */ d("div", { className: "flex items-center gap-2", children: [
2105
- /* @__PURE__ */ r(
2106
- "button",
2107
- {
2108
- type: "button",
2109
- onClick: (H) => {
2110
- H.stopPropagation(), B || W(D);
2111
- },
2112
- disabled: B,
2113
- className: "rounded-xl p-2 hover:bg-slate-100 hover:cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed",
2114
- title: A.preview,
2115
- children: /* @__PURE__ */ r(lt, { size: 20, className: "text-slate-400" })
2116
- }
2117
- ),
2118
- /* @__PURE__ */ r(
2119
- "button",
2120
- {
2121
- type: "button",
2122
- onClick: (H) => {
2123
- H.stopPropagation(), te(D.id);
2124
- },
2125
- disabled: o || f,
2126
- className: "rounded-xl p-2 text-slate-base hover:bg-slate-100 disabled:opacity-50 hover:cursor-pointer",
2127
- title: A.remove,
2128
- children: /* @__PURE__ */ r(ge, { className: "h-6 w-6" })
2129
- }
2130
- )
2131
- ] })
2132
- ]
2133
- },
2134
- D.id
2135
- );
2136
- }) })
2137
- ] }),
2138
- c && /* @__PURE__ */ r("p", { className: "mt-2 text-sm font-normal text-red-600", children: c })
2139
- ] });
2140
- };
2141
- function vn({
2142
- show: e,
2143
- setShow: t,
2144
- title: n,
2145
- description: l,
2146
- Header: o,
2147
- Body: a,
2148
- footer: i,
2149
- handleClickOutside: c = !1,
2150
- showCloseIcon: p = !0,
2151
- showHeader: b = !0,
2152
- overlayClassName: y,
2153
- containerClassName: S,
2154
- bodyClassName: I,
2155
- footerClassName: T
2156
- }) {
2157
- const E = ae(null), { handleEscape: h } = _e(() => t(!1));
2158
- J(() => (e ? (document.addEventListener("keydown", h), document.body.style.overflow = "hidden") : document.body.style.overflow = "unset", () => document.removeEventListener("keydown", h)), [e, h]);
2159
- const { handleClick: w } = Le(E, () => {
2160
- c && t(!1);
2161
- });
2162
- J(() => (e && c && document.addEventListener("mousedown", w), () => document.removeEventListener("mousedown", w)), [e, w, c]);
2163
- const O = b && !!(o || n || l);
2164
- return /* @__PURE__ */ r(
2165
- "div",
2166
- {
2167
- className: s(
2168
- "bg-black/40 fixed inset-0 z-50 flex justify-center transition-all duration-500 ease-in-out",
2169
- "items-end sm:items-center",
2170
- e ? "opacity-100" : "pointer-events-none opacity-0",
2171
- y
2172
- ),
2173
- children: /* @__PURE__ */ d(
2174
- "div",
2175
- {
2176
- ref: E,
2177
- className: s(
2178
- "relative bg-white w-full",
2179
- "sm:max-w-[720px]",
2180
- "rounded-t-2xl sm:rounded-2xl",
2181
- "transition-all duration-500 ease-out",
2182
- e ? "scale-100 opacity-100" : "scale-95 opacity-0",
2183
- S
2184
- ),
2185
- children: [
2186
- O && /* @__PURE__ */ d("div", { className: "border-b border-slate-200 flex items-start justify-between p-4 sm:p-6 mb-4", children: [
2187
- o || /* @__PURE__ */ d("div", { className: "block", children: [
2188
- /* @__PURE__ */ r("h2", { className: "text-h3 font-semibold text-black", children: n }),
2189
- l && /* @__PURE__ */ r("p", { className: "text-base text-slate-base font-normal mt-2", children: l })
2190
- ] }),
2191
- p && /* @__PURE__ */ r(
2192
- "button",
2193
- {
2194
- onClick: () => t(!1),
2195
- className: "bg-slate-100 rounded-xl w-12 h-12 hover:cursor-pointer text-black transition flex items-center justify-center group",
2196
- "aria-label": "Close modal",
2197
- type: "button",
2198
- children: /* @__PURE__ */ r(ge, { className: "h-6 w-6 transition-transform duration-300 group-hover:rotate-180" })
2199
- }
2200
- )
2201
- ] }),
2202
- a && /* @__PURE__ */ r(
2203
- "div",
2204
- {
2205
- className: s(
2206
- "scrollbar-thin scrollbar-thumb-slate-200 overflow-y-auto",
2207
- "max-h-[70dvh] sm:max-h-96",
2208
- "px-4 sm:px-6 mb-2",
2209
- I
2210
- ),
2211
- children: a
2212
- }
2213
- ),
2214
- i && /* @__PURE__ */ r(
2215
- "div",
2216
- {
2217
- className: s(
2218
- "flex items-center justify-end gap-3 border-t border-slate-200",
2219
- "p-4 sm:p-6",
2220
- T
2221
- ),
2222
- children: i
2223
- }
2224
- )
2225
- ]
2226
- }
2227
- )
2228
- }
2229
- );
2230
- }
2231
- function Tr(e, t, n) {
2232
- const l = [], o = t * 2 + 5;
2233
- if (n <= o)
2234
- return Array.from({ length: n }, (c, p) => p + 1);
2235
- const a = Math.max(e - t, 2), i = Math.min(e + t, n - 1);
2236
- l.push(1), a > 2 && l.push("...");
2237
- for (let c = a; c <= i; c += 1) l.push(c);
2238
- return i < n - 1 && l.push("..."), n > 1 && l.push(n), l;
2239
- }
2240
- const Ir = {
2241
- medium: "h-9 text-sm",
2242
- large: "h-10 text-base"
2243
- }, Fr = {
2244
- yellow: {
2245
- active: "bg-yellow-500 text-white border-yellow-500",
2246
- inactive: "bg-slate-100 border-slate-200 text-black hover:bg-slate-200",
2247
- disabled: "text-slate-400 border-slate-200",
2248
- arrow: "text-black"
2249
- },
2250
- blue: {
2251
- active: "bg-blue-600 text-white border-blue-600",
2252
- inactive: "bg-slate-100 border-slate-200 text-black hover:bg-slate-200",
2253
- disabled: "text-slate-400 border-slate-300",
2254
- arrow: "text-black"
2255
- }
2256
- };
2257
- function Nn({
2258
- totalItems: e,
2259
- currentPage: t,
2260
- perPage: n,
2261
- onPageChange: l,
2262
- onPerPageChange: o,
2263
- siblingCount: a = 1,
2264
- perPageOptions: i = [10, 30, 50, 100],
2265
- showPerPage: c = !0,
2266
- variant: p = "yellow",
2267
- size: b = "large",
2268
- paginationClassName: y
2269
- }) {
2270
- const S = Number.isFinite(e) && e > 0 ? e : 0, I = Number.isFinite(n) && n > 0 ? n : 10, T = Math.max(1, Number.isFinite(t) ? t : 1), E = Math.ceil(S / I), h = z(() => Tr(T, a, E), [T, a, E]), w = Ir[b], M = Fr[p ?? "yellow"];
2271
- return E <= 1 || S === 0 ? null : /* @__PURE__ */ d("div", { className: s(
2272
- "flex items-center justify-between gap-4 w-full",
2273
- y
2274
- ), children: [
2275
- c && o && /* @__PURE__ */ d("div", { className: "flex items-center gap-2", children: [
2276
- /* @__PURE__ */ r(
2277
- "span",
2278
- {
2279
- className: "whitespace-nowrap text-extra-small text-slate-base font-normal",
2280
- children: "Строк на странице:"
2281
- }
2282
- ),
2283
- /* @__PURE__ */ d("div", { className: "relative", children: [
2284
- /* @__PURE__ */ r(
2285
- "select",
2286
- {
2287
- value: I,
2288
- onChange: (O) => o(Number(O.target.value)),
2289
- className: s(
2290
- "appearance-none bg-white border border-slate-200 rounded-lg pl-3 pr-8 text-base text-black font-medium focus:outline-none cursor-pointer",
2291
- b === "large" ? "h-10" : "h-9"
2292
- ),
2293
- "aria-label": "Количество строк на странице",
2294
- children: i.map((O) => /* @__PURE__ */ r("option", { value: O, children: O }, O))
2295
- }
2296
- ),
2297
- /* @__PURE__ */ r(
2298
- Fe,
2299
- {
2300
- className: "absolute right-3 top-1/2 -translate-y-1/2 pointer-events-none text-slate-400",
2301
- weight: "Linear",
2302
- size: 20
2303
- }
2304
- )
2305
- ] })
2306
- ] }),
2307
- /* @__PURE__ */ d("nav", { "aria-label": "Пагинация", className: "flex items-center gap-1 shrink-0 whitespace-nowrap", children: [
2308
- /* @__PURE__ */ r(
2309
- "button",
2310
- {
2311
- onClick: () => l(T - 1),
2312
- disabled: T === 1,
2313
- "aria-label": "Предыдущая страница",
2314
- className: s(
2315
- "flex items-center justify-center rounded-lg border transition-all bg-slate-100 min-w-10",
2316
- w,
2317
- T === 1 ? s("cursor-not-allowed opacity-50", M.disabled) : s("hover:cursor-pointer", M.arrow, "border-slate-200")
2318
- ),
2319
- children: /* @__PURE__ */ r(Me, { weight: "Linear", size: 20 })
2320
- }
2321
- ),
2322
- /* @__PURE__ */ r("div", { className: "flex items-center gap-1", children: h.map((O, k) => {
2323
- if (O === "...")
2324
- return /* @__PURE__ */ r(
2325
- "span",
2326
- {
2327
- className: s("flex items-center justify-center text-black font-medium min-w-10", w),
2328
- "aria-hidden": "true",
2329
- children: /* @__PURE__ */ r(Dt, { weight: "Bold", size: 20 })
2330
- },
2331
- k
2332
- );
2333
- const f = O === T;
2334
- return /* @__PURE__ */ r(
2335
- "button",
2336
- {
2337
- onClick: () => l(O),
2338
- "aria-label": `Страница ${O}${f ? ", текущая" : ""}`,
2339
- "aria-current": f ? "page" : void 0,
2340
- className: s(
2341
- "flex items-center justify-center rounded-lg border font-medium transition-all hover:cursor-pointer min-w-10 px-2",
2342
- w,
2343
- f ? M.active : M.inactive
2344
- ),
2345
- children: O
2346
- },
2347
- k
2348
- );
2349
- }) }),
2350
- /* @__PURE__ */ r(
2351
- "button",
2352
- {
2353
- onClick: () => l(T + 1),
2354
- disabled: T === E,
2355
- "aria-label": "Следующая страница",
2356
- className: s(
2357
- "flex items-center justify-center rounded-lg border transition-all bg-slate-100 min-w-10",
2358
- w,
2359
- T === E ? s("cursor-not-allowed opacity-50", M.disabled) : s("hover:cursor-pointer", M.arrow, "border-slate-200")
2360
- ),
2361
- children: /* @__PURE__ */ r(Ne, { size: 20, weight: "Linear" })
2362
- }
2363
- )
2364
- ] })
2365
- ] });
2366
- }
2367
- function Ge({
2368
- className: e,
2369
- variant: t = "default",
2370
- width: n = "100%",
2371
- height: l = "1rem"
2372
- }) {
2373
- return /* @__PURE__ */ r(
2374
- "div",
2375
- {
2376
- className: s(
2377
- "relative overflow-hidden bg-slate-200",
2378
- "rounded-lg",
2379
- t === "circle" && "rounded-full",
2380
- t === "rounded" && "rounded-md",
2381
- e
2382
- ),
2383
- style: {
2384
- width: typeof n == "number" ? `${n}px` : n,
2385
- height: typeof l == "number" ? `${l}px` : l
2386
- },
2387
- children: /* @__PURE__ */ r("div", { className: "shimmer-mask absolute inset-0" })
2388
- }
2389
- );
2390
- }
2391
- const Lr = {
2392
- top: "flex-col",
2393
- bottom: "flex-col-reverse",
2394
- left: "flex-row",
2395
- right: "flex-row-reverse"
2396
- }, jr = {
2397
- top: "flex-row",
2398
- bottom: "flex-row",
2399
- left: "flex-col",
2400
- right: "flex-col"
2401
- }, Or = {
2402
- top: "mt-4",
2403
- bottom: "mb-4",
2404
- left: "ml-4",
2405
- right: "mr-4"
2406
- };
2407
- function kn({
2408
- tabs: e,
2409
- defaultTab: t,
2410
- position: n = "top",
2411
- className: l,
2412
- tabListClassName: o,
2413
- contentClassName: a,
2414
- extra: i,
2415
- onChange: c
2416
- }) {
2417
- const [p, b] = P(t || e[0]?.id), [y, S] = P({}), I = ae([]), T = $(() => {
2418
- requestAnimationFrame(() => {
2419
- const h = e.findIndex((M) => M?.id === p), w = I.current[h];
2420
- if (w) {
2421
- const { offsetLeft: M, offsetTop: O, offsetWidth: k, offsetHeight: f } = w;
2422
- S({
2423
- left: `${M}px`,
2424
- top: `${O}px`,
2425
- width: `${k}px`,
2426
- height: `${f}px`,
2427
- transition: "all 0.35s cubic-bezier(0.25, 1, 0.5, 1)"
2428
- });
2429
- }
2430
- });
2431
- }, [p, e]);
2432
- J(() => (T(), window.addEventListener("resize", T), "fonts" in document && document.fonts.ready.then(T), () => window.removeEventListener("resize", T)), [n, T]), J(() => {
2433
- I.current = I.current.slice(0, e.length);
2434
- }, [e]);
2435
- const E = n === "left" || n === "right";
2436
- return /* @__PURE__ */ d("div", { className: s("flex w-full", Lr[n], l), children: [
2437
- /* @__PURE__ */ d(
2438
- "div",
2439
- {
2440
- className: s(
2441
- "flex w-full gap-4",
2442
- E ? "flex-col items-start" : "flex-row flex-wrap items-center"
2443
- ),
2444
- children: [
2445
- /* @__PURE__ */ r(
2446
- "div",
2447
- {
2448
- className: s(
2449
- "flex-1",
2450
- E ? "w-full" : "min-w-[520px]"
2451
- ),
2452
- children: /* @__PURE__ */ d(
2453
- "div",
2454
- {
2455
- className: s(
2456
- "relative flex rounded-xl bg-slate-100 p-1",
2457
- jr[n],
2458
- !E && "w-full overflow-hidden",
2459
- E ? "min-w-48" : "",
2460
- o
2461
- ),
2462
- children: [
2463
- /* @__PURE__ */ r(
2464
- "div",
2465
- {
2466
- className: s("absolute rounded-lg bg-white", E ? "w-full" : "h-full"),
2467
- style: y
2468
- }
2469
- ),
2470
- e?.map((h, w) => {
2471
- const M = p === h.id;
2472
- return /* @__PURE__ */ d(
2473
- "button",
2474
- {
2475
- ref: (O) => {
2476
- I.current[w] = O;
2477
- },
2478
- onClick: () => {
2479
- h?.disabled || (b(h?.id), c?.(h?.id));
2480
- },
2481
- disabled: h?.disabled,
2482
- className: s(
2483
- "relative z-10 flex items-center justify-center whitespace-nowrap px-3 py-2 text-base font-normal text-black transition-colors duration-300 hover:cursor-pointer",
2484
- h?.disabled && "cursor-not-allowed opacity-50",
2485
- E ? "w-full justify-start" : "flex-1 min-w-0"
2486
- ),
2487
- children: [
2488
- h?.icon && /* @__PURE__ */ r("span", { className: s("shrink-0 transition-transform duration-200", M && "scale-110"), children: h?.icon }),
2489
- /* @__PURE__ */ r("span", { className: "relative z-10 truncate", title: h?.label, children: h?.label })
2490
- ]
2491
- },
2492
- h?.id
2493
- );
2494
- })
2495
- ]
2496
- }
2497
- )
2498
- }
2499
- ),
2500
- i && /* @__PURE__ */ r(
2501
- "div",
2502
- {
2503
- className: s(
2504
- "shrink-0 ml-auto",
2505
- E ? "w-full" : "max-w-full"
2506
- ),
2507
- children: /* @__PURE__ */ r("div", { className: "flex flex-wrap items-center justify-end gap-2", children: i })
2508
- }
2509
- )
2510
- ]
2511
- }
2512
- ),
2513
- /* @__PURE__ */ r("div", { className: s("w-full flex-1 overflow-hidden", Or[n], a), children: /* @__PURE__ */ r("div", { className: "animate-fade-in w-full", style: { animationDuration: "0.35s" }, children: e?.find((h) => h.id === p)?.content }, p) })
2514
- ] });
2515
- }
2516
- const Rr = {
2517
- sm: "px-2 py-0.5",
2518
- md: "px-2 py-1",
2519
- lg: "px-3 py-2"
2520
- }, Je = {
2521
- sm: "w-3 h-3",
2522
- md: "w-3 h-3",
2523
- lg: "w-3 h-3"
2524
- }, $r = {
2525
- success: "bg-green-50 text-green-600",
2526
- warning: "bg-orange-50 text-orange-600",
2527
- error: "bg-red-50 text-red-600",
2528
- gray: "bg-slate-200 text-slate-700",
2529
- blue: "bg-blue-50 text-blue-600"
2530
- };
2531
- function Cn({
2532
- children: e,
2533
- variant: t = "success",
2534
- size: n = "lg",
2535
- icon: l,
2536
- iconPosition: o = "left",
2537
- className: a
2538
- }) {
2539
- return /* @__PURE__ */ d(
2540
- "span",
2541
- {
2542
- className: s(
2543
- "inline-flex animate-[fadeIn_0.3s_ease-out] items-center rounded-lg text-extra-small font-medium",
2544
- Rr[n],
2545
- $r[t],
2546
- l && "gap-[2px]",
2547
- a
2548
- ),
2549
- children: [
2550
- l && o === "left" && /* @__PURE__ */ r("span", { className: `flex items-center ${s(Je[n])}`, children: l }),
2551
- /* @__PURE__ */ r("span", { children: e }),
2552
- l && o === "right" && /* @__PURE__ */ r("span", { className: `flex items-center ${s(Je[n])}`, children: l })
2553
- ]
2554
- }
2555
- );
2556
- }
2557
- const _r = be(
2558
- ({
2559
- label: e,
2560
- placeholder: t,
2561
- value: n = "",
2562
- onChange: l,
2563
- required: o = !1,
2564
- disabled: a = !1,
2565
- error: i,
2566
- className: c,
2567
- rows: p = 4,
2568
- name: b
2569
- }, y) => {
2570
- const S = z(() => i ? "border-red-600 focus:border-red-600 shadow-red" : "border-slate-200 hover:border-slate-400 focus:shadow-blue focus:border-blue-600", [i]);
2571
- return /* @__PURE__ */ d("div", { className: s("relative w-full", c), children: [
2572
- e && /* @__PURE__ */ d(
2573
- "label",
2574
- {
2575
- className: s(
2576
- "mb-2 block text-base font-medium",
2577
- i ? "text-red-600" : "text-slate-700"
2578
- ),
2579
- children: [
2580
- e,
2581
- o && /* @__PURE__ */ r("span", { className: "ml-1 text-red-600", children: "*" })
2582
- ]
2583
- }
2584
- ),
2585
- /* @__PURE__ */ r(
2586
- "textarea",
2587
- {
2588
- ref: y,
2589
- name: b,
2590
- rows: p,
2591
- value: n,
2592
- onChange: (I) => l?.(I.target.value),
2593
- disabled: a,
2594
- placeholder: t,
2595
- className: s(
2596
- "w-full resize-none rounded-xl border bg-white text-base font-normal transition-all duration-300 ease-in-out outline-none",
2597
- "p-3 disabled:cursor-not-allowed disabled:border-slate-200 disabled:bg-slate-100 disabled:text-slate-400",
2598
- S
2599
- )
2600
- }
2601
- ),
2602
- i && /* @__PURE__ */ r("p", { className: "mt-2 animate-[slideDown_0.3s_ease-out] text-sm font-normal text-red-600", children: i })
2603
- ] });
2604
- }
2605
- );
2606
- _r.displayName = "MciTextarea";
2607
- const Br = {
2608
- success: /* @__PURE__ */ r(Lt, { weight: "Bold", className: "w-5 h-5" }),
2609
- error: /* @__PURE__ */ r(Ft, { weight: "Bold", className: "w-5 h-5" }),
2610
- warning: /* @__PURE__ */ r(It, { weight: "Bold", className: "w-5 h-5" }),
2611
- info: /* @__PURE__ */ r(Tt, { weight: "Bold", className: "w-5 h-5" }),
2612
- loading: /* @__PURE__ */ r(Mt, { weight: "Bold", className: "w-5 h-5 animate-spin" })
2613
- }, De = {
2614
- bg: {
2615
- success: "bg-green-50",
2616
- error: "bg-red-50",
2617
- warning: "bg-orange-50",
2618
- info: "bg-blue-50",
2619
- loading: "bg-slate-50"
2620
- },
2621
- line: {
2622
- success: "bg-green-600",
2623
- error: "bg-red-600",
2624
- warning: "bg-orange-600",
2625
- info: "bg-blue-600",
2626
- loading: "bg-slate-600"
2627
- },
2628
- text: {
2629
- success: "text-green-600",
2630
- error: "text-red-600",
2631
- warning: "text-orange-600",
2632
- info: "text-blue-600",
2633
- loading: "text-slate-600"
2634
- },
2635
- action: {
2636
- success: "text-green-600",
2637
- error: "text-red-600",
2638
- warning: "text-orange-600",
2639
- info: "text-blue-600",
2640
- loading: "text-slate-600"
2641
- }
2642
- };
2643
- function Pr() {
2644
- let e = document.getElementById("mci-toast-container");
2645
- return e || (e = document.createElement("div"), e.id = "mci-toast-container", e.className = "fixed top-4 right-4 z-[9999] flex flex-col gap-3 pointer-events-none", document.body.appendChild(e)), e;
2646
- }
2647
- const zr = Pr();
2648
- let Re = null, Wr = 0;
2649
- const Te = [], Qe = () => {
2650
- Re || (Re = Pt(zr)), Re.render(
2651
- /* @__PURE__ */ r("div", { className: "flex flex-col gap-3", children: Te.map(({ id: e, element: t }) => /* @__PURE__ */ r("div", { className: "pointer-events-auto", children: t }, e)) })
2652
- );
2653
- };
2654
- function Yr({
2655
- title: e,
2656
- description: t,
2657
- type: n = "info",
2658
- duration: l = 3e3,
2659
- action: o,
2660
- onClose: a
2661
- }) {
2662
- const [i, c] = P(100);
2663
- return J(() => {
2664
- if (l === 1 / 0) {
2665
- c(100);
2666
- return;
2667
- }
2668
- let p = null;
2669
- const b = (S) => {
2670
- p || (p = S);
2671
- const I = S - p, T = Math.max(0, (l - I) / l * 100);
2672
- c(T), T > 0 ? requestAnimationFrame(b) : a?.();
2673
- }, y = requestAnimationFrame(b);
2674
- return () => cancelAnimationFrame(y);
2675
- }, [l, a]), /* @__PURE__ */ d(
2676
- "div",
2677
- {
2678
- className: s(
2679
- "relative w-[300px] max-w-full overflow-hidden shadow-md rounded-lg",
2680
- "animate-in fade-in slide-in-from-top-2 duration-300",
2681
- De.bg[n]
2682
- ),
2683
- children: [
2684
- /* @__PURE__ */ r(
2685
- "div",
2686
- {
2687
- className: s("absolute bottom-0 left-0 h-1", De.line[n]),
2688
- style: {
2689
- width: `${i}%`,
2690
- transition: "none"
2691
- }
2692
- }
2693
- ),
2694
- /* @__PURE__ */ r("div", { className: "p-4", children: /* @__PURE__ */ d("div", { className: "flex items-start gap-2", children: [
2695
- /* @__PURE__ */ r("div", { className: s("flex-shrink-0", De.text[n]), children: Br[n] }),
2696
- /* @__PURE__ */ d("div", { className: "flex-1 min-w-0", children: [
2697
- /* @__PURE__ */ r("h4", { className: "text-base font-medium mb-1", children: e }),
2698
- t && /* @__PURE__ */ r("p", { className: "text-sm text-[#82828C]", children: t }),
2699
- o && /* @__PURE__ */ r("div", { className: "mt-3", children: /* @__PURE__ */ r("div", { className: s("underline font-medium text-sm", De.action[n]), children: o }) })
2700
- ] }),
2701
- /* @__PURE__ */ r(
2702
- "button",
2703
- {
2704
- onClick: a,
2705
- className: "flex-shrink-0 rounded-full transition cursor-pointer active:animate-spin",
2706
- children: /* @__PURE__ */ r(ge, { className: "w-6 h-6 text-slate-base" })
2707
- }
2708
- )
2709
- ] }) })
2710
- ]
2711
- }
2712
- );
2713
- }
2714
- const xe = (e) => {
2715
- const t = Wr++, n = () => {
2716
- const o = Te.findIndex((a) => a?.id === t);
2717
- o !== -1 && (Te.splice(o, 1), Qe());
2718
- }, l = /* @__PURE__ */ r(Yr, { ...e, onClose: n });
2719
- return Te.push({ id: t, element: l }), Qe(), e.duration !== 1 / 0 && setTimeout(n, (e.duration || 3e3) + 300), { close: n };
2720
- }, Sn = {
2721
- success: (e, t, n) => xe(typeof e == "string" ? { title: e, description: t, type: "success", action: n } : {
2722
- ...e,
2723
- type: "success"
2724
- }),
2725
- error: (e, t, n) => xe(typeof e == "string" ? { title: e, description: t, type: "error", action: n } : {
2726
- ...e,
2727
- type: "error"
2728
- }),
2729
- warning: (e, t, n) => xe(typeof e == "string" ? { title: e, description: t, type: "warning", action: n } : {
2730
- ...e,
2731
- type: "warning"
2732
- }),
2733
- info: (e, t, n) => xe(typeof e == "string" ? { title: e, description: t, type: "info", action: n } : {
2734
- ...e,
2735
- type: "info"
2736
- }),
2737
- loading: (e, t) => xe(typeof e == "string" ? {
2738
- title: e,
2739
- description: t,
2740
- type: "loading",
2741
- duration: 1 / 0
2742
- } : { ...e, type: "loading", duration: 1 / 0 })
2743
- }, Vr = {
2744
- top: "bottom-full left-1/2 -translate-x-1/2 mb-2",
2745
- bottom: "top-full left-1/2 -translate-x-1/2 mt-2",
2746
- left: "right-full top-1/2 -translate-y-1/2 mr-2",
2747
- right: "left-full top-1/2 -translate-y-1/2 ml-2"
2748
- }, Hr = {
2749
- top: "left-1/2 -translate-x-1/2 top-full",
2750
- bottom: "left-1/2 -translate-x-1/2 bottom-full",
2751
- left: "top-1/2 -translate-y-1/2 left-full",
2752
- right: "top-1/2 -translate-y-1/2 right-full"
2753
- };
2754
- function En({
2755
- content: e,
2756
- children: t,
2757
- position: n = "top",
2758
- delay: l = 200,
2759
- className: o
2760
- }) {
2761
- return /* @__PURE__ */ d("div", { className: "group relative inline-block", children: [
2762
- t,
2763
- /* @__PURE__ */ d(
2764
- "div",
2765
- {
2766
- className: s(
2767
- "absolute z-50 rounded-md bg-slate-400 px-2 py-1 text-xs whitespace-nowrap text-white shadow-md",
2768
- "scale-95 opacity-0 transition-all group-hover:scale-100 group-hover:opacity-100",
2769
- "duration-200 ease-out group-hover:delay-200",
2770
- Vr[n],
2771
- o
2772
- ),
2773
- style: { transitionDelay: `${l}ms` },
2774
- children: [
2775
- e,
2776
- /* @__PURE__ */ r(
2777
- "span",
2778
- {
2779
- className: s(
2780
- "absolute h-2 w-2 rotate-45 bg-slate-400",
2781
- Hr[n]
2782
- )
2783
- }
2784
- )
2785
- ]
2786
- }
2787
- )
2788
- ] });
2789
- }
2790
- const $e = {
2791
- blue: {
2792
- active: "bg-blue-600",
2793
- hover: "hover:bg-blue-600",
2794
- focus: "focus:shadow-blue"
2795
- },
2796
- yellow: {
2797
- active: "bg-yellow-500",
2798
- hover: "hover:bg-yellow-500",
2799
- focus: "focus:ring-2 focus:ring-yellow-200"
2800
- }
2801
- };
2802
- function An({
2803
- checked: e = !1,
2804
- onChange: t,
2805
- disabled: n = !1,
2806
- variant: l = "yellow",
2807
- label: o,
2808
- supportText: a,
2809
- className: i
2810
- }) {
2811
- const c = () => {
2812
- n || t?.(!e);
2813
- };
2814
- return /* @__PURE__ */ d(
2815
- "div",
2816
- {
2817
- className: s(
2818
- "flex items-start gap-3 select-none",
2819
- i
2820
- ),
2821
- children: [
2822
- /* @__PURE__ */ r(
2823
- "button",
2824
- {
2825
- type: "button",
2826
- disabled: n,
2827
- className: s(
2828
- "relative h-6 w-11 rounded-xl transition-all duration-300 outline-none cursor-pointer",
2829
- e ? $e[l].active : "bg-slate-200",
2830
- !n && $e[l].hover,
2831
- !n && $e[l].focus,
2832
- n && "bg-slate-100 cursor-not-allowed"
2833
- ),
2834
- onClick: c,
2835
- children: /* @__PURE__ */ r(
2836
- "span",
2837
- {
2838
- className: s(
2839
- "absolute top-1/2 left-0.5 h-5 w-5 -translate-y-1/2 rounded-full transition-all duration-300 bg-white",
2840
- e && "translate-x-5"
2841
- )
2842
- }
2843
- )
2844
- }
2845
- ),
2846
- (o || a) && /* @__PURE__ */ d("div", { className: "flex flex-col leading-tight", children: [
2847
- o && /* @__PURE__ */ r(
2848
- "span",
2849
- {
2850
- className: s(
2851
- "text-base font-medium text-black"
2852
- ),
2853
- children: o
2854
- }
2855
- ),
2856
- a && /* @__PURE__ */ r("span", { className: "text-sm font-normal text-slate-500", children: a })
2857
- ] })
2858
- ]
2859
- }
2860
- );
2861
- }
2862
- const Ur = (e) => /* @__PURE__ */ ee.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 177 177", fill: "none", ...e }, /* @__PURE__ */ ee.createElement("path", { opacity: 0.083334, d: "M94.5 48.5C94.5 41.8726 91.8137 36.5 88.5 36.5C85.1863 36.5 82.5 41.8726 82.5 48.5C82.5 55.1274 85.1863 60.5 88.5 60.5C91.8137 60.5 94.5 55.1274 94.5 48.5Z", fill: "currentColor" }), /* @__PURE__ */ ee.createElement("path", { opacity: 0.166667, d: "M113.697 56.8591C117.011 51.1196 117.371 45.1237 114.501 43.4668C111.631 41.8099 106.618 45.1196 103.305 50.8591C99.991 56.5986 99.6311 62.5946 102.501 64.2514C105.371 65.9083 110.383 62.5986 113.697 56.8591Z", fill: "currentColor" }), /* @__PURE__ */ ee.createElement("path", { opacity: 0.25, d: "M126.141 73.696C131.88 70.3823 135.19 65.3696 133.533 62.4999C131.876 59.6301 125.88 59.99 120.141 63.3037C114.401 66.6174 111.092 71.6301 112.749 74.4999C114.405 77.3696 120.401 77.0097 126.141 73.696Z", fill: "currentColor" }), /* @__PURE__ */ ee.createElement("path", { opacity: 0.333334, d: "M128.5 94.5C135.127 94.5 140.5 91.8137 140.5 88.5C140.5 85.1863 135.127 82.5 128.5 82.5C121.873 82.5 116.5 85.1863 116.5 88.5C116.5 91.8137 121.873 94.5 128.5 94.5Z", fill: "currentColor" }), /* @__PURE__ */ ee.createElement("path", { opacity: 0.416667, d: "M120.141 113.696C125.88 117.01 131.876 117.37 133.533 114.5C135.19 111.63 131.88 106.617 126.141 103.304C120.401 99.99 114.405 99.6301 112.749 102.5C111.092 105.37 114.401 110.382 120.141 113.696Z", fill: "currentColor" }), /* @__PURE__ */ ee.createElement("path", { opacity: 0.5, d: "M103.303 126.141C106.617 131.88 111.629 135.19 114.499 133.533C117.369 131.876 117.009 125.88 113.695 120.141C110.382 114.401 105.369 111.092 102.499 112.749C99.6294 114.405 99.9893 120.401 103.303 126.141Z", fill: "currentColor" }), /* @__PURE__ */ ee.createElement("path", { opacity: 0.583334, d: "M82.5 128.5C82.5 135.127 85.1863 140.5 88.5 140.5C91.8137 140.5 94.5 135.127 94.5 128.5C94.5 121.873 91.8137 116.5 88.5 116.5C85.1863 116.5 82.5 121.873 82.5 128.5Z", fill: "currentColor" }), /* @__PURE__ */ ee.createElement("path", { opacity: 0.666667, d: "M63.303 120.141C59.9893 125.88 59.6294 131.876 62.4992 133.533C65.3689 135.19 70.3816 131.88 73.6953 126.141C77.009 120.401 77.3689 114.405 74.4992 112.749C71.6294 111.092 66.6167 114.401 63.303 120.141Z", fill: "currentColor" }), /* @__PURE__ */ ee.createElement("path", { opacity: 0.75, d: "M50.8591 103.304C45.1196 106.618 41.8099 111.63 43.4668 114.5C45.1237 117.37 51.1196 117.01 56.8591 113.696C62.5986 110.383 65.9083 105.37 64.2514 102.5C62.5946 99.6304 56.5986 99.9903 50.8591 103.304Z", fill: "currentColor" }), /* @__PURE__ */ ee.createElement("path", { opacity: 0.833334, d: "M48.5 82.5C41.8726 82.5 36.5 85.1863 36.5 88.5C36.5 91.8137 41.8726 94.5 48.5 94.5C55.1274 94.5 60.5 91.8137 60.5 88.5C60.5 85.1863 55.1274 82.5 48.5 82.5Z", fill: "currentColor" }), /* @__PURE__ */ ee.createElement("path", { opacity: 0.916667, d: "M56.8591 63.304C51.1196 59.9903 45.1237 59.6304 43.4668 62.5001C41.8099 65.3699 45.1196 70.3826 50.8591 73.6963C56.5986 77.01 62.5946 77.3699 64.2514 74.5001C65.9083 71.6304 62.5986 66.6177 56.8591 63.304Z", fill: "currentColor" }), /* @__PURE__ */ ee.createElement("path", { d: "M73.697 50.8591C70.3833 45.1196 65.3706 41.8099 62.5008 43.4668C59.6311 45.1237 59.991 51.1196 63.3047 56.8591C66.6184 62.5986 71.6311 65.9083 74.5008 64.2514C77.3706 62.5946 77.0107 56.5986 73.697 50.8591Z", fill: "currentColor" }));
2863
- function Dn({
2864
- className: e,
2865
- size: t = 150,
2866
- iconClassName: n,
2867
- isLoading: l = !1,
2868
- isFullPage: o = !0,
2869
- variant: a = "yellow"
2870
- }) {
2871
- return l ? /* @__PURE__ */ r(
2872
- "div",
2873
- {
2874
- className: s(
2875
- "z-[99px] flex flex-col items-center justify-center transition-all duration-300",
2876
- o ? "fixed inset-0 backdrop-blur-[2px]" : "absolute inset-0 w-full h-full rounded-[inherit]",
2877
- e
2878
- ),
2879
- children: /* @__PURE__ */ r(
2880
- Ur,
2881
- {
2882
- width: t,
2883
- height: t,
2884
- className: s(
2885
- "animate-spin",
2886
- !n && (a === "blue" ? "text-blue-600" : "text-yellow-500"),
2887
- n
2888
- ),
2889
- style: { fill: "currentColor", stroke: "currentColor" }
2890
- }
2891
- )
2892
- }
2893
- ) : null;
2894
- }
2895
- const Zr = {
2896
- sm: {
2897
- input: "h-9 text-sm",
2898
- iconPadding: "pl-8 pr-2",
2899
- defaultPadding: "px-2",
2900
- iconSize: "w-4 h-4",
2901
- iconLeft: "left-2",
2902
- labelFont: "text-sm",
2903
- iconWrapper: "h-4"
2904
- },
2905
- md: {
2906
- input: "h-10 text-sm",
2907
- iconPadding: "pl-10 pr-4",
2908
- defaultPadding: "px-4",
2909
- iconSize: "w-4 h-4",
2910
- iconLeft: "left-3",
2911
- labelFont: "text-base",
2912
- iconWrapper: "h-4"
2913
- },
2914
- base: {
2915
- input: "h-12 text-base",
2916
- iconPadding: "pl-11 pr-4",
2917
- defaultPadding: "px-4",
2918
- iconSize: "w-5 h-5",
2919
- iconLeft: "left-3",
2920
- labelFont: "text-base",
2921
- iconWrapper: "h-5"
2922
- }
2923
- };
2924
- function Xr(e) {
2925
- let t = e.replace(/\D/g, "");
2926
- t.startsWith("998") || (t = `998${t}`), t = t.substring(0, 12);
2927
- let n = "+998";
2928
- return t.length > 3 && (n += ` (${t.substring(3, 5)}`), t.length > 5 && (n += `) ${t.substring(5, 8)}`), t.length > 8 && (n += ` ${t.substring(8, 10)}`), t.length > 10 && (n += ` ${t.substring(10, 12)}`), n;
2929
- }
2930
- function Kr(e) {
2931
- return e ? "border-red-600 focus:border-red-600 shadow-red" : "border-slate-200 hover:border-slate-400 focus:shadow-blue focus:border-blue-600";
2932
- }
2933
- function qr(e, t, n) {
2934
- return e ? "text-slate-400" : t ? "text-red-600" : n ? "text-black" : "text-slate-400";
2935
- }
2936
- const Gr = be(
2937
- ({
2938
- label: e,
2939
- placeholder: t = "+998 (__) ___ __ __",
2940
- size: n = "base",
2941
- error: l,
2942
- disabled: o = !1,
2943
- required: a = !1,
2944
- value: i = "",
2945
- onChange: c,
2946
- onFocus: p,
2947
- onBlur: b,
2948
- className: y,
2949
- name: S,
2950
- showIcon: I = !1
2951
- }, T) => {
2952
- const [E, h] = P(!1), w = (A) => {
2953
- const m = A.target.value;
2954
- if (m.length < 5) {
2955
- c?.("+998");
2956
- return;
2957
- }
2958
- const u = Xr(m);
2959
- c?.(u);
2960
- }, M = () => {
2961
- h(!0), (!i || i === "") && c?.("+998"), p?.();
2962
- }, O = () => {
2963
- h(!1), b?.();
2964
- }, k = Zr[n], f = I ? k.iconPadding : k.defaultPadding, L = z(() => Kr(l), [l]), v = z(
2965
- () => qr(o, l, E),
2966
- [l, E, o]
2967
- );
2968
- return /* @__PURE__ */ d("div", { className: s("w-full", y), children: [
2969
- e && /* @__PURE__ */ d("label", { className: s(
2970
- "mb-2 block font-medium transition-colors duration-200",
2971
- l ? "text-red-600" : E ? "text-blue-600" : "text-slate-700",
2972
- k.labelFont
2973
- ), children: [
2974
- e,
2975
- a && /* @__PURE__ */ r("span", { className: "text-red-600 ml-1", children: "*" })
2976
- ] }),
2977
- /* @__PURE__ */ d("div", { className: "relative flex items-center", children: [
2978
- I && /* @__PURE__ */ r("div", { className: s(
2979
- "absolute top-1/2 flex -translate-y-1/2 items-center justify-center transition-all duration-300",
2980
- k.iconLeft,
2981
- v
2982
- ), children: /* @__PURE__ */ r("div", { className: s("flex items-center justify-center", k.iconWrapper), children: /* @__PURE__ */ r(jt, { className: s(k.iconSize), weight: "Linear" }) }) }),
2983
- /* @__PURE__ */ r(
2984
- "input",
2985
- {
2986
- ref: T,
2987
- name: S,
2988
- type: "tel",
2989
- value: i,
2990
- onChange: w,
2991
- onFocus: M,
2992
- onBlur: O,
2993
- disabled: o,
2994
- placeholder: t,
2995
- className: s(
2996
- "w-full border bg-white font-normal transition-all duration-300 outline-none",
2997
- n === "base" ? "rounded-xl" : "rounded-lg",
2998
- "disabled:bg-slate-100 disabled:text-slate-400 disabled:cursor-not-allowed",
2999
- k.input,
3000
- f,
3001
- L
3002
- )
3003
- }
3004
- )
3005
- ] }),
3006
- l && /* @__PURE__ */ r("p", { className: "mt-2 animate-slide-up text-sm font-normal text-red-600", children: l })
3007
- ] });
3008
- }
3009
- );
3010
- Gr.displayName = "MciPhone";
3011
- function Jr(e) {
3012
- const t = e.replace(/\s/g, "").toUpperCase();
3013
- let n = "";
3014
- for (let l = 0; l < t.length; l += 1) {
3015
- const o = t[l];
3016
- if (n.length < 2 ? /[A-Z]/.test(o) && (n += o) : /[0-9]/.test(o) && (n += o), n.length >= 9) break;
3017
- }
3018
- return n.length > 2 ? `${n.slice(0, 2)} ${n.slice(2)}` : n;
3019
- }
3020
- function Qr(e) {
3021
- return e.replace(/\D/g, "").slice(0, 14);
3022
- }
3023
- function en(e) {
3024
- return e.toUpperCase().replace(/[^A-Z0-9\-\s]/g, "").replace(/\s+/g, " ").slice(0, 15);
3025
- }
3026
- function tn(e, t) {
3027
- return e === "passport" ? Jr(t) : e === "pinfl" ? Qr(t) : en(t);
3028
- }
3029
- function rn(e, t) {
3030
- return t || (e === "passport" ? "AA 1234567" : e === "pinfl" ? "12345678901234" : e === "metirka" ? "I-TN 1234567" : "");
3031
- }
3032
- function nn(e, t) {
3033
- return t || (e === "passport" ? 10 : e === "pinfl" ? 14 : e === "metirka" ? 15 : 255);
3034
- }
3035
- const ln = be(
3036
- ({ mode: e, onChange: t, value: n, ...l }, o) => {
3037
- const [a, i] = P(""), c = n !== void 0 ? n : a, p = $(
3038
- (b) => {
3039
- const y = b.target.value, S = tn(e, y);
3040
- n === void 0 && i(S), b.target.value = S, t?.(S, b);
3041
- },
3042
- [e, t, n]
3043
- );
3044
- return /* @__PURE__ */ r(
3045
- ze,
3046
- {
3047
- ref: o,
3048
- ...l,
3049
- value: c,
3050
- onChange: p,
3051
- maxLength: nn(e, l.maxLength),
3052
- placeholder: rn(e, l.placeholder)
3053
- }
3054
- );
3055
- }
3056
- );
3057
- ln.displayName = "MciIdentityInput";
3058
- function Mn({
3059
- open: e,
3060
- onClose: t,
3061
- columns: n,
3062
- hidden: l,
3063
- onToggle: o,
3064
- onMove: a,
3065
- onMoveByKey: i,
3066
- minVisible: c = 5
3067
- }) {
3068
- const p = ae(null), { handleClick: b } = Le(p, t);
3069
- J(() => {
3070
- if (e)
3071
- return document.addEventListener("mousedown", b), () => document.removeEventListener("mousedown", b);
3072
- }, [e, b]);
3073
- const y = z(() => new Set(l), [l]), S = z(() => {
3074
- let u = 0;
3075
- for (const x of n) y.has(x.key) || u++;
3076
- return u;
3077
- }, [n, y]), [I, T] = P(null), [E, h] = P(null), [w, M] = P(null), [O, k] = P("before"), f = $(
3078
- (u, x, j) => {
3079
- let F = j === "after" ? x + 1 : x;
3080
- return u < F && (F -= 1), F;
3081
- },
3082
- []
3083
- ), L = $(() => {
3084
- T(null), M(null), h(null), k("before");
3085
- }, []), v = $(
3086
- (u, x, j) => {
3087
- T(x), M(String(j)), h(null), k("before"), u.dataTransfer.effectAllowed = "move", u.dataTransfer.setData("text/plain", String(x));
3088
- const F = new Image();
3089
- F.src = "data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=", u.dataTransfer.setDragImage(F, 0, 0);
3090
- },
3091
- []
3092
- ), A = $(
3093
- (u, x) => {
3094
- u.preventDefault();
3095
- const j = I ?? Number.parseInt(u.dataTransfer.getData("text/plain") || "-1", 10);
3096
- if (!Number.isFinite(j) || j < 0) {
3097
- L();
3098
- return;
3099
- }
3100
- const F = n[j], R = n[x];
3101
- if (!F || !R) {
3102
- L();
3103
- return;
3104
- }
3105
- const W = f(j, x, O);
3106
- W !== j && (i ? i(F.key, R.key, O) : a(j, W)), L();
3107
- },
3108
- [n, f, I, O, a, i, L]
3109
- ), m = $(
3110
- (u, x) => {
3111
- x || o(u);
3112
- },
3113
- [o]
3114
- );
3115
- return e ? /* @__PURE__ */ d(
3116
- "div",
3117
- {
3118
- ref: p,
3119
- className: s(
3120
- "absolute right-0 top-full z-50 mt-2 w-[320px]",
3121
- "rounded-2xl p-4 bg-white",
3122
- "border border-slate-200"
3123
- ),
3124
- children: [
3125
- /* @__PURE__ */ d("div", { className: "flex items-center justify-between gap-4", children: [
3126
- /* @__PURE__ */ r("h4", { className: "text-slate-600 text-large font-normal", children: "Settings" }),
3127
- /* @__PURE__ */ r(
3128
- "button",
3129
- {
3130
- type: "button",
3131
- onClick: t,
3132
- className: "rounded-lg px-2 py-1 text-slate-500 hover:bg-slate-100",
3133
- "aria-label": "Close",
3134
- children: "✕"
3135
- }
3136
- )
3137
- ] }),
3138
- /* @__PURE__ */ r("div", { className: "my-4 h-px bg-slate-100" }),
3139
- /* @__PURE__ */ d("p", { className: "mb-3 text-xs text-slate-500", children: [
3140
- "Active columns: ",
3141
- S,
3142
- "/",
3143
- n.length
3144
- ] }),
3145
- /* @__PURE__ */ r(
3146
- "div",
3147
- {
3148
- className: s(
3149
- "max-h-[275px] overflow-auto",
3150
- "[&::-webkit-scrollbar]:w-1.5",
3151
- "[&::-webkit-scrollbar-track]:bg-transparent",
3152
- "[&::-webkit-scrollbar-thumb]:bg-slate-200",
3153
- "[&::-webkit-scrollbar-thumb]:rounded-full",
3154
- "hover:[&::-webkit-scrollbar-thumb]:bg-slate-300"
3155
- ),
3156
- children: n.map((u, x) => {
3157
- const j = !y.has(u.key), F = j && S <= c, R = E === x, W = w === u.key;
3158
- return /* @__PURE__ */ d("div", { className: "relative", children: [
3159
- R && !W && /* @__PURE__ */ r(
3160
- "div",
3161
- {
3162
- className: s(
3163
- "pointer-events-none absolute left-2 right-2 z-10 h-0.5 rounded-full bg-blue-300",
3164
- O === "before" ? "top-0" : "bottom-0"
3165
- )
3166
- }
3167
- ),
3168
- /* @__PURE__ */ d(
3169
- "div",
3170
- {
3171
- draggable: !0,
3172
- onDragStart: (V) => v(V, x, u.key),
3173
- onDragOver: (V) => {
3174
- if (I == null) return;
3175
- V.preventDefault(), V.dataTransfer.dropEffect = "move";
3176
- const X = V.currentTarget.getBoundingClientRect(), re = V.clientY - X.top > X.height / 2 ? "after" : "before";
3177
- E !== x && h(x), O !== re && k(re);
3178
- },
3179
- onDrop: (V) => A(V, x),
3180
- onDragEnd: L,
3181
- className: s(
3182
- "group flex items-center py-2 px-1 gap-4",
3183
- "rounded-md box-border overflow-visible",
3184
- "transition-[background,transform] duration-150",
3185
- !W && !R && "hover:bg-slate-50",
3186
- R && !W && "bg-slate-50",
3187
- W && "bg-slate-50 opacity-100 scale-[0.99] cursor-grabbing"
3188
- ),
3189
- children: [
3190
- /* @__PURE__ */ r(
3191
- "button",
3192
- {
3193
- type: "button",
3194
- className: s(
3195
- "shrink-0 text-slate-400",
3196
- "cursor-grab active:cursor-grabbing",
3197
- "rounded-lg p-1 hover:bg-slate-100",
3198
- W && "cursor-grabbing"
3199
- ),
3200
- "aria-label": "Drag",
3201
- children: /* @__PURE__ */ r(Ot, { weight: "Linear", size: 20 })
3202
- }
3203
- ),
3204
- /* @__PURE__ */ r("div", { className: "shrink-0", children: /* @__PURE__ */ r(
3205
- Ie,
3206
- {
3207
- checked: j,
3208
- disabled: F,
3209
- onChange: () => m(u.key, F),
3210
- variant: "blue"
3211
- }
3212
- ) }),
3213
- /* @__PURE__ */ d("div", { className: "min-w-0 flex-1", children: [
3214
- /* @__PURE__ */ r("h4", { className: "truncate text-slate-700 text-base font-medium", title: u.title, children: u.title }),
3215
- F && /* @__PURE__ */ d("p", { className: "text-xs text-slate-400 mt-0.5", children: [
3216
- "Минимум ",
3217
- c,
3218
- " колонок"
3219
- ] })
3220
- ] })
3221
- ]
3222
- }
3223
- ),
3224
- x !== n.length - 1 && /* @__PURE__ */ r("div", { className: "mx-2 h-px bg-slate-100" })
3225
- ] }, u.key);
3226
- })
3227
- }
3228
- )
3229
- ]
3230
- }
3231
- ) : null;
3232
- }
3233
- const et = (e) => Array.isArray(e) && e.every((t) => typeof t == "string"), sn = (e) => {
3234
- if (!e) return null;
3235
- try {
3236
- const t = JSON.parse(e);
3237
- if (typeof t != "object" || t === null) return null;
3238
- const n = t;
3239
- return !et(n.order) || !et(n.hidden) ? null : { order: n.order, hidden: n.hidden };
3240
- } catch {
3241
- return null;
3242
- }
3243
- }, me = (e) => {
3244
- const t = /* @__PURE__ */ new Set(), n = [];
3245
- for (const l of e)
3246
- t.has(l) || (t.add(l), n.push(l));
3247
- return n;
3248
- }, an = (e) => new Set((e ?? []).map(String)), tt = (e, t) => {
3249
- const n = t ? me(t.filter((l) => e.includes(l))) : [];
3250
- return me([...n, ...e]);
3251
- }, rt = (e, t) => {
3252
- if (!t?.length) return [];
3253
- const n = an(t);
3254
- return e.filter((l) => !n.has(l));
3255
- }, on = (e, t) => Math.max(0, Math.min(e, t)), we = (e, t, n) => {
3256
- const l = new Set(t), o = me(e.filter((i) => l.has(i))), a = Math.max(0, t.length - n);
3257
- return o.slice(0, a);
3258
- };
3259
- function Tn(e) {
3260
- const { storageKey: t, columns: n, defaultVisibleKeys: l, defaultOrder: o, minVisible: a = 5 } = e, i = z(() => n.map((f) => String(f.key)), [n]), c = z(() => new Set(i), [i]), p = z(
3261
- () => on(a, i.length),
3262
- [i.length, a]
3263
- ), [b, y] = P(() => {
3264
- const f = tt(
3265
- i,
3266
- o?.map(String) ?? []
3267
- ), L = rt(
3268
- i,
3269
- l?.map(String) ?? []
3270
- );
3271
- if (typeof window > "u")
3272
- return {
3273
- order: f,
3274
- hidden: we(L, i, p)
3275
- };
3276
- const v = sn(window.localStorage.getItem(t)), A = me((v?.order ?? []).filter((j) => c.has(j))), m = me([...A, ...f, ...i]), u = me((v?.hidden ?? []).filter((j) => c.has(j)));
3277
- return {
3278
- order: m,
3279
- hidden: we(v ? u : L, i, p)
3280
- };
3281
- });
3282
- J(() => {
3283
- if (!(typeof window > "u"))
3284
- try {
3285
- window.localStorage.setItem(t, JSON.stringify(b));
3286
- } catch {
3287
- }
3288
- }, [b, t]), J(() => {
3289
- y((f) => {
3290
- const L = me([
3291
- ...f.order.filter((u) => c.has(u)),
3292
- ...i.filter((u) => !f.order.includes(u))
3293
- ]), v = we(f.hidden, i, p), A = L.length === f.order.length && L.every((u, x) => u === f.order[x]), m = v.length === f.hidden.length && v.every((u, x) => u === f.hidden[x]);
3294
- return A && m ? f : { order: L, hidden: v };
3295
- });
3296
- }, [i, c, p]);
3297
- const S = z(() => new Set(b.hidden), [b.hidden]), I = z(() => {
3298
- const f = /* @__PURE__ */ new Map();
3299
- return b.order.forEach((L, v) => f.set(L, v)), [...n].sort((L, v) => {
3300
- const A = f.get(String(L.key)) ?? Number.MAX_SAFE_INTEGER, m = f.get(String(v.key)) ?? Number.MAX_SAFE_INTEGER;
3301
- return A - m;
3302
- });
3303
- }, [n, b.order]), T = z(
3304
- () => I.filter((f) => !S.has(String(f.key))),
3305
- [I, S]
3306
- ), E = z(
3307
- () => b.hidden.filter((f) => c.has(f)),
3308
- [b.hidden, c]
3309
- ), h = i.length - E.length, w = $((f) => {
3310
- const L = String(f);
3311
- y((v) => {
3312
- if (v.hidden.includes(L))
3313
- return { ...v, hidden: v.hidden.filter((x) => x !== L) };
3314
- if (i.length - v.hidden.length <= p) return v;
3315
- const u = we([...v.hidden, L], i, p);
3316
- return { ...v, hidden: u };
3317
- });
3318
- }, [i, p]), M = $((f, L) => {
3319
- y((v) => {
3320
- const A = v.order.slice();
3321
- if (f < 0 || L < 0 || f >= A.length || L >= A.length) return v;
3322
- const [m] = A.splice(f, 1);
3323
- return A.splice(L, 0, m), { ...v, order: A };
3324
- });
3325
- }, []), O = $((f, L, v = "before") => {
3326
- const A = String(f), m = String(L);
3327
- A !== m && y((u) => {
3328
- const x = u.order.slice(), j = x.indexOf(A), F = x.indexOf(m);
3329
- if (j < 0 || F < 0 || j === F) return u;
3330
- let R = v === "after" ? F + 1 : F;
3331
- if (j < R && (R -= 1), R === j) return u;
3332
- const [W] = x.splice(j, 1);
3333
- return x.splice(R, 0, W), { ...u, order: x };
3334
- });
3335
- }, []), k = $(() => {
3336
- y(() => {
3337
- const f = tt(
3338
- i,
3339
- o?.map(String) ?? []
3340
- ), L = rt(
3341
- i,
3342
- l?.map(String) ?? []
3343
- );
3344
- return {
3345
- order: f,
3346
- hidden: we(L, i, p)
3347
- };
3348
- });
3349
- }, [i, o, l, p]);
3350
- return {
3351
- orderedAllColumns: I,
3352
- orderedColumns: T,
3353
- hiddenKeys: E,
3354
- visibleCount: h,
3355
- toggleColumn: w,
3356
- moveColumn: M,
3357
- moveColumnByKey: O,
3358
- reset: k
3359
- };
3360
- }
3361
- export {
3362
- at as MciAccordion,
3363
- pn as MciBreadcrumb,
3364
- bn as MciButton,
3365
- Ie as MciCheck,
3366
- gn as MciCollapse,
3367
- xn as MciDrawer,
3368
- ln as MciIdentityInput,
3369
- ze as MciInput,
3370
- Dn as MciLoader,
3371
- vn as MciModal,
3372
- Nn as MciPagination,
3373
- Gr as MciPhone,
3374
- sr as MciPicker,
3375
- dr as MciSelect,
3376
- Ge as MciSkeleton,
3377
- wn as MciTable,
3378
- Mn as MciTableColumnsPanel,
3379
- kn as MciTabs,
3380
- Cn as MciTag,
3381
- _r as MciTextarea,
3382
- Sn as MciToast,
3383
- An as MciToggle,
3384
- En as MciTooltip,
3385
- yn as MciUpload,
3386
- Tn as useTableColumnSettings
3387
- };