laif-ds 0.1.40 → 0.1.42

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