laif-ds 0.1.37 → 0.1.39
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.
- package/dist/_virtual/index.js +2 -5
- package/dist/_virtual/index2.js +3 -2
- package/dist/_virtual/index3.js +4 -2
- package/dist/components/ui/tables/data-cross-table/data-cross-table.js +375 -222
- package/dist/components/ui/tables/data-cross-table/edit-controls.js +31 -40
- package/dist/node_modules/@radix-ui/react-use-is-hydrated/dist/index.js +1 -1
- package/dist/node_modules/react-is/index.js +1 -1
- package/dist/node_modules/recharts/es6/util/ReactUtils.js +1 -1
- package/dist/node_modules/use-sync-external-store/shim/index.js +1 -1
- package/package.json +1 -1
- package/dist/components/ui/tables/data-cross-table/editable-input.js +0 -100
package/dist/_virtual/index.js
CHANGED
package/dist/_virtual/index2.js
CHANGED
package/dist/_virtual/index3.js
CHANGED
|
@@ -1,329 +1,409 @@
|
|
|
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
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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
|
+
import { Icon as U } from "../../icon.js";
|
|
10
|
+
import { Popover as De, PopoverTrigger as Re, PopoverContent as $e } from "../../popover.js";
|
|
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({
|
|
15
|
+
crossTableData: $,
|
|
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
|
|
33
34
|
}) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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(
|
|
45
|
+
(t) => {
|
|
46
|
+
t && l && T(l.value), y(t);
|
|
47
|
+
},
|
|
48
|
+
[l]
|
|
49
|
+
), ge = I(() => {
|
|
50
|
+
l && z !== null ? (S((t) => ({
|
|
51
|
+
...t,
|
|
52
|
+
[l.cellKey]: {
|
|
53
|
+
value: z,
|
|
54
|
+
cell: l.cellData
|
|
55
|
+
}
|
|
56
|
+
})), p[l.cellKey] && x((t) => {
|
|
57
|
+
const e = { ...t };
|
|
58
|
+
return delete e[l.cellKey], e;
|
|
59
|
+
}), setTimeout(() => {
|
|
60
|
+
y(!1);
|
|
61
|
+
}, 300)) : y(!1);
|
|
62
|
+
}, [l, z, p]), ve = I(() => {
|
|
63
|
+
l && (T(l.originalValue), S((t) => {
|
|
64
|
+
const e = { ...t };
|
|
65
|
+
return e[l.cellKey] && delete e[l.cellKey], e;
|
|
66
|
+
}), x((t) => {
|
|
67
|
+
const e = { ...t };
|
|
68
|
+
return e[l.cellKey] && delete e[l.cellKey], e;
|
|
69
|
+
})), y(!1);
|
|
70
|
+
}, [l]), xe = I(() => {
|
|
71
|
+
l && (S((t) => {
|
|
72
|
+
const e = { ...t };
|
|
73
|
+
return e[l.cellKey] && delete e[l.cellKey], e;
|
|
74
|
+
}), x((t) => ({
|
|
75
|
+
...t,
|
|
76
|
+
[l.cellKey]: {
|
|
77
|
+
value: l.originalValue,
|
|
78
|
+
cell: l.cellData
|
|
79
|
+
}
|
|
80
|
+
}))), y(!1);
|
|
81
|
+
}, [l]), ye = I(
|
|
82
|
+
(t) => {
|
|
83
|
+
T(t.target.value);
|
|
84
|
+
},
|
|
85
|
+
[]
|
|
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;
|
|
88
|
+
const e = f.findIndex(
|
|
89
|
+
(n) => n.id === w
|
|
46
90
|
);
|
|
47
|
-
if (
|
|
48
|
-
const r =
|
|
49
|
-
var
|
|
50
|
-
const
|
|
51
|
-
return { header:
|
|
91
|
+
if (e === -1) return m;
|
|
92
|
+
const r = m.map((n, i) => {
|
|
93
|
+
var g;
|
|
94
|
+
const s = ((g = v[e]) == null ? void 0 : g[i]) ?? null, a = be(s);
|
|
95
|
+
return { header: n, value: a };
|
|
52
96
|
});
|
|
53
|
-
return r.sort((
|
|
54
|
-
if (typeof
|
|
55
|
-
return
|
|
56
|
-
const
|
|
57
|
-
return
|
|
58
|
-
}), r.map((
|
|
59
|
-
}, [
|
|
60
|
-
const
|
|
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(() => {
|
|
104
|
+
const t = [
|
|
61
105
|
{
|
|
62
106
|
id: "cross-header",
|
|
63
|
-
header: () => /* @__PURE__ */
|
|
64
|
-
/* @__PURE__ */
|
|
65
|
-
/* @__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 })
|
|
66
110
|
] }),
|
|
67
|
-
accessorFn: (
|
|
68
|
-
cell: (
|
|
69
|
-
const r =
|
|
70
|
-
if (!
|
|
71
|
-
return /* @__PURE__ */
|
|
72
|
-
|
|
111
|
+
accessorFn: (e) => e.item,
|
|
112
|
+
cell: (e) => {
|
|
113
|
+
const r = e.getValue();
|
|
114
|
+
if (!b)
|
|
115
|
+
return /* @__PURE__ */ o(
|
|
116
|
+
R,
|
|
73
117
|
{
|
|
74
118
|
text: r.label,
|
|
75
|
-
maxLength:
|
|
119
|
+
maxLength: C,
|
|
76
120
|
className: "w-full"
|
|
77
121
|
}
|
|
78
122
|
);
|
|
79
|
-
const
|
|
80
|
-
return /* @__PURE__ */
|
|
81
|
-
|
|
123
|
+
const n = w === r.id;
|
|
124
|
+
return /* @__PURE__ */ o(
|
|
125
|
+
k,
|
|
82
126
|
{
|
|
83
127
|
variant: "ghost",
|
|
84
128
|
size: "sm",
|
|
85
129
|
iconLeft: "ArrowLeftRight",
|
|
86
130
|
className: "text-right",
|
|
87
131
|
onClick: () => {
|
|
88
|
-
|
|
132
|
+
b && (n ? F((i) => !i) : (P(f[e.row.index].id), F(!0), q && q(f[e.row.index])));
|
|
89
133
|
},
|
|
90
|
-
children: /* @__PURE__ */
|
|
134
|
+
children: /* @__PURE__ */ o(R, { text: r.label, maxLength: C })
|
|
91
135
|
}
|
|
92
136
|
);
|
|
93
137
|
}
|
|
94
138
|
}
|
|
95
139
|
];
|
|
96
|
-
return
|
|
97
|
-
|
|
98
|
-
id:
|
|
99
|
-
accessorFn: (r) => r[
|
|
100
|
-
header: ({ column: r }) =>
|
|
101
|
-
|
|
140
|
+
return h.forEach((e) => {
|
|
141
|
+
t.push({
|
|
142
|
+
id: e.id,
|
|
143
|
+
accessorFn: (r) => r[e.id],
|
|
144
|
+
header: ({ column: r }) => b ? /* @__PURE__ */ o(
|
|
145
|
+
k,
|
|
102
146
|
{
|
|
103
147
|
variant: "ghost",
|
|
104
148
|
size: "sm",
|
|
105
149
|
iconLeft: "ArrowUpDown",
|
|
106
|
-
onClick:
|
|
107
|
-
children: /* @__PURE__ */
|
|
150
|
+
onClick: b ? () => r.toggleSorting(r.getIsSorted() === "asc") : void 0,
|
|
151
|
+
children: /* @__PURE__ */ o(R, { text: e.label, maxLength: C })
|
|
108
152
|
}
|
|
109
|
-
) : /* @__PURE__ */
|
|
110
|
-
|
|
153
|
+
) : /* @__PURE__ */ o(
|
|
154
|
+
R,
|
|
111
155
|
{
|
|
112
|
-
text:
|
|
113
|
-
maxLength:
|
|
156
|
+
text: e.label,
|
|
157
|
+
maxLength: C,
|
|
114
158
|
className: "font-medium"
|
|
115
159
|
}
|
|
116
160
|
),
|
|
117
|
-
sortingFn: (r,
|
|
118
|
-
let
|
|
119
|
-
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)));
|
|
120
164
|
},
|
|
121
165
|
cell: (r) => {
|
|
122
|
-
const
|
|
123
|
-
return
|
|
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;
|
|
124
168
|
}
|
|
125
169
|
});
|
|
126
|
-
}),
|
|
170
|
+
}), t;
|
|
127
171
|
}, [
|
|
128
|
-
c,
|
|
129
|
-
T,
|
|
130
|
-
j,
|
|
131
|
-
a,
|
|
132
172
|
h,
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
173
|
+
K,
|
|
174
|
+
M,
|
|
175
|
+
d,
|
|
176
|
+
b,
|
|
177
|
+
C,
|
|
178
|
+
P,
|
|
179
|
+
F
|
|
180
|
+
]), we = Y(() => f.map((t, e) => {
|
|
181
|
+
const r = { item: t };
|
|
182
|
+
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;
|
|
142
186
|
}), r;
|
|
143
|
-
}), [
|
|
144
|
-
data:
|
|
145
|
-
columns:
|
|
146
|
-
state: { sorting:
|
|
147
|
-
onSortingChange:
|
|
148
|
-
getCoreRowModel:
|
|
149
|
-
getSortedRowModel:
|
|
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()
|
|
150
194
|
});
|
|
151
|
-
if (!
|
|
152
|
-
return /* @__PURE__ */
|
|
153
|
-
if (
|
|
154
|
-
return /* @__PURE__ */
|
|
155
|
-
|
|
195
|
+
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,
|
|
156
200
|
{
|
|
157
|
-
headerRow:
|
|
158
|
-
rowCount:
|
|
159
|
-
columnCount:
|
|
160
|
-
className:
|
|
161
|
-
cornerHeaderFrom:
|
|
162
|
-
cornerHeaderTo:
|
|
201
|
+
headerRow: h.map((t) => t.label),
|
|
202
|
+
rowCount: f.length || 5,
|
|
203
|
+
columnCount: h.length || 5,
|
|
204
|
+
className: A,
|
|
205
|
+
cornerHeaderFrom: K,
|
|
206
|
+
cornerHeaderTo: M
|
|
163
207
|
}
|
|
164
208
|
);
|
|
165
|
-
const
|
|
166
|
-
const
|
|
167
|
-
|
|
168
|
-
let
|
|
169
|
-
return
|
|
170
|
-
className:
|
|
171
|
-
style: { boxShadow:
|
|
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)"), {
|
|
214
|
+
className: n.join(" "),
|
|
215
|
+
style: { boxShadow: i, width: `${E}px` }
|
|
172
216
|
};
|
|
173
|
-
},
|
|
174
|
-
count:
|
|
175
|
-
getScrollElement: () =>
|
|
217
|
+
}, G = ke(null), J = je({
|
|
218
|
+
count: _.getRowModel().rows.length,
|
|
219
|
+
getScrollElement: () => G.current,
|
|
176
220
|
estimateSize: () => 40,
|
|
177
221
|
overscan: 5,
|
|
178
|
-
measureElement: typeof window < "u" ? (
|
|
222
|
+
measureElement: typeof window < "u" ? (t) => t.getBoundingClientRect().height : void 0
|
|
179
223
|
});
|
|
180
|
-
return /* @__PURE__ */
|
|
181
|
-
|
|
182
|
-
|
|
224
|
+
return /* @__PURE__ */ c("div", { className: `w-[900px] ${A || ""}`, children: [
|
|
225
|
+
O && /* @__PURE__ */ o(
|
|
226
|
+
Te,
|
|
183
227
|
{
|
|
184
|
-
editable:
|
|
185
|
-
editConfirmLabel:
|
|
186
|
-
editCancelLabel:
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
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
|
+
},
|
|
190
253
|
confirmAll: () => {
|
|
191
|
-
if (
|
|
192
|
-
const
|
|
193
|
-
([
|
|
194
|
-
fromId:
|
|
195
|
-
toId:
|
|
196
|
-
id:
|
|
197
|
-
value:
|
|
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
|
|
198
261
|
})
|
|
199
|
-
), r = Object.entries(
|
|
200
|
-
([
|
|
201
|
-
fromId:
|
|
202
|
-
toId:
|
|
203
|
-
id:
|
|
204
|
-
value:
|
|
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
|
|
205
268
|
})
|
|
206
269
|
);
|
|
207
|
-
|
|
208
|
-
editedCells:
|
|
270
|
+
V({
|
|
271
|
+
editedCells: e,
|
|
209
272
|
toDefaultCells: r
|
|
210
273
|
});
|
|
211
274
|
}
|
|
212
|
-
|
|
275
|
+
S({}), x({});
|
|
213
276
|
},
|
|
214
277
|
cancelAll: () => {
|
|
215
|
-
|
|
278
|
+
S({}), x({});
|
|
216
279
|
}
|
|
217
280
|
}
|
|
218
281
|
),
|
|
219
|
-
/* @__PURE__ */
|
|
282
|
+
/* @__PURE__ */ o(
|
|
220
283
|
"div",
|
|
221
284
|
{
|
|
222
|
-
ref:
|
|
285
|
+
ref: G,
|
|
223
286
|
className: "max-h-[600px] overflow-auto rounded-md border",
|
|
224
|
-
children: /* @__PURE__ */
|
|
225
|
-
/* @__PURE__ */
|
|
226
|
-
|
|
287
|
+
children: /* @__PURE__ */ c(Ae, { className: "relative w-full table-fixed border-collapse", children: [
|
|
288
|
+
/* @__PURE__ */ o(
|
|
289
|
+
Ke,
|
|
227
290
|
{
|
|
228
291
|
className: "bg-d-secondary sticky top-0 z-20",
|
|
229
292
|
style: { boxShadow: "0 1px 0 0 var(--d-border)" },
|
|
230
|
-
children:
|
|
231
|
-
|
|
293
|
+
children: _.getHeaderGroups().map((t) => /* @__PURE__ */ o(
|
|
294
|
+
X,
|
|
232
295
|
{
|
|
233
296
|
className: "bg-d-secondary sticky top-0 z-20",
|
|
234
|
-
children:
|
|
235
|
-
const r =
|
|
236
|
-
return /* @__PURE__ */
|
|
237
|
-
|
|
297
|
+
children: t.headers.map((e) => {
|
|
298
|
+
const r = Ne(e);
|
|
299
|
+
return /* @__PURE__ */ o(
|
|
300
|
+
Me,
|
|
238
301
|
{
|
|
239
302
|
className: r.className,
|
|
240
303
|
style: r.style,
|
|
241
|
-
children:
|
|
242
|
-
|
|
243
|
-
|
|
304
|
+
children: e.isPlaceholder ? null : te(
|
|
305
|
+
e.column.columnDef.header,
|
|
306
|
+
e.getContext()
|
|
244
307
|
)
|
|
245
308
|
},
|
|
246
|
-
|
|
309
|
+
e.id
|
|
247
310
|
);
|
|
248
311
|
})
|
|
249
312
|
},
|
|
250
|
-
|
|
313
|
+
t.id
|
|
251
314
|
))
|
|
252
315
|
}
|
|
253
316
|
),
|
|
254
|
-
/* @__PURE__ */
|
|
255
|
-
|
|
317
|
+
/* @__PURE__ */ o(
|
|
318
|
+
Ee,
|
|
256
319
|
{
|
|
257
320
|
style: {
|
|
258
|
-
height: `${
|
|
321
|
+
height: `${J.getTotalSize()}px`,
|
|
259
322
|
position: "relative",
|
|
260
323
|
width: "100%"
|
|
261
324
|
},
|
|
262
|
-
children:
|
|
263
|
-
const
|
|
264
|
-
return /* @__PURE__ */
|
|
265
|
-
|
|
325
|
+
children: J.getVirtualItems().map((t) => {
|
|
326
|
+
const e = _.getRowModel().rows[t.index];
|
|
327
|
+
return /* @__PURE__ */ o(
|
|
328
|
+
X,
|
|
266
329
|
{
|
|
267
|
-
"data-index":
|
|
330
|
+
"data-index": t.index,
|
|
268
331
|
style: {
|
|
269
332
|
position: "absolute",
|
|
270
333
|
top: 0,
|
|
271
334
|
left: 0,
|
|
272
|
-
transform: `translateY(${
|
|
335
|
+
transform: `translateY(${t.start}px)`,
|
|
273
336
|
width: "100%",
|
|
274
|
-
height: `${
|
|
337
|
+
height: `${t.size}px`,
|
|
275
338
|
display: "flex"
|
|
276
339
|
},
|
|
277
|
-
children:
|
|
278
|
-
const
|
|
279
|
-
return /* @__PURE__ */
|
|
280
|
-
|
|
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,
|
|
281
344
|
{
|
|
282
|
-
className: `text-center ${
|
|
345
|
+
className: `text-center ${i ? "sticky left-0 z-10" : "border-r"}`,
|
|
283
346
|
style: {
|
|
284
|
-
boxShadow:
|
|
285
|
-
backgroundColor:
|
|
286
|
-
width: `${
|
|
287
|
-
flex:
|
|
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`,
|
|
288
351
|
display: "flex",
|
|
289
352
|
alignItems: "center",
|
|
290
353
|
justifyContent: "center"
|
|
291
354
|
},
|
|
292
|
-
children:
|
|
355
|
+
children: i || !j || !s ? (
|
|
293
356
|
// Rendering normale per la prima colonna o quando non siamo in modalità edit
|
|
294
|
-
|
|
357
|
+
te(
|
|
295
358
|
r.column.columnDef.cell,
|
|
296
359
|
r.getContext()
|
|
297
360
|
)
|
|
298
361
|
) : (
|
|
299
|
-
// Rendering con
|
|
362
|
+
// Rendering con cella modificabile
|
|
300
363
|
(() => {
|
|
301
|
-
const
|
|
302
|
-
return /* @__PURE__ */
|
|
303
|
-
|
|
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",
|
|
304
367
|
{
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
return delete p[y], p;
|
|
319
|
-
});
|
|
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);
|
|
320
381
|
},
|
|
321
|
-
|
|
322
|
-
D
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
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
|
+
] })
|
|
327
407
|
}
|
|
328
408
|
);
|
|
329
409
|
})()
|
|
@@ -333,16 +413,89 @@ function De({
|
|
|
333
413
|
);
|
|
334
414
|
})
|
|
335
415
|
},
|
|
336
|
-
|
|
416
|
+
e.id
|
|
337
417
|
);
|
|
338
418
|
})
|
|
339
419
|
}
|
|
340
420
|
)
|
|
341
421
|
] })
|
|
342
422
|
}
|
|
343
|
-
)
|
|
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
|
|
449
|
+
}
|
|
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,
|
|
469
|
+
{
|
|
470
|
+
variant: "ghost",
|
|
471
|
+
size: "sm",
|
|
472
|
+
onClick: ve,
|
|
473
|
+
className: "text-xs",
|
|
474
|
+
title: "Annulla le modifiche correnti e chiudi",
|
|
475
|
+
children: "Annulla"
|
|
476
|
+
}
|
|
477
|
+
),
|
|
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
|
+
)
|
|
491
|
+
] })
|
|
492
|
+
] })
|
|
493
|
+
] })
|
|
494
|
+
}
|
|
495
|
+
)
|
|
496
|
+
] })
|
|
344
497
|
] });
|
|
345
498
|
}
|
|
346
499
|
export {
|
|
347
|
-
|
|
500
|
+
We as DataCrossTable
|
|
348
501
|
};
|
|
@@ -1,47 +1,38 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsxs as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
({ onClick: e, label: t }) => /* @__PURE__ */ r(m, { variant: "ghost", size: "sm", onClick: e, children: t })
|
|
18
|
-
);
|
|
19
|
-
function k({
|
|
20
|
-
editConfirmLabel: e,
|
|
21
|
-
editCancelLabel: t,
|
|
22
|
-
editMode: n,
|
|
23
|
-
setEditMode: c,
|
|
24
|
-
editedCount: i,
|
|
25
|
-
confirmAll: s,
|
|
26
|
-
cancelAll: a,
|
|
27
|
-
editable: d
|
|
2
|
+
import { jsxs as r, jsx as c, Fragment as l } from "react/jsx-runtime";
|
|
3
|
+
import { Switch as x } from "../../switch.js";
|
|
4
|
+
import { Button as n } from "../../button.js";
|
|
5
|
+
function z({
|
|
6
|
+
editConfirmLabel: t,
|
|
7
|
+
editCancelLabel: o,
|
|
8
|
+
editRestoreDefaultLabel: h = "Restore Default",
|
|
9
|
+
editMode: s,
|
|
10
|
+
setEditMode: a,
|
|
11
|
+
editedCount: e,
|
|
12
|
+
defaultCount: i = 0,
|
|
13
|
+
confirmAll: d,
|
|
14
|
+
cancelAll: k,
|
|
15
|
+
restoreDefault: m,
|
|
16
|
+
editable: p
|
|
28
17
|
}) {
|
|
29
|
-
return
|
|
30
|
-
/* @__PURE__ */
|
|
31
|
-
/* @__PURE__ */
|
|
32
|
-
|
|
33
|
-
/* @__PURE__ */ r(
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
18
|
+
return p ? /* @__PURE__ */ r("div", { className: "mb-2 flex items-center gap-2", children: [
|
|
19
|
+
/* @__PURE__ */ c(x, { id: "edit-mode", checked: s, onCheckedChange: a }),
|
|
20
|
+
/* @__PURE__ */ c("label", { htmlFor: "edit-mode", className: "text-sm select-none", children: "Edit mode" }),
|
|
21
|
+
s && /* @__PURE__ */ r(l, { children: [
|
|
22
|
+
e > 0 && /* @__PURE__ */ c(l, { children: /* @__PURE__ */ r(n, { size: "sm", onClick: d, children: [
|
|
23
|
+
t,
|
|
24
|
+
" ",
|
|
25
|
+
e > 0 && `(${e})`
|
|
26
|
+
] }) }),
|
|
27
|
+
i > 0 && m && /* @__PURE__ */ r(n, { size: "sm", onClick: m, variant: "destructive", children: [
|
|
28
|
+
h,
|
|
29
|
+
" ",
|
|
30
|
+
i > 0 && `(${i})`
|
|
31
|
+
] }),
|
|
32
|
+
(e > 0 || i > 0) && /* @__PURE__ */ c(n, { size: "sm", variant: "ghost", onClick: k, children: o })
|
|
42
33
|
] })
|
|
43
34
|
] }) : null;
|
|
44
35
|
}
|
|
45
36
|
export {
|
|
46
|
-
|
|
37
|
+
z as EditControls
|
|
47
38
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { __module as e } from "../../_virtual/
|
|
2
|
+
import { __module as e } from "../../_virtual/index3.js";
|
|
3
3
|
import { __require as t } from "./cjs/react-is.production.min.js";
|
|
4
4
|
import { __require as o } from "./cjs/react-is.development.js";
|
|
5
5
|
var r;
|
|
@@ -5,7 +5,7 @@ import "../../../../_virtual/isString.js";
|
|
|
5
5
|
import f from "../../../../_virtual/isFunction.js";
|
|
6
6
|
import s from "../../../../_virtual/isObject.js";
|
|
7
7
|
import { isValidElement as d } from "react";
|
|
8
|
-
import "../../../../_virtual/
|
|
8
|
+
import "../../../../_virtual/index.js";
|
|
9
9
|
import { SVGElementPropKeys as m, EventKeys as p, FilteredElementKeyMap as o } from "./types.js";
|
|
10
10
|
var h = function(i) {
|
|
11
11
|
return typeof i == "string" ? i : i ? i.displayName || i.name || "Component" : "";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { __module as e } from "../../../_virtual/
|
|
2
|
+
import { __module as e } from "../../../_virtual/index4.js";
|
|
3
3
|
import { __require as i } from "../cjs/use-sync-external-store-shim.production.js";
|
|
4
4
|
import { __require as o } from "../cjs/use-sync-external-store-shim.development.js";
|
|
5
5
|
var r;
|
package/package.json
CHANGED
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { jsxs as t, jsx as e } from "react/jsx-runtime";
|
|
3
|
-
import { memo as k, useState as v, useCallback as o } from "react";
|
|
4
|
-
import { Popover as z, PopoverTrigger as I, PopoverContent as P } from "../../popover.js";
|
|
5
|
-
import { Icon as h } from "../../icon.js";
|
|
6
|
-
import { Button as p } from "../../button.js";
|
|
7
|
-
const E = k(
|
|
8
|
-
({
|
|
9
|
-
value: i,
|
|
10
|
-
onChange: u,
|
|
11
|
-
resetCell: a,
|
|
12
|
-
resetToDefault: l,
|
|
13
|
-
cellKey: n,
|
|
14
|
-
originalValue: s,
|
|
15
|
-
cellData: m
|
|
16
|
-
}) => {
|
|
17
|
-
const [N, r] = v(!1), [d, f] = v(i), C = (c) => {
|
|
18
|
-
c && f(i), r(c);
|
|
19
|
-
}, g = o(
|
|
20
|
-
(c) => {
|
|
21
|
-
f(c.target.value);
|
|
22
|
-
},
|
|
23
|
-
[]
|
|
24
|
-
), w = o(() => {
|
|
25
|
-
u(n, d), r(!1);
|
|
26
|
-
}, [u, n, d]), b = o(() => {
|
|
27
|
-
f(s ?? null), a(n), r(!1);
|
|
28
|
-
}, [s, a, n]), j = o(() => {
|
|
29
|
-
a(n), m && l && l(n, s, m), r(!1);
|
|
30
|
-
}, [l, a, n, s, m]), x = i !== s;
|
|
31
|
-
return /* @__PURE__ */ t(z, { open: N, onOpenChange: C, children: [
|
|
32
|
-
/* @__PURE__ */ e(I, { asChild: !0, children: /* @__PURE__ */ e("div", { className: "flex w-full cursor-pointer items-center justify-center", children: /* @__PURE__ */ t("div", { className: "relative w-full flex-1 items-center justify-center text-center", children: [
|
|
33
|
-
i || "",
|
|
34
|
-
x && /* @__PURE__ */ e("div", { className: "bg-d-primary text-d-primary-foreground absolute top-0 left-0 rounded p-1" }),
|
|
35
|
-
/* @__PURE__ */ e("span", { className: "text-d-muted-foreground ml-1 inline-flex items-center", children: /* @__PURE__ */ e(h, { name: "Pencil", size: "sm", className: "h-3 w-3" }) })
|
|
36
|
-
] }) }) }),
|
|
37
|
-
/* @__PURE__ */ e(P, { className: "w-[400px] p-4", children: /* @__PURE__ */ t("div", { className: "space-y-4", children: [
|
|
38
|
-
/* @__PURE__ */ t("div", { className: "flex items-center justify-between", children: [
|
|
39
|
-
/* @__PURE__ */ e("div", { className: "font-medium", children: "Modifica valore" }),
|
|
40
|
-
x && /* @__PURE__ */ e("div", { className: "text-d-muted-foreground text-xs", children: "Valore modificato" })
|
|
41
|
-
] }),
|
|
42
|
-
/* @__PURE__ */ e(
|
|
43
|
-
"input",
|
|
44
|
-
{
|
|
45
|
-
type: "text",
|
|
46
|
-
className: "bg-d-secondary w-full rounded border p-2",
|
|
47
|
-
value: d || "",
|
|
48
|
-
onChange: g,
|
|
49
|
-
autoFocus: !0
|
|
50
|
-
}
|
|
51
|
-
),
|
|
52
|
-
/* @__PURE__ */ t("div", { className: "flex items-center justify-between", children: [
|
|
53
|
-
/* @__PURE__ */ t(
|
|
54
|
-
p,
|
|
55
|
-
{
|
|
56
|
-
variant: "destructive",
|
|
57
|
-
size: "sm",
|
|
58
|
-
onClick: j,
|
|
59
|
-
className: "text-xs",
|
|
60
|
-
title: "Ripristina il valore originale e segna la cella come da ripristinare",
|
|
61
|
-
children: [
|
|
62
|
-
/* @__PURE__ */ e(h, { name: "RotateCcw", className: "mr-1 h-3 w-3" }),
|
|
63
|
-
"Ripristina"
|
|
64
|
-
]
|
|
65
|
-
}
|
|
66
|
-
),
|
|
67
|
-
/* @__PURE__ */ t("div", { className: "flex space-x-2", children: [
|
|
68
|
-
/* @__PURE__ */ e(
|
|
69
|
-
p,
|
|
70
|
-
{
|
|
71
|
-
variant: "ghost",
|
|
72
|
-
size: "sm",
|
|
73
|
-
onClick: b,
|
|
74
|
-
className: "text-xs",
|
|
75
|
-
title: "Annulla le modifiche correnti e chiudi",
|
|
76
|
-
children: "Annulla"
|
|
77
|
-
}
|
|
78
|
-
),
|
|
79
|
-
/* @__PURE__ */ t(
|
|
80
|
-
p,
|
|
81
|
-
{
|
|
82
|
-
size: "sm",
|
|
83
|
-
onClick: w,
|
|
84
|
-
className: "text-xs",
|
|
85
|
-
title: "Conferma le modifiche e salva",
|
|
86
|
-
children: [
|
|
87
|
-
/* @__PURE__ */ e(h, { name: "Check", className: "mr-1 h-3 w-3" }),
|
|
88
|
-
"Conferma"
|
|
89
|
-
]
|
|
90
|
-
}
|
|
91
|
-
)
|
|
92
|
-
] })
|
|
93
|
-
] })
|
|
94
|
-
] }) })
|
|
95
|
-
] });
|
|
96
|
-
}
|
|
97
|
-
);
|
|
98
|
-
export {
|
|
99
|
-
E as EditableInput
|
|
100
|
-
};
|