laif-ds 0.1.30 → 0.1.32
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/components/ui/app-multiple-select-dropdown.js +14 -14
- package/dist/components/ui/data-cross-table.js +112 -107
- package/dist/components/ui/data-table.js +42 -41
- package/dist/components/ui/dropdown-menu.js +131 -0
- package/dist/components/ui/table.js +3 -10
- package/dist/index.d.ts +18 -3
- package/dist/index.js +168 -161
- package/dist/node_modules/@radix-ui/react-dropdown-menu/dist/index.js +217 -0
- package/dist/node_modules/@radix-ui/react-dropdown-menu/node_modules/@radix-ui/react-arrow/dist/index.js +25 -0
- package/dist/node_modules/@radix-ui/react-dropdown-menu/node_modules/@radix-ui/react-collection/dist/index.js +49 -0
- package/dist/node_modules/@radix-ui/react-dropdown-menu/node_modules/@radix-ui/react-dismissable-layer/dist/index.js +128 -0
- package/dist/node_modules/@radix-ui/react-dropdown-menu/node_modules/@radix-ui/react-focus-scope/dist/index.js +138 -0
- package/dist/node_modules/@radix-ui/react-dropdown-menu/node_modules/@radix-ui/react-menu/dist/index.js +625 -0
- package/dist/node_modules/@radix-ui/react-dropdown-menu/node_modules/@radix-ui/react-popper/dist/index.js +221 -0
- package/dist/node_modules/@radix-ui/react-dropdown-menu/node_modules/@radix-ui/react-portal/dist/index.js +17 -0
- package/dist/node_modules/@radix-ui/react-dropdown-menu/node_modules/@radix-ui/react-primitive/dist/index.js +37 -0
- package/dist/node_modules/@radix-ui/react-dropdown-menu/node_modules/@radix-ui/react-roving-focus/dist/index.js +184 -0
- package/dist/node_modules/@radix-ui/react-dropdown-menu/node_modules/@radix-ui/react-use-controllable-state/dist/index.js +55 -0
- package/package.json +1 -1
|
@@ -5,7 +5,7 @@ import { useEffect as A } from "react";
|
|
|
5
5
|
import { cn as N } from "../../lib/utils.js";
|
|
6
6
|
import { Label as B } from "./label.js";
|
|
7
7
|
import { Badge as D } from "./badge.js";
|
|
8
|
-
import { Button as
|
|
8
|
+
import { Button as p } from "./button.js";
|
|
9
9
|
import { Command as F, CommandList as P, CommandEmpty as G, CommandGroup as X, CommandItem as q } from "./command.js";
|
|
10
10
|
import { Input as H } from "./input.js";
|
|
11
11
|
import { Checkbox as I } from "./checkbox.js";
|
|
@@ -29,10 +29,10 @@ function ne({
|
|
|
29
29
|
cancelButtonLabel: O = "Cancella",
|
|
30
30
|
maxSelectedItems: s
|
|
31
31
|
}) {
|
|
32
|
-
const f = a.useId(), [c, b] = a.useState(!1), [m, v] = a.useState(""),
|
|
32
|
+
const f = a.useId(), [c, b] = a.useState(!1), [m, v] = a.useState(""), h = a.useRef(null);
|
|
33
33
|
A(() => {
|
|
34
34
|
const e = (n) => {
|
|
35
|
-
|
|
35
|
+
h.current && !h.current.contains(n.target) && c && b(!1);
|
|
36
36
|
};
|
|
37
37
|
return document.addEventListener("mousedown", e), () => {
|
|
38
38
|
document.removeEventListener("mousedown", e);
|
|
@@ -46,11 +46,11 @@ function ne({
|
|
|
46
46
|
return;
|
|
47
47
|
i([...t, e]);
|
|
48
48
|
}
|
|
49
|
-
}, [t, i, s]),
|
|
49
|
+
}, [t, i, s]), w = a.useCallback(() => {
|
|
50
50
|
i([]), v("");
|
|
51
51
|
}, [i]), u = a.useMemo(() => o.filter((e) => t.includes(e.value)), [o, t]), j = a.useMemo(() => m ? o.filter(
|
|
52
52
|
(e) => e.label.toLowerCase().includes(m.toLowerCase())
|
|
53
|
-
) : o, [o, m]),
|
|
53
|
+
) : o, [o, m]), x = a.useMemo(() => s ? t.length >= s : !1, [t, s]);
|
|
54
54
|
return /* @__PURE__ */ r(T.Provider, { value: { size: d, id: f }, children: /* @__PURE__ */ l("div", { className: "space-y-1.5", children: [
|
|
55
55
|
g && /* @__PURE__ */ r(
|
|
56
56
|
B,
|
|
@@ -60,9 +60,9 @@ function ne({
|
|
|
60
60
|
children: g
|
|
61
61
|
}
|
|
62
62
|
),
|
|
63
|
-
/* @__PURE__ */ l("div", { ref:
|
|
63
|
+
/* @__PURE__ */ l("div", { ref: h, className: "relative w-full", "data-slot": "app-multiple-select-dropdown", children: [
|
|
64
64
|
/* @__PURE__ */ l(
|
|
65
|
-
|
|
65
|
+
p,
|
|
66
66
|
{
|
|
67
67
|
id: f,
|
|
68
68
|
type: "button",
|
|
@@ -94,13 +94,13 @@ function ne({
|
|
|
94
94
|
}
|
|
95
95
|
),
|
|
96
96
|
/* @__PURE__ */ l(
|
|
97
|
-
|
|
97
|
+
p,
|
|
98
98
|
{
|
|
99
99
|
variant: "ghost",
|
|
100
100
|
size: "sm",
|
|
101
101
|
className: "h-5 w-5 p-0 hover:bg-d-secondary/20 rounded-full",
|
|
102
102
|
onClick: (e) => {
|
|
103
|
-
e.stopPropagation(),
|
|
103
|
+
e.stopPropagation(), w();
|
|
104
104
|
},
|
|
105
105
|
children: [
|
|
106
106
|
/* @__PURE__ */ r(J, { className: "h-3 w-3" }),
|
|
@@ -122,16 +122,16 @@ function ne({
|
|
|
122
122
|
placeholder: z,
|
|
123
123
|
value: m,
|
|
124
124
|
onChange: (e) => v(e.target.value),
|
|
125
|
-
className: "w-full !border-0 !border-none !outline-none focus-visible:ring-0"
|
|
125
|
+
className: "w-full !border-0 !border-none !outline-none focus-visible:ring-0 shadow-none"
|
|
126
126
|
}
|
|
127
127
|
),
|
|
128
128
|
u.length > 0 && /* @__PURE__ */ r(
|
|
129
|
-
|
|
129
|
+
p,
|
|
130
130
|
{
|
|
131
131
|
variant: "ghost",
|
|
132
132
|
size: "sm",
|
|
133
133
|
className: "h-6 px-2 text-xs",
|
|
134
|
-
onClick:
|
|
134
|
+
onClick: w,
|
|
135
135
|
children: O
|
|
136
136
|
}
|
|
137
137
|
)
|
|
@@ -144,11 +144,11 @@ function ne({
|
|
|
144
144
|
q,
|
|
145
145
|
{
|
|
146
146
|
value: e.value,
|
|
147
|
-
disabled: e.disabled || !n &&
|
|
147
|
+
disabled: e.disabled || !n && x,
|
|
148
148
|
onSelect: () => S(e.value),
|
|
149
149
|
className: N(
|
|
150
150
|
"flex items-center gap-2 px-2 py-1.5 aria-selected:bg-d-accent aria-selected:text-d-accent-foreground cursor-pointer",
|
|
151
|
-
(e.disabled || !n &&
|
|
151
|
+
(e.disabled || !n && x) && "cursor-not-allowed opacity-50"
|
|
152
152
|
),
|
|
153
153
|
children: [
|
|
154
154
|
/* @__PURE__ */ r(
|
|
@@ -1,97 +1,95 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsxs as
|
|
3
|
-
import { useState as
|
|
4
|
-
import { useReactTable as
|
|
5
|
-
import { TableSkeleton as
|
|
6
|
-
import { Button as
|
|
7
|
-
import { TooltipProvider as
|
|
8
|
-
import { TableRow as
|
|
9
|
-
import { getSortedRowModel as
|
|
10
|
-
function
|
|
11
|
-
return !
|
|
12
|
-
/* @__PURE__ */ o(
|
|
13
|
-
|
|
2
|
+
import { jsxs as b, jsx as o } from "react/jsx-runtime";
|
|
3
|
+
import { useState as C, useMemo as S } from "react";
|
|
4
|
+
import { useReactTable as P, flexRender as V } from "../../node_modules/@tanstack/react-table/build/lib/index.js";
|
|
5
|
+
import { TableSkeleton as U } from "./table-skeleton.js";
|
|
6
|
+
import { Button as j } from "./button.js";
|
|
7
|
+
import { TooltipProvider as q, Tooltip as G, TooltipTrigger as J, TooltipContent as K } from "./tooltip.js";
|
|
8
|
+
import { TableRow as T, TableCell as A, Table as Q, TableHeader as X, TableHead as Y, TableBody as Z } from "./table.js";
|
|
9
|
+
import { getSortedRowModel as _, getCoreRowModel as W } from "../../node_modules/@tanstack/table-core/build/lib/index.js";
|
|
10
|
+
function v({ text: c, maxLength: a, className: h = "" }) {
|
|
11
|
+
return !c || c.length <= a ? /* @__PURE__ */ o("div", { className: h, children: c }) : /* @__PURE__ */ o(q, { children: /* @__PURE__ */ b(G, { children: [
|
|
12
|
+
/* @__PURE__ */ o(J, { asChild: !0, children: /* @__PURE__ */ b("div", { className: `truncate ${h} cursor-pointer`, children: [
|
|
13
|
+
c.substring(0, a),
|
|
14
14
|
"..."
|
|
15
15
|
] }) }),
|
|
16
|
-
/* @__PURE__ */ o(
|
|
16
|
+
/* @__PURE__ */ o(K, { children: /* @__PURE__ */ o("p", { children: c }) })
|
|
17
17
|
] }) });
|
|
18
18
|
}
|
|
19
19
|
function ie({
|
|
20
|
-
crossTableData:
|
|
21
|
-
filterable:
|
|
22
|
-
loading:
|
|
23
|
-
emptyComponent:
|
|
24
|
-
className:
|
|
25
|
-
notFoundMessage:
|
|
26
|
-
cornerHeaderFrom:
|
|
27
|
-
cornerHeaderTo:
|
|
28
|
-
maxHeaderLength:
|
|
29
|
-
minWidthCell:
|
|
30
|
-
initialFreezeColumn: i = !0,
|
|
31
|
-
initialFreezeRow: b = !1
|
|
20
|
+
crossTableData: c,
|
|
21
|
+
filterable: a = !1,
|
|
22
|
+
loading: h = !1,
|
|
23
|
+
emptyComponent: D,
|
|
24
|
+
className: N,
|
|
25
|
+
notFoundMessage: M = "Nessun risultato trovato.",
|
|
26
|
+
cornerHeaderFrom: x = "Da",
|
|
27
|
+
cornerHeaderTo: w = "A",
|
|
28
|
+
maxHeaderLength: g = 15,
|
|
29
|
+
minWidthCell: R = 160
|
|
32
30
|
}) {
|
|
33
|
-
const [
|
|
34
|
-
if (!
|
|
35
|
-
const n =
|
|
36
|
-
if (n === -1) return
|
|
37
|
-
const r =
|
|
38
|
-
var
|
|
39
|
-
const s = ((
|
|
31
|
+
const [L, $] = C([]), { headerTop: d, headerLeft: m, data: f } = c, [p, I] = C(null), [y, k] = C(!0), B = (n) => n && typeof n == "object" && "value" in n ? n.value : n, u = S(() => {
|
|
32
|
+
if (!p) return d;
|
|
33
|
+
const n = m.indexOf(p);
|
|
34
|
+
if (n === -1) return d;
|
|
35
|
+
const r = d.map((e, t) => {
|
|
36
|
+
var i;
|
|
37
|
+
const s = ((i = f[n]) == null ? void 0 : i[t]) ?? null, l = B(s);
|
|
40
38
|
return { header: e, value: l };
|
|
41
39
|
});
|
|
42
40
|
return r.sort((e, t) => {
|
|
43
41
|
if (typeof e.value == "number" && typeof t.value == "number")
|
|
44
|
-
return
|
|
42
|
+
return y ? e.value - t.value : t.value - e.value;
|
|
45
43
|
const s = String(e.value ?? ""), l = String(t.value ?? "");
|
|
46
|
-
return
|
|
44
|
+
return y ? s.localeCompare(l) : l.localeCompare(s);
|
|
47
45
|
}), r.map((e) => e.header);
|
|
48
|
-
}, [
|
|
46
|
+
}, [d, m, f, p, y]), F = S(() => {
|
|
49
47
|
const n = [
|
|
50
48
|
{
|
|
51
49
|
id: "cross-header",
|
|
52
|
-
header: () => /* @__PURE__ */
|
|
53
|
-
/* @__PURE__ */ o("div", { className: "absolute top-0 left-2 text-xs", children:
|
|
54
|
-
/* @__PURE__ */ o("div", { className: "absolute bottom-0 right-2 text-xs", children:
|
|
50
|
+
header: () => /* @__PURE__ */ b("div", { className: "relative", children: [
|
|
51
|
+
/* @__PURE__ */ o("div", { className: "absolute top-0 left-2 text-xs", children: x }),
|
|
52
|
+
/* @__PURE__ */ o("div", { className: "absolute bottom-0 right-2 text-xs", children: w })
|
|
55
53
|
] }),
|
|
56
54
|
accessorFn: (r) => r.item,
|
|
57
55
|
cell: (r) => {
|
|
58
56
|
const e = r.getValue();
|
|
59
|
-
if (!
|
|
60
|
-
return /* @__PURE__ */ o(
|
|
61
|
-
const t =
|
|
57
|
+
if (!a)
|
|
58
|
+
return /* @__PURE__ */ o(v, { text: e, maxLength: g, className: "text-left" });
|
|
59
|
+
const t = p === e;
|
|
62
60
|
return /* @__PURE__ */ o(
|
|
63
|
-
|
|
61
|
+
j,
|
|
64
62
|
{
|
|
65
63
|
variant: "ghost",
|
|
66
64
|
size: "sm",
|
|
67
65
|
iconLeft: "ArrowLeftRight",
|
|
68
66
|
className: "text-right",
|
|
69
67
|
onClick: () => {
|
|
70
|
-
|
|
68
|
+
a && (t ? k((s) => !s) : (I(e), k(!0)));
|
|
71
69
|
},
|
|
72
|
-
children: /* @__PURE__ */ o(
|
|
70
|
+
children: /* @__PURE__ */ o(v, { text: e, maxLength: g })
|
|
73
71
|
}
|
|
74
72
|
);
|
|
75
73
|
}
|
|
76
74
|
}
|
|
77
75
|
];
|
|
78
|
-
return
|
|
76
|
+
return u.forEach((r) => {
|
|
79
77
|
n.push({
|
|
80
78
|
id: r,
|
|
81
79
|
accessorFn: (e) => e[r],
|
|
82
|
-
header: ({ column: e }) =>
|
|
83
|
-
|
|
80
|
+
header: ({ column: e }) => a ? /* @__PURE__ */ o(
|
|
81
|
+
j,
|
|
84
82
|
{
|
|
85
83
|
variant: "ghost",
|
|
86
84
|
size: "sm",
|
|
87
85
|
iconLeft: "ArrowUpDown",
|
|
88
|
-
onClick:
|
|
89
|
-
children: /* @__PURE__ */ o(
|
|
86
|
+
onClick: a ? () => e.toggleSorting(e.getIsSorted() === "asc") : void 0,
|
|
87
|
+
children: /* @__PURE__ */ o(v, { text: r, maxLength: g })
|
|
90
88
|
}
|
|
91
|
-
) : /* @__PURE__ */ o(
|
|
89
|
+
) : /* @__PURE__ */ o(v, { text: r, maxLength: g, className: "font-medium" }),
|
|
92
90
|
sortingFn: (e, t, s) => {
|
|
93
|
-
let l = e.getValue(s),
|
|
94
|
-
return l == null &&
|
|
91
|
+
let l = e.getValue(s), i = t.getValue(s);
|
|
92
|
+
return l == null && i == null ? 0 : l == null ? 1 : i == null ? -1 : (l && typeof l == "object" && "value" in l && (l = l.value), i && typeof i == "object" && "value" in i && (i = i.value), typeof l == "number" && typeof i == "number" ? l - i : String(l).localeCompare(String(i)));
|
|
95
93
|
},
|
|
96
94
|
//NOTE Cell is responsible for rendering the cell of his column
|
|
97
95
|
cell: (e) => {
|
|
@@ -100,79 +98,86 @@ function ie({
|
|
|
100
98
|
}
|
|
101
99
|
});
|
|
102
100
|
}), n;
|
|
103
|
-
}, [
|
|
101
|
+
}, [u, x, w, p, a]), E = S(() => m.map((n, r) => {
|
|
104
102
|
const e = { item: n };
|
|
105
|
-
return
|
|
103
|
+
return u.forEach((t) => {
|
|
106
104
|
var l;
|
|
107
|
-
const s =
|
|
108
|
-
e[t] = s !== -1 ? ((l =
|
|
105
|
+
const s = d.indexOf(t);
|
|
106
|
+
e[t] = s !== -1 ? ((l = f[r]) == null ? void 0 : l[s]) ?? null : null;
|
|
109
107
|
}), e;
|
|
110
|
-
}), [
|
|
111
|
-
data:
|
|
112
|
-
columns:
|
|
113
|
-
state: { sorting:
|
|
114
|
-
onSortingChange:
|
|
115
|
-
getCoreRowModel:
|
|
116
|
-
getSortedRowModel:
|
|
108
|
+
}), [m, u, f, d]), z = P({
|
|
109
|
+
data: E,
|
|
110
|
+
columns: F,
|
|
111
|
+
state: { sorting: L },
|
|
112
|
+
onSortingChange: $,
|
|
113
|
+
getCoreRowModel: W(),
|
|
114
|
+
getSortedRowModel: _()
|
|
117
115
|
});
|
|
118
|
-
if (!
|
|
119
|
-
return /* @__PURE__ */ o(
|
|
120
|
-
if (
|
|
116
|
+
if (!f || f.length === 0)
|
|
117
|
+
return /* @__PURE__ */ o(T, { children: /* @__PURE__ */ o(A, { colSpan: u.length + 1, children: D || M }) });
|
|
118
|
+
if (h)
|
|
121
119
|
return /* @__PURE__ */ o(
|
|
122
|
-
|
|
120
|
+
U,
|
|
123
121
|
{
|
|
124
|
-
headerRow:
|
|
125
|
-
rowCount:
|
|
126
|
-
columnCount:
|
|
127
|
-
className:
|
|
128
|
-
cornerHeaderFrom:
|
|
129
|
-
cornerHeaderTo:
|
|
122
|
+
headerRow: u,
|
|
123
|
+
rowCount: m.length || 5,
|
|
124
|
+
columnCount: u.length || 5,
|
|
125
|
+
className: N,
|
|
126
|
+
cornerHeaderFrom: x,
|
|
127
|
+
cornerHeaderTo: w
|
|
130
128
|
}
|
|
131
129
|
);
|
|
132
|
-
const
|
|
133
|
-
const r = n.column.id === "cross-header", e = r
|
|
134
|
-
r
|
|
130
|
+
const O = (n) => {
|
|
131
|
+
const r = n.column.id === "cross-header", e = r, t = ["bg-d-secondary"];
|
|
132
|
+
r || t.push("border-r"), r && t.push("sticky left-0"), t.push("sticky top-0 z-20"), e ? t.push("z-40") : r && t.push("z-30");
|
|
135
133
|
let s = "none";
|
|
136
|
-
return r &&
|
|
134
|
+
return r && (s = "inset -1px 0 0 0 var(--d-border), 0 1px 0 0 var(--d-border)"), {
|
|
137
135
|
className: t.join(" "),
|
|
138
|
-
style: { boxShadow: s, width: `${
|
|
136
|
+
style: { boxShadow: s, width: `${R}px` }
|
|
139
137
|
};
|
|
140
138
|
};
|
|
141
|
-
return /* @__PURE__ */ o("div", { className: `w-[900px] ${
|
|
142
|
-
/* @__PURE__ */ o(
|
|
143
|
-
|
|
139
|
+
return /* @__PURE__ */ o("div", { className: `w-[900px] ${N || ""}`, children: /* @__PURE__ */ o("div", { className: "rounded-md border overflow-auto max-h-[600px]", children: /* @__PURE__ */ b(Q, { className: "w-full table-fixed relative border-collapse", children: [
|
|
140
|
+
/* @__PURE__ */ o(
|
|
141
|
+
X,
|
|
144
142
|
{
|
|
145
|
-
className:
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
143
|
+
className: "sticky top-0 z-20 bg-d-secondary",
|
|
144
|
+
style: { boxShadow: "0 1px 0 0 var(--d-border)" },
|
|
145
|
+
children: z.getHeaderGroups().map((n) => /* @__PURE__ */ o(
|
|
146
|
+
T,
|
|
147
|
+
{
|
|
148
|
+
className: "sticky top-0 z-20 bg-d-secondary",
|
|
149
|
+
children: n.headers.map((r) => {
|
|
150
|
+
const e = O(r);
|
|
151
|
+
return /* @__PURE__ */ o(
|
|
152
|
+
Y,
|
|
153
|
+
{
|
|
154
|
+
className: e.className,
|
|
155
|
+
style: e.style,
|
|
156
|
+
children: r.isPlaceholder ? null : V(
|
|
157
|
+
r.column.columnDef.header,
|
|
158
|
+
r.getContext()
|
|
159
|
+
)
|
|
160
|
+
},
|
|
161
|
+
r.id
|
|
162
|
+
);
|
|
163
|
+
})
|
|
164
|
+
},
|
|
165
|
+
n.id
|
|
166
|
+
))
|
|
167
|
+
}
|
|
168
|
+
),
|
|
169
|
+
/* @__PURE__ */ o(Z, { children: z.getRowModel().rows.map((n) => /* @__PURE__ */ o(T, { children: n.getVisibleCells().map((r, e) => {
|
|
170
|
+
const t = e === 0, s = r.getValue(), l = t ? "var(--d-secondary)" : (s == null ? void 0 : s.color) || "transparent";
|
|
166
171
|
return /* @__PURE__ */ o(
|
|
167
|
-
|
|
172
|
+
A,
|
|
168
173
|
{
|
|
169
|
-
className: `text-center ${t
|
|
174
|
+
className: `text-center ${t ? "sticky left-0 z-10" : "border-r"}`,
|
|
170
175
|
style: {
|
|
171
|
-
boxShadow: t
|
|
176
|
+
boxShadow: t ? "inset -1px 0 0 0 var(--d-border)" : "none",
|
|
172
177
|
backgroundColor: l,
|
|
173
|
-
width: `${
|
|
178
|
+
width: `${R}px`
|
|
174
179
|
},
|
|
175
|
-
children:
|
|
180
|
+
children: V(
|
|
176
181
|
r.column.columnDef.cell,
|
|
177
182
|
r.getContext()
|
|
178
183
|
)
|
|
@@ -2,32 +2,33 @@
|
|
|
2
2
|
import { jsx as l, jsxs as d } from "react/jsx-runtime";
|
|
3
3
|
import { useReactTable as _, flexRender as b } from "../../node_modules/@tanstack/react-table/build/lib/index.js";
|
|
4
4
|
import j, { useState as i, useEffect as B } from "react";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
|
|
5
|
+
import { cn as L } from "../../lib/utils.js";
|
|
6
|
+
import { Checkbox as p } from "./checkbox.js";
|
|
7
|
+
import { Input as E } from "./input.js";
|
|
8
|
+
import { ScrollArea as G, ScrollBar as w } from "./scroll-area.js";
|
|
9
|
+
import { Table as W, TableHeader as q, TableRow as r, TableHead as J, TableBody as K, TableCell as m } from "./table.js";
|
|
10
|
+
import { Skeleton as O } from "./skeleton.js";
|
|
11
|
+
import { getFilteredRowModel as Q, getSortedRowModel as U, getPaginationRowModel as X, getCoreRowModel as Y } from "../../node_modules/@tanstack/table-core/build/lib/index.js";
|
|
12
|
+
function se({
|
|
13
|
+
columns: n,
|
|
13
14
|
data: g,
|
|
14
15
|
loading: C = !1,
|
|
15
16
|
emptyComponent: R,
|
|
16
17
|
className: k,
|
|
17
|
-
rowSelection:
|
|
18
|
+
rowSelection: x = {},
|
|
18
19
|
onRowSelectionChange: u,
|
|
19
|
-
checkable:
|
|
20
|
+
checkable: a = !1,
|
|
20
21
|
onCheckedRowsChange: c,
|
|
21
|
-
notFoundMessage:
|
|
22
|
+
notFoundMessage: y = "Nessun risultato trovato.",
|
|
22
23
|
clientFilter: s = null,
|
|
23
|
-
clientFilterPlaceholder:
|
|
24
|
+
clientFilterPlaceholder: M = "Cerca..."
|
|
24
25
|
}) {
|
|
25
26
|
var h, S;
|
|
26
|
-
const [
|
|
27
|
+
const [N, v] = i([]), [T, z] = i([]), [D, F] = i({}), [V, $] = i({}), f = u ? x : V, A = u || $, H = j.useMemo(() => a ? [
|
|
27
28
|
{
|
|
28
29
|
id: "select",
|
|
29
30
|
header: ({ table: t }) => /* @__PURE__ */ l("div", { className: "text-center", children: /* @__PURE__ */ l(
|
|
30
|
-
|
|
31
|
+
p,
|
|
31
32
|
{
|
|
32
33
|
checked: t.getIsAllPageRowsSelected(),
|
|
33
34
|
onCheckedChange: (e) => t.toggleAllPageRowsSelected(!!e),
|
|
@@ -35,7 +36,7 @@ function re({
|
|
|
35
36
|
}
|
|
36
37
|
) }),
|
|
37
38
|
cell: ({ row: t }) => /* @__PURE__ */ l("div", { className: "text-center", children: /* @__PURE__ */ l(
|
|
38
|
-
|
|
39
|
+
p,
|
|
39
40
|
{
|
|
40
41
|
checked: t.getIsSelected(),
|
|
41
42
|
onCheckedChange: (e) => t.toggleSelected(!!e),
|
|
@@ -45,36 +46,36 @@ function re({
|
|
|
45
46
|
enableSorting: !1,
|
|
46
47
|
enableHiding: !1
|
|
47
48
|
},
|
|
48
|
-
...
|
|
49
|
-
] :
|
|
49
|
+
...n
|
|
50
|
+
] : n, [n, a]), o = _({
|
|
50
51
|
data: g,
|
|
51
52
|
columns: H,
|
|
52
|
-
getCoreRowModel:
|
|
53
|
-
getPaginationRowModel:
|
|
53
|
+
getCoreRowModel: Y(),
|
|
54
|
+
getPaginationRowModel: X(),
|
|
54
55
|
onSortingChange: v,
|
|
55
|
-
getSortedRowModel:
|
|
56
|
-
onColumnFiltersChange:
|
|
57
|
-
getFilteredRowModel:
|
|
58
|
-
onColumnVisibilityChange:
|
|
56
|
+
getSortedRowModel: U(),
|
|
57
|
+
onColumnFiltersChange: z,
|
|
58
|
+
getFilteredRowModel: Q(),
|
|
59
|
+
onColumnVisibilityChange: F,
|
|
59
60
|
onRowSelectionChange: A,
|
|
60
61
|
state: {
|
|
61
|
-
sorting:
|
|
62
|
+
sorting: N,
|
|
62
63
|
columnFilters: T,
|
|
63
|
-
columnVisibility:
|
|
64
|
+
columnVisibility: D,
|
|
64
65
|
rowSelection: f
|
|
65
66
|
}
|
|
66
67
|
});
|
|
67
68
|
return B(() => {
|
|
68
|
-
if (c &&
|
|
69
|
+
if (c && a) {
|
|
69
70
|
const t = o.getFilteredSelectedRowModel().rows.map((e) => e.original);
|
|
70
71
|
c(t);
|
|
71
72
|
}
|
|
72
|
-
}, [o, c,
|
|
73
|
+
}, [o, c, a, f]), /* @__PURE__ */ d("div", { className: L("w-full h-full", k), children: [
|
|
73
74
|
s && /* @__PURE__ */ l("div", { className: "flex items-center py-4", children: /* @__PURE__ */ l(
|
|
74
|
-
|
|
75
|
+
E,
|
|
75
76
|
{
|
|
76
77
|
iconLeft: "Search",
|
|
77
|
-
placeholder:
|
|
78
|
+
placeholder: M ?? "Cerca...",
|
|
78
79
|
value: (h = o.getColumn(s)) == null ? void 0 : h.getFilterValue(),
|
|
79
80
|
onChange: (t) => {
|
|
80
81
|
var e;
|
|
@@ -83,12 +84,12 @@ function re({
|
|
|
83
84
|
className: "max-w-sm"
|
|
84
85
|
}
|
|
85
86
|
) }),
|
|
86
|
-
/* @__PURE__ */
|
|
87
|
-
/* @__PURE__ */ l(
|
|
88
|
-
/* @__PURE__ */ l(
|
|
89
|
-
/* @__PURE__ */ d(
|
|
90
|
-
/* @__PURE__ */ l(
|
|
91
|
-
|
|
87
|
+
/* @__PURE__ */ d(G, { className: "h-full w-full rounded-md border", children: [
|
|
88
|
+
/* @__PURE__ */ l(w, { orientation: "horizontal" }),
|
|
89
|
+
/* @__PURE__ */ l(w, { orientation: "vertical" }),
|
|
90
|
+
/* @__PURE__ */ d(W, { children: [
|
|
91
|
+
/* @__PURE__ */ l(q, { children: o.getHeaderGroups().map((t) => /* @__PURE__ */ l(r, { children: t.headers.map((e) => /* @__PURE__ */ l(
|
|
92
|
+
J,
|
|
92
93
|
{
|
|
93
94
|
className: `${e.column.columnDef.sticky ? "sticky left-0 z-10 bg-d-background" : ""}`,
|
|
94
95
|
children: e.isPlaceholder ? null : b(
|
|
@@ -98,11 +99,11 @@ function re({
|
|
|
98
99
|
},
|
|
99
100
|
e.id
|
|
100
101
|
)) }, t.id)) }),
|
|
101
|
-
/* @__PURE__ */ l(
|
|
102
|
+
/* @__PURE__ */ l(K, { children: C ? Array.from({ length: g.length || 8 }).map((t, e) => /* @__PURE__ */ l(r, { children: o.getHeaderGroups()[0].headers.map((P, I) => /* @__PURE__ */ l(
|
|
102
103
|
m,
|
|
103
104
|
{
|
|
104
105
|
className: `w-full ${P.column.columnDef.sticky ? "sticky left-0 z-10 bg-d-background" : ""}`,
|
|
105
|
-
children: /* @__PURE__ */ l(
|
|
106
|
+
children: /* @__PURE__ */ l(O, { className: "h-6 w-full" })
|
|
106
107
|
},
|
|
107
108
|
`skeleton-cell-${e}-${I}`
|
|
108
109
|
)) }, `skeleton-row-${e}`)) : (S = o.getRowModel().rows) != null && S.length ? o.getRowModel().rows.map((t) => /* @__PURE__ */ l(
|
|
@@ -125,15 +126,15 @@ function re({
|
|
|
125
126
|
)) : /* @__PURE__ */ l(r, { children: /* @__PURE__ */ l(
|
|
126
127
|
m,
|
|
127
128
|
{
|
|
128
|
-
colSpan:
|
|
129
|
+
colSpan: n.length,
|
|
129
130
|
className: "h-24 text-center",
|
|
130
|
-
children: R ||
|
|
131
|
+
children: R || y
|
|
131
132
|
}
|
|
132
133
|
) }) })
|
|
133
134
|
] })
|
|
134
|
-
] })
|
|
135
|
+
] })
|
|
135
136
|
] });
|
|
136
137
|
}
|
|
137
138
|
export {
|
|
138
|
-
|
|
139
|
+
se as DataTable
|
|
139
140
|
};
|