laif-ds 0.2.75 → 0.2.77

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,111 +1,112 @@
1
1
  "use client";
2
- import { jsx as r, jsxs as D } from "react/jsx-runtime";
3
- import { flexRender as ee } from "../../../../../node_modules/@tanstack/react-table/build/lib/index.js";
4
- import { useRef as te, useState as E, useMemo as b, useCallback as F, useLayoutEffect as oe, useEffect as G } from "react";
5
- import { cn as ne } from "../../../../../lib/utils.js";
6
- import { ScrollArea as re, ScrollBar as L } from "../../../scroll-area.js";
7
- import { Table as se, TableBody as C, TableRow as P, TableCell as A } from "../../../table.js";
8
- import { getPinnedStyle as ie } from "../data-table.service.js";
9
- import { DataTableHeaderComponent as ce } from "./data-table-header.js";
10
- import { SkeletonRows as le } from "./data-table-skeleton-rows.js";
11
- function be({
2
+ import { jsx as s, jsxs as C } from "react/jsx-runtime";
3
+ import { flexRender as oe } from "../../../../../node_modules/@tanstack/react-table/build/lib/index.js";
4
+ import { useRef as ne, useState as G, useMemo as b, useCallback as F, useLayoutEffect as re, useEffect as B } from "react";
5
+ import { cn as L } from "../../../../../lib/utils.js";
6
+ import { ScrollArea as se, ScrollBar as P } from "../../../scroll-area.js";
7
+ import { Table as ie, TableBody as A, TableRow as I, TableCell as M } from "../../../table.js";
8
+ import { getPinnedStyle as ce } from "../data-table.service.js";
9
+ import { DataTableHeaderComponent as le } from "./data-table-header.js";
10
+ import { SkeletonRows as ue } from "./data-table-skeleton-rows.js";
11
+ function Re({
12
12
  table: u,
13
- tableContainerRef: s,
13
+ tableContainerRef: i,
14
14
  loading: d,
15
- data: I,
16
- emptyComponent: M,
17
- notFoundMessage: W,
18
- onAddFilter: j,
19
- maxSortedColumns: V = 3,
20
- i18n: $,
15
+ data: W,
16
+ emptyComponent: j,
17
+ notFoundMessage: V,
18
+ onAddFilter: $,
19
+ maxSortedColumns: U = 3,
20
+ i18n: J,
21
21
  isServerSide: p = !1,
22
- filterBadges: U = [],
22
+ filterBadges: K = [],
23
23
  advancedFilterBadge: R,
24
- searchbarGlobalFilter: J,
25
- serverDebounceTime: N = 750
24
+ searchbarGlobalFilter: Q,
25
+ serverDebounceTime: D = 750,
26
+ rowClassName: x
26
27
  }) {
27
- const K = (e) => {
28
- if (U.some((n) => n.columnId === e)) return !0;
29
- const o = (n) => n.some((c) => c.columnId === e), i = (n) => n ? n.some((c) => o(c.conditions) ? !0 : c.groups ? i(c.groups) : !1) : !1;
28
+ const X = (e) => {
29
+ if (K.some((r) => r.columnId === e)) return !0;
30
+ const o = (r) => r.some((c) => c.columnId === e), n = (r) => r ? r.some((c) => o(c.conditions) ? !0 : c.groups ? n(c.groups) : !1) : !1;
30
31
  if (R?.rootGroup) {
31
32
  if (o(R.rootGroup.conditions))
32
33
  return !0;
33
34
  if (R.rootGroup.groups)
34
- return i(R.rootGroup.groups);
35
+ return n(R.rootGroup.groups);
35
36
  }
36
37
  return !1;
37
- }, y = te({}), [z, Q] = E({}), [X, B] = E(8), [k, _] = E(!1), T = b(() => {
38
+ }, z = ne({}), [k, Y] = G({}), [Z, N] = G(8), [v, _] = G(!1), y = b(() => {
38
39
  let e;
39
40
  const t = (o) => {
40
41
  clearTimeout(e), e = setTimeout(
41
42
  () => _(o),
42
- N
43
+ D
43
44
  );
44
45
  };
45
46
  return t.cancel = () => {
46
47
  clearTimeout(e);
47
48
  }, t;
48
- }, [N]), q = b(() => {
49
+ }, [D]), q = b(() => {
49
50
  const e = u.getHeaderGroups()[0];
50
51
  return e ? e.headers : [];
51
52
  }, [u.getHeaderGroups]), g = b(
52
53
  () => q.filter((e) => e.column.getIsVisible()),
53
54
  [q]
54
- ), v = b(
55
+ ), H = b(
55
56
  () => g.filter((e) => e.column.columnDef.meta?.pinned === "left"),
56
57
  [g]
57
- ), H = b(
58
+ ), S = b(
58
59
  () => g.filter((e) => e.column.columnDef.meta?.pinned === "right"),
59
60
  [g]
60
- ), Y = b(
61
+ ), ee = b(
61
62
  () => g.map((e) => e.id).join("|"),
62
63
  [g]
63
- ), Z = u.getState().pagination, x = F(() => {
64
- const e = s.current;
64
+ ), te = u.getState().pagination, T = F(() => {
65
+ const e = i.current;
65
66
  if (!e) return 8;
66
- const t = e.querySelector("thead tr"), o = e.querySelector("tbody tr"), i = t?.getBoundingClientRect().height ?? 40, n = o?.getBoundingClientRect().height ?? 32.5, S = e.offsetHeight - i, w = Math.floor(S / n);
67
+ const t = e.querySelector("thead tr"), o = e.querySelector("tbody tr"), n = t?.getBoundingClientRect().height ?? 40, r = o?.getBoundingClientRect().height ?? 32.5, O = e.offsetHeight - n, w = Math.floor(O / r);
67
68
  return w > 1 ? w : 8;
68
- }, [s]), a = F(
69
+ }, [i]), a = F(
69
70
  (e = 0) => {
70
71
  const t = {};
71
72
  let o = !1;
72
- if (!s.current) {
73
+ if (!i.current) {
73
74
  e < 5 && setTimeout(() => a(e + 1), 100);
74
75
  return;
75
76
  }
76
- const i = s.current.querySelector(
77
+ const n = i.current.querySelector(
77
78
  "tbody tr:first-child"
78
79
  );
79
- let n = 0;
80
- for (const w of v) {
80
+ let r = 0;
81
+ for (const w of H) {
81
82
  const f = w.column.id;
82
- t[f] = { side: "left", offset: n };
83
+ t[f] = { side: "left", offset: r };
83
84
  let l = 0;
84
- const m = i?.querySelector(
85
+ const m = n?.querySelector(
85
86
  `[data-column-id="${f}"]`
86
- ), h = y.current[f];
87
- m && m.offsetWidth > 0 ? l = m.getBoundingClientRect().width : h && h.offsetWidth > 0 ? l = h.getBoundingClientRect().width : (o = !0, l = 150), n += l;
87
+ ), h = z.current[f];
88
+ m && m.offsetWidth > 0 ? l = m.getBoundingClientRect().width : h && h.offsetWidth > 0 ? l = h.getBoundingClientRect().width : (o = !0, l = 150), r += l;
88
89
  }
89
90
  let c = 0;
90
- for (const w of [...H].reverse()) {
91
+ for (const w of [...S].reverse()) {
91
92
  const f = w.column.id;
92
93
  t[f] = { side: "right", offset: c };
93
94
  let l = 0;
94
- const m = i?.querySelector(
95
+ const m = n?.querySelector(
95
96
  `[data-column-id="${f}"]`
96
- ), h = y.current[f];
97
+ ), h = z.current[f];
97
98
  m && m.offsetWidth > 0 ? l = m.getBoundingClientRect().width : h && h.offsetWidth > 0 ? l = h.getBoundingClientRect().width : (o = !0, l = 150), c += l;
98
99
  }
99
- Q(t);
100
- const S = x();
101
- B(S), o && e < 5 && setTimeout(
100
+ Y(t);
101
+ const O = T();
102
+ N(O), o && e < 5 && setTimeout(
102
103
  () => a(e + 1),
103
104
  100 * (e + 1)
104
105
  );
105
106
  },
106
- [x, v, H, s]
107
+ [T, H, S, i]
107
108
  );
108
- return oe(() => {
109
+ return re(() => {
109
110
  (() => {
110
111
  requestAnimationFrame(() => {
111
112
  requestAnimationFrame(() => {
@@ -116,33 +117,33 @@ function be({
116
117
  });
117
118
  })();
118
119
  }, [
119
- v,
120
120
  H,
121
- Y,
121
+ S,
122
+ ee,
122
123
  d,
123
- I,
124
- Z,
124
+ W,
125
+ te,
125
126
  a
126
- ]), G(() => {
127
+ ]), B(() => {
127
128
  const e = () => {
128
129
  clearTimeout(e.timeout), e.timeout = setTimeout(() => a(), 100);
129
130
  };
130
131
  window.addEventListener("resize", e);
131
- const t = s.current;
132
+ const t = i.current;
132
133
  let o = null;
133
134
  return t && typeof ResizeObserver < "u" && (o = new ResizeObserver(() => {
134
135
  a();
135
136
  }), o.observe(t)), () => {
136
137
  window.removeEventListener("resize", e), clearTimeout(e.timeout), o && o.disconnect();
137
138
  };
138
- }, [a, s]), G(() => {
139
+ }, [a, i]), B(() => {
139
140
  if (d) {
140
141
  const e = () => {
141
- const i = x();
142
- B(i);
142
+ const n = T();
143
+ N(n);
143
144
  };
144
145
  e();
145
- const t = s.current;
146
+ const t = i.current;
146
147
  let o = null;
147
148
  return t && typeof ResizeObserver < "u" && (o = new ResizeObserver(() => {
148
149
  e();
@@ -150,84 +151,91 @@ function be({
150
151
  o && o.disconnect();
151
152
  };
152
153
  }
153
- }, [x, d, s]), G(() => (d ? (_(!0), T.cancel()) : T(!1), () => {
154
- T.cancel();
155
- }), [d, T]), /* @__PURE__ */ r(
154
+ }, [T, d, i]), B(() => (d ? (_(!0), y.cancel()) : y(!1), () => {
155
+ y.cancel();
156
+ }), [d, y]), /* @__PURE__ */ s(
156
157
  "div",
157
158
  {
158
159
  className: "flex max-h-full min-h-0 max-w-full min-w-0 flex-1",
159
- ref: s,
160
- children: /* @__PURE__ */ D(re, { className: "border-d-border h-full min-h-0 w-full rounded-md border", children: [
161
- /* @__PURE__ */ r(L, { orientation: "horizontal", className: "z-[100]" }),
162
- /* @__PURE__ */ r(L, { orientation: "vertical" }),
163
- /* @__PURE__ */ D(se, { className: "w-full min-w-max", children: [
164
- /* @__PURE__ */ r(
165
- ce,
160
+ ref: i,
161
+ children: /* @__PURE__ */ C(se, { className: "border-d-border h-full min-h-0 w-full rounded-md border", children: [
162
+ /* @__PURE__ */ s(P, { orientation: "horizontal", className: "z-[100]" }),
163
+ /* @__PURE__ */ s(P, { orientation: "vertical" }),
164
+ /* @__PURE__ */ C(ie, { className: "w-full min-w-max", children: [
165
+ /* @__PURE__ */ s(
166
+ le,
166
167
  {
167
168
  table: u,
168
- headerRefs: y,
169
- pinnedOffsets: z,
170
- maxSortedColumns: V,
171
- i18n: $,
172
- searchbarGlobalFilter: J,
173
- isColumnFiltered: K,
174
- onAddFilter: j
169
+ headerRefs: z,
170
+ pinnedOffsets: k,
171
+ maxSortedColumns: U,
172
+ i18n: J,
173
+ searchbarGlobalFilter: Q,
174
+ isColumnFiltered: X,
175
+ onAddFilter: $
175
176
  }
176
177
  ),
177
- /* @__PURE__ */ r(
178
- C,
178
+ /* @__PURE__ */ s(
179
+ A,
179
180
  {
180
181
  "data-table-body": "skeleton",
181
- className: p && k || !p && d ? "" : "absolute -z-100 h-0 min-h-0 overflow-hidden opacity-0",
182
- children: (p && k || !p && d) && /* @__PURE__ */ r(
183
- le,
182
+ className: p && v || !p && d ? "" : "absolute -z-100 h-0 min-h-0 overflow-hidden opacity-0",
183
+ children: (p && v || !p && d) && /* @__PURE__ */ s(
184
+ ue,
184
185
  {
185
- skeletonRowCount: X,
186
- pinnedOffsets: z,
186
+ skeletonRowCount: Z,
187
+ pinnedOffsets: k,
187
188
  table: u
188
189
  }
189
190
  )
190
191
  }
191
192
  ),
192
- /* @__PURE__ */ r(
193
- C,
193
+ /* @__PURE__ */ s(
194
+ A,
194
195
  {
195
196
  "data-table-body": "data",
196
- className: p && k || !p && d ? "absolute -z-100 h-0 min-h-0 overflow-hidden opacity-0" : "",
197
- children: u.getRowModel().rows?.length ? u.getRowModel().rows.map((e) => /* @__PURE__ */ r(
198
- P,
197
+ className: p && v || !p && d ? "absolute -z-100 h-0 min-h-0 overflow-hidden opacity-0" : "",
198
+ children: u.getRowModel().rows?.length ? u.getRowModel().rows.map((e) => /* @__PURE__ */ s(
199
+ I,
199
200
  {
200
201
  "data-state": e.getIsSelected() && "selected",
201
- className: "border-0 shadow-[inset_0_-1px_0_var(--d-border)]",
202
- children: e.getVisibleCells().map((t) => /* @__PURE__ */ r(
203
- A,
204
- {
205
- "data-column-id": t.column.id,
206
- className: ne(
207
- "border-0",
208
- t.column.columnDef.meta?.pinned ? "bg-d-background z-[50]" : "shadow-[inset_-1px_0_0_var(--d-border)]"
209
- ),
210
- style: ie(
211
- t.column.id,
212
- z,
213
- t.column.columnDef.meta?.pinned,
214
- !1
215
- ),
216
- children: ee(
217
- t.column.columnDef.cell,
218
- t.getContext()
219
- )
220
- },
221
- t.id
222
- ))
202
+ className: L(
203
+ "border-0 shadow-[inset_0_-1px_0_var(--d-border)]",
204
+ typeof x == "function" ? x(e) : x
205
+ ),
206
+ children: e.getVisibleCells().map((t) => {
207
+ const o = t.column.columnDef.meta?.cellClassName, n = typeof o == "function" ? o(t.getValue(), e.original) : o;
208
+ return /* @__PURE__ */ s(
209
+ M,
210
+ {
211
+ "data-column-id": t.column.id,
212
+ className: L(
213
+ "border-0",
214
+ t.column.columnDef.meta?.pinned ? "bg-d-background z-[50]" : "shadow-[inset_-1px_0_0_var(--d-border)]",
215
+ n
216
+ ),
217
+ style: ce(
218
+ t.column.id,
219
+ k,
220
+ t.column.columnDef.meta?.pinned,
221
+ !1
222
+ ),
223
+ children: oe(
224
+ t.column.columnDef.cell,
225
+ t.getContext()
226
+ )
227
+ },
228
+ t.id
229
+ );
230
+ })
223
231
  },
224
232
  e.id
225
- )) : /* @__PURE__ */ r(P, { children: /* @__PURE__ */ r(
226
- A,
233
+ )) : /* @__PURE__ */ s(I, { children: /* @__PURE__ */ s(
234
+ M,
227
235
  {
228
236
  colSpan: u?.getHeaderGroups()?.[0]?.headers?.length ?? 1,
229
237
  className: "pt-4 text-center",
230
- children: M || W
238
+ children: j || V
231
239
  }
232
240
  ) })
233
241
  }
@@ -238,5 +246,5 @@ function be({
238
246
  );
239
247
  }
240
248
  export {
241
- be as DataTableBody
249
+ Re as DataTableBody
242
250
  };
@@ -6,8 +6,8 @@ import { cn as l } from "../../../../../lib/utils.js";
6
6
  import { Button as i } from "../../../button.js";
7
7
  import { Icon as m } from "../../../icon.js";
8
8
  import { Popover as D, PopoverTrigger as y, PopoverContent as N } from "../../../popover.js";
9
- import { TableHeader as I, TableRow as h, TableHead as z } from "../../../table.js";
10
- import { getPinnedStyle as C } from "../data-table.service.js";
9
+ import { TableHeader as I, TableRow as h, TableHead as C } from "../../../table.js";
10
+ import { getPinnedStyle as z } from "../data-table.service.js";
11
11
  function F({
12
12
  table: r,
13
13
  headerRefs: g,
@@ -20,16 +20,17 @@ function F({
20
20
  }) {
21
21
  const [x, u] = S.useState({});
22
22
  return /* @__PURE__ */ t(I, { children: r.getHeaderGroups().map((a) => /* @__PURE__ */ t(h, { children: a.headers.map((e) => /* @__PURE__ */ t(
23
- z,
23
+ C,
24
24
  {
25
25
  ref: (o) => {
26
26
  g.current[e.column.id] = o;
27
27
  },
28
28
  className: l(
29
29
  "bg-d-background sticky top-0 h-8 px-0",
30
- e.column.columnDef.meta?.pinned ? "z-[49]" : "z-10"
30
+ e.column.columnDef.meta?.pinned ? "z-[49]" : "z-10",
31
+ e.column.columnDef.meta?.headerClassName
31
32
  ),
32
- style: C(
33
+ style: z(
33
34
  e.column.id,
34
35
  d,
35
36
  e.column.columnDef.meta?.pinned,