laif-ds 0.1.41 → 0.1.42

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,126 @@
1
+ "use client";
2
+ import { jsxs as l, jsx as p } from "react/jsx-runtime";
3
+ import { useDataCrossTable as w } from "./data-cross-table-context.js";
4
+ import { Button as n } from "../../button.js";
5
+ import { Icon as z } from "../../icon.js";
6
+ const B = ({ className: D = "" }) => {
7
+ const {
8
+ editedCells: m,
9
+ setEditedCells: f,
10
+ toDefaultCells: i,
11
+ setToDefaultCells: a,
12
+ editMode: j,
13
+ setEditMode: C,
14
+ onConfirmedCells: o,
15
+ editConfirmLabel: k,
16
+ editCancelLabel: L,
17
+ editRestoreDefaultLabel: u,
18
+ showDefaultActionButton: h
19
+ } = w();
20
+ if (!j) return null;
21
+ const d = Object.keys(m).length, e = Object.keys(i).length, b = d > 0 || e > 0, x = () => {
22
+ if (o) {
23
+ const r = Object.entries(i).map(
24
+ ([v, { value: c, cell: t }]) => ({
25
+ fromId: t.fromId,
26
+ toId: t.toId,
27
+ id: t.id,
28
+ value: c
29
+ })
30
+ );
31
+ o({
32
+ editedCells: [],
33
+ toDefaultCells: r
34
+ });
35
+ }
36
+ a({});
37
+ }, N = () => {
38
+ if (o && b) {
39
+ const r = Object.entries(m).map(
40
+ ([c, { value: t, cell: s }]) => ({
41
+ fromId: s.fromId,
42
+ toId: s.toId,
43
+ id: s.id,
44
+ value: t
45
+ })
46
+ ), I = Object.entries(i).map(
47
+ ([c, { value: t, cell: s }]) => ({
48
+ fromId: s.fromId,
49
+ toId: s.toId,
50
+ id: s.id,
51
+ value: t
52
+ })
53
+ );
54
+ o({
55
+ editedCells: r,
56
+ toDefaultCells: I
57
+ });
58
+ }
59
+ f({}), a({}), C(!1);
60
+ }, O = () => {
61
+ f({}), a({}), C(!1);
62
+ };
63
+ return /* @__PURE__ */ l("div", { className: `flex items-center space-x-2 ${D}`, children: [
64
+ h && /* @__PURE__ */ l(
65
+ n,
66
+ {
67
+ variant: "outline",
68
+ size: "sm",
69
+ onClick: x,
70
+ disabled: e === 0,
71
+ className: "text-xs",
72
+ iconLeft: "RotateCcw",
73
+ children: [
74
+ u,
75
+ " ",
76
+ e > 0 && `(${e})`
77
+ ]
78
+ }
79
+ ),
80
+ h && /* @__PURE__ */ l(
81
+ n,
82
+ {
83
+ variant: "outline",
84
+ size: "sm",
85
+ onClick: x,
86
+ disabled: e === 0,
87
+ className: "text-xs",
88
+ iconLeft: "RotateCcw",
89
+ children: [
90
+ u,
91
+ " ",
92
+ e > 0 && `(${e})`
93
+ ]
94
+ }
95
+ ),
96
+ /* @__PURE__ */ p(
97
+ n,
98
+ {
99
+ variant: "outline",
100
+ size: "sm",
101
+ onClick: O,
102
+ className: "text-xs",
103
+ iconLeft: "X",
104
+ children: L
105
+ }
106
+ ),
107
+ /* @__PURE__ */ l(
108
+ n,
109
+ {
110
+ size: "sm",
111
+ onClick: N,
112
+ disabled: !b,
113
+ className: "text-xs",
114
+ children: [
115
+ /* @__PURE__ */ p(z, { name: "Check", className: "mr-1 h-3 w-3" }),
116
+ k,
117
+ " ",
118
+ d > 0 && `(${d})`
119
+ ]
120
+ }
121
+ )
122
+ ] });
123
+ };
124
+ export {
125
+ B as DataCrossTableButtonsGroup
126
+ };
@@ -0,0 +1,50 @@
1
+ "use client";
2
+ import { jsx as w } from "react/jsx-runtime";
3
+ import { useState as t, createContext as E, useContext as M } from "react";
4
+ const s = E(void 0), R = ({
5
+ children: e,
6
+ onConfirmedCells: a,
7
+ editConfirmLabel: r = "Salva",
8
+ editCancelLabel: l = "Annulla",
9
+ editRestoreDefaultLabel: n = "Ripristina Default",
10
+ initialEditMode: i = !1,
11
+ showDefaultActionButton: u = !1,
12
+ cellEditTitleLabel: c = "Modifica valore",
13
+ cellEditModifiedLabel: d = "Valore modificato",
14
+ cellConfirmButtonLabel: f = "Conferma",
15
+ cellCancelButtonLabel: C = "Annulla",
16
+ cellResetButtonLabel: D = "Ripristina"
17
+ }) => {
18
+ const [m, v] = t({}), [x, b] = t({}), [p, T] = t(i), o = {
19
+ editedCells: m,
20
+ setEditedCells: v,
21
+ toDefaultCells: x,
22
+ setToDefaultCells: b,
23
+ editMode: p,
24
+ setEditMode: T,
25
+ onConfirmedCells: a,
26
+ // Etichette per i pulsanti principali
27
+ editConfirmLabel: r,
28
+ editCancelLabel: l,
29
+ editRestoreDefaultLabel: n,
30
+ showDefaultActionButton: u,
31
+ // Etichette per i pulsanti dell'EditableInput
32
+ cellEditTitleLabel: c,
33
+ cellEditModifiedLabel: d,
34
+ cellConfirmButtonLabel: f,
35
+ cellCancelButtonLabel: C,
36
+ cellResetButtonLabel: D
37
+ };
38
+ return /* @__PURE__ */ w(s.Provider, { value: o, children: typeof e == "function" ? e(o) : e });
39
+ }, S = () => {
40
+ const e = M(s);
41
+ if (!e)
42
+ throw new Error(
43
+ "useDataCrossTable must be used within a DataCrossTableProvider"
44
+ );
45
+ return e;
46
+ };
47
+ export {
48
+ R as DataCrossTableProvider,
49
+ S as useDataCrossTable
50
+ };