@bfrs/agentic-components 0.7.9 → 0.8.1

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,16 +1,16 @@
1
- import { jsxs as k, jsx as a } from "react/jsx-runtime";
2
- import { ArrowsDownUp as Fe } from "../../../node_modules/@phosphor-icons/react/dist/csr/ArrowsDownUp.es.js";
3
- import { CaretDown as ze } from "../../../node_modules/@phosphor-icons/react/dist/csr/CaretDown.es.js";
1
+ import { jsxs as m, jsx as i } from "react/jsx-runtime";
2
+ import { ArrowsDownUp as ze } from "../../../node_modules/@phosphor-icons/react/dist/csr/ArrowsDownUp.es.js";
3
+ import { CaretDown as Fe } from "../../../node_modules/@phosphor-icons/react/dist/csr/CaretDown.es.js";
4
4
  import { CaretUp as Le } from "../../../node_modules/@phosphor-icons/react/dist/csr/CaretUp.es.js";
5
- import { useRef as Ne, useState as D, useMemo as M, useEffect as Mt, useCallback as Ee, useLayoutEffect as He } from "react";
5
+ import { useRef as Ne, useState as D, useMemo as M, useEffect as It, useCallback as Ee, useLayoutEffect as He } from "react";
6
6
  import l from "@emotion/styled";
7
7
  import { clsx as Ue } from "../../../node_modules/clsx/dist/clsx.js";
8
8
  import { twRing as Ct } from "../../../lib/emotionTw.js";
9
- import { TableEmptyState as je } from "./TableEmptyState.js";
10
- import { TableErrorState as Ve } from "./TableErrorState.js";
9
+ import { TableEmptyStateContent as Ve } from "./TableEmptyState.js";
10
+ import { TableErrorState as je } from "./TableErrorState.js";
11
11
  import { TablePagination as $e } from "./TablePagination.js";
12
12
  import { TableSkeleton as Ke } from "./TableSkeleton.js";
13
- const Jt = typeof window > "u" ? Mt : He, Qt = 144, Wt = 220, B = 44, Ye = 146, qe = 3, Ge = {
13
+ const Jt = typeof window > "u" ? It : He, Qt = 144, Tt = 220, B = 44, Ye = 146, qe = 3, Ge = {
14
14
  height: "38px",
15
15
  paddingLeft: "1.25rem",
16
16
  paddingRight: "1.25rem",
@@ -22,7 +22,7 @@ const Jt = typeof window > "u" ? Mt : He, Qt = 144, Wt = 220, B = 44, Ye = 146,
22
22
  paddingRight: "1.25rem",
23
23
  paddingTop: "1rem",
24
24
  paddingBottom: "1rem"
25
- }, At = {
25
+ }, Wt = {
26
26
  fontSize: "12px",
27
27
  fontWeight: 700,
28
28
  letterSpacing: ".24px",
@@ -40,7 +40,7 @@ const Jt = typeof window > "u" ? Mt : He, Qt = 144, Wt = 220, B = 44, Ye = 146,
40
40
  "--tw-shadow": "-3px 0 4px rgba(0,0,0,.04)",
41
41
  "--tw-shadow-colored": "-3px 0 4px var(--tw-shadow-color)",
42
42
  boxShadow: "var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)"
43
- }, F = {
43
+ }, z = {
44
44
  "--tw-bg-opacity": "1",
45
45
  backgroundColor: "hsl(var(--bfrs-color-surface-app) / var(--tw-bg-opacity, 1))"
46
46
  }, Xe = /* @__PURE__ */ l("div", {
@@ -65,7 +65,15 @@ const Jt = typeof window > "u" ? Mt : He, Qt = 144, Wt = 220, B = 44, Ye = 146,
65
65
  minHeight: "0px",
66
66
  flex: "1 1 auto",
67
67
  overflow: "auto"
68
- }), _e = /* @__PURE__ */ l("table", {
68
+ }), _e = /* @__PURE__ */ l("div", {
69
+ label: "AgenticDataTable-stateViewport"
70
+ })({
71
+ position: "sticky",
72
+ left: 0,
73
+ width: "100%",
74
+ minWidth: "0px",
75
+ boxSizing: "border-box"
76
+ }), Oe = /* @__PURE__ */ l("table", {
69
77
  label: "AgenticDataTable-table"
70
78
  })({
71
79
  width: "100%",
@@ -74,7 +82,7 @@ const Jt = typeof window > "u" ? Mt : He, Qt = 144, Wt = 220, B = 44, Ye = 146,
74
82
  "--tw-border-spacing-y": "0px",
75
83
  borderSpacing: "var(--tw-border-spacing-x) var(--tw-border-spacing-y)",
76
84
  textAlign: "left"
77
- }), Oe = /* @__PURE__ */ l("thead", {
85
+ }), Ce = /* @__PURE__ */ l("thead", {
78
86
  label: "AgenticDataTable-head",
79
87
  shouldForwardProp: (e) => e !== "ownerState"
80
88
  })(({ ownerState: e }) => [
@@ -83,20 +91,20 @@ const Jt = typeof window > "u" ? Mt : He, Qt = 144, Wt = 220, B = 44, Ye = 146,
83
91
  top: 0,
84
92
  zIndex: 30
85
93
  }
86
- ]), Ce = /* @__PURE__ */ l("tr", {
94
+ ]), tr = /* @__PURE__ */ l("tr", {
87
95
  label: "AgenticDataTable-headerRow"
88
- })(F), tr = {
96
+ })(z), er = {
89
97
  // Positioning context so the pin button can float without reserving header width.
90
98
  position: "relative",
91
99
  borderBottomWidth: "1px",
92
100
  "--tw-border-opacity": "1",
93
101
  borderColor: "hsl(var(--bfrs-color-border-strong) / var(--tw-border-opacity, 1))",
94
- ...F
95
- }, O = /* @__PURE__ */ l("th", {
102
+ ...z
103
+ }, _ = /* @__PURE__ */ l("th", {
96
104
  label: "AgenticDataTable-headerCell",
97
105
  shouldForwardProp: (e) => e !== "ownerState"
98
106
  })(({ ownerState: e }) => [
99
- tr,
107
+ er,
100
108
  e.kind === "selection" && {
101
109
  textAlign: "center",
102
110
  "--tw-text-opacity": "1",
@@ -104,16 +112,16 @@ const Jt = typeof window > "u" ? Mt : He, Qt = 144, Wt = 220, B = 44, Ye = 146,
104
112
  },
105
113
  e.kind === "leading" && {
106
114
  verticalAlign: "middle",
107
- ...At,
115
+ ...Wt,
108
116
  "&:hover button[title]": { opacity: 1 }
109
117
  },
110
118
  e.kind === "data" && {
111
119
  borderLeftWidth: "2px",
112
120
  borderLeftColor: "transparent",
113
- ...At,
121
+ ...Wt,
114
122
  "&:hover button[title]": { opacity: 1 }
115
123
  },
116
- e.kind === "actions" && At,
124
+ e.kind === "actions" && Wt,
117
125
  Ge,
118
126
  e.sortable && {
119
127
  "&:hover": {
@@ -150,7 +158,7 @@ const Jt = typeof window > "u" ? Mt : He, Qt = 144, Wt = 220, B = 44, Ye = 146,
150
158
  },
151
159
  e.align === "right" && { justifyContent: "flex-end" },
152
160
  e.align === "center" && { justifyContent: "center" }
153
- ]), er = /* @__PURE__ */ l("button", {
161
+ ]), rr = /* @__PURE__ */ l("button", {
154
162
  label: "AgenticDataTable-sortButton"
155
163
  })({
156
164
  display: "inline-flex",
@@ -164,7 +172,7 @@ const Jt = typeof window > "u" ? Mt : He, Qt = 144, Wt = 220, B = 44, Ye = 146,
164
172
  ...Ct("2px", "hsl(var(--bfrs-color-border-focus) / var(--tw-ring-opacity, 1))"),
165
173
  "--tw-ring-opacity": "1"
166
174
  }
167
- }), Bt = /* @__PURE__ */ l("span", {
175
+ }), At = /* @__PURE__ */ l("span", {
168
176
  label: "AgenticDataTable-truncate",
169
177
  shouldForwardProp: (e) => e !== "ownerState"
170
178
  })(({ ownerState: e }) => ({
@@ -172,7 +180,7 @@ const Jt = typeof window > "u" ? Mt : He, Qt = 144, Wt = 220, B = 44, Ye = 146,
172
180
  overflow: e.overflow === "visible" ? "visible" : "hidden",
173
181
  textOverflow: e.overflow === "visible" ? "clip" : "ellipsis",
174
182
  whiteSpace: "nowrap"
175
- })), rr = /* @__PURE__ */ l(Fe, {
183
+ })), or = /* @__PURE__ */ l(ze, {
176
184
  label: "AgenticDataTable-sortIdleIcon"
177
185
  })({
178
186
  "--tw-text-opacity": "1",
@@ -231,7 +239,7 @@ const Jt = typeof window > "u" ? Mt : He, Qt = 144, Wt = 220, B = 44, Ye = 146,
231
239
  color: "hsl(var(--bfrs-color-text-primary) / var(--tw-text-opacity, 1))"
232
240
  }
233
241
  }
234
- ]), or = /* @__PURE__ */ l("tr", {
242
+ ]), ar = /* @__PURE__ */ l("tr", {
235
243
  label: "AgenticDataTable-row",
236
244
  shouldForwardProp: (e) => e !== "ownerState"
237
245
  })(({ ownerState: e }) => [
@@ -241,12 +249,12 @@ const Jt = typeof window > "u" ? Mt : He, Qt = 144, Wt = 220, B = 44, Ye = 146,
241
249
  transitionProperty: "color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter",
242
250
  transitionTimingFunction: "cubic-bezier(.4,0,.2,1)",
243
251
  transitionDuration: ".15s",
244
- "&:hover": F,
245
- "&:hover > td": F
252
+ "&:hover": z,
253
+ "&:hover > td": z
246
254
  },
247
- e.selected && F,
255
+ e.selected && z,
248
256
  e.clickable && { cursor: "pointer" }
249
- ]), C = /* @__PURE__ */ l("td", {
257
+ ]), O = /* @__PURE__ */ l("td", {
250
258
  label: "AgenticDataTable-cell",
251
259
  shouldForwardProp: (e) => e !== "ownerState"
252
260
  })(({ ownerState: e }) => [
@@ -269,7 +277,7 @@ const Jt = typeof window > "u" ? Mt : He, Qt = 144, Wt = 220, B = 44, Ye = 146,
269
277
  color: "hsl(var(--bfrs-color-text-secondary) / var(--tw-text-opacity, 1))"
270
278
  },
271
279
  Je,
272
- e.selected && F,
280
+ e.selected && z,
273
281
  e.kind === "data" && { fontSize: "12px" },
274
282
  e.cellTextSize === "compact" && {
275
283
  fontSize: "12px",
@@ -279,7 +287,7 @@ const Jt = typeof window > "u" ? Mt : He, Qt = 144, Wt = 220, B = 44, Ye = 146,
279
287
  },
280
288
  e.edgeShadow && te,
281
289
  e.actionsShadow && Re
282
- ]), tt = /* @__PURE__ */ l("input", {
290
+ ]), C = /* @__PURE__ */ l("input", {
283
291
  label: "AgenticDataTable-checkbox"
284
292
  })({
285
293
  width: ".75rem",
@@ -293,13 +301,13 @@ const Jt = typeof window > "u" ? Mt : He, Qt = 144, Wt = 220, B = 44, Ye = 146,
293
301
  display: "flex",
294
302
  alignItems: "center",
295
303
  justifyContent: "center"
296
- }), ar = /* @__PURE__ */ l("div", {
304
+ }), ir = /* @__PURE__ */ l("div", {
297
305
  label: "AgenticDataTable-leadingLayout"
298
306
  })({
299
307
  display: "flex",
300
308
  alignItems: "center",
301
309
  gap: ".75rem"
302
- }), ir = /* @__PURE__ */ l("div", {
310
+ }), nr = /* @__PURE__ */ l("div", {
303
311
  label: "AgenticDataTable-leadingContent"
304
312
  })({
305
313
  minWidth: "0px",
@@ -312,7 +320,7 @@ function ee(e, o) {
312
320
  function _t(e, o) {
313
321
  return o.sortValue ? o.sortValue(e) : ee(e, o);
314
322
  }
315
- function nr(e, o) {
323
+ function sr(e, o) {
316
324
  return typeof e == "number" && typeof o == "number" ? e - o : String(e ?? "").localeCompare(String(o ?? ""), void 0, { numeric: !0, sensitivity: "base" });
317
325
  }
318
326
  function Ot(e, o) {
@@ -323,175 +331,175 @@ function Ot(e, o) {
323
331
  }
324
332
  return o;
325
333
  }
326
- function Pt(e, o) {
327
- const p = e.filter((w) => o.includes(w)), b = o.filter((w) => !p.includes(w));
328
- return [...p, ...b];
334
+ function Bt(e, o) {
335
+ const p = e.filter((w) => o.includes(w)), h = o.filter((w) => !p.includes(w));
336
+ return [...p, ...h];
329
337
  }
330
- function sr(e, o, p) {
331
- const b = [...e], w = b.indexOf(o), P = b.indexOf(p);
332
- return w === -1 || P === -1 || w === P ? e : (b.splice(w, 1), b.splice(P, 0, o), b);
338
+ function cr(e, o, p) {
339
+ const h = [...e], w = h.indexOf(o), F = h.indexOf(p);
340
+ return w === -1 || F === -1 || w === F ? e : (h.splice(w, 1), h.splice(F, 0, o), h);
333
341
  }
334
- function cr(e) {
342
+ function lr(e) {
335
343
  return Math.round(e * 100) / 100;
336
344
  }
337
- function It(e, o) {
345
+ function Pt(e, o) {
338
346
  return e && e > 0 ? e : o;
339
347
  }
340
- function lr(e, o) {
341
- return !e || e.columns.length !== o.columns.length || Math.abs(e.selection - o.selection) > 0.5 || Math.abs(e.leading - o.leading) > 0.5 || Math.abs(e.rowActions - o.rowActions) > 0.5 ? !1 : e.columns.every((p, b) => Math.abs(p - o.columns[b]) <= 0.5);
348
+ function dr(e, o) {
349
+ return !e || e.columns.length !== o.columns.length || Math.abs(e.selection - o.selection) > 0.5 || Math.abs(e.leading - o.leading) > 0.5 || Math.abs(e.rowActions - o.rowActions) > 0.5 ? !1 : e.columns.every((p, h) => Math.abs(p - o.columns[h]) <= 0.5);
342
350
  }
343
- function kr({
351
+ function Dr({
344
352
  data: e,
345
353
  columns: o,
346
354
  getRowId: p,
347
- loading: b,
355
+ loading: h,
348
356
  error: w,
349
- emptyState: P,
357
+ emptyState: F,
350
358
  // Default no-data view is a two-line message (title + description). Consumers
351
359
  // can override either line, or replace the whole thing via `emptyState`.
352
360
  emptyTitle: re = "No records found",
353
361
  emptyDescription: oe = "There's nothing to show here yet.",
354
- pagination: Ft,
355
- enableSorting: et = !0,
356
- sorting: z,
357
- defaultSorting: rt = null,
358
- onSortingChange: ot,
359
- visibleColumnIds: at,
360
- columnOrder: m,
361
- defaultColumnOrder: it,
362
- onColumnOrderChange: nt,
362
+ pagination: Mt,
363
+ enableSorting: tt = !0,
364
+ sorting: L,
365
+ defaultSorting: et = null,
366
+ onSortingChange: rt,
367
+ visibleColumnIds: ot,
368
+ columnOrder: k,
369
+ defaultColumnOrder: at,
370
+ onColumnOrderChange: it,
363
371
  enableColumnPinning: Y = !0,
364
- pinnedColumnCount: L,
365
- defaultPinnedColumnCount: st = 0,
366
- onPinnedColumnCountChange: ct,
367
- pinLeadingColumn: N,
368
- defaultPinLeadingColumn: lt = !1,
369
- onPinLeadingColumnChange: dt,
370
- enableColumnReordering: E = !0,
372
+ pinnedColumnCount: N,
373
+ defaultPinnedColumnCount: nt = 0,
374
+ onPinnedColumnCountChange: st,
375
+ pinLeadingColumn: E,
376
+ defaultPinLeadingColumn: ct = !1,
377
+ onPinLeadingColumnChange: lt,
378
+ enableColumnReordering: H = !0,
371
379
  resetKey: zt,
372
- showSortIcon: Lt = "always",
380
+ showSortIcon: Ft = "always",
373
381
  leadingColumn: n,
374
382
  rowActions: T,
375
383
  rowActionsHeader: ae = "Actions",
376
384
  rowActionsWidth: q = Ye,
377
385
  stickyRowActions: G = !!T,
378
386
  selection: J,
379
- selectedRowIds: H = [],
387
+ selectedRowIds: U = [],
380
388
  onSelectedRowIdsChange: Q,
381
- stickyHeader: pt = !0,
389
+ stickyHeader: dt = !0,
382
390
  fill: ie = !1,
383
- headerTextOverflow: ht = "truncate",
391
+ headerTextOverflow: pt = "truncate",
384
392
  cellTextSize: R = "default",
385
393
  minWidth: ne = "100%",
386
- maxHeight: Nt,
394
+ maxHeight: Lt,
387
395
  className: se,
388
396
  scrollerClassName: ce,
389
397
  tableClassName: le,
390
398
  headerClassName: de,
391
- rowClassName: bt,
392
- cellClassName: ft,
399
+ rowClassName: ht,
400
+ cellClassName: bt,
393
401
  onRowClick: X,
394
402
  "aria-label": pe = "Data table"
395
403
  }) {
396
- const wt = Ne(null), [he, Et] = D(rt), [yt, vt] = D(() => it ?? o.map((t) => t.id)), [be, Ht] = D(st), [fe, Ut] = D(lt), [Z, U] = D(null), [we, j] = D(null), [ye, jt] = D(null), [y, ve] = D(null), h = et ? z === void 0 ? he : z : null, W = M(() => o.map((t) => t.id), [o]), Vt = M(() => new Map(o.map((t) => [t.id, t])), [o]);
397
- Mt(() => {
398
- m === void 0 && vt((t) => Pt(t, W));
399
- }, [W, m]), Mt(() => {
400
- zt !== void 0 && (z === void 0 && Et(rt), m === void 0 && vt(Pt(it ?? W, W)), L === void 0 && Ht(st), N === void 0 && Ut(lt), U(null), j(null));
404
+ const ft = Ne(null), [he, Nt] = D(et), [wt, yt] = D(() => at ?? o.map((t) => t.id)), [be, Et] = D(nt), [fe, Ht] = D(ct), [Z, V] = D(null), [we, j] = D(null), [ye, Ut] = D(null), [y, ve] = D(null), b = tt ? L === void 0 ? he : L : null, W = M(() => o.map((t) => t.id), [o]), Vt = M(() => new Map(o.map((t) => [t.id, t])), [o]);
405
+ It(() => {
406
+ k === void 0 && yt((t) => Bt(t, W));
407
+ }, [W, k]), It(() => {
408
+ zt !== void 0 && (L === void 0 && Nt(et), k === void 0 && yt(Bt(at ?? W, W)), N === void 0 && Et(nt), E === void 0 && Ht(ct), V(null), j(null));
401
409
  }, [
402
410
  W,
403
- m,
404
- it,
405
- st,
406
- lt,
407
- rt,
411
+ k,
412
+ at,
413
+ nt,
414
+ ct,
415
+ et,
416
+ E,
408
417
  N,
409
- L,
410
418
  zt,
411
- z
419
+ L
412
420
  ]);
413
- const gt = M(() => Pt(m ?? yt, W).map((r) => Vt.get(r)).filter((r) => !!r), [Vt, W, m, yt]), f = M(() => {
414
- if (!at) return gt;
415
- const t = new Set(at);
416
- return gt.filter((r) => t.has(r.id));
417
- }, [gt, at]), ge = M(
421
+ const vt = M(() => Bt(k ?? wt, W).map((r) => Vt.get(r)).filter((r) => !!r), [Vt, W, k, wt]), f = M(() => {
422
+ if (!ot) return vt;
423
+ const t = new Set(ot);
424
+ return vt.filter((r) => t.has(r.id));
425
+ }, [vt, ot]), ge = M(
418
426
  () => f.map((t) => Ot(t.width ?? t.minWidth, Qt)),
419
427
  [f]
420
428
  ), u = Y ? Math.min(
421
429
  f.length,
422
- Math.max(0, L === void 0 ? be : L)
423
- ) : 0, x = !!n && ((Y && n ? N === void 0 ? fe : N : !1) || u > 0), $t = x && u === 0, I = !!(J && !n), A = I && u > 0, ue = Ot((n == null ? void 0 : n.width) ?? (n == null ? void 0 : n.minWidth), Wt), ut = (y == null ? void 0 : y.columns.length) === f.length ? y.columns : void 0, xe = It(y == null ? void 0 : y.selection, B), Se = It(y == null ? void 0 : y.leading, ue), me = (A ? xe : 0) + (x ? Se : 0), _ = f.length + (I ? 1 : 0) + (n ? 1 : 0) + (T ? 1 : 0), xt = (t, r) => (p == null ? void 0 : p(t, r)) ?? String(t.id ?? r), St = Ee(() => {
430
+ Math.max(0, N === void 0 ? be : N)
431
+ ) : 0, x = !!n && ((Y && n ? E === void 0 ? fe : E : !1) || u > 0), jt = x && u === 0, P = !!(J && !n), A = P && u > 0, ue = Ot((n == null ? void 0 : n.width) ?? (n == null ? void 0 : n.minWidth), Tt), gt = (y == null ? void 0 : y.columns.length) === f.length ? y.columns : void 0, xe = Pt(y == null ? void 0 : y.selection, B), Se = Pt(y == null ? void 0 : y.leading, ue), me = (A ? xe : 0) + (x ? Se : 0), $t = f.length + (P ? 1 : 0) + (n ? 1 : 0) + (T ? 1 : 0), ut = (t, r) => (p == null ? void 0 : p(t, r)) ?? String(t.id ?? r), xt = Ee(() => {
424
432
  var S, v;
425
- const t = (v = (S = wt.current) == null ? void 0 : S.tHead) == null ? void 0 : v.rows[0];
433
+ const t = (v = (S = ft.current) == null ? void 0 : S.tHead) == null ? void 0 : v.rows[0];
426
434
  if (!t) return;
427
435
  const r = Array.from(t.cells);
428
436
  let s = 0;
429
- const i = () => {
437
+ const a = () => {
430
438
  var c;
431
- return cr(((c = r[s++]) == null ? void 0 : c.getBoundingClientRect().width) ?? 0);
439
+ return lr(((c = r[s++]) == null ? void 0 : c.getBoundingClientRect().width) ?? 0);
432
440
  }, d = {
433
- selection: I ? i() : 0,
434
- leading: n ? i() : 0,
435
- columns: f.map(() => i()),
436
- rowActions: T ? i() : 0
441
+ selection: P ? a() : 0,
442
+ leading: n ? a() : 0,
443
+ columns: f.map(() => a()),
444
+ rowActions: T ? a() : 0
437
445
  };
438
- ve((c) => lr(c, d) ? c : d);
439
- }, [f, I, n, T]);
446
+ ve((c) => dr(c, d) ? c : d);
447
+ }, [f, P, n, T]);
440
448
  Jt(() => {
441
- St();
449
+ xt();
442
450
  }), Jt(() => {
443
- var s, i;
444
- const t = wt.current;
451
+ var s, a;
452
+ const t = ft.current;
445
453
  if (!t || typeof window > "u" || typeof window.ResizeObserver > "u") return;
446
- const r = new window.ResizeObserver(St);
447
- return r.observe(t), Array.from(((i = (s = t.tHead) == null ? void 0 : s.rows[0]) == null ? void 0 : i.cells) ?? []).forEach((d) => r.observe(d)), () => r.disconnect();
448
- }, [St]);
449
- const V = M(() => {
450
- if (!h) return e;
451
- const t = o.find((r) => r.id === h.columnId);
454
+ const r = new window.ResizeObserver(xt);
455
+ return r.observe(t), Array.from(((a = (s = t.tHead) == null ? void 0 : s.rows[0]) == null ? void 0 : a.cells) ?? []).forEach((d) => r.observe(d)), () => r.disconnect();
456
+ }, [xt]);
457
+ const I = M(() => {
458
+ if (!b) return e;
459
+ const t = o.find((r) => r.id === b.columnId);
452
460
  return t ? [...e].sort((r, s) => {
453
- const i = nr(_t(r, t), _t(s, t));
454
- return h.direction === "asc" ? i : -i;
461
+ const a = sr(_t(r, t), _t(s, t));
462
+ return b.direction === "asc" ? a : -a;
455
463
  }) : e;
456
- }, [h, o, e]), mt = V.length > 0 && V.every((t, r) => H.includes(xt(t, r))), ke = (t) => {
457
- if (!et || !t.sortable) return;
458
- const r = (h == null ? void 0 : h.columnId) === t.id ? { columnId: t.id, direction: h.direction === "asc" ? "desc" : "asc" } : { columnId: t.id, direction: "asc" };
459
- z === void 0 && Et(r), ot == null || ot(r);
464
+ }, [b, o, e]), St = I.length > 0 && I.every((t, r) => U.includes(ut(t, r))), ke = (t) => {
465
+ if (!tt || !t.sortable) return;
466
+ const r = (b == null ? void 0 : b.columnId) === t.id ? { columnId: t.id, direction: b.direction === "asc" ? "desc" : "asc" } : { columnId: t.id, direction: "asc" };
467
+ L === void 0 && Nt(r), rt == null || rt(r);
460
468
  }, De = (t) => {
461
- m === void 0 && vt(t), nt == null || nt(t);
462
- }, kt = (t) => {
469
+ k === void 0 && yt(t), it == null || it(t);
470
+ }, mt = (t) => {
463
471
  const r = Math.min(f.length, Math.max(0, t));
464
- L === void 0 && Ht(r), ct == null || ct(r);
472
+ N === void 0 && Et(r), st == null || st(r);
465
473
  }, Kt = (t) => {
466
- N === void 0 && Ut(t), dt == null || dt(t);
474
+ E === void 0 && Ht(t), lt == null || lt(t);
467
475
  }, Yt = () => {
468
- Q && Q(mt ? [] : V.map((t, r) => xt(t, r)));
476
+ Q && Q(St ? [] : I.map((t, r) => ut(t, r)));
469
477
  }, qt = (t) => {
470
- Q && Q(H.includes(t) ? H.filter((r) => r !== t) : [...H, t]);
478
+ Q && Q(U.includes(t) ? U.filter((r) => r !== t) : [...U, t]);
471
479
  }, Gt = (t) => {
472
480
  let r = me;
473
481
  for (let s = 0; s < t; s += 1)
474
- r += It(ut == null ? void 0 : ut[s], ge[s] ?? Qt);
482
+ r += Pt(gt == null ? void 0 : gt[s], ge[s] ?? Qt);
475
483
  return r;
476
484
  }, Te = (t, r) => {
477
- E && (U(r), t.dataTransfer.effectAllowed = "move");
485
+ H && (V(r), t.dataTransfer.effectAllowed = "move");
478
486
  }, We = (t, r) => {
479
- E && (t.preventDefault(), j(r));
487
+ H && (t.preventDefault(), j(r));
480
488
  }, Ae = (t, r) => {
481
489
  var d, S;
482
- if (!E) return;
490
+ if (!H) return;
483
491
  if (t.preventDefault(), Z === null || Z === r) {
484
- U(null), j(null);
492
+ V(null), j(null);
485
493
  return;
486
494
  }
487
- const s = (d = f[Z]) == null ? void 0 : d.id, i = (S = f[r]) == null ? void 0 : S.id;
488
- s && i && (De(sr(m ?? yt, s, i)), Z < u && kt(Math.min(u, r + 1))), U(null), j(null);
489
- }, Dt = (t, r = 20) => ({
495
+ const s = (d = f[Z]) == null ? void 0 : d.id, a = (S = f[r]) == null ? void 0 : S.id;
496
+ s && a && (De(cr(k ?? wt, s, a)), Z < u && mt(Math.min(u, r + 1))), V(null), j(null);
497
+ }, kt = (t, r = 20) => ({
490
498
  position: "sticky",
491
499
  left: t,
492
- ...pt ? { top: 0 } : {},
500
+ ...dt ? { top: 0 } : {},
493
501
  zIndex: r
494
- }), Tt = (t, r = 10) => ({
502
+ }), Dt = (t, r = 10) => ({
495
503
  position: "sticky",
496
504
  left: t,
497
505
  zIndex: r
@@ -502,191 +510,194 @@ function kr({
502
510
  } : {}, Pe = G ? {
503
511
  position: "sticky",
504
512
  right: 0,
505
- ...pt ? { top: 0 } : {},
513
+ ...dt ? { top: 0 } : {},
506
514
  zIndex: 24
507
515
  } : {};
508
- return /* @__PURE__ */ k(Xe, { className: se, ownerState: { fill: ie }, children: [
509
- /* @__PURE__ */ a(Ze, { className: ce, style: Nt !== void 0 ? { maxHeight: Nt } : void 0, children: /* @__PURE__ */ k(_e, { ref: wt, "aria-label": pe, "aria-busy": b || void 0, className: le, style: { minWidth: ne, tableLayout: "fixed" }, children: [
510
- /* @__PURE__ */ a(Oe, { ownerState: { sticky: !!pt }, className: de, children: /* @__PURE__ */ k(Ce, { children: [
511
- I && /* @__PURE__ */ a(
512
- O,
513
- {
514
- ownerState: { kind: "selection", edgeShadow: A },
515
- style: { width: B, minWidth: B, ...A ? Dt(0, 24) : {} },
516
- children: /* @__PURE__ */ a(Zt, { children: /* @__PURE__ */ a(tt, { type: "checkbox", checked: mt, onChange: Yt, "aria-label": "Select all rows" }) })
517
- }
518
- ),
519
- n && /* @__PURE__ */ a(
520
- O,
521
- {
522
- scope: "col",
523
- ownerState: { kind: "leading", edgeShadow: $t },
524
- className: n.headerClassName,
525
- style: {
526
- width: n.width,
527
- minWidth: n.minWidth ?? n.width ?? Wt,
528
- ...x ? Dt(A ? B : 0, 23) : {},
529
- ...n.headerStyle
530
- },
531
- children: /* @__PURE__ */ k(Rt, { ownerState: { wide: !0 }, children: [
532
- J && /* @__PURE__ */ a(tt, { type: "checkbox", checked: mt, onChange: Yt, "aria-label": "Select all rows" }),
533
- /* @__PURE__ */ a(Bt, { ownerState: { overflow: ht }, children: n.header }),
534
- Y && /* @__PURE__ */ a(
535
- Xt,
536
- {
537
- type: "button",
538
- ownerState: { pinned: x, side: "right" },
539
- title: x ? "Unpin leading column" : "Pin leading column",
540
- "aria-label": x ? "Unpin leading column" : "Pin leading column",
541
- onClick: (t) => {
542
- t.stopPropagation(), x ? (Kt(!1), kt(0)) : Kt(!0);
543
- },
544
- children: x ? "Unpin" : "Pin"
545
- }
546
- )
547
- ] })
548
- }
549
- ),
550
- f.map((t, r) => {
551
- const s = (h == null ? void 0 : h.columnId) === t.id, i = r < u, d = r === u - 1, S = {
552
- width: t.width,
553
- minWidth: t.minWidth ?? t.width,
554
- textAlign: t.align,
555
- ...i ? Dt(Gt(r), 22) : {},
556
- ...t.headerStyle
557
- }, v = et && t.sortable, c = v && Lt === "always" && !s, $ = v && s && Lt !== "never", K = Y && r < qe && /* @__PURE__ */ a(
558
- Xt,
516
+ return /* @__PURE__ */ m(Xe, { className: se, ownerState: { fill: ie }, children: [
517
+ /* @__PURE__ */ m(Ze, { className: ce, style: Lt !== void 0 ? { maxHeight: Lt } : void 0, children: [
518
+ /* @__PURE__ */ m(Oe, { ref: ft, "aria-label": pe, "aria-busy": h || void 0, className: le, style: { minWidth: ne, tableLayout: "fixed" }, children: [
519
+ /* @__PURE__ */ i(Ce, { ownerState: { sticky: !!dt }, className: de, children: /* @__PURE__ */ m(tr, { children: [
520
+ P && /* @__PURE__ */ i(
521
+ _,
559
522
  {
560
- type: "button",
561
- ownerState: { pinned: i, side: t.align === "right" ? "left" : "right" },
562
- title: i && d ? "Unpin columns" : "Pin up to this column",
563
- "aria-label": i && d ? "Unpin columns" : `Pin up to ${String(t.header)}`,
564
- onClick: (g) => {
565
- g.stopPropagation(), kt(i && d ? 0 : r + 1);
566
- },
567
- children: i ? "Unpin" : "Pin"
523
+ ownerState: { kind: "selection", edgeShadow: A },
524
+ style: { width: B, minWidth: B, ...A ? kt(0, 24) : {} },
525
+ children: /* @__PURE__ */ i(Zt, { children: /* @__PURE__ */ i(C, { type: "checkbox", checked: St, onChange: Yt, "aria-label": "Select all rows" }) })
568
526
  }
569
- );
570
- return /* @__PURE__ */ a(
571
- O,
527
+ ),
528
+ n && /* @__PURE__ */ i(
529
+ _,
572
530
  {
573
531
  scope: "col",
574
- "aria-sort": v ? s ? h.direction === "asc" ? "ascending" : "descending" : "none" : void 0,
575
- draggable: E,
576
- onDragStart: (g) => Te(g, r),
577
- onDragOver: (g) => We(g, r),
578
- onDrop: (g) => Ae(g, r),
579
- onDragEnd: () => {
580
- U(null), j(null);
532
+ ownerState: { kind: "leading", edgeShadow: jt },
533
+ className: n.headerClassName,
534
+ style: {
535
+ width: n.width,
536
+ minWidth: n.minWidth ?? n.width ?? Tt,
537
+ ...x ? kt(A ? B : 0, 23) : {},
538
+ ...n.headerStyle
581
539
  },
582
- ownerState: {
583
- kind: "data",
584
- sortable: !!v,
585
- sorted: !!s,
586
- reorderable: E,
587
- dropTarget: we === r,
588
- edgeShadow: i && d
589
- },
590
- className: t.headerClassName,
591
- style: S,
592
- children: /* @__PURE__ */ k(Rt, { ownerState: { align: t.align }, children: [
593
- t.align === "right" && K,
594
- v ? /* @__PURE__ */ k(er, { type: "button", onClick: () => ke(t), children: [
595
- /* @__PURE__ */ a(Bt, { ownerState: { overflow: ht }, children: t.header }),
596
- $ && (h.direction === "asc" ? /* @__PURE__ */ a(Le, { size: 12, weight: "bold" }) : /* @__PURE__ */ a(ze, { size: 12, weight: "bold" })),
597
- c && /* @__PURE__ */ a(rr, { size: 12 })
598
- ] }) : /* @__PURE__ */ a(Bt, { ownerState: { overflow: ht }, children: t.header }),
599
- t.align !== "right" && K
540
+ children: /* @__PURE__ */ m(Rt, { ownerState: { wide: !0 }, children: [
541
+ J && /* @__PURE__ */ i(C, { type: "checkbox", checked: St, onChange: Yt, "aria-label": "Select all rows" }),
542
+ /* @__PURE__ */ i(At, { ownerState: { overflow: pt }, children: n.header }),
543
+ Y && /* @__PURE__ */ i(
544
+ Xt,
545
+ {
546
+ type: "button",
547
+ ownerState: { pinned: x, side: "right" },
548
+ title: x ? "Unpin leading column" : "Pin leading column",
549
+ "aria-label": x ? "Unpin leading column" : "Pin leading column",
550
+ onClick: (t) => {
551
+ t.stopPropagation(), x ? (Kt(!1), mt(0)) : Kt(!0);
552
+ },
553
+ children: x ? "Unpin" : "Pin"
554
+ }
555
+ )
600
556
  ] })
601
- },
602
- t.id
603
- );
604
- }),
605
- T && /* @__PURE__ */ a(
606
- O,
607
- {
608
- ownerState: { kind: "actions", actionsShadow: G },
609
- style: { width: q, minWidth: q, ...Pe },
610
- children: ae
611
- }
612
- )
613
- ] }) }),
614
- /* @__PURE__ */ a("tbody", { children: b ? /* @__PURE__ */ a(Ke, { rows: 5, columns: _ }) : w ? /* @__PURE__ */ a(Ve, { description: w, colSpan: _ }) : V.length === 0 ? P ? /* @__PURE__ */ a("tr", { children: /* @__PURE__ */ a("td", { colSpan: _, children: P }) }) : /* @__PURE__ */ a(je, { title: re, description: oe, colSpan: _ }) : V.map((t, r) => {
615
- const s = xt(t, r), i = H.includes(s), d = ye === s, S = typeof bt == "function" ? bt(t, r) : bt, v = { rowIndex: r, selected: i, hovered: d };
616
- return /* @__PURE__ */ k(
617
- or,
618
- {
619
- ownerState: { selected: i, clickable: !!X },
620
- className: S,
621
- onMouseEnter: () => jt(s),
622
- onMouseLeave: () => jt(null),
623
- onClick: () => X == null ? void 0 : X(t),
624
- children: [
625
- I && /* @__PURE__ */ a(
626
- C,
627
- {
628
- ownerState: { kind: "selection", selected: i, cellTextSize: R, edgeShadow: A },
629
- style: { width: B, minWidth: B, ...A ? Tt(0, 14) : {} },
630
- onClick: (c) => c.stopPropagation(),
631
- children: /* @__PURE__ */ a(Zt, { children: /* @__PURE__ */ a(tt, { type: "checkbox", checked: i, onChange: () => qt(s), "aria-label": `Select row ${r + 1}` }) })
632
- }
633
- ),
634
- n && /* @__PURE__ */ a(
635
- C,
636
- {
637
- ownerState: { kind: "leading", selected: i, cellTextSize: R, edgeShadow: $t },
638
- className: n.className,
639
- style: {
640
- width: n.width,
641
- minWidth: n.minWidth ?? n.width ?? Wt,
642
- ...x ? Tt(A ? B : 0, 13) : {},
643
- ...n.style
644
- },
645
- onClick: J ? (c) => c.stopPropagation() : void 0,
646
- children: /* @__PURE__ */ k(ar, { children: [
647
- J && /* @__PURE__ */ a(tt, { type: "checkbox", checked: i, onChange: () => qt(s), "aria-label": `Select row ${r + 1}` }),
648
- /* @__PURE__ */ a(ir, { children: n.cell(t, v) })
649
- ] })
650
- }
651
- ),
652
- f.map((c, $) => {
653
- const K = ee(t, c), g = $ < u, Ie = $ === u - 1, Me = typeof ft == "function" ? ft(t, r, c) : ft;
654
- return /* @__PURE__ */ a(
655
- C,
557
+ }
558
+ ),
559
+ f.map((t, r) => {
560
+ const s = (b == null ? void 0 : b.columnId) === t.id, a = r < u, d = r === u - 1, S = {
561
+ width: t.width,
562
+ minWidth: t.minWidth ?? t.width,
563
+ textAlign: t.align,
564
+ ...a ? kt(Gt(r), 22) : {},
565
+ ...t.headerStyle
566
+ }, v = tt && t.sortable, c = v && Ft === "always" && !s, $ = v && s && Ft !== "never", K = Y && r < qe && /* @__PURE__ */ i(
567
+ Xt,
568
+ {
569
+ type: "button",
570
+ ownerState: { pinned: a, side: t.align === "right" ? "left" : "right" },
571
+ title: a && d ? "Unpin columns" : "Pin up to this column",
572
+ "aria-label": a && d ? "Unpin columns" : `Pin up to ${String(t.header)}`,
573
+ onClick: (g) => {
574
+ g.stopPropagation(), mt(a && d ? 0 : r + 1);
575
+ },
576
+ children: a ? "Unpin" : "Pin"
577
+ }
578
+ );
579
+ return /* @__PURE__ */ i(
580
+ _,
581
+ {
582
+ scope: "col",
583
+ "aria-sort": v ? s ? b.direction === "asc" ? "ascending" : "descending" : "none" : void 0,
584
+ draggable: H,
585
+ onDragStart: (g) => Te(g, r),
586
+ onDragOver: (g) => We(g, r),
587
+ onDrop: (g) => Ae(g, r),
588
+ onDragEnd: () => {
589
+ V(null), j(null);
590
+ },
591
+ ownerState: {
592
+ kind: "data",
593
+ sortable: !!v,
594
+ sorted: !!s,
595
+ reorderable: H,
596
+ dropTarget: we === r,
597
+ edgeShadow: a && d
598
+ },
599
+ className: t.headerClassName,
600
+ style: S,
601
+ children: /* @__PURE__ */ m(Rt, { ownerState: { align: t.align }, children: [
602
+ t.align === "right" && K,
603
+ v ? /* @__PURE__ */ m(rr, { type: "button", onClick: () => ke(t), children: [
604
+ /* @__PURE__ */ i(At, { ownerState: { overflow: pt }, children: t.header }),
605
+ $ && (b.direction === "asc" ? /* @__PURE__ */ i(Le, { size: 12, weight: "bold" }) : /* @__PURE__ */ i(Fe, { size: 12, weight: "bold" })),
606
+ c && /* @__PURE__ */ i(or, { size: 12 })
607
+ ] }) : /* @__PURE__ */ i(At, { ownerState: { overflow: pt }, children: t.header }),
608
+ t.align !== "right" && K
609
+ ] })
610
+ },
611
+ t.id
612
+ );
613
+ }),
614
+ T && /* @__PURE__ */ i(
615
+ _,
616
+ {
617
+ ownerState: { kind: "actions", actionsShadow: G },
618
+ style: { width: q, minWidth: q, ...Pe },
619
+ children: ae
620
+ }
621
+ )
622
+ ] }) }),
623
+ /* @__PURE__ */ i("tbody", { children: h ? /* @__PURE__ */ i(Ke, { rows: 5, columns: $t }) : w ? /* @__PURE__ */ i(je, { description: w, colSpan: $t }) : I.length === 0 ? null : I.map((t, r) => {
624
+ const s = ut(t, r), a = U.includes(s), d = ye === s, S = typeof ht == "function" ? ht(t, r) : ht, v = { rowIndex: r, selected: a, hovered: d };
625
+ return /* @__PURE__ */ m(
626
+ ar,
627
+ {
628
+ ownerState: { selected: a, clickable: !!X },
629
+ className: S,
630
+ onMouseEnter: () => Ut(s),
631
+ onMouseLeave: () => Ut(null),
632
+ onClick: () => X == null ? void 0 : X(t),
633
+ children: [
634
+ P && /* @__PURE__ */ i(
635
+ O,
636
+ {
637
+ ownerState: { kind: "selection", selected: a, cellTextSize: R, edgeShadow: A },
638
+ style: { width: B, minWidth: B, ...A ? Dt(0, 14) : {} },
639
+ onClick: (c) => c.stopPropagation(),
640
+ children: /* @__PURE__ */ i(Zt, { children: /* @__PURE__ */ i(C, { type: "checkbox", checked: a, onChange: () => qt(s), "aria-label": `Select row ${r + 1}` }) })
641
+ }
642
+ ),
643
+ n && /* @__PURE__ */ i(
644
+ O,
656
645
  {
657
- ownerState: { kind: "data", selected: i, cellTextSize: R, edgeShadow: g && Ie },
658
- className: Ue(Me, c.className),
646
+ ownerState: { kind: "leading", selected: a, cellTextSize: R, edgeShadow: jt },
647
+ className: n.className,
659
648
  style: {
660
- width: c.width,
661
- minWidth: c.minWidth ?? c.width,
662
- textAlign: c.align,
663
- ...g ? Tt(Gt($), 12) : {},
664
- ...c.style
649
+ width: n.width,
650
+ minWidth: n.minWidth ?? n.width ?? Tt,
651
+ ...x ? Dt(A ? B : 0, 13) : {},
652
+ ...n.style
653
+ },
654
+ onClick: J ? (c) => c.stopPropagation() : void 0,
655
+ children: /* @__PURE__ */ m(ir, { children: [
656
+ J && /* @__PURE__ */ i(C, { type: "checkbox", checked: a, onChange: () => qt(s), "aria-label": `Select row ${r + 1}` }),
657
+ /* @__PURE__ */ i(nr, { children: n.cell(t, v) })
658
+ ] })
659
+ }
660
+ ),
661
+ f.map((c, $) => {
662
+ const K = ee(t, c), g = $ < u, Ie = $ === u - 1, Me = typeof bt == "function" ? bt(t, r, c) : bt;
663
+ return /* @__PURE__ */ i(
664
+ O,
665
+ {
666
+ ownerState: { kind: "data", selected: a, cellTextSize: R, edgeShadow: g && Ie },
667
+ className: Ue(Me, c.className),
668
+ style: {
669
+ width: c.width,
670
+ minWidth: c.minWidth ?? c.width,
671
+ textAlign: c.align,
672
+ ...g ? Dt(Gt($), 12) : {},
673
+ ...c.style
674
+ },
675
+ children: c.cell ? c.cell(t, { value: K, rowIndex: r, selected: a, hovered: d }) : String(K ?? "")
665
676
  },
666
- children: c.cell ? c.cell(t, { value: K, rowIndex: r, selected: i, hovered: d }) : String(K ?? "")
667
- },
668
- c.id
669
- );
670
- }),
671
- T && /* @__PURE__ */ a(
672
- C,
673
- {
674
- ownerState: { kind: "actions", selected: i, cellTextSize: R, actionsShadow: G },
675
- style: { width: q, minWidth: q, ...Be },
676
- onClick: (c) => c.stopPropagation(),
677
- children: T(t)
678
- }
679
- )
680
- ]
681
- },
682
- s
683
- );
684
- }) })
685
- ] }) }),
686
- Ft && /* @__PURE__ */ a($e, { ...Ft })
677
+ c.id
678
+ );
679
+ }),
680
+ T && /* @__PURE__ */ i(
681
+ O,
682
+ {
683
+ ownerState: { kind: "actions", selected: a, cellTextSize: R, actionsShadow: G },
684
+ style: { width: q, minWidth: q, ...Be },
685
+ onClick: (c) => c.stopPropagation(),
686
+ children: T(t)
687
+ }
688
+ )
689
+ ]
690
+ },
691
+ s
692
+ );
693
+ }) })
694
+ ] }),
695
+ !h && !w && I.length === 0 && /* @__PURE__ */ i(_e, { children: F ?? /* @__PURE__ */ i(Ve, { title: re, description: oe }) })
696
+ ] }),
697
+ Mt && /* @__PURE__ */ i($e, { ...Mt })
687
698
  ] });
688
699
  }
689
700
  export {
690
- kr as DataTable
701
+ Dr as DataTable
691
702
  };
692
703
  //# sourceMappingURL=DataTable.js.map