laif-ds 0.1.47 → 0.1.48
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 +49 -49
- package/package.json +1 -1
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as
|
|
2
|
+
import { jsx as t, jsxs as w } from "react/jsx-runtime";
|
|
3
3
|
import { useReactTable as K, flexRender as k } from "../../node_modules/@tanstack/react-table/build/lib/index.js";
|
|
4
4
|
import q, { useState as b, useEffect as J } from "react";
|
|
5
5
|
import { Checkbox as D } from "./checkbox.js";
|
|
6
6
|
import { cn as Q } from "../../lib/utils.js";
|
|
7
7
|
import { Input as U } from "./input.js";
|
|
8
|
-
import { ScrollArea as A, ScrollBar as
|
|
8
|
+
import { ScrollArea as A, ScrollBar as C } from "./scroll-area.js";
|
|
9
9
|
import { AppMultipleSelectDropdown as X } from "./app-multiple-select-dropdown.js";
|
|
10
|
-
import { Table as Y, TableHeader as Z, TableRow as
|
|
11
|
-
import { Skeleton as
|
|
12
|
-
import { getFilteredRowModel as
|
|
10
|
+
import { Table as Y, TableHeader as Z, TableRow as x, TableHead as B, TableBody as ee, TableCell as p } from "./table.js";
|
|
11
|
+
import { Skeleton as le } from "./skeleton.js";
|
|
12
|
+
import { getFilteredRowModel as te, getSortedRowModel as oe, getPaginationRowModel as ne, getCoreRowModel as ae } from "../../node_modules/@tanstack/table-core/build/lib/index.js";
|
|
13
13
|
function ce(s, r, n, d) {
|
|
14
14
|
const i = s.getValue(r), u = d == null ? void 0 : d.find((o) => o.column === r), m = (u == null ? void 0 : u.innerFiltersMode) ?? "OR";
|
|
15
15
|
if (Array.isArray(i))
|
|
@@ -41,7 +41,7 @@ function ie(s) {
|
|
|
41
41
|
{}
|
|
42
42
|
) || {};
|
|
43
43
|
}
|
|
44
|
-
function
|
|
44
|
+
function xe({
|
|
45
45
|
columns: s,
|
|
46
46
|
data: r,
|
|
47
47
|
loading: n = !1,
|
|
@@ -60,19 +60,19 @@ function pe({
|
|
|
60
60
|
const [T, z] = b([]), [$, j] = b([]), [H, P] = b({}), [y, F] = b(""), [L, O] = b({}), N = m ? u : L, _ = m || O, G = q.useMemo(() => o ? [
|
|
61
61
|
{
|
|
62
62
|
id: "select",
|
|
63
|
-
header: ({ table: e }) => /* @__PURE__ */
|
|
63
|
+
header: ({ table: e }) => /* @__PURE__ */ t("div", { className: "text-center", children: /* @__PURE__ */ t(
|
|
64
64
|
D,
|
|
65
65
|
{
|
|
66
66
|
checked: e.getIsAllPageRowsSelected(),
|
|
67
|
-
onCheckedChange: (
|
|
67
|
+
onCheckedChange: (l) => e.toggleAllPageRowsSelected(!!l),
|
|
68
68
|
"aria-label": "Seleziona tutti"
|
|
69
69
|
}
|
|
70
70
|
) }),
|
|
71
|
-
cell: ({ row: e }) => /* @__PURE__ */
|
|
71
|
+
cell: ({ row: e }) => /* @__PURE__ */ t("div", { className: "text-center", children: /* @__PURE__ */ t(
|
|
72
72
|
D,
|
|
73
73
|
{
|
|
74
74
|
checked: e.getIsSelected(),
|
|
75
|
-
onCheckedChange: (
|
|
75
|
+
onCheckedChange: (l) => e.toggleSelected(!!l),
|
|
76
76
|
"aria-label": "Seleziona riga"
|
|
77
77
|
}
|
|
78
78
|
) }),
|
|
@@ -81,12 +81,12 @@ function pe({
|
|
|
81
81
|
},
|
|
82
82
|
...s
|
|
83
83
|
] : s, [s, o]).map((e) => {
|
|
84
|
-
const
|
|
84
|
+
const l = a == null ? void 0 : a.find(
|
|
85
85
|
(c) => c.column === (e == null ? void 0 : e.accessorKey)
|
|
86
86
|
);
|
|
87
87
|
return {
|
|
88
88
|
...e,
|
|
89
|
-
filterFn:
|
|
89
|
+
filterFn: l != null && l.filterFn ? l.column : "multiValue"
|
|
90
90
|
};
|
|
91
91
|
}), I = {
|
|
92
92
|
data: r,
|
|
@@ -97,13 +97,13 @@ function pe({
|
|
|
97
97
|
getSortedRowModel: oe(),
|
|
98
98
|
onColumnVisibilityChange: P,
|
|
99
99
|
onRowSelectionChange: _,
|
|
100
|
-
getFilteredRowModel:
|
|
101
|
-
globalFilterFn: (e,
|
|
100
|
+
getFilteredRowModel: te(),
|
|
101
|
+
globalFilterFn: (e, l, c) => c ? (f == null ? void 0 : f.columns.some((S) => {
|
|
102
102
|
const R = e.getValue(S);
|
|
103
103
|
return String(R).toLowerCase().includes(c.toLowerCase());
|
|
104
104
|
})) ?? !1 : !0,
|
|
105
105
|
filterFns: {
|
|
106
|
-
multiValue: (e,
|
|
106
|
+
multiValue: (e, l, c) => ce(e, l, c, a),
|
|
107
107
|
...ie(a ?? [])
|
|
108
108
|
},
|
|
109
109
|
state: {
|
|
@@ -116,12 +116,12 @@ function pe({
|
|
|
116
116
|
}, h = K(I);
|
|
117
117
|
return J(() => {
|
|
118
118
|
if (g && o) {
|
|
119
|
-
const e = h.getFilteredSelectedRowModel().rows.map((
|
|
119
|
+
const e = h.getFilteredSelectedRowModel().rows.map((l) => l.original);
|
|
120
120
|
g(e);
|
|
121
121
|
}
|
|
122
|
-
}, [h, g, o, N]), /* @__PURE__ */
|
|
123
|
-
(f || (a == null ? void 0 : a.length)) && /* @__PURE__ */
|
|
124
|
-
f && /* @__PURE__ */
|
|
122
|
+
}, [h, g, o, N]), /* @__PURE__ */ w("div", { className: Q("flex h-full w-full flex-col gap-2", i), children: [
|
|
123
|
+
(f || (a == null ? void 0 : a.length)) && /* @__PURE__ */ w("div", { className: "flex flex-col items-start justify-between gap-2 sm:flex-row sm:items-end", children: [
|
|
124
|
+
f && /* @__PURE__ */ t(
|
|
125
125
|
U,
|
|
126
126
|
{
|
|
127
127
|
iconLeft: "Search",
|
|
@@ -133,11 +133,11 @@ function pe({
|
|
|
133
133
|
className: "w-60"
|
|
134
134
|
}
|
|
135
135
|
),
|
|
136
|
-
/* @__PURE__ */
|
|
137
|
-
/* @__PURE__ */
|
|
138
|
-
/* @__PURE__ */
|
|
136
|
+
/* @__PURE__ */ t("div", { className: "flex h-full max-w-full min-w-0 flex-1 items-center", children: a && a.length > 0 && /* @__PURE__ */ w(A, { className: "h-full w-full", children: [
|
|
137
|
+
/* @__PURE__ */ t(C, { orientation: "horizontal" }),
|
|
138
|
+
/* @__PURE__ */ t("div", { className: "flex w-full max-w-full min-w-0 items-center justify-start gap-2 sm:justify-end", children: a.map((e, l) => {
|
|
139
139
|
const [c, S] = b([]);
|
|
140
|
-
return /* @__PURE__ */
|
|
140
|
+
return /* @__PURE__ */ t(
|
|
141
141
|
X,
|
|
142
142
|
{
|
|
143
143
|
className: "w-60",
|
|
@@ -157,52 +157,52 @@ function pe({
|
|
|
157
157
|
});
|
|
158
158
|
}
|
|
159
159
|
},
|
|
160
|
-
|
|
160
|
+
l
|
|
161
161
|
);
|
|
162
162
|
}) })
|
|
163
163
|
] }) })
|
|
164
164
|
] }),
|
|
165
|
-
/* @__PURE__ */
|
|
166
|
-
/* @__PURE__ */
|
|
167
|
-
/* @__PURE__ */
|
|
168
|
-
/* @__PURE__ */
|
|
169
|
-
/* @__PURE__ */
|
|
165
|
+
/* @__PURE__ */ w(A, { className: "border-d-border h-full min-h-0 w-full rounded-md border", children: [
|
|
166
|
+
/* @__PURE__ */ t(C, { orientation: "horizontal" }),
|
|
167
|
+
/* @__PURE__ */ t(C, { orientation: "vertical" }),
|
|
168
|
+
/* @__PURE__ */ w(Y, { children: [
|
|
169
|
+
/* @__PURE__ */ t(Z, { children: h.getHeaderGroups().map((e) => /* @__PURE__ */ t(x, { children: e.headers.map((l) => /* @__PURE__ */ t(
|
|
170
170
|
B,
|
|
171
171
|
{
|
|
172
|
-
className: `bg-d-secondary sticky top-0 z-10 ${
|
|
173
|
-
children:
|
|
174
|
-
|
|
175
|
-
|
|
172
|
+
className: `bg-d-secondary sticky top-0 z-10 ${l.column.columnDef.sticky ? "left-0" : ""}`,
|
|
173
|
+
children: l.isPlaceholder ? null : k(
|
|
174
|
+
l.column.columnDef.header,
|
|
175
|
+
l.getContext()
|
|
176
176
|
)
|
|
177
177
|
},
|
|
178
|
-
|
|
178
|
+
l.id
|
|
179
179
|
)) }, e.id)) }),
|
|
180
|
-
/* @__PURE__ */
|
|
181
|
-
|
|
180
|
+
/* @__PURE__ */ t(ee, { children: n ? Array.from({ length: r.length || 8 }).map((e, l) => /* @__PURE__ */ t(x, { children: h.getHeaderGroups()[0].headers.map((c, S) => /* @__PURE__ */ t(
|
|
181
|
+
p,
|
|
182
182
|
{
|
|
183
183
|
className: `w-full ${c.column.columnDef.sticky ? "bg-d-background sticky left-0 z-10" : ""}`,
|
|
184
|
-
children: /* @__PURE__ */
|
|
184
|
+
children: /* @__PURE__ */ t(le, { className: "h-6 w-full" })
|
|
185
185
|
},
|
|
186
|
-
`skeleton-cell-${
|
|
187
|
-
)) }, `skeleton-row-${
|
|
188
|
-
|
|
186
|
+
`skeleton-cell-${l}-${S}`
|
|
187
|
+
)) }, `skeleton-row-${l}`)) : (v = h.getRowModel().rows) != null && v.length ? h.getRowModel().rows.map((e) => /* @__PURE__ */ t(
|
|
188
|
+
x,
|
|
189
189
|
{
|
|
190
190
|
"data-state": e.getIsSelected() && "selected",
|
|
191
|
-
children: e.getVisibleCells().map((
|
|
192
|
-
|
|
191
|
+
children: e.getVisibleCells().map((l) => /* @__PURE__ */ t(
|
|
192
|
+
p,
|
|
193
193
|
{
|
|
194
|
-
className: `${
|
|
194
|
+
className: `${l.column.columnDef.sticky ? "bg-d-background sticky left-0 z-10" : ""}`,
|
|
195
195
|
children: k(
|
|
196
|
-
|
|
197
|
-
|
|
196
|
+
l.column.columnDef.cell,
|
|
197
|
+
l.getContext()
|
|
198
198
|
)
|
|
199
199
|
},
|
|
200
|
-
|
|
200
|
+
l.id
|
|
201
201
|
))
|
|
202
202
|
},
|
|
203
203
|
e.id
|
|
204
|
-
)) : /* @__PURE__ */
|
|
205
|
-
|
|
204
|
+
)) : /* @__PURE__ */ t(x, { children: /* @__PURE__ */ t(
|
|
205
|
+
p,
|
|
206
206
|
{
|
|
207
207
|
colSpan: s.length,
|
|
208
208
|
className: "pt-4 text-center",
|
|
@@ -214,5 +214,5 @@ function pe({
|
|
|
214
214
|
] });
|
|
215
215
|
}
|
|
216
216
|
export {
|
|
217
|
-
|
|
217
|
+
xe as DataTable
|
|
218
218
|
};
|