laif-ds 0.2.57 → 0.2.58

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.
@@ -46,7 +46,7 @@ function xe({
46
46
  ), j = () => {
47
47
  const o = d.current;
48
48
  if (!o) return 8;
49
- const e = o.querySelector("thead tr"), t = o.querySelector("tbody tr"), r = e?.getBoundingClientRect().height ?? 40, l = t?.getBoundingClientRect().height ?? 32.5, N = o.offsetHeight - r, a = Math.floor(N / l);
49
+ const e = o.querySelector("thead tr"), t = o.querySelector("tbody tr"), r = e?.getBoundingClientRect().height ?? 40, l = t?.getBoundingClientRect().height ?? 32.5, k = o.offsetHeight - r, a = Math.floor(k / l);
50
50
  return a > 1 ? a : 8;
51
51
  }, b = (o = 0) => {
52
52
  const e = {};
@@ -79,8 +79,8 @@ function xe({
79
79
  g && g.offsetWidth > 0 ? m = g.getBoundingClientRect().width : p && p.offsetWidth > 0 ? m = p.getBoundingClientRect().width : (t = !0, m = 150), c += m;
80
80
  }
81
81
  Y(e);
82
- const N = j();
83
- $(N), t && o < 5 && setTimeout(
82
+ const k = j();
83
+ $(k), t && o < 5 && setTimeout(
84
84
  () => b(o + 1),
85
85
  100 * (o + 1)
86
86
  );
@@ -130,7 +130,7 @@ function xe({
130
130
  };
131
131
  }
132
132
  }, [v, d]);
133
- const k = (o, e, t) => {
133
+ const N = (o, e, t) => {
134
134
  const r = Q[o];
135
135
  if (!r || !e || r.side !== e) return;
136
136
  const l = r.side === "left" ? `${r.offset}px` : void 0, c = r.side === "right" ? `${r.offset}px` : void 0;
@@ -150,9 +150,9 @@ function xe({
150
150
  className: "flex max-h-full min-h-0 max-w-full min-w-0 flex-1",
151
151
  ref: d,
152
152
  children: /* @__PURE__ */ i(re, { className: "border-d-border h-full min-h-0 w-full rounded-md border", children: [
153
- /* @__PURE__ */ n(q, { orientation: "horizontal" }),
153
+ /* @__PURE__ */ n(q, { orientation: "horizontal", className: "z-[100]" }),
154
154
  /* @__PURE__ */ n(q, { orientation: "vertical" }),
155
- /* @__PURE__ */ i(se, { className: "w-full", style: { minWidth: "max-content" }, children: [
155
+ /* @__PURE__ */ i(se, { className: "w-full min-w-max", children: [
156
156
  /* @__PURE__ */ n(le, { children: s.getHeaderGroups().map((o) => /* @__PURE__ */ n(y, { children: o.headers.map((e) => /* @__PURE__ */ n(
157
157
  ce,
158
158
  {
@@ -163,7 +163,7 @@ function xe({
163
163
  "bg-d-background sticky top-0 h-8 px-0",
164
164
  e.column.columnDef.meta?.pinned ? "z-[49]" : "z-10"
165
165
  ),
166
- style: k(
166
+ style: N(
167
167
  e.column.id,
168
168
  e.column.columnDef.meta?.pinned,
169
169
  !0
@@ -337,7 +337,7 @@ function xe({
337
337
  "border-0",
338
338
  t.column.columnDef.meta?.pinned && "bg-d-background z-[50]"
339
339
  ),
340
- style: k(
340
+ style: N(
341
341
  t.column.id,
342
342
  t.column.columnDef.meta?.pinned,
343
343
  !1
@@ -353,7 +353,7 @@ function xe({
353
353
  "border-0",
354
354
  t.column.columnDef.meta?.pinned && "bg-d-background z-[50]"
355
355
  ),
356
- style: k(
356
+ style: N(
357
357
  t.column.id,
358
358
  t.column.columnDef.meta?.pinned,
359
359
  !1
@@ -374,7 +374,7 @@ function xe({
374
374
  "border-0",
375
375
  e.column.columnDef.meta?.pinned ? "bg-d-background z-[50]" : "shadow-[inset_-1px_0_0_var(--d-border)]"
376
376
  ),
377
- style: k(
377
+ style: N(
378
378
  e.column.id,
379
379
  e.column.columnDef.meta?.pinned,
380
380
  !1
@@ -17,13 +17,13 @@ import { defaultDataTableI18n as pt } from "./data-table-i18n.js";
17
17
  import { getPaginationRowModel as ft, getFilteredRowModel as ht, getSortedRowModel as bt, getCoreRowModel as Ft } from "../../../../node_modules/@tanstack/table-core/build/lib/index.js";
18
18
  function Gt({
19
19
  columns: Q,
20
- data: P,
20
+ data: j,
21
21
  loading: B = !1,
22
22
  emptyComponent: Ie,
23
23
  className: Se,
24
24
  rowSelection: Te = {},
25
25
  onRowSelectionChange: ie,
26
- checkable: V = !1,
26
+ checkable: P = !1,
27
27
  onCheckedRowsChange: Y,
28
28
  actions: ze = [],
29
29
  customComponentsLeft: ve,
@@ -32,10 +32,10 @@ function Gt({
32
32
  hideActionsRow: _e = !1,
33
33
  i18n: h = pt,
34
34
  maxSortedColumns: se = 2,
35
- initialState: m,
35
+ initialState: d,
36
36
  // New mode-based API
37
37
  serverMode: a = !1,
38
- serverConfig: d,
38
+ serverConfig: m,
39
39
  disableAutoPageSize: F = !1
40
40
  }) {
41
41
  const q = f(null), le = (e) => !e || !e.sort_by || !e.sort_order ? [] : e.sort_by.map((t, o) => ({
@@ -51,10 +51,12 @@ function Gt({
51
51
  computedFilter: e?.computedFilter
52
52
  // Use provided value or undefined
53
53
  };
54
- }, [O, He] = u(() => le(m?.sorting)), [Ne] = u([]), [Oe, Ge] = u({}), [g, Le] = u(() => m?.filters?.searchbarFilter), [E, G] = u(() => m?.pagination ?? { pageIndex: 0, pageSize: 10 }), ce = f(d);
55
- ce.current = d;
56
- const W = f(d?.onStateChange);
57
- W.current = d?.onStateChange;
54
+ }, [O, He] = u(() => le(d?.sorting)), [Ne] = u([]), [Oe, Ge] = u(
55
+ () => d?.columnVisibility ?? {}
56
+ ), [g, Le] = u(() => d?.filters?.searchbarFilter), [E, G] = u(() => d?.pagination ?? { pageIndex: 0, pageSize: 10 }), ce = f(m);
57
+ ce.current = m;
58
+ const W = f(m?.onStateChange);
59
+ W.current = m?.onStateChange;
58
60
  const J = f(null), M = f(null), ke = f(0), ue = f(!1), de = f(null), K = f({}), me = f(null), Z = f(B);
59
61
  Z.current = B;
60
62
  const L = (e) => {
@@ -78,19 +80,19 @@ function Gt({
78
80
  };
79
81
  }, []);
80
82
  const [n, k] = u(() => {
81
- const { computedSorting: e, computedFilter: t } = De(m);
83
+ const { computedSorting: e, computedFilter: t } = De(d);
82
84
  return {
83
- pagination: m?.pagination ?? { pageIndex: 0, pageSize: 10 },
84
- sorting: m?.sorting,
85
- filters: m?.filters,
86
- computedFilter: m?.computedFilter ?? t,
87
- computedSorting: m?.computedSorting ?? e
85
+ pagination: d?.pagination ?? { pageIndex: 0, pageSize: 10 },
86
+ sorting: d?.sorting,
87
+ filters: d?.filters,
88
+ computedFilter: d?.computedFilter ?? t,
89
+ computedSorting: d?.computedSorting ?? e
88
90
  };
89
91
  });
90
- a && !d && console.warn("DataTable: Server mode requires serverConfig");
91
- const [Ae, ge] = u(0), [je, pe] = u(0), [Pe, Ve] = u({}), fe = ie ? Te : Pe, qe = ie || Ve, [w, $] = u(
92
- () => m?.filters?.filterBadges ?? []
93
- ), [y, ee] = u(() => m?.filters?.advancedFilterBadge), [U, Ee] = u(""), [he, be] = u([]), Fe = C(() => V ? [
92
+ a && !m && console.warn("DataTable: Server mode requires serverConfig");
93
+ const [Ae, ge] = u(0), [Ve, pe] = u(0), [je, Pe] = u({}), fe = ie ? Te : je, qe = ie || Pe, [w, $] = u(
94
+ () => d?.filters?.filterBadges ?? []
95
+ ), [y, ee] = u(() => d?.filters?.advancedFilterBadge), [U, Ee] = u(""), [he, be] = u([]), Fe = C(() => P ? [
94
96
  {
95
97
  id: "data-table-integrated-checkbox-column",
96
98
  size: 24,
@@ -141,7 +143,7 @@ function Gt({
141
143
  }
142
144
  },
143
145
  ...Q
144
- ] : Q, [Q, V]), T = C(() => Fe.map(
146
+ ] : Q, [Q, P]), T = C(() => Fe.map(
145
147
  (e) => e
146
148
  ), [Fe]);
147
149
  N(() => {
@@ -150,11 +152,11 @@ function Gt({
150
152
  }, [T]);
151
153
  const _ = C(() => T.filter(
152
154
  (e) => !!e?.meta?.searchable
153
- ), [T]), z = C(() => _.map((e) => e.accessorKey ?? e.id).filter(Boolean), [_]), [X, We] = u(() => m?.computedFilter ?? {}), Je = {
154
- data: C(() => a || Object.keys(X).length === 0 ? P : P.filter((e) => Re({
155
+ ), [T]), z = C(() => _.map((e) => e.accessorKey ?? e.id).filter(Boolean), [_]), [X, We] = u(() => d?.computedFilter ?? {}), Je = {
156
+ data: C(() => a || Object.keys(X).length === 0 ? j : j.filter((e) => Re({
155
157
  original: e,
156
158
  getValue: (o) => e[o]
157
- }, X)), [P, X, a]),
159
+ }, X)), [j, X, a]),
158
160
  columns: T,
159
161
  getCoreRowModel: Ft(),
160
162
  onSortingChange: (e) => {
@@ -178,7 +180,7 @@ function Gt({
178
180
  advancedFilter: (e) => a ? !0 : Re(e, X)
179
181
  },
180
182
  onPaginationChange: (e) => {
181
- if (a && d) {
183
+ if (a && m) {
182
184
  if (typeof e == "object") {
183
185
  const t = F ? {
184
186
  ...n.pagination,
@@ -206,7 +208,7 @@ function Gt({
206
208
  },
207
209
  getPaginationRowModel: ft(),
208
210
  manualPagination: a,
209
- pageCount: a && B ? je : Ae,
211
+ pageCount: a && B ? Ve : Ae,
210
212
  state: {
211
213
  sorting: O,
212
214
  columnFilters: Ne,
@@ -220,9 +222,9 @@ function Gt({
220
222
  autoResetPageIndex: !1
221
223
  }, i = $e(Je), te = i.getFilteredRowModel();
222
224
  N(() => {
223
- if (a && d) {
225
+ if (a && m) {
224
226
  const e = Math.ceil(
225
- d.totalItems / (n.pagination.pageSize || 10)
227
+ m.totalItems / (n.pagination.pageSize || 10)
226
228
  );
227
229
  ge(e), !B && e > 0 && pe(e);
228
230
  } else {
@@ -231,7 +233,7 @@ function Gt({
231
233
  }
232
234
  }, [
233
235
  a,
234
- d?.totalItems,
236
+ m?.totalItems,
235
237
  n.pagination.pageSize,
236
238
  n.pagination.pageIndex,
237
239
  i,
@@ -254,7 +256,7 @@ function Gt({
254
256
  rowHeight: v,
255
257
  headerHeight: I,
256
258
  onPageChange: a ? (S, x) => {
257
- if (d && ue.current) {
259
+ if (m && ue.current) {
258
260
  const b = F ? {
259
261
  ...n.pagination,
260
262
  pageIndex: S
@@ -265,14 +267,14 @@ function Gt({
265
267
  }, re = b.pageIndex === n.pagination.pageIndex, oe = F || b.pageSize === n.pagination.pageSize;
266
268
  if (re && oe)
267
269
  return;
268
- const j = {
270
+ const V = {
269
271
  ...n,
270
272
  pagination: b,
271
273
  // Preserve computed values if they exist
272
274
  computedFilter: n.computedFilter,
273
275
  computedSorting: n.computedSorting
274
276
  };
275
- k(j), Z.current || L(j);
277
+ k(V), Z.current || L(V);
276
278
  }
277
279
  } : (S, x) => {
278
280
  G(
@@ -281,7 +283,7 @@ function Gt({
281
283
  },
282
284
  setPagination: (S) => {
283
285
  const x = typeof S == "function" ? S(n.pagination) : S;
284
- if (a && d) {
286
+ if (a && m) {
285
287
  const b = F ? {
286
288
  ...n.pagination,
287
289
  pageIndex: x.pageIndex
@@ -292,14 +294,14 @@ function Gt({
292
294
  }, re = b.pageIndex === n.pagination.pageIndex, oe = F || b.pageSize === n.pagination.pageSize;
293
295
  if (re && oe)
294
296
  return;
295
- const j = {
297
+ const V = {
296
298
  ...n,
297
299
  pagination: b,
298
300
  // Preserve computed values if they exist
299
301
  computedFilter: n.computedFilter,
300
302
  computedSorting: n.computedSorting
301
303
  };
302
- k(j), Z.current || L(j);
304
+ k(V), Z.current || L(V);
303
305
  } else
304
306
  G(
305
307
  (b) => F ? { ...b, pageIndex: x.pageIndex } : {
@@ -337,11 +339,11 @@ function Gt({
337
339
  // Recalculate when the rendered rows count changes; helps when data arrives async
338
340
  te.rows.length
339
341
  ]), N(() => {
340
- if (Y && V) {
342
+ if (Y && P) {
341
343
  const e = i.getFilteredSelectedRowModel().rows.map((t) => t.original);
342
344
  Y(e);
343
345
  }
344
- }, [i, Y, V, fe]);
346
+ }, [i, Y, P, fe]);
345
347
  const Ke = C(() => {
346
348
  const e = i.getHeaderGroups()[0], t = e ? e.headers : [];
347
349
  return (i.getState().sorting || []).map((s) => t.find((p) => p.column.id === s.id)).filter(Boolean);
@@ -530,7 +532,7 @@ function Gt({
530
532
  table: i,
531
533
  tableContainerRef: q,
532
534
  loading: B,
533
- data: P,
535
+ data: j,
534
536
  emptyComponent: Ie,
535
537
  notFoundMessage: h?.notFoundMessage ?? "N/A",
536
538
  onAddFilter: xe,
@@ -549,10 +551,10 @@ function Gt({
549
551
  isServerSide: a,
550
552
  clientPagination: E,
551
553
  serverState: a ? n : void 0,
552
- onServerStateChange: a && d ? (e) => {
554
+ onServerStateChange: a && m ? (e) => {
553
555
  k(e), L(e);
554
556
  } : void 0,
555
- totalItems: d?.totalItems,
557
+ totalItems: m?.totalItems,
556
558
  i18n: h
557
559
  }
558
560
  )
@@ -31,10 +31,10 @@ function y(e) {
31
31
  function h(e) {
32
32
  return a(e, "boolean");
33
33
  }
34
- function f(e) {
34
+ function C(e) {
35
35
  return a(e, "date");
36
36
  }
37
- function C(e) {
37
+ function f(e) {
38
38
  return a(e, "datetime");
39
39
  }
40
40
  function q(e) {
@@ -168,7 +168,7 @@ function D(e, t, r, l, n) {
168
168
  value: n
169
169
  });
170
170
  }
171
- function k(e, t, r, l, n, u, o) {
171
+ function V(e, t, r, l, n, u, o) {
172
172
  return s({
173
173
  columnId: e,
174
174
  columnAccessorKey: t,
@@ -185,7 +185,7 @@ function d(e) {
185
185
  sort_order: e.map((t) => t.order)
186
186
  };
187
187
  }
188
- function L(e) {
188
+ function k(e) {
189
189
  return {
190
190
  ...e.filters && {
191
191
  filters: {
@@ -199,19 +199,22 @@ function L(e) {
199
199
  }
200
200
  },
201
201
  ...e.sorting && { sorting: d(e.sorting) },
202
- ...e.pagination && { pagination: e.pagination }
202
+ ...e.pagination && { pagination: e.pagination },
203
+ ...e.columnVisibility && {
204
+ columnVisibility: e.columnVisibility
205
+ }
203
206
  };
204
207
  }
205
208
  function _(e) {
206
209
  return e.map((t) => ({ value: t, label: t }));
207
210
  }
208
- function $(e, t, r) {
211
+ function L(e, t, r) {
209
212
  return e.map((l) => ({
210
213
  value: String(l[t]),
211
214
  label: String(l[r])
212
215
  }));
213
216
  }
214
- function M(e, t, r) {
217
+ function $(e, t, r) {
215
218
  return e.map((l) => {
216
219
  if (l.accessorKey === t) {
217
220
  const u = typeof r[0] == "string" ? _(r) : r;
@@ -226,7 +229,7 @@ function M(e, t, r) {
226
229
  return l;
227
230
  });
228
231
  }
229
- function w(e, t) {
232
+ function M(e, t) {
230
233
  return e.map((r) => {
231
234
  const l = r.accessorKey || r.id, n = t.left?.includes(l) ? "left" : t.right?.includes(l) ? "right" : void 0;
232
235
  return n ? {
@@ -238,10 +241,10 @@ function w(e, t) {
238
241
  } : r;
239
242
  });
240
243
  }
241
- function N(e) {
244
+ function w(e) {
242
245
  return e.map((t) => t.accessorKey || t.id).filter(Boolean);
243
246
  }
244
- function V(e, t) {
247
+ function N(e, t) {
245
248
  return {
246
249
  string: [
247
250
  "like",
@@ -277,15 +280,15 @@ export {
277
280
  h as createBooleanColumn,
278
281
  B as createBooleanFilter,
279
282
  S as createComputedColumn,
280
- f as createDateColumn,
283
+ C as createDateColumn,
281
284
  A as createDateFilter,
282
- C as createDateTimeColumn,
285
+ f as createDateTimeColumn,
283
286
  D as createDateTimeFilter,
284
287
  v as createDisplayColumn,
285
288
  s as createFilterBadge,
286
289
  O as createFilterBadges,
287
- L as createInitialState,
288
- k as createListFilter,
290
+ k as createInitialState,
291
+ V as createListFilter,
289
292
  F as createMultiSelectColumn,
290
293
  y as createNumberColumn,
291
294
  I as createNumberFilter,
@@ -293,10 +296,10 @@ export {
293
296
  d as createSorting,
294
297
  b as createStringColumn,
295
298
  T as createStringFilter,
296
- N as getColumnIds,
297
- V as isValidOperatorForType,
298
- w as pinColumns,
299
+ w as getColumnIds,
300
+ N as isValidOperatorForType,
301
+ M as pinColumns,
299
302
  _ as toSelectOptions,
300
- $ as toSelectOptionsFromObjects,
301
- M as updateColumnListOptions
303
+ L as toSelectOptionsFromObjects,
304
+ $ as updateColumnListOptions
302
305
  };
package/dist/index.d.ts CHANGED
@@ -1032,7 +1032,7 @@ export declare function createFilterBadges(configs: FilterBadgeConfig[]): DataTa
1032
1032
  * pagination: { pageIndex: 0, pageSize: 20 }
1033
1033
  * })
1034
1034
  */
1035
- export declare function createInitialState(config: InitialStateConfig): DataTableState;
1035
+ export declare function createInitialState<TData = Record<string, unknown>>(config: InitialStateConfig<TData>): DataTableState<TData>;
1036
1036
 
1037
1037
  /**
1038
1038
  * Creates a list filter badge
@@ -1444,7 +1444,7 @@ export declare interface DataTableProps<TData, TValue> {
1444
1444
  hideActionsRow?: boolean;
1445
1445
  i18n?: DataTableI18n;
1446
1446
  maxSortedColumns?: number;
1447
- initialState?: DataTableState;
1447
+ initialState?: DataTableState<TData>;
1448
1448
  serverMode?: boolean;
1449
1449
  serverConfig?: DataTableServerConfig;
1450
1450
  disableAutoPageSize?: boolean;
@@ -1460,13 +1460,14 @@ export declare interface DataTableSorting {
1460
1460
  sort_order: ("asc" | "desc")[];
1461
1461
  }
1462
1462
 
1463
- export declare interface DataTableState {
1463
+ export declare interface DataTableState<TData = Record<string, unknown>> {
1464
1464
  filters?: IFilterState;
1465
1465
  sorting?: DataTableSorting;
1466
1466
  pagination?: DataTablePagination;
1467
1467
  searchbarFilter?: string;
1468
1468
  computedFilter?: DataTableFilterForSearch;
1469
1469
  computedSorting?: DataTableSorting;
1470
+ columnVisibility?: Partial<Record<keyof TData, boolean>>;
1470
1471
  }
1471
1472
 
1472
1473
  export declare function DatePicker({ value, onChange, placeholder, dateFormat, className, disabled, size, firstDate, lastDate, availableDates, locale, initialCalendarMonth, customCalendarProps, label, wrpClassName, }: DatePickerProps): JSX.Element;
@@ -1768,7 +1769,7 @@ declare interface IFilterState {
1768
1769
  searchbarFilter?: string;
1769
1770
  }
1770
1771
 
1771
- declare interface InitialStateConfig {
1772
+ declare interface InitialStateConfig<TData = Record<string, unknown>> {
1772
1773
  filters?: DataTableBadgeFilter[];
1773
1774
  searchbarFilter?: string;
1774
1775
  sorting?: Array<{
@@ -1779,6 +1780,7 @@ declare interface InitialStateConfig {
1779
1780
  pageIndex: number;
1780
1781
  pageSize: number;
1781
1782
  };
1783
+ columnVisibility?: Partial<Record<keyof TData, boolean>>;
1782
1784
  }
1783
1785
 
1784
1786
  export declare const Input: React_2.ForwardRefExoticComponent<Omit<InputProps, "ref"> & React_2.RefAttributes<HTMLInputElement>>;
@@ -3,7 +3,7 @@ import { stringify as w } from "../../comma-separated-tokens/index.js";
3
3
  import { ok as u } from "../../devlop/lib/default.js";
4
4
  import { svg as m, html as C } from "../../property-information/index.js";
5
5
  import { stringify as N } from "../../space-separated-tokens/index.js";
6
- import S from "../../../_virtual/index5.js";
6
+ import S from "../../../_virtual/index4.js";
7
7
  import { whitespace as j } from "../../hast-util-whitespace/lib/index.js";
8
8
  import { name as x } from "../../estree-util-is-identifier-name/lib/index.js";
9
9
  import { VFileMessage as h } from "../../vfile-message/lib/index.js";
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
  import { bail as P } from "../../bail/index.js";
3
- import y from "../../../_virtual/index4.js";
3
+ import y from "../../../_virtual/index5.js";
4
4
  import z from "../../is-plain-obj/index.js";
5
5
  import { CallableInstance as C } from "./callable-instance.js";
6
6
  import { trough as A } from "../../trough/lib/index.js";