laif-ds 0.1.39 → 0.1.40

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,56 +1,67 @@
1
1
  "use client";
2
- import { jsxs as c, jsx as o } from "react/jsx-runtime";
3
- import { useState as u, useEffect as ee, useCallback as I, useMemo as Y, useRef as ke } from "react";
4
- import { useReactTable as Ve, flexRender as te } from "../../../../node_modules/@tanstack/react-table/build/lib/index.js";
5
- import { useVirtualizer as je } from "../../../../node_modules/@tanstack/react-virtual/dist/esm/index.js";
6
- import { TableSkeleton as ze } from "../../table-skeleton.js";
7
- import { TruncatedText as R } from "./truncated-text.js";
8
- import { EditControls as Te } from "./edit-controls.js";
2
+ import { jsxs as d, jsx as r } from "react/jsx-runtime";
3
+ import { useState as c, useRef as oe, useEffect as X, useCallback as I, useMemo as Y } from "react";
4
+ import { useReactTable as Re, flexRender as re } from "../../../../node_modules/@tanstack/react-table/build/lib/index.js";
5
+ import { useVirtualizer as Te } from "../../../../node_modules/@tanstack/react-virtual/dist/esm/index.js";
6
+ import { TableSkeleton as Ee } from "../../table-skeleton.js";
7
+ import { TruncatedText as D } from "./truncated-text.js";
8
+ import { EditControls as De } from "./edit-controls.js";
9
9
  import { Icon as U } from "../../icon.js";
10
- import { Popover as De, PopoverTrigger as Re, PopoverContent as $e } from "../../popover.js";
10
+ import { Popover as $e, PopoverTrigger as Oe, PopoverContent as Ae } from "../../popover.js";
11
11
  import { Button as k } from "../../button.js";
12
- import { TableRow as X, TableCell as le, Table as Ae, TableHeader as Ke, TableHead as Me, TableBody as Ee } from "../../table.js";
13
- import { getSortedRowModel as Oe, getCoreRowModel as Le } from "../../../../node_modules/@tanstack/table-core/build/lib/index.js";
14
- function We({
12
+ import { TableRow as q, TableCell as se, Table as Ke, TableHeader as Le, TableHead as Me, TableBody as Pe } from "../../table.js";
13
+ import { getSortedRowModel as Be, getCoreRowModel as Fe } from "../../../../node_modules/@tanstack/table-core/build/lib/index.js";
14
+ function nt({
15
15
  crossTableData: $,
16
16
  filterable: b = !1,
17
- loading: ne = !1,
18
- emptyComponent: oe,
19
- className: A,
20
- notFoundMessage: re = "Nessun risultato trovato.",
21
- cornerHeaderFrom: K = "Da",
22
- cornerHeaderTo: M = "A",
23
- maxHeaderLength: C = 15,
24
- minWidthCell: E = 160,
25
- editable: O = !1,
26
- editMode: se = !1,
27
- editConfirmLabel: ie = "Conferma",
28
- editCancelLabel: ae = "Annulla",
29
- onConfirmedCells: V,
30
- onEditModeChange: L,
31
- onSelectedRow: q,
32
- selectedRow: d,
33
- rowSortAsc: ce = !0
17
+ loading: ie = !1,
18
+ emptyComponent: ae,
19
+ className: O,
20
+ notFoundMessage: de = "Nessun risultato trovato.",
21
+ cornerHeaderFrom: A = "Da",
22
+ cornerHeaderTo: K = "A",
23
+ maxHeaderLength: w = 15,
24
+ minWidthCell: L = 160,
25
+ editable: M = !1,
26
+ editMode: ce = !1,
27
+ editConfirmLabel: ue = "Conferma",
28
+ editCancelLabel: fe = "Annulla",
29
+ onConfirmedCells: z,
30
+ onEditModeChange: P,
31
+ onSelectedRow: G,
32
+ selectedRow: u,
33
+ rowSortAsc: me = !0
34
34
  }) {
35
- var Q, Z;
36
- const [de, ue] = u([]), m = $.headerTop, f = $.headerLeft, v = $.data, [w, P] = u(
37
- (d == null ? void 0 : d.id) ?? null
38
- ), [B, F] = u(ce), [j, fe] = u(O && se);
39
- ee(() => {
40
- L && L(!!j);
41
- }, [j, L]), ee(() => {
42
- d != null && d.id && P(d.id);
43
- }, [d]);
44
- const [N, S] = u({}), [p, x] = u({}), [l, me] = u(null), [pe, y] = u(!1), [z, T] = u(null), he = I(
35
+ var ee, te;
36
+ const [pe, he] = c([]), m = $.headerTop, f = $.headerLeft, v = $.data, [C, B] = c(
37
+ (u == null ? void 0 : u.id) ?? null
38
+ ), [F, W] = c(me), [V, ge] = c(M && ce), [J, Q] = c(0), j = oe(null);
39
+ X(() => {
40
+ const t = () => {
41
+ if (j.current && j.current.parentElement) {
42
+ const e = j.current.parentElement.clientWidth, o = window.getComputedStyle(
43
+ j.current.parentElement
44
+ ), n = parseInt(o.paddingLeft, 10) || 0, s = parseInt(o.paddingRight, 10) || 0;
45
+ Q(e - n - s);
46
+ } else
47
+ Q(document.body.clientWidth - 40);
48
+ };
49
+ return window.addEventListener("resize", t), setTimeout(t, 0), () => window.removeEventListener("resize", t);
50
+ }, []), X(() => {
51
+ P && P(!!V);
52
+ }, [V, P]), X(() => {
53
+ u != null && u.id && B(u.id);
54
+ }, [u]);
55
+ const [S, N] = c({}), [p, x] = c({}), [l, ve] = c(null), [xe, y] = c(!1), [R, T] = c(null), ye = I(
45
56
  (t) => {
46
57
  t && l && T(l.value), y(t);
47
58
  },
48
59
  [l]
49
- ), ge = I(() => {
50
- l && z !== null ? (S((t) => ({
60
+ ), be = I(() => {
61
+ l && R !== null ? (N((t) => ({
51
62
  ...t,
52
63
  [l.cellKey]: {
53
- value: z,
64
+ value: R,
54
65
  cell: l.cellData
55
66
  }
56
67
  })), p[l.cellKey] && x((t) => {
@@ -59,16 +70,16 @@ function We({
59
70
  }), setTimeout(() => {
60
71
  y(!1);
61
72
  }, 300)) : y(!1);
62
- }, [l, z, p]), ve = I(() => {
63
- l && (T(l.originalValue), S((t) => {
73
+ }, [l, R, p]), we = I(() => {
74
+ l && (T(l.originalValue), N((t) => {
64
75
  const e = { ...t };
65
76
  return e[l.cellKey] && delete e[l.cellKey], e;
66
77
  }), x((t) => {
67
78
  const e = { ...t };
68
79
  return e[l.cellKey] && delete e[l.cellKey], e;
69
80
  })), y(!1);
70
- }, [l]), xe = I(() => {
71
- l && (S((t) => {
81
+ }, [l]), Ce = I(() => {
82
+ l && (N((t) => {
72
83
  const e = { ...t };
73
84
  return e[l.cellKey] && delete e[l.cellKey], e;
74
85
  }), x((t) => ({
@@ -78,50 +89,50 @@ function We({
78
89
  cell: l.cellData
79
90
  }
80
91
  }))), y(!1);
81
- }, [l]), ye = I(
92
+ }, [l]), Se = I(
82
93
  (t) => {
83
94
  T(t.target.value);
84
95
  },
85
96
  []
86
- ), be = (t) => t && typeof t == "object" && "value" in t ? t.value : t, h = Y(() => {
87
- if (!w || !f.find((n) => n.id === w)) return m;
97
+ ), Ne = (t) => t && typeof t == "object" && "value" in t ? t.value : t, h = Y(() => {
98
+ if (!C || !f.find((n) => n.id === C)) return m;
88
99
  const e = f.findIndex(
89
- (n) => n.id === w
100
+ (n) => n.id === C
90
101
  );
91
102
  if (e === -1) return m;
92
- const r = m.map((n, i) => {
103
+ const o = m.map((n, s) => {
93
104
  var g;
94
- const s = ((g = v[e]) == null ? void 0 : g[i]) ?? null, a = be(s);
105
+ const i = ((g = v[e]) == null ? void 0 : g[s]) ?? null, a = Ne(i);
95
106
  return { header: n, value: a };
96
107
  });
97
- return r.sort((n, i) => {
98
- if (typeof n.value == "number" && typeof i.value == "number")
99
- return B ? n.value - i.value : i.value - n.value;
100
- const s = String(n.value ?? ""), a = String(i.value ?? "");
101
- return B ? s.localeCompare(a) : a.localeCompare(s);
102
- }), r.map((n) => n.header);
103
- }, [m, f, v, w, B]), Ce = Y(() => {
108
+ return o.sort((n, s) => {
109
+ if (typeof n.value == "number" && typeof s.value == "number")
110
+ return F ? n.value - s.value : s.value - n.value;
111
+ const i = String(n.value ?? ""), a = String(s.value ?? "");
112
+ return F ? i.localeCompare(a) : a.localeCompare(i);
113
+ }), o.map((n) => n.header);
114
+ }, [m, f, v, C, F]), Ie = Y(() => {
104
115
  const t = [
105
116
  {
106
117
  id: "cross-header",
107
- header: () => /* @__PURE__ */ c("div", { className: "relative", children: [
108
- /* @__PURE__ */ o("div", { className: "absolute top-0 left-2 text-xs", children: K }),
109
- /* @__PURE__ */ o("div", { className: "absolute right-2 bottom-0 text-xs", children: M })
118
+ header: () => /* @__PURE__ */ d("div", { className: "relative", children: [
119
+ /* @__PURE__ */ r("div", { className: "absolute top-0 left-2 text-xs", children: A }),
120
+ /* @__PURE__ */ r("div", { className: "absolute right-2 bottom-0 text-xs", children: K })
110
121
  ] }),
111
122
  accessorFn: (e) => e.item,
112
123
  cell: (e) => {
113
- const r = e.getValue();
124
+ const o = e.getValue();
114
125
  if (!b)
115
- return /* @__PURE__ */ o(
116
- R,
126
+ return /* @__PURE__ */ r(
127
+ D,
117
128
  {
118
- text: r.label,
119
- maxLength: C,
129
+ text: o.label,
130
+ maxLength: w,
120
131
  className: "w-full"
121
132
  }
122
133
  );
123
- const n = w === r.id;
124
- return /* @__PURE__ */ o(
134
+ const n = C === o.id;
135
+ return /* @__PURE__ */ r(
125
136
  k,
126
137
  {
127
138
  variant: "ghost",
@@ -129,9 +140,9 @@ function We({
129
140
  iconLeft: "ArrowLeftRight",
130
141
  className: "text-right",
131
142
  onClick: () => {
132
- b && (n ? F((i) => !i) : (P(f[e.row.index].id), F(!0), q && q(f[e.row.index])));
143
+ b && (n ? W((s) => !s) : (B(f[e.row.index].id), W(!0), G && G(f[e.row.index])));
133
144
  },
134
- children: /* @__PURE__ */ o(R, { text: r.label, maxLength: C })
145
+ children: /* @__PURE__ */ r(D, { text: o.label, maxLength: w })
135
146
  }
136
147
  );
137
148
  }
@@ -140,362 +151,376 @@ function We({
140
151
  return h.forEach((e) => {
141
152
  t.push({
142
153
  id: e.id,
143
- accessorFn: (r) => r[e.id],
144
- header: ({ column: r }) => b ? /* @__PURE__ */ o(
154
+ accessorFn: (o) => o[e.id],
155
+ header: ({ column: o }) => b ? /* @__PURE__ */ r(
145
156
  k,
146
157
  {
147
158
  variant: "ghost",
148
159
  size: "sm",
149
160
  iconLeft: "ArrowUpDown",
150
- onClick: b ? () => r.toggleSorting(r.getIsSorted() === "asc") : void 0,
151
- children: /* @__PURE__ */ o(R, { text: e.label, maxLength: C })
161
+ onClick: b ? () => o.toggleSorting(o.getIsSorted() === "asc") : void 0,
162
+ children: /* @__PURE__ */ r(D, { text: e.label, maxLength: w })
152
163
  }
153
- ) : /* @__PURE__ */ o(
154
- R,
164
+ ) : /* @__PURE__ */ r(
165
+ D,
155
166
  {
156
167
  text: e.label,
157
- maxLength: C,
168
+ maxLength: w,
158
169
  className: "font-medium"
159
170
  }
160
171
  ),
161
- sortingFn: (r, n, i) => {
162
- let s = r.getValue(i), a = n.getValue(i);
163
- return s == null && a == null ? 0 : s == null ? 1 : a == null ? -1 : (s && typeof s == "object" && "value" in s && (s = s.value), a && typeof a == "object" && "value" in a && (a = a.value), typeof s == "number" && typeof a == "number" ? s - a : String(s).localeCompare(String(a)));
172
+ sortingFn: (o, n, s) => {
173
+ let i = o.getValue(s), a = n.getValue(s);
174
+ return i == null && a == null ? 0 : i == null ? 1 : a == null ? -1 : (i && typeof i == "object" && "value" in i && (i = i.value), a && typeof a == "object" && "value" in a && (a = a.value), typeof i == "number" && typeof a == "number" ? i - a : String(i).localeCompare(String(a)));
164
175
  },
165
- cell: (r) => {
166
- const n = r.getValue();
167
- return n ? n.render ? n.render(n.fromId, n.toId, n.id) : /* @__PURE__ */ o("div", { children: n.value }) : null;
176
+ cell: (o) => {
177
+ const n = o.getValue();
178
+ return n ? n.render ? n.render(n.fromId, n.toId, n.id) : /* @__PURE__ */ r("div", { children: n.value }) : null;
168
179
  }
169
180
  });
170
181
  }), t;
171
182
  }, [
172
183
  h,
184
+ A,
173
185
  K,
174
- M,
175
- d,
186
+ u,
176
187
  b,
177
- C,
178
- P,
179
- F
180
- ]), we = Y(() => f.map((t, e) => {
181
- const r = { item: t };
188
+ w,
189
+ B,
190
+ W
191
+ ]), ke = Y(() => f.map((t, e) => {
192
+ const o = { item: t };
182
193
  return h.forEach((n) => {
183
- var s;
184
- const i = m.findIndex((a) => a.id === n.id);
185
- r[n.id] = i !== -1 ? ((s = v[e]) == null ? void 0 : s[i]) ?? null : null;
186
- }), r;
187
- }), [f, h, v, m]), _ = Ve({
188
- data: we,
189
- columns: Ce,
190
- state: { sorting: de },
191
- onSortingChange: ue,
192
- getCoreRowModel: Le(),
193
- getSortedRowModel: Oe()
194
+ var i;
195
+ const s = m.findIndex((a) => a.id === n.id);
196
+ o[n.id] = s !== -1 ? ((i = v[e]) == null ? void 0 : i[s]) ?? null : null;
197
+ }), o;
198
+ }), [f, h, v, m]), _ = Re({
199
+ data: ke,
200
+ columns: Ie,
201
+ state: { sorting: pe },
202
+ onSortingChange: he,
203
+ getCoreRowModel: Fe(),
204
+ getSortedRowModel: Be()
194
205
  });
195
206
  if (!v || v.length === 0)
196
- return /* @__PURE__ */ o("div", { className: A, children: /* @__PURE__ */ o(X, { children: /* @__PURE__ */ o(le, { colSpan: h.length + 1, children: oe || re }) }) });
197
- if (ne)
198
- return /* @__PURE__ */ o(
199
- ze,
207
+ return /* @__PURE__ */ r("div", { className: O, children: /* @__PURE__ */ r(q, { children: /* @__PURE__ */ r(se, { colSpan: h.length + 1, children: ae || de }) }) });
208
+ if (ie)
209
+ return /* @__PURE__ */ r(
210
+ Ee,
200
211
  {
201
212
  headerRow: h.map((t) => t.label),
202
213
  rowCount: f.length || 5,
203
214
  columnCount: h.length || 5,
204
- className: A,
205
- cornerHeaderFrom: K,
206
- cornerHeaderTo: M
215
+ className: O,
216
+ cornerHeaderFrom: A,
217
+ cornerHeaderTo: K
207
218
  }
208
219
  );
209
- const Ne = (t) => {
210
- const e = t.column.id === "cross-header", r = e, n = ["bg-d-secondary"];
211
- e || n.push("border-r"), e && n.push("sticky left-0"), n.push("sticky top-0 z-20"), r ? n.push("z-40") : e && n.push("z-30");
212
- let i = "none";
213
- return e && (i = "inset -1px 0 0 0 var(--d-border), 0 1px 0 0 var(--d-border)"), {
220
+ const ze = (t) => {
221
+ const e = t.column.id === "cross-header", o = e, n = ["bg-d-secondary"];
222
+ e || n.push("border-r"), e && n.push("sticky left-0"), n.push("sticky top-0 z-20"), o ? n.push("z-40") : e && n.push("z-30");
223
+ let s = "none";
224
+ return e && (s = "inset -1px 0 0 0 var(--d-border), 0 1px 0 0 var(--d-border)"), {
214
225
  className: n.join(" "),
215
- style: { boxShadow: i, width: `${E}px` }
226
+ style: { boxShadow: s, width: `${L}px` }
216
227
  };
217
- }, G = ke(null), J = je({
228
+ }, Z = oe(null), H = Te({
218
229
  count: _.getRowModel().rows.length,
219
- getScrollElement: () => G.current,
230
+ getScrollElement: () => Z.current,
220
231
  estimateSize: () => 40,
221
232
  overscan: 5,
222
233
  measureElement: typeof window < "u" ? (t) => t.getBoundingClientRect().height : void 0
223
234
  });
224
- return /* @__PURE__ */ c("div", { className: `w-[900px] ${A || ""}`, children: [
225
- O && /* @__PURE__ */ o(
226
- Te,
227
- {
228
- editable: O,
229
- editConfirmLabel: ie,
230
- editCancelLabel: ae,
231
- editRestoreDefaultLabel: "Ripristina Default",
232
- editMode: j,
233
- setEditMode: fe,
234
- editedCount: Object.keys(N).length,
235
- defaultCount: Object.keys(p).length,
236
- restoreDefault: () => {
237
- if (V) {
238
- const t = Object.entries(p).map(
239
- ([r, { value: n, cell: i }]) => ({
240
- fromId: i.fromId,
241
- toId: i.toId,
242
- id: i.id,
243
- value: n
244
- })
245
- );
246
- V({
247
- editedCells: [],
248
- toDefaultCells: t
249
- });
250
- }
251
- x({});
252
- },
253
- confirmAll: () => {
254
- if (V && (Object.keys(N).length > 0 || Object.keys(p).length > 0)) {
255
- const e = Object.entries(N).map(
256
- ([i, { value: s, cell: a }]) => ({
257
- fromId: a.fromId,
258
- toId: a.toId,
259
- id: a.id,
260
- value: s
261
- })
262
- ), r = Object.entries(p).map(
263
- ([i, { value: s, cell: a }]) => ({
264
- fromId: a.fromId,
265
- toId: a.toId,
266
- id: a.id,
267
- value: s
268
- })
269
- );
270
- V({
271
- editedCells: e,
272
- toDefaultCells: r
273
- });
274
- }
275
- S({}), x({});
276
- },
277
- cancelAll: () => {
278
- S({}), x({});
279
- }
280
- }
281
- ),
282
- /* @__PURE__ */ o(
283
- "div",
284
- {
285
- ref: G,
286
- className: "max-h-[600px] overflow-auto rounded-md border",
287
- children: /* @__PURE__ */ c(Ae, { className: "relative w-full table-fixed border-collapse", children: [
288
- /* @__PURE__ */ o(
289
- Ke,
290
- {
291
- className: "bg-d-secondary sticky top-0 z-20",
292
- style: { boxShadow: "0 1px 0 0 var(--d-border)" },
293
- children: _.getHeaderGroups().map((t) => /* @__PURE__ */ o(
294
- X,
295
- {
296
- className: "bg-d-secondary sticky top-0 z-20",
297
- children: t.headers.map((e) => {
298
- const r = Ne(e);
299
- return /* @__PURE__ */ o(
300
- Me,
301
- {
302
- className: r.className,
303
- style: r.style,
304
- children: e.isPlaceholder ? null : te(
305
- e.column.columnDef.header,
306
- e.getContext()
307
- )
308
- },
309
- e.id
310
- );
235
+ return /* @__PURE__ */ d(
236
+ "div",
237
+ {
238
+ className: O || "",
239
+ style: { width: `${J}px`, overflowX: "auto" },
240
+ children: [
241
+ M && /* @__PURE__ */ r(
242
+ De,
243
+ {
244
+ editable: M,
245
+ editConfirmLabel: ue,
246
+ editCancelLabel: fe,
247
+ editRestoreDefaultLabel: "Ripristina Default",
248
+ editMode: V,
249
+ setEditMode: ge,
250
+ editedCount: Object.keys(S).length,
251
+ defaultCount: Object.keys(p).length,
252
+ restoreDefault: () => {
253
+ if (z) {
254
+ const t = Object.entries(p).map(
255
+ ([o, { value: n, cell: s }]) => ({
256
+ fromId: s.fromId,
257
+ toId: s.toId,
258
+ id: s.id,
259
+ value: n
260
+ })
261
+ );
262
+ z({
263
+ editedCells: [],
264
+ toDefaultCells: t
265
+ });
266
+ }
267
+ x({});
268
+ },
269
+ confirmAll: () => {
270
+ if (z && (Object.keys(S).length > 0 || Object.keys(p).length > 0)) {
271
+ const e = Object.entries(S).map(
272
+ ([s, { value: i, cell: a }]) => ({
273
+ fromId: a.fromId,
274
+ toId: a.toId,
275
+ id: a.id,
276
+ value: i
311
277
  })
312
- },
313
- t.id
314
- ))
278
+ ), o = Object.entries(p).map(
279
+ ([s, { value: i, cell: a }]) => ({
280
+ fromId: a.fromId,
281
+ toId: a.toId,
282
+ id: a.id,
283
+ value: i
284
+ })
285
+ );
286
+ z({
287
+ editedCells: e,
288
+ toDefaultCells: o
289
+ });
290
+ }
291
+ N({}), x({});
292
+ },
293
+ cancelAll: () => {
294
+ N({}), x({});
315
295
  }
316
- ),
317
- /* @__PURE__ */ o(
318
- Ee,
319
- {
320
- style: {
321
- height: `${J.getTotalSize()}px`,
322
- position: "relative",
323
- width: "100%"
324
- },
325
- children: J.getVirtualItems().map((t) => {
326
- const e = _.getRowModel().rows[t.index];
327
- return /* @__PURE__ */ o(
328
- X,
329
- {
330
- "data-index": t.index,
331
- style: {
332
- position: "absolute",
333
- top: 0,
334
- left: 0,
335
- transform: `translateY(${t.start}px)`,
336
- width: "100%",
337
- height: `${t.size}px`,
338
- display: "flex"
339
- },
340
- children: e.getVisibleCells().map((r, n) => {
341
- const i = n === 0, s = r.getValue(), a = i ? "var(--d-secondary)" : (s == null ? void 0 : s.color) || "transparent";
342
- return /* @__PURE__ */ o(
343
- le,
296
+ }
297
+ ),
298
+ /* @__PURE__ */ r(
299
+ "div",
300
+ {
301
+ ref: Z,
302
+ className: "max-h-[600px] overflow-auto rounded-md border",
303
+ children: /* @__PURE__ */ d(
304
+ Ke,
305
+ {
306
+ className: "relative table-fixed border-collapse",
307
+ style: { width: `${J}px` },
308
+ children: [
309
+ /* @__PURE__ */ r(
310
+ Le,
311
+ {
312
+ className: "bg-d-secondary sticky top-0 z-20",
313
+ style: { boxShadow: "0 1px 0 0 var(--d-border)" },
314
+ children: _.getHeaderGroups().map((t) => /* @__PURE__ */ r(
315
+ q,
344
316
  {
345
- className: `text-center ${i ? "sticky left-0 z-10" : "border-r"}`,
346
- style: {
347
- boxShadow: i ? "inset -1px 0 0 0 var(--d-border)" : "none",
348
- backgroundColor: a,
349
- width: `${E}px`,
350
- flex: i ? "0 0 auto" : `1 0 ${E}px`,
351
- display: "flex",
352
- alignItems: "center",
353
- justifyContent: "center"
354
- },
355
- children: i || !j || !s ? (
356
- // Rendering normale per la prima colonna o quando non siamo in modalità edit
357
- te(
358
- r.column.columnDef.cell,
359
- r.getContext()
360
- )
361
- ) : (
362
- // Rendering con cella modificabile
363
- (() => {
364
- const g = `${e.index}-${r.column.id}`, D = g in N ? N[g].value : s.value || "", Se = D !== s.value, H = g in p;
365
- return /* @__PURE__ */ o(
366
- "div",
317
+ className: "bg-d-secondary sticky top-0 z-20",
318
+ children: t.headers.map((e) => {
319
+ const o = ze(e);
320
+ return /* @__PURE__ */ r(
321
+ Me,
322
+ {
323
+ className: o.className,
324
+ style: o.style,
325
+ children: e.isPlaceholder ? null : re(
326
+ e.column.columnDef.header,
327
+ e.getContext()
328
+ )
329
+ },
330
+ e.id
331
+ );
332
+ })
333
+ },
334
+ t.id
335
+ ))
336
+ }
337
+ ),
338
+ /* @__PURE__ */ r(
339
+ Pe,
340
+ {
341
+ style: {
342
+ height: `${H.getTotalSize()}px`,
343
+ position: "relative",
344
+ width: "100%"
345
+ },
346
+ children: H.getVirtualItems().map((t) => {
347
+ const e = _.getRowModel().rows[t.index];
348
+ return /* @__PURE__ */ r(
349
+ q,
350
+ {
351
+ "data-index": t.index,
352
+ style: {
353
+ position: "absolute",
354
+ top: 0,
355
+ left: 0,
356
+ transform: `translateY(${t.start}px)`,
357
+ width: "100%",
358
+ height: `${t.size}px`,
359
+ display: "flex"
360
+ },
361
+ children: e.getVisibleCells().map((o, n) => {
362
+ const s = n === 0, i = o.getValue(), a = s ? "var(--d-secondary)" : (i == null ? void 0 : i.color) || "transparent";
363
+ return /* @__PURE__ */ r(
364
+ se,
367
365
  {
368
- className: "flex w-full cursor-pointer items-center justify-center",
369
- onClick: (Ie) => {
370
- const W = Ie.currentTarget.getBoundingClientRect();
371
- me({
372
- cellKey: g,
373
- value: D,
374
- originalValue: s.value || "",
375
- cellData: s,
376
- position: {
377
- top: W.bottom + window.scrollY + 5,
378
- left: W.left + window.scrollX
379
- }
380
- }), T(D), y(!0);
366
+ className: `text-center ${s ? "sticky left-0 z-10" : "border-r"}`,
367
+ style: {
368
+ boxShadow: s ? "inset -1px 0 0 0 var(--d-border)" : "none",
369
+ backgroundColor: a,
370
+ width: `${L}px`,
371
+ flex: s ? "0 0 auto" : `1 0 ${L}px`,
372
+ display: "flex",
373
+ alignItems: "center",
374
+ justifyContent: "center"
381
375
  },
382
- children: /* @__PURE__ */ c("div", { className: "relative w-full flex-1 items-center justify-center text-center", children: [
383
- D || "",
384
- Se && !H && /* @__PURE__ */ o(
385
- "div",
386
- {
387
- className: "bg-d-primary absolute top-0 left-0 rounded p-1",
388
- title: "Valore modificato"
389
- }
390
- ),
391
- H && /* @__PURE__ */ o(
392
- "div",
393
- {
394
- className: "bg-d-destructive absolute top-0 right-0 rounded p-1",
395
- title: "Ripristino richiesto"
396
- }
397
- ),
398
- /* @__PURE__ */ o("span", { className: "text-d-muted-foreground ml-1 inline-flex items-center", children: /* @__PURE__ */ o(
399
- U,
400
- {
401
- name: "Pencil",
402
- size: "sm",
403
- className: "h-3 w-3"
404
- }
405
- ) })
406
- ] })
407
- }
376
+ children: s || !V || !i ? (
377
+ // Rendering normale per la prima colonna o quando non siamo in modalità edit
378
+ re(
379
+ o.column.columnDef.cell,
380
+ o.getContext()
381
+ )
382
+ ) : (
383
+ // Rendering con cella modificabile
384
+ (() => {
385
+ const g = `${e.index}-${o.column.id}`, E = g in S ? S[g].value : i.value || "", Ve = E !== i.value, ne = g in p;
386
+ return /* @__PURE__ */ r(
387
+ "div",
388
+ {
389
+ className: "flex w-full cursor-pointer items-center justify-center",
390
+ onClick: (je) => {
391
+ const le = je.currentTarget.getBoundingClientRect();
392
+ ve({
393
+ cellKey: g,
394
+ value: E,
395
+ originalValue: i.value || "",
396
+ cellData: i,
397
+ position: {
398
+ top: le.bottom + window.scrollY + 5,
399
+ left: le.left + window.scrollX
400
+ }
401
+ }), T(E), y(!0);
402
+ },
403
+ children: /* @__PURE__ */ d("div", { className: "relative w-full flex-1 items-center justify-center text-center", children: [
404
+ E || "",
405
+ Ve && !ne && /* @__PURE__ */ r(
406
+ "div",
407
+ {
408
+ className: "bg-d-primary absolute top-0 left-0 rounded p-1",
409
+ title: "Valore modificato"
410
+ }
411
+ ),
412
+ ne && /* @__PURE__ */ r(
413
+ "div",
414
+ {
415
+ className: "bg-d-destructive absolute top-0 right-0 rounded p-1",
416
+ title: "Ripristino richiesto"
417
+ }
418
+ ),
419
+ /* @__PURE__ */ r("span", { className: "text-d-muted-foreground ml-1 inline-flex items-center", children: /* @__PURE__ */ r(
420
+ U,
421
+ {
422
+ name: "Pencil",
423
+ size: "sm",
424
+ className: "h-3 w-3"
425
+ }
426
+ ) })
427
+ ] })
428
+ }
429
+ );
430
+ })()
431
+ )
432
+ },
433
+ o.id
408
434
  );
409
- })()
410
- )
411
- },
412
- r.id
413
- );
414
- })
415
- },
416
- e.id
417
- );
418
- })
419
- }
420
- )
421
- ] })
422
- }
423
- ),
424
- /* @__PURE__ */ c(De, { open: pe, onOpenChange: he, children: [
425
- /* @__PURE__ */ o(Re, { asChild: !0, children: /* @__PURE__ */ o("div", { style: { display: "none" } }) }),
426
- /* @__PURE__ */ o(
427
- $e,
428
- {
429
- className: "w-[400px] p-4",
430
- style: {
431
- position: l != null && l.position ? "absolute" : "fixed",
432
- top: (Q = l == null ? void 0 : l.position) != null && Q.top ? `${l.position.top}px` : "50%",
433
- left: (Z = l == null ? void 0 : l.position) != null && Z.left ? `${l.position.left}px` : "50%",
434
- transform: l != null && l.position ? "none" : "translate(-50%, -50%)"
435
- },
436
- children: /* @__PURE__ */ c("div", { className: "space-y-4", children: [
437
- /* @__PURE__ */ c("div", { className: "flex items-center justify-between", children: [
438
- /* @__PURE__ */ o("div", { className: "font-medium", children: "Modifica valore" }),
439
- l && l.value !== l.originalValue && /* @__PURE__ */ o("div", { className: "text-d-muted-foreground text-xs", children: "Valore modificato" })
440
- ] }),
441
- /* @__PURE__ */ o(
442
- "input",
443
- {
444
- type: "text",
445
- className: "bg-d-secondary w-full rounded border p-2",
446
- value: z || "",
447
- onChange: ye,
448
- autoFocus: !0
435
+ })
436
+ },
437
+ e.id
438
+ );
439
+ })
440
+ }
441
+ )
442
+ ]
449
443
  }
450
- ),
451
- /* @__PURE__ */ c("div", { className: "flex items-center justify-between", children: [
452
- /* @__PURE__ */ c(
453
- k,
454
- {
455
- variant: "destructive",
456
- size: "sm",
457
- onClick: xe,
458
- className: "text-xs",
459
- title: "Ripristina il valore originale e segna la cella come da ripristinare",
460
- children: [
461
- /* @__PURE__ */ o(U, { name: "RotateCcw", className: "mr-1 h-3 w-3" }),
462
- "Ripristina"
463
- ]
464
- }
465
- ),
466
- /* @__PURE__ */ c("div", { className: "flex space-x-2", children: [
467
- /* @__PURE__ */ o(
468
- k,
444
+ )
445
+ }
446
+ ),
447
+ /* @__PURE__ */ d($e, { open: xe, onOpenChange: ye, children: [
448
+ /* @__PURE__ */ r(Oe, { asChild: !0, children: /* @__PURE__ */ r("div", { style: { display: "none" } }) }),
449
+ /* @__PURE__ */ r(
450
+ Ae,
451
+ {
452
+ className: "w-[400px] p-4",
453
+ style: {
454
+ position: l != null && l.position ? "absolute" : "fixed",
455
+ top: (ee = l == null ? void 0 : l.position) != null && ee.top ? `${l.position.top}px` : "50%",
456
+ left: (te = l == null ? void 0 : l.position) != null && te.left ? `${l.position.left}px` : "50%",
457
+ transform: l != null && l.position ? "none" : "translate(-50%, -50%)"
458
+ },
459
+ children: /* @__PURE__ */ d("div", { className: "space-y-4", children: [
460
+ /* @__PURE__ */ d("div", { className: "flex items-center justify-between", children: [
461
+ /* @__PURE__ */ r("div", { className: "font-medium", children: "Modifica valore" }),
462
+ l && l.value !== l.originalValue && /* @__PURE__ */ r("div", { className: "text-d-muted-foreground text-xs", children: "Valore modificato" })
463
+ ] }),
464
+ /* @__PURE__ */ r(
465
+ "input",
469
466
  {
470
- variant: "ghost",
471
- size: "sm",
472
- onClick: ve,
473
- className: "text-xs",
474
- title: "Annulla le modifiche correnti e chiudi",
475
- children: "Annulla"
467
+ type: "text",
468
+ className: "bg-d-secondary w-full rounded border p-2",
469
+ value: R || "",
470
+ onChange: Se,
471
+ autoFocus: !0
476
472
  }
477
473
  ),
478
- /* @__PURE__ */ c(
479
- k,
480
- {
481
- size: "sm",
482
- onClick: ge,
483
- className: "text-xs",
484
- title: "Conferma le modifiche e salva",
485
- children: [
486
- /* @__PURE__ */ o(U, { name: "Check", className: "mr-1 h-3 w-3" }),
487
- "Conferma"
488
- ]
489
- }
490
- )
474
+ /* @__PURE__ */ d("div", { className: "flex items-center justify-between", children: [
475
+ /* @__PURE__ */ d(
476
+ k,
477
+ {
478
+ variant: "destructive",
479
+ size: "sm",
480
+ onClick: Ce,
481
+ className: "text-xs",
482
+ title: "Ripristina il valore originale e segna la cella come da ripristinare",
483
+ children: [
484
+ /* @__PURE__ */ r(U, { name: "RotateCcw", className: "mr-1 h-3 w-3" }),
485
+ "Ripristina"
486
+ ]
487
+ }
488
+ ),
489
+ /* @__PURE__ */ d("div", { className: "flex space-x-2", children: [
490
+ /* @__PURE__ */ r(
491
+ k,
492
+ {
493
+ variant: "ghost",
494
+ size: "sm",
495
+ onClick: we,
496
+ className: "text-xs",
497
+ title: "Annulla le modifiche correnti e chiudi",
498
+ children: "Annulla"
499
+ }
500
+ ),
501
+ /* @__PURE__ */ d(
502
+ k,
503
+ {
504
+ size: "sm",
505
+ onClick: be,
506
+ className: "text-xs",
507
+ title: "Conferma le modifiche e salva",
508
+ children: [
509
+ /* @__PURE__ */ r(U, { name: "Check", className: "mr-1 h-3 w-3" }),
510
+ "Conferma"
511
+ ]
512
+ }
513
+ )
514
+ ] })
515
+ ] })
491
516
  ] })
492
- ] })
493
- ] })
494
- }
495
- )
496
- ] })
497
- ] });
517
+ }
518
+ )
519
+ ] })
520
+ ]
521
+ }
522
+ );
498
523
  }
499
524
  export {
500
- We as DataCrossTable
525
+ nt as DataCrossTable
501
526
  };