laif-ds 0.1.31 → 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/data-table.js +42 -41
- package/package.json +1 -1
|
@@ -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
|
};
|