@chumsinc/sortable-tables 2.1.2 → 2.2.0
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/CHANGELOG.md +23 -1
- package/dist/DataTable.d.ts +1 -1
- package/dist/DataTableCell.d.ts +172 -172
- package/dist/DataTableCols.d.ts +5 -0
- package/dist/DataTableHead.d.ts +2 -2
- package/dist/DataTableRow.d.ts +1 -1
- package/dist/DataTableTBody.d.ts +1 -1
- package/dist/DataTableWithContext.d.ts +2 -0
- package/dist/RowsPerPage.d.ts +0 -1
- package/dist/SortableTable.d.ts +1 -1
- package/dist/SortableTableHead.d.ts +1 -1
- package/dist/SortableTableWithContext.d.ts +2 -0
- package/dist/TableProvider.d.ts +17 -0
- package/dist/index.cjs.js +18 -12
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +8 -2
- package/dist/index.es.js +351 -268
- package/dist/index.es.js.map +1 -1
- package/dist/types.d.ts +14 -16
- package/eslint.config.mjs +3 -3
- package/package.json +6 -4
- package/src/DataTable.tsx +5 -33
- package/src/DataTableCell.tsx +5 -5
- package/src/DataTableCols.tsx +25 -0
- package/src/DataTableHead.tsx +6 -5
- package/src/DataTableRow.tsx +5 -4
- package/src/DataTableTBody.tsx +0 -2
- package/src/DataTableTH.tsx +8 -7
- package/src/DataTableWithContext.tsx +41 -0
- package/src/RowsPerPage.tsx +4 -5
- package/src/SortableTable.tsx +5 -31
- package/src/SortableTableHead.tsx +12 -11
- package/src/SortableTableTH.tsx +7 -4
- package/src/SortableTableWithContext.tsx +44 -0
- package/src/Table.tsx +2 -2
- package/src/TablePagination.tsx +3 -3
- package/src/TableProvider.tsx +77 -0
- package/src/index.tsx +10 -2
- package/src/types.ts +18 -20
- package/test/TableColumnsHandler.tsx +28 -0
- package/test/TestTable.tsx +15 -37
- package/test/tableFields.tsx +44 -0
- package/vite.config.ts +1 -2
package/dist/index.es.js
CHANGED
|
@@ -1,388 +1,471 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
function
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { jsx as l, jsxs as p } from "react/jsx-runtime";
|
|
2
|
+
import A, { createContext as B, useState as V, useCallback as v, useMemo as W, useContext as g, createElement as G, useId as I } from "react";
|
|
3
|
+
import x from "@emotion/styled";
|
|
4
|
+
const N = B(null);
|
|
5
|
+
function S({ children: t, initialFields: a = [] }) {
|
|
6
|
+
const [e, n] = V(a), s = v((o) => {
|
|
7
|
+
n(o);
|
|
8
|
+
}, []), c = v((o, u) => {
|
|
9
|
+
const b = e.map((d) => d.id === o ? { ...d, ...u } : d);
|
|
10
|
+
n(b);
|
|
11
|
+
}, [e]), i = v((o) => e.find((u) => u.id === o), [e]), r = W(
|
|
12
|
+
() => ({
|
|
13
|
+
fields: e,
|
|
14
|
+
setFields: s,
|
|
15
|
+
updateField: c,
|
|
16
|
+
getField: i
|
|
17
|
+
}),
|
|
18
|
+
[e, s, c, i]
|
|
19
|
+
);
|
|
20
|
+
return /* @__PURE__ */ l(N.Provider, { value: r, children: t });
|
|
21
|
+
}
|
|
22
|
+
function J() {
|
|
23
|
+
const t = g(N);
|
|
24
|
+
if (!t)
|
|
25
|
+
throw new Error("useTableContext must be used within a FieldsProvider");
|
|
26
|
+
return t;
|
|
27
|
+
}
|
|
28
|
+
function y() {
|
|
29
|
+
return J().fields;
|
|
30
|
+
}
|
|
31
|
+
function nt(t) {
|
|
32
|
+
const a = g(N);
|
|
33
|
+
if (!a)
|
|
34
|
+
throw new Error("useTableContext must be used within a FieldsProvider");
|
|
35
|
+
return a.fields.find((n) => n.id === t) ?? null;
|
|
36
|
+
}
|
|
37
|
+
function lt() {
|
|
38
|
+
return g(N) !== null;
|
|
39
|
+
}
|
|
40
|
+
function H(t) {
|
|
41
|
+
var a, e, n = "";
|
|
42
|
+
if (typeof t == "string" || typeof t == "number") n += t;
|
|
43
|
+
else if (typeof t == "object") if (Array.isArray(t)) {
|
|
44
|
+
var s = t.length;
|
|
45
|
+
for (a = 0; a < s; a++) t[a] && (e = H(t[a])) && (n && (n += " "), n += e);
|
|
46
|
+
} else for (e in t) t[e] && (n && (n += " "), n += e);
|
|
47
|
+
return n;
|
|
48
|
+
}
|
|
49
|
+
function m() {
|
|
50
|
+
for (var t, a, e = 0, n = "", s = arguments.length; e < s; e++) (t = arguments[e]) && (a = H(t)) && (n && (n += " "), n += a);
|
|
51
|
+
return n;
|
|
52
|
+
}
|
|
53
|
+
const D = x.table`
|
|
54
|
+
--table-sticky-top: ${(t) => t.sticky ? "0" : void 0};
|
|
55
|
+
|
|
56
|
+
thead {
|
|
57
|
+
tr:nth-of-type(1) td,
|
|
58
|
+
tr:nth-of-type(1) th {
|
|
59
|
+
top: var(--table-sticky-top, unset);
|
|
60
|
+
position: ${(t) => t.sticky ? "sticky" : "unset"};
|
|
61
|
+
z-index: ${(t) => t.sticky ? 10 : "unset"};
|
|
62
|
+
background: ${(t) => t.sticky ? "linear-gradient(var(--bs-table-bg) 75%, rgba(var(--bs-secondary-bg-rgb), 0.9))" : "unset"};
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
`, F = A.forwardRef(
|
|
66
|
+
function({
|
|
67
|
+
sticky: a,
|
|
68
|
+
responsive: e,
|
|
69
|
+
children: n,
|
|
70
|
+
className: s,
|
|
71
|
+
...c
|
|
72
|
+
}, i) {
|
|
73
|
+
if (e) {
|
|
74
|
+
const r = m(s, {
|
|
75
|
+
"table-responsive": e === !0,
|
|
76
|
+
[`table-responsive-${e}`]: e !== !0
|
|
77
|
+
});
|
|
78
|
+
return /* @__PURE__ */ l("div", { className: r, children: /* @__PURE__ */ l(D, { ref: i, ...c, children: n }) });
|
|
79
|
+
}
|
|
80
|
+
return /* @__PURE__ */ l(D, { className: s, sticky: a, ref: i, ...c, children: n });
|
|
81
|
+
}
|
|
82
|
+
);
|
|
83
|
+
function C({
|
|
84
|
+
field: t,
|
|
85
|
+
className: a,
|
|
86
|
+
children: e,
|
|
87
|
+
...n
|
|
10
88
|
}) {
|
|
11
|
-
const s =
|
|
12
|
-
return /* @__PURE__ */
|
|
89
|
+
const s = m({ [`text-${t.align}`]: !!t.align }, a);
|
|
90
|
+
return /* @__PURE__ */ l("th", { className: s, scope: "col", ...n, children: e ?? t.title });
|
|
13
91
|
}
|
|
14
|
-
|
|
15
|
-
function
|
|
16
|
-
|
|
17
|
-
|
|
92
|
+
C.displayName = "DataTableTH";
|
|
93
|
+
function R({ ...t }) {
|
|
94
|
+
const a = y();
|
|
95
|
+
return /* @__PURE__ */ l("thead", { ...t, children: /* @__PURE__ */ l("tr", { children: a.map((e, n) => /* @__PURE__ */ l(
|
|
96
|
+
C,
|
|
18
97
|
{
|
|
19
|
-
...
|
|
20
|
-
field:
|
|
21
|
-
className:
|
|
22
|
-
typeof
|
|
98
|
+
...e.thProps,
|
|
99
|
+
field: e,
|
|
100
|
+
className: m(
|
|
101
|
+
typeof e.className == "function" ? { [`text-${e.align}`]: !!e.align } : e.className
|
|
23
102
|
)
|
|
24
103
|
},
|
|
25
|
-
|
|
104
|
+
e.id ?? n
|
|
26
105
|
)) }) });
|
|
27
106
|
}
|
|
28
|
-
|
|
29
|
-
function
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
107
|
+
R.displayName = "DataTableHead";
|
|
108
|
+
function L({
|
|
109
|
+
className: t,
|
|
110
|
+
size: a,
|
|
111
|
+
responsive: e,
|
|
112
|
+
sticky: n,
|
|
113
|
+
data: s,
|
|
114
|
+
keyField: c,
|
|
115
|
+
rowClassName: i,
|
|
116
|
+
renderRow: r,
|
|
117
|
+
onSelectRow: o,
|
|
118
|
+
selected: u,
|
|
119
|
+
tableHeadProps: b,
|
|
120
|
+
children: d,
|
|
121
|
+
tfoot: f,
|
|
122
|
+
...h
|
|
123
|
+
}) {
|
|
124
|
+
const T = m("table", t, {
|
|
125
|
+
[`table-${a}`]: !!a
|
|
126
|
+
});
|
|
127
|
+
return /* @__PURE__ */ p(F, { sticky: n, responsive: e, className: T, ...h, children: [
|
|
128
|
+
/* @__PURE__ */ l(k, {}),
|
|
129
|
+
/* @__PURE__ */ l(R, { ...b }),
|
|
130
|
+
!!s.length && /* @__PURE__ */ l(
|
|
131
|
+
$,
|
|
132
|
+
{
|
|
133
|
+
data: s,
|
|
134
|
+
keyField: c,
|
|
135
|
+
rowClassName: i,
|
|
136
|
+
renderRow: r,
|
|
137
|
+
onSelectRow: o,
|
|
138
|
+
selected: u
|
|
139
|
+
}
|
|
140
|
+
),
|
|
141
|
+
d,
|
|
142
|
+
f
|
|
143
|
+
] });
|
|
144
|
+
}
|
|
145
|
+
function q({
|
|
146
|
+
fields: t,
|
|
147
|
+
...a
|
|
148
|
+
}) {
|
|
149
|
+
return /* @__PURE__ */ l(S, { initialFields: t, children: /* @__PURE__ */ l(L, { ...a }) });
|
|
150
|
+
}
|
|
151
|
+
q.displayName = "DataTable";
|
|
152
|
+
function K({ field: t, row: a, className: e, as: n, ...s }) {
|
|
153
|
+
const c = m(
|
|
154
|
+
{ [`text-${t.align}`]: !!t.align },
|
|
155
|
+
e,
|
|
156
|
+
typeof t.className == "function" ? t.className(a) : t.className
|
|
34
157
|
);
|
|
35
|
-
return
|
|
36
|
-
|
|
158
|
+
return G(
|
|
159
|
+
n ?? t.as ?? "td",
|
|
37
160
|
{
|
|
38
161
|
className: c,
|
|
39
|
-
scope: (
|
|
40
|
-
colSpan:
|
|
41
|
-
...
|
|
162
|
+
scope: (n ?? t.as) === "th" ? "row" : void 0,
|
|
163
|
+
colSpan: t.colSpan,
|
|
164
|
+
...t.cellProps,
|
|
42
165
|
...s
|
|
43
166
|
},
|
|
44
|
-
|
|
167
|
+
a[t.field] === void 0 && !t.render ? null : typeof t.render == "function" ? t.render(a) : a[t.field]
|
|
45
168
|
);
|
|
46
169
|
}
|
|
47
|
-
function
|
|
48
|
-
className:
|
|
49
|
-
rowClassName:
|
|
50
|
-
selected:
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
onClick: r,
|
|
170
|
+
function w({
|
|
171
|
+
className: t,
|
|
172
|
+
rowClassName: a,
|
|
173
|
+
selected: e,
|
|
174
|
+
row: n,
|
|
175
|
+
trRef: s,
|
|
176
|
+
onClick: c,
|
|
55
177
|
...i
|
|
56
178
|
}) {
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
},
|
|
60
|
-
return
|
|
179
|
+
const r = y(), o = (b) => {
|
|
180
|
+
c?.(n, b);
|
|
181
|
+
}, u = typeof a == "function" ? a(n) : a;
|
|
182
|
+
return n ? /* @__PURE__ */ l(
|
|
61
183
|
"tr",
|
|
62
184
|
{
|
|
63
|
-
ref:
|
|
64
|
-
className:
|
|
65
|
-
onClick:
|
|
185
|
+
ref: s,
|
|
186
|
+
className: m({ "table-active": e }, t, u),
|
|
187
|
+
onClick: o,
|
|
66
188
|
...i,
|
|
67
|
-
children:
|
|
189
|
+
children: r.map((b, d) => /* @__PURE__ */ l(K, { field: b, row: n }, b?.id ?? d))
|
|
68
190
|
}
|
|
69
191
|
) : null;
|
|
70
192
|
}
|
|
71
|
-
|
|
72
|
-
function
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
selected: r = "",
|
|
193
|
+
w.displayName = "DataTableRow";
|
|
194
|
+
function $({
|
|
195
|
+
data: t,
|
|
196
|
+
keyField: a,
|
|
197
|
+
rowClassName: e,
|
|
198
|
+
renderRow: n,
|
|
199
|
+
onSelectRow: s,
|
|
200
|
+
selected: c = "",
|
|
80
201
|
children: i,
|
|
81
|
-
...
|
|
202
|
+
...r
|
|
82
203
|
}) {
|
|
83
|
-
return /* @__PURE__ */
|
|
84
|
-
|
|
85
|
-
const
|
|
86
|
-
return
|
|
87
|
-
|
|
204
|
+
return /* @__PURE__ */ p("tbody", { ...r, children: [
|
|
205
|
+
t.map((o) => {
|
|
206
|
+
const u = String(typeof a == "function" ? a(o) : o[a]), b = typeof c == "function" ? c(o) : u === c;
|
|
207
|
+
return n ? n(o) : /* @__PURE__ */ l(
|
|
208
|
+
w,
|
|
88
209
|
{
|
|
89
|
-
onClick:
|
|
90
|
-
rowClassName:
|
|
91
|
-
fields: a,
|
|
210
|
+
onClick: s,
|
|
211
|
+
rowClassName: e,
|
|
92
212
|
row: o,
|
|
93
|
-
selected:
|
|
213
|
+
selected: b
|
|
94
214
|
},
|
|
95
|
-
|
|
215
|
+
u
|
|
96
216
|
);
|
|
97
217
|
}),
|
|
98
218
|
i
|
|
99
219
|
] });
|
|
100
220
|
}
|
|
101
|
-
|
|
102
|
-
const
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
thead {
|
|
106
|
-
tr:nth-of-type(1) td,
|
|
107
|
-
tr:nth-of-type(1) th {
|
|
108
|
-
top: var(--table-sticky-top, unset);
|
|
109
|
-
position: ${(a) => a.sticky ? "sticky" : "unset"};
|
|
110
|
-
z-index: ${(a) => a.sticky ? 10 : "unset"};
|
|
111
|
-
background: ${(a) => a.sticky ? "linear-gradient(var(--bs-table-bg) 75%, rgba(var(--bs-secondary-bg-rgb), 0.9))" : "unset"};
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
`, D = $.forwardRef(
|
|
115
|
-
function({
|
|
116
|
-
sticky: n,
|
|
117
|
-
responsive: t,
|
|
118
|
-
children: l,
|
|
119
|
-
className: s,
|
|
120
|
-
...c
|
|
121
|
-
}, r) {
|
|
122
|
-
if (t) {
|
|
123
|
-
const i = u(s, {
|
|
124
|
-
"table-responsive": t === !0,
|
|
125
|
-
[`table-responsive-${t}`]: t !== !0
|
|
126
|
-
});
|
|
127
|
-
return /* @__PURE__ */ e("div", { className: i, children: /* @__PURE__ */ e(g, { ref: r, ...c, children: l }) });
|
|
128
|
-
}
|
|
129
|
-
return /* @__PURE__ */ e(g, { className: s, sticky: n, ref: r, ...c, children: l });
|
|
130
|
-
}
|
|
131
|
-
);
|
|
132
|
-
function B({
|
|
133
|
-
fields: a,
|
|
134
|
-
data: n,
|
|
135
|
-
keyField: t,
|
|
136
|
-
size: l = "",
|
|
137
|
-
sticky: s,
|
|
138
|
-
responsive: c,
|
|
139
|
-
rowClassName: r,
|
|
140
|
-
renderRow: i,
|
|
141
|
-
onSelectRow: m,
|
|
142
|
-
selected: o = "",
|
|
143
|
-
className: b = "",
|
|
144
|
-
tfoot: d,
|
|
145
|
-
children: p,
|
|
146
|
-
tableHeadProps: h,
|
|
147
|
-
...y
|
|
148
|
-
}) {
|
|
149
|
-
const f = u("table", b, {
|
|
150
|
-
[`table-${l}`]: !!l
|
|
151
|
-
});
|
|
152
|
-
return /* @__PURE__ */ N(D, { sticky: s, responsive: c, className: f, ...y, children: [
|
|
153
|
-
/* @__PURE__ */ e(x, { ...h, fields: a }),
|
|
154
|
-
!!n.length && /* @__PURE__ */ e(
|
|
155
|
-
v,
|
|
156
|
-
{
|
|
157
|
-
fields: a,
|
|
158
|
-
data: n,
|
|
159
|
-
keyField: t,
|
|
160
|
-
rowClassName: r,
|
|
161
|
-
renderRow: i,
|
|
162
|
-
onSelectRow: m,
|
|
163
|
-
selected: o
|
|
164
|
-
}
|
|
165
|
-
),
|
|
166
|
-
p,
|
|
167
|
-
d
|
|
168
|
-
] });
|
|
169
|
-
}
|
|
170
|
-
B.displayName = "DataTable";
|
|
171
|
-
const M = (a) => {
|
|
172
|
-
if (!a)
|
|
221
|
+
$.displayName = "DataTableTBody";
|
|
222
|
+
const O = (t) => {
|
|
223
|
+
if (!t)
|
|
173
224
|
return "flex-start";
|
|
174
|
-
switch (
|
|
225
|
+
switch (t) {
|
|
175
226
|
case "end":
|
|
176
227
|
return "flex-end";
|
|
177
228
|
default:
|
|
178
229
|
return "center";
|
|
179
230
|
}
|
|
180
|
-
},
|
|
231
|
+
}, Q = x.div`
|
|
181
232
|
display: flex;
|
|
182
233
|
width: 100%;
|
|
183
|
-
flex-direction: ${(
|
|
184
|
-
justify-content: ${(
|
|
234
|
+
flex-direction: ${(t) => t.align === "end" ? "row-reverse" : "row"};
|
|
235
|
+
justify-content: ${(t) => O(t.align)};
|
|
236
|
+
|
|
185
237
|
.sort-icon {
|
|
186
|
-
flex-grow: ${(
|
|
187
|
-
opacity: ${(
|
|
238
|
+
flex-grow: ${(t) => t.align === "end" ? "1" : "0"};
|
|
239
|
+
opacity: ${(t) => t.sorted ? 1 : 0};
|
|
188
240
|
}
|
|
241
|
+
|
|
189
242
|
&:hover .sort-icon {
|
|
190
|
-
color: ${(
|
|
243
|
+
color: ${(t) => t.sorted ? "unset" : "var(--bs-primary)"};
|
|
191
244
|
opacity: 0.75;
|
|
192
245
|
transition: opacity 0.2s;
|
|
193
246
|
}
|
|
194
247
|
`;
|
|
195
|
-
function
|
|
196
|
-
field:
|
|
197
|
-
sorted:
|
|
198
|
-
ascending:
|
|
199
|
-
className:
|
|
248
|
+
function j({
|
|
249
|
+
field: t,
|
|
250
|
+
sorted: a,
|
|
251
|
+
ascending: e,
|
|
252
|
+
className: n,
|
|
200
253
|
onClick: s
|
|
201
254
|
}) {
|
|
202
|
-
if (!
|
|
203
|
-
return /* @__PURE__ */
|
|
204
|
-
const { className: c, ...
|
|
205
|
-
|
|
255
|
+
if (!t.sortable)
|
|
256
|
+
return /* @__PURE__ */ l(C, { field: t, className: n });
|
|
257
|
+
const { className: c, ...i } = t.thProps ?? {}, r = m(
|
|
258
|
+
n,
|
|
206
259
|
c,
|
|
207
|
-
{ [`text-${
|
|
208
|
-
),
|
|
209
|
-
s({ field:
|
|
210
|
-
},
|
|
211
|
-
"bi-arrow-down":
|
|
212
|
-
"bi-arrow-up": !
|
|
260
|
+
{ [`text-${t.align}`]: !!t.align }
|
|
261
|
+
), o = () => {
|
|
262
|
+
s({ field: t.field, ascending: a ? !e : !0 });
|
|
263
|
+
}, u = {
|
|
264
|
+
"bi-arrow-down": e,
|
|
265
|
+
"bi-arrow-up": !e
|
|
213
266
|
};
|
|
214
|
-
return /* @__PURE__ */
|
|
215
|
-
/* @__PURE__ */
|
|
216
|
-
/* @__PURE__ */
|
|
267
|
+
return /* @__PURE__ */ l("th", { ...i, className: m("sortable", r), scope: "col", onClick: o, children: /* @__PURE__ */ p(Q, { sorted: a, align: t.align, children: [
|
|
268
|
+
/* @__PURE__ */ l("div", { className: "field-title", children: t.title }),
|
|
269
|
+
/* @__PURE__ */ l("div", { className: m("me-1 sort-icon", u) })
|
|
217
270
|
] }) });
|
|
218
271
|
}
|
|
219
|
-
|
|
220
|
-
function
|
|
221
|
-
currentSort:
|
|
222
|
-
|
|
223
|
-
onChangeSort: t
|
|
272
|
+
j.displayName = "SortableTableTH";
|
|
273
|
+
function E({
|
|
274
|
+
currentSort: t,
|
|
275
|
+
onChangeSort: a
|
|
224
276
|
}) {
|
|
225
|
-
const { field:
|
|
226
|
-
return /* @__PURE__ */
|
|
227
|
-
|
|
277
|
+
const e = y(), { field: n, ascending: s } = t;
|
|
278
|
+
return /* @__PURE__ */ l("thead", { children: /* @__PURE__ */ l("tr", { children: e.map((c, i) => /* @__PURE__ */ l(
|
|
279
|
+
j,
|
|
228
280
|
{
|
|
229
281
|
field: c,
|
|
230
|
-
sorted:
|
|
282
|
+
sorted: n === c.field,
|
|
231
283
|
ascending: s,
|
|
232
|
-
className:
|
|
284
|
+
className: m(
|
|
233
285
|
typeof c.className == "function" ? { [`text-${c.align}`]: !!c.align } : c.className
|
|
234
286
|
),
|
|
235
|
-
onClick:
|
|
287
|
+
onClick: a
|
|
236
288
|
},
|
|
237
|
-
|
|
289
|
+
i
|
|
238
290
|
)) }) });
|
|
239
291
|
}
|
|
240
|
-
|
|
241
|
-
function
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
sticky: r,
|
|
292
|
+
E.displayName = "SortableTableHead";
|
|
293
|
+
function U({
|
|
294
|
+
className: t,
|
|
295
|
+
size: a,
|
|
296
|
+
responsive: e,
|
|
297
|
+
sticky: n,
|
|
298
|
+
data: s,
|
|
299
|
+
keyField: c,
|
|
249
300
|
rowClassName: i,
|
|
250
|
-
renderRow:
|
|
301
|
+
renderRow: r,
|
|
251
302
|
onSelectRow: o,
|
|
252
|
-
selected:
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
303
|
+
selected: u,
|
|
304
|
+
tableHeadProps: b,
|
|
305
|
+
children: d,
|
|
306
|
+
tfoot: f,
|
|
307
|
+
currentSort: h,
|
|
308
|
+
onChangeSort: T,
|
|
309
|
+
...P
|
|
257
310
|
}) {
|
|
258
|
-
const
|
|
259
|
-
[`table-${
|
|
311
|
+
const _ = m("table", t, {
|
|
312
|
+
[`table-${a}`]: !!a
|
|
260
313
|
});
|
|
261
|
-
return /* @__PURE__ */
|
|
262
|
-
/* @__PURE__ */
|
|
263
|
-
|
|
264
|
-
|
|
314
|
+
return /* @__PURE__ */ p(F, { className: _, responsive: e, sticky: n, ...P, children: [
|
|
315
|
+
/* @__PURE__ */ l(k, {}),
|
|
316
|
+
/* @__PURE__ */ l(E, { currentSort: h, onChangeSort: T, ...b }),
|
|
317
|
+
!!s.length && /* @__PURE__ */ l(
|
|
318
|
+
$,
|
|
265
319
|
{
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
keyField: s,
|
|
320
|
+
data: s,
|
|
321
|
+
keyField: c,
|
|
269
322
|
rowClassName: i,
|
|
270
|
-
renderRow:
|
|
323
|
+
renderRow: r,
|
|
271
324
|
onSelectRow: o,
|
|
272
|
-
selected:
|
|
325
|
+
selected: u
|
|
273
326
|
}
|
|
274
327
|
),
|
|
275
|
-
|
|
276
|
-
|
|
328
|
+
d,
|
|
329
|
+
f
|
|
277
330
|
] });
|
|
278
331
|
}
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
332
|
+
function X({
|
|
333
|
+
fields: t,
|
|
334
|
+
...a
|
|
335
|
+
}) {
|
|
336
|
+
return /* @__PURE__ */ l(S, { initialFields: t, children: /* @__PURE__ */ l(U, { ...a }) });
|
|
337
|
+
}
|
|
338
|
+
X.displayName = "SortableTable";
|
|
339
|
+
const Y = [10, 25, 50, 100, 250, 500, 1e3];
|
|
340
|
+
function M({
|
|
341
|
+
value: t,
|
|
342
|
+
pageValues: a = Y,
|
|
343
|
+
size: e,
|
|
344
|
+
label: n,
|
|
286
345
|
className: s,
|
|
287
346
|
onChange: c,
|
|
288
|
-
...
|
|
347
|
+
...i
|
|
289
348
|
}) {
|
|
290
|
-
const
|
|
291
|
-
[`input-group-${
|
|
349
|
+
const r = I(), o = (d) => c(Number(d.target.value)), u = s ?? m("form-select", { [`form-select-${e}`]: !!e }), b = m("input-group", {
|
|
350
|
+
[`input-group-${e}`]: !!e
|
|
292
351
|
});
|
|
293
|
-
return /* @__PURE__ */
|
|
294
|
-
/* @__PURE__ */
|
|
295
|
-
/* @__PURE__ */
|
|
352
|
+
return /* @__PURE__ */ p("div", { className: b, children: [
|
|
353
|
+
/* @__PURE__ */ l("label", { className: "input-group-text", htmlFor: r, children: n ?? "Rows" }),
|
|
354
|
+
/* @__PURE__ */ l(
|
|
296
355
|
"select",
|
|
297
356
|
{
|
|
298
|
-
className:
|
|
299
|
-
id:
|
|
300
|
-
value:
|
|
301
|
-
onChange:
|
|
302
|
-
...
|
|
303
|
-
children:
|
|
357
|
+
className: u,
|
|
358
|
+
id: r,
|
|
359
|
+
value: t,
|
|
360
|
+
onChange: o,
|
|
361
|
+
...i,
|
|
362
|
+
children: a.map((d) => /* @__PURE__ */ l("option", { value: d, children: d }, d))
|
|
304
363
|
}
|
|
305
364
|
)
|
|
306
|
-
] },
|
|
365
|
+
] }, t);
|
|
307
366
|
}
|
|
308
|
-
|
|
309
|
-
function
|
|
310
|
-
page:
|
|
311
|
-
rowsPerPage:
|
|
312
|
-
onChangePage:
|
|
313
|
-
count:
|
|
367
|
+
M.displayName = "RowsPerPage";
|
|
368
|
+
function Z({
|
|
369
|
+
page: t,
|
|
370
|
+
rowsPerPage: a,
|
|
371
|
+
onChangePage: e,
|
|
372
|
+
count: n,
|
|
314
373
|
size: s,
|
|
315
374
|
showFirst: c,
|
|
316
|
-
showLast:
|
|
317
|
-
className:
|
|
318
|
-
rowsPerPageProps:
|
|
319
|
-
...
|
|
375
|
+
showLast: i,
|
|
376
|
+
className: r,
|
|
377
|
+
rowsPerPageProps: o,
|
|
378
|
+
...u
|
|
320
379
|
}) {
|
|
321
|
-
const b =
|
|
322
|
-
return /* @__PURE__ */
|
|
323
|
-
!!
|
|
324
|
-
/* @__PURE__ */
|
|
325
|
-
/* @__PURE__ */
|
|
380
|
+
const b = n === 0 ? 0 : t * a + 1, d = Math.min(t * a + a, n), f = a === 0 ? 0 : Math.floor((n - 1) / a), h = m("btn btn-link", { [`btn-${s}`]: !!s });
|
|
381
|
+
return /* @__PURE__ */ p("div", { className: m("row g-3 justify-content-end", r), ...u, children: [
|
|
382
|
+
!!o && /* @__PURE__ */ l("div", { className: "col-auto", children: /* @__PURE__ */ l(M, { ...o, value: a, size: s }) }),
|
|
383
|
+
/* @__PURE__ */ l("div", { className: "col-auto", children: /* @__PURE__ */ p("div", { className: "row g-3 flex-nowrap align-items-baseline", children: [
|
|
384
|
+
/* @__PURE__ */ p("div", { className: "col-auto", children: [
|
|
326
385
|
b,
|
|
327
386
|
"-",
|
|
328
387
|
d,
|
|
329
388
|
" of ",
|
|
330
|
-
|
|
389
|
+
n
|
|
331
390
|
] }),
|
|
332
|
-
c && /* @__PURE__ */
|
|
391
|
+
c && /* @__PURE__ */ l("div", { className: "col-auto", children: /* @__PURE__ */ l(
|
|
333
392
|
"button",
|
|
334
393
|
{
|
|
335
394
|
className: h,
|
|
336
|
-
disabled:
|
|
337
|
-
onClick: () =>
|
|
395
|
+
disabled: t === 0,
|
|
396
|
+
onClick: () => e(0),
|
|
338
397
|
"aria-label": "First page",
|
|
339
|
-
children: /* @__PURE__ */
|
|
398
|
+
children: /* @__PURE__ */ l("span", { className: "bi-chevron-bar-left", "aria-hidden": "true" })
|
|
340
399
|
}
|
|
341
400
|
) }),
|
|
342
|
-
/* @__PURE__ */
|
|
401
|
+
/* @__PURE__ */ l("div", { className: "col-auto", children: /* @__PURE__ */ l(
|
|
343
402
|
"button",
|
|
344
403
|
{
|
|
345
404
|
className: h,
|
|
346
|
-
disabled:
|
|
347
|
-
onClick: () => t
|
|
405
|
+
disabled: t === 0,
|
|
406
|
+
onClick: () => e(t - 1),
|
|
348
407
|
"aria-label": "Previous page",
|
|
349
|
-
children: /* @__PURE__ */
|
|
408
|
+
children: /* @__PURE__ */ l("span", { className: "bi-chevron-left", "aria-hidden": "true" })
|
|
350
409
|
}
|
|
351
410
|
) }),
|
|
352
|
-
/* @__PURE__ */
|
|
411
|
+
/* @__PURE__ */ l("div", { className: "col-auto", children: /* @__PURE__ */ l(
|
|
353
412
|
"button",
|
|
354
413
|
{
|
|
355
414
|
className: h,
|
|
356
|
-
disabled:
|
|
357
|
-
onClick: () => t
|
|
415
|
+
disabled: t >= f,
|
|
416
|
+
onClick: () => e(t + 1),
|
|
358
417
|
"aria-label": "Next page",
|
|
359
|
-
children: /* @__PURE__ */
|
|
418
|
+
children: /* @__PURE__ */ l("span", { className: "bi-chevron-right", "aria-hidden": "true" })
|
|
360
419
|
}
|
|
361
420
|
) }),
|
|
362
|
-
|
|
421
|
+
i && /* @__PURE__ */ l("div", { className: "col-auto", children: /* @__PURE__ */ l(
|
|
363
422
|
"button",
|
|
364
423
|
{
|
|
365
424
|
className: h,
|
|
366
|
-
disabled:
|
|
367
|
-
onClick: () =>
|
|
425
|
+
disabled: t >= f,
|
|
426
|
+
onClick: () => e(f),
|
|
368
427
|
"aria-label": "Last page",
|
|
369
|
-
children: /* @__PURE__ */
|
|
428
|
+
children: /* @__PURE__ */ l("span", { className: "bi-chevron-bar-right", "aria-hidden": "true" })
|
|
370
429
|
}
|
|
371
430
|
) })
|
|
372
431
|
] }) })
|
|
373
432
|
] });
|
|
374
433
|
}
|
|
375
|
-
|
|
434
|
+
Z.displayname = "TablePagination";
|
|
435
|
+
const z = x.col`
|
|
436
|
+
&.col-collapsed {
|
|
437
|
+
visibility: collapse;
|
|
438
|
+
}
|
|
439
|
+
`;
|
|
440
|
+
function k() {
|
|
441
|
+
const t = y();
|
|
442
|
+
return /* @__PURE__ */ l("colgroup", { children: t.map((a, e) => /* @__PURE__ */ l(
|
|
443
|
+
z,
|
|
444
|
+
{
|
|
445
|
+
className: m(a.colClassName, { "col-collapsed": a.collapse }),
|
|
446
|
+
span: a.colSpan ?? 1
|
|
447
|
+
},
|
|
448
|
+
e
|
|
449
|
+
)) });
|
|
450
|
+
}
|
|
451
|
+
k.displayName = "DataTableCols";
|
|
376
452
|
export {
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
453
|
+
q as DataTable,
|
|
454
|
+
k as DataTableCols,
|
|
455
|
+
S as DataTableProvider,
|
|
456
|
+
w as DataTableRow,
|
|
457
|
+
$ as DataTableTBody,
|
|
458
|
+
C as DataTableTH,
|
|
459
|
+
L as DataTableWithContext,
|
|
460
|
+
M as RowsPerPage,
|
|
461
|
+
X as SortableTable,
|
|
462
|
+
E as SortableTableHead,
|
|
463
|
+
j as SortableTableTH,
|
|
464
|
+
U as SortableTableWithContext,
|
|
465
|
+
Z as TablePagination,
|
|
466
|
+
nt as useField,
|
|
467
|
+
lt as useHasTableFieldsContext,
|
|
468
|
+
J as useTableContext,
|
|
469
|
+
y as useTableFields
|
|
387
470
|
};
|
|
388
471
|
//# sourceMappingURL=index.es.js.map
|