laif-ds 0.2.75 → 0.2.76

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,21 +1,21 @@
1
1
  "use client";
2
2
  import { jsx as d, jsxs as se } from "react/jsx-runtime";
3
- import { useReactTable as lt } from "../../../../node_modules/@tanstack/react-table/build/lib/index.js";
3
+ import { useReactTable as ct } from "../../../../node_modules/@tanstack/react-table/build/lib/index.js";
4
4
  import { useRef as f, useState as l, useEffect as O, useMemo as C } from "react";
5
- import { cn as ct } from "../../../../lib/utils.js";
6
- import { Button as dt } from "../../button.js";
5
+ import { cn as dt } from "../../../../lib/utils.js";
6
+ import { Button as ut } from "../../button.js";
7
7
  import { Checkbox as Ie } from "../../checkbox.js";
8
- import { DataTableActionsComponent as ut } from "./components/data-table-actions.js";
9
- import { DataTableBody as gt } from "./components/data-table-body.js";
10
- import { DataTableColumnVisibility as mt } from "./components/data-table-column-visibility.js";
11
- import { DataTableFilters as pt } from "./components/data-table-filters.js";
12
- import { DataTablePaginationComponent as ft } from "./components/data-table-pagination.js";
13
- import { DataTableSearchbar as ht } from "./components/data-table-searchbar.js";
14
- import { DataTableSortingComponent as St } from "./components/data-table-sorting.js";
15
- import { applySearchFilterToRow as Te, debounce as bt, buildSearchFilter as Ft, updatePageSizeFromContainer as vt, createDefaultAdvancedFilter as Ct, createBadgeFilterFromHeader as xt } from "./data-table.service.js";
16
- import { defaultDataTableI18n as yt } from "./data-table-i18n.js";
17
- import { getPaginationRowModel as wt, getFilteredRowModel as Rt, getSortedRowModel as It, getCoreRowModel as Tt } from "../../../../node_modules/@tanstack/table-core/build/lib/index.js";
18
- function Et({
8
+ import { DataTableActionsComponent as gt } from "./components/data-table-actions.js";
9
+ import { DataTableBody as mt } from "./components/data-table-body.js";
10
+ import { DataTableColumnVisibility as pt } from "./components/data-table-column-visibility.js";
11
+ import { DataTableFilters as ft } from "./components/data-table-filters.js";
12
+ import { DataTablePaginationComponent as ht } from "./components/data-table-pagination.js";
13
+ import { DataTableSearchbar as St } from "./components/data-table-searchbar.js";
14
+ import { DataTableSortingComponent as bt } from "./components/data-table-sorting.js";
15
+ import { applySearchFilterToRow as Te, debounce as Ft, buildSearchFilter as vt, updatePageSizeFromContainer as Ct, createDefaultAdvancedFilter as xt, createBadgeFilterFromHeader as yt } from "./data-table.service.js";
16
+ import { defaultDataTableI18n as wt } from "./data-table-i18n.js";
17
+ import { getPaginationRowModel as Rt, getFilteredRowModel as It, getSortedRowModel as Tt, getCoreRowModel as zt } from "../../../../node_modules/@tanstack/table-core/build/lib/index.js";
18
+ function Wt({
19
19
  columns: Z,
20
20
  data: V,
21
21
  loading: z = !1,
@@ -30,7 +30,7 @@ function Et({
30
30
  customComponentsRight: Oe,
31
31
  hidePagination: He = !1,
32
32
  hideActionsRow: Ne = !1,
33
- i18n: h = yt,
33
+ i18n: h = wt,
34
34
  maxSortedColumns: ce = 2,
35
35
  initialState: u,
36
36
  // New mode-based API
@@ -39,12 +39,13 @@ function Et({
39
39
  disableAutoPageSize: b = !1,
40
40
  // Test & Accessibility
41
41
  id: Ge,
42
- "data-testid": Pe
42
+ "data-testid": Pe,
43
+ rowClassName: ke
43
44
  }) {
44
45
  const q = f(null), i = Le === !0, g = i ? de : void 0, ue = (e) => !e || !e.sort_by || !e.sort_order ? [] : e.sort_by.map((t, n) => ({
45
46
  id: t,
46
47
  desc: e.sort_order[n] === "desc"
47
- })), ke = (e) => {
48
+ })), Ae = (e) => {
48
49
  const t = ue(e?.sorting), n = {
49
50
  sort_by: t.map((a) => a.id),
50
51
  sort_order: t.map((a) => a.desc ? "desc" : "asc")
@@ -54,13 +55,13 @@ function Et({
54
55
  computedFilter: e?.computedFilter
55
56
  // Use provided value or undefined
56
57
  };
57
- }, [H, Ae] = l(() => ue(u?.sorting)), [Ve] = l([]), [je, qe] = l(
58
+ }, [H, Ve] = l(() => ue(u?.sorting)), [je] = l([]), [qe, Ke] = l(
58
59
  () => u?.columnVisibility ?? {}
59
- ), [m, Ke] = l(() => u?.filters?.searchbarFilter), [K, N] = l(() => u?.pagination ?? { pageIndex: 0, pageSize: 10 }), ge = f(g);
60
+ ), [m, Ee] = l(() => u?.filters?.searchbarFilter), [K, N] = l(() => u?.pagination ?? { pageIndex: 0, pageSize: 10 }), ge = f(g);
60
61
  ge.current = g;
61
62
  const E = f(g?.onStateChange);
62
63
  E.current = g?.onStateChange;
63
- const W = f(null), D = f(null), Ee = f(0), me = f(!1), pe = f(null), J = f({}), fe = f(null), U = f(z);
64
+ const W = f(null), D = f(null), We = f(0), me = f(!1), pe = f(null), J = f({}), fe = f(null), U = f(z);
64
65
  U.current = z;
65
66
  const L = (e) => {
66
67
  e.computedFilter && (J.current.computedFilter = e.computedFilter), e.computedSorting && (J.current.computedSorting = e.computedSorting);
@@ -71,7 +72,7 @@ function Et({
71
72
  computedSorting: e.computedSorting || J.current.computedSorting
72
73
  };
73
74
  W.current = t, D.current && clearTimeout(D.current), D.current = setTimeout(() => {
74
- W.current && E.current && (Ee.current = Date.now(), E.current(W.current), W.current = null, D.current = null);
75
+ W.current && E.current && (We.current = Date.now(), E.current(W.current), W.current = null, D.current = null);
75
76
  }, 400);
76
77
  };
77
78
  O(() => {
@@ -83,7 +84,7 @@ function Et({
83
84
  };
84
85
  }, []);
85
86
  const [r, G] = l(() => {
86
- const { computedSorting: e, computedFilter: t } = ke(u);
87
+ const { computedSorting: e, computedFilter: t } = Ae(u);
87
88
  return {
88
89
  pagination: u?.pagination ?? { pageIndex: 0, pageSize: 10 },
89
90
  sorting: u?.sorting,
@@ -93,9 +94,9 @@ function Et({
93
94
  };
94
95
  });
95
96
  i && !g && console.warn("DataTable: Server mode requires serverConfig");
96
- const [We, he] = l(0), [Je, Se] = l(0), [Ue, Xe] = l({}), be = le ? Be : Ue, Qe = le || Xe, [F, ee] = l(
97
+ const [Je, he] = l(0), [Ue, Se] = l(0), [Xe, Qe] = l({}), be = le ? Be : Xe, Ye = le || Qe, [F, ee] = l(
97
98
  () => u?.filters?.filterBadges ?? []
98
- ), [x, te] = l(() => u?.filters?.advancedFilterBadge), [X, Ye] = l(""), [Ze, re] = l(void 0), [Fe, ve] = l([]), Ce = C(() => j ? [
99
+ ), [x, te] = l(() => u?.filters?.advancedFilterBadge), [X, Ze] = l(""), [$e, re] = l(void 0), [Fe, ve] = l([]), Ce = C(() => j ? [
99
100
  {
100
101
  id: "data-table-integrated-checkbox-column",
101
102
  size: 24,
@@ -152,7 +153,7 @@ function Et({
152
153
  if (e.id) return e.id;
153
154
  if ("accessorKey" in e && typeof e.accessorKey == "string")
154
155
  return e.accessorKey;
155
- }, $e = (e) => {
156
+ }, et = (e) => {
156
157
  const t = e.meta?.headerLabel;
157
158
  return t || (typeof e.header == "string" ? e.header : Q(e) ?? "-");
158
159
  };
@@ -160,23 +161,23 @@ function Et({
160
161
  const e = (I ?? []).map(Q).filter((c) => !!c), t = new Set(Fe), n = new Set(e);
161
162
  t.size === n.size && [...t].every((c) => n.has(c)) || ve(e);
162
163
  }, [I]);
163
- const B = C(() => I.filter((e) => !!e.meta?.searchable), [I]), T = C(() => B.map((e) => "accessorKey" in e && typeof e.accessorKey == "string" ? e.accessorKey : e.id).filter((e) => !!e), [B]), [Y, et] = l(() => u?.computedFilter ?? {}), tt = {
164
+ const B = C(() => I.filter((e) => !!e.meta?.searchable), [I]), T = C(() => B.map((e) => "accessorKey" in e && typeof e.accessorKey == "string" ? e.accessorKey : e.id).filter((e) => !!e), [B]), [Y, tt] = l(() => u?.computedFilter ?? {}), rt = {
164
165
  data: C(() => i || Object.keys(Y).length === 0 ? V : V.filter((e) => Te({
165
166
  original: e,
166
167
  getValue: (n) => e[n]
167
168
  }, Y)), [V, Y, i]),
168
169
  columns: I,
169
- getCoreRowModel: Tt(),
170
+ getCoreRowModel: zt(),
170
171
  onSortingChange: (e) => {
171
172
  const t = typeof e == "function" ? e(H) : e;
172
- Ae(t);
173
+ Ve(t);
173
174
  },
174
- getSortedRowModel: It(),
175
+ getSortedRowModel: Tt(),
175
176
  manualSorting: i,
176
- onColumnVisibilityChange: qe,
177
- onRowSelectionChange: Qe,
177
+ onColumnVisibilityChange: Ke,
178
+ onRowSelectionChange: Ye,
178
179
  onColumnOrderChange: ve,
179
- getFilteredRowModel: Rt(),
180
+ getFilteredRowModel: It(),
180
181
  manualFiltering: i,
181
182
  globalFilterFn: (e, t, n) => i || !n ? !0 : (T ?? []).some((a) => {
182
183
  const c = e.getValue(a);
@@ -214,13 +215,13 @@ function Et({
214
215
  } : e
215
216
  );
216
217
  },
217
- getPaginationRowModel: wt(),
218
+ getPaginationRowModel: Rt(),
218
219
  manualPagination: i,
219
- pageCount: i && z ? Je : We,
220
+ pageCount: i && z ? Ue : Je,
220
221
  state: {
221
222
  sorting: H,
222
- columnFilters: Ve,
223
- columnVisibility: je,
223
+ columnFilters: je,
224
+ columnVisibility: qe,
224
225
  rowSelection: be,
225
226
  globalFilter: m,
226
227
  pagination: i ? r.pagination : K,
@@ -228,7 +229,7 @@ function Et({
228
229
  },
229
230
  // Prevent implicit resets on data/columns changes so filters/sorting persist
230
231
  autoResetPageIndex: !1
231
- }, s = lt(tt), ne = s.getFilteredRowModel();
232
+ }, s = ct(rt), ne = s.getFilteredRowModel();
232
233
  O(() => {
233
234
  if (i && g) {
234
235
  const e = Math.ceil(
@@ -261,7 +262,7 @@ function Et({
261
262
  ), w = _?.getBoundingClientRect().height ?? 40;
262
263
  if (!!!o?.querySelector("td")) return;
263
264
  const k = o?.getBoundingClientRect().height ?? 32.5;
264
- vt(y, {
265
+ Ct(y, {
265
266
  rowHeight: k,
266
267
  headerHeight: w,
267
268
  onPageChange: i ? (R, v) => {
@@ -320,7 +321,7 @@ function Et({
320
321
  );
321
322
  }
322
323
  });
323
- }, t = bt(() => {
324
+ }, t = Ft(() => {
324
325
  requestAnimationFrame(() => {
325
326
  e();
326
327
  });
@@ -353,26 +354,26 @@ function Et({
353
354
  $(e);
354
355
  }
355
356
  }, [s, $, j, be]);
356
- const xe = s.getState().sorting, rt = C(() => {
357
+ const xe = s.getState().sorting, nt = C(() => {
357
358
  const e = s.getHeaderGroups()[0], t = e ? e.headers : [];
358
359
  return (xe || []).map((c) => t.find((p) => p.column.id === c.id)).filter(Boolean);
359
- }, [s.getHeaderGroups, xe, I]), oe = C(() => s.getHeaderGroups()[0].headers.filter((e) => e.column.columnDef.meta?.sortable), [s.getHeaderGroups, I]), P = C(() => s.getHeaderGroups()[0].headers.filter((e) => e.column.columnDef.meta?.filterable), [s.getHeaderGroups, I]), nt = C(() => X ? P.filter((e) => (e.column.columnDef.meta?.headerLabel ?? (typeof e.column.columnDef.header == "string" ? e.column.columnDef.header : void 0) ?? e.column.id).toLowerCase().includes(X.toLowerCase())) : P, [P, X]), ye = (e) => {
360
+ }, [s.getHeaderGroups, xe, I]), oe = C(() => s.getHeaderGroups()[0].headers.filter((e) => e.column.columnDef.meta?.sortable), [s.getHeaderGroups, I]), P = C(() => s.getHeaderGroups()[0].headers.filter((e) => e.column.columnDef.meta?.filterable), [s.getHeaderGroups, I]), ot = C(() => X ? P.filter((e) => (e.column.columnDef.meta?.headerLabel ?? (typeof e.column.columnDef.header == "string" ? e.column.columnDef.header : void 0) ?? e.column.id).toLowerCase().includes(X.toLowerCase())) : P, [P, X]), ye = (e) => {
360
361
  const t = F.find(
361
362
  (a) => a.columnId === (e?.id ?? "")
362
363
  );
363
364
  if (t)
364
365
  return re(t.id), t.id;
365
- const n = xt(e);
366
+ const n = yt(e);
366
367
  return ee((a) => [...a, n]), re(n.id), n.id;
367
- }, ot = () => {
368
- te(Ct());
369
- }, it = C(() => F.sort((e, t) => e.value === void 0 || e.value === "" ? 1 : t.value === void 0 || t.value === "" ? -1 : 1), [F]), we = f({
368
+ }, it = () => {
369
+ te(xt());
370
+ }, at = C(() => F.sort((e, t) => e.value === void 0 || e.value === "" ? 1 : t.value === void 0 || t.value === "" ? -1 : 1), [F]), we = f({
370
371
  filterBadges: [],
371
372
  advancedFilterBadge: void 0,
372
373
  searchbarGlobalFilter: void 0
373
374
  });
374
375
  O(() => {
375
- const e = Ft(
376
+ const e = vt(
376
377
  F,
377
378
  x ?? void 0
378
379
  ), t = m && T.length > 0 ? T.length === 1 ? (() => {
@@ -420,7 +421,7 @@ function Et({
420
421
  searchbarGlobalFilter: m
421
422
  };
422
423
  const _ = ge.current;
423
- if (et(a), i && E.current && _) {
424
+ if (tt(a), i && E.current && _) {
424
425
  const o = {
425
426
  ...r,
426
427
  computedFilter: a,
@@ -459,13 +460,13 @@ function Et({
459
460
  H,
460
461
  i
461
462
  ]);
462
- const Re = s.getAllLeafColumns(), at = Re.filter((e) => e.getIsVisible()), st = Re.filter((e) => !e.getIsVisible());
463
+ const Re = s.getAllLeafColumns(), st = Re.filter((e) => e.getIsVisible()), lt = Re.filter((e) => !e.getIsVisible());
463
464
  return /* @__PURE__ */ se(
464
465
  "div",
465
466
  {
466
467
  id: Ge,
467
468
  "data-testid": Pe,
468
- className: ct(
469
+ className: dt(
469
470
  "flex h-full max-h-full min-h-[250px] w-full max-w-full min-w-0 flex-col gap-2",
470
471
  De
471
472
  ),
@@ -473,10 +474,10 @@ function Et({
473
474
  !Ne && /* @__PURE__ */ se("div", { className: "flex w-full items-center justify-between gap-1", children: [
474
475
  /* @__PURE__ */ se("div", { className: "flex min-w-0 flex-1 items-center gap-1 overflow-x-auto", children: [
475
476
  oe.length > 0 && /* @__PURE__ */ d(
476
- St,
477
+ bt,
477
478
  {
478
479
  table: s,
479
- sortedColumns: rt,
480
+ sortedColumns: nt,
480
481
  sortableColumns: oe,
481
482
  i18n: h,
482
483
  maxSortedColumns: ce
@@ -485,19 +486,19 @@ function Et({
485
486
  oe.length > 0 && P.length > 0 && /* @__PURE__ */ d("div", { className: "border-d-border h-4 min-h-4 w-[1px] border-r" }),
486
487
  Me,
487
488
  /* @__PURE__ */ d(
488
- pt,
489
+ ft,
489
490
  {
490
491
  advancedFilterBadge: x,
491
492
  setAdvancedFilterBadge: te,
492
493
  filterableColumns: P,
493
- sortedFilterBadges: it,
494
+ sortedFilterBadges: at,
494
495
  setFilterBadges: ee,
495
496
  filterSearch: X,
496
- setFilterSearch: Ye,
497
- filteredColumns: nt,
497
+ setFilterSearch: Ze,
498
+ filteredColumns: ot,
498
499
  handleAddFilter: ye,
499
- handleAddAdvancedFilter: ot,
500
- pendingOpenFilterId: Ze,
500
+ handleAddAdvancedFilter: it,
501
+ pendingOpenFilterId: $e,
501
502
  onPendingOpenFilterHandled: () => re(void 0),
502
503
  i18n: h
503
504
  }
@@ -506,7 +507,7 @@ function Et({
506
507
  /* @__PURE__ */ d("div", { className: "border-d-border h-4 min-h-4 w-[1px] border-r" }),
507
508
  Oe,
508
509
  (F.length || x) && /* @__PURE__ */ d(
509
- dt,
510
+ ut,
510
511
  {
511
512
  className: "h-6 text-xs",
512
513
  iconLeft: "FunnelX",
@@ -519,30 +520,30 @@ function Et({
519
520
  }
520
521
  ),
521
522
  T.length > 0 && /* @__PURE__ */ d(
522
- ht,
523
+ St,
523
524
  {
524
525
  debounceMs: 300,
525
- onSearch: Ke,
526
+ onSearch: Ee,
526
527
  i18n: h,
527
528
  initialValue: m ?? "",
528
529
  searchableColumnsHeaders: B.map(
529
- (e) => $e(e)
530
+ (e) => et(e)
530
531
  )
531
532
  }
532
533
  ),
533
534
  /* @__PURE__ */ d(
534
- mt,
535
+ pt,
535
536
  {
536
537
  table: s,
537
- visibleColumns: at,
538
- hiddenColumns: st,
538
+ visibleColumns: st,
539
+ hiddenColumns: lt,
539
540
  i18n: h
540
541
  }
541
542
  ),
542
- /* @__PURE__ */ d(ut, { actions: _e, i18n: h })
543
+ /* @__PURE__ */ d(gt, { actions: _e, i18n: h })
543
544
  ] }),
544
545
  /* @__PURE__ */ d(
545
- gt,
546
+ mt,
546
547
  {
547
548
  table: s,
548
549
  tableContainerRef: q,
@@ -557,11 +558,12 @@ function Et({
557
558
  filterBadges: F,
558
559
  advancedFilterBadge: x,
559
560
  searchbarGlobalFilter: m,
560
- serverDebounceTime: de?.serverDebounceTime
561
+ serverDebounceTime: de?.serverDebounceTime,
562
+ rowClassName: ke
561
563
  }
562
564
  ),
563
565
  !He && /* @__PURE__ */ d(
564
- ft,
566
+ ht,
565
567
  {
566
568
  table: s,
567
569
  isServerSide: i,
@@ -579,5 +581,5 @@ function Et({
579
581
  );
580
582
  }
581
583
  export {
582
- Et as DataTable
584
+ Wt as DataTable
583
585
  };
@@ -19,14 +19,16 @@ function s(e, t) {
19
19
  sortable: e.sortable ?? !1,
20
20
  filterable: e.filterable ?? !1,
21
21
  searchable: e.searchable ?? !1,
22
- pinned: e.pinned
22
+ pinned: e.pinned,
23
+ cellClassName: e.cellClassName,
24
+ headerClassName: e.headerClassName
23
25
  }
24
26
  };
25
27
  }
26
- function y(e) {
28
+ function h(e) {
27
29
  return s(e, "string");
28
30
  }
29
- function h(e) {
31
+ function y(e) {
30
32
  return s(e, "number");
31
33
  }
32
34
  function _(e) {
@@ -39,7 +41,10 @@ function q(e) {
39
41
  return s(e, "datetime");
40
42
  }
41
43
  function F(e) {
42
- const t = Array.isArray(e.options) ? typeof e.options[0] == "string" ? e.options.map((a) => ({ value: a, label: a })) : e.options : [], r = s(e, "list_single_select");
44
+ const t = Array.isArray(e.options) ? typeof e.options[0] == "string" ? e.options.map((a) => ({ value: a, label: a })) : e.options : [], r = s(
45
+ e,
46
+ "list_single_select"
47
+ );
43
48
  return {
44
49
  ...r,
45
50
  meta: {
@@ -50,7 +55,10 @@ function F(e) {
50
55
  };
51
56
  }
52
57
  function K(e) {
53
- const t = Array.isArray(e.options) ? typeof e.options[0] == "string" ? e.options.map((a) => ({ value: a, label: a })) : e.options : [], r = s(e, "list_multi_select");
58
+ const t = Array.isArray(e.options) ? typeof e.options[0] == "string" ? e.options.map((a) => ({ value: a, label: a })) : e.options : [], r = s(
59
+ e,
60
+ "list_multi_select"
61
+ );
54
62
  return {
55
63
  ...r,
56
64
  meta: {
@@ -175,7 +183,7 @@ function D(e, t, r, a, l) {
175
183
  value: l
176
184
  });
177
185
  }
178
- function V(e, t, r, a, l, n, i) {
186
+ function N(e, t, r, a, l, n, i) {
179
187
  return u({
180
188
  columnId: e,
181
189
  columnAccessorKey: t,
@@ -192,7 +200,7 @@ function p(e) {
192
200
  sort_order: e.map((t) => t.order)
193
201
  };
194
202
  }
195
- function f(e) {
203
+ function V(e) {
196
204
  return {
197
205
  ...e.filters && {
198
206
  filters: {
@@ -250,10 +258,10 @@ function M(e, t) {
250
258
  } : r;
251
259
  });
252
260
  }
253
- function w(e) {
261
+ function f(e) {
254
262
  return e.map((t) => t.accessorKey || t.id).filter(Boolean);
255
263
  }
256
- function N(e, t) {
264
+ function w(e, t) {
257
265
  return {
258
266
  string: [
259
267
  "like",
@@ -296,17 +304,17 @@ export {
296
304
  v as createDisplayColumn,
297
305
  u as createFilterBadge,
298
306
  O as createFilterBadges,
299
- f as createInitialState,
300
- V as createListFilter,
307
+ V as createInitialState,
308
+ N as createListFilter,
301
309
  K as createMultiSelectColumn,
302
- h as createNumberColumn,
310
+ y as createNumberColumn,
303
311
  I as createNumberFilter,
304
312
  F as createSingleSelectColumn,
305
313
  p as createSorting,
306
- y as createStringColumn,
314
+ h as createStringColumn,
307
315
  T as createStringFilter,
308
- w as getColumnIds,
309
- N as isValidOperatorForType,
316
+ f as getColumnIds,
317
+ w as isValidOperatorForType,
310
318
  M as pinColumns,
311
319
  b as toSelectOptions,
312
320
  k as toSelectOptionsFromObjects,
@@ -0,0 +1,100 @@
1
+ "use client";
2
+ import { jsx as e, jsxs as v } from "react/jsx-runtime";
3
+ import { useState as h, useRef as b, useCallback as j, useEffect as N } from "react";
4
+ import { cn as c } from "../../lib/utils.js";
5
+ import { Icon as B } from "./icon.js";
6
+ import { Popover as L, PopoverTrigger as W, PopoverContent as K } from "./popover.js";
7
+ import { Typo as T } from "./typo.js";
8
+ function H({
9
+ children: o,
10
+ text: a,
11
+ title: w,
12
+ popoverContent: f,
13
+ className: k = "",
14
+ wrapperClassName: x = "",
15
+ popoverClassName: z = "",
16
+ showButton: O = !0,
17
+ emptyFallback: R = "-"
18
+ }) {
19
+ const [p, C] = h(!1), [l, m] = h(!1), [P, E] = h(""), i = b(null), s = b(null), d = o !== void 0, t = a || P || (typeof o == "string" ? o : ""), D = d || typeof a == "string" && a.trim().length > 0, r = d || !!a || !!f || p, u = j(() => {
20
+ if (i.current) {
21
+ const { scrollWidth: n, clientWidth: I } = i.current, g = i.current.textContent?.trim() ?? "";
22
+ E(
23
+ (y) => y === g ? y : g
24
+ ), C(n > I);
25
+ }
26
+ }, []);
27
+ return N(() => {
28
+ u(), i.current && typeof ResizeObserver < "u" && (s.current = new ResizeObserver(u), s.current.observe(i.current));
29
+ const n = () => u();
30
+ return window.addEventListener("resize", n), () => {
31
+ s.current && (s.current.disconnect(), s.current = null), window.removeEventListener("resize", n);
32
+ };
33
+ }, [t, u]), N(() => {
34
+ !r && l && m(!1);
35
+ }, [r, l]), !D && !t ? /* @__PURE__ */ e("div", { className: c(x, "text-muted-foreground"), children: R }) : /* @__PURE__ */ v(L, { open: l, onOpenChange: m, children: [
36
+ /* @__PURE__ */ e(W, { asChild: !0, children: /* @__PURE__ */ v(
37
+ "button",
38
+ {
39
+ type: "button",
40
+ className: c(
41
+ "group flex max-w-60 min-w-0 items-center gap-2 text-left",
42
+ r && "cursor-pointer",
43
+ x
44
+ ),
45
+ disabled: !r,
46
+ "aria-label": r && t ? `Click to view full content: ${t}` : t || void 0,
47
+ onKeyDown: (n) => {
48
+ (n.key === "Enter" || n.key === " ") && r && (n.preventDefault(), m(!l));
49
+ },
50
+ children: [
51
+ /* @__PURE__ */ e("div", { className: "flex min-w-0 flex-1", children: /* @__PURE__ */ e(
52
+ "div",
53
+ {
54
+ ref: i,
55
+ className: c(
56
+ "truncate whitespace-nowrap",
57
+ r && "group-hover:underline",
58
+ k
59
+ ),
60
+ title: p ? t : void 0,
61
+ children: d ? o : t
62
+ }
63
+ ) }),
64
+ p && O && /* @__PURE__ */ e(
65
+ "span",
66
+ {
67
+ className: c(
68
+ "text-d-muted-foreground flex shrink-0 items-center opacity-50 transition-opacity group-hover:opacity-100"
69
+ ),
70
+ "aria-hidden": "true",
71
+ children: /* @__PURE__ */ e(B, { name: "Eye", size: "sm" })
72
+ }
73
+ )
74
+ ]
75
+ }
76
+ ) }),
77
+ /* @__PURE__ */ v(
78
+ K,
79
+ {
80
+ side: "top",
81
+ align: "start",
82
+ className: c("w-96", z),
83
+ children: [
84
+ w && /* @__PURE__ */ e("div", { className: "w-full", children: /* @__PURE__ */ e(T, { variant: "caption", className: "w-full font-bold", children: w }) }),
85
+ /* @__PURE__ */ e("div", { className: "w-full", children: f || (d && !t ? /* @__PURE__ */ e("div", { className: "w-full min-w-0", children: o }) : /* @__PURE__ */ e(
86
+ T,
87
+ {
88
+ variant: "caption",
89
+ className: "w-full break-words whitespace-pre-wrap",
90
+ children: t
91
+ }
92
+ )) })
93
+ ]
94
+ }
95
+ )
96
+ ] });
97
+ }
98
+ export {
99
+ H as TruncatedCell
100
+ };
package/dist/index.d.ts CHANGED
@@ -65,7 +65,7 @@ import { UseEmblaCarouselType } from 'embla-carousel-react';
65
65
  import { UseFormReturn } from 'react-hook-form';
66
66
  import { VariantProps } from 'class-variance-authority';
67
67
 
68
- declare type AcceptItem = "pdf" | "doc" | "docx" | "xls" | "xlsx" | "ppt" | "pptx" | "txt" | "csv" | "jpg" | "jpeg" | "png" | "gif" | "image" | "video" | "audio";
68
+ declare type AcceptItem = "pdf" | "doc" | "docx" | "xls" | "xlsx" | "ppt" | "pptx" | "txt" | "csv" | "jpg" | "jpeg" | "png" | "gif" | "image" | "video" | "audio" | "zip" | "rar" | "7z" | "tar" | "gz" | "tgz";
69
69
 
70
70
  /**
71
71
  * Distributive helper: for a given key K, creates a config where cell gets the resolved value type.
@@ -74,6 +74,7 @@ declare type AcceptItem = "pdf" | "doc" | "docx" | "xls" | "xlsx" | "ppt" | "ppt
74
74
  declare type AccessorColumnConfigForKey<TData, K extends string> = BaseColumnFields & {
75
75
  accessorKey: K;
76
76
  cell?: (value: DeepValue<TData, K>, row: TData, tableRow: Row<TData>) => React.ReactNode;
77
+ cellClassName?: string | ((value: DeepValue<TData, K>, row: TData) => string);
77
78
  };
78
79
 
79
80
  export declare function Accordion({ ...props }: AccordionProps): JSX.Element;
@@ -605,6 +606,7 @@ declare type BaseColumnFields = {
605
606
  filterable?: boolean;
606
607
  searchable?: boolean;
607
608
  pinned?: "left" | "right";
609
+ headerClassName?: string;
608
610
  } & HeaderConfig;
609
611
 
610
612
  declare type BaseProps = {
@@ -1407,7 +1409,7 @@ export declare enum DataRepeatTypes {
1407
1409
  MONTH = "MONTH"
1408
1410
  }
1409
1411
 
1410
- export declare function DataTable<TData, TValue>({ columns, data, loading, emptyComponent, className, rowSelection, onRowSelectionChange, checkable, onCheckedRowsChange, actions, customComponentsLeft, customComponentsRight, hidePagination, hideActionsRow, i18n, maxSortedColumns, initialState, serverMode, serverConfig, disableAutoPageSize, id, "data-testid": dataTestId, }: DataTableProps<TData, TValue>): JSX.Element;
1412
+ export declare function DataTable<TData, TValue>({ columns, data, loading, emptyComponent, className, rowSelection, onRowSelectionChange, checkable, onCheckedRowsChange, actions, customComponentsLeft, customComponentsRight, hidePagination, hideActionsRow, i18n, maxSortedColumns, initialState, serverMode, serverConfig, disableAutoPageSize, id, "data-testid": dataTestId, rowClassName, }: DataTableProps<TData, TValue>): JSX.Element;
1411
1413
 
1412
1414
  export declare interface DataTableActions {
1413
1415
  label: string;
@@ -1598,6 +1600,7 @@ export declare interface DataTableProps<TData, TValue> {
1598
1600
  disableAutoPageSize?: boolean;
1599
1601
  id?: string;
1600
1602
  "data-testid"?: string;
1603
+ rowClassName?: string | ((row: Row<TData>) => string);
1601
1604
  }
1602
1605
 
1603
1606
  export declare interface DataTableServerConfig {
@@ -1745,10 +1748,13 @@ export declare function DialogTrigger({ ...props }: React_2.ComponentProps<typeo
1745
1748
  declare type DisplayColumnConfig<TData> = BaseColumnFields & {
1746
1749
  accessorKey?: undefined;
1747
1750
  cell?: (value: undefined, row: TData, tableRow: Row<TData>) => React.ReactNode;
1751
+ cellClassName?: string | ((value: undefined, row: TData) => string);
1748
1752
  };
1749
1753
 
1750
- /** Distributes AccessorColumnConfig over each key in the DeepKeys union */
1751
- declare type DistributedAccessorConfig<TData> = DeepKeys<TData> extends infer K ? K extends string ? AccessorColumnConfigForKey<TData, K> : never : never;
1754
+ /** Maps each key to its typed accessor config, then unions them */
1755
+ declare type DistributedAccessorConfig<TData> = {
1756
+ [K in DeepKeys<TData> & string]: AccessorColumnConfigForKey<TData, K>;
1757
+ }[DeepKeys<TData> & string];
1752
1758
 
1753
1759
  export declare const downloadFile: (url: string, filename?: string) => void;
1754
1760
 
@@ -3016,6 +3022,29 @@ declare type TransformedDataType<T> = {
3016
3022
  [P in keyof T as Exclude<P, "children">]: T[P];
3017
3023
  };
3018
3024
 
3025
+ export declare function TruncatedCell({ children, text, title, popoverContent, className, wrapperClassName, popoverClassName, showButton, emptyFallback, }: TruncatedCellProps): JSX.Element;
3026
+
3027
+ export declare interface TruncatedCellProps {
3028
+ /** The text to display and potentially truncate (can be string or ReactNode) */
3029
+ children?: React.ReactNode;
3030
+ /** The text value to use for truncation detection, accessibility and default popover content */
3031
+ text?: string;
3032
+ /** Optional title for the popover dialog */
3033
+ title?: string;
3034
+ /** Custom popover content to override default text display */
3035
+ popoverContent?: React.ReactNode;
3036
+ /** Additional CSS classes for the wrapper container */
3037
+ wrapperClassName?: string;
3038
+ /** Additional CSS classes for cell */
3039
+ className?: string;
3040
+ /** CSS classes for the popoverContent component */
3041
+ popoverClassName?: string;
3042
+ /** Flg used to show / hide the eye button */
3043
+ showButton?: boolean;
3044
+ /** Custom placeholder rendered when there is no content */
3045
+ emptyFallback?: React.ReactNode;
3046
+ }
3047
+
3019
3048
  export declare function TypingIndicator(): JSX.Element;
3020
3049
 
3021
3050
  export declare const Typo: React_2.FC<TypoProps>;
@@ -3130,5 +3159,7 @@ declare module "@tanstack/react-table" {
3130
3159
  searchable?: boolean;
3131
3160
  pinned?: "left" | "right";
3132
3161
  listOptions?: AppSelectOption[];
3162
+ cellClassName?: string | ((value: unknown, row: TData) => string);
3163
+ headerClassName?: string;
3133
3164
  }
3134
3165
  }