flexi-datagrid 1.2.8 → 1.2.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -3
- package/dist/DataTable/DataTable.d.ts +2 -0
- package/dist/DataTable/components/FilterDropdown.d.ts +4 -0
- package/dist/DataTable/components/GroupZone.d.ts +1 -0
- package/dist/DataTable/components/HeaderCell.d.ts +8 -0
- package/dist/DataTable/components/Pagination.d.ts +1 -0
- package/dist/DataTable/components/PinnedBottomBody.d.ts +1 -0
- package/dist/DataTable/components/SettingsMenu.d.ts +4 -0
- package/dist/DataTable/components/TableBody.d.ts +1 -0
- package/dist/DataTable/components/TableColGroup.d.ts +1 -0
- package/dist/DataTable/components/TableHeader.d.ts +1 -0
- package/dist/DataTable/components/rows.d.ts +18 -0
- package/dist/DataTable/constants.d.ts +11 -0
- package/dist/DataTable/context/DataTableContext.d.ts +8 -0
- package/dist/DataTable/hooks/index.d.ts +12 -0
- package/dist/DataTable/hooks/useAnchoredPosition.d.ts +13 -0
- package/dist/DataTable/hooks/useClickOutside.d.ts +5 -0
- package/dist/DataTable/hooks/useColumnFilters.d.ts +25 -0
- package/dist/DataTable/hooks/useColumnReorder.d.ts +15 -0
- package/dist/DataTable/hooks/useColumnResize.d.ts +7 -0
- package/dist/DataTable/hooks/useColumnVisibility.d.ts +13 -0
- package/dist/DataTable/hooks/useDataTableState.d.ts +89 -0
- package/dist/DataTable/hooks/usePagination.d.ts +18 -0
- package/dist/DataTable/hooks/usePinnedColumns.d.ts +5 -0
- package/dist/DataTable/hooks/useRowGrouping.d.ts +7 -0
- package/dist/DataTable/hooks/useSettingsMenu.d.ts +11 -0
- package/dist/DataTable/hooks/useSorting.d.ts +6 -0
- package/dist/DataTable/hooks/useVirtualRows.d.ts +15 -0
- package/dist/DataTable/index.d.ts +2 -0
- package/dist/{Datatable.d.ts → DataTable/types.d.ts} +36 -7
- package/dist/DataTable/utils/classNames.d.ts +1 -0
- package/dist/DataTable/utils/columns.d.ts +12 -0
- package/dist/DataTable/utils/grouping.d.ts +5 -0
- package/dist/DataTable/utils/pinning.d.ts +12 -0
- package/dist/DataTable/utils/records.d.ts +10 -0
- package/dist/DataTable/utils/rowSpan.d.ts +7 -0
- package/dist/flexi-datagrid.css +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.es.js +1194 -881
- package/dist/index.umd.js +1 -1
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -1,17 +1,152 @@
|
|
|
1
|
-
import { ArrowDown as e, ArrowUp as t, ArrowUpDown as n, ChevronDown as r, ChevronLeft as i, ChevronRight as a, ChevronsLeft as o, ChevronsRight as s, Filter as
|
|
2
|
-
import { useEffect as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
//#region src/
|
|
6
|
-
var
|
|
1
|
+
import { ArrowDown as e, ArrowUp as t, ArrowUpDown as n, ChevronDown as r, ChevronLeft as i, ChevronRight as a, ChevronsLeft as o, ChevronsRight as s, Filter as c, Pin as l, PinOff as u, RotateCcw as d, Settings as f, X as p } from "lucide-react";
|
|
2
|
+
import { createContext as m, useCallback as h, useContext as g, useEffect as _, useMemo as v, useRef as y, useState as b } from "react";
|
|
3
|
+
import { jsx as x, jsxs as S } from "react/jsx-runtime";
|
|
4
|
+
import { createPortal as C } from "react-dom";
|
|
5
|
+
//#region src/DataTable/context/DataTableContext.tsx
|
|
6
|
+
var w = m(null);
|
|
7
|
+
function ee({ value: e, children: t }) {
|
|
8
|
+
return /* @__PURE__ */ x(w.Provider, {
|
|
9
|
+
value: e,
|
|
10
|
+
children: t
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
function T() {
|
|
14
|
+
let e = g(w);
|
|
15
|
+
if (!e) throw Error("DataTable components must be rendered inside <DataTable>.");
|
|
16
|
+
return e;
|
|
17
|
+
}
|
|
18
|
+
//#endregion
|
|
19
|
+
//#region src/DataTable/utils/classNames.ts
|
|
20
|
+
var E = (...e) => e.filter(Boolean).join(" ");
|
|
21
|
+
//#endregion
|
|
22
|
+
//#region src/DataTable/components/GroupZone.tsx
|
|
23
|
+
function D() {
|
|
24
|
+
let { groupedColumns: e, columnsByKey: t, addGroup: n, removeGroup: r } = T(), [i, a] = b(!1);
|
|
25
|
+
return /* @__PURE__ */ x("div", {
|
|
26
|
+
onDragOver: (e) => {
|
|
27
|
+
e.preventDefault(), a(!0);
|
|
28
|
+
},
|
|
29
|
+
onDragLeave: () => a(!1),
|
|
30
|
+
onDrop: (e) => {
|
|
31
|
+
e.preventDefault(), a(!1);
|
|
32
|
+
let r = e.dataTransfer.getData("text/plain");
|
|
33
|
+
r && t.has(r) && n(r);
|
|
34
|
+
},
|
|
35
|
+
className: E("flexi-groupzone", i && "flexi-groupzone--dragover"),
|
|
36
|
+
children: e.length === 0 ? /* @__PURE__ */ x("span", {
|
|
37
|
+
className: "flexi-groupzone-hint",
|
|
38
|
+
children: "Drag a column header here to group your records by that field"
|
|
39
|
+
}) : /* @__PURE__ */ S("div", {
|
|
40
|
+
className: "flexi-groupzone-chips",
|
|
41
|
+
children: [/* @__PURE__ */ x("span", {
|
|
42
|
+
className: "flexi-groupzone-label",
|
|
43
|
+
children: "Grouped By:"
|
|
44
|
+
}), e.map((e) => /* @__PURE__ */ S("div", {
|
|
45
|
+
className: "flexi-chip",
|
|
46
|
+
children: [/* @__PURE__ */ x("span", { children: t.get(e)?.header || e }), /* @__PURE__ */ x("button", {
|
|
47
|
+
type: "button",
|
|
48
|
+
onClick: () => r(e),
|
|
49
|
+
className: "flexi-icon-btn flexi-chip-remove",
|
|
50
|
+
children: /* @__PURE__ */ x(p, { className: "flexi-icon-xs" })
|
|
51
|
+
})]
|
|
52
|
+
}, e))]
|
|
53
|
+
})
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
//#endregion
|
|
57
|
+
//#region src/DataTable/components/Pagination.tsx
|
|
58
|
+
function O() {
|
|
59
|
+
let { currentPage: e, pageSize: t, totalPages: n, totalCount: r, pageSizeOptions: c, goToPage: l, changePageSize: u } = T();
|
|
60
|
+
return /* @__PURE__ */ S("div", {
|
|
61
|
+
className: "flexi-pagination",
|
|
62
|
+
children: [
|
|
63
|
+
/* @__PURE__ */ S("div", {
|
|
64
|
+
className: "flexi-pagination-size",
|
|
65
|
+
children: [/* @__PURE__ */ x("span", { children: "Rows per page" }), /* @__PURE__ */ x("select", {
|
|
66
|
+
value: t,
|
|
67
|
+
onChange: (e) => u(Number(e.target.value)),
|
|
68
|
+
className: "flexi-pagination-select",
|
|
69
|
+
children: c.map((e) => /* @__PURE__ */ x("option", {
|
|
70
|
+
value: e,
|
|
71
|
+
children: e
|
|
72
|
+
}, e))
|
|
73
|
+
})]
|
|
74
|
+
}),
|
|
75
|
+
/* @__PURE__ */ x("div", {
|
|
76
|
+
className: "flexi-pagination-info",
|
|
77
|
+
children: r === 0 ? "0 of 0" : `${(e - 1) * t + 1}–${Math.min(e * t, r)} of ${r}`
|
|
78
|
+
}),
|
|
79
|
+
/* @__PURE__ */ S("div", {
|
|
80
|
+
className: "flexi-pagination-controls",
|
|
81
|
+
children: [
|
|
82
|
+
/* @__PURE__ */ x("button", {
|
|
83
|
+
type: "button",
|
|
84
|
+
onClick: () => l(1),
|
|
85
|
+
disabled: e === 1,
|
|
86
|
+
className: "flexi-icon-btn",
|
|
87
|
+
title: "First page",
|
|
88
|
+
children: /* @__PURE__ */ x(o, { className: "flexi-icon-sm" })
|
|
89
|
+
}),
|
|
90
|
+
/* @__PURE__ */ x("button", {
|
|
91
|
+
type: "button",
|
|
92
|
+
onClick: () => l(e - 1),
|
|
93
|
+
disabled: e === 1,
|
|
94
|
+
className: "flexi-icon-btn",
|
|
95
|
+
title: "Previous page",
|
|
96
|
+
children: /* @__PURE__ */ x(i, { className: "flexi-icon-sm" })
|
|
97
|
+
}),
|
|
98
|
+
/* @__PURE__ */ S("span", {
|
|
99
|
+
className: "flexi-pagination-page",
|
|
100
|
+
children: [
|
|
101
|
+
"Page ",
|
|
102
|
+
e,
|
|
103
|
+
" of ",
|
|
104
|
+
n
|
|
105
|
+
]
|
|
106
|
+
}),
|
|
107
|
+
/* @__PURE__ */ x("button", {
|
|
108
|
+
type: "button",
|
|
109
|
+
onClick: () => l(e + 1),
|
|
110
|
+
disabled: e === n,
|
|
111
|
+
className: "flexi-icon-btn",
|
|
112
|
+
title: "Next page",
|
|
113
|
+
children: /* @__PURE__ */ x(a, { className: "flexi-icon-sm" })
|
|
114
|
+
}),
|
|
115
|
+
/* @__PURE__ */ x("button", {
|
|
116
|
+
type: "button",
|
|
117
|
+
onClick: () => l(n),
|
|
118
|
+
disabled: e === n,
|
|
119
|
+
className: "flexi-icon-btn",
|
|
120
|
+
title: "Last page",
|
|
121
|
+
children: /* @__PURE__ */ x(s, { className: "flexi-icon-sm" })
|
|
122
|
+
})
|
|
123
|
+
]
|
|
124
|
+
})
|
|
125
|
+
]
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
//#endregion
|
|
129
|
+
//#region src/DataTable/constants.ts
|
|
130
|
+
var te = [
|
|
131
|
+
10,
|
|
132
|
+
25,
|
|
133
|
+
50,
|
|
134
|
+
100
|
|
135
|
+
], k = [], A = [], j = (e) => {
|
|
7
136
|
let t = [];
|
|
8
137
|
return e.forEach((e) => {
|
|
9
|
-
e.children && e.children.length > 0 ? t.push(...
|
|
138
|
+
e.children && e.children.length > 0 ? t.push(...j(e.children)) : t.push(e);
|
|
10
139
|
}), t;
|
|
11
|
-
},
|
|
140
|
+
}, ne = (e) => {
|
|
12
141
|
if (e === !0) return "left";
|
|
13
142
|
if (e === "left" || e === "right") return e;
|
|
14
|
-
},
|
|
143
|
+
}, M = (e) => {
|
|
144
|
+
let t = {};
|
|
145
|
+
return e.forEach((e) => {
|
|
146
|
+
let n = ne(e.pinned);
|
|
147
|
+
n && (t[e.key] = n);
|
|
148
|
+
}), t;
|
|
149
|
+
}, N = (e, t, n) => {
|
|
15
150
|
let r = (e) => {
|
|
16
151
|
let n = t[e];
|
|
17
152
|
return n === "left" ? 0 : n === "right" ? 2 : 1;
|
|
@@ -26,922 +161,1100 @@ var m = (e) => {
|
|
|
26
161
|
children: i(e.children)
|
|
27
162
|
} : e);
|
|
28
163
|
return i(e);
|
|
29
|
-
},
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
64
|
-
}, [D]), c(() => {
|
|
65
|
-
if (!N) return;
|
|
66
|
-
function e(e) {
|
|
67
|
-
let t = e.target;
|
|
68
|
-
$e.current && !$e.current.contains(t) && !(P.current && P.current.contains(t)) && Qe(!1);
|
|
69
|
-
}
|
|
70
|
-
return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
71
|
-
}, [N]), c(() => {
|
|
72
|
-
if (!N) return;
|
|
73
|
-
let e = () => {
|
|
74
|
-
let e = P.current, t = U.current;
|
|
75
|
-
if (!e || !t) return;
|
|
76
|
-
let n = e.getBoundingClientRect(), r = t.getBoundingClientRect();
|
|
77
|
-
Le({
|
|
78
|
-
top: n.bottom - r.top + 4,
|
|
79
|
-
right: r.right - n.right
|
|
80
|
-
});
|
|
81
|
-
};
|
|
82
|
-
return e(), window.addEventListener("scroll", e, !0), window.addEventListener("resize", e), () => {
|
|
83
|
-
window.removeEventListener("scroll", e, !0), window.removeEventListener("resize", e);
|
|
84
|
-
};
|
|
85
|
-
}, [N]), c(() => {
|
|
86
|
-
if (!D) return;
|
|
87
|
-
let e = () => {
|
|
88
|
-
let e = Re.current.get(D), t = U.current;
|
|
89
|
-
if (!e || !t) return;
|
|
90
|
-
let n = e.getBoundingClientRect(), r = t.getBoundingClientRect();
|
|
91
|
-
Fe({
|
|
92
|
-
top: n.bottom - r.top + 4,
|
|
93
|
-
left: n.left - r.left
|
|
94
|
-
});
|
|
95
|
-
};
|
|
96
|
-
return e(), window.addEventListener("scroll", e, !0), window.addEventListener("resize", e), () => {
|
|
97
|
-
window.removeEventListener("scroll", e, !0), window.removeEventListener("resize", e);
|
|
98
|
-
};
|
|
99
|
-
}, [D]);
|
|
100
|
-
let at = (e) => typeof pe == "function" ? pe(e) : String(e[pe]), ot = (e, t) => {
|
|
101
|
-
if (!we) return;
|
|
102
|
-
let n;
|
|
103
|
-
for (let r in we) we[r](e, t) && (n = n ? `${n} ${r}` : r);
|
|
104
|
-
return n;
|
|
105
|
-
}, st = (e) => {
|
|
106
|
-
rt((t) => {
|
|
107
|
-
let n = t[e], r = n ? n === "left" ? "right" : void 0 : "left", i = { ...t };
|
|
108
|
-
return r ? i[e] = r : delete i[e], ge && ge(e, !!r, r), i;
|
|
109
|
-
});
|
|
110
|
-
}, ct = (e) => {
|
|
111
|
-
Ze((t) => {
|
|
112
|
-
let n = t.includes(e) ? t.filter((t) => t !== e) : [...t, e];
|
|
113
|
-
return w && w(n), n;
|
|
114
|
-
});
|
|
115
|
-
}, lt = () => {
|
|
116
|
-
Xe(De), Ze(Oe), w && w(Oe);
|
|
117
|
-
}, ut = (e) => {
|
|
118
|
-
let t = "asc";
|
|
119
|
-
j.key === e && (t = j.direction === "asc" ? "desc" : j.direction === "desc" ? null : "asc"), We({
|
|
120
|
-
key: t ? e : null,
|
|
121
|
-
direction: t
|
|
122
|
-
});
|
|
123
|
-
}, dt = (e, t, n) => {
|
|
124
|
-
if (nt.current) {
|
|
125
|
-
e.preventDefault();
|
|
126
|
-
return;
|
|
127
|
-
}
|
|
128
|
-
tt.current = t, n && e.dataTransfer.setData("text/plain", t), e.dataTransfer.effectAllowed = "move";
|
|
129
|
-
}, ft = (e, t, n) => {
|
|
130
|
-
let r = e.map((e) => e.key);
|
|
131
|
-
if (r.includes(t) && r.includes(n)) return e;
|
|
132
|
-
for (let r of e) if (r.children && r.children.length > 0) {
|
|
133
|
-
let e = ft(r.children, t, n);
|
|
134
|
-
if (e) return e;
|
|
135
|
-
}
|
|
136
|
-
return null;
|
|
137
|
-
}, pt = (e, t) => {
|
|
138
|
-
e.preventDefault(), e.stopPropagation();
|
|
139
|
-
let n = tt.current;
|
|
140
|
-
if (tt.current = null, !n || n === t) return;
|
|
141
|
-
let r = ft(V, n, t);
|
|
142
|
-
if (!r) return;
|
|
143
|
-
let i = r.map((e) => e.key), a = i.indexOf(n), o = i.indexOf(t);
|
|
144
|
-
i.splice(o, 0, i.splice(a, 1)[0]);
|
|
145
|
-
let s = { ...qe };
|
|
146
|
-
i.forEach((e, t) => {
|
|
147
|
-
s[e] = t;
|
|
148
|
-
}), Je(s), Ce && Ce(m(le(g, B, s)).map((e) => e.key));
|
|
149
|
-
}, mt = (e, t) => {
|
|
150
|
-
e.preventDefault(), e.stopPropagation(), nt.current = !0, R.current = {
|
|
151
|
-
key: t.key,
|
|
152
|
-
startX: e.clientX,
|
|
153
|
-
startWidth: W(t)
|
|
154
|
-
};
|
|
155
|
-
let n = t.minWidth ?? fe, r = t.maxWidth, i = (e) => {
|
|
156
|
-
let t = R.current;
|
|
157
|
-
if (!t) return;
|
|
158
|
-
let i = t.startWidth + (e.clientX - t.startX);
|
|
159
|
-
i = Math.max(n, i), r && (i = Math.min(r, i)), Ke((e) => e[t.key] === i ? e : {
|
|
160
|
-
...e,
|
|
161
|
-
[t.key]: i
|
|
162
|
-
});
|
|
163
|
-
}, a = () => {
|
|
164
|
-
let e = R.current;
|
|
165
|
-
R.current = null, window.removeEventListener("mousemove", i), window.removeEventListener("mouseup", a), requestAnimationFrame(() => {
|
|
166
|
-
nt.current = !1;
|
|
167
|
-
}), e && Se && Ke((t) => (t[e.key] !== void 0 && Se(e.key, t[e.key]), t));
|
|
168
|
-
};
|
|
169
|
-
window.addEventListener("mousemove", i), window.addEventListener("mouseup", a);
|
|
170
|
-
}, ht = (e) => {
|
|
171
|
-
e.preventDefault(), Ue(!1);
|
|
172
|
-
let t = e.dataTransfer.getData("text/plain");
|
|
173
|
-
if (t && !A.includes(t)) {
|
|
174
|
-
let e = [...A, t];
|
|
175
|
-
ze(e), b && b(e);
|
|
176
|
-
}
|
|
177
|
-
}, gt = (e) => {
|
|
178
|
-
let t = A.filter((t) => t !== e);
|
|
179
|
-
ze(t), Ve({}), b && b(t);
|
|
180
|
-
}, _t = l(() => {
|
|
181
|
-
let e = (t) => {
|
|
182
|
-
let n = 0;
|
|
183
|
-
return t.forEach((t) => {
|
|
184
|
-
n = t.children && t.children.length > 0 ? Math.max(n, 1 + e(t.children)) : Math.max(n, 1);
|
|
185
|
-
}), n;
|
|
186
|
-
}, t = e(V), n = Array.from({ length: t }, () => []), r = (e) => !e.children || e.children.length === 0 ? y && A.includes(e.key) || M.includes(e.key) ? 0 : 1 : e.children.reduce((e, t) => e + r(t), 0), i = y ? A : [], a = (e, o) => {
|
|
187
|
-
e.forEach((e) => {
|
|
188
|
-
if (i.includes(e.key)) return;
|
|
189
|
-
let s = r(e);
|
|
190
|
-
s !== 0 && (e.children && e.children.length > 0 ? (n[o].push({
|
|
191
|
-
col: e,
|
|
192
|
-
rowSpan: 1,
|
|
193
|
-
colSpan: s
|
|
194
|
-
}), a(e.children, o + 1)) : n[o].push({
|
|
195
|
-
col: e,
|
|
196
|
-
rowSpan: t - o,
|
|
197
|
-
colSpan: 1
|
|
198
|
-
}));
|
|
199
|
-
});
|
|
200
|
-
};
|
|
201
|
-
return a(V, 0), n.filter((e) => e.length > 0);
|
|
202
|
-
}, [
|
|
203
|
-
V,
|
|
204
|
-
A,
|
|
205
|
-
y,
|
|
206
|
-
M
|
|
207
|
-
]), W = (e) => {
|
|
208
|
-
if (Ge[e.key] !== void 0) return Ge[e.key];
|
|
209
|
-
let t = e.style?.width || e.headerStyle?.width || `${de}px`;
|
|
210
|
-
return typeof t == "number" ? t : parseInt(String(t), 10) || de;
|
|
211
|
-
}, vt = l(() => {
|
|
212
|
-
let e = {}, t = 0;
|
|
213
|
-
y && A.length > 0 && (t += 48), H.forEach((n) => {
|
|
214
|
-
B[n.key] === "left" && (e[n.key] = {
|
|
215
|
-
side: "left",
|
|
216
|
-
offset: t
|
|
217
|
-
}, t += W(n));
|
|
218
|
-
});
|
|
219
|
-
let n = v ? 100 : 0;
|
|
220
|
-
for (let t = H.length - 1; t >= 0; t--) {
|
|
221
|
-
let r = H[t];
|
|
222
|
-
B[r.key] === "right" && (e[r.key] = {
|
|
223
|
-
side: "right",
|
|
224
|
-
offset: n
|
|
225
|
-
}, n += W(r));
|
|
226
|
-
}
|
|
227
|
-
return e;
|
|
228
|
-
}, [
|
|
229
|
-
H,
|
|
230
|
-
B,
|
|
231
|
-
A,
|
|
232
|
-
y,
|
|
233
|
-
v,
|
|
234
|
-
Ge
|
|
235
|
-
]), yt = (e, t) => {
|
|
236
|
-
Me((n) => {
|
|
237
|
-
let r = n[e] || [], i = r.includes(t) ? r.filter((e) => e !== t) : [...r, t], a = {
|
|
238
|
-
...n,
|
|
239
|
-
[e]: i
|
|
240
|
-
};
|
|
241
|
-
return a[e].length === 0 && delete a[e], a;
|
|
242
|
-
});
|
|
243
|
-
}, bt = (e) => {
|
|
244
|
-
Me((t) => {
|
|
245
|
-
let n = { ...t };
|
|
246
|
-
return delete n[e], n;
|
|
247
|
-
});
|
|
248
|
-
}, G = l(() => {
|
|
249
|
-
let e = /* @__PURE__ */ new Map();
|
|
250
|
-
return z.forEach((t) => e.set(t.key, t)), e;
|
|
251
|
-
}, [z]), xt = l(() => {
|
|
252
|
-
if (!D) return [];
|
|
253
|
-
let e = G.get(D), t = _.map((t) => e?.getValue ? e.getValue(t) : t[D]);
|
|
254
|
-
return Array.from(new Set(t)).filter((e) => e != null);
|
|
255
|
-
}, [
|
|
256
|
-
_,
|
|
257
|
-
D,
|
|
258
|
-
G
|
|
259
|
-
]), St = l(() => {
|
|
260
|
-
if (!k.trim()) return xt;
|
|
261
|
-
let e = k.toLowerCase();
|
|
262
|
-
return xt.filter((t) => String(t).toLowerCase().includes(e));
|
|
263
|
-
}, [xt, k]), K = l(() => {
|
|
264
|
-
let e = Object.entries(O).filter(([, e]) => e && e.length > 0), t = e.length === 0 ? _ : _.filter((t) => e.every(([e, n]) => {
|
|
265
|
-
let r = G.get(e), i = r?.getValue ? r.getValue(t) : t[e];
|
|
266
|
-
return n.includes(i);
|
|
267
|
-
}));
|
|
268
|
-
if (j.key && j.direction) {
|
|
269
|
-
let { key: e, direction: n } = j, r = G.get(e);
|
|
270
|
-
t = [...t].sort((t, i) => {
|
|
271
|
-
let a = r?.getValue ? r.getValue(t) : t[e], o = r?.getValue ? r.getValue(i) : i[e];
|
|
272
|
-
if (a === o) return 0;
|
|
273
|
-
if (a == null) return 1;
|
|
274
|
-
if (o == null) return -1;
|
|
275
|
-
let s = 0;
|
|
276
|
-
return s = typeof a == "number" && typeof o == "number" ? a - o : String(a).localeCompare(String(o), void 0, {
|
|
277
|
-
numeric: !0,
|
|
278
|
-
sensitivity: "base"
|
|
279
|
-
}), n === "asc" ? s : -s;
|
|
280
|
-
});
|
|
281
|
-
}
|
|
282
|
-
return t;
|
|
283
|
-
}, [
|
|
284
|
-
_,
|
|
285
|
-
O,
|
|
286
|
-
j,
|
|
287
|
-
G
|
|
288
|
-
]), q = K.length, J = T ? Math.max(1, Math.ceil(q / L)) : 1;
|
|
289
|
-
c(() => {
|
|
290
|
-
I(1);
|
|
291
|
-
}, [
|
|
292
|
-
O,
|
|
293
|
-
j,
|
|
294
|
-
L,
|
|
295
|
-
T
|
|
296
|
-
]), c(() => {
|
|
297
|
-
F > J && I(J);
|
|
298
|
-
}, [F, J]);
|
|
299
|
-
let Ct = l(() => {
|
|
300
|
-
if (!T) return K;
|
|
301
|
-
let e = (F - 1) * L;
|
|
302
|
-
return K.slice(e, e + L);
|
|
303
|
-
}, [
|
|
304
|
-
K,
|
|
305
|
-
T,
|
|
306
|
-
F,
|
|
307
|
-
L
|
|
308
|
-
]), Y = (e) => {
|
|
309
|
-
let t = Math.min(Math.max(1, e), J);
|
|
310
|
-
I(t), E && E(t, L);
|
|
311
|
-
}, wt = (e) => {
|
|
312
|
-
et(e), I(1), E && E(1, e);
|
|
313
|
-
}, Tt = l(() => {
|
|
314
|
-
if (!y || A.length === 0) return Ct;
|
|
315
|
-
let e = (t, n, r = "") => {
|
|
316
|
-
if (n >= A.length) return t;
|
|
317
|
-
let i = A[n], a = G.get(i), o = {};
|
|
318
|
-
return t.forEach((e) => {
|
|
319
|
-
let t = a?.getValue ? a.getValue(e) : e[i], n = String(t ?? "N/A");
|
|
320
|
-
o[n] || (o[n] = []), o[n].push(e);
|
|
321
|
-
}), Object.entries(o).sort(([e], [t]) => e.localeCompare(t, void 0, {
|
|
322
|
-
numeric: !0,
|
|
323
|
-
sensitivity: "base"
|
|
324
|
-
})).map(([t, a]) => {
|
|
325
|
-
let o = r ? `${r}➔${t}` : t;
|
|
326
|
-
return {
|
|
327
|
-
isGroupRow: !0,
|
|
328
|
-
groupKey: i,
|
|
329
|
-
groupValue: t,
|
|
330
|
-
path: o,
|
|
331
|
-
depth: n,
|
|
332
|
-
children: e(a, n + 1, o),
|
|
333
|
-
totalItemsCount: a.length
|
|
334
|
-
};
|
|
335
|
-
});
|
|
336
|
-
};
|
|
337
|
-
return e(Ct, 0);
|
|
338
|
-
}, [
|
|
339
|
-
Ct,
|
|
340
|
-
A,
|
|
341
|
-
y,
|
|
342
|
-
G
|
|
343
|
-
]), Et = (e) => {
|
|
344
|
-
Ve((t) => {
|
|
345
|
-
let n = t[e] !== !1;
|
|
346
|
-
return {
|
|
347
|
-
...t,
|
|
348
|
-
[e]: !n
|
|
349
|
-
};
|
|
164
|
+
}, P = (e, t, n) => {
|
|
165
|
+
let r = e.map((e) => e.key);
|
|
166
|
+
if (r.includes(t) && r.includes(n)) return e;
|
|
167
|
+
for (let r of e) if (r.children && r.children.length > 0) {
|
|
168
|
+
let e = P(r.children, t, n);
|
|
169
|
+
if (e) return e;
|
|
170
|
+
}
|
|
171
|
+
return null;
|
|
172
|
+
}, F = (e, t) => {
|
|
173
|
+
let n = t[e.key];
|
|
174
|
+
if (n !== void 0) return n;
|
|
175
|
+
let r = e.style?.width || e.headerStyle?.width || "150px";
|
|
176
|
+
if (typeof r == "number") return r;
|
|
177
|
+
let i = String(r).trim();
|
|
178
|
+
return /^\d+(\.\d+)?(px)?$/i.test(i) && parseInt(i, 10) || 150;
|
|
179
|
+
}, re = (e, t, n) => {
|
|
180
|
+
let r = (e) => {
|
|
181
|
+
let t = 0;
|
|
182
|
+
return e.forEach((e) => {
|
|
183
|
+
t = e.children && e.children.length > 0 ? Math.max(t, 1 + r(e.children)) : Math.max(t, 1);
|
|
184
|
+
}), t;
|
|
185
|
+
}, i = r(e), a = Array.from({ length: i }, () => []), o = (e) => !e.children || e.children.length === 0 ? t.includes(e.key) || n.includes(e.key) ? 0 : 1 : e.children.reduce((e, t) => e + o(t), 0), s = (e, n) => {
|
|
186
|
+
e.forEach((e) => {
|
|
187
|
+
if (t.includes(e.key)) return;
|
|
188
|
+
let r = o(e);
|
|
189
|
+
r !== 0 && (e.children && e.children.length > 0 ? (a[n].push({
|
|
190
|
+
col: e,
|
|
191
|
+
rowSpan: 1,
|
|
192
|
+
colSpan: r
|
|
193
|
+
}), s(e.children, n + 1)) : a[n].push({
|
|
194
|
+
col: e,
|
|
195
|
+
rowSpan: i - n,
|
|
196
|
+
colSpan: 1
|
|
197
|
+
}));
|
|
350
198
|
});
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
},
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
let
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
let e = /* @__PURE__ */ new Map();
|
|
401
|
-
if (!C || C.length === 0) return e;
|
|
402
|
-
let t = (e, t) => {
|
|
403
|
-
let n = G.get(t);
|
|
404
|
-
return n?.getValue ? n.getValue(e) : e[t];
|
|
405
|
-
}, n = Ft, r = n.map(() => C.map(() => !0)), i = null;
|
|
406
|
-
for (let e = 0; e < n.length; e++) {
|
|
407
|
-
let a = n[e];
|
|
408
|
-
if (a.isGroupRow) {
|
|
409
|
-
i = null;
|
|
410
|
-
continue;
|
|
411
|
-
}
|
|
412
|
-
if (i !== null) {
|
|
413
|
-
let o = n[i], s = !0;
|
|
414
|
-
for (let n = 0; n < C.length; n++) {
|
|
415
|
-
let i = C[n];
|
|
416
|
-
s && t(a, i) === t(o, i) ? r[e][n] = !1 : (s = !1, r[e][n] = !0);
|
|
417
|
-
}
|
|
418
|
-
}
|
|
419
|
-
i = e;
|
|
420
|
-
}
|
|
421
|
-
return C.forEach((t, i) => {
|
|
422
|
-
let a = 0;
|
|
423
|
-
for (; a < n.length;) {
|
|
424
|
-
if (n[a].isGroupRow || !r[a][i]) {
|
|
425
|
-
a++;
|
|
426
|
-
continue;
|
|
427
|
-
}
|
|
428
|
-
let o = a + 1;
|
|
429
|
-
for (; o < n.length && !n[o].isGroupRow && !r[o][i];) o++;
|
|
430
|
-
if (o - a > 1) {
|
|
431
|
-
let n = e.get(Q + a) || {};
|
|
432
|
-
n[t] = o - a, e.set(Q + a, n);
|
|
433
|
-
for (let n = a + 1; n < o; n++) {
|
|
434
|
-
let r = e.get(Q + n) || {};
|
|
435
|
-
r[t] = "skip", e.set(Q + n, r);
|
|
436
|
-
}
|
|
437
|
-
}
|
|
438
|
-
a = o;
|
|
439
|
-
}
|
|
440
|
-
}), e;
|
|
441
|
-
}, [
|
|
442
|
-
Ft,
|
|
443
|
-
C,
|
|
444
|
-
G,
|
|
445
|
-
Q
|
|
446
|
-
]), Lt = (e, t = !1, n) => {
|
|
447
|
-
let r = vt[e];
|
|
448
|
-
if (!r) return n || {};
|
|
449
|
-
let i = r.side === "right";
|
|
450
|
-
return {
|
|
199
|
+
};
|
|
200
|
+
s(e, 0);
|
|
201
|
+
let c = a.filter((e) => e.length > 0);
|
|
202
|
+
return c.map((e, t) => e.map((e) => ({
|
|
203
|
+
...e,
|
|
204
|
+
rowSpan: Math.min(e.rowSpan, c.length - t)
|
|
205
|
+
})));
|
|
206
|
+
}, ie = ({ visibleLeafColumns: e, pinnedColumns: t, columnWidths: n, hasGroups: r, hasActions: i }) => {
|
|
207
|
+
let a = {}, o = r ? 48 : 0;
|
|
208
|
+
e.forEach((e) => {
|
|
209
|
+
t[e.key] === "left" && (a[e.key] = {
|
|
210
|
+
side: "left",
|
|
211
|
+
offset: o
|
|
212
|
+
}, o += F(e, n));
|
|
213
|
+
});
|
|
214
|
+
let s = i ? 100 : 0;
|
|
215
|
+
for (let r = e.length - 1; r >= 0; r--) {
|
|
216
|
+
let i = e[r];
|
|
217
|
+
t[i.key] === "right" && (a[i.key] = {
|
|
218
|
+
side: "right",
|
|
219
|
+
offset: s
|
|
220
|
+
}, s += F(i, n));
|
|
221
|
+
}
|
|
222
|
+
return a;
|
|
223
|
+
}, I = (e, t, n = !1, r) => {
|
|
224
|
+
let i = e[t];
|
|
225
|
+
if (!i) return r || {};
|
|
226
|
+
let a = i.side === "right";
|
|
227
|
+
return {
|
|
228
|
+
position: "sticky",
|
|
229
|
+
[a ? "right" : "left"]: `${i.offset}px`,
|
|
230
|
+
...n ? { top: 0 } : {},
|
|
231
|
+
zIndex: n ? 30 : 20,
|
|
232
|
+
background: "#f8fafc",
|
|
233
|
+
boxShadow: a ? "-2px 0 5px -2px rgba(0,0,0,0.1)" : "2px 0 5px -2px rgba(0,0,0,0.1)",
|
|
234
|
+
...r
|
|
235
|
+
};
|
|
236
|
+
}, ae = () => /* @__PURE__ */ x("td", {
|
|
237
|
+
className: "flexi-row-indent-cell",
|
|
238
|
+
style: {
|
|
239
|
+
position: "sticky",
|
|
240
|
+
left: 0,
|
|
241
|
+
zIndex: 10
|
|
242
|
+
}
|
|
243
|
+
});
|
|
244
|
+
function L({ children: e }) {
|
|
245
|
+
return /* @__PURE__ */ x("td", {
|
|
246
|
+
className: "flexi-actions-cell",
|
|
247
|
+
style: {
|
|
451
248
|
position: "sticky",
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
249
|
+
right: 0
|
|
250
|
+
},
|
|
251
|
+
children: /* @__PURE__ */ x("div", {
|
|
252
|
+
className: "flexi-actions-inner",
|
|
253
|
+
children: e
|
|
254
|
+
})
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
function oe({ node: e }) {
|
|
258
|
+
let { rowHeight: t, expandedGroups: n, toggleGroupExpansion: i, totalColumnsCount: o } = T(), s = n[e.path] !== !1;
|
|
259
|
+
return /* @__PURE__ */ S("tr", {
|
|
260
|
+
className: "flexi-group-row",
|
|
261
|
+
style: { height: t },
|
|
262
|
+
children: [/* @__PURE__ */ x("td", {
|
|
263
|
+
className: "flexi-group-cell",
|
|
264
|
+
style: {
|
|
265
|
+
position: "sticky",
|
|
266
|
+
left: 0,
|
|
267
|
+
zIndex: 20,
|
|
268
|
+
backgroundColor: "rgba(248, 250, 252, 0.9)",
|
|
269
|
+
paddingLeft: `${e.depth * 12 + 16}px`
|
|
270
|
+
},
|
|
271
|
+
children: /* @__PURE__ */ S("button", {
|
|
272
|
+
type: "button",
|
|
273
|
+
onClick: () => i(e.path),
|
|
274
|
+
className: "flexi-group-toggle",
|
|
275
|
+
children: [
|
|
276
|
+
x(s ? r : a, { className: "flexi-icon-md flexi-icon-muted" }),
|
|
277
|
+
/* @__PURE__ */ x("span", {
|
|
278
|
+
className: "flexi-group-value",
|
|
279
|
+
children: e.groupValue
|
|
280
|
+
}),
|
|
281
|
+
/* @__PURE__ */ x("span", {
|
|
282
|
+
className: "flexi-group-count",
|
|
283
|
+
children: e.totalItemsCount
|
|
284
|
+
})
|
|
285
|
+
]
|
|
286
|
+
})
|
|
287
|
+
}), /* @__PURE__ */ x("td", {
|
|
288
|
+
colSpan: Math.max(1, o - 1),
|
|
289
|
+
className: "flexi-group-filler"
|
|
290
|
+
})]
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
function se({ record: e, rowIndex: t, className: n }) {
|
|
294
|
+
let { rowHeight: r, hasGroups: i, hasActions: a, actions: o, onRowClick: s, visibleLeafColumns: c, pinnedColumns: l, pinOffsets: u, rowSpanColumns: d, rowSpanInfo: f } = T(), p = f.get(t);
|
|
295
|
+
return /* @__PURE__ */ S("tr", {
|
|
296
|
+
className: E("flexi-row", s && "flexi-row--clickable", n),
|
|
297
|
+
style: { height: r },
|
|
298
|
+
onClick: s ? (n) => s(e, t, n) : void 0,
|
|
299
|
+
children: [
|
|
300
|
+
i && /* @__PURE__ */ x(ae, {}),
|
|
301
|
+
c.map((t) => {
|
|
302
|
+
let n = d?.includes(t.key) ? p?.[t.key] : void 0;
|
|
303
|
+
if (n === "skip") return null;
|
|
304
|
+
let r = e[t.key];
|
|
305
|
+
return /* @__PURE__ */ x("td", {
|
|
306
|
+
rowSpan: typeof n == "number" ? n : void 0,
|
|
307
|
+
className: E("flexi-cell", !!l[t.key] && "flexi-cell--pinned", t.className),
|
|
308
|
+
style: I(u, t.key, !1, t.style),
|
|
309
|
+
children: t.render ? t.render(r, e) : /* @__PURE__ */ x("span", {
|
|
310
|
+
className: "flexi-cell-text",
|
|
311
|
+
children: r
|
|
312
|
+
})
|
|
313
|
+
}, t.key);
|
|
314
|
+
}),
|
|
315
|
+
a && o && /* @__PURE__ */ x(L, { children: o(e) })
|
|
316
|
+
]
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
function R({ record: e, index: t, className: n }) {
|
|
320
|
+
let { hasGroups: r, hasActions: i, actions: a, pinnedBottomRowData: o, visibleLeafColumns: s, pinnedColumns: c, pinOffsets: l } = T(), u = {
|
|
321
|
+
position: "sticky",
|
|
322
|
+
bottom: `${(o.length - 1 - t) * 48}px`,
|
|
323
|
+
zIndex: 45
|
|
324
|
+
};
|
|
325
|
+
return /* @__PURE__ */ S("tr", {
|
|
326
|
+
className: E("flexi-row", "flexi-row--pinned-bottom", n),
|
|
327
|
+
style: u,
|
|
328
|
+
children: [
|
|
329
|
+
r && /* @__PURE__ */ x(ae, {}),
|
|
330
|
+
s.map((t) => {
|
|
331
|
+
let n = e[t.key], r = t.pinnedRender ?? t.render;
|
|
332
|
+
return /* @__PURE__ */ x("td", {
|
|
333
|
+
className: E("flexi-cell", !!c[t.key] && "flexi-cell--pinned", t.className),
|
|
334
|
+
style: I(l, t.key, !1, t.style),
|
|
335
|
+
children: r ? r(n, e) : /* @__PURE__ */ x("span", {
|
|
336
|
+
className: "flexi-cell-text",
|
|
337
|
+
children: n
|
|
338
|
+
})
|
|
339
|
+
}, t.key);
|
|
340
|
+
}),
|
|
341
|
+
i && a && /* @__PURE__ */ x(L, { children: a(e) })
|
|
342
|
+
]
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
//#endregion
|
|
346
|
+
//#region src/DataTable/components/PinnedBottomBody.tsx
|
|
347
|
+
function ce() {
|
|
348
|
+
let { pinnedBottomRowData: e, pinnedRowClassName: t } = T();
|
|
349
|
+
return e.length === 0 ? null : /* @__PURE__ */ x("tbody", {
|
|
350
|
+
className: "flexi-tbody flexi-tbody--pinned-bottom",
|
|
351
|
+
children: e.map((e, n) => /* @__PURE__ */ x(R, {
|
|
352
|
+
record: e,
|
|
353
|
+
index: n,
|
|
354
|
+
className: typeof t == "function" ? t(e, n) : t
|
|
355
|
+
}, `pinned-bottom-row-${n}`))
|
|
356
|
+
});
|
|
357
|
+
}
|
|
358
|
+
//#endregion
|
|
359
|
+
//#region src/DataTable/components/SettingsMenu.tsx
|
|
360
|
+
function le() {
|
|
361
|
+
let { settingsMenu: e } = T();
|
|
362
|
+
return /* @__PURE__ */ x("button", {
|
|
460
363
|
type: "button",
|
|
461
|
-
ref:
|
|
462
|
-
onClick: (
|
|
463
|
-
|
|
364
|
+
ref: e.buttonRef,
|
|
365
|
+
onClick: (t) => {
|
|
366
|
+
t.stopPropagation(), e.toggle();
|
|
464
367
|
},
|
|
465
|
-
className:
|
|
368
|
+
className: E("flexi-icon-btn", e.isOpen && "flexi-settings-btn--active"),
|
|
466
369
|
title: "Grid display settings",
|
|
467
|
-
children: /* @__PURE__ */ f
|
|
468
|
-
})
|
|
469
|
-
|
|
370
|
+
children: /* @__PURE__ */ x(f, { className: "flexi-icon-sm" })
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
function ue() {
|
|
374
|
+
let { gridRootRef: e, settingsMenu: t, displayPinnedIcon: n, toggleDisplayPinnedIcon: r, showGroupBy: i, toggleShowGroupBy: a, initialLeafColumns: o, hiddenColumns: s, toggleColumnVisibility: c, resetControlPanelDefaults: l } = T(), u = e.current;
|
|
375
|
+
return !t.isOpen || !t.position || !u ? null : C(/* @__PURE__ */ S("div", {
|
|
376
|
+
ref: t.menuRef,
|
|
470
377
|
className: "flexi-settings-menu",
|
|
471
378
|
style: {
|
|
472
|
-
top:
|
|
473
|
-
right:
|
|
379
|
+
top: t.position.top,
|
|
380
|
+
right: t.position.right,
|
|
474
381
|
zIndex: 9999
|
|
475
382
|
},
|
|
476
383
|
children: [
|
|
477
|
-
/* @__PURE__ */
|
|
384
|
+
/* @__PURE__ */ S("div", {
|
|
478
385
|
className: "flexi-settings-section",
|
|
479
|
-
children: [
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
386
|
+
children: [
|
|
387
|
+
/* @__PURE__ */ x("span", {
|
|
388
|
+
className: "flexi-settings-heading",
|
|
389
|
+
children: "Action Icons"
|
|
390
|
+
}),
|
|
391
|
+
/* @__PURE__ */ S("label", {
|
|
392
|
+
className: "flexi-filter-option",
|
|
393
|
+
children: [/* @__PURE__ */ x("input", {
|
|
394
|
+
type: "checkbox",
|
|
395
|
+
className: "flexi-checkbox",
|
|
396
|
+
checked: n,
|
|
397
|
+
onChange: r
|
|
398
|
+
}), /* @__PURE__ */ x("span", {
|
|
399
|
+
className: "flexi-filter-option-text",
|
|
400
|
+
children: "Show pin icon on hover"
|
|
401
|
+
})]
|
|
402
|
+
}),
|
|
403
|
+
/* @__PURE__ */ S("label", {
|
|
404
|
+
className: "flexi-filter-option",
|
|
405
|
+
children: [/* @__PURE__ */ x("input", {
|
|
406
|
+
type: "checkbox",
|
|
407
|
+
className: "flexi-checkbox",
|
|
408
|
+
checked: i,
|
|
409
|
+
onChange: a
|
|
410
|
+
}), /* @__PURE__ */ x("span", {
|
|
411
|
+
className: "flexi-filter-option-text",
|
|
412
|
+
children: "Group By"
|
|
413
|
+
})]
|
|
414
|
+
})
|
|
415
|
+
]
|
|
494
416
|
}),
|
|
495
|
-
/* @__PURE__ */
|
|
496
|
-
/* @__PURE__ */
|
|
417
|
+
/* @__PURE__ */ x("div", { className: "flexi-settings-divider" }),
|
|
418
|
+
/* @__PURE__ */ S("div", {
|
|
497
419
|
className: "flexi-settings-section",
|
|
498
|
-
children: [/* @__PURE__ */
|
|
420
|
+
children: [/* @__PURE__ */ x("span", {
|
|
499
421
|
className: "flexi-settings-heading",
|
|
500
422
|
children: "Columns"
|
|
501
|
-
}),
|
|
423
|
+
}), o.map((e) => /* @__PURE__ */ S("label", {
|
|
502
424
|
className: "flexi-filter-option",
|
|
503
|
-
children: [/* @__PURE__ */
|
|
425
|
+
children: [/* @__PURE__ */ x("input", {
|
|
504
426
|
type: "checkbox",
|
|
505
427
|
className: "flexi-checkbox",
|
|
506
|
-
checked: !
|
|
507
|
-
onChange: () =>
|
|
508
|
-
}), /* @__PURE__ */
|
|
428
|
+
checked: !s.includes(e.key),
|
|
429
|
+
onChange: () => c(e.key)
|
|
430
|
+
}), /* @__PURE__ */ x("span", {
|
|
509
431
|
className: "flexi-filter-option-text",
|
|
510
432
|
children: e.header
|
|
511
433
|
})]
|
|
512
434
|
}, e.key))]
|
|
513
435
|
}),
|
|
514
|
-
/* @__PURE__ */
|
|
515
|
-
/* @__PURE__ */
|
|
436
|
+
/* @__PURE__ */ x("div", { className: "flexi-settings-divider" }),
|
|
437
|
+
/* @__PURE__ */ S("button", {
|
|
516
438
|
type: "button",
|
|
517
|
-
onClick:
|
|
439
|
+
onClick: l,
|
|
518
440
|
className: "flexi-settings-reset",
|
|
519
441
|
title: "Reset pin icon visibility and hidden columns to their defaults",
|
|
520
|
-
children: [/* @__PURE__ */
|
|
442
|
+
children: [/* @__PURE__ */ x(d, { className: "flexi-icon-sm" }), /* @__PURE__ */ x("span", { children: "Reset to defaults" })]
|
|
521
443
|
})
|
|
522
444
|
]
|
|
523
|
-
}),
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
445
|
+
}), u);
|
|
446
|
+
}
|
|
447
|
+
//#endregion
|
|
448
|
+
//#region src/DataTable/utils/records.ts
|
|
449
|
+
var z = (e, t, n) => n?.getValue ? n.getValue(e) : e[t], B = (e, t) => {
|
|
450
|
+
let n = typeof t == "function" ? t(e) : e[t];
|
|
451
|
+
return n == null ? void 0 : String(n);
|
|
452
|
+
}, V = (e, t, n) => {
|
|
453
|
+
if (!n) return;
|
|
454
|
+
let r;
|
|
455
|
+
for (let i in n) n[i](e, t) && (r = r ? `${r} ${i}` : i);
|
|
456
|
+
return r;
|
|
457
|
+
}, de = (e, t, n) => {
|
|
458
|
+
let r = e.map((e) => z(e, t, n));
|
|
459
|
+
return Array.from(new Set(r)).filter((e) => e != null);
|
|
460
|
+
}, fe = (e, t, n) => {
|
|
461
|
+
let r = Object.entries(t).filter(([, e]) => e && e.length > 0);
|
|
462
|
+
return r.length === 0 ? e : e.filter((e) => r.every(([t, r]) => r.includes(z(e, t, n.get(t)))));
|
|
463
|
+
}, H = (e) => e == null || typeof e == "number" && Number.isNaN(e), pe = (e, t) => typeof e == "number" && typeof t == "number" ? e - t : e instanceof Date && t instanceof Date ? e.getTime() - t.getTime() : String(e).localeCompare(String(t), void 0, {
|
|
464
|
+
numeric: !0,
|
|
465
|
+
sensitivity: "base"
|
|
466
|
+
}), me = (e, t, n, r) => [...e].sort((e, i) => {
|
|
467
|
+
let a = z(e, t, r), o = z(i, t, r);
|
|
468
|
+
if (a === o) return 0;
|
|
469
|
+
let s = H(a), c = H(o);
|
|
470
|
+
if (s && c) return 0;
|
|
471
|
+
if (s) return 1;
|
|
472
|
+
if (c) return -1;
|
|
473
|
+
let l = pe(a, o);
|
|
474
|
+
return n === "asc" ? l : -l;
|
|
475
|
+
});
|
|
476
|
+
//#endregion
|
|
477
|
+
//#region src/DataTable/components/TableBody.tsx
|
|
478
|
+
function U() {
|
|
479
|
+
let { isLoading: e, visibleRows: t, startIndex: n, totalRowCount: r, topSpacerHeight: i, bottomSpacerHeight: a, totalColumnsCount: o, rowKey: s, rowClassRules: c } = T(), l = Math.max(1, o);
|
|
480
|
+
return e || r === 0 ? /* @__PURE__ */ x("tbody", {
|
|
481
|
+
className: "flexi-tbody",
|
|
482
|
+
children: /* @__PURE__ */ x("tr", { children: /* @__PURE__ */ x("td", {
|
|
483
|
+
colSpan: l,
|
|
484
|
+
className: "flexi-empty-cell",
|
|
485
|
+
children: e ? "Loading records..." : "No records found matching criteria."
|
|
486
|
+
}) })
|
|
487
|
+
}) : /* @__PURE__ */ S("tbody", {
|
|
488
|
+
className: "flexi-tbody",
|
|
527
489
|
children: [
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
}) : /* @__PURE__ */ p("div", {
|
|
539
|
-
className: "flexi-groupzone-chips",
|
|
540
|
-
children: [/* @__PURE__ */ f("span", {
|
|
541
|
-
className: "flexi-groupzone-label",
|
|
542
|
-
children: "Grouped By:"
|
|
543
|
-
}), A.map((e) => /* @__PURE__ */ p("div", {
|
|
544
|
-
className: "flexi-chip",
|
|
545
|
-
children: [/* @__PURE__ */ f("span", { children: z.find((t) => t.key === e)?.header || e }), /* @__PURE__ */ f("button", {
|
|
546
|
-
type: "button",
|
|
547
|
-
onClick: () => gt(e),
|
|
548
|
-
className: "flexi-icon-btn flexi-chip-remove",
|
|
549
|
-
children: /* @__PURE__ */ f(ae, { className: "flexi-icon-xs" })
|
|
550
|
-
})]
|
|
551
|
-
}, e))]
|
|
490
|
+
i > 0 && /* @__PURE__ */ x("tr", {
|
|
491
|
+
"aria-hidden": "true",
|
|
492
|
+
style: { height: i },
|
|
493
|
+
children: /* @__PURE__ */ x("td", {
|
|
494
|
+
colSpan: l,
|
|
495
|
+
style: {
|
|
496
|
+
padding: 0,
|
|
497
|
+
border: "none",
|
|
498
|
+
height: i
|
|
499
|
+
}
|
|
552
500
|
})
|
|
553
501
|
}),
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
className:
|
|
560
|
-
|
|
561
|
-
children: [
|
|
562
|
-
/* @__PURE__ */ p("colgroup", { children: [
|
|
563
|
-
y && A.length > 0 && /* @__PURE__ */ f("col", { style: { width: "48px" } }),
|
|
564
|
-
H.map((e) => /* @__PURE__ */ f("col", { style: {
|
|
565
|
-
...e.style,
|
|
566
|
-
width: W(e)
|
|
567
|
-
} }, e.key)),
|
|
568
|
-
v && /* @__PURE__ */ f("col", { style: { width: "100px" } })
|
|
569
|
-
] }),
|
|
570
|
-
/* @__PURE__ */ f("thead", {
|
|
571
|
-
className: "flexi-thead",
|
|
572
|
-
children: _t.map((r, i) => /* @__PURE__ */ p("tr", {
|
|
573
|
-
className: "flexi-header-row",
|
|
574
|
-
children: [
|
|
575
|
-
i === 0 && y && A.length > 0 && /* @__PURE__ */ f("th", {
|
|
576
|
-
rowSpan: _t.length,
|
|
577
|
-
className: "flexi-group-spacer-th",
|
|
578
|
-
style: {
|
|
579
|
-
position: "sticky",
|
|
580
|
-
top: 0,
|
|
581
|
-
left: 0,
|
|
582
|
-
zIndex: 35,
|
|
583
|
-
backgroundColor: "rgb(248, 250, 252)"
|
|
584
|
-
}
|
|
585
|
-
}),
|
|
586
|
-
r.map(({ col: a, rowSpan: o, colSpan: s }, re) => {
|
|
587
|
-
let ie = (O[a.key]?.length || 0) > 0, ae = !!B[a.key], c = Lt(a.key, !0, a.headerStyle), l = !a.children || a.children.length === 0, u = j.key === a.key, d = !!(y && l), se = l && a.resizable !== !1;
|
|
588
|
-
return i === 0 && r.length - 1, /* @__PURE__ */ p("th", {
|
|
589
|
-
rowSpan: o,
|
|
590
|
-
colSpan: s,
|
|
591
|
-
draggable: !0,
|
|
592
|
-
onDragStart: (e) => dt(e, a.key, l),
|
|
593
|
-
onDragOver: (e) => e.preventDefault(),
|
|
594
|
-
onDrop: (e) => pt(e, a.key),
|
|
595
|
-
className: h("flexi-th", "flexi-th--draggable", d && "flexi-th--group-draggable", ae && "flexi-th--pinned", a.className, a.headerClassName),
|
|
596
|
-
style: c,
|
|
597
|
-
children: [/* @__PURE__ */ p("div", {
|
|
598
|
-
className: "flexi-th-inner",
|
|
599
|
-
children: [
|
|
600
|
-
/* @__PURE__ */ p("div", {
|
|
601
|
-
className: h("flexi-th-label", a.sortable && l && "flexi-th-label--sortable"),
|
|
602
|
-
onClick: () => a.sortable && l && ut(a.key),
|
|
603
|
-
children: [/* @__PURE__ */ f("span", {
|
|
604
|
-
className: "flexi-th-text",
|
|
605
|
-
children: a.header
|
|
606
|
-
}), l && a.sortable && /* @__PURE__ */ f("span", {
|
|
607
|
-
className: h("flexi-sort-icon", u && "flexi-sort-icon--active"),
|
|
608
|
-
children: u && j.direction === "asc" ? /* @__PURE__ */ f(t, { className: "flexi-icon-sm" }) : u && j.direction === "desc" ? /* @__PURE__ */ f(e, { className: "flexi-icon-sm" }) : /* @__PURE__ */ f(n, { className: "flexi-icon-sm" })
|
|
609
|
-
})]
|
|
610
|
-
}),
|
|
611
|
-
/* @__PURE__ */ p("div", {
|
|
612
|
-
className: "flexi-th-actions",
|
|
613
|
-
children: [l && a.filterable && /* @__PURE__ */ f("button", {
|
|
614
|
-
type: "button",
|
|
615
|
-
ref: (e) => {
|
|
616
|
-
e ? Re.current.set(a.key, e) : Re.current.delete(a.key);
|
|
617
|
-
},
|
|
618
|
-
onClick: (e) => {
|
|
619
|
-
e.stopPropagation(), Ne(""), je(D === a.key ? null : a.key);
|
|
620
|
-
},
|
|
621
|
-
className: h("flexi-icon-btn", "flexi-filter-btn", ie && "flexi-filter-btn--active"),
|
|
622
|
-
children: /* @__PURE__ */ f(ee, { className: "flexi-icon-sm" })
|
|
623
|
-
}), l && Ye && /* @__PURE__ */ f("button", {
|
|
624
|
-
type: "button",
|
|
625
|
-
onClick: (e) => {
|
|
626
|
-
e.stopPropagation(), st(a.key);
|
|
627
|
-
},
|
|
628
|
-
className: h("flexi-icon-btn", "flexi-pin-btn", ae && "flexi-pin-btn--pinned"),
|
|
629
|
-
title: B[a.key] === "left" ? "Pinned left (click to pin right)" : B[a.key] === "right" ? "Pinned right (click to unpin)" : "Pin column left",
|
|
630
|
-
children: f(ae ? ne : te, { className: "flexi-icon-sm" })
|
|
631
|
-
})]
|
|
632
|
-
}),
|
|
633
|
-
D === a.key && l && Pe && U.current && oe(/* @__PURE__ */ p("div", {
|
|
634
|
-
ref: it,
|
|
635
|
-
className: "flexi-filter-dropdown",
|
|
636
|
-
style: {
|
|
637
|
-
top: Pe.top,
|
|
638
|
-
left: Pe.left,
|
|
639
|
-
zIndex: 9999
|
|
640
|
-
},
|
|
641
|
-
children: [
|
|
642
|
-
/* @__PURE__ */ f("div", {
|
|
643
|
-
className: "flexi-filter-search",
|
|
644
|
-
children: /* @__PURE__ */ f("input", {
|
|
645
|
-
type: "text",
|
|
646
|
-
placeholder: "Search values...",
|
|
647
|
-
value: k,
|
|
648
|
-
onChange: (e) => Ne(e.target.value),
|
|
649
|
-
className: "flexi-input",
|
|
650
|
-
onClick: (e) => e.stopPropagation()
|
|
651
|
-
})
|
|
652
|
-
}),
|
|
653
|
-
/* @__PURE__ */ f("div", {
|
|
654
|
-
className: "flexi-filter-list",
|
|
655
|
-
children: St.length === 0 ? /* @__PURE__ */ f("div", {
|
|
656
|
-
className: "flexi-filter-empty",
|
|
657
|
-
children: "No results found"
|
|
658
|
-
}) : St.map((e, t) => /* @__PURE__ */ p("label", {
|
|
659
|
-
className: "flexi-filter-option",
|
|
660
|
-
children: [/* @__PURE__ */ f("input", {
|
|
661
|
-
type: "checkbox",
|
|
662
|
-
className: "flexi-checkbox",
|
|
663
|
-
checked: O[a.key]?.includes(e) || !1,
|
|
664
|
-
onChange: () => yt(a.key, e)
|
|
665
|
-
}), /* @__PURE__ */ f("span", {
|
|
666
|
-
className: "flexi-filter-option-text",
|
|
667
|
-
children: String(e)
|
|
668
|
-
})]
|
|
669
|
-
}, t))
|
|
670
|
-
}),
|
|
671
|
-
ie && /* @__PURE__ */ f("div", {
|
|
672
|
-
className: "flexi-filter-footer",
|
|
673
|
-
children: /* @__PURE__ */ f("button", {
|
|
674
|
-
type: "button",
|
|
675
|
-
onClick: () => bt(a.key),
|
|
676
|
-
className: "flexi-filter-clear",
|
|
677
|
-
children: "Clear Filter"
|
|
678
|
-
})
|
|
679
|
-
})
|
|
680
|
-
]
|
|
681
|
-
}), U.current)
|
|
682
|
-
]
|
|
683
|
-
}), se && /* @__PURE__ */ f("div", {
|
|
684
|
-
className: "flexi-th-resizer",
|
|
685
|
-
onMouseDown: (e) => mt(e, a),
|
|
686
|
-
onClick: (e) => e.stopPropagation(),
|
|
687
|
-
onDragStart: (e) => e.preventDefault()
|
|
688
|
-
})]
|
|
689
|
-
}, a.key);
|
|
690
|
-
}),
|
|
691
|
-
Ee && i === 0 && /* @__PURE__ */ f("div", {
|
|
692
|
-
className: "flexi-actions-th flexi-th",
|
|
693
|
-
style: {
|
|
694
|
-
position: "sticky",
|
|
695
|
-
top: 0,
|
|
696
|
-
right: 0,
|
|
697
|
-
zIndex: 55,
|
|
698
|
-
display: "flex",
|
|
699
|
-
justifyContent: "center",
|
|
700
|
-
alignItems: "center"
|
|
701
|
-
},
|
|
702
|
-
children: Ee && zt
|
|
703
|
-
})
|
|
704
|
-
]
|
|
705
|
-
}, `header-row-${i}`))
|
|
706
|
-
}),
|
|
707
|
-
/* @__PURE__ */ f("tbody", {
|
|
708
|
-
className: "flexi-tbody",
|
|
709
|
-
children: me ? /* @__PURE__ */ f("tr", { children: /* @__PURE__ */ f("td", {
|
|
710
|
-
colSpan: $,
|
|
711
|
-
className: "flexi-empty-cell",
|
|
712
|
-
children: "Loading records..."
|
|
713
|
-
}) }) : X.length === 0 ? /* @__PURE__ */ f("tr", { children: /* @__PURE__ */ f("td", {
|
|
714
|
-
colSpan: $,
|
|
715
|
-
className: "flexi-empty-cell",
|
|
716
|
-
children: "No records found matching criteria."
|
|
717
|
-
}) }) : /* @__PURE__ */ p(se, { children: [
|
|
718
|
-
Nt > 0 && /* @__PURE__ */ f("tr", {
|
|
719
|
-
"aria-hidden": "true",
|
|
720
|
-
style: { height: Nt },
|
|
721
|
-
children: /* @__PURE__ */ f("td", {
|
|
722
|
-
colSpan: $,
|
|
723
|
-
style: {
|
|
724
|
-
padding: 0,
|
|
725
|
-
border: "none",
|
|
726
|
-
height: Nt
|
|
727
|
-
}
|
|
728
|
-
})
|
|
729
|
-
}),
|
|
730
|
-
Ft.map((e, t) => Vt(e, Q + t)),
|
|
731
|
-
Pt > 0 && /* @__PURE__ */ f("tr", {
|
|
732
|
-
"aria-hidden": "true",
|
|
733
|
-
style: { height: Pt },
|
|
734
|
-
children: /* @__PURE__ */ f("td", {
|
|
735
|
-
colSpan: $,
|
|
736
|
-
style: {
|
|
737
|
-
padding: 0,
|
|
738
|
-
border: "none",
|
|
739
|
-
height: Pt
|
|
740
|
-
}
|
|
741
|
-
})
|
|
742
|
-
})
|
|
743
|
-
] })
|
|
744
|
-
}),
|
|
745
|
-
x.length > 0 && /* @__PURE__ */ f("tbody", {
|
|
746
|
-
className: "flexi-tbody flexi-tbody--pinned-bottom",
|
|
747
|
-
children: x.map((e, t) => Ht(e, t))
|
|
748
|
-
})
|
|
749
|
-
]
|
|
750
|
-
})
|
|
502
|
+
t.map((e, t) => {
|
|
503
|
+
let r = n + t;
|
|
504
|
+
return e.kind === "group" ? /* @__PURE__ */ x(oe, { node: e }, `group-header-${e.path}-${r}`) : /* @__PURE__ */ x(se, {
|
|
505
|
+
record: e.record,
|
|
506
|
+
rowIndex: r,
|
|
507
|
+
className: V(e.record, r, c)
|
|
508
|
+
}, B(e.record, s) ?? `row-${r}`);
|
|
751
509
|
}),
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
children:
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
value: e,
|
|
764
|
-
children: e
|
|
765
|
-
}, e))
|
|
766
|
-
})]
|
|
767
|
-
}),
|
|
768
|
-
/* @__PURE__ */ f("div", {
|
|
769
|
-
className: "flexi-pagination-info",
|
|
770
|
-
children: q === 0 ? "0 of 0" : `${(F - 1) * L + 1}–${Math.min(F * L, q)} of ${q}`
|
|
771
|
-
}),
|
|
772
|
-
/* @__PURE__ */ p("div", {
|
|
773
|
-
className: "flexi-pagination-controls",
|
|
774
|
-
children: [
|
|
775
|
-
/* @__PURE__ */ f("button", {
|
|
776
|
-
type: "button",
|
|
777
|
-
onClick: () => Y(1),
|
|
778
|
-
disabled: F === 1,
|
|
779
|
-
className: "flexi-icon-btn",
|
|
780
|
-
title: "First page",
|
|
781
|
-
children: /* @__PURE__ */ f(o, { className: "flexi-icon-sm" })
|
|
782
|
-
}),
|
|
783
|
-
/* @__PURE__ */ f("button", {
|
|
784
|
-
type: "button",
|
|
785
|
-
onClick: () => Y(F - 1),
|
|
786
|
-
disabled: F === 1,
|
|
787
|
-
className: "flexi-icon-btn",
|
|
788
|
-
title: "Previous page",
|
|
789
|
-
children: /* @__PURE__ */ f(i, { className: "flexi-icon-sm" })
|
|
790
|
-
}),
|
|
791
|
-
/* @__PURE__ */ p("span", {
|
|
792
|
-
className: "flexi-pagination-page",
|
|
793
|
-
children: [
|
|
794
|
-
"Page ",
|
|
795
|
-
F,
|
|
796
|
-
" of ",
|
|
797
|
-
J
|
|
798
|
-
]
|
|
799
|
-
}),
|
|
800
|
-
/* @__PURE__ */ f("button", {
|
|
801
|
-
type: "button",
|
|
802
|
-
onClick: () => Y(F + 1),
|
|
803
|
-
disabled: F === J,
|
|
804
|
-
className: "flexi-icon-btn",
|
|
805
|
-
title: "Next page",
|
|
806
|
-
children: /* @__PURE__ */ f(a, { className: "flexi-icon-sm" })
|
|
807
|
-
}),
|
|
808
|
-
/* @__PURE__ */ f("button", {
|
|
809
|
-
type: "button",
|
|
810
|
-
onClick: () => Y(J),
|
|
811
|
-
disabled: F === J,
|
|
812
|
-
className: "flexi-icon-btn",
|
|
813
|
-
title: "Last page",
|
|
814
|
-
children: /* @__PURE__ */ f(s, { className: "flexi-icon-sm" })
|
|
815
|
-
})
|
|
816
|
-
]
|
|
817
|
-
})
|
|
818
|
-
]
|
|
510
|
+
a > 0 && /* @__PURE__ */ x("tr", {
|
|
511
|
+
"aria-hidden": "true",
|
|
512
|
+
style: { height: a },
|
|
513
|
+
children: /* @__PURE__ */ x("td", {
|
|
514
|
+
colSpan: l,
|
|
515
|
+
style: {
|
|
516
|
+
padding: 0,
|
|
517
|
+
border: "none",
|
|
518
|
+
height: a
|
|
519
|
+
}
|
|
520
|
+
})
|
|
819
521
|
})
|
|
820
522
|
]
|
|
821
523
|
});
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
524
|
+
}
|
|
525
|
+
//#endregion
|
|
526
|
+
//#region src/DataTable/components/TableColGroup.tsx
|
|
527
|
+
function he() {
|
|
528
|
+
let { hasGroups: e, hasActions: t, visibleLeafColumns: n, columnWidths: r } = T();
|
|
529
|
+
return /* @__PURE__ */ S("colgroup", { children: [
|
|
530
|
+
e && /* @__PURE__ */ x("col", { style: { width: "48px" } }),
|
|
531
|
+
n.map((e) => /* @__PURE__ */ x("col", { style: {
|
|
532
|
+
...e.style,
|
|
533
|
+
width: F(e, r)
|
|
534
|
+
} }, e.key)),
|
|
535
|
+
t && /* @__PURE__ */ x("col", { style: { width: "100px" } })
|
|
536
|
+
] });
|
|
537
|
+
}
|
|
538
|
+
//#endregion
|
|
539
|
+
//#region src/DataTable/components/FilterDropdown.tsx
|
|
540
|
+
function ge({ columnKey: e }) {
|
|
541
|
+
let { gridRootRef: t, filters: n } = T(), r = t.current, { filterPosition: i } = n;
|
|
542
|
+
if (!r || !i) return null;
|
|
543
|
+
let a = n.selectedFilters[e], o = (a?.length || 0) > 0, s = n.filteredUniqueValues;
|
|
544
|
+
return C(/* @__PURE__ */ S("div", {
|
|
545
|
+
ref: n.dropdownRef,
|
|
546
|
+
className: "flexi-filter-dropdown",
|
|
547
|
+
style: {
|
|
548
|
+
top: i.top,
|
|
549
|
+
left: i.left,
|
|
550
|
+
zIndex: 9999
|
|
551
|
+
},
|
|
552
|
+
children: [
|
|
553
|
+
/* @__PURE__ */ x("div", {
|
|
554
|
+
className: "flexi-filter-search",
|
|
555
|
+
children: /* @__PURE__ */ x("input", {
|
|
556
|
+
type: "text",
|
|
557
|
+
placeholder: "Search values...",
|
|
558
|
+
value: n.filterSearchQuery,
|
|
559
|
+
onChange: (e) => n.setFilterSearchQuery(e.target.value),
|
|
560
|
+
className: "flexi-input",
|
|
561
|
+
onClick: (e) => e.stopPropagation()
|
|
562
|
+
})
|
|
563
|
+
}),
|
|
564
|
+
/* @__PURE__ */ x("div", {
|
|
565
|
+
className: "flexi-filter-list",
|
|
566
|
+
children: s.length === 0 ? /* @__PURE__ */ x("div", {
|
|
567
|
+
className: "flexi-filter-empty",
|
|
568
|
+
children: "No results found"
|
|
569
|
+
}) : s.map((t, r) => /* @__PURE__ */ S("label", {
|
|
570
|
+
className: "flexi-filter-option",
|
|
571
|
+
children: [/* @__PURE__ */ x("input", {
|
|
572
|
+
type: "checkbox",
|
|
573
|
+
className: "flexi-checkbox",
|
|
574
|
+
checked: a?.includes(t) || !1,
|
|
575
|
+
onChange: () => n.handleFilterChange(e, t)
|
|
576
|
+
}), /* @__PURE__ */ x("span", {
|
|
577
|
+
className: "flexi-filter-option-text",
|
|
578
|
+
children: String(t)
|
|
579
|
+
})]
|
|
580
|
+
}, r))
|
|
581
|
+
}),
|
|
582
|
+
o && /* @__PURE__ */ x("div", {
|
|
583
|
+
className: "flexi-filter-footer",
|
|
584
|
+
children: /* @__PURE__ */ x("button", {
|
|
585
|
+
type: "button",
|
|
586
|
+
onClick: () => n.clearFilter(e),
|
|
587
|
+
className: "flexi-filter-clear",
|
|
588
|
+
children: "Clear Filter"
|
|
589
|
+
})
|
|
590
|
+
})
|
|
591
|
+
]
|
|
592
|
+
}), r);
|
|
593
|
+
}
|
|
594
|
+
//#endregion
|
|
595
|
+
//#region src/DataTable/components/HeaderCell.tsx
|
|
596
|
+
function _e({ col: r, rowSpan: i, colSpan: a }) {
|
|
597
|
+
let { groupBy: o, pinnedColumns: s, pinOffsets: d, displayPinnedIcon: f, togglePin: p, sortState: m, handleSort: h, filters: g, handleDragStart: _, handleDragEnd: v, handleDrop: y, startResize: b } = T(), C = s[r.key], w = !!C, ee = (g.selectedFilters[r.key]?.length || 0) > 0, D = !r.children || r.children.length === 0, O = m.key === r.key, te = o && D, k = D && r.resizable !== !1, A = !!r.sortable && D;
|
|
598
|
+
return /* @__PURE__ */ S("th", {
|
|
599
|
+
rowSpan: i,
|
|
600
|
+
colSpan: a,
|
|
601
|
+
draggable: !0,
|
|
602
|
+
onDragStart: (e) => _(e, r.key, D),
|
|
603
|
+
onDragEnd: v,
|
|
604
|
+
onDragOver: (e) => e.preventDefault(),
|
|
605
|
+
onDrop: (e) => y(e, r.key),
|
|
606
|
+
className: E("flexi-th", "flexi-th--draggable", te && "flexi-th--group-draggable", w && "flexi-th--pinned", r.className, r.headerClassName),
|
|
607
|
+
style: I(d, r.key, !0, r.headerStyle),
|
|
608
|
+
children: [/* @__PURE__ */ S("div", {
|
|
609
|
+
className: "flexi-th-inner",
|
|
864
610
|
children: [
|
|
865
|
-
|
|
866
|
-
className: "flexi-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
}
|
|
611
|
+
/* @__PURE__ */ S("div", {
|
|
612
|
+
className: E("flexi-th-label", A && "flexi-th-label--sortable"),
|
|
613
|
+
onClick: () => A && h(r.key),
|
|
614
|
+
children: [/* @__PURE__ */ x("span", {
|
|
615
|
+
className: "flexi-th-text",
|
|
616
|
+
children: r.header
|
|
617
|
+
}), A && /* @__PURE__ */ x("span", {
|
|
618
|
+
className: E("flexi-sort-icon", O && "flexi-sort-icon--active"),
|
|
619
|
+
children: O && m.direction === "asc" ? /* @__PURE__ */ x(t, { className: "flexi-icon-sm" }) : O && m.direction === "desc" ? /* @__PURE__ */ x(e, { className: "flexi-icon-sm" }) : /* @__PURE__ */ x(n, { className: "flexi-icon-sm" })
|
|
620
|
+
})]
|
|
872
621
|
}),
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
622
|
+
/* @__PURE__ */ S("div", {
|
|
623
|
+
className: "flexi-th-actions",
|
|
624
|
+
children: [D && r.filterable && /* @__PURE__ */ x("button", {
|
|
625
|
+
type: "button",
|
|
626
|
+
ref: (e) => g.registerFilterButton(r.key, e),
|
|
627
|
+
onClick: (e) => {
|
|
628
|
+
e.stopPropagation(), g.toggleFilterDropdown(r.key);
|
|
629
|
+
},
|
|
630
|
+
className: E("flexi-icon-btn", "flexi-filter-btn", ee && "flexi-filter-btn--active"),
|
|
631
|
+
children: /* @__PURE__ */ x(c, { className: "flexi-icon-sm" })
|
|
632
|
+
}), D && f && /* @__PURE__ */ x("button", {
|
|
633
|
+
type: "button",
|
|
634
|
+
onClick: (e) => {
|
|
635
|
+
e.stopPropagation(), p(r.key);
|
|
636
|
+
},
|
|
637
|
+
className: E("flexi-icon-btn", "flexi-pin-btn", w && "flexi-pin-btn--pinned"),
|
|
638
|
+
title: C === "left" ? "Pinned left (click to pin right)" : C === "right" ? "Pinned right (click to unpin)" : "Pin column left",
|
|
639
|
+
children: x(w ? u : l, { className: "flexi-icon-sm" })
|
|
640
|
+
})]
|
|
886
641
|
}),
|
|
887
|
-
|
|
888
|
-
className: "flexi-actions-cell",
|
|
889
|
-
style: {
|
|
890
|
-
position: "sticky",
|
|
891
|
-
right: 0
|
|
892
|
-
},
|
|
893
|
-
children: /* @__PURE__ */ f("div", {
|
|
894
|
-
className: "flexi-actions-inner",
|
|
895
|
-
children: v(e)
|
|
896
|
-
})
|
|
897
|
-
})
|
|
642
|
+
D && g.activeFilterKey === r.key && /* @__PURE__ */ x(ge, { columnKey: r.key })
|
|
898
643
|
]
|
|
899
|
-
},
|
|
644
|
+
}), k && /* @__PURE__ */ x("div", {
|
|
645
|
+
className: "flexi-th-resizer",
|
|
646
|
+
onMouseDown: (e) => b(e, r),
|
|
647
|
+
onClick: (e) => e.stopPropagation(),
|
|
648
|
+
onDragStart: (e) => e.preventDefault()
|
|
649
|
+
})]
|
|
650
|
+
});
|
|
651
|
+
}
|
|
652
|
+
//#endregion
|
|
653
|
+
//#region src/DataTable/components/TableHeader.tsx
|
|
654
|
+
function ve() {
|
|
655
|
+
let { headerRows: e, hasGroups: t } = T();
|
|
656
|
+
return /* @__PURE__ */ x("thead", {
|
|
657
|
+
className: "flexi-thead",
|
|
658
|
+
children: e.map((n, r) => /* @__PURE__ */ S("tr", {
|
|
659
|
+
className: "flexi-header-row",
|
|
660
|
+
children: [r === 0 && t && /* @__PURE__ */ x("th", {
|
|
661
|
+
rowSpan: e.length,
|
|
662
|
+
className: "flexi-group-spacer-th",
|
|
663
|
+
style: {
|
|
664
|
+
position: "sticky",
|
|
665
|
+
top: 0,
|
|
666
|
+
left: 0,
|
|
667
|
+
zIndex: 35,
|
|
668
|
+
backgroundColor: "rgb(248, 250, 252)"
|
|
669
|
+
}
|
|
670
|
+
}), n.map(({ col: e, rowSpan: t, colSpan: n }) => /* @__PURE__ */ x(_e, {
|
|
671
|
+
col: e,
|
|
672
|
+
rowSpan: t,
|
|
673
|
+
colSpan: n
|
|
674
|
+
}, e.key))]
|
|
675
|
+
}, `header-row-${r}`))
|
|
676
|
+
});
|
|
677
|
+
}
|
|
678
|
+
//#endregion
|
|
679
|
+
//#region src/DataTable/utils/grouping.ts
|
|
680
|
+
var ye = (e, t, n, r = 0, i = "") => {
|
|
681
|
+
if (r >= t.length) return e.map((e) => ({
|
|
682
|
+
kind: "record",
|
|
683
|
+
record: e
|
|
684
|
+
}));
|
|
685
|
+
let a = t[r], o = n.get(a), s = /* @__PURE__ */ new Map();
|
|
686
|
+
return e.forEach((e) => {
|
|
687
|
+
let t = String(z(e, a, o) ?? "N/A"), n = s.get(t);
|
|
688
|
+
n ? n.push(e) : s.set(t, [e]);
|
|
689
|
+
}), Array.from(s.entries()).sort(([e], [t]) => e.localeCompare(t, void 0, {
|
|
690
|
+
numeric: !0,
|
|
691
|
+
sensitivity: "base"
|
|
692
|
+
})).map(([e, o]) => {
|
|
693
|
+
let s = i ? `${i}➔${e}` : e;
|
|
694
|
+
return {
|
|
695
|
+
kind: "group",
|
|
696
|
+
groupKey: a,
|
|
697
|
+
groupValue: e,
|
|
698
|
+
path: s,
|
|
699
|
+
depth: r,
|
|
700
|
+
children: ye(o, t, n, r + 1, s),
|
|
701
|
+
totalItemsCount: o.length
|
|
702
|
+
};
|
|
703
|
+
});
|
|
704
|
+
}, be = (e, t) => {
|
|
705
|
+
let n = [], r = (e) => {
|
|
706
|
+
e.forEach((e) => {
|
|
707
|
+
n.push(e), e.kind === "group" && t[e.path] !== !1 && r(e.children);
|
|
708
|
+
});
|
|
709
|
+
};
|
|
710
|
+
return r(e), n;
|
|
711
|
+
}, xe = (e, t, n, r) => {
|
|
712
|
+
let i = /* @__PURE__ */ new Map();
|
|
713
|
+
if (!t || t.length === 0) return i;
|
|
714
|
+
let a = e.map(() => t.map(() => !0)), o = null;
|
|
715
|
+
for (let r = 0; r < e.length; r++) {
|
|
716
|
+
let i = e[r];
|
|
717
|
+
if (i.kind === "group") {
|
|
718
|
+
o = null;
|
|
719
|
+
continue;
|
|
720
|
+
}
|
|
721
|
+
let s = o === null ? null : e[o];
|
|
722
|
+
if (s && s.kind === "record") {
|
|
723
|
+
let e = !0;
|
|
724
|
+
for (let o = 0; o < t.length; o++) {
|
|
725
|
+
let c = t[o], l = n.get(c);
|
|
726
|
+
e && z(i.record, c, l) === z(s.record, c, l) ? a[r][o] = !1 : (e = !1, a[r][o] = !0);
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
o = r;
|
|
900
730
|
}
|
|
901
|
-
|
|
902
|
-
let
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
731
|
+
return t.forEach((t, n) => {
|
|
732
|
+
let o = 0;
|
|
733
|
+
for (; o < e.length;) {
|
|
734
|
+
if (e[o].kind === "group" || !a[o][n]) {
|
|
735
|
+
o++;
|
|
736
|
+
continue;
|
|
737
|
+
}
|
|
738
|
+
let s = o + 1;
|
|
739
|
+
for (; s < e.length && e[s].kind !== "group" && !a[s][n];) s++;
|
|
740
|
+
if (s - o > 1) {
|
|
741
|
+
let e = i.get(r + o) || {};
|
|
742
|
+
e[t] = s - o, i.set(r + o, e);
|
|
743
|
+
for (let e = o + 1; e < s; e++) {
|
|
744
|
+
let n = i.get(r + e) || {};
|
|
745
|
+
n[t] = "skip", i.set(r + e, n);
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
o = s;
|
|
749
|
+
}
|
|
750
|
+
}), i;
|
|
751
|
+
};
|
|
752
|
+
//#endregion
|
|
753
|
+
//#region src/DataTable/hooks/useAnchoredPosition.ts
|
|
754
|
+
function W({ active: e, resetKey: t, rootRef: n, getAnchor: r, compute: i }) {
|
|
755
|
+
let [a, o] = b(null), s = y(r), c = y(i);
|
|
756
|
+
return s.current = r, c.current = i, _(() => {
|
|
757
|
+
if (!e) {
|
|
758
|
+
o(null);
|
|
759
|
+
return;
|
|
760
|
+
}
|
|
761
|
+
let t = () => {
|
|
762
|
+
let e = s.current(), t = n.current;
|
|
763
|
+
!e || !t || o(c.current(e.getBoundingClientRect(), t.getBoundingClientRect()));
|
|
764
|
+
};
|
|
765
|
+
return t(), window.addEventListener("scroll", t, !0), window.addEventListener("resize", t), () => {
|
|
766
|
+
window.removeEventListener("scroll", t, !0), window.removeEventListener("resize", t);
|
|
907
767
|
};
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
768
|
+
}, [
|
|
769
|
+
e,
|
|
770
|
+
t,
|
|
771
|
+
n
|
|
772
|
+
]), a;
|
|
773
|
+
}
|
|
774
|
+
//#endregion
|
|
775
|
+
//#region src/DataTable/hooks/useClickOutside.ts
|
|
776
|
+
function G(e, t, n) {
|
|
777
|
+
let r = y(t), i = y(n);
|
|
778
|
+
r.current = t, i.current = n, _(() => {
|
|
779
|
+
if (!e) return;
|
|
780
|
+
let t = (e) => {
|
|
781
|
+
let t = e.target, [n, ...a] = r.current();
|
|
782
|
+
n && (n.contains(t) || a.some((e) => e?.contains(t)) || i.current());
|
|
783
|
+
};
|
|
784
|
+
return document.addEventListener("mousedown", t), () => document.removeEventListener("mousedown", t);
|
|
785
|
+
}, [e]);
|
|
786
|
+
}
|
|
787
|
+
//#endregion
|
|
788
|
+
//#region src/DataTable/hooks/useColumnFilters.ts
|
|
789
|
+
function Se({ data: e, columnsByKey: t, gridRootRef: n }) {
|
|
790
|
+
let [r, i] = b(null), [a, o] = b({}), [s, c] = b(""), l = y(/* @__PURE__ */ new Map()), u = y(null), d = h((e, t) => {
|
|
791
|
+
t ? l.current.set(e, t) : l.current.delete(e);
|
|
792
|
+
}, []), f = h(() => {
|
|
793
|
+
i(null), c("");
|
|
794
|
+
}, []), p = h((e) => {
|
|
795
|
+
c(""), i((t) => t === e ? null : e);
|
|
796
|
+
}, []);
|
|
797
|
+
G(r !== null, () => [u.current, r ? l.current.get(r) : null], f);
|
|
798
|
+
let m = W({
|
|
799
|
+
active: r !== null,
|
|
800
|
+
resetKey: r,
|
|
801
|
+
rootRef: n,
|
|
802
|
+
getAnchor: () => r ? l.current.get(r) : null,
|
|
803
|
+
compute: (e, t) => ({
|
|
804
|
+
top: e.bottom - t.top + 4,
|
|
805
|
+
left: e.left - t.left
|
|
806
|
+
})
|
|
807
|
+
}), g = h((e, t) => {
|
|
808
|
+
o((n) => {
|
|
809
|
+
let r = n[e] || [], i = r.includes(t) ? r.filter((e) => e !== t) : [...r, t], a = {
|
|
810
|
+
...n,
|
|
811
|
+
[e]: i
|
|
812
|
+
};
|
|
813
|
+
return i.length === 0 && delete a[e], a;
|
|
814
|
+
});
|
|
815
|
+
}, []), _ = h((e) => {
|
|
816
|
+
o((t) => {
|
|
817
|
+
let n = { ...t };
|
|
818
|
+
return delete n[e], n;
|
|
819
|
+
});
|
|
820
|
+
}, []), x = v(() => r ? de(e, r, t.get(r)) : [], [
|
|
821
|
+
e,
|
|
822
|
+
r,
|
|
823
|
+
t
|
|
824
|
+
]);
|
|
825
|
+
return {
|
|
826
|
+
activeFilterKey: r,
|
|
827
|
+
selectedFilters: a,
|
|
828
|
+
filterSearchQuery: s,
|
|
829
|
+
setFilterSearchQuery: c,
|
|
830
|
+
filterPosition: m,
|
|
831
|
+
dropdownRef: u,
|
|
832
|
+
filteredUniqueValues: v(() => {
|
|
833
|
+
if (!s.trim()) return x;
|
|
834
|
+
let e = s.toLowerCase();
|
|
835
|
+
return x.filter((t) => String(t).toLowerCase().includes(e));
|
|
836
|
+
}, [x, s]),
|
|
837
|
+
registerFilterButton: d,
|
|
838
|
+
toggleFilterDropdown: p,
|
|
839
|
+
handleFilterChange: g,
|
|
840
|
+
clearFilter: _
|
|
841
|
+
};
|
|
842
|
+
}
|
|
843
|
+
//#endregion
|
|
844
|
+
//#region src/DataTable/hooks/useColumnReorder.ts
|
|
845
|
+
function Ce({ columns: e, pinnedColumns: t, isResizingRef: n, onColumnReorder: r }) {
|
|
846
|
+
let [i, a] = b({}), o = y(null), s = v(() => N(e, t, i), [
|
|
847
|
+
e,
|
|
848
|
+
t,
|
|
849
|
+
i
|
|
850
|
+
]);
|
|
851
|
+
return {
|
|
852
|
+
reorderedColumns: s,
|
|
853
|
+
handleDragStart: h((e, t, r) => {
|
|
854
|
+
if (n.current) {
|
|
855
|
+
e.preventDefault();
|
|
856
|
+
return;
|
|
857
|
+
}
|
|
858
|
+
o.current = t, r && e.dataTransfer.setData("text/plain", t), e.dataTransfer.effectAllowed = "move";
|
|
859
|
+
}, [n]),
|
|
860
|
+
handleDragEnd: h(() => {
|
|
861
|
+
o.current = null;
|
|
862
|
+
}, []),
|
|
863
|
+
handleDrop: h((n, c) => {
|
|
864
|
+
n.preventDefault(), n.stopPropagation();
|
|
865
|
+
let l = o.current;
|
|
866
|
+
if (o.current = null, !l || l === c) return;
|
|
867
|
+
let u = P(s, l, c);
|
|
868
|
+
if (!u) return;
|
|
869
|
+
let d = u.map((e) => e.key), f = d.indexOf(l), p = d.indexOf(c);
|
|
870
|
+
d.splice(p, 0, d.splice(f, 1)[0]);
|
|
871
|
+
let m = { ...i };
|
|
872
|
+
d.forEach((e, t) => {
|
|
873
|
+
m[e] = t;
|
|
874
|
+
}), a(m), r && r(j(N(e, t, m)).map((e) => e.key));
|
|
875
|
+
}, [
|
|
876
|
+
s,
|
|
877
|
+
i,
|
|
878
|
+
e,
|
|
879
|
+
t,
|
|
880
|
+
r
|
|
881
|
+
])
|
|
882
|
+
};
|
|
883
|
+
}
|
|
884
|
+
//#endregion
|
|
885
|
+
//#region src/DataTable/hooks/useColumnResize.ts
|
|
886
|
+
function we(e) {
|
|
887
|
+
let [t, n] = b({}), r = y(!1), i = y(null), a = y(e);
|
|
888
|
+
return a.current = e, _(() => () => i.current?.(), []), {
|
|
889
|
+
columnWidths: t,
|
|
890
|
+
isResizingRef: r,
|
|
891
|
+
startResize: h((e, o) => {
|
|
892
|
+
e.preventDefault(), e.stopPropagation(), i.current?.(), r.current = !0;
|
|
893
|
+
let s = e.clientX, c = F(o, t), l = o.minWidth ?? 60, u = o.maxWidth, d = t[o.key], f = (e) => {
|
|
894
|
+
let t = Math.max(l, c + (e.clientX - s));
|
|
895
|
+
u && (t = Math.min(u, t)), d = t, n((e) => e[o.key] === t ? e : {
|
|
896
|
+
...e,
|
|
897
|
+
[o.key]: t
|
|
898
|
+
});
|
|
899
|
+
}, p = () => {
|
|
900
|
+
window.removeEventListener("mousemove", f), window.removeEventListener("mouseup", m), i.current = null;
|
|
901
|
+
}, m = () => {
|
|
902
|
+
p(), requestAnimationFrame(() => {
|
|
903
|
+
r.current = !1;
|
|
904
|
+
}), d !== void 0 && a.current?.(o.key, d);
|
|
905
|
+
};
|
|
906
|
+
window.addEventListener("mousemove", f), window.addEventListener("mouseup", m), i.current = () => {
|
|
907
|
+
p(), r.current = !1;
|
|
908
|
+
};
|
|
909
|
+
}, [t])
|
|
910
|
+
};
|
|
911
|
+
}
|
|
912
|
+
//#endregion
|
|
913
|
+
//#region src/DataTable/hooks/useColumnVisibility.ts
|
|
914
|
+
function Te({ defaultHiddenColumns: e, defaultDisplayPinnedIcon: t, onColumnVisibilityChange: n }) {
|
|
915
|
+
let [r, i] = b(e), [a, o] = b(t);
|
|
916
|
+
return {
|
|
917
|
+
hiddenColumns: r,
|
|
918
|
+
displayPinnedIcon: a,
|
|
919
|
+
toggleColumnVisibility: h((e) => {
|
|
920
|
+
let t = r.includes(e) ? r.filter((t) => t !== e) : [...r, e];
|
|
921
|
+
i(t), n?.(t);
|
|
922
|
+
}, [r, n]),
|
|
923
|
+
toggleDisplayPinnedIcon: h(() => o((e) => !e), []),
|
|
924
|
+
resetControlPanelDefaults: h(() => {
|
|
925
|
+
o(t), i(e), n?.(e);
|
|
926
|
+
}, [
|
|
927
|
+
t,
|
|
928
|
+
e,
|
|
929
|
+
n
|
|
930
|
+
])
|
|
931
|
+
};
|
|
932
|
+
}
|
|
933
|
+
//#endregion
|
|
934
|
+
//#region src/DataTable/hooks/usePagination.ts
|
|
935
|
+
function Ee({ items: e, enabled: t, defaultPageSize: n, onPageChange: r, resetOn: i }) {
|
|
936
|
+
let [a, o] = b(1), [s, c] = b(Math.max(1, Math.floor(n) || 1)), l = e.length, u = t ? Math.max(1, Math.ceil(l / s)) : 1;
|
|
937
|
+
return _(() => {
|
|
938
|
+
o(1);
|
|
939
|
+
}, [
|
|
940
|
+
...i,
|
|
941
|
+
s,
|
|
942
|
+
t
|
|
943
|
+
]), _(() => {
|
|
944
|
+
a > u && o(u);
|
|
945
|
+
}, [a, u]), {
|
|
946
|
+
currentPage: a,
|
|
947
|
+
pageSize: s,
|
|
948
|
+
totalPages: u,
|
|
949
|
+
totalCount: l,
|
|
950
|
+
pagedItems: v(() => {
|
|
951
|
+
if (!t) return e;
|
|
952
|
+
let n = (a - 1) * s;
|
|
953
|
+
return e.slice(n, n + s);
|
|
954
|
+
}, [
|
|
955
|
+
e,
|
|
956
|
+
t,
|
|
957
|
+
a,
|
|
958
|
+
s
|
|
959
|
+
]),
|
|
960
|
+
goToPage: h((e) => {
|
|
961
|
+
let t = Math.min(Math.max(1, e), u);
|
|
962
|
+
o(t), r?.(t, s);
|
|
963
|
+
}, [
|
|
964
|
+
u,
|
|
965
|
+
s,
|
|
966
|
+
r
|
|
967
|
+
]),
|
|
968
|
+
changePageSize: h((e) => {
|
|
969
|
+
c(e), o(1), r?.(1, e);
|
|
970
|
+
}, [r])
|
|
971
|
+
};
|
|
972
|
+
}
|
|
973
|
+
//#endregion
|
|
974
|
+
//#region src/DataTable/hooks/usePinnedColumns.ts
|
|
975
|
+
function De(e, t) {
|
|
976
|
+
let [n, r] = b(() => M(e));
|
|
977
|
+
return {
|
|
978
|
+
pinnedColumns: n,
|
|
979
|
+
togglePin: h((e) => {
|
|
980
|
+
let i = n[e], a = i ? i === "left" ? "right" : void 0 : "left", o = { ...n };
|
|
981
|
+
a ? o[e] = a : delete o[e], r(o), t?.(e, !!a, a);
|
|
982
|
+
}, [n, t])
|
|
983
|
+
};
|
|
984
|
+
}
|
|
985
|
+
//#endregion
|
|
986
|
+
//#region src/DataTable/hooks/useRowGrouping.ts
|
|
987
|
+
function Oe(e, t) {
|
|
988
|
+
let [n, r] = b(e), [i, a] = b({});
|
|
989
|
+
return {
|
|
990
|
+
groupedColumns: n,
|
|
991
|
+
expandedGroups: i,
|
|
992
|
+
addGroup: h((e) => {
|
|
993
|
+
if (!e || n.includes(e)) return;
|
|
994
|
+
let i = [...n, e];
|
|
995
|
+
r(i), t?.(i);
|
|
996
|
+
}, [n, t]),
|
|
997
|
+
removeGroup: h((e) => {
|
|
998
|
+
let i = n.filter((t) => t !== e);
|
|
999
|
+
r(i), a({}), t?.(i);
|
|
1000
|
+
}, [n, t]),
|
|
1001
|
+
toggleGroupExpansion: h((e) => {
|
|
1002
|
+
a((t) => ({
|
|
1003
|
+
...t,
|
|
1004
|
+
[e]: t[e] === !1
|
|
1005
|
+
}));
|
|
1006
|
+
}, [])
|
|
1007
|
+
};
|
|
1008
|
+
}
|
|
1009
|
+
//#endregion
|
|
1010
|
+
//#region src/DataTable/hooks/useSettingsMenu.ts
|
|
1011
|
+
function ke(e) {
|
|
1012
|
+
let [t, n] = b(!1), r = y(null), i = y(null), a = h(() => n((e) => !e), []);
|
|
1013
|
+
return G(t, () => [r.current, i.current], h(() => n(!1), [])), {
|
|
1014
|
+
isOpen: t,
|
|
1015
|
+
position: W({
|
|
1016
|
+
active: t,
|
|
1017
|
+
rootRef: e,
|
|
1018
|
+
getAnchor: () => i.current,
|
|
1019
|
+
compute: (e, t) => ({
|
|
1020
|
+
top: e.bottom - t.top + 4,
|
|
1021
|
+
right: t.right - e.right
|
|
1022
|
+
})
|
|
1023
|
+
}),
|
|
1024
|
+
menuRef: r,
|
|
1025
|
+
buttonRef: i,
|
|
1026
|
+
toggle: a
|
|
1027
|
+
};
|
|
1028
|
+
}
|
|
1029
|
+
//#endregion
|
|
1030
|
+
//#region src/DataTable/hooks/useSorting.ts
|
|
1031
|
+
function Ae() {
|
|
1032
|
+
let [e, t] = b({
|
|
1033
|
+
key: null,
|
|
1034
|
+
direction: null
|
|
1035
|
+
});
|
|
1036
|
+
return {
|
|
1037
|
+
sortState: e,
|
|
1038
|
+
handleSort: h((e) => {
|
|
1039
|
+
t((t) => {
|
|
1040
|
+
let n = "asc";
|
|
1041
|
+
return t.key === e && (t.direction === "asc" ? n = "desc" : t.direction === "desc" && (n = null)), {
|
|
1042
|
+
key: n ? e : null,
|
|
1043
|
+
direction: n
|
|
1044
|
+
};
|
|
1045
|
+
});
|
|
1046
|
+
}, [])
|
|
1047
|
+
};
|
|
1048
|
+
}
|
|
1049
|
+
//#endregion
|
|
1050
|
+
//#region src/DataTable/hooks/useVirtualRows.ts
|
|
1051
|
+
function je({ containerRef: e, totalRowCount: t, rowHeight: n, overscan: r }) {
|
|
1052
|
+
let [i, a] = b(0), [o, s] = b(0);
|
|
1053
|
+
return _(() => {
|
|
1054
|
+
let t = e.current;
|
|
1055
|
+
if (!t) return;
|
|
1056
|
+
let n = () => a(t.scrollTop);
|
|
1057
|
+
s(t.clientHeight), a(t.scrollTop), t.addEventListener("scroll", n, { passive: !0 });
|
|
1058
|
+
let r;
|
|
1059
|
+
return typeof ResizeObserver < "u" && (r = new ResizeObserver(() => s(t.clientHeight)), r.observe(t)), () => {
|
|
1060
|
+
t.removeEventListener("scroll", n), r?.disconnect();
|
|
1061
|
+
};
|
|
1062
|
+
}, [e]), v(() => {
|
|
1063
|
+
if (o === 0) return {
|
|
1064
|
+
startIndex: 0,
|
|
1065
|
+
endIndex: t,
|
|
1066
|
+
topSpacerHeight: 0,
|
|
1067
|
+
bottomSpacerHeight: 0
|
|
1068
|
+
};
|
|
1069
|
+
let e = n > 0 ? n : 1, a = Math.max(0, t - 1), s = Math.min(a, Math.floor(i / e)), c = Math.ceil(o / e) + 1, l = Math.max(0, s - r), u = Math.min(t, s + c + r);
|
|
1070
|
+
return {
|
|
1071
|
+
startIndex: l,
|
|
1072
|
+
endIndex: u,
|
|
1073
|
+
topSpacerHeight: l * e,
|
|
1074
|
+
bottomSpacerHeight: (t - u) * e
|
|
1075
|
+
};
|
|
1076
|
+
}, [
|
|
1077
|
+
i,
|
|
1078
|
+
o,
|
|
1079
|
+
t,
|
|
1080
|
+
n,
|
|
1081
|
+
r
|
|
1082
|
+
]);
|
|
1083
|
+
}
|
|
1084
|
+
//#endregion
|
|
1085
|
+
//#region src/DataTable/hooks/useDataTableState.ts
|
|
1086
|
+
function K({ columns: e, data: t, rowKey: n, actions: r, isLoading: i, groupBy: a = !1, defaultGroupBy: o = k, onPinChange: s, onGroupChange: c, pinnedBottomRowData: l = A, pinnedRowClassName: u, rowHeight: d = 40, overscan: f = 8, onColumnResize: p, onColumnReorder: m, rowClassRules: g, onRowClick: x, rowSpanColumns: S, controlPanel: C = !1, defaultDisplayPinnedIcon: w = !0, defaultHiddenColumns: ee = k, onColumnVisibilityChange: T, pagination: E = !1, defaultPageSize: D = 10, pageSizeOptions: O = te, onPageChange: ne }) {
|
|
1087
|
+
let M = y(null), N = y(null), P = v(() => j(e), [e]), F = v(() => {
|
|
1088
|
+
let e = /* @__PURE__ */ new Map();
|
|
1089
|
+
return P.forEach((t) => e.set(t.key, t)), e;
|
|
1090
|
+
}, [P]), { pinnedColumns: I, togglePin: ae } = De(P, s), { columnWidths: L, isResizingRef: oe, startResize: se } = we(p), { reorderedColumns: R, handleDragStart: ce, handleDragEnd: le, handleDrop: ue } = Ce({
|
|
1091
|
+
columns: e,
|
|
1092
|
+
pinnedColumns: I,
|
|
1093
|
+
isResizingRef: oe,
|
|
1094
|
+
onColumnReorder: m
|
|
1095
|
+
}), z = Te({
|
|
1096
|
+
defaultHiddenColumns: ee,
|
|
1097
|
+
defaultDisplayPinnedIcon: w,
|
|
1098
|
+
onColumnVisibilityChange: T
|
|
1099
|
+
}), { hiddenColumns: B } = z, V = Oe(o, c), { groupedColumns: de, expandedGroups: H } = V, [pe, U] = b(a);
|
|
1100
|
+
_(() => U(a), [a]);
|
|
1101
|
+
let he = h(() => U((e) => !e), []), { resetControlPanelDefaults: ge } = z, _e = h(() => {
|
|
1102
|
+
ge(), U(a);
|
|
1103
|
+
}, [ge, a]), ve = pe, W = ve ? de : k, G = W.length > 0, K = !!r, q = v(() => j(R).filter((e) => !W.includes(e.key) && !B.includes(e.key)), [
|
|
1104
|
+
R,
|
|
1105
|
+
W,
|
|
1106
|
+
B
|
|
1107
|
+
]), Me = v(() => re(R, W, B), [
|
|
1108
|
+
R,
|
|
1109
|
+
W,
|
|
1110
|
+
B
|
|
1111
|
+
]), Ne = v(() => ie({
|
|
1112
|
+
visibleLeafColumns: q,
|
|
1113
|
+
pinnedColumns: I,
|
|
1114
|
+
columnWidths: L,
|
|
1115
|
+
hasGroups: G,
|
|
1116
|
+
hasActions: K
|
|
1117
|
+
}), [
|
|
1118
|
+
q,
|
|
1119
|
+
I,
|
|
1120
|
+
L,
|
|
1121
|
+
G,
|
|
1122
|
+
K
|
|
1123
|
+
]), J = Se({
|
|
1124
|
+
data: t,
|
|
1125
|
+
columnsByKey: F,
|
|
1126
|
+
gridRootRef: M
|
|
1127
|
+
}), { sortState: Y, handleSort: Pe } = Ae(), X = Ee({
|
|
1128
|
+
items: v(() => {
|
|
1129
|
+
let e = fe(t, J.selectedFilters, F);
|
|
1130
|
+
return !Y.key || !Y.direction ? e : me(e, Y.key, Y.direction, F.get(Y.key));
|
|
1131
|
+
}, [
|
|
1132
|
+
t,
|
|
1133
|
+
J.selectedFilters,
|
|
1134
|
+
Y,
|
|
1135
|
+
F
|
|
1136
|
+
]),
|
|
1137
|
+
enabled: E,
|
|
1138
|
+
defaultPageSize: D,
|
|
1139
|
+
onPageChange: ne,
|
|
1140
|
+
resetOn: [J.selectedFilters, Y]
|
|
1141
|
+
}), Fe = v(() => ye(X.pagedItems, W, F), [
|
|
1142
|
+
X.pagedItems,
|
|
1143
|
+
W,
|
|
1144
|
+
F
|
|
1145
|
+
]), Z = v(() => be(Fe, H), [Fe, H]), Ie = Z.length, { startIndex: Q, endIndex: Le, topSpacerHeight: Re, bottomSpacerHeight: ze } = je({
|
|
1146
|
+
containerRef: N,
|
|
1147
|
+
totalRowCount: Ie,
|
|
1148
|
+
rowHeight: d,
|
|
1149
|
+
overscan: f
|
|
1150
|
+
}), $ = v(() => Z.slice(Q, Le), [
|
|
1151
|
+
Z,
|
|
1152
|
+
Q,
|
|
1153
|
+
Le
|
|
1154
|
+
]), Be = v(() => xe($, S, F, Q), [
|
|
1155
|
+
$,
|
|
1156
|
+
S,
|
|
1157
|
+
F,
|
|
1158
|
+
Q
|
|
1159
|
+
]), Ve = ke(M), He = q.length + +!!K + +!!G;
|
|
1160
|
+
return {
|
|
1161
|
+
gridRootRef: M,
|
|
1162
|
+
tableWrapRef: N,
|
|
1163
|
+
rowKey: n,
|
|
1164
|
+
actions: r,
|
|
1165
|
+
isLoading: !!i,
|
|
1166
|
+
groupBy: ve,
|
|
1167
|
+
showGroupBy: pe,
|
|
1168
|
+
toggleShowGroupBy: he,
|
|
1169
|
+
controlPanel: C,
|
|
1170
|
+
rowHeight: d,
|
|
1171
|
+
rowSpanColumns: S,
|
|
1172
|
+
rowClassRules: g,
|
|
1173
|
+
onRowClick: x,
|
|
1174
|
+
pinnedBottomRowData: l,
|
|
1175
|
+
pinnedRowClassName: u,
|
|
1176
|
+
pageSizeOptions: O,
|
|
1177
|
+
paginationEnabled: E,
|
|
1178
|
+
initialLeafColumns: P,
|
|
1179
|
+
columnsByKey: F,
|
|
1180
|
+
visibleLeafColumns: q,
|
|
1181
|
+
headerRows: Me,
|
|
1182
|
+
pinnedColumns: I,
|
|
1183
|
+
pinOffsets: Ne,
|
|
1184
|
+
columnWidths: L,
|
|
1185
|
+
togglePin: ae,
|
|
1186
|
+
startResize: se,
|
|
1187
|
+
handleDragStart: ce,
|
|
1188
|
+
handleDragEnd: le,
|
|
1189
|
+
handleDrop: ue,
|
|
1190
|
+
hiddenColumns: B,
|
|
1191
|
+
displayPinnedIcon: z.displayPinnedIcon,
|
|
1192
|
+
toggleColumnVisibility: z.toggleColumnVisibility,
|
|
1193
|
+
toggleDisplayPinnedIcon: z.toggleDisplayPinnedIcon,
|
|
1194
|
+
resetControlPanelDefaults: _e,
|
|
1195
|
+
settingsMenu: Ve,
|
|
1196
|
+
groupedColumns: de,
|
|
1197
|
+
expandedGroups: H,
|
|
1198
|
+
addGroup: V.addGroup,
|
|
1199
|
+
removeGroup: V.removeGroup,
|
|
1200
|
+
toggleGroupExpansion: V.toggleGroupExpansion,
|
|
1201
|
+
hasGroups: G,
|
|
1202
|
+
hasActions: K,
|
|
1203
|
+
sortState: Y,
|
|
1204
|
+
handleSort: Pe,
|
|
1205
|
+
filters: J,
|
|
1206
|
+
currentPage: X.currentPage,
|
|
1207
|
+
pageSize: X.pageSize,
|
|
1208
|
+
totalPages: X.totalPages,
|
|
1209
|
+
totalCount: X.totalCount,
|
|
1210
|
+
goToPage: X.goToPage,
|
|
1211
|
+
changePageSize: X.changePageSize,
|
|
1212
|
+
visibleRows: $,
|
|
1213
|
+
startIndex: Q,
|
|
1214
|
+
totalRowCount: Ie,
|
|
1215
|
+
topSpacerHeight: Re,
|
|
1216
|
+
bottomSpacerHeight: ze,
|
|
1217
|
+
rowSpanInfo: Be,
|
|
1218
|
+
totalColumnsCount: He
|
|
1219
|
+
};
|
|
1220
|
+
}
|
|
1221
|
+
//#endregion
|
|
1222
|
+
//#region src/DataTable/DataTable.tsx
|
|
1223
|
+
function q(e) {
|
|
1224
|
+
let t = K(e), { containerStyle: n, tableStyle: r, bordered: i = !1 } = e;
|
|
1225
|
+
return /* @__PURE__ */ x(ee, {
|
|
1226
|
+
value: t,
|
|
1227
|
+
children: /* @__PURE__ */ S("div", {
|
|
1228
|
+
ref: t.gridRootRef,
|
|
1229
|
+
className: "flexi-root",
|
|
911
1230
|
children: [
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
return /* @__PURE__ */ f("td", {
|
|
923
|
-
className: h("flexi-cell", i && "flexi-cell--pinned", t.className),
|
|
924
|
-
style: r,
|
|
925
|
-
children: a ? a(n, e) : /* @__PURE__ */ f("span", {
|
|
926
|
-
className: "flexi-cell-text",
|
|
927
|
-
children: n
|
|
1231
|
+
t.groupBy && /* @__PURE__ */ x(D, {}),
|
|
1232
|
+
/* @__PURE__ */ S("div", {
|
|
1233
|
+
ref: t.tableWrapRef,
|
|
1234
|
+
className: "flexi-table-wrap",
|
|
1235
|
+
style: n,
|
|
1236
|
+
children: [t.controlPanel && /* @__PURE__ */ x("div", {
|
|
1237
|
+
className: "flexi-settings-corner",
|
|
1238
|
+
children: /* @__PURE__ */ x("div", {
|
|
1239
|
+
className: "flexi-settings-corner-inner",
|
|
1240
|
+
children: /* @__PURE__ */ x(le, {})
|
|
928
1241
|
})
|
|
929
|
-
},
|
|
1242
|
+
}), /* @__PURE__ */ S("table", {
|
|
1243
|
+
className: E("flexi-table", i && "flexi-table--bordered"),
|
|
1244
|
+
style: r,
|
|
1245
|
+
children: [
|
|
1246
|
+
/* @__PURE__ */ x(he, {}),
|
|
1247
|
+
/* @__PURE__ */ x(ve, {}),
|
|
1248
|
+
/* @__PURE__ */ x(U, {}),
|
|
1249
|
+
/* @__PURE__ */ x(ce, {})
|
|
1250
|
+
]
|
|
1251
|
+
})]
|
|
930
1252
|
}),
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
style: {
|
|
934
|
-
position: "sticky",
|
|
935
|
-
right: 0
|
|
936
|
-
},
|
|
937
|
-
children: /* @__PURE__ */ f("div", {
|
|
938
|
-
className: "flexi-actions-inner",
|
|
939
|
-
children: v(e)
|
|
940
|
-
})
|
|
941
|
-
})
|
|
1253
|
+
/* @__PURE__ */ x(ue, {}),
|
|
1254
|
+
t.paginationEnabled && /* @__PURE__ */ x(O, {})
|
|
942
1255
|
]
|
|
943
|
-
}
|
|
944
|
-
}
|
|
1256
|
+
})
|
|
1257
|
+
});
|
|
945
1258
|
}
|
|
946
1259
|
//#endregion
|
|
947
|
-
export {
|
|
1260
|
+
export { q as DataTable };
|