@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.
Files changed (43) hide show
  1. package/CHANGELOG.md +23 -1
  2. package/dist/DataTable.d.ts +1 -1
  3. package/dist/DataTableCell.d.ts +172 -172
  4. package/dist/DataTableCols.d.ts +5 -0
  5. package/dist/DataTableHead.d.ts +2 -2
  6. package/dist/DataTableRow.d.ts +1 -1
  7. package/dist/DataTableTBody.d.ts +1 -1
  8. package/dist/DataTableWithContext.d.ts +2 -0
  9. package/dist/RowsPerPage.d.ts +0 -1
  10. package/dist/SortableTable.d.ts +1 -1
  11. package/dist/SortableTableHead.d.ts +1 -1
  12. package/dist/SortableTableWithContext.d.ts +2 -0
  13. package/dist/TableProvider.d.ts +17 -0
  14. package/dist/index.cjs.js +18 -12
  15. package/dist/index.cjs.js.map +1 -1
  16. package/dist/index.d.ts +8 -2
  17. package/dist/index.es.js +351 -268
  18. package/dist/index.es.js.map +1 -1
  19. package/dist/types.d.ts +14 -16
  20. package/eslint.config.mjs +3 -3
  21. package/package.json +6 -4
  22. package/src/DataTable.tsx +5 -33
  23. package/src/DataTableCell.tsx +5 -5
  24. package/src/DataTableCols.tsx +25 -0
  25. package/src/DataTableHead.tsx +6 -5
  26. package/src/DataTableRow.tsx +5 -4
  27. package/src/DataTableTBody.tsx +0 -2
  28. package/src/DataTableTH.tsx +8 -7
  29. package/src/DataTableWithContext.tsx +41 -0
  30. package/src/RowsPerPage.tsx +4 -5
  31. package/src/SortableTable.tsx +5 -31
  32. package/src/SortableTableHead.tsx +12 -11
  33. package/src/SortableTableTH.tsx +7 -4
  34. package/src/SortableTableWithContext.tsx +44 -0
  35. package/src/Table.tsx +2 -2
  36. package/src/TablePagination.tsx +3 -3
  37. package/src/TableProvider.tsx +77 -0
  38. package/src/index.tsx +10 -2
  39. package/src/types.ts +18 -20
  40. package/test/TableColumnsHandler.tsx +28 -0
  41. package/test/TestTable.tsx +15 -37
  42. package/test/tableFields.tsx +44 -0
  43. package/vite.config.ts +1 -2
package/dist/index.es.js CHANGED
@@ -1,388 +1,471 @@
1
- import { jsx as e, jsxs as N } from "react/jsx-runtime";
2
- import u from "classnames";
3
- import $, { useId as j } from "react";
4
- import k from "@emotion/styled";
5
- function T({
6
- field: a,
7
- className: n,
8
- children: t,
9
- ...l
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 = u({ [`text-${a.align}`]: !!a.align }, n);
12
- return /* @__PURE__ */ e("th", { className: s, scope: "col", ...l, children: t ?? a.title });
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
- T.displayName = "DataTableTH";
15
- function x({ fields: a, ...n }) {
16
- return /* @__PURE__ */ e("thead", { ...n, children: /* @__PURE__ */ e("tr", { children: a.map((t, l) => /* @__PURE__ */ e(
17
- T,
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
- ...t.thProps,
20
- field: t,
21
- className: u(
22
- typeof t.className == "function" ? { [`text-${t.align}`]: !!t.align } : t.className
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
- t.id ?? l
104
+ e.id ?? n
26
105
  )) }) });
27
106
  }
28
- x.displayName = "DataTableHead";
29
- function _({ field: a, row: n, className: t, as: l, ...s }) {
30
- const c = u(
31
- { [`text-${a.align}`]: !!a.align },
32
- t,
33
- typeof a.className == "function" ? a.className(n) : a.className
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 $.createElement(
36
- l ?? a.as ?? "td",
158
+ return G(
159
+ n ?? t.as ?? "td",
37
160
  {
38
161
  className: c,
39
- scope: (l ?? a.as) === "th" ? "row" : void 0,
40
- colSpan: a.colSpan,
41
- ...a.cellProps,
162
+ scope: (n ?? t.as) === "th" ? "row" : void 0,
163
+ colSpan: t.colSpan,
164
+ ...t.cellProps,
42
165
  ...s
43
166
  },
44
- n[a.field] === void 0 && !a.render ? null : typeof a.render == "function" ? a.render(n) : n[a.field]
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 C({
48
- className: a,
49
- rowClassName: n,
50
- selected: t,
51
- fields: l,
52
- row: s,
53
- trRef: c,
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 m = (b) => {
58
- r?.(s, b);
59
- }, o = typeof n == "function" ? n(s) : n;
60
- return s ? /* @__PURE__ */ e(
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: c,
64
- className: u({ "table-active": t }, a, o),
65
- onClick: m,
185
+ ref: s,
186
+ className: m({ "table-active": e }, t, u),
187
+ onClick: o,
66
188
  ...i,
67
- children: l.map((b, d) => /* @__PURE__ */ e(_, { field: b, row: s }, d))
189
+ children: r.map((b, d) => /* @__PURE__ */ l(K, { field: b, row: n }, b?.id ?? d))
68
190
  }
69
191
  ) : null;
70
192
  }
71
- C.displayName = "DataTableRow";
72
- function v({
73
- fields: a,
74
- data: n,
75
- keyField: t,
76
- rowClassName: l,
77
- renderRow: s,
78
- onSelectRow: c,
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
- ...m
202
+ ...r
82
203
  }) {
83
- return /* @__PURE__ */ N("tbody", { ...m, children: [
84
- n.map((o) => {
85
- const b = String(typeof t == "function" ? t(o) : o[t]), d = typeof r == "function" ? r(o) : b === r;
86
- return s ? s(o) : /* @__PURE__ */ e(
87
- C,
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: c,
90
- rowClassName: l,
91
- fields: a,
210
+ onClick: s,
211
+ rowClassName: e,
92
212
  row: o,
93
- selected: d
213
+ selected: b
94
214
  },
95
- b
215
+ u
96
216
  );
97
217
  }),
98
218
  i
99
219
  ] });
100
220
  }
101
- v.displayName = "DataTableTBody";
102
- const g = k.table`
103
- --table-sticky-top: ${(a) => a.sticky ? "0" : void 0};
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 (a) {
225
+ switch (t) {
175
226
  case "end":
176
227
  return "flex-end";
177
228
  default:
178
229
  return "center";
179
230
  }
180
- }, V = k.div`
231
+ }, Q = x.div`
181
232
  display: flex;
182
233
  width: 100%;
183
- flex-direction: ${(a) => a.align === "end" ? "row-reverse" : "row"};
184
- justify-content: ${(a) => M(a.align)};
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: ${(a) => a.align === "end" ? "1" : "0"};
187
- opacity: ${(a) => a.sorted ? 1 : 0};
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: ${(a) => a.sorted ? "unset" : "var(--bs-primary)"} ;
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 H({
196
- field: a,
197
- sorted: n,
198
- ascending: t,
199
- className: l,
248
+ function j({
249
+ field: t,
250
+ sorted: a,
251
+ ascending: e,
252
+ className: n,
200
253
  onClick: s
201
254
  }) {
202
- if (!a.sortable)
203
- return /* @__PURE__ */ e(T, { field: a, className: l });
204
- const { className: c, ...r } = a.thProps ?? {}, i = u(
205
- l,
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-${a.align}`]: !!a.align }
208
- ), m = () => {
209
- s({ field: a.field, ascending: n ? !t : !0 });
210
- }, o = {
211
- "bi-arrow-down": t,
212
- "bi-arrow-up": !t
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__ */ e("th", { ...r, className: u("sortable", i), scope: "col", onClick: m, children: /* @__PURE__ */ N(V, { sorted: n, align: a.align, children: [
215
- /* @__PURE__ */ e("div", { className: "field-title", children: a.title }),
216
- /* @__PURE__ */ e("div", { className: u("me-1 sort-icon", o) })
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
- H.displayName = "SortableTableTH";
220
- function S({
221
- currentSort: a,
222
- fields: n,
223
- onChangeSort: t
272
+ j.displayName = "SortableTableTH";
273
+ function E({
274
+ currentSort: t,
275
+ onChangeSort: a
224
276
  }) {
225
- const { field: l, ascending: s } = a;
226
- return /* @__PURE__ */ e("thead", { children: /* @__PURE__ */ e("tr", { children: n.map((c, r) => /* @__PURE__ */ e(
227
- H,
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: l === c.field,
282
+ sorted: n === c.field,
231
283
  ascending: s,
232
- className: u(
284
+ className: m(
233
285
  typeof c.className == "function" ? { [`text-${c.align}`]: !!c.align } : c.className
234
286
  ),
235
- onClick: t
287
+ onClick: a
236
288
  },
237
- r
289
+ i
238
290
  )) }) });
239
291
  }
240
- S.displayName = "SortableTableHead";
241
- function E({
242
- fields: a,
243
- data: n,
244
- currentSort: t,
245
- onChangeSort: l,
246
- keyField: s,
247
- size: c = "",
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: m,
301
+ renderRow: r,
251
302
  onSelectRow: o,
252
- selected: b = "",
253
- className: d = "",
254
- tfoot: p,
255
- children: h,
256
- ...y
303
+ selected: u,
304
+ tableHeadProps: b,
305
+ children: d,
306
+ tfoot: f,
307
+ currentSort: h,
308
+ onChangeSort: T,
309
+ ...P
257
310
  }) {
258
- const f = u("table", d, {
259
- [`table-${c}`]: !!c
311
+ const _ = m("table", t, {
312
+ [`table-${a}`]: !!a
260
313
  });
261
- return /* @__PURE__ */ N(D, { className: f, sticky: r, ...y, children: [
262
- /* @__PURE__ */ e(S, { currentSort: t, fields: a, onChangeSort: l }),
263
- !!n.length && /* @__PURE__ */ e(
264
- v,
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
- fields: a,
267
- data: n,
268
- keyField: s,
320
+ data: s,
321
+ keyField: c,
269
322
  rowClassName: i,
270
- renderRow: m,
323
+ renderRow: r,
271
324
  onSelectRow: o,
272
- selected: b
325
+ selected: u
273
326
  }
274
327
  ),
275
- h,
276
- p
328
+ d,
329
+ f
277
330
  ] });
278
331
  }
279
- E.displayName = "SortableTable";
280
- const G = [10, 25, 50, 100, 250, 500, 1e3];
281
- function R({
282
- value: a,
283
- pageValues: n = G,
284
- size: t,
285
- label: l,
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
- ...r
347
+ ...i
289
348
  }) {
290
- const i = j(), m = (d) => c(Number(d.target.value)), o = s ?? u("form-select", { [`form-select-${t}`]: !!t }), b = u("input-group", {
291
- [`input-group-${t}`]: !!t
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__ */ N("div", { className: b, children: [
294
- /* @__PURE__ */ e("label", { className: "input-group-text", htmlFor: i, children: l ?? "Rows" }),
295
- /* @__PURE__ */ e(
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: o,
299
- id: i,
300
- value: a,
301
- onChange: m,
302
- ...r,
303
- children: n.map((d) => /* @__PURE__ */ e("option", { value: d, children: d }, d))
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
- ] }, a);
365
+ ] }, t);
307
366
  }
308
- R.displayName = "RowsPerPage";
309
- function I({
310
- page: a,
311
- rowsPerPage: n,
312
- onChangePage: t,
313
- count: l,
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: r,
317
- className: i,
318
- rowsPerPageProps: m,
319
- ...o
375
+ showLast: i,
376
+ className: r,
377
+ rowsPerPageProps: o,
378
+ ...u
320
379
  }) {
321
- const b = l === 0 ? 0 : a * n + 1, d = Math.min(a * n + n, l), p = n === 0 ? 0 : Math.floor((l - 1) / n), h = u("btn btn-link", { [`btn-${s}`]: !!s });
322
- return /* @__PURE__ */ N("div", { className: u("row g-3 justify-content-end", i), ...o, children: [
323
- !!m && /* @__PURE__ */ e("div", { className: "col-auto", children: /* @__PURE__ */ e(R, { ...m, value: n, size: s }) }),
324
- /* @__PURE__ */ e("div", { className: "col-auto", children: /* @__PURE__ */ N("div", { className: "row g-3 flex-nowrap align-items-baseline", children: [
325
- /* @__PURE__ */ N("div", { className: "col-auto", children: [
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
- l
389
+ n
331
390
  ] }),
332
- c && /* @__PURE__ */ e("div", { className: "col-auto", children: /* @__PURE__ */ e(
391
+ c && /* @__PURE__ */ l("div", { className: "col-auto", children: /* @__PURE__ */ l(
333
392
  "button",
334
393
  {
335
394
  className: h,
336
- disabled: a === 0,
337
- onClick: () => t(0),
395
+ disabled: t === 0,
396
+ onClick: () => e(0),
338
397
  "aria-label": "First page",
339
- children: /* @__PURE__ */ e("span", { className: "bi-chevron-bar-left", "aria-hidden": "true" })
398
+ children: /* @__PURE__ */ l("span", { className: "bi-chevron-bar-left", "aria-hidden": "true" })
340
399
  }
341
400
  ) }),
342
- /* @__PURE__ */ e("div", { className: "col-auto", children: /* @__PURE__ */ e(
401
+ /* @__PURE__ */ l("div", { className: "col-auto", children: /* @__PURE__ */ l(
343
402
  "button",
344
403
  {
345
404
  className: h,
346
- disabled: a === 0,
347
- onClick: () => t(a - 1),
405
+ disabled: t === 0,
406
+ onClick: () => e(t - 1),
348
407
  "aria-label": "Previous page",
349
- children: /* @__PURE__ */ e("span", { className: "bi-chevron-left", "aria-hidden": "true" })
408
+ children: /* @__PURE__ */ l("span", { className: "bi-chevron-left", "aria-hidden": "true" })
350
409
  }
351
410
  ) }),
352
- /* @__PURE__ */ e("div", { className: "col-auto", children: /* @__PURE__ */ e(
411
+ /* @__PURE__ */ l("div", { className: "col-auto", children: /* @__PURE__ */ l(
353
412
  "button",
354
413
  {
355
414
  className: h,
356
- disabled: a >= p,
357
- onClick: () => t(a + 1),
415
+ disabled: t >= f,
416
+ onClick: () => e(t + 1),
358
417
  "aria-label": "Next page",
359
- children: /* @__PURE__ */ e("span", { className: "bi-chevron-right", "aria-hidden": "true" })
418
+ children: /* @__PURE__ */ l("span", { className: "bi-chevron-right", "aria-hidden": "true" })
360
419
  }
361
420
  ) }),
362
- r && /* @__PURE__ */ e("div", { className: "col-auto", children: /* @__PURE__ */ e(
421
+ i && /* @__PURE__ */ l("div", { className: "col-auto", children: /* @__PURE__ */ l(
363
422
  "button",
364
423
  {
365
424
  className: h,
366
- disabled: a >= p,
367
- onClick: () => t(p),
425
+ disabled: t >= f,
426
+ onClick: () => e(f),
368
427
  "aria-label": "Last page",
369
- children: /* @__PURE__ */ e("span", { className: "bi-chevron-bar-right", "aria-hidden": "true" })
428
+ children: /* @__PURE__ */ l("span", { className: "bi-chevron-bar-right", "aria-hidden": "true" })
370
429
  }
371
430
  ) })
372
431
  ] }) })
373
432
  ] });
374
433
  }
375
- I.displayname = "TablePagination";
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
- B as DataTable,
378
- C as DataTableRow,
379
- v as DataTableTBody,
380
- T as DataTableTH,
381
- R as RowsPerPage,
382
- E as SortableTable,
383
- S as SortableTableHead,
384
- H as SortableTableTH,
385
- I as TablePagination,
386
- G as defaultRowsPerPageValues
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