@overdoser/react-toolkit 0.19.0 → 0.20.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.
@@ -1,50 +1,56 @@
1
- import { jsxs as v, jsx as l } from "react/jsx-runtime";
2
- import { useMemo as W, useCallback as y, useEffect as Ue, useState as ke, useRef as H } from "react";
3
- import o from "clsx";
1
+ import { jsxs as v, jsx as a } from "react/jsx-runtime";
2
+ import { useMemo as H, useCallback as y, useEffect as Je, useState as Se, useRef as V } from "react";
3
+ import c from "clsx";
4
4
  import n from "./Table.module.scss.js";
5
- import { useTableSort as Ge } from "./useTableSort.js";
6
- import { Loader as Je } from "../Loader/Loader.js";
7
- import { Skeleton as Qe } from "../Skeleton/Skeleton.js";
8
- import { Checkbox as Ne } from "../inputs/Checkbox/Checkbox.js";
9
- const Ye = 'button, a, input, select, textarea, label, [role="button"], [role="checkbox"], [role="menuitem"], [contenteditable]';
10
- function Ze({ direction: c, sortIndex: f }) {
5
+ import { useTableSort as Qe } from "./useTableSort.js";
6
+ import { Loader as Ye } from "../Loader/Loader.js";
7
+ import { Skeleton as Ze } from "../Skeleton/Skeleton.js";
8
+ import { Checkbox as ke } from "../inputs/Checkbox/Checkbox.js";
9
+ function _(s) {
10
+ return typeof s.key == "string";
11
+ }
12
+ function P(s) {
13
+ return _(s) ? s.key : s.id;
14
+ }
15
+ const ze = 'button, a, input, select, textarea, label, [role="button"], [role="checkbox"], [role="menuitem"], [contenteditable]';
16
+ function et({ direction: s, sortIndex: u }) {
11
17
  return /* @__PURE__ */ v("span", { className: n.sortIndicator, "aria-hidden": "true", children: [
12
- /* @__PURE__ */ l("span", { className: o(n.sortArrow, c === "asc" && n.sortArrowActive), children: "▲" }),
13
- /* @__PURE__ */ l("span", { className: o(n.sortArrow, c === "desc" && n.sortArrowActive), children: "▼" }),
14
- f !== void 0 && f >= 0 && /* @__PURE__ */ l("span", { className: n.sortIndex, children: f + 1 })
18
+ /* @__PURE__ */ a("span", { className: c(n.sortArrow, s === "asc" && n.sortArrowActive), children: "▲" }),
19
+ /* @__PURE__ */ a("span", { className: c(n.sortArrow, s === "desc" && n.sortArrowActive), children: "▼" }),
20
+ u !== void 0 && u >= 0 && /* @__PURE__ */ a("span", { className: n.sortIndex, children: u + 1 })
15
21
  ] });
16
22
  }
17
- function ze({
18
- page: c,
19
- pageSize: f,
20
- totalRows: E,
21
- pageSizeOptions: I = [10, 25, 50, 100],
22
- onPageChange: P,
23
- paginatorClasses: R
23
+ function tt({
24
+ page: s,
25
+ pageSize: u,
26
+ totalRows: K,
27
+ pageSizeOptions: D = [10, 25, 50, 100],
28
+ onPageChange: L,
29
+ paginatorClasses: q
24
30
  }) {
25
- const p = Math.max(1, Math.ceil(E / f)), J = (c - 1) * f + 1, Q = Math.min(c * f, E), Y = W(() => {
31
+ const p = Math.max(1, Math.ceil(K / u)), Z = (s - 1) * u + 1, z = Math.min(s * u, K), ee = H(() => {
26
32
  const i = [];
27
33
  if (p <= 7)
28
- for (let k = 1; k <= p; k++) i.push(k);
34
+ for (let C = 1; C <= p; C++) i.push(C);
29
35
  else {
30
- i.push(1), c > 3 && i.push("ellipsis");
31
- for (let k = Math.max(2, c - 1); k <= Math.min(p - 1, c + 1); k++)
32
- i.push(k);
33
- c < p - 2 && i.push("ellipsis"), i.push(p);
36
+ i.push(1), s > 3 && i.push("ellipsis");
37
+ for (let C = Math.max(2, s - 1); C <= Math.min(p - 1, s + 1); C++)
38
+ i.push(C);
39
+ s < p - 2 && i.push("ellipsis"), i.push(p);
34
40
  }
35
41
  return i;
36
- }, [c, p]);
37
- return /* @__PURE__ */ v("nav", { className: o(n.paginator, R?.paginator), "aria-label": "Table pagination", children: [
42
+ }, [s, p]);
43
+ return /* @__PURE__ */ v("nav", { className: c(n.paginator, q?.paginator), "aria-label": "Table pagination", children: [
38
44
  /* @__PURE__ */ v("div", { className: n.paginatorInfo, children: [
39
- /* @__PURE__ */ l("span", { className: n.paginatorText, children: E > 0 ? `${J}–${Q} of ${E}` : "No results" }),
40
- I.length > 1 && /* @__PURE__ */ l(
45
+ /* @__PURE__ */ a("span", { className: n.paginatorText, children: K > 0 ? `${Z}–${z} of ${K}` : "No results" }),
46
+ D.length > 1 && /* @__PURE__ */ a(
41
47
  "select",
42
48
  {
43
49
  className: n.pageSizeSelect,
44
- value: f,
45
- onChange: (i) => P(1, Number(i.target.value)),
50
+ value: u,
51
+ onChange: (i) => L(1, Number(i.target.value)),
46
52
  "aria-label": "Rows per page",
47
- children: I.map((i) => /* @__PURE__ */ v("option", { value: i, children: [
53
+ children: D.map((i) => /* @__PURE__ */ v("option", { value: i, children: [
48
54
  i,
49
55
  " / page"
50
56
  ] }, i))
@@ -52,38 +58,38 @@ function ze({
52
58
  )
53
59
  ] }),
54
60
  /* @__PURE__ */ v("div", { className: n.paginatorNav, children: [
55
- /* @__PURE__ */ l(
61
+ /* @__PURE__ */ a(
56
62
  "button",
57
63
  {
58
64
  type: "button",
59
- className: o(n.pageButton, R?.pageButton),
60
- disabled: c <= 1,
61
- onClick: () => P(c - 1, f),
65
+ className: c(n.pageButton, q?.pageButton),
66
+ disabled: s <= 1,
67
+ onClick: () => L(s - 1, u),
62
68
  "aria-label": "Previous page",
63
69
  children: "‹"
64
70
  }
65
71
  ),
66
- Y.map(
67
- (i, k) => i === "ellipsis" ? /* @__PURE__ */ l("span", { className: n.pageEllipsis, children: "…" }, `ellipsis-${k}`) : /* @__PURE__ */ l(
72
+ ee.map(
73
+ (i, C) => i === "ellipsis" ? /* @__PURE__ */ a("span", { className: n.pageEllipsis, children: "…" }, `ellipsis-${C}`) : /* @__PURE__ */ a(
68
74
  "button",
69
75
  {
70
76
  type: "button",
71
- className: o(n.pageButton, i === c && n.pageButtonActive, R?.pageButton),
72
- onClick: () => P(i, f),
77
+ className: c(n.pageButton, i === s && n.pageButtonActive, q?.pageButton),
78
+ onClick: () => L(i, u),
73
79
  "aria-label": `Page ${i}`,
74
- "aria-current": i === c ? "page" : void 0,
80
+ "aria-current": i === s ? "page" : void 0,
75
81
  children: i
76
82
  },
77
83
  i
78
84
  )
79
85
  ),
80
- /* @__PURE__ */ l(
86
+ /* @__PURE__ */ a(
81
87
  "button",
82
88
  {
83
89
  type: "button",
84
- className: o(n.pageButton, R?.pageButton),
85
- disabled: c >= p,
86
- onClick: () => P(c + 1, f),
90
+ className: c(n.pageButton, q?.pageButton),
91
+ disabled: s >= p,
92
+ onClick: () => L(s + 1, u),
87
93
  "aria-label": "Next page",
88
94
  children: "›"
89
95
  }
@@ -91,163 +97,163 @@ function ze({
91
97
  ] })
92
98
  ] });
93
99
  }
94
- function et({
95
- data: c,
96
- columns: f,
97
- sortConfig: E,
98
- onSort: I,
99
- multiSort: P = !0,
100
- scrollable: R = !1,
100
+ function nt({
101
+ data: s,
102
+ columns: u,
103
+ sortConfig: K,
104
+ onSort: D,
105
+ multiSort: L = !0,
106
+ scrollable: q = !1,
101
107
  dragScroll: p = !1,
102
- striped: J = !1,
103
- hoverable: Q = !1,
104
- compact: Y = !1,
108
+ striped: Z = !1,
109
+ hoverable: z = !1,
110
+ compact: ee = !1,
105
111
  className: i,
106
- style: k,
107
- rowKey: K,
108
- rowClassName: Z,
109
- rowStyle: z,
110
- emptyMessage: Ce = "No data",
112
+ style: C,
113
+ rowKey: R,
114
+ rowClassName: te,
115
+ rowStyle: ne,
116
+ emptyMessage: xe = "No data",
111
117
  pagination: A,
112
- loading: $ = !1,
113
- loadingRows: Se = 3,
118
+ loading: O = !1,
119
+ loadingRows: Ie = 3,
114
120
  onRowClick: N,
115
121
  selectable: m = !1,
116
- selectedKeys: ce,
117
- defaultSelectedKeys: xe,
118
- onSelectionChange: ee,
119
- isRowSelectable: te,
120
- bulkActions: _,
121
- selectionLabel: de,
122
- columnVisibility: ne,
123
- layout: Ie = "auto",
124
- classes: s
122
+ selectedKeys: ue,
123
+ defaultSelectedKeys: Me,
124
+ onSelectionChange: re,
125
+ isRowSelectable: le,
126
+ bulkActions: F,
127
+ selectionLabel: fe,
128
+ columnVisibility: ae,
129
+ layout: De = "auto",
130
+ classes: o
125
131
  }) {
126
- const q = I !== void 0, Me = R || p, j = W(
127
- () => ne ? f.filter((e) => ne[e.key] !== !1) : f,
128
- [f, ne]
132
+ const W = D !== void 0, Te = q || p, U = H(
133
+ () => ae ? u.filter((e) => ae[P(e)] !== !1) : u,
134
+ [u, ae]
129
135
  ), {
130
- sortedData: Te,
131
- sortConfig: we,
132
- requestSort: ue,
133
- requestMultiSort: fe
134
- } = Ge(c, E), S = q ? E ?? [] : we, M = q ? c : Te, D = W(() => {
135
- if (!A || q) return M;
136
+ sortedData: Ae,
137
+ sortConfig: Be,
138
+ requestSort: he,
139
+ requestMultiSort: pe
140
+ } = Qe(s, K), I = W ? K ?? [] : Be, T = W ? s : Ae, B = H(() => {
141
+ if (!A || W) return T;
136
142
  const e = (A.page - 1) * A.pageSize;
137
- return M.slice(e, e + A.pageSize);
138
- }, [M, A, q]), Ae = A?.totalRows ?? M.length, x = y(
143
+ return T.slice(e, e + A.pageSize);
144
+ }, [T, A, W]), we = A?.totalRows ?? T.length, M = y(
139
145
  (e, t) => {
140
- if (!K) return t;
141
- const r = e[K];
146
+ if (!R) return t;
147
+ const r = e[R];
142
148
  return typeof r == "number" ? r : String(r);
143
149
  },
144
- [K]
150
+ [R]
145
151
  );
146
- Ue(() => {
147
- m && !K && console.error(
152
+ Je(() => {
153
+ m && !R && console.error(
148
154
  "Table: `selectable` needs `rowKey` so selections survive sorting and paging; falling back to the row index."
149
155
  );
150
- }, [m, K]);
151
- const [De, Be] = ke(
152
- () => xe ?? []
153
- ), re = ce !== void 0, d = re ? ce : De, V = W(() => new Set(d), [d]), le = H(null), B = y(
156
+ }, [m, R]);
157
+ const [Ee, Pe] = Se(
158
+ () => Me ?? []
159
+ ), se = ue !== void 0, d = se ? ue : Ee, G = H(() => new Set(d), [d]), ie = V(null), w = y(
154
160
  (e) => {
155
- if (re || Be(e), ee) {
161
+ if (se || Pe(e), re) {
156
162
  const t = new Set(e);
157
- ee(
163
+ re(
158
164
  e,
159
- M.filter((r, h) => t.has(x(r, h)))
165
+ T.filter((r, f) => t.has(M(r, f)))
160
166
  );
161
167
  }
162
168
  },
163
- [re, ee, M, x]
164
- ), X = y(
165
- (e) => te ? te(e) !== !1 : !0,
166
- [te]
167
- ), L = W(
169
+ [se, re, T, M]
170
+ ), j = y(
171
+ (e) => le ? le(e) !== !1 : !0,
172
+ [le]
173
+ ), $ = H(
168
174
  () => {
169
175
  if (!m) return [];
170
176
  const e = [];
171
- return D.forEach((t, r) => {
172
- X(t) && e.push(x(t, r));
177
+ return B.forEach((t, r) => {
178
+ j(t) && e.push(M(t, r));
173
179
  }), e;
174
180
  },
175
- [m, D, X, x]
176
- ), he = L.filter((e) => V.has(e)).length, F = L.length > 0 && he === L.length, Ee = he > 0 && !F, Pe = y(() => {
177
- if (F) {
178
- const e = new Set(L);
179
- B(d.filter((t) => !e.has(t)));
181
+ [m, B, j, M]
182
+ ), me = $.filter((e) => G.has(e)).length, J = $.length > 0 && me === $.length, Ke = me > 0 && !J, Le = y(() => {
183
+ if (J) {
184
+ const e = new Set($);
185
+ w(d.filter((t) => !e.has(t)));
180
186
  } else {
181
187
  const e = [...d], t = new Set(d);
182
- for (const r of L) t.has(r) || e.push(r);
183
- B(e);
188
+ for (const r of $) t.has(r) || e.push(r);
189
+ w(e);
184
190
  }
185
- }, [F, L, d, B]), Ke = y(
191
+ }, [J, $, d, w]), Re = y(
186
192
  (e, t, r) => {
187
- const h = x(e, t), g = r.target.checked, C = r.nativeEvent.shiftKey === !0;
188
- let b = [h];
189
- if (C && le.current !== null) {
190
- const u = D.map((se, oe) => x(se, oe)), T = u.indexOf(le.current), w = u.indexOf(h);
191
- if (T >= 0 && w >= 0) {
192
- const [se, oe] = T < w ? [T, w] : [w, T];
193
+ const f = M(e, t), g = r.target.checked, S = r.nativeEvent.shiftKey === !0;
194
+ let b = [f];
195
+ if (S && ie.current !== null) {
196
+ const h = B.map((E, de) => M(E, de)), k = h.indexOf(ie.current), x = h.indexOf(f);
197
+ if (k >= 0 && x >= 0) {
198
+ const [E, de] = k < x ? [k, x] : [x, k];
193
199
  b = [];
194
- for (let G = se; G <= oe; G++)
195
- X(D[G]) && b.push(u[G]);
200
+ for (let Y = E; Y <= de; Y++)
201
+ j(B[Y]) && b.push(h[Y]);
196
202
  }
197
203
  }
198
- le.current = h;
199
- const a = new Set(b);
204
+ ie.current = f;
205
+ const l = new Set(b);
200
206
  if (g) {
201
- const u = new Set(d), T = [...d];
202
- for (const w of b) u.has(w) || T.push(w);
203
- B(T);
207
+ const h = new Set(d), k = [...d];
208
+ for (const x of b) h.has(x) || k.push(x);
209
+ w(k);
204
210
  } else
205
- B(d.filter((u) => !a.has(u)));
211
+ w(d.filter((h) => !l.has(h)));
206
212
  },
207
- [x, D, X, d, B]
208
- ), pe = y(() => B([]), [B]), Le = W(
209
- () => m && d.length ? M.filter((e, t) => V.has(x(e, t))) : [],
210
- [m, d.length, M, V, x]
211
- ), Re = y(
213
+ [M, B, j, d, w]
214
+ ), ge = y(() => w([]), [w]), $e = H(
215
+ () => m && d.length ? T.filter((e, t) => G.has(M(e, t))) : [],
216
+ [m, d.length, T, G, M]
217
+ ), qe = y(
212
218
  (e, t, r) => {
213
219
  if (!N) return;
214
- const g = r.target?.closest?.(Ye);
220
+ const g = r.target?.closest?.(ze);
215
221
  g && g !== r.currentTarget && r.currentTarget.contains(g) || N(e, t, r);
216
222
  },
217
223
  [N]
218
- ), $e = y(
224
+ ), Oe = y(
219
225
  (e, t, r) => {
220
226
  !N || r.target !== r.currentTarget || (r.key === "Enter" || r.key === " ") && (r.preventDefault(), N(e, t, r));
221
227
  },
222
228
  [N]
223
- ), qe = y(
229
+ ), We = y(
224
230
  (e, t, r) => {
225
- const h = P && (t.ctrlKey || t.metaKey || t.shiftKey), g = r === "asc" ? "desc" : "asc";
226
- if (q)
227
- if (h) {
228
- const C = S.findIndex((a) => a.key === e);
231
+ const f = L && (t.ctrlKey || t.metaKey || t.shiftKey), g = r === "asc" ? "desc" : "asc";
232
+ if (W)
233
+ if (f) {
234
+ const S = I.findIndex((l) => l.key === e);
229
235
  let b;
230
- C === -1 ? b = [...S, { key: e, direction: r }] : S[C].direction === r ? b = S.map(
231
- (a, u) => u === C ? { key: e, direction: g } : a
232
- ) : b = S.filter((a, u) => u !== C), I(b);
236
+ S === -1 ? b = [...I, { key: e, direction: r }] : I[S].direction === r ? b = I.map(
237
+ (l, h) => h === S ? { key: e, direction: g } : l
238
+ ) : b = I.filter((l, h) => h !== S), D(b);
233
239
  } else {
234
- const C = S.find((b) => b.key === e);
235
- C ? C.direction === r ? I([{ key: e, direction: g }]) : I([]) : I([{ key: e, direction: r }]);
240
+ const S = I.find((b) => b.key === e);
241
+ S ? S.direction === r ? D([{ key: e, direction: g }]) : D([]) : D([{ key: e, direction: r }]);
236
242
  }
237
243
  else
238
- h ? fe(e, r) : ue(e, r);
244
+ f ? pe(e, r) : he(e, r);
239
245
  },
240
246
  [
241
- q,
242
- P,
243
- S,
247
+ W,
248
+ L,
244
249
  I,
245
- ue,
246
- fe
250
+ D,
251
+ he,
252
+ pe
247
253
  ]
248
- ), ae = H(null), O = H(null), U = H(!1), [Oe, me] = ke(!1), We = y((e) => {
249
- const t = ae.current;
250
- t && (U.current = !1, !(e.button !== 1 && e.button !== 2) && (t.scrollWidth <= t.clientWidth || (e.button === 1 && e.preventDefault(), O.current = {
254
+ ), oe = V(null), X = V(null), Q = V(!1), [Xe, be] = Se(!1), He = y((e) => {
255
+ const t = oe.current;
256
+ t && (Q.current = !1, !(e.button !== 1 && e.button !== 2) && (t.scrollWidth <= t.clientWidth || (e.button === 1 && e.preventDefault(), X.current = {
251
257
  pointerId: e.pointerId,
252
258
  button: e.button,
253
259
  startX: e.clientX,
@@ -255,142 +261,147 @@ function et({
255
261
  downAt: performance.now(),
256
262
  dragging: !1
257
263
  })));
258
- }, []), Xe = y((e) => {
259
- const t = O.current, r = ae.current;
264
+ }, []), _e = y((e) => {
265
+ const t = X.current, r = oe.current;
260
266
  if (!t || !r || e.pointerId !== t.pointerId) return;
261
- const h = e.clientX - t.startX;
267
+ const f = e.clientX - t.startX;
262
268
  if (!t.dragging) {
263
269
  if (t.button === 2 && performance.now() - t.downAt > 200) {
264
- O.current = null;
270
+ X.current = null;
265
271
  return;
266
272
  }
267
- if (Math.abs(h) < 5) return;
268
- t.dragging = !0, me(!0);
273
+ if (Math.abs(f) < 5) return;
274
+ t.dragging = !0, be(!0);
269
275
  try {
270
276
  r.setPointerCapture(t.pointerId);
271
277
  } catch {
272
278
  }
273
279
  }
274
- r.scrollLeft = t.startScrollLeft - h;
275
- }, []), ge = y((e) => {
276
- const t = O.current;
277
- !t || e.pointerId !== t.pointerId || (O.current = null, t.dragging && (t.button === 2 && (U.current = !0), me(!1)));
278
- }, []), He = y((e) => {
279
- (O.current?.dragging || U.current) && (U.current = !1, e.preventDefault());
280
- }, []), ie = (e) => S.find((r) => r.key === e)?.direction, _e = (e) => {
281
- if (S.length <= 1) return;
282
- const t = S.findIndex((r) => r.key === e);
280
+ r.scrollLeft = t.startScrollLeft - f;
281
+ }, []), ye = y((e) => {
282
+ const t = X.current;
283
+ !t || e.pointerId !== t.pointerId || (X.current = null, t.dragging && (t.button === 2 && (Q.current = !0), be(!1)));
284
+ }, []), je = y((e) => {
285
+ (X.current?.dragging || Q.current) && (Q.current = !1, e.preventDefault());
286
+ }, []), ce = (e) => I.find((r) => r.key === e)?.direction, Ve = (e) => {
287
+ if (I.length <= 1) return;
288
+ const t = I.findIndex((r) => r.key === e);
283
289
  return t >= 0 ? t : void 0;
284
- }, be = H(!1);
285
- $ && (be.current = !0);
286
- const je = j.length + (m ? 1 : 0), ye = $ && D.length === 0, Ve = m && d.length > 0, ve = /* @__PURE__ */ v(
290
+ }, ve = V(!1);
291
+ O && (ve.current = !0);
292
+ const Fe = U.length + (m ? 1 : 0), Ce = O && B.length === 0, Ue = m && d.length > 0, Ne = /* @__PURE__ */ v(
287
293
  "table",
288
294
  {
289
- className: o(
295
+ className: c(
290
296
  n.root,
291
- J && n.striped,
292
- Q && n.hoverable,
293
- Y && n.compact,
294
- Ie === "fixed" && n.layoutFixed,
295
- s?.root,
297
+ Z && n.striped,
298
+ z && n.hoverable,
299
+ ee && n.compact,
300
+ De === "fixed" && n.layoutFixed,
301
+ o?.root,
296
302
  i
297
303
  ),
298
- style: k,
299
- "aria-busy": $ || void 0,
304
+ style: C,
305
+ "aria-busy": O || void 0,
300
306
  children: [
301
- /* @__PURE__ */ l("thead", { children: /* @__PURE__ */ v("tr", { children: [
302
- m && /* @__PURE__ */ l(
307
+ /* @__PURE__ */ a("thead", { children: /* @__PURE__ */ v("tr", { children: [
308
+ m && /* @__PURE__ */ a(
303
309
  "th",
304
310
  {
305
- className: o(n.headerCell, n.selectHeaderCell, s?.headerCell, s?.selectHeaderCell),
306
- children: /* @__PURE__ */ l(
307
- Ne,
311
+ className: c(n.headerCell, n.selectHeaderCell, o?.headerCell, o?.selectHeaderCell),
312
+ children: /* @__PURE__ */ a(
313
+ ke,
308
314
  {
309
315
  "aria-label": "Select all",
310
- checked: F,
311
- indeterminate: Ee,
312
- disabled: L.length === 0,
313
- onChange: Pe
316
+ checked: J,
317
+ indeterminate: Ke,
318
+ disabled: $.length === 0,
319
+ onChange: Le
314
320
  }
315
321
  )
316
322
  }
317
323
  ),
318
- j.map((e) => /* @__PURE__ */ v(
324
+ U.map((e) => /* @__PURE__ */ v(
319
325
  "th",
320
326
  {
321
- className: o(
327
+ className: c(
322
328
  n.headerCell,
323
- e.sortable && n.headerCellSortable,
329
+ _(e) && e.sortable && n.headerCellSortable,
324
330
  e.sticky && n.headerCellSticky,
325
- s?.headerCell
331
+ o?.headerCell
326
332
  ),
327
333
  style: {
328
334
  width: e.width,
329
335
  textAlign: e.align
330
336
  },
331
- onClick: e.sortable ? (t) => qe(e.key, t, e.defaultSortDirection ?? "asc") : void 0,
332
- "aria-sort": e.sortable ? ie(e.key) === "asc" ? "ascending" : ie(e.key) === "desc" ? "descending" : "none" : void 0,
337
+ onClick: _(e) && e.sortable ? (t) => We(e.key, t, e.defaultSortDirection ?? "asc") : void 0,
338
+ "aria-sort": _(e) && e.sortable ? ce(P(e)) === "asc" ? "ascending" : ce(P(e)) === "desc" ? "descending" : "none" : void 0,
333
339
  children: [
334
340
  e.header,
335
- e.sortable && /* @__PURE__ */ l(
336
- Ze,
341
+ _(e) && e.sortable && /* @__PURE__ */ a(
342
+ et,
337
343
  {
338
- direction: ie(e.key),
339
- sortIndex: _e(e.key)
344
+ direction: ce(P(e)),
345
+ sortIndex: Ve(P(e))
340
346
  }
341
347
  )
342
348
  ]
343
349
  },
344
- e.key
350
+ P(e)
345
351
  ))
346
352
  ] }) }),
347
- /* @__PURE__ */ l("tbody", { children: ye ? Array.from({ length: Math.max(1, Se) }, (e, t) => /* @__PURE__ */ v("tr", { className: o(n.row, n.loadingRow, s?.row, s?.loadingRow), "aria-hidden": "true", children: [
348
- m && /* @__PURE__ */ l("td", { className: o(n.cell, n.selectCell, s?.cell) }),
349
- j.map((r) => /* @__PURE__ */ l("td", { className: o(n.cell, s?.cell), children: /* @__PURE__ */ l(Qe, { variant: "text" }) }, r.key))
350
- ] }, `loading-${t}`)) : D.length === 0 ? /* @__PURE__ */ l("tr", { className: n.emptyRow, children: /* @__PURE__ */ l("td", { className: o(n.emptyCell, s?.emptyCell), colSpan: je, children: Ce }) }) : D.map((e, t) => {
351
- const r = K ? String(e[K]) : t, h = m ? x(e, t) : null, g = h !== null && V.has(h), C = typeof Z == "function" ? Z(e, t) : Z, b = typeof z == "function" ? z(e, t) : z;
353
+ /* @__PURE__ */ a("tbody", { children: Ce ? Array.from({ length: Math.max(1, Ie) }, (e, t) => /* @__PURE__ */ v("tr", { className: c(n.row, n.loadingRow, o?.row, o?.loadingRow), "aria-hidden": "true", children: [
354
+ m && /* @__PURE__ */ a("td", { className: c(n.cell, n.selectCell, o?.cell) }),
355
+ U.map((r) => /* @__PURE__ */ a("td", { className: c(n.cell, o?.cell), children: /* @__PURE__ */ a(Ze, { variant: "text" }) }, P(r)))
356
+ ] }, `loading-${t}`)) : B.length === 0 ? /* @__PURE__ */ a("tr", { className: n.emptyRow, children: /* @__PURE__ */ a("td", { className: c(n.emptyCell, o?.emptyCell), colSpan: Fe, children: xe }) }) : B.map((e, t) => {
357
+ const r = R ? String(e[R]) : t, f = m ? M(e, t) : null, g = f !== null && G.has(f), S = typeof te == "function" ? te(e, t) : te, b = typeof ne == "function" ? ne(e, t) : ne;
352
358
  return /* @__PURE__ */ v(
353
359
  "tr",
354
360
  {
355
- className: o(
361
+ className: c(
356
362
  n.row,
357
363
  N && n.rowClickable,
358
364
  g && n.rowSelected,
359
- s?.row,
360
- N && s?.rowClickable,
361
- g && s?.rowSelected,
362
- C
365
+ o?.row,
366
+ N && o?.rowClickable,
367
+ g && o?.rowSelected,
368
+ S
363
369
  ),
364
370
  style: b,
365
371
  tabIndex: N ? 0 : void 0,
366
- onClick: N ? (a) => Re(e, t, a) : void 0,
367
- onKeyDown: N ? (a) => $e(e, t, a) : void 0,
372
+ onClick: N ? (l) => qe(e, t, l) : void 0,
373
+ onKeyDown: N ? (l) => Oe(e, t, l) : void 0,
368
374
  "aria-selected": m ? g : void 0,
369
375
  children: [
370
- m && /* @__PURE__ */ l("td", { className: o(n.cell, n.selectCell, s?.cell, s?.selectCell), children: /* @__PURE__ */ l(
371
- Ne,
376
+ m && /* @__PURE__ */ a("td", { className: c(n.cell, n.selectCell, o?.cell, o?.selectCell), children: /* @__PURE__ */ a(
377
+ ke,
372
378
  {
373
379
  "aria-label": "Select row",
374
380
  checked: g,
375
- disabled: !X(e),
376
- onChange: (a) => Ke(e, t, a)
381
+ disabled: !j(e),
382
+ onChange: (l) => Re(e, t, l)
377
383
  }
378
384
  ) }),
379
- j.map((a) => {
380
- const u = e[a.key], T = typeof a.cellClassName == "function" ? a.cellClassName(u, e, t) : a.cellClassName, w = typeof a.cellStyle == "function" ? a.cellStyle(u, e, t) : a.cellStyle;
381
- return /* @__PURE__ */ l(
385
+ U.map((l) => {
386
+ let h, k, x;
387
+ if (_(l)) {
388
+ const E = e[l.key];
389
+ k = typeof l.cellClassName == "function" ? l.cellClassName(E, e, t) : l.cellClassName, x = typeof l.cellStyle == "function" ? l.cellStyle(E, e, t) : l.cellStyle, h = l.render ? l.render(E, e, t) : E;
390
+ } else
391
+ k = typeof l.cellClassName == "function" ? l.cellClassName(e, t) : l.cellClassName, x = typeof l.cellStyle == "function" ? l.cellStyle(e, t) : l.cellStyle, h = l.render(e, t);
392
+ return /* @__PURE__ */ a(
382
393
  "td",
383
394
  {
384
- className: o(
395
+ className: c(
385
396
  n.cell,
386
- a.sticky && n.cellSticky,
387
- s?.cell,
388
- T
397
+ l.sticky && n.cellSticky,
398
+ o?.cell,
399
+ k
389
400
  ),
390
- style: { textAlign: a.align, ...w },
391
- children: a.render ? a.render(u, e, t) : u
401
+ style: { textAlign: l.align, ...x },
402
+ children: h
392
403
  },
393
- a.key
404
+ P(l)
394
405
  );
395
406
  })
396
407
  ]
@@ -400,46 +411,46 @@ function et({
400
411
  }) })
401
412
  ]
402
413
  }
403
- ), Fe = { selectedKeys: d, selectedRows: Le, clear: pe };
414
+ ), Ge = { selectedKeys: d, selectedRows: $e, clear: ge };
404
415
  return /* @__PURE__ */ v(
405
416
  "div",
406
417
  {
407
- ref: ae,
408
- className: o(
418
+ ref: oe,
419
+ className: c(
409
420
  n.wrapper,
410
- Me && n.scrollable,
411
- Oe && n.dragging,
412
- s?.wrapper
421
+ Te && n.scrollable,
422
+ Xe && n.dragging,
423
+ o?.wrapper
413
424
  ),
414
- onPointerDown: p ? We : void 0,
415
- onPointerMove: p ? Xe : void 0,
416
- onPointerUp: p ? ge : void 0,
417
- onPointerCancel: p ? ge : void 0,
418
- onContextMenu: p ? He : void 0,
425
+ onPointerDown: p ? He : void 0,
426
+ onPointerMove: p ? _e : void 0,
427
+ onPointerUp: p ? ye : void 0,
428
+ onPointerCancel: p ? ye : void 0,
429
+ onContextMenu: p ? je : void 0,
419
430
  children: [
420
- Ve && /* @__PURE__ */ v("div", { className: o(n.bulkBar, s?.bulkBar), role: "region", "aria-label": "Selected rows", children: [
421
- /* @__PURE__ */ l("span", { className: o(n.bulkLabel, s?.bulkLabel), children: de ? de(d.length) : `${d.length} selected` }),
422
- /* @__PURE__ */ l("button", { type: "button", className: o(n.bulkClear, s?.bulkClear), onClick: pe, children: "Clear" }),
423
- _ !== void 0 && /* @__PURE__ */ l("div", { className: o(n.bulkActions, s?.bulkActions), children: typeof _ == "function" ? _(Fe) : _ })
431
+ Ue && /* @__PURE__ */ v("div", { className: c(n.bulkBar, o?.bulkBar), role: "region", "aria-label": "Selected rows", children: [
432
+ /* @__PURE__ */ a("span", { className: c(n.bulkLabel, o?.bulkLabel), children: fe ? fe(d.length) : `${d.length} selected` }),
433
+ /* @__PURE__ */ a("button", { type: "button", className: c(n.bulkClear, o?.bulkClear), onClick: ge, children: "Clear" }),
434
+ F !== void 0 && /* @__PURE__ */ a("div", { className: c(n.bulkActions, o?.bulkActions), children: typeof F == "function" ? F(Ge) : F })
424
435
  ] }),
425
- $ !== void 0 && ($ || be.current) ? (
436
+ O !== void 0 && (O || ve.current) ? (
426
437
  // Once a consumer has used `loading`, keep the wrapper so toggling it
427
438
  // doesn't remount the table (focus, scroll position).
428
- /* @__PURE__ */ l(Je, { loading: $ && !ye, delay: 150, backdrop: "dim", classes: { root: n.loaderWrap }, children: ve })
429
- ) : ve,
430
- A && /* @__PURE__ */ l(
431
- ze,
439
+ /* @__PURE__ */ a(Ye, { loading: O && !Ce, delay: 150, backdrop: "dim", classes: { root: n.loaderWrap }, children: Ne })
440
+ ) : Ne,
441
+ A && /* @__PURE__ */ a(
442
+ tt,
432
443
  {
433
444
  ...A,
434
- totalRows: Ae,
435
- paginatorClasses: { paginator: s?.paginator, pageButton: s?.pageButton }
445
+ totalRows: we,
446
+ paginatorClasses: { paginator: o?.paginator, pageButton: o?.pageButton }
436
447
  }
437
448
  )
438
449
  ]
439
450
  }
440
451
  );
441
452
  }
442
- const ct = et;
453
+ const ut = nt;
443
454
  export {
444
- ct as Table
455
+ ut as Table
445
456
  };