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