laif-ds 0.1.38 → 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.
@@ -1,6 +1,3 @@
1
1
  "use client";
2
- import { __require as r } from "../node_modules/use-sync-external-store/shim/index.js";
3
- var i = r();
4
- export {
5
- i as s
6
- };
2
+ import { __require as e } from "../node_modules/react-is/index.js";
3
+ e();
@@ -1,5 +1,6 @@
1
1
  "use client";
2
- var e = { exports: {} };
2
+ import { __require as r } from "../node_modules/use-sync-external-store/shim/index.js";
3
+ var i = r();
3
4
  export {
4
- e as __module
5
+ i as s
5
6
  };
@@ -1,3 +1,5 @@
1
1
  "use client";
2
- import { __require as e } from "../node_modules/react-is/index.js";
3
- e();
2
+ var e = { exports: {} };
3
+ export {
4
+ e as __module
5
+ };
@@ -1,349 +1,409 @@
1
1
  "use client";
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
- import { useReactTable as fe, flexRender as q } from "../../../../node_modules/@tanstack/react-table/build/lib/index.js";
5
- import { useVirtualizer as me } from "../../../../node_modules/@tanstack/react-virtual/dist/esm/index.js";
6
- import { TableSkeleton as pe } from "../../table-skeleton.js";
7
- import { TruncatedText as N } from "./truncated-text.js";
8
- import { EditControls as ge } from "./edit-controls.js";
9
- import { EditableInput as he } from "./editable-input.js";
10
- import { Button as G } from "../../button.js";
11
- import { TableRow as _, TableCell as J, Table as xe, TableHeader as be, TableHead as ve, TableBody as ye } from "../../table.js";
12
- import { getSortedRowModel as Ce, getCoreRowModel as Se } from "../../../../node_modules/@tanstack/table-core/build/lib/index.js";
13
- function Ae({
14
- crossTableData: z,
15
- filterable: h = !1,
16
- loading: Q = !1,
17
- emptyComponent: X,
18
- className: T,
19
- notFoundMessage: Z = "Nessun risultato trovato.",
20
- cornerHeaderFrom: D = "Da",
21
- cornerHeaderTo: V = "A",
22
- maxHeaderLength: x = 15,
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,
23
24
  minWidthCell: E = 160,
24
- editable: M = !1,
25
- editMode: H = !1,
26
- editConfirmLabel: W = "Conferma",
27
- editCancelLabel: ee = "Annulla",
28
- onConfirmedCells: w,
29
- onEditModeChange: $,
30
- onSelectedRow: K,
31
- selectedRow: a,
32
- rowSortAsc: te = !0
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
- const [re, oe] = g([]), u = z.headerTop, d = z.headerLeft, m = z.data, [b, A] = g(
35
- (a == null ? void 0 : a.id) ?? null
36
- ), [L, O] = g(te), [I, ne] = g(M && H);
37
- Y(() => {
38
- $ && $(!!I);
39
- }, [I, $]), Y(() => {
40
- a != null && a.id && A(a.id);
41
- }, [a]);
42
- const [v, j] = g({}), [y, k] = g({}), le = (l) => l && typeof l == "object" && "value" in l ? l.value : l, c = F(() => {
43
- if (!b || !d.find((e) => e.id === b)) return u;
44
- const t = d.findIndex(
45
- (e) => e.id === b
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 (t === -1) return u;
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 };
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((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
- }), r.map((e) => e.header);
59
- }, [u, d, m, b, L]), se = F(() => {
60
- const l = [
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__ */ 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 })
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: (t) => t.item,
68
- cell: (t) => {
69
- const r = t.getValue();
70
- if (!h)
71
- return /* @__PURE__ */ i(
72
- N,
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: x,
119
+ maxLength: C,
76
120
  className: "w-full"
77
121
  }
78
122
  );
79
- const e = b === r.id;
80
- return /* @__PURE__ */ i(
81
- G,
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
- h && (e ? O((n) => !n) : (A(d[t.row.index].id), O(!0), K && K(d[t.row.index])));
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__ */ i(N, { text: r.label, maxLength: x })
134
+ children: /* @__PURE__ */ o(R, { text: r.label, maxLength: C })
91
135
  }
92
136
  );
93
137
  }
94
138
  }
95
139
  ];
96
- return c.forEach((t) => {
97
- l.push({
98
- id: t.id,
99
- accessorFn: (r) => r[t.id],
100
- header: ({ column: r }) => h ? /* @__PURE__ */ i(
101
- G,
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: h ? () => r.toggleSorting(r.getIsSorted() === "asc") : void 0,
107
- children: /* @__PURE__ */ i(N, { text: t.label, maxLength: x })
150
+ onClick: b ? () => r.toggleSorting(r.getIsSorted() === "asc") : void 0,
151
+ children: /* @__PURE__ */ o(R, { text: e.label, maxLength: C })
108
152
  }
109
- ) : /* @__PURE__ */ i(
110
- N,
153
+ ) : /* @__PURE__ */ o(
154
+ R,
111
155
  {
112
- text: t.label,
113
- maxLength: x,
156
+ text: e.label,
157
+ maxLength: C,
114
158
  className: "font-medium"
115
159
  }
116
160
  ),
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)));
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 e = r.getValue();
123
- return e ? e.render ? e.render(e.fromId, e.toId, e.id) : /* @__PURE__ */ i("div", { children: e.value }) : null;
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
- }), l;
170
+ }), t;
127
171
  }, [
128
- c,
129
- D,
130
- V,
131
- a,
132
172
  h,
133
- x,
134
- A,
135
- O
136
- ]), ie = F(() => d.map((l, t) => {
137
- const r = { item: l };
138
- return c.forEach((e) => {
139
- var o;
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;
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
- }), [d, c, m, u]), R = fe({
144
- data: ie,
145
- columns: se,
146
- state: { sorting: re },
147
- onSortingChange: oe,
148
- getCoreRowModel: Se(),
149
- getSortedRowModel: Ce()
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 (!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
- if (Q)
154
- return /* @__PURE__ */ i(
155
- pe,
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: c.map((l) => l.label),
158
- rowCount: d.length || 5,
159
- columnCount: c.length || 5,
160
- className: T,
161
- cornerHeaderFrom: D,
162
- cornerHeaderTo: V
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 ae = (l) => {
166
- const t = l.column.id === "cross-header", r = t, e = ["bg-d-secondary"];
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 n = "none";
169
- return t && (n = "inset -1px 0 0 0 var(--d-border), 0 1px 0 0 var(--d-border)"), {
170
- className: e.join(" "),
171
- style: { boxShadow: n, width: `${E}px` }
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
- }, P = ce(null), U = me({
174
- count: R.getRowModel().rows.length,
175
- getScrollElement: () => P.current,
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" ? (l) => l.getBoundingClientRect().height : void 0
222
+ measureElement: typeof window < "u" ? (t) => t.getBoundingClientRect().height : void 0
179
223
  });
180
- return /* @__PURE__ */ B("div", { className: `w-[900px] ${T || ""}`, children: [
181
- M && /* @__PURE__ */ i(
182
- ge,
224
+ return /* @__PURE__ */ c("div", { className: `w-[900px] ${A || ""}`, children: [
225
+ O && /* @__PURE__ */ o(
226
+ Te,
183
227
  {
184
- editable: M,
185
- editConfirmLabel: W,
186
- editCancelLabel: ee,
228
+ editable: O,
229
+ editConfirmLabel: ie,
230
+ editCancelLabel: ae,
187
231
  editRestoreDefaultLabel: "Ripristina Default",
188
- editMode: I,
189
- setEditMode: ne,
190
- editedCount: Object.keys(v).length,
191
- defaultCount: Object.keys(y).length,
232
+ editMode: j,
233
+ setEditMode: fe,
234
+ editedCount: Object.keys(N).length,
235
+ defaultCount: Object.keys(p).length,
192
236
  restoreDefault: () => {
193
- if (w) {
194
- const l = Object.entries(y).map(
195
- ([r, { value: e, cell: n }]) => ({
196
- fromId: n.fromId,
197
- toId: n.toId,
198
- id: n.id,
199
- value: e
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
200
244
  })
201
245
  );
202
- w({
246
+ V({
203
247
  editedCells: [],
204
- toDefaultCells: l
248
+ toDefaultCells: t
205
249
  });
206
250
  }
207
- k({});
251
+ x({});
208
252
  },
209
253
  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,
216
- value: o
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
217
261
  })
218
- ), r = Object.entries(y).map(
219
- ([n, { value: o, cell: s }]) => ({
220
- fromId: s.fromId,
221
- toId: s.toId,
222
- id: s.id,
223
- value: o
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
224
268
  })
225
269
  );
226
- w({
227
- editedCells: t,
270
+ V({
271
+ editedCells: e,
228
272
  toDefaultCells: r
229
273
  });
230
274
  }
231
- j({}), k({});
275
+ S({}), x({});
232
276
  },
233
277
  cancelAll: () => {
234
- j({}), k({});
278
+ S({}), x({});
235
279
  }
236
280
  }
237
281
  ),
238
- /* @__PURE__ */ i(
282
+ /* @__PURE__ */ o(
239
283
  "div",
240
284
  {
241
- ref: P,
285
+ ref: G,
242
286
  className: "max-h-[600px] overflow-auto rounded-md border",
243
- children: /* @__PURE__ */ B(xe, { className: "relative w-full table-fixed border-collapse", children: [
244
- /* @__PURE__ */ i(
245
- be,
287
+ children: /* @__PURE__ */ c(Ae, { className: "relative w-full table-fixed border-collapse", children: [
288
+ /* @__PURE__ */ o(
289
+ Ke,
246
290
  {
247
291
  className: "bg-d-secondary sticky top-0 z-20",
248
292
  style: { boxShadow: "0 1px 0 0 var(--d-border)" },
249
- children: R.getHeaderGroups().map((l) => /* @__PURE__ */ i(
250
- _,
293
+ children: _.getHeaderGroups().map((t) => /* @__PURE__ */ o(
294
+ X,
251
295
  {
252
296
  className: "bg-d-secondary sticky top-0 z-20",
253
- children: l.headers.map((t) => {
254
- const r = ae(t);
255
- return /* @__PURE__ */ i(
256
- ve,
297
+ children: t.headers.map((e) => {
298
+ const r = Ne(e);
299
+ return /* @__PURE__ */ o(
300
+ Me,
257
301
  {
258
302
  className: r.className,
259
303
  style: r.style,
260
- children: t.isPlaceholder ? null : q(
261
- t.column.columnDef.header,
262
- t.getContext()
304
+ children: e.isPlaceholder ? null : te(
305
+ e.column.columnDef.header,
306
+ e.getContext()
263
307
  )
264
308
  },
265
- t.id
309
+ e.id
266
310
  );
267
311
  })
268
312
  },
269
- l.id
313
+ t.id
270
314
  ))
271
315
  }
272
316
  ),
273
- /* @__PURE__ */ i(
274
- ye,
317
+ /* @__PURE__ */ o(
318
+ Ee,
275
319
  {
276
320
  style: {
277
- height: `${U.getTotalSize()}px`,
321
+ height: `${J.getTotalSize()}px`,
278
322
  position: "relative",
279
323
  width: "100%"
280
324
  },
281
- children: U.getVirtualItems().map((l) => {
282
- const t = R.getRowModel().rows[l.index];
283
- return /* @__PURE__ */ i(
284
- _,
325
+ children: J.getVirtualItems().map((t) => {
326
+ const e = _.getRowModel().rows[t.index];
327
+ return /* @__PURE__ */ o(
328
+ X,
285
329
  {
286
- "data-index": l.index,
330
+ "data-index": t.index,
287
331
  style: {
288
332
  position: "absolute",
289
333
  top: 0,
290
334
  left: 0,
291
- transform: `translateY(${l.start}px)`,
335
+ transform: `translateY(${t.start}px)`,
292
336
  width: "100%",
293
- height: `${l.size}px`,
337
+ height: `${t.size}px`,
294
338
  display: "flex"
295
339
  },
296
- children: t.getVisibleCells().map((r, e) => {
297
- const n = e === 0, o = r.getValue(), s = n ? "var(--d-secondary)" : (o == null ? void 0 : o.color) || "transparent";
298
- return /* @__PURE__ */ i(
299
- J,
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,
300
344
  {
301
- className: `text-center ${n ? "sticky left-0 z-10" : "border-r"}`,
345
+ className: `text-center ${i ? "sticky left-0 z-10" : "border-r"}`,
302
346
  style: {
303
- boxShadow: n ? "inset -1px 0 0 0 var(--d-border)" : "none",
304
- backgroundColor: s,
347
+ boxShadow: i ? "inset -1px 0 0 0 var(--d-border)" : "none",
348
+ backgroundColor: a,
305
349
  width: `${E}px`,
306
- flex: n ? "0 0 auto" : `1 0 ${E}px`,
350
+ flex: i ? "0 0 auto" : `1 0 ${E}px`,
307
351
  display: "flex",
308
352
  alignItems: "center",
309
353
  justifyContent: "center"
310
354
  },
311
- children: n || !I || !o ? (
355
+ children: i || !j || !s ? (
312
356
  // Rendering normale per la prima colonna o quando non siamo in modalità edit
313
- q(
357
+ te(
314
358
  r.column.columnDef.cell,
315
359
  r.getContext()
316
360
  )
317
361
  ) : (
318
- // Rendering con EditableInput per le celle modificabili
362
+ // Rendering con cella modificabile
319
363
  (() => {
320
- const f = `${t.index}-${r.column.id}`, de = f in v ? v[f].value : o.value || "";
321
- return /* @__PURE__ */ i(
322
- he,
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",
323
367
  {
324
- value: de,
325
- originalValue: o.value || "",
326
- cellKey: f,
327
- cellData: o,
328
- isMarkedForReset: f in y,
329
- onChange: (C, S) => {
330
- j((p) => ({
331
- ...p,
332
- [C]: { value: S, cell: o }
333
- }));
334
- },
335
- resetCell: (C) => {
336
- j((S) => {
337
- const p = { ...S };
338
- return delete p[C], p;
339
- });
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);
340
381
  },
341
- resetToDefault: (C, S, p) => {
342
- k((ue) => ({
343
- ...ue,
344
- [C]: { value: S, cell: p }
345
- }));
346
- }
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
+ ] })
347
407
  }
348
408
  );
349
409
  })()
@@ -353,16 +413,89 @@ function Ae({
353
413
  );
354
414
  })
355
415
  },
356
- t.id
416
+ e.id
357
417
  );
358
418
  })
359
419
  }
360
420
  )
361
421
  ] })
362
422
  }
363
- )
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
+ ] })
364
497
  ] });
365
498
  }
366
499
  export {
367
- Ae as DataCrossTable
500
+ We as DataCrossTable
368
501
  };
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import { s as e } from "../../../../_virtual/index.js";
2
+ import { s as e } from "../../../../_virtual/index2.js";
3
3
  function s() {
4
4
  return e.useSyncExternalStore(
5
5
  r,
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import { __module as e } from "../../_virtual/index4.js";
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/index3.js";
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/index2.js";
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,7 +1,7 @@
1
1
  {
2
2
  "name": "laif-ds",
3
3
  "private": false,
4
- "version": "0.1.38",
4
+ "version": "0.1.39",
5
5
  "type": "module",
6
6
  "main": "dist/index.es.js",
7
7
  "module": "dist/index.es.js",
@@ -1,102 +0,0 @@
1
- "use client";
2
- import { jsxs as t, jsx as e } from "react/jsx-runtime";
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
- import { Button as p } from "../../button.js";
7
- const S = z(
8
- ({
9
- value: n,
10
- onChange: u,
11
- resetCell: a,
12
- resetToDefault: l,
13
- cellKey: s,
14
- originalValue: i,
15
- cellData: d,
16
- isMarkedForReset: x = !1
17
- }) => {
18
- const [C, r] = N(!1), [m, h] = N(n), g = (c) => {
19
- c && h(n), r(c);
20
- }, b = o(
21
- (c) => {
22
- h(c.target.value);
23
- },
24
- []
25
- ), w = o(() => {
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" }) })
38
- ] }) }) }),
39
- /* @__PURE__ */ e(R, { className: "w-[400px] p-4", children: /* @__PURE__ */ t("div", { className: "space-y-4", children: [
40
- /* @__PURE__ */ t("div", { className: "flex items-center justify-between", children: [
41
- /* @__PURE__ */ e("div", { className: "font-medium", children: "Modifica valore" }),
42
- v && /* @__PURE__ */ e("div", { className: "text-d-muted-foreground text-xs", children: "Valore modificato" })
43
- ] }),
44
- /* @__PURE__ */ e(
45
- "input",
46
- {
47
- type: "text",
48
- className: "bg-d-secondary w-full rounded border p-2",
49
- value: m || "",
50
- onChange: b,
51
- autoFocus: !0
52
- }
53
- ),
54
- /* @__PURE__ */ t("div", { className: "flex items-center justify-between", children: [
55
- /* @__PURE__ */ t(
56
- p,
57
- {
58
- variant: "destructive",
59
- size: "sm",
60
- onClick: k,
61
- className: "text-xs",
62
- title: "Ripristina il valore originale e segna la cella come da ripristinare",
63
- children: [
64
- /* @__PURE__ */ e(f, { name: "RotateCcw", className: "mr-1 h-3 w-3" }),
65
- "Ripristina"
66
- ]
67
- }
68
- ),
69
- /* @__PURE__ */ t("div", { className: "flex space-x-2", children: [
70
- /* @__PURE__ */ e(
71
- p,
72
- {
73
- variant: "ghost",
74
- size: "sm",
75
- onClick: j,
76
- className: "text-xs",
77
- title: "Annulla le modifiche correnti e chiudi",
78
- children: "Annulla"
79
- }
80
- ),
81
- /* @__PURE__ */ t(
82
- p,
83
- {
84
- size: "sm",
85
- onClick: w,
86
- className: "text-xs",
87
- title: "Conferma le modifiche e salva",
88
- children: [
89
- /* @__PURE__ */ e(f, { name: "Check", className: "mr-1 h-3 w-3" }),
90
- "Conferma"
91
- ]
92
- }
93
- )
94
- ] })
95
- ] })
96
- ] }) })
97
- ] });
98
- }
99
- );
100
- export {
101
- S as EditableInput
102
- };