@krosoft/react 0.0.249 → 0.0.251

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.
@@ -18,7 +18,7 @@ import { t as W } from "../../AppTitle-BR4JFZfp.js";
18
18
  import { n as G, t as K } from "../../states-N8-LjFng.js";
19
19
  import { AppPageHeader as q, KpiCardsLayout as J } from "./layouts/index.js";
20
20
  import { a as Y, i as X, n as Z, o as Q, r as $, t as ee } from "../../navbar-G9FexEW-.js";
21
- import { a as te, c as ne, d as re, f as ie, i as ae, l as oe, n as se, o as ce, r as le, s as ue, t as de, u as fe } from "../../table-DdrfvDFF.js";
21
+ import { a as te, c as ne, d as re, f as ie, i as ae, l as oe, n as se, o as ce, r as le, s as ue, t as de, u as fe } from "../../table-DhdShTkb.js";
22
22
  import { AppTabContainer as pe, AppTabHeader as me, AppTabs as he, AppVerticalTabs as ge } from "./tabs/index.js";
23
23
  import { t as _e } from "../../theme-BGakUJ9c.js";
24
24
  export { ue as ACTIONS_COLUMN_KEY, R as ActiveFilters, z as AdvancedFilters, k as AppActions, E as AppDialog, q as AppPageHeader, A as AppSubTitle, pe as AppTabContainer, me as AppTabHeader, he as AppTabs, W as AppTitle, ge as AppVerticalTabs, v as BarChartHorizontal, C as BarChartVertical, _ as CHART_COLORS, y as ChartCard, S as CircularGauge, D as ConfirmationDialog, r as DashboardCard, de as DataTable, P as DatePicker, I as DateRangePicker, l as Dialog, c as DialogClose, p as DialogContent, g as DialogDescription, s as DialogFooter, h as DialogHeader, d as DialogOverlay, f as DialogPortal, m as DialogTitle, u as DialogTrigger, N as ErrorAlert, G as ErrorState, B as FilterField, T as FormDialog, M as GenericForm, Q as GlobalSearch, O as ImageInput, e as KpiCard, t as KpiCards, J as KpiCardsLayout, U as LanguageSelector, b as LineChart, K as LoadingState, i as MetricCard, j as MultiSelect, Y as NotificationsBell, w as PieChart, o as Progress, ne as SELECTION_COLUMN_KEY, L as SearchInput, V as SearchableFilterPill, F as SearchableSelect, $ as Sidebar, Z as SidebarHeader, X as SidebarNavItem, n as SkeletonCard, a as SkeletonCards, ie as TableActions, ce as TableBody, te as TableBulkActions, H as TableFilter, ae as TableHeader, le as TablePagination, se as TableSettings, _e as ThemeSelector, ee as Topbar, fe as getAlignmentClass, x as getChartColor, re as getColumnAlignment, oe as getFixedCellProps };
@@ -1,2 +1,2 @@
1
- import { a as e, c as t, d as n, f as r, i, l as a, n as o, o as s, r as c, s as l, t as u, u as d } from "../../../table-DdrfvDFF.js";
1
+ import { a as e, c as t, d as n, f as r, i, l as a, n as o, o as s, r as c, s as l, t as u, u as d } from "../../../table-DhdShTkb.js";
2
2
  export { l as ACTIONS_COLUMN_KEY, u as DataTable, t as SELECTION_COLUMN_KEY, r as TableActions, s as TableBody, e as TableBulkActions, i as TableHeader, c as TablePagination, o as TableSettings, d as getAlignmentClass, n as getColumnAlignment, a as getFixedCellProps };
@@ -21,7 +21,7 @@ import { t as qr } from "../AppTitle-BR4JFZfp.js";
21
21
  import { n as Jr, t as Yr } from "../states-N8-LjFng.js";
22
22
  import { AppPageHeader as Xr, KpiCardsLayout as Zr } from "./core/layouts/index.js";
23
23
  import { a as Qr, i as $r, n as ei, o as ti, r as ni, t as ri } from "../navbar-G9FexEW-.js";
24
- import { a as ii, c as ai, d as oi, f as si, i as ci, l as li, n as ui, o as di, r as fi, s as pi, t as mi, u as hi } from "../table-DdrfvDFF.js";
24
+ import { a as ii, c as ai, d as oi, f as si, i as ci, l as li, n as ui, o as di, r as fi, s as pi, t as mi, u as hi } from "../table-DhdShTkb.js";
25
25
  import { AppTabContainer as gi, AppTabHeader as _i, AppTabs as vi, AppVerticalTabs as yi } from "./core/tabs/index.js";
26
26
  import { t as bi } from "../theme-BGakUJ9c.js";
27
27
  import "./core/index.js";
@@ -5,7 +5,7 @@ import { t as i } from "../useNotifications-CyhTruIG.js";
5
5
  import { t as a } from "../useLanguage-DN3CuBv5.js";
6
6
  import { t as o } from "../useDocumentTitle-D7MywIeB.js";
7
7
  import { a as s, c, d as l, f as u, i as d, l as f, n as p, o as m, p as h, r as g, s as _, t as v, u as y } from "../behavior-D3JNfIVJ.js";
8
- import { n as b, t as x } from "../useFixedColumns-DfAX30tT.js";
9
- import { t as S } from "../ui-DSVBO3iM.js";
8
+ import { n as b, t as x } from "../useFixedColumns-DnzqhbfT.js";
9
+ import { t as S } from "../ui-CmUIUFnk.js";
10
10
  import { t as C } from "../useTheme-DVfcJ-Qd.js";
11
11
  export { v as URL_DATE_FORMAT, p as parseDateRange, g as serializeDateRange, n as toast, l as useConfirmDeleteDialog, u as useConfirmationDialog, b as useDataTable, y as useDebouncedValue, h as useDialog, o as useDocumentTitle, x as useFixedColumns, a as useLanguage, r as useMobile, i as useNotifications, f as usePage, e as useScrollFade, S as useServerTable, c as useSidebar, C as useTheme, t as useToast, d as useUrlArrayState, s as useUrlDateRangeState, m as useUrlNumberState, _ as useUrlState };
@@ -4,7 +4,7 @@ import { t as r } from "../../useMobile-pTQ8lWvt.js";
4
4
  import { t as i } from "../../useNotifications-CyhTruIG.js";
5
5
  import { t as a } from "../../useLanguage-DN3CuBv5.js";
6
6
  import { t as o } from "../../useDocumentTitle-D7MywIeB.js";
7
- import { n as s, t as c } from "../../useFixedColumns-DfAX30tT.js";
8
- import { t as l } from "../../ui-DSVBO3iM.js";
7
+ import { n as s, t as c } from "../../useFixedColumns-DnzqhbfT.js";
8
+ import { t as l } from "../../ui-CmUIUFnk.js";
9
9
  import { t as u } from "../../useTheme-DVfcJ-Qd.js";
10
10
  export { n as toast, s as useDataTable, o as useDocumentTitle, c as useFixedColumns, a as useLanguage, r as useMobile, i as useNotifications, e as useScrollFade, l as useServerTable, u as useTheme, t as useToast };
@@ -1 +1 @@
1
- {"version":3,"file":"useDataTable.d.ts","sourceRoot":"","sources":["../../../src/hooks/ui/useDataTable.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAGhE,wBAAgB,YAAY,CAAC,CAAC,EAAE,EAC9B,IAAI,EACJ,OAAO,EACP,QAAQ,EACR,eAAe,EACf,OAAO,EACP,WAAW,EACX,gBAAuB,EACvB,SAAS,EACT,WAAW,EAAE,qBAAqB,EAClC,QAAQ,EAAE,kBAAkB,EAC5B,YAAY,EACZ,gBAAgB,EAChB,UAAU,EAAE,oBAAoB,EAChC,aAAa,EAAE,uBAAuB,EACtC,YAAY,GACb,EAAE,iBAAiB,CAAC,CAAC,CAAC,GAAG,kBAAkB,CAAC,CAAC,CAAC,CAqQ9C"}
1
+ {"version":3,"file":"useDataTable.d.ts","sourceRoot":"","sources":["../../../src/hooks/ui/useDataTable.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AA6BhE,wBAAgB,YAAY,CAAC,CAAC,EAAE,EAC9B,IAAI,EACJ,OAAO,EACP,QAAQ,EACR,eAAe,EACf,OAAO,EACP,WAAW,EACX,gBAAuB,EACvB,SAAS,EACT,WAAW,EAAE,qBAAqB,EAClC,QAAQ,EAAE,kBAAkB,EAC5B,YAAY,EACZ,gBAAgB,EAChB,UAAU,EAAE,oBAAoB,EAChC,aAAa,EAAE,uBAAuB,EACtC,YAAY,GACb,EAAE,iBAAiB,CAAC,CAAC,CAAC,GAAG,kBAAkB,CAAC,CAAC,CAAC,CAiR9C"}
@@ -2,7 +2,7 @@ import { Ft as e, Gt as t, Mt as n, Nt as r, bn as i, jt as a } from "./ui-CiX0E
2
2
  import { s as o } from "./tooltip-B2dzyfs9.js";
3
3
  import { t as s } from "./i18n-Dw99bRmg.js";
4
4
  import { i as c, l, n as u, t as d, u as f } from "./select-ULiTPOr5.js";
5
- import { n as p, t as m } from "./useFixedColumns-DfAX30tT.js";
5
+ import { n as p, t as m } from "./useFixedColumns-DnzqhbfT.js";
6
6
  import "react";
7
7
  import { Fragment as h, jsx as g, jsxs as _ } from "react/jsx-runtime";
8
8
  import { AlertTriangleIcon as v, ArrowDownIcon as y, ArrowUpDownIcon as b, ArrowUpIcon as x, ChevronLeftIcon as S, ChevronRightIcon as C, GripVerticalIcon as w, Loader2Icon as T, MoreVerticalIcon as E, SettingsIcon as D } from "lucide-react";
@@ -162,9 +162,9 @@ function R({ isLoading: e, error: t, colSpanCount: n, noDataMessage: r, paginate
162
162
  l ? /* @__PURE__ */ g("td", {
163
163
  className: `p-1 text-center align-middle ${D.className}`,
164
164
  style: {
165
- width: "32px",
166
- minWidth: "32px",
167
- maxWidth: "32px",
165
+ width: "48px",
166
+ minWidth: "48px",
167
+ maxWidth: "48px",
168
168
  ...D.style
169
169
  },
170
170
  onClick: (e) => {
@@ -324,11 +324,11 @@ function V({ hasBulkActions: e, selectedRows: t, totalItems: n, toggleSelectAll:
324
324
  e ? /* @__PURE__ */ g("th", {
325
325
  "data-column-key": P,
326
326
  "data-fixed-side": D ? "left" : void 0,
327
- className: `p-1 flex-shrink-0 text-center align-middle ${I.className}`,
327
+ className: `p-1 text-center align-middle ${I.className}`,
328
328
  style: {
329
- width: "32px",
330
- minWidth: "32px",
331
- maxWidth: "32px",
329
+ width: "48px",
330
+ minWidth: "48px",
331
+ maxWidth: "48px",
332
332
  ...I.style
333
333
  },
334
334
  children: /* @__PURE__ */ g("div", {
@@ -4,7 +4,7 @@ import "./useMobile-pTQ8lWvt.js";
4
4
  import "./useNotifications-CyhTruIG.js";
5
5
  import "./useLanguage-DN3CuBv5.js";
6
6
  import "./useDocumentTitle-D7MywIeB.js";
7
- import "./useFixedColumns-DfAX30tT.js";
7
+ import "./useFixedColumns-DnzqhbfT.js";
8
8
  import "./useTheme-DVfcJ-Qd.js";
9
9
  import { useCallback as e, useEffect as t, useState as n } from "react";
10
10
  //#region src/hooks/ui/useServerTable.ts
@@ -0,0 +1,171 @@
1
+ import { useCallback as e, useLayoutEffect as t, useMemo as n, useRef as r, useState as i } from "react";
2
+ //#region src/hooks/ui/useDataTable.ts
3
+ var a = 100, o = (e) => e.defaultVisible !== !1, ee = (e, t) => {
4
+ let n = new Map(t.map((e) => [e.key, e])), r = e.filter((e) => n.has(e)), i = new Set(r);
5
+ return t.forEach((e, n) => {
6
+ if (i.has(e.key)) return;
7
+ let a = 0;
8
+ for (let e = n - 1; e >= 0; e--) {
9
+ let n = r.indexOf(t[e].key);
10
+ if (n !== -1) {
11
+ a = n + 1;
12
+ break;
13
+ }
14
+ }
15
+ r.splice(a, 0, e.key), i.add(e.key);
16
+ }), r.map((e) => n.get(e)).filter((e) => e !== void 0);
17
+ };
18
+ function s({ data: t, columns: s, getRowId: c, defaultPageSize: l, actions: u, bulkActions: d, columnVisibility: f = !0, totalRows: p, currentPage: te, pageSize: ne, onPageChange: m, onPageSizeChange: h, sortColumn: g, sortDirection: re, onSortChange: _ }) {
19
+ let [ie, v] = i(s.find((e) => e.sortable === !0)?.key ?? null), y = g === void 0 ? ie : g, [ae, oe] = i("asc"), b = re ?? ae, [x, S] = i([]), [C, se] = i({}), [w, T] = i({}), [E, D] = i(null), [O, k] = i(1), A = te ?? O, [ce, le] = i(l), j = ne ?? ce, ue = r(null), M = r(null), N = r(0), P = r(0), F = r(null), I = r(null), L = u !== void 0 && u.length > 0, R = d !== void 0 && d.length > 0, z = n(() => E === null ? s : ee(E, s), [E, s]), B = n(() => {
20
+ let e = /* @__PURE__ */ new Set();
21
+ for (let t of s) (C[t.key] ?? o(t)) && e.add(t.key);
22
+ return e;
23
+ }, [s, C]), V = n(() => z.filter((e) => B.has(e.key)), [z, B]), H = n(() => s.reduce((e, t) => ({
24
+ ...e,
25
+ [t.key]: w[t.key] ?? t.minWidth ?? a
26
+ }), {}), [s, w]), de = V.length + +!!R + (L || f ? 1 : 0), U = p ?? t.length, W = Math.max(1, Math.ceil(U / j)), G = A > W ? W : A, K = U === 0 ? 0 : (G - 1) * j, q = p === void 0 ? Math.min(K + j, t.length) : Math.min(K + t.length, p), J = e((e) => {
27
+ m ? m(e) : k(e);
28
+ }, [m]), Y = e((e) => {
29
+ h ? h(e) : (le(e), k(1));
30
+ }, [h]), fe = e((e) => {
31
+ let t = typeof e == "function" ? e(A) : e;
32
+ J(t);
33
+ }, [A, J]), pe = e((e) => {
34
+ let t = typeof e == "function" ? e(j) : e;
35
+ Y(t);
36
+ }, [j, Y]), me = e((e) => {
37
+ if (s.find((t) => t.key === e)?.sortable !== !0) return;
38
+ let t = "asc";
39
+ y === e && (t = b === "asc" ? "desc" : "asc"), _ ? _(e, t) : (v(e), oe(t), J(1));
40
+ }, [
41
+ s,
42
+ y,
43
+ b,
44
+ _,
45
+ J
46
+ ]), X = e((e) => {
47
+ let t = M.current;
48
+ if (t === null) return;
49
+ let n = e.clientX - N.current, r = Math.max(80, P.current + n);
50
+ T((e) => ({
51
+ ...e,
52
+ [t]: r
53
+ }));
54
+ }, []), Z = e(function e() {
55
+ M.current = null, document.removeEventListener("mousemove", X), document.removeEventListener("mouseup", e);
56
+ }, [X]), Q = e((e, t) => {
57
+ e.preventDefault(), e.stopPropagation(), M.current = t, N.current = e.clientX, P.current = H[t], document.addEventListener("mousemove", X), document.addEventListener("mouseup", Z);
58
+ }, [
59
+ H,
60
+ X,
61
+ Z
62
+ ]), he = (e, t) => {
63
+ F.current = t, e.dataTransfer.effectAllowed = "move", e.dataTransfer.setData("text/html", t);
64
+ }, ge = (e, t) => {
65
+ e.preventDefault(), e.dataTransfer.dropEffect = "move", I.current = t;
66
+ }, _e = (e, t) => {
67
+ if (e.preventDefault(), F.current === null || F.current === t) return;
68
+ let n = z.map((e) => e.key), r = n.indexOf(F.current), i = n.indexOf(t);
69
+ r !== -1 && i !== -1 && (n.splice(r, 1), n.splice(i, 0, F.current), D(n), F.current = null, I.current = null);
70
+ }, $ = n(() => _ === void 0 ? [...t].sort((e, t) => {
71
+ if (y === null) return 0;
72
+ let n = s.find((e) => e.key === y), r = n?.getSortValue === void 0 ? e[y] : n.getSortValue(e), i = n?.getSortValue === void 0 ? t[y] : n.getSortValue(t);
73
+ if (typeof r == "string" && typeof i == "string") {
74
+ let e = r.localeCompare(i);
75
+ return b === "asc" ? e : -e;
76
+ }
77
+ return r === i ? 0 : r == null ? 1 : i == null ? -1 : r < i ? b === "asc" ? -1 : 1 : r > i ? b === "asc" ? 1 : -1 : 0;
78
+ }) : t, [
79
+ t,
80
+ y,
81
+ b,
82
+ s,
83
+ _
84
+ ]);
85
+ return {
86
+ sortColumn: y,
87
+ sortDirection: b,
88
+ selectedRows: x,
89
+ setSelectedRows: S,
90
+ visibleColumns: B,
91
+ columnWidths: H,
92
+ currentPage: A,
93
+ setCurrentPage: fe,
94
+ pageSize: j,
95
+ setPageSize: pe,
96
+ totalPages: W,
97
+ safeCurrentPage: G,
98
+ startIndex: K,
99
+ endIndex: q,
100
+ tableRef: ue,
101
+ hasActions: L,
102
+ hasBulkActions: R,
103
+ orderedColumns: z,
104
+ visibleColumnsArray: V,
105
+ colSpanCount: de,
106
+ paginatedData: n(() => p === void 0 ? $.slice(K, q) : $, [
107
+ $,
108
+ K,
109
+ q,
110
+ p
111
+ ]),
112
+ handleSort: me,
113
+ handleMouseDown: Q,
114
+ handleDragStart: he,
115
+ handleDragOver: ge,
116
+ handleDrop: _e,
117
+ toggleColumnVisibility: (e) => {
118
+ let t = s.find((t) => t.key === e);
119
+ if (t === void 0) return;
120
+ let n = C[e] ?? o(t);
121
+ se((t) => ({
122
+ ...t,
123
+ [e]: !n
124
+ }));
125
+ },
126
+ toggleRowSelection: (e) => {
127
+ x.includes(e) ? S(x.filter((t) => t !== e)) : S([...x, e]);
128
+ },
129
+ toggleSelectAll: () => {
130
+ x.length === t.length ? S([]) : S(t.map((e) => c(e)));
131
+ }
132
+ };
133
+ }
134
+ //#endregion
135
+ //#region src/hooks/ui/useFixedColumns.ts
136
+ var c = (e, t) => {
137
+ let n = Object.keys(e);
138
+ return n.length === Object.keys(t).length && n.every((n) => {
139
+ let r = e[n], i = t[n];
140
+ return r.side === i?.side && r.offset === i.offset && r.isEdge === i.isEdge;
141
+ });
142
+ };
143
+ function l(e) {
144
+ let [n, r] = i({});
145
+ return t(() => {
146
+ let t = e.current;
147
+ if (!t) return;
148
+ let n = [], i = () => {
149
+ n = Array.from(t.querySelectorAll("thead th[data-fixed-side]"));
150
+ let e = {}, i = (t, n) => {
151
+ let r = 0;
152
+ t.forEach((i, a) => {
153
+ let o = i.dataset.columnKey;
154
+ o !== void 0 && (e[o] = {
155
+ side: n,
156
+ offset: r,
157
+ isEdge: a === t.length - 1
158
+ }, r += i.getBoundingClientRect().width);
159
+ });
160
+ };
161
+ i(n.filter((e) => e.dataset.fixedSide === "left"), "left"), i(n.filter((e) => e.dataset.fixedSide === "right").reverse(), "right"), r((t) => c(t, e) ? t : e);
162
+ };
163
+ i();
164
+ let a = typeof ResizeObserver > "u" ? null : new ResizeObserver(i);
165
+ return a?.observe(t), n.forEach((e) => a?.observe(e)), () => {
166
+ a?.disconnect();
167
+ };
168
+ }), n;
169
+ }
170
+ //#endregion
171
+ export { s as n, l as t };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@krosoft/react",
3
- "version": "0.0.249",
3
+ "version": "0.0.251",
4
4
  "description": "Krosoft shared React package",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -1,147 +0,0 @@
1
- import { useCallback as e, useLayoutEffect as t, useMemo as n, useRef as r, useState as i } from "react";
2
- //#region src/hooks/ui/useDataTable.ts
3
- function a({ data: t, columns: a, getRowId: o, defaultPageSize: s, actions: c, bulkActions: l, columnVisibility: ee = !0, totalRows: u, currentPage: d, pageSize: te, onPageChange: f, onPageSizeChange: p, sortColumn: m, sortDirection: h, onSortChange: g }) {
4
- let [_, v] = i(a.find((e) => e.sortable === !0)?.key ?? null), y = m === void 0 ? _ : m, [b, x] = i("asc"), S = h ?? b, [C, w] = i([]), [T, ne] = i(new Set(a.filter((e) => e.defaultVisible !== !1).map((e) => e.key))), [E, re] = i(a.map((e) => e.key)), [D, ie] = i(a.reduce((e, t) => ({
5
- ...e,
6
- [t.key]: t.minWidth ?? 100
7
- }), {})), [O, k] = i(1), A = d ?? O, [ae, oe] = i(s), j = te ?? ae, M = r(null), N = r(null), P = r(0), F = r(0), I = r(null), L = r(null), R = c !== void 0 && c.length > 0, z = l !== void 0 && l.length > 0, B = n(() => E.map((e) => a.find((t) => t.key === e)).filter((e) => e !== void 0), [E, a]), V = n(() => B.filter((e) => T.has(e.key)), [B, T]), H = V.length + +!!z + (R || ee ? 1 : 0), U = u ?? t.length, W = Math.max(1, Math.ceil(U / j)), G = A > W ? W : A, K = U === 0 ? 0 : (G - 1) * j, q = u === void 0 ? Math.min(K + j, t.length) : Math.min(K + t.length, u), J = e((e) => {
8
- f ? f(e) : k(e);
9
- }, [f]), Y = e((e) => {
10
- p ? p(e) : (oe(e), k(1));
11
- }, [p]), se = e((e) => {
12
- let t = typeof e == "function" ? e(A) : e;
13
- J(t);
14
- }, [A, J]), X = e((e) => {
15
- let t = typeof e == "function" ? e(j) : e;
16
- Y(t);
17
- }, [j, Y]), ce = e((e) => {
18
- if (a.find((t) => t.key === e)?.sortable !== !0) return;
19
- let t = "asc";
20
- y === e && (t = S === "asc" ? "desc" : "asc"), g ? g(e, t) : (v(e), x(t), J(1));
21
- }, [
22
- a,
23
- y,
24
- S,
25
- g,
26
- J
27
- ]), Z = e((e) => {
28
- let t = N.current;
29
- if (t === null) return;
30
- let n = e.clientX - P.current, r = Math.max(80, F.current + n);
31
- ie((e) => ({
32
- ...e,
33
- [t]: r
34
- }));
35
- }, []), Q = e(function e() {
36
- N.current = null, document.removeEventListener("mousemove", Z), document.removeEventListener("mouseup", e);
37
- }, [Z]), le = e((e, t) => {
38
- e.preventDefault(), e.stopPropagation(), N.current = t, P.current = e.clientX, F.current = D[t], document.addEventListener("mousemove", Z), document.addEventListener("mouseup", Q);
39
- }, [
40
- D,
41
- Z,
42
- Q
43
- ]), ue = (e, t) => {
44
- I.current = t, e.dataTransfer.effectAllowed = "move", e.dataTransfer.setData("text/html", t);
45
- }, de = (e, t) => {
46
- e.preventDefault(), e.dataTransfer.dropEffect = "move", L.current = t;
47
- }, fe = (e, t) => {
48
- if (e.preventDefault(), I.current === null || I.current === t) return;
49
- let n = [...E], r = n.indexOf(I.current), i = n.indexOf(t);
50
- n.splice(r, 1), n.splice(i, 0, I.current), re(n), I.current = null, L.current = null;
51
- }, $ = n(() => g === void 0 ? [...t].sort((e, t) => {
52
- if (y === null) return 0;
53
- let n = a.find((e) => e.key === y), r = n?.getSortValue === void 0 ? e[y] : n.getSortValue(e), i = n?.getSortValue === void 0 ? t[y] : n.getSortValue(t);
54
- if (typeof r == "string" && typeof i == "string") {
55
- let e = r.localeCompare(i);
56
- return S === "asc" ? e : -e;
57
- }
58
- return r === i ? 0 : r == null ? 1 : i == null ? -1 : r < i ? S === "asc" ? -1 : 1 : r > i ? S === "asc" ? 1 : -1 : 0;
59
- }) : t, [
60
- t,
61
- y,
62
- S,
63
- a,
64
- g
65
- ]);
66
- return {
67
- sortColumn: y,
68
- sortDirection: S,
69
- selectedRows: C,
70
- setSelectedRows: w,
71
- visibleColumns: T,
72
- columnWidths: D,
73
- currentPage: A,
74
- setCurrentPage: se,
75
- pageSize: j,
76
- setPageSize: X,
77
- totalPages: W,
78
- safeCurrentPage: G,
79
- startIndex: K,
80
- endIndex: q,
81
- tableRef: M,
82
- hasActions: R,
83
- hasBulkActions: z,
84
- orderedColumns: B,
85
- visibleColumnsArray: V,
86
- colSpanCount: H,
87
- paginatedData: n(() => u === void 0 ? $.slice(K, q) : $, [
88
- $,
89
- K,
90
- q,
91
- u
92
- ]),
93
- handleSort: ce,
94
- handleMouseDown: le,
95
- handleDragStart: ue,
96
- handleDragOver: de,
97
- handleDrop: fe,
98
- toggleColumnVisibility: (e) => {
99
- let t = new Set(T);
100
- t.has(e) ? t.delete(e) : t.add(e), ne(t);
101
- },
102
- toggleRowSelection: (e) => {
103
- C.includes(e) ? w(C.filter((t) => t !== e)) : w([...C, e]);
104
- },
105
- toggleSelectAll: () => {
106
- C.length === t.length ? w([]) : w(t.map((e) => o(e)));
107
- }
108
- };
109
- }
110
- //#endregion
111
- //#region src/hooks/ui/useFixedColumns.ts
112
- var o = (e, t) => {
113
- let n = Object.keys(e);
114
- return n.length === Object.keys(t).length && n.every((n) => {
115
- let r = e[n], i = t[n];
116
- return r.side === i?.side && r.offset === i.offset && r.isEdge === i.isEdge;
117
- });
118
- };
119
- function s(e) {
120
- let [n, r] = i({});
121
- return t(() => {
122
- let t = e.current;
123
- if (!t) return;
124
- let n = [], i = () => {
125
- n = Array.from(t.querySelectorAll("thead th[data-fixed-side]"));
126
- let e = {}, i = (t, n) => {
127
- let r = 0;
128
- t.forEach((i, a) => {
129
- let o = i.dataset.columnKey;
130
- o !== void 0 && (e[o] = {
131
- side: n,
132
- offset: r,
133
- isEdge: a === t.length - 1
134
- }, r += i.getBoundingClientRect().width);
135
- });
136
- };
137
- i(n.filter((e) => e.dataset.fixedSide === "left"), "left"), i(n.filter((e) => e.dataset.fixedSide === "right").reverse(), "right"), r((t) => o(t, e) ? t : e);
138
- };
139
- i();
140
- let a = typeof ResizeObserver > "u" ? null : new ResizeObserver(i);
141
- return a?.observe(t), n.forEach((e) => a?.observe(e)), () => {
142
- a?.disconnect();
143
- };
144
- }), n;
145
- }
146
- //#endregion
147
- export { a as n, s as t };