@chumsinc/sortable-tables 3.1.0 → 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.
Files changed (43) hide show
  1. package/CHANGELOG.md +42 -1
  2. package/README.md +38 -0
  3. package/dist/ContainedDataTable.d.ts +1 -1
  4. package/dist/ContainedDataTableRow.d.ts +1 -1
  5. package/dist/ContainedSortableTable.d.ts +1 -1
  6. package/dist/DataTable.d.ts +1 -1
  7. package/dist/DataTableCell.d.ts +173 -173
  8. package/dist/DataTableContext.d.ts +2 -2
  9. package/dist/DataTableHead.d.ts +1 -1
  10. package/dist/DataTableProvider.d.ts +2 -2
  11. package/dist/DataTableRow.d.ts +2 -2
  12. package/dist/DataTableRowCellSet.d.ts +2 -0
  13. package/dist/DataTableTBody.d.ts +1 -1
  14. package/dist/DataTableTH.d.ts +1 -1
  15. package/dist/DataTableTR.d.ts +6 -0
  16. package/dist/RowsPerPage.d.ts +1 -1
  17. package/dist/SortHelper.d.ts +1 -1
  18. package/dist/SortableTable.d.ts +1 -1
  19. package/dist/SortableTableHead.d.ts +1 -1
  20. package/dist/SortableTableHeadWrapper.d.ts +1 -1
  21. package/dist/SortableTableTH.d.ts +1 -1
  22. package/dist/Table.d.ts +2 -2
  23. package/dist/TablePagination.d.ts +1 -1
  24. package/dist/index.cjs.js +4 -4
  25. package/dist/index.cjs.js.map +1 -1
  26. package/dist/index.d.ts +5 -1
  27. package/dist/index.es.js +287 -255
  28. package/dist/index.es.js.map +1 -1
  29. package/dist/types.d.ts +6 -2
  30. package/dist/useField.d.ts +1 -1
  31. package/dist/useTableContext.d.ts +1 -1
  32. package/dist/useTableFields.d.ts +1 -1
  33. package/dist/useTableSort.d.ts +1 -1
  34. package/{eslint.config.mjs → eslint.config.js} +2 -2
  35. package/package.json +8 -11
  36. package/src/DataTableRow.tsx +6 -21
  37. package/src/DataTableRowCellSet.tsx +13 -0
  38. package/src/DataTableTR.tsx +33 -0
  39. package/src/index.tsx +7 -2
  40. package/src/types.ts +6 -0
  41. package/tsconfig-dts.json +8 -0
  42. package/tsconfig.json +1 -1
  43. package/vite.config.ts +3 -2
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 I, useState as w, useCallback as g, useMemo as J, useContext as C, createElement as L, useEffect as q, useId as K } from "react";
3
- import R from "@emotion/styled";
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, a, n = "";
39
- if (typeof t == "string" || typeof t == "number") n += t;
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] && (a = E(t[e])) && (n && (n += " "), n += a);
43
- } else for (a in t) t[a] && (n && (n += " "), n += a);
44
- return n;
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 m() {
47
- for (var t, e, a = 0, n = "", s = arguments.length; a < s; a++) (t = arguments[a]) && (e = E(t)) && (n && (n += " "), n += e);
48
- return n;
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 F = R.table`
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: a,
67
- className: n,
33
+ children: n,
34
+ className: a,
68
35
  ref: s,
69
36
  ...r
70
37
  }) {
71
38
  if (e) {
72
- const c = m(n, {
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: c, children: /* @__PURE__ */ l(F, { ref: s, ...r, children: a }) });
43
+ return /* @__PURE__ */ l("div", { className: o, children: /* @__PURE__ */ l(w, { ref: s, ...r, children: n }) });
77
44
  }
78
- return /* @__PURE__ */ l(F, { className: n, sticky: t, ref: s, ...r, children: a });
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: a,
84
- ...n
132
+ children: n,
133
+ ...a
85
134
  }) {
86
135
  if (t.visible === !1)
87
136
  return null;
88
- const s = m({ [`text-${t.align}`]: !!t.align }, e);
89
- return /* @__PURE__ */ l("th", { className: s, scope: "col", ...n, children: a ?? t.title });
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
- S.displayName = "DataTableTH";
140
+ D.displayName = "DataTableTH";
92
141
  function v() {
93
- const t = C(T);
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 j({ ...t }) {
150
+ function _({ ...t }) {
102
151
  const [e] = v();
103
- return /* @__PURE__ */ l("thead", { ...t, children: /* @__PURE__ */ l("tr", { children: e.map((a, n) => /* @__PURE__ */ l(
104
- S,
152
+ return /* @__PURE__ */ l("thead", { ...t, children: /* @__PURE__ */ l("tr", { children: e.map((n, a) => /* @__PURE__ */ l(
153
+ D,
105
154
  {
106
- ...a.thProps,
107
- field: a,
108
- className: m(
109
- typeof a.className == "function" ? { [`text-${a.align}`]: !!a.align } : a.className
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(a.id ?? n)
161
+ String(n.id ?? a)
113
162
  )) }) });
114
163
  }
115
- j.displayName = "DataTableHead";
116
- function _({
164
+ _.displayName = "DataTableHead";
165
+ function M({
117
166
  className: t,
118
167
  size: e,
119
- responsive: a,
120
- sticky: n,
168
+ responsive: n,
169
+ sticky: a,
121
170
  data: s,
122
171
  keyField: r,
123
- rowClassName: c,
124
- renderRow: u,
172
+ rowClassName: o,
173
+ renderRow: c,
125
174
  onSelectRow: i,
126
- selected: d,
127
- tableHeadProps: o,
128
- children: b,
175
+ selected: u,
176
+ tableHeadProps: d,
177
+ children: m,
129
178
  tfoot: p,
130
179
  ...f
131
180
  }) {
132
- const N = m("table", t, {
181
+ const N = b("table", t, {
133
182
  [`table-${e}`]: !!e
134
183
  });
135
- return /* @__PURE__ */ h(P, { sticky: n, responsive: a, className: N, ...f, children: [
184
+ return /* @__PURE__ */ h(P, { sticky: a, responsive: n, className: N, ...f, children: [
136
185
  /* @__PURE__ */ l(H, {}),
137
- /* @__PURE__ */ l(j, { ...o }),
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: c,
144
- renderRow: u,
192
+ rowClassName: o,
193
+ renderRow: c,
145
194
  onSelectRow: i,
146
- selected: d
195
+ selected: u
147
196
  }
148
197
  ),
149
- b,
198
+ m,
150
199
  p
151
200
  ] });
152
201
  }
153
- _.displayName = "ContainedDataTable";
154
- function O({
202
+ M.displayName = "ContainedDataTable";
203
+ function X({
155
204
  fields: t,
156
205
  ...e
157
206
  }) {
158
- return /* @__PURE__ */ l(x, { initialFields: t, children: /* @__PURE__ */ l(_, { ...e }) });
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
- D.displayName = "DataTableCell";
182
- function M({
209
+ X.displayName = "DataTable";
210
+ function A({
183
211
  className: t,
184
212
  rowClassName: e,
185
- selected: a,
186
- row: n,
213
+ selected: n,
214
+ row: a,
187
215
  trRef: s,
188
216
  onClick: r,
189
- ...c
217
+ ...o
190
218
  }) {
191
- const [u] = v(), i = (o) => {
192
- r?.(n, o);
193
- }, d = typeof e == "function" ? e(n) : e;
194
- return n ? /* @__PURE__ */ l(
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: m({ "table-active": a }, t, d),
226
+ className: b({ "table-active": n }, t, u),
199
227
  onClick: i,
200
- ...c,
201
- children: u.map((o, b) => /* @__PURE__ */ l(D, { field: o, row: n }, String(o?.id ?? b)))
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
- M.displayName = "ContainedDataTableRow";
206
- function Q({
233
+ A.displayName = "ContainedDataTableRow";
234
+ function Y({
207
235
  fields: t,
208
236
  className: e,
209
- rowClassName: a,
210
- selected: n,
237
+ rowClassName: n,
238
+ selected: a,
211
239
  row: s,
212
240
  trRef: r,
213
- onClick: c,
214
- ...u
241
+ onClick: o,
242
+ ...c
215
243
  }) {
216
- const i = (o) => {
217
- c?.(s, o);
218
- }, d = typeof a == "function" ? a(s) : a;
219
- return s ? /* @__PURE__ */ l(
220
- "tr",
244
+ return /* @__PURE__ */ l(
245
+ j,
221
246
  {
222
- ref: r,
223
- className: m({ "table-active": n }, e, d),
224
- onClick: i,
225
- ...u,
226
- children: t.map((o, b) => /* @__PURE__ */ l(D, { field: o, row: s }, String(o?.id ?? b)))
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
- ) : null;
256
+ );
229
257
  }
230
- Q.displayName = "DataTableRow";
258
+ Y.displayName = "DataTableRow";
231
259
  function k({
232
260
  data: t,
233
261
  keyField: e,
234
- rowClassName: a,
235
- renderRow: n,
262
+ rowClassName: n,
263
+ renderRow: a,
236
264
  onSelectRow: s,
237
265
  selected: r = "",
238
- children: c,
239
- ...u
266
+ children: o,
267
+ ...c
240
268
  }) {
241
- return /* @__PURE__ */ h("tbody", { ...u, children: [
269
+ return /* @__PURE__ */ h("tbody", { ...c, children: [
242
270
  t.map((i) => {
243
- const d = String(typeof e == "function" ? e(i) : i[e]), o = typeof r == "function" ? r(i) : d === r;
244
- return n ? n(i) : /* @__PURE__ */ l(
245
- M,
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: a,
276
+ rowClassName: n,
249
277
  row: i,
250
- selected: o
278
+ selected: d
251
279
  },
252
- d
280
+ u
253
281
  );
254
282
  }),
255
- c
283
+ o
256
284
  ] });
257
285
  }
258
286
  k.displayName = "DataTableTBody";
259
287
  function $() {
260
- const t = C(T);
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 U = (t) => t ? t === "end" ? "flex-end" : "center" : "flex-start", X = R.div`
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) => U(t.align)};
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 A({
313
+ function B({
286
314
  field: t,
287
315
  sorted: e,
288
- ascending: a,
289
- className: n,
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(S, { field: t, className: n });
296
- const { className: r, ...c } = t.thProps ?? {}, u = m(
297
- n,
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 ? !a : !0 });
302
- }, d = {
303
- "bi-arrow-down": a,
304
- "bi-arrow-up": !a
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", { ...c, className: m("sortable", u), scope: "col", onClick: i, children: /* @__PURE__ */ h(X, { sorted: e, align: t.align, children: [
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: m("me-1 sort-icon", d) })
336
+ /* @__PURE__ */ l("div", { className: b("me-1 sort-icon", u) })
309
337
  ] }) });
310
338
  }
311
- A.displayName = "SortableTableTH";
312
- function B({
339
+ B.displayName = "SortableTableTH";
340
+ function V({
313
341
  onChangeSort: t
314
342
  }) {
315
- const [e] = v(), [a] = $();
316
- return /* @__PURE__ */ l("thead", { children: /* @__PURE__ */ l("tr", { children: e.map((n, s) => /* @__PURE__ */ l(
317
- A,
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: n,
320
- sorted: a?.field === n.field,
321
- ascending: a?.ascending,
322
- className: m(
323
- typeof n.className == "function" ? { [`text-${n.align}`]: !!n.align } : n.className
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
- B.displayName = "SortableTableHead";
331
- function V({
358
+ V.displayName = "SortableTableHead";
359
+ function W({
332
360
  onChangeSort: t
333
361
  }) {
334
- const [e] = v(), [a] = $();
335
- return /* @__PURE__ */ l(B, { fields: e, currentSort: a, onChangeSort: t });
362
+ const [e] = v(), [n] = $();
363
+ return /* @__PURE__ */ l(V, { fields: e, currentSort: n, onChangeSort: t });
336
364
  }
337
- V.displayName = "SortableTableHeadWrapper";
338
- function W({
365
+ W.displayName = "SortableTableHeadWrapper";
366
+ function G({
339
367
  className: t,
340
368
  size: e,
341
- responsive: a,
342
- sticky: n,
369
+ responsive: n,
370
+ sticky: a,
343
371
  data: s,
344
372
  keyField: r,
345
- rowClassName: c,
346
- renderRow: u,
373
+ rowClassName: o,
374
+ renderRow: c,
347
375
  onSelectRow: i,
348
- selected: d,
349
- tableHeadProps: o,
350
- children: b,
376
+ selected: u,
377
+ tableHeadProps: d,
378
+ children: m,
351
379
  tfoot: p,
352
380
  onChangeSort: f,
353
381
  ...N
354
382
  }) {
355
- const y = m("table", t, {
383
+ const T = b("table", t, {
356
384
  [`table-${e}`]: !!e
357
385
  });
358
- return /* @__PURE__ */ h(P, { className: y, responsive: a, sticky: n, ...N, children: [
386
+ return /* @__PURE__ */ h(P, { className: T, responsive: n, sticky: a, ...N, children: [
359
387
  /* @__PURE__ */ l(H, {}),
360
- /* @__PURE__ */ l(V, { onChangeSort: f, ...o }),
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: c,
367
- renderRow: u,
394
+ rowClassName: o,
395
+ renderRow: c,
368
396
  onSelectRow: i,
369
- selected: d
397
+ selected: u
370
398
  }
371
399
  ),
372
- b,
400
+ m,
373
401
  p
374
402
  ] });
375
403
  }
376
- W.displayName = "ContainedSortableTable";
377
- function Y({ nextSort: t }) {
404
+ G.displayName = "ContainedSortableTable";
405
+ function tt({ nextSort: t }) {
378
406
  const [, e] = $();
379
- return q(() => {
407
+ return O(() => {
380
408
  console.log("setNextSort", t), e(t);
381
409
  }, [t, e]), null;
382
410
  }
383
- function Z({
411
+ function et({
384
412
  fields: t,
385
413
  currentSort: e,
386
- ...a
414
+ ...n
387
415
  }) {
388
- return /* @__PURE__ */ h(x, { initialFields: t, initialSort: e, children: [
389
- /* @__PURE__ */ l(Y, { nextSort: e }),
390
- /* @__PURE__ */ l(W, { ...a })
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
- Z.displayName = "SortableTable";
394
- const z = [10, 25, 50, 100, 250, 500, 1e3];
395
- function G({
421
+ et.displayName = "SortableTable";
422
+ const at = [10, 25, 50, 100, 250, 500, 1e3];
423
+ function I({
396
424
  value: t,
397
- pageValues: e = z,
398
- size: a,
399
- label: n,
425
+ pageValues: e = at,
426
+ size: n,
427
+ label: a,
400
428
  className: s,
401
429
  onChange: r,
402
- ...c
430
+ ...o
403
431
  }) {
404
- const u = K(), i = (b) => r(Number(b.target.value)), d = s ?? m("form-select", { [`form-select-${a}`]: !!a }), o = m("input-group", {
405
- [`input-group-${a}`]: !!a
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: o, children: [
408
- /* @__PURE__ */ l("label", { className: "input-group-text", htmlFor: u, children: n ?? "Rows" }),
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: d,
413
- id: u,
440
+ className: u,
441
+ id: c,
414
442
  value: t,
415
443
  onChange: i,
416
- ...c,
417
- children: e.map((b) => /* @__PURE__ */ l("option", { value: b, children: b }, b))
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
- G.displayName = "RowsPerPage";
423
- function tt({
450
+ I.displayName = "RowsPerPage";
451
+ function nt({
424
452
  page: t,
425
453
  rowsPerPage: e,
426
- onChangePage: a,
427
- count: n,
454
+ onChangePage: n,
455
+ count: a,
428
456
  size: s,
429
457
  showFirst: r,
430
- showLast: c,
431
- className: u,
458
+ showLast: o,
459
+ className: c,
432
460
  rowsPerPageProps: i,
433
- ...d
461
+ ...u
434
462
  }) {
435
- const o = n === 0 ? 0 : t * e + 1, b = Math.min(t * e + e, n), p = e === 0 ? 0 : Math.floor((n - 1) / e), f = m("btn btn-link", { [`btn-${s}`]: !!s });
436
- return /* @__PURE__ */ h("div", { className: m("row g-3 justify-content-end", u), ...d, children: [
437
- !!i && /* @__PURE__ */ l("div", { className: "col-auto", children: /* @__PURE__ */ l(G, { ...i, value: e, size: s }) }),
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
- o,
468
+ d,
441
469
  "-",
442
- b,
470
+ m,
443
471
  " of ",
444
- n
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: () => a(0),
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: () => a(t - 1),
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: () => a(t + 1),
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
- c && /* @__PURE__ */ l("div", { className: "col-auto", children: /* @__PURE__ */ l(
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: () => a(p),
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
- tt.displayname = "TablePagination";
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, a) => /* @__PURE__ */ l(
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
- a
526
+ n
499
527
  )) });
500
528
  }
501
529
  H.displayName = "DataTableCols";
502
- function lt(t) {
503
- const e = C(T);
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((a) => a.id === t) ?? null,
535
+ e.fields.find((n) => n.id === t) ?? null,
508
536
  e.updateField
509
537
  ];
510
538
  }
511
- function st() {
512
- const t = C(T);
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
- _ as ContainedDataTable,
519
- M as ContainedDataTableRow,
520
- W as ContainedSortableTable,
521
- O as DataTable,
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
- T as DataTableContext,
524
- x as DataTableProvider,
525
- Q as DataTableRow,
552
+ y as DataTableContext,
553
+ S as DataTableProvider,
554
+ Y as DataTableRow,
555
+ U as DataTableRowCellSet,
526
556
  k as DataTableTBody,
527
- S as DataTableTH,
528
- G as RowsPerPage,
529
- Z as SortableTable,
530
- B as SortableTableHead,
531
- A as SortableTableTH,
532
- tt as TablePagination,
533
- lt as useField,
534
- st as useTableContext,
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
  };