laif-ds 0.1.36 → 0.1.38
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,75 +1,75 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsxs as
|
|
3
|
-
import { useState as g, useEffect as Y, useMemo as
|
|
2
|
+
import { jsxs as B, jsx as i } from "react/jsx-runtime";
|
|
3
|
+
import { useState as g, useEffect as Y, useMemo as F, useRef as ce } from "react";
|
|
4
4
|
import { useReactTable as fe, flexRender as q } from "../../../../node_modules/@tanstack/react-table/build/lib/index.js";
|
|
5
5
|
import { useVirtualizer as me } from "../../../../node_modules/@tanstack/react-virtual/dist/esm/index.js";
|
|
6
6
|
import { TableSkeleton as pe } from "../../table-skeleton.js";
|
|
7
|
-
import { TruncatedText as
|
|
7
|
+
import { TruncatedText as N } from "./truncated-text.js";
|
|
8
8
|
import { EditControls as ge } from "./edit-controls.js";
|
|
9
9
|
import { EditableInput as he } from "./editable-input.js";
|
|
10
10
|
import { Button as G } from "../../button.js";
|
|
11
|
-
import { TableRow as
|
|
11
|
+
import { TableRow as _, TableCell as J, Table as xe, TableHeader as be, TableHead as ve, TableBody as ye } from "../../table.js";
|
|
12
12
|
import { getSortedRowModel as Ce, getCoreRowModel as Se } from "../../../../node_modules/@tanstack/table-core/build/lib/index.js";
|
|
13
|
-
function
|
|
14
|
-
crossTableData:
|
|
13
|
+
function Ae({
|
|
14
|
+
crossTableData: z,
|
|
15
15
|
filterable: h = !1,
|
|
16
16
|
loading: Q = !1,
|
|
17
17
|
emptyComponent: X,
|
|
18
|
-
className:
|
|
18
|
+
className: T,
|
|
19
19
|
notFoundMessage: Z = "Nessun risultato trovato.",
|
|
20
|
-
cornerHeaderFrom:
|
|
21
|
-
cornerHeaderTo:
|
|
20
|
+
cornerHeaderFrom: D = "Da",
|
|
21
|
+
cornerHeaderTo: V = "A",
|
|
22
22
|
maxHeaderLength: x = 15,
|
|
23
|
-
minWidthCell:
|
|
24
|
-
editable:
|
|
23
|
+
minWidthCell: E = 160,
|
|
24
|
+
editable: M = !1,
|
|
25
25
|
editMode: H = !1,
|
|
26
26
|
editConfirmLabel: W = "Conferma",
|
|
27
27
|
editCancelLabel: ee = "Annulla",
|
|
28
|
-
onConfirmedCells:
|
|
29
|
-
onEditModeChange:
|
|
30
|
-
onSelectedRow:
|
|
28
|
+
onConfirmedCells: w,
|
|
29
|
+
onEditModeChange: $,
|
|
30
|
+
onSelectedRow: K,
|
|
31
31
|
selectedRow: a,
|
|
32
32
|
rowSortAsc: te = !0
|
|
33
33
|
}) {
|
|
34
|
-
const [re, oe] = g([]), u =
|
|
34
|
+
const [re, oe] = g([]), u = z.headerTop, d = z.headerLeft, m = z.data, [b, A] = g(
|
|
35
35
|
(a == null ? void 0 : a.id) ?? null
|
|
36
|
-
), [
|
|
36
|
+
), [L, O] = g(te), [I, ne] = g(M && H);
|
|
37
37
|
Y(() => {
|
|
38
|
-
|
|
39
|
-
}, [
|
|
40
|
-
a != null && a.id &&
|
|
38
|
+
$ && $(!!I);
|
|
39
|
+
}, [I, $]), Y(() => {
|
|
40
|
+
a != null && a.id && A(a.id);
|
|
41
41
|
}, [a]);
|
|
42
|
-
const [v,
|
|
42
|
+
const [v, j] = g({}), [y, k] = g({}), le = (l) => l && typeof l == "object" && "value" in l ? l.value : l, c = F(() => {
|
|
43
43
|
if (!b || !d.find((e) => e.id === b)) return u;
|
|
44
44
|
const t = d.findIndex(
|
|
45
45
|
(e) => e.id === b
|
|
46
46
|
);
|
|
47
47
|
if (t === -1) return u;
|
|
48
|
-
const r = u.map((e,
|
|
49
|
-
var
|
|
50
|
-
const o = ((
|
|
51
|
-
return { header: e, value:
|
|
48
|
+
const r = u.map((e, n) => {
|
|
49
|
+
var f;
|
|
50
|
+
const o = ((f = m[t]) == null ? void 0 : f[n]) ?? null, s = le(o);
|
|
51
|
+
return { header: e, value: s };
|
|
52
52
|
});
|
|
53
|
-
return r.sort((e,
|
|
54
|
-
if (typeof e.value == "number" && typeof
|
|
55
|
-
return
|
|
56
|
-
const o = String(e.value ?? ""),
|
|
57
|
-
return
|
|
53
|
+
return r.sort((e, n) => {
|
|
54
|
+
if (typeof e.value == "number" && typeof n.value == "number")
|
|
55
|
+
return L ? e.value - n.value : n.value - e.value;
|
|
56
|
+
const o = String(e.value ?? ""), s = String(n.value ?? "");
|
|
57
|
+
return L ? o.localeCompare(s) : s.localeCompare(o);
|
|
58
58
|
}), r.map((e) => e.header);
|
|
59
|
-
}, [u, d,
|
|
59
|
+
}, [u, d, m, b, L]), se = F(() => {
|
|
60
60
|
const l = [
|
|
61
61
|
{
|
|
62
62
|
id: "cross-header",
|
|
63
|
-
header: () => /* @__PURE__ */
|
|
64
|
-
/* @__PURE__ */ i("div", { className: "absolute top-0 left-2 text-xs", children:
|
|
65
|
-
/* @__PURE__ */ i("div", { className: "absolute right-2 bottom-0 text-xs", children:
|
|
63
|
+
header: () => /* @__PURE__ */ B("div", { className: "relative", children: [
|
|
64
|
+
/* @__PURE__ */ i("div", { className: "absolute top-0 left-2 text-xs", children: D }),
|
|
65
|
+
/* @__PURE__ */ i("div", { className: "absolute right-2 bottom-0 text-xs", children: V })
|
|
66
66
|
] }),
|
|
67
67
|
accessorFn: (t) => t.item,
|
|
68
68
|
cell: (t) => {
|
|
69
69
|
const r = t.getValue();
|
|
70
70
|
if (!h)
|
|
71
71
|
return /* @__PURE__ */ i(
|
|
72
|
-
|
|
72
|
+
N,
|
|
73
73
|
{
|
|
74
74
|
text: r.label,
|
|
75
75
|
maxLength: x,
|
|
@@ -85,9 +85,9 @@ function De({
|
|
|
85
85
|
iconLeft: "ArrowLeftRight",
|
|
86
86
|
className: "text-right",
|
|
87
87
|
onClick: () => {
|
|
88
|
-
h && (e ?
|
|
88
|
+
h && (e ? O((n) => !n) : (A(d[t.row.index].id), O(!0), K && K(d[t.row.index])));
|
|
89
89
|
},
|
|
90
|
-
children: /* @__PURE__ */ i(
|
|
90
|
+
children: /* @__PURE__ */ i(N, { text: r.label, maxLength: x })
|
|
91
91
|
}
|
|
92
92
|
);
|
|
93
93
|
}
|
|
@@ -104,19 +104,19 @@ function De({
|
|
|
104
104
|
size: "sm",
|
|
105
105
|
iconLeft: "ArrowUpDown",
|
|
106
106
|
onClick: h ? () => r.toggleSorting(r.getIsSorted() === "asc") : void 0,
|
|
107
|
-
children: /* @__PURE__ */ i(
|
|
107
|
+
children: /* @__PURE__ */ i(N, { text: t.label, maxLength: x })
|
|
108
108
|
}
|
|
109
109
|
) : /* @__PURE__ */ i(
|
|
110
|
-
|
|
110
|
+
N,
|
|
111
111
|
{
|
|
112
112
|
text: t.label,
|
|
113
113
|
maxLength: x,
|
|
114
114
|
className: "font-medium"
|
|
115
115
|
}
|
|
116
116
|
),
|
|
117
|
-
sortingFn: (r, e,
|
|
118
|
-
let o = r.getValue(
|
|
119
|
-
return o == null &&
|
|
117
|
+
sortingFn: (r, e, n) => {
|
|
118
|
+
let o = r.getValue(n), s = e.getValue(n);
|
|
119
|
+
return o == null && s == null ? 0 : o == null ? 1 : s == null ? -1 : (o && typeof o == "object" && "value" in o && (o = o.value), s && typeof s == "object" && "value" in s && (s = s.value), typeof o == "number" && typeof s == "number" ? o - s : String(o).localeCompare(String(s)));
|
|
120
120
|
},
|
|
121
121
|
cell: (r) => {
|
|
122
122
|
const e = r.getValue();
|
|
@@ -126,21 +126,21 @@ function De({
|
|
|
126
126
|
}), l;
|
|
127
127
|
}, [
|
|
128
128
|
c,
|
|
129
|
-
|
|
130
|
-
|
|
129
|
+
D,
|
|
130
|
+
V,
|
|
131
131
|
a,
|
|
132
132
|
h,
|
|
133
133
|
x,
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
]), ie =
|
|
134
|
+
A,
|
|
135
|
+
O
|
|
136
|
+
]), ie = F(() => d.map((l, t) => {
|
|
137
137
|
const r = { item: l };
|
|
138
138
|
return c.forEach((e) => {
|
|
139
139
|
var o;
|
|
140
|
-
const
|
|
141
|
-
r[e.id] =
|
|
140
|
+
const n = u.findIndex((s) => s.id === e.id);
|
|
141
|
+
r[e.id] = n !== -1 ? ((o = m[t]) == null ? void 0 : o[n]) ?? null : null;
|
|
142
142
|
}), r;
|
|
143
|
-
}), [d, c,
|
|
143
|
+
}), [d, c, m, u]), R = fe({
|
|
144
144
|
data: ie,
|
|
145
145
|
columns: se,
|
|
146
146
|
state: { sorting: re },
|
|
@@ -148,8 +148,8 @@ function De({
|
|
|
148
148
|
getCoreRowModel: Se(),
|
|
149
149
|
getSortedRowModel: Ce()
|
|
150
150
|
});
|
|
151
|
-
if (!
|
|
152
|
-
return /* @__PURE__ */ i("div", { className:
|
|
151
|
+
if (!m || m.length === 0)
|
|
152
|
+
return /* @__PURE__ */ i("div", { className: T, children: /* @__PURE__ */ i(_, { children: /* @__PURE__ */ i(J, { colSpan: c.length + 1, children: X || Z }) }) });
|
|
153
153
|
if (Q)
|
|
154
154
|
return /* @__PURE__ */ i(
|
|
155
155
|
pe,
|
|
@@ -157,62 +157,81 @@ function De({
|
|
|
157
157
|
headerRow: c.map((l) => l.label),
|
|
158
158
|
rowCount: d.length || 5,
|
|
159
159
|
columnCount: c.length || 5,
|
|
160
|
-
className:
|
|
161
|
-
cornerHeaderFrom:
|
|
162
|
-
cornerHeaderTo:
|
|
160
|
+
className: T,
|
|
161
|
+
cornerHeaderFrom: D,
|
|
162
|
+
cornerHeaderTo: V
|
|
163
163
|
}
|
|
164
164
|
);
|
|
165
165
|
const ae = (l) => {
|
|
166
166
|
const t = l.column.id === "cross-header", r = t, e = ["bg-d-secondary"];
|
|
167
167
|
t || e.push("border-r"), t && e.push("sticky left-0"), e.push("sticky top-0 z-20"), r ? e.push("z-40") : t && e.push("z-30");
|
|
168
|
-
let
|
|
169
|
-
return t && (
|
|
168
|
+
let n = "none";
|
|
169
|
+
return t && (n = "inset -1px 0 0 0 var(--d-border), 0 1px 0 0 var(--d-border)"), {
|
|
170
170
|
className: e.join(" "),
|
|
171
|
-
style: { boxShadow:
|
|
171
|
+
style: { boxShadow: n, width: `${E}px` }
|
|
172
172
|
};
|
|
173
173
|
}, P = ce(null), U = me({
|
|
174
|
-
count:
|
|
174
|
+
count: R.getRowModel().rows.length,
|
|
175
175
|
getScrollElement: () => P.current,
|
|
176
176
|
estimateSize: () => 40,
|
|
177
177
|
overscan: 5,
|
|
178
178
|
measureElement: typeof window < "u" ? (l) => l.getBoundingClientRect().height : void 0
|
|
179
179
|
});
|
|
180
|
-
return /* @__PURE__ */
|
|
181
|
-
|
|
180
|
+
return /* @__PURE__ */ B("div", { className: `w-[900px] ${T || ""}`, children: [
|
|
181
|
+
M && /* @__PURE__ */ i(
|
|
182
182
|
ge,
|
|
183
183
|
{
|
|
184
|
-
editable:
|
|
184
|
+
editable: M,
|
|
185
185
|
editConfirmLabel: W,
|
|
186
186
|
editCancelLabel: ee,
|
|
187
|
-
|
|
187
|
+
editRestoreDefaultLabel: "Ripristina Default",
|
|
188
|
+
editMode: I,
|
|
188
189
|
setEditMode: ne,
|
|
189
190
|
editedCount: Object.keys(v).length,
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
191
|
+
defaultCount: Object.keys(y).length,
|
|
192
|
+
restoreDefault: () => {
|
|
193
|
+
if (w) {
|
|
194
|
+
const l = Object.entries(y).map(
|
|
195
|
+
([r, { value: e, cell: n }]) => ({
|
|
194
196
|
fromId: n.fromId,
|
|
195
197
|
toId: n.toId,
|
|
196
198
|
id: n.id,
|
|
199
|
+
value: e
|
|
200
|
+
})
|
|
201
|
+
);
|
|
202
|
+
w({
|
|
203
|
+
editedCells: [],
|
|
204
|
+
toDefaultCells: l
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
k({});
|
|
208
|
+
},
|
|
209
|
+
confirmAll: () => {
|
|
210
|
+
if (w && (Object.keys(v).length > 0 || Object.keys(y).length > 0)) {
|
|
211
|
+
const t = Object.entries(v).map(
|
|
212
|
+
([n, { value: o, cell: s }]) => ({
|
|
213
|
+
fromId: s.fromId,
|
|
214
|
+
toId: s.toId,
|
|
215
|
+
id: s.id,
|
|
197
216
|
value: o
|
|
198
217
|
})
|
|
199
|
-
), r = Object.entries(
|
|
200
|
-
([
|
|
201
|
-
fromId:
|
|
202
|
-
toId:
|
|
203
|
-
id:
|
|
218
|
+
), r = Object.entries(y).map(
|
|
219
|
+
([n, { value: o, cell: s }]) => ({
|
|
220
|
+
fromId: s.fromId,
|
|
221
|
+
toId: s.toId,
|
|
222
|
+
id: s.id,
|
|
204
223
|
value: o
|
|
205
224
|
})
|
|
206
225
|
);
|
|
207
|
-
|
|
226
|
+
w({
|
|
208
227
|
editedCells: t,
|
|
209
228
|
toDefaultCells: r
|
|
210
229
|
});
|
|
211
230
|
}
|
|
212
|
-
|
|
231
|
+
j({}), k({});
|
|
213
232
|
},
|
|
214
233
|
cancelAll: () => {
|
|
215
|
-
|
|
234
|
+
j({}), k({});
|
|
216
235
|
}
|
|
217
236
|
}
|
|
218
237
|
),
|
|
@@ -221,14 +240,14 @@ function De({
|
|
|
221
240
|
{
|
|
222
241
|
ref: P,
|
|
223
242
|
className: "max-h-[600px] overflow-auto rounded-md border",
|
|
224
|
-
children: /* @__PURE__ */
|
|
243
|
+
children: /* @__PURE__ */ B(xe, { className: "relative w-full table-fixed border-collapse", children: [
|
|
225
244
|
/* @__PURE__ */ i(
|
|
226
245
|
be,
|
|
227
246
|
{
|
|
228
247
|
className: "bg-d-secondary sticky top-0 z-20",
|
|
229
248
|
style: { boxShadow: "0 1px 0 0 var(--d-border)" },
|
|
230
|
-
children:
|
|
231
|
-
|
|
249
|
+
children: R.getHeaderGroups().map((l) => /* @__PURE__ */ i(
|
|
250
|
+
_,
|
|
232
251
|
{
|
|
233
252
|
className: "bg-d-secondary sticky top-0 z-20",
|
|
234
253
|
children: l.headers.map((t) => {
|
|
@@ -260,9 +279,9 @@ function De({
|
|
|
260
279
|
width: "100%"
|
|
261
280
|
},
|
|
262
281
|
children: U.getVirtualItems().map((l) => {
|
|
263
|
-
const t =
|
|
282
|
+
const t = R.getRowModel().rows[l.index];
|
|
264
283
|
return /* @__PURE__ */ i(
|
|
265
|
-
|
|
284
|
+
_,
|
|
266
285
|
{
|
|
267
286
|
"data-index": l.index,
|
|
268
287
|
style: {
|
|
@@ -275,21 +294,21 @@ function De({
|
|
|
275
294
|
display: "flex"
|
|
276
295
|
},
|
|
277
296
|
children: t.getVisibleCells().map((r, e) => {
|
|
278
|
-
const
|
|
297
|
+
const n = e === 0, o = r.getValue(), s = n ? "var(--d-secondary)" : (o == null ? void 0 : o.color) || "transparent";
|
|
279
298
|
return /* @__PURE__ */ i(
|
|
280
299
|
J,
|
|
281
300
|
{
|
|
282
|
-
className: `text-center ${
|
|
301
|
+
className: `text-center ${n ? "sticky left-0 z-10" : "border-r"}`,
|
|
283
302
|
style: {
|
|
284
|
-
boxShadow:
|
|
285
|
-
backgroundColor:
|
|
286
|
-
width: `${
|
|
287
|
-
flex:
|
|
303
|
+
boxShadow: n ? "inset -1px 0 0 0 var(--d-border)" : "none",
|
|
304
|
+
backgroundColor: s,
|
|
305
|
+
width: `${E}px`,
|
|
306
|
+
flex: n ? "0 0 auto" : `1 0 ${E}px`,
|
|
288
307
|
display: "flex",
|
|
289
308
|
alignItems: "center",
|
|
290
309
|
justifyContent: "center"
|
|
291
310
|
},
|
|
292
|
-
children:
|
|
311
|
+
children: n || !I || !o ? (
|
|
293
312
|
// Rendering normale per la prima colonna o quando non siamo in modalità edit
|
|
294
313
|
q(
|
|
295
314
|
r.column.columnDef.cell,
|
|
@@ -298,30 +317,31 @@ function De({
|
|
|
298
317
|
) : (
|
|
299
318
|
// Rendering con EditableInput per le celle modificabili
|
|
300
319
|
(() => {
|
|
301
|
-
const
|
|
320
|
+
const f = `${t.index}-${r.column.id}`, de = f in v ? v[f].value : o.value || "";
|
|
302
321
|
return /* @__PURE__ */ i(
|
|
303
322
|
he,
|
|
304
323
|
{
|
|
305
324
|
value: de,
|
|
306
325
|
originalValue: o.value || "",
|
|
307
|
-
cellKey:
|
|
326
|
+
cellKey: f,
|
|
308
327
|
cellData: o,
|
|
309
|
-
|
|
310
|
-
|
|
328
|
+
isMarkedForReset: f in y,
|
|
329
|
+
onChange: (C, S) => {
|
|
330
|
+
j((p) => ({
|
|
311
331
|
...p,
|
|
312
|
-
[
|
|
332
|
+
[C]: { value: S, cell: o }
|
|
313
333
|
}));
|
|
314
334
|
},
|
|
315
|
-
resetCell: (
|
|
316
|
-
|
|
317
|
-
const p = { ...
|
|
318
|
-
return delete p[
|
|
335
|
+
resetCell: (C) => {
|
|
336
|
+
j((S) => {
|
|
337
|
+
const p = { ...S };
|
|
338
|
+
return delete p[C], p;
|
|
319
339
|
});
|
|
320
340
|
},
|
|
321
|
-
resetToDefault: (
|
|
322
|
-
|
|
341
|
+
resetToDefault: (C, S, p) => {
|
|
342
|
+
k((ue) => ({
|
|
323
343
|
...ue,
|
|
324
|
-
[
|
|
344
|
+
[C]: { value: S, cell: p }
|
|
325
345
|
}));
|
|
326
346
|
}
|
|
327
347
|
}
|
|
@@ -344,5 +364,5 @@ function De({
|
|
|
344
364
|
] });
|
|
345
365
|
}
|
|
346
366
|
export {
|
|
347
|
-
|
|
367
|
+
Ae as DataCrossTable
|
|
348
368
|
};
|
|
@@ -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,51 +1,53 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsxs as t, jsx as e } from "react/jsx-runtime";
|
|
3
|
-
import { memo as
|
|
4
|
-
import { Popover as
|
|
5
|
-
import { Icon as
|
|
3
|
+
import { memo as z, useState as N, useCallback as o } from "react";
|
|
4
|
+
import { Popover as I, PopoverTrigger as P, PopoverContent as R } from "../../popover.js";
|
|
5
|
+
import { Icon as f } from "../../icon.js";
|
|
6
6
|
import { Button as p } from "../../button.js";
|
|
7
|
-
const
|
|
7
|
+
const S = z(
|
|
8
8
|
({
|
|
9
|
-
value:
|
|
9
|
+
value: n,
|
|
10
10
|
onChange: u,
|
|
11
11
|
resetCell: a,
|
|
12
12
|
resetToDefault: l,
|
|
13
|
-
cellKey:
|
|
14
|
-
originalValue:
|
|
15
|
-
cellData:
|
|
13
|
+
cellKey: s,
|
|
14
|
+
originalValue: i,
|
|
15
|
+
cellData: d,
|
|
16
|
+
isMarkedForReset: x = !1
|
|
16
17
|
}) => {
|
|
17
|
-
const [
|
|
18
|
-
c &&
|
|
19
|
-
},
|
|
18
|
+
const [C, r] = N(!1), [m, h] = N(n), g = (c) => {
|
|
19
|
+
c && h(n), r(c);
|
|
20
|
+
}, b = o(
|
|
20
21
|
(c) => {
|
|
21
|
-
|
|
22
|
+
h(c.target.value);
|
|
22
23
|
},
|
|
23
24
|
[]
|
|
24
25
|
), w = o(() => {
|
|
25
|
-
u(
|
|
26
|
-
}, [u,
|
|
27
|
-
|
|
28
|
-
}, [
|
|
29
|
-
a(
|
|
30
|
-
}, [l, a,
|
|
31
|
-
return /* @__PURE__ */ t(
|
|
32
|
-
/* @__PURE__ */ e(
|
|
33
|
-
|
|
34
|
-
x && /* @__PURE__ */ e("div", { className: "bg-d-primary
|
|
35
|
-
/* @__PURE__ */ e("
|
|
26
|
+
u(s, m), r(!1);
|
|
27
|
+
}, [u, s, m]), j = o(() => {
|
|
28
|
+
h(i ?? null), a(s), r(!1);
|
|
29
|
+
}, [i, a, s]), k = o(() => {
|
|
30
|
+
a(s), d && l && l(s, i, d), r(!1);
|
|
31
|
+
}, [l, a, s, i, d]), v = n !== i;
|
|
32
|
+
return /* @__PURE__ */ t(I, { open: C, onOpenChange: g, children: [
|
|
33
|
+
/* @__PURE__ */ e(P, { 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: [
|
|
34
|
+
n || "",
|
|
35
|
+
v && !x && /* @__PURE__ */ e("div", { className: "bg-d-primary absolute top-0 left-0 rounded p-1", title: "Valore modificato" }),
|
|
36
|
+
x && /* @__PURE__ */ e("div", { className: "bg-d-destructive absolute top-0 right-0 rounded p-1", title: "Ripristino richiesto" }),
|
|
37
|
+
/* @__PURE__ */ e("span", { className: "text-d-muted-foreground ml-1 inline-flex items-center", children: /* @__PURE__ */ e(f, { name: "Pencil", size: "sm", className: "h-3 w-3" }) })
|
|
36
38
|
] }) }) }),
|
|
37
|
-
/* @__PURE__ */ e(
|
|
39
|
+
/* @__PURE__ */ e(R, { className: "w-[400px] p-4", children: /* @__PURE__ */ t("div", { className: "space-y-4", children: [
|
|
38
40
|
/* @__PURE__ */ t("div", { className: "flex items-center justify-between", children: [
|
|
39
41
|
/* @__PURE__ */ e("div", { className: "font-medium", children: "Modifica valore" }),
|
|
40
|
-
|
|
42
|
+
v && /* @__PURE__ */ e("div", { className: "text-d-muted-foreground text-xs", children: "Valore modificato" })
|
|
41
43
|
] }),
|
|
42
44
|
/* @__PURE__ */ e(
|
|
43
45
|
"input",
|
|
44
46
|
{
|
|
45
47
|
type: "text",
|
|
46
48
|
className: "bg-d-secondary w-full rounded border p-2",
|
|
47
|
-
value:
|
|
48
|
-
onChange:
|
|
49
|
+
value: m || "",
|
|
50
|
+
onChange: b,
|
|
49
51
|
autoFocus: !0
|
|
50
52
|
}
|
|
51
53
|
),
|
|
@@ -55,11 +57,11 @@ const E = k(
|
|
|
55
57
|
{
|
|
56
58
|
variant: "destructive",
|
|
57
59
|
size: "sm",
|
|
58
|
-
onClick:
|
|
60
|
+
onClick: k,
|
|
59
61
|
className: "text-xs",
|
|
60
62
|
title: "Ripristina il valore originale e segna la cella come da ripristinare",
|
|
61
63
|
children: [
|
|
62
|
-
/* @__PURE__ */ e(
|
|
64
|
+
/* @__PURE__ */ e(f, { name: "RotateCcw", className: "mr-1 h-3 w-3" }),
|
|
63
65
|
"Ripristina"
|
|
64
66
|
]
|
|
65
67
|
}
|
|
@@ -70,7 +72,7 @@ const E = k(
|
|
|
70
72
|
{
|
|
71
73
|
variant: "ghost",
|
|
72
74
|
size: "sm",
|
|
73
|
-
onClick:
|
|
75
|
+
onClick: j,
|
|
74
76
|
className: "text-xs",
|
|
75
77
|
title: "Annulla le modifiche correnti e chiudi",
|
|
76
78
|
children: "Annulla"
|
|
@@ -84,7 +86,7 @@ const E = k(
|
|
|
84
86
|
className: "text-xs",
|
|
85
87
|
title: "Conferma le modifiche e salva",
|
|
86
88
|
children: [
|
|
87
|
-
/* @__PURE__ */ e(
|
|
89
|
+
/* @__PURE__ */ e(f, { name: "Check", className: "mr-1 h-3 w-3" }),
|
|
88
90
|
"Conferma"
|
|
89
91
|
]
|
|
90
92
|
}
|
|
@@ -96,5 +98,5 @@ const E = k(
|
|
|
96
98
|
}
|
|
97
99
|
);
|
|
98
100
|
export {
|
|
99
|
-
|
|
101
|
+
S as EditableInput
|
|
100
102
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -490,14 +490,14 @@ export declare function CommandShortcut({ className, ...props }: React_2.Compone
|
|
|
490
490
|
declare const confirm_2: (payload: ConfirmOptions) => Promise<boolean>;
|
|
491
491
|
export { confirm_2 as confirm }
|
|
492
492
|
|
|
493
|
-
declare interface ConfirmedCell {
|
|
493
|
+
export declare interface ConfirmedCell {
|
|
494
494
|
fromId: string;
|
|
495
495
|
toId: string;
|
|
496
496
|
id?: string;
|
|
497
497
|
value: any;
|
|
498
498
|
}
|
|
499
499
|
|
|
500
|
-
declare interface ConfirmedCellsData {
|
|
500
|
+
export declare interface ConfirmedCellsData {
|
|
501
501
|
editedCells: ConfirmedCell[];
|
|
502
502
|
toDefaultCells: ConfirmedCell[];
|
|
503
503
|
}
|
|
@@ -572,13 +572,13 @@ export declare interface CrossTableCell {
|
|
|
572
572
|
id?: string;
|
|
573
573
|
}
|
|
574
574
|
|
|
575
|
-
declare interface CrossTableData {
|
|
575
|
+
export declare interface CrossTableData {
|
|
576
576
|
headerTop: CrossTableHeader[];
|
|
577
577
|
headerLeft: CrossTableHeader[];
|
|
578
578
|
data: (CrossTableCell | null)[][];
|
|
579
579
|
}
|
|
580
580
|
|
|
581
|
-
declare interface CrossTableHeader {
|
|
581
|
+
export declare interface CrossTableHeader {
|
|
582
582
|
id: string;
|
|
583
583
|
label: string;
|
|
584
584
|
}
|