laif-ds 0.1.40 → 0.1.41
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,67 +1,56 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsxs as
|
|
3
|
-
import { useState as
|
|
4
|
-
import { useReactTable as
|
|
5
|
-
import { useVirtualizer as
|
|
6
|
-
import { TableSkeleton as
|
|
7
|
-
import { TruncatedText as
|
|
8
|
-
import { EditControls as
|
|
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";
|
|
9
9
|
import { Icon as U } from "../../icon.js";
|
|
10
|
-
import { Popover as
|
|
10
|
+
import { Popover as De, PopoverTrigger as Re, PopoverContent as $e } from "../../popover.js";
|
|
11
11
|
import { Button as k } from "../../button.js";
|
|
12
|
-
import { TableRow as
|
|
13
|
-
import { getSortedRowModel as
|
|
14
|
-
function
|
|
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({
|
|
15
15
|
crossTableData: $,
|
|
16
16
|
filterable: b = !1,
|
|
17
|
-
loading:
|
|
18
|
-
emptyComponent:
|
|
19
|
-
className:
|
|
20
|
-
notFoundMessage:
|
|
21
|
-
cornerHeaderFrom:
|
|
22
|
-
cornerHeaderTo:
|
|
23
|
-
maxHeaderLength:
|
|
24
|
-
minWidthCell:
|
|
25
|
-
editable:
|
|
26
|
-
editMode:
|
|
27
|
-
editConfirmLabel:
|
|
28
|
-
editCancelLabel:
|
|
29
|
-
onConfirmedCells:
|
|
30
|
-
onEditModeChange:
|
|
31
|
-
onSelectedRow:
|
|
32
|
-
selectedRow:
|
|
33
|
-
rowSortAsc:
|
|
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
|
|
34
34
|
}) {
|
|
35
|
-
var
|
|
36
|
-
const [
|
|
37
|
-
(
|
|
38
|
-
), [
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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(
|
|
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(
|
|
56
45
|
(t) => {
|
|
57
46
|
t && l && T(l.value), y(t);
|
|
58
47
|
},
|
|
59
48
|
[l]
|
|
60
|
-
),
|
|
61
|
-
l &&
|
|
49
|
+
), ge = I(() => {
|
|
50
|
+
l && z !== null ? (S((t) => ({
|
|
62
51
|
...t,
|
|
63
52
|
[l.cellKey]: {
|
|
64
|
-
value:
|
|
53
|
+
value: z,
|
|
65
54
|
cell: l.cellData
|
|
66
55
|
}
|
|
67
56
|
})), p[l.cellKey] && x((t) => {
|
|
@@ -70,16 +59,16 @@ function nt({
|
|
|
70
59
|
}), setTimeout(() => {
|
|
71
60
|
y(!1);
|
|
72
61
|
}, 300)) : y(!1);
|
|
73
|
-
}, [l,
|
|
74
|
-
l && (T(l.originalValue),
|
|
62
|
+
}, [l, z, p]), ve = I(() => {
|
|
63
|
+
l && (T(l.originalValue), S((t) => {
|
|
75
64
|
const e = { ...t };
|
|
76
65
|
return e[l.cellKey] && delete e[l.cellKey], e;
|
|
77
66
|
}), x((t) => {
|
|
78
67
|
const e = { ...t };
|
|
79
68
|
return e[l.cellKey] && delete e[l.cellKey], e;
|
|
80
69
|
})), y(!1);
|
|
81
|
-
}, [l]),
|
|
82
|
-
l && (
|
|
70
|
+
}, [l]), xe = I(() => {
|
|
71
|
+
l && (S((t) => {
|
|
83
72
|
const e = { ...t };
|
|
84
73
|
return e[l.cellKey] && delete e[l.cellKey], e;
|
|
85
74
|
}), x((t) => ({
|
|
@@ -89,50 +78,50 @@ function nt({
|
|
|
89
78
|
cell: l.cellData
|
|
90
79
|
}
|
|
91
80
|
}))), y(!1);
|
|
92
|
-
}, [l]),
|
|
81
|
+
}, [l]), ye = I(
|
|
93
82
|
(t) => {
|
|
94
83
|
T(t.target.value);
|
|
95
84
|
},
|
|
96
85
|
[]
|
|
97
|
-
),
|
|
98
|
-
if (!
|
|
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;
|
|
99
88
|
const e = f.findIndex(
|
|
100
|
-
(n) => n.id ===
|
|
89
|
+
(n) => n.id === w
|
|
101
90
|
);
|
|
102
91
|
if (e === -1) return m;
|
|
103
|
-
const
|
|
92
|
+
const r = m.map((n, i) => {
|
|
104
93
|
var g;
|
|
105
|
-
const
|
|
94
|
+
const s = ((g = v[e]) == null ? void 0 : g[i]) ?? null, a = be(s);
|
|
106
95
|
return { header: n, value: a };
|
|
107
96
|
});
|
|
108
|
-
return
|
|
109
|
-
if (typeof n.value == "number" && typeof
|
|
110
|
-
return
|
|
111
|
-
const
|
|
112
|
-
return
|
|
113
|
-
}),
|
|
114
|
-
}, [m, f, v,
|
|
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(() => {
|
|
115
104
|
const t = [
|
|
116
105
|
{
|
|
117
106
|
id: "cross-header",
|
|
118
|
-
header: () => /* @__PURE__ */
|
|
119
|
-
/* @__PURE__ */
|
|
120
|
-
/* @__PURE__ */
|
|
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 })
|
|
121
110
|
] }),
|
|
122
111
|
accessorFn: (e) => e.item,
|
|
123
112
|
cell: (e) => {
|
|
124
|
-
const
|
|
113
|
+
const r = e.getValue();
|
|
125
114
|
if (!b)
|
|
126
|
-
return /* @__PURE__ */
|
|
127
|
-
|
|
115
|
+
return /* @__PURE__ */ o(
|
|
116
|
+
R,
|
|
128
117
|
{
|
|
129
|
-
text:
|
|
130
|
-
maxLength:
|
|
118
|
+
text: r.label,
|
|
119
|
+
maxLength: C,
|
|
131
120
|
className: "w-full"
|
|
132
121
|
}
|
|
133
122
|
);
|
|
134
|
-
const n =
|
|
135
|
-
return /* @__PURE__ */
|
|
123
|
+
const n = w === r.id;
|
|
124
|
+
return /* @__PURE__ */ o(
|
|
136
125
|
k,
|
|
137
126
|
{
|
|
138
127
|
variant: "ghost",
|
|
@@ -140,9 +129,9 @@ function nt({
|
|
|
140
129
|
iconLeft: "ArrowLeftRight",
|
|
141
130
|
className: "text-right",
|
|
142
131
|
onClick: () => {
|
|
143
|
-
b && (n ?
|
|
132
|
+
b && (n ? F((i) => !i) : (P(f[e.row.index].id), F(!0), q && q(f[e.row.index])));
|
|
144
133
|
},
|
|
145
|
-
children: /* @__PURE__ */
|
|
134
|
+
children: /* @__PURE__ */ o(R, { text: r.label, maxLength: C })
|
|
146
135
|
}
|
|
147
136
|
);
|
|
148
137
|
}
|
|
@@ -151,376 +140,362 @@ function nt({
|
|
|
151
140
|
return h.forEach((e) => {
|
|
152
141
|
t.push({
|
|
153
142
|
id: e.id,
|
|
154
|
-
accessorFn: (
|
|
155
|
-
header: ({ column:
|
|
143
|
+
accessorFn: (r) => r[e.id],
|
|
144
|
+
header: ({ column: r }) => b ? /* @__PURE__ */ o(
|
|
156
145
|
k,
|
|
157
146
|
{
|
|
158
147
|
variant: "ghost",
|
|
159
148
|
size: "sm",
|
|
160
149
|
iconLeft: "ArrowUpDown",
|
|
161
|
-
onClick: b ? () =>
|
|
162
|
-
children: /* @__PURE__ */
|
|
150
|
+
onClick: b ? () => r.toggleSorting(r.getIsSorted() === "asc") : void 0,
|
|
151
|
+
children: /* @__PURE__ */ o(R, { text: e.label, maxLength: C })
|
|
163
152
|
}
|
|
164
|
-
) : /* @__PURE__ */
|
|
165
|
-
|
|
153
|
+
) : /* @__PURE__ */ o(
|
|
154
|
+
R,
|
|
166
155
|
{
|
|
167
156
|
text: e.label,
|
|
168
|
-
maxLength:
|
|
157
|
+
maxLength: C,
|
|
169
158
|
className: "font-medium"
|
|
170
159
|
}
|
|
171
160
|
),
|
|
172
|
-
sortingFn: (
|
|
173
|
-
let
|
|
174
|
-
return
|
|
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)));
|
|
175
164
|
},
|
|
176
|
-
cell: (
|
|
177
|
-
const n =
|
|
178
|
-
return n ? n.render ? n.render(n.fromId, n.toId, n.id) : /* @__PURE__ */
|
|
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;
|
|
179
168
|
}
|
|
180
169
|
});
|
|
181
170
|
}), t;
|
|
182
171
|
}, [
|
|
183
172
|
h,
|
|
184
|
-
A,
|
|
185
173
|
K,
|
|
186
|
-
|
|
174
|
+
M,
|
|
175
|
+
d,
|
|
187
176
|
b,
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
]),
|
|
192
|
-
const
|
|
177
|
+
C,
|
|
178
|
+
P,
|
|
179
|
+
F
|
|
180
|
+
]), we = Y(() => f.map((t, e) => {
|
|
181
|
+
const r = { item: t };
|
|
193
182
|
return h.forEach((n) => {
|
|
194
|
-
var
|
|
195
|
-
const
|
|
196
|
-
|
|
197
|
-
}),
|
|
198
|
-
}), [f, h, v, m]), _ =
|
|
199
|
-
data:
|
|
200
|
-
columns:
|
|
201
|
-
state: { sorting:
|
|
202
|
-
onSortingChange:
|
|
203
|
-
getCoreRowModel:
|
|
204
|
-
getSortedRowModel:
|
|
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()
|
|
205
194
|
});
|
|
206
195
|
if (!v || v.length === 0)
|
|
207
|
-
return /* @__PURE__ */
|
|
208
|
-
if (
|
|
209
|
-
return /* @__PURE__ */
|
|
210
|
-
|
|
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,
|
|
211
200
|
{
|
|
212
201
|
headerRow: h.map((t) => t.label),
|
|
213
202
|
rowCount: f.length || 5,
|
|
214
203
|
columnCount: h.length || 5,
|
|
215
|
-
className:
|
|
216
|
-
cornerHeaderFrom:
|
|
217
|
-
cornerHeaderTo:
|
|
204
|
+
className: A,
|
|
205
|
+
cornerHeaderFrom: K,
|
|
206
|
+
cornerHeaderTo: M
|
|
218
207
|
}
|
|
219
208
|
);
|
|
220
|
-
const
|
|
221
|
-
const e = t.column.id === "cross-header",
|
|
222
|
-
e || n.push("border-r"), e && n.push("sticky left-0"), n.push("sticky top-0 z-20"),
|
|
223
|
-
let
|
|
224
|
-
return e && (
|
|
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)"), {
|
|
225
214
|
className: n.join(" "),
|
|
226
|
-
style: { boxShadow:
|
|
215
|
+
style: { boxShadow: i, width: `${E}px` }
|
|
227
216
|
};
|
|
228
|
-
},
|
|
217
|
+
}, G = ke(null), J = je({
|
|
229
218
|
count: _.getRowModel().rows.length,
|
|
230
|
-
getScrollElement: () =>
|
|
219
|
+
getScrollElement: () => G.current,
|
|
231
220
|
estimateSize: () => 40,
|
|
232
221
|
overscan: 5,
|
|
233
222
|
measureElement: typeof window < "u" ? (t) => t.getBoundingClientRect().height : void 0
|
|
234
223
|
});
|
|
235
|
-
return /* @__PURE__ */
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
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 w-full",
|
|
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
|
+
);
|
|
284
311
|
})
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
toDefaultCells: o
|
|
289
|
-
});
|
|
290
|
-
}
|
|
291
|
-
N({}), x({});
|
|
292
|
-
},
|
|
293
|
-
cancelAll: () => {
|
|
294
|
-
N({}), x({});
|
|
312
|
+
},
|
|
313
|
+
t.id
|
|
314
|
+
))
|
|
295
315
|
}
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
{
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
{
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
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,
|
|
316
344
|
{
|
|
317
|
-
className:
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
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,
|
|
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",
|
|
365
367
|
{
|
|
366
|
-
className:
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
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);
|
|
375
381
|
},
|
|
376
|
-
children:
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
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
|
|
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
|
+
}
|
|
434
408
|
);
|
|
435
|
-
})
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
}
|
|
441
|
-
|
|
442
|
-
|
|
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
|
|
443
449
|
}
|
|
444
|
-
)
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
] }),
|
|
464
|
-
/* @__PURE__ */ r(
|
|
465
|
-
"input",
|
|
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,
|
|
466
469
|
{
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
470
|
+
variant: "ghost",
|
|
471
|
+
size: "sm",
|
|
472
|
+
onClick: ve,
|
|
473
|
+
className: "text-xs",
|
|
474
|
+
title: "Annulla le modifiche correnti e chiudi",
|
|
475
|
+
children: "Annulla"
|
|
472
476
|
}
|
|
473
477
|
),
|
|
474
|
-
/* @__PURE__ */
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
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
|
-
] })
|
|
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
|
+
)
|
|
516
491
|
] })
|
|
517
|
-
}
|
|
518
|
-
)
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
}
|
|
522
|
-
);
|
|
492
|
+
] })
|
|
493
|
+
] })
|
|
494
|
+
}
|
|
495
|
+
)
|
|
496
|
+
] })
|
|
497
|
+
] });
|
|
523
498
|
}
|
|
524
499
|
export {
|
|
525
|
-
|
|
500
|
+
We as DataCrossTable
|
|
526
501
|
};
|