laif-ds 0.1.49 → 0.1.50
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/async-select.js +148 -131
- package/dist/components/ui/data-table.js +111 -166
- package/dist/components/ui/pagination.js +27 -67
- package/dist/index.d.ts +0 -19
- package/package.json +1 -1
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsxs as
|
|
3
|
-
import * as
|
|
4
|
-
import { useState as
|
|
5
|
-
import { useDebounce as
|
|
6
|
-
import { cva as
|
|
7
|
-
import { cn as
|
|
8
|
-
import { Button as
|
|
9
|
-
import { Label as
|
|
10
|
-
import { Command as
|
|
11
|
-
import { Popover as
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
const
|
|
2
|
+
import { jsxs as s, jsx as e } from "react/jsx-runtime";
|
|
3
|
+
import * as Y from "react";
|
|
4
|
+
import { useState as c, useEffect as j, useCallback as D } from "react";
|
|
5
|
+
import { useDebounce as Z } from "../../hooks/use-debounce.js";
|
|
6
|
+
import { cva as _ } from "../../node_modules/class-variance-authority/dist/index.js";
|
|
7
|
+
import { cn as k } from "../../lib/utils.js";
|
|
8
|
+
import { Button as V } from "./button.js";
|
|
9
|
+
import { Label as ee } from "./label.js";
|
|
10
|
+
import { Command as te, CommandInput as oe, CommandList as se, CommandEmpty as ne, CommandGroup as O, CommandItem as A } from "./command.js";
|
|
11
|
+
import { Popover as re, PopoverTrigger as ae, PopoverContent as ce } from "./popover.js";
|
|
12
|
+
import ie from "../../node_modules/lucide-react/dist/esm/icons/x.js";
|
|
13
|
+
import le from "../../node_modules/lucide-react/dist/esm/icons/chevrons-up-down.js";
|
|
14
|
+
import de from "../../node_modules/lucide-react/dist/esm/icons/loader-circle.js";
|
|
15
|
+
import me from "../../node_modules/lucide-react/dist/esm/icons/check.js";
|
|
16
|
+
const fe = _(
|
|
17
17
|
"flex items-center justify-between whitespace-nowrap rounded-md border border-input bg-transparent px-3 py-2 shadow-sm ring-offset-background data-[placeholder]:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",
|
|
18
18
|
{
|
|
19
19
|
variants: {
|
|
@@ -28,162 +28,179 @@ const he = te(
|
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
);
|
|
31
|
-
function
|
|
32
|
-
fetcher:
|
|
33
|
-
preload:
|
|
31
|
+
function ke({
|
|
32
|
+
fetcher: i,
|
|
33
|
+
preload: m,
|
|
34
34
|
filterFn: x,
|
|
35
|
-
renderOption:
|
|
36
|
-
getOptionValue:
|
|
37
|
-
getDisplayValue:
|
|
38
|
-
notFound:
|
|
39
|
-
loadingSkeleton:
|
|
40
|
-
label:
|
|
41
|
-
labelClassName:
|
|
42
|
-
placeholder:
|
|
43
|
-
value:
|
|
44
|
-
onChange:
|
|
45
|
-
disabled:
|
|
46
|
-
width:
|
|
47
|
-
className:
|
|
48
|
-
triggerClassName:
|
|
49
|
-
noResultsMessage:
|
|
35
|
+
renderOption: F,
|
|
36
|
+
getOptionValue: a,
|
|
37
|
+
getDisplayValue: w,
|
|
38
|
+
notFound: R,
|
|
39
|
+
loadingSkeleton: $,
|
|
40
|
+
label: l,
|
|
41
|
+
labelClassName: B,
|
|
42
|
+
placeholder: G = "Select...",
|
|
43
|
+
value: n,
|
|
44
|
+
onChange: p,
|
|
45
|
+
disabled: z = !1,
|
|
46
|
+
width: E = "200px",
|
|
47
|
+
className: M,
|
|
48
|
+
triggerClassName: U,
|
|
49
|
+
noResultsMessage: X,
|
|
50
50
|
clearable: v = !0,
|
|
51
|
-
size:
|
|
51
|
+
size: q
|
|
52
52
|
}) {
|
|
53
|
-
const [
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
t && L(t);
|
|
60
|
-
}
|
|
61
|
-
}, [a, o, i]), y(() => {
|
|
62
|
-
f || (async () => {
|
|
63
|
-
try {
|
|
64
|
-
u(!0), h(null);
|
|
65
|
-
const s = await l(a);
|
|
66
|
-
P(s), p(s);
|
|
67
|
-
} catch (s) {
|
|
68
|
-
h(
|
|
69
|
-
s instanceof Error ? s.message : "Failed to fetch options"
|
|
70
|
-
);
|
|
71
|
-
} finally {
|
|
72
|
-
u(!1);
|
|
73
|
-
}
|
|
74
|
-
})();
|
|
75
|
-
}, [f, l, a]), y(() => {
|
|
76
|
-
const t = async () => {
|
|
77
|
-
try {
|
|
78
|
-
u(!0), h(null);
|
|
79
|
-
const s = await l(g);
|
|
80
|
-
P(s), p(s);
|
|
81
|
-
} catch (s) {
|
|
82
|
-
h(
|
|
83
|
-
s instanceof Error ? s.message : "Failed to fetch options"
|
|
53
|
+
const [u, N] = c(!1), [r, d] = c([]), [C, h] = c(!1), [b, g] = c(null), [S, y] = c(null), [I, H] = c(""), f = Z(I, m ? 0 : 300), [L, P] = c([]);
|
|
54
|
+
j(() => ((async () => {
|
|
55
|
+
try {
|
|
56
|
+
if (h(!0), g(null), m) {
|
|
57
|
+
console.log(
|
|
58
|
+
"[AsyncSelect] Preload attivo: caricamento completo dei dati"
|
|
84
59
|
);
|
|
85
|
-
|
|
86
|
-
|
|
60
|
+
const o = await i("");
|
|
61
|
+
P(o), d(o);
|
|
62
|
+
} else {
|
|
63
|
+
const o = await i(n);
|
|
64
|
+
d(o);
|
|
87
65
|
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
66
|
+
} catch (o) {
|
|
67
|
+
g(
|
|
68
|
+
o instanceof Error ? o.message : "Failed to fetch options"
|
|
69
|
+
);
|
|
70
|
+
} finally {
|
|
71
|
+
h(!1);
|
|
72
|
+
}
|
|
73
|
+
})(), () => {
|
|
74
|
+
d([]), P([]);
|
|
75
|
+
}), [i, n, m]), j(() => {
|
|
76
|
+
if (u)
|
|
77
|
+
if (m)
|
|
78
|
+
if (console.log(
|
|
79
|
+
"[AsyncSelect] Filtraggio locale dei dati con preload attivo"
|
|
80
|
+
), f) {
|
|
81
|
+
const t = L.filter(
|
|
82
|
+
(o) => x ? x(o, f) : String(w(o)).toLowerCase().includes(f.toLowerCase())
|
|
83
|
+
);
|
|
84
|
+
d(t);
|
|
85
|
+
} else
|
|
86
|
+
d(L);
|
|
87
|
+
else
|
|
88
|
+
(async () => {
|
|
89
|
+
try {
|
|
90
|
+
h(!0), g(null);
|
|
91
|
+
const o = await i(f);
|
|
92
|
+
d(o);
|
|
93
|
+
} catch (o) {
|
|
94
|
+
g(
|
|
95
|
+
o instanceof Error ? o.message : "Failed to fetch options"
|
|
96
|
+
);
|
|
97
|
+
} finally {
|
|
98
|
+
h(!1);
|
|
99
|
+
}
|
|
100
|
+
})();
|
|
101
|
+
}, [
|
|
102
|
+
u,
|
|
103
|
+
f,
|
|
104
|
+
m,
|
|
105
|
+
x,
|
|
106
|
+
L,
|
|
107
|
+
w
|
|
108
|
+
]), j(() => {
|
|
109
|
+
if (n && r.length > 0) {
|
|
110
|
+
const t = r.find((o) => a(o) === n);
|
|
111
|
+
y(t || null);
|
|
112
|
+
} else n || y(null);
|
|
113
|
+
}, [n, r, a]);
|
|
114
|
+
const J = D(
|
|
96
115
|
(t) => {
|
|
97
|
-
const
|
|
98
|
-
|
|
99
|
-
o.find((_) => i(_) === s) || null
|
|
100
|
-
), m(s), N(!1);
|
|
116
|
+
const o = v && t === n ? "" : t, Q = r.find((W) => a(W) === o) || null;
|
|
117
|
+
y(Q), p(o), N(!1);
|
|
101
118
|
},
|
|
102
|
-
[
|
|
103
|
-
),
|
|
119
|
+
[n, p, v, r, a]
|
|
120
|
+
), K = D(
|
|
104
121
|
(t) => {
|
|
105
|
-
t.stopPropagation(), t.preventDefault(),
|
|
122
|
+
t.stopPropagation(), t.preventDefault(), y(null), p(""), N(!1);
|
|
106
123
|
},
|
|
107
|
-
[
|
|
108
|
-
),
|
|
109
|
-
return /* @__PURE__ */
|
|
110
|
-
|
|
111
|
-
/* @__PURE__ */
|
|
112
|
-
/* @__PURE__ */ e(
|
|
113
|
-
|
|
124
|
+
[p]
|
|
125
|
+
), T = Y.useId();
|
|
126
|
+
return /* @__PURE__ */ s("div", { className: "space-y-1.5", children: [
|
|
127
|
+
l && /* @__PURE__ */ e(ee, { htmlFor: T, className: B, children: l }),
|
|
128
|
+
/* @__PURE__ */ s(re, { open: u, onOpenChange: N, children: [
|
|
129
|
+
/* @__PURE__ */ e(ae, { asChild: !0, children: /* @__PURE__ */ e(
|
|
130
|
+
V,
|
|
114
131
|
{
|
|
115
|
-
id:
|
|
132
|
+
id: T,
|
|
116
133
|
variant: "ghost",
|
|
117
134
|
role: "combobox",
|
|
118
|
-
"aria-expanded":
|
|
119
|
-
className:
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
135
|
+
"aria-expanded": u,
|
|
136
|
+
className: k(
|
|
137
|
+
fe({ size: q }),
|
|
138
|
+
z && "cursor-not-allowed opacity-50",
|
|
139
|
+
U,
|
|
123
140
|
"font-normal"
|
|
124
141
|
),
|
|
125
|
-
style: { width:
|
|
126
|
-
disabled:
|
|
127
|
-
children: /* @__PURE__ */
|
|
128
|
-
|
|
129
|
-
/* @__PURE__ */
|
|
130
|
-
v &&
|
|
142
|
+
style: { width: E },
|
|
143
|
+
disabled: z,
|
|
144
|
+
children: /* @__PURE__ */ s("div", { className: "flex flex-1 items-center justify-between overflow-hidden", children: [
|
|
145
|
+
S ? /* @__PURE__ */ e("div", { className: "truncate", children: w(S) }) : /* @__PURE__ */ e("span", { className: "text-d-muted-foreground hover:text-d-foreground", children: G }),
|
|
146
|
+
/* @__PURE__ */ s("div", { className: "flex items-center gap-1", children: [
|
|
147
|
+
v && S && /* @__PURE__ */ e(
|
|
131
148
|
"div",
|
|
132
149
|
{
|
|
133
150
|
className: "bg-d-secondary/20 hover:bg-d-secondary/30 z-20 flex cursor-pointer items-center justify-center rounded-full border p-1",
|
|
134
|
-
onClick:
|
|
151
|
+
onClick: K,
|
|
135
152
|
onMouseDown: (t) => t.preventDefault(),
|
|
136
153
|
"aria-label": "Clear selection",
|
|
137
|
-
children: /* @__PURE__ */ e(
|
|
154
|
+
children: /* @__PURE__ */ e(ie, { size: 8, className: "text-d-foreground" })
|
|
138
155
|
}
|
|
139
156
|
),
|
|
140
|
-
/* @__PURE__ */ e(
|
|
157
|
+
/* @__PURE__ */ e(le, { className: "opacity-50", size: 10 })
|
|
141
158
|
] })
|
|
142
159
|
] })
|
|
143
160
|
}
|
|
144
161
|
) }),
|
|
145
162
|
/* @__PURE__ */ e(
|
|
146
|
-
|
|
163
|
+
ce,
|
|
147
164
|
{
|
|
148
|
-
style: { width:
|
|
149
|
-
className:
|
|
150
|
-
children: /* @__PURE__ */
|
|
151
|
-
/* @__PURE__ */
|
|
165
|
+
style: { width: E },
|
|
166
|
+
className: k("p-0", M),
|
|
167
|
+
children: /* @__PURE__ */ s(te, { shouldFilter: !1, children: [
|
|
168
|
+
/* @__PURE__ */ s("div", { className: "relative w-full border-b", children: [
|
|
152
169
|
/* @__PURE__ */ e(
|
|
153
|
-
|
|
170
|
+
oe,
|
|
154
171
|
{
|
|
155
|
-
placeholder: `Search ${typeof
|
|
156
|
-
value:
|
|
172
|
+
placeholder: `Search ${typeof l == "string" ? l.toLowerCase() : "options"}...`,
|
|
173
|
+
value: I,
|
|
157
174
|
onValueChange: (t) => {
|
|
158
|
-
|
|
175
|
+
H(t);
|
|
159
176
|
}
|
|
160
177
|
}
|
|
161
178
|
),
|
|
162
|
-
|
|
179
|
+
C && r.length > 0 && /* @__PURE__ */ e("div", { className: "absolute top-1/2 right-2 flex -translate-y-1/2 transform items-center", children: /* @__PURE__ */ e(de, { className: "h-4 w-4 animate-spin" }) })
|
|
163
180
|
] }),
|
|
164
|
-
/* @__PURE__ */
|
|
181
|
+
/* @__PURE__ */ s(se, { children: [
|
|
165
182
|
b && /* @__PURE__ */ e("div", { className: "text-d-destructive p-3 text-center", children: b }),
|
|
166
|
-
|
|
167
|
-
!
|
|
168
|
-
/* @__PURE__ */ e(
|
|
169
|
-
|
|
183
|
+
C && r.length === 0 && ($ || /* @__PURE__ */ e(pe, {})),
|
|
184
|
+
!C && !b && r.length === 0 && (R || /* @__PURE__ */ e(ne, { children: X ?? `No ${typeof l == "string" ? l.toLowerCase() : "options"} found.` })),
|
|
185
|
+
/* @__PURE__ */ e(O, { children: r.map((t) => /* @__PURE__ */ s(
|
|
186
|
+
A,
|
|
170
187
|
{
|
|
171
|
-
value:
|
|
172
|
-
onSelect:
|
|
188
|
+
value: a(t),
|
|
189
|
+
onSelect: J,
|
|
173
190
|
children: [
|
|
174
|
-
|
|
191
|
+
F(t),
|
|
175
192
|
/* @__PURE__ */ e(
|
|
176
|
-
|
|
193
|
+
me,
|
|
177
194
|
{
|
|
178
|
-
className:
|
|
195
|
+
className: k(
|
|
179
196
|
"ml-auto h-3 w-3",
|
|
180
|
-
|
|
197
|
+
n === a(t) ? "opacity-100" : "opacity-0"
|
|
181
198
|
)
|
|
182
199
|
}
|
|
183
200
|
)
|
|
184
201
|
]
|
|
185
202
|
},
|
|
186
|
-
|
|
203
|
+
a(t)
|
|
187
204
|
)) })
|
|
188
205
|
] })
|
|
189
206
|
] })
|
|
@@ -192,15 +209,15 @@ function Ee({
|
|
|
192
209
|
] })
|
|
193
210
|
] });
|
|
194
211
|
}
|
|
195
|
-
function
|
|
196
|
-
return /* @__PURE__ */ e(
|
|
212
|
+
function pe() {
|
|
213
|
+
return /* @__PURE__ */ e(O, { children: [1, 2, 3].map((i) => /* @__PURE__ */ e(A, { disabled: !0, children: /* @__PURE__ */ s("div", { className: "flex w-full items-center gap-2", children: [
|
|
197
214
|
/* @__PURE__ */ e("div", { className: "bg-d-secondary h-6 w-6 animate-pulse rounded-full" }),
|
|
198
|
-
/* @__PURE__ */
|
|
215
|
+
/* @__PURE__ */ s("div", { className: "flex flex-1 flex-col gap-1", children: [
|
|
199
216
|
/* @__PURE__ */ e("div", { className: "bg-d-secondary h-4 w-24 animate-pulse rounded" }),
|
|
200
217
|
/* @__PURE__ */ e("div", { className: "bg-d-secondary h-3 w-16 animate-pulse rounded" })
|
|
201
218
|
] })
|
|
202
|
-
] }) },
|
|
219
|
+
] }) }, i)) });
|
|
203
220
|
}
|
|
204
221
|
export {
|
|
205
|
-
|
|
222
|
+
ke as AsyncSelect
|
|
206
223
|
};
|
|
@@ -1,68 +1,67 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as t, jsxs as
|
|
3
|
-
import { useReactTable as
|
|
4
|
-
import
|
|
5
|
-
import { Checkbox as
|
|
6
|
-
import { cn as
|
|
7
|
-
import { Input as
|
|
8
|
-
import { ScrollArea as
|
|
9
|
-
import { AppMultipleSelectDropdown as
|
|
10
|
-
import { Table as
|
|
2
|
+
import { jsx as t, jsxs as w } from "react/jsx-runtime";
|
|
3
|
+
import { useReactTable as K, flexRender as k } from "../../node_modules/@tanstack/react-table/build/lib/index.js";
|
|
4
|
+
import q, { useState as b, useEffect as J } from "react";
|
|
5
|
+
import { Checkbox as D } from "./checkbox.js";
|
|
6
|
+
import { cn as Q } from "../../lib/utils.js";
|
|
7
|
+
import { Input as U } from "./input.js";
|
|
8
|
+
import { ScrollArea as A, ScrollBar as C } from "./scroll-area.js";
|
|
9
|
+
import { AppMultipleSelectDropdown as X } from "./app-multiple-select-dropdown.js";
|
|
10
|
+
import { Table as Y, TableHeader as Z, TableRow as x, TableHead as B, TableBody as ee, TableCell as p } from "./table.js";
|
|
11
11
|
import { Skeleton as le } from "./skeleton.js";
|
|
12
|
-
import {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
switch (f) {
|
|
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
|
+
function ce(s, r, n, d) {
|
|
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
|
+
if (Array.isArray(i))
|
|
16
|
+
return m === "AND" ? n.every((o) => i.includes(o)) : n.some((o) => i.includes(o));
|
|
17
|
+
switch (m) {
|
|
19
18
|
case "AND":
|
|
20
|
-
return
|
|
19
|
+
return n.every((o) => String(i) === o);
|
|
21
20
|
case "OR":
|
|
22
21
|
default:
|
|
23
|
-
return
|
|
22
|
+
return n.some((o) => String(i) === o);
|
|
24
23
|
}
|
|
25
24
|
}
|
|
26
|
-
function
|
|
27
|
-
return
|
|
28
|
-
(
|
|
29
|
-
const
|
|
30
|
-
switch (
|
|
25
|
+
function ie(s) {
|
|
26
|
+
return s.reduce(
|
|
27
|
+
(r, n) => (n.filterFn && (r[n.column] = (d, i, u) => {
|
|
28
|
+
const m = d.getValue(i);
|
|
29
|
+
switch (n.innerFiltersMode ?? "OR") {
|
|
31
30
|
case "AND":
|
|
32
|
-
return
|
|
33
|
-
(
|
|
31
|
+
return u.every(
|
|
32
|
+
(g) => n.filterFn(m, [g])
|
|
34
33
|
);
|
|
35
34
|
case "OR":
|
|
36
35
|
default:
|
|
37
|
-
return
|
|
38
|
-
(
|
|
36
|
+
return u.some(
|
|
37
|
+
(g) => n.filterFn(m, [g])
|
|
39
38
|
);
|
|
40
39
|
}
|
|
41
|
-
}),
|
|
40
|
+
}), r),
|
|
42
41
|
{}
|
|
43
42
|
) || {};
|
|
44
43
|
}
|
|
45
|
-
function
|
|
46
|
-
columns:
|
|
47
|
-
data:
|
|
48
|
-
loading:
|
|
49
|
-
emptyComponent:
|
|
50
|
-
className:
|
|
51
|
-
rowSelection:
|
|
52
|
-
onRowSelectionChange:
|
|
44
|
+
function xe({
|
|
45
|
+
columns: s,
|
|
46
|
+
data: r,
|
|
47
|
+
loading: n = !1,
|
|
48
|
+
emptyComponent: d,
|
|
49
|
+
className: i,
|
|
50
|
+
rowSelection: u = {},
|
|
51
|
+
onRowSelectionChange: m,
|
|
53
52
|
checkable: o = !1,
|
|
54
|
-
onCheckedRowsChange:
|
|
53
|
+
onCheckedRowsChange: g,
|
|
55
54
|
notFoundMessage: V = "Nessun risultato trovato.",
|
|
56
|
-
searchBar:
|
|
57
|
-
dropdownFilters:
|
|
55
|
+
searchBar: f = void 0,
|
|
56
|
+
dropdownFilters: a = void 0
|
|
58
57
|
// outerFiltersMode = EFiltersMode.AND,
|
|
59
58
|
}) {
|
|
60
|
-
var
|
|
61
|
-
const [
|
|
59
|
+
var v;
|
|
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 ? [
|
|
62
61
|
{
|
|
63
62
|
id: "select",
|
|
64
63
|
header: ({ table: e }) => /* @__PURE__ */ t("div", { className: "text-center", children: /* @__PURE__ */ t(
|
|
65
|
-
|
|
64
|
+
D,
|
|
66
65
|
{
|
|
67
66
|
checked: e.getIsAllPageRowsSelected(),
|
|
68
67
|
onCheckedChange: (l) => e.toggleAllPageRowsSelected(!!l),
|
|
@@ -70,7 +69,7 @@ function ze({
|
|
|
70
69
|
}
|
|
71
70
|
) }),
|
|
72
71
|
cell: ({ row: e }) => /* @__PURE__ */ t("div", { className: "text-center", children: /* @__PURE__ */ t(
|
|
73
|
-
|
|
72
|
+
D,
|
|
74
73
|
{
|
|
75
74
|
checked: e.getIsSelected(),
|
|
76
75
|
onCheckedChange: (l) => e.toggleSelected(!!l),
|
|
@@ -80,80 +79,80 @@ function ze({
|
|
|
80
79
|
enableSorting: !1,
|
|
81
80
|
enableHiding: !1
|
|
82
81
|
},
|
|
83
|
-
...
|
|
84
|
-
] :
|
|
85
|
-
const l =
|
|
86
|
-
(
|
|
82
|
+
...s
|
|
83
|
+
] : s, [s, o]).map((e) => {
|
|
84
|
+
const l = a == null ? void 0 : a.find(
|
|
85
|
+
(c) => c.column === (e == null ? void 0 : e.accessorKey)
|
|
87
86
|
);
|
|
88
87
|
return {
|
|
89
88
|
...e,
|
|
90
89
|
filterFn: l != null && l.filterFn ? l.column : "multiValue"
|
|
91
90
|
};
|
|
92
|
-
}),
|
|
93
|
-
data:
|
|
94
|
-
columns:
|
|
95
|
-
getCoreRowModel:
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
91
|
+
}), I = {
|
|
92
|
+
data: r,
|
|
93
|
+
columns: G,
|
|
94
|
+
getCoreRowModel: ae(),
|
|
95
|
+
getPaginationRowModel: ne(),
|
|
96
|
+
onSortingChange: z,
|
|
97
|
+
getSortedRowModel: oe(),
|
|
98
|
+
onColumnVisibilityChange: P,
|
|
99
99
|
onRowSelectionChange: _,
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
return String(s).toLowerCase().includes(a.toLowerCase());
|
|
100
|
+
getFilteredRowModel: te(),
|
|
101
|
+
globalFilterFn: (e, l, c) => c ? (f == null ? void 0 : f.columns.some((S) => {
|
|
102
|
+
const R = e.getValue(S);
|
|
103
|
+
return String(R).toLowerCase().includes(c.toLowerCase());
|
|
105
104
|
})) ?? !1 : !0,
|
|
106
105
|
filterFns: {
|
|
107
|
-
multiValue: (e, l,
|
|
108
|
-
...
|
|
106
|
+
multiValue: (e, l, c) => ce(e, l, c, a),
|
|
107
|
+
...ie(a ?? [])
|
|
109
108
|
},
|
|
110
109
|
state: {
|
|
111
|
-
sorting:
|
|
112
|
-
columnFilters:
|
|
113
|
-
columnVisibility:
|
|
114
|
-
rowSelection:
|
|
115
|
-
globalFilter:
|
|
110
|
+
sorting: T,
|
|
111
|
+
columnFilters: $,
|
|
112
|
+
columnVisibility: H,
|
|
113
|
+
rowSelection: N,
|
|
114
|
+
globalFilter: y
|
|
116
115
|
}
|
|
117
|
-
},
|
|
118
|
-
return
|
|
119
|
-
if (
|
|
120
|
-
const e =
|
|
121
|
-
|
|
116
|
+
}, h = K(I);
|
|
117
|
+
return J(() => {
|
|
118
|
+
if (g && o) {
|
|
119
|
+
const e = h.getFilteredSelectedRowModel().rows.map((l) => l.original);
|
|
120
|
+
g(e);
|
|
122
121
|
}
|
|
123
|
-
}, [
|
|
124
|
-
(
|
|
125
|
-
|
|
126
|
-
|
|
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
|
+
U,
|
|
127
126
|
{
|
|
128
127
|
iconLeft: "Search",
|
|
129
|
-
placeholder:
|
|
130
|
-
value:
|
|
128
|
+
placeholder: f.placeholder ?? "Cerca...",
|
|
129
|
+
value: y,
|
|
131
130
|
onChange: (e) => {
|
|
132
|
-
|
|
131
|
+
F(e.target.value || "");
|
|
133
132
|
},
|
|
134
133
|
className: "w-60"
|
|
135
134
|
}
|
|
136
135
|
),
|
|
137
|
-
/* @__PURE__ */ t("div", { className: "flex h-full max-w-full min-w-0 flex-1 items-center", children:
|
|
138
|
-
/* @__PURE__ */ t(
|
|
139
|
-
/* @__PURE__ */ t("div", { className: "flex w-full max-w-full min-w-0 items-center justify-start gap-2 sm:justify-end", children:
|
|
140
|
-
const [
|
|
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
|
+
const [c, S] = b([]);
|
|
141
140
|
return /* @__PURE__ */ t(
|
|
142
|
-
|
|
141
|
+
X,
|
|
143
142
|
{
|
|
144
143
|
className: "w-60",
|
|
145
144
|
options: e.items,
|
|
146
|
-
value:
|
|
145
|
+
value: c,
|
|
147
146
|
placeholder: e.placeholder,
|
|
148
147
|
label: e.label,
|
|
149
|
-
onChange: (
|
|
150
|
-
|
|
151
|
-
const
|
|
152
|
-
(
|
|
148
|
+
onChange: (R) => {
|
|
149
|
+
S(R), j((W) => {
|
|
150
|
+
const M = W.filter(
|
|
151
|
+
(E) => E.id !== e.column
|
|
153
152
|
);
|
|
154
|
-
return
|
|
155
|
-
...
|
|
156
|
-
{ id: e.column, value:
|
|
153
|
+
return R.length === 0 ? M : [
|
|
154
|
+
...M,
|
|
155
|
+
{ id: e.column, value: R }
|
|
157
156
|
];
|
|
158
157
|
});
|
|
159
158
|
}
|
|
@@ -163,37 +162,37 @@ function ze({
|
|
|
163
162
|
}) })
|
|
164
163
|
] }) })
|
|
165
164
|
] }),
|
|
166
|
-
/* @__PURE__ */
|
|
167
|
-
/* @__PURE__ */ t(
|
|
168
|
-
/* @__PURE__ */ t(
|
|
169
|
-
/* @__PURE__ */
|
|
170
|
-
/* @__PURE__ */ t(
|
|
171
|
-
|
|
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
|
+
B,
|
|
172
171
|
{
|
|
173
172
|
className: `bg-d-secondary sticky top-0 z-10 ${l.column.columnDef.sticky ? "left-0" : ""}`,
|
|
174
|
-
children: l.isPlaceholder ? null :
|
|
173
|
+
children: l.isPlaceholder ? null : k(
|
|
175
174
|
l.column.columnDef.header,
|
|
176
175
|
l.getContext()
|
|
177
176
|
)
|
|
178
177
|
},
|
|
179
178
|
l.id
|
|
180
179
|
)) }, e.id)) }),
|
|
181
|
-
/* @__PURE__ */ t(
|
|
182
|
-
|
|
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,
|
|
183
182
|
{
|
|
184
|
-
className: `w-full ${
|
|
183
|
+
className: `w-full ${c.column.columnDef.sticky ? "bg-d-background sticky left-0 z-10" : ""}`,
|
|
185
184
|
children: /* @__PURE__ */ t(le, { className: "h-6 w-full" })
|
|
186
185
|
},
|
|
187
|
-
`skeleton-cell-${l}-${
|
|
188
|
-
)) }, `skeleton-row-${l}`)) : (
|
|
189
|
-
|
|
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,
|
|
190
189
|
{
|
|
191
190
|
"data-state": e.getIsSelected() && "selected",
|
|
192
191
|
children: e.getVisibleCells().map((l) => /* @__PURE__ */ t(
|
|
193
|
-
|
|
192
|
+
p,
|
|
194
193
|
{
|
|
195
194
|
className: `${l.column.columnDef.sticky ? "bg-d-background sticky left-0 z-10" : ""}`,
|
|
196
|
-
children:
|
|
195
|
+
children: k(
|
|
197
196
|
l.column.columnDef.cell,
|
|
198
197
|
l.getContext()
|
|
199
198
|
)
|
|
@@ -202,72 +201,18 @@ function ze({
|
|
|
202
201
|
))
|
|
203
202
|
},
|
|
204
203
|
e.id
|
|
205
|
-
)) : /* @__PURE__ */ t(
|
|
206
|
-
|
|
204
|
+
)) : /* @__PURE__ */ t(x, { children: /* @__PURE__ */ t(
|
|
205
|
+
p,
|
|
207
206
|
{
|
|
208
|
-
colSpan:
|
|
207
|
+
colSpan: s.length,
|
|
209
208
|
className: "pt-4 text-center",
|
|
210
|
-
children:
|
|
209
|
+
children: d || V
|
|
211
210
|
}
|
|
212
211
|
) }) })
|
|
213
212
|
] })
|
|
214
|
-
] })
|
|
215
|
-
/* @__PURE__ */ t(ne, { children: /* @__PURE__ */ C(oe, { children: [
|
|
216
|
-
/* @__PURE__ */ t(p, { children: /* @__PURE__ */ t(
|
|
217
|
-
ae,
|
|
218
|
-
{
|
|
219
|
-
size: "sm",
|
|
220
|
-
onClick: () => n.setPageIndex(0),
|
|
221
|
-
"aria-label": "Go to first page",
|
|
222
|
-
children: "«"
|
|
223
|
-
}
|
|
224
|
-
) }),
|
|
225
|
-
/* @__PURE__ */ t(p, { children: /* @__PURE__ */ t(
|
|
226
|
-
ie,
|
|
227
|
-
{
|
|
228
|
-
size: "sm",
|
|
229
|
-
onClick: () => {
|
|
230
|
-
n.getCanPreviousPage() && n.previousPage();
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
) }),
|
|
234
|
-
(() => {
|
|
235
|
-
const e = n.getState().pagination.pageIndex, l = n.getPageCount(), a = 5;
|
|
236
|
-
let m = Math.max(
|
|
237
|
-
0,
|
|
238
|
-
e - Math.floor(a / 2)
|
|
239
|
-
), s = m + a;
|
|
240
|
-
return s > l && (s = l, m = Math.max(0, s - a)), n.getPageOptions().slice(m, s).map((P, R) => /* @__PURE__ */ t(p, { children: /* @__PURE__ */ t(
|
|
241
|
-
ce,
|
|
242
|
-
{
|
|
243
|
-
size: "icon",
|
|
244
|
-
isActive: e === P,
|
|
245
|
-
onClick: () => n.setPageIndex(P),
|
|
246
|
-
children: P + 1
|
|
247
|
-
}
|
|
248
|
-
) }, R));
|
|
249
|
-
})(),
|
|
250
|
-
/* @__PURE__ */ t(p, { children: /* @__PURE__ */ t(
|
|
251
|
-
se,
|
|
252
|
-
{
|
|
253
|
-
size: "sm",
|
|
254
|
-
onClick: () => {
|
|
255
|
-
n.getCanNextPage() && n.nextPage();
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
) }),
|
|
259
|
-
/* @__PURE__ */ t(p, { children: /* @__PURE__ */ t(
|
|
260
|
-
re,
|
|
261
|
-
{
|
|
262
|
-
size: "sm",
|
|
263
|
-
onClick: () => n.setPageIndex(n.getPageCount() - 1),
|
|
264
|
-
"aria-label": "Go to last page",
|
|
265
|
-
children: "»"
|
|
266
|
-
}
|
|
267
|
-
) })
|
|
268
|
-
] }) })
|
|
213
|
+
] })
|
|
269
214
|
] });
|
|
270
215
|
}
|
|
271
216
|
export {
|
|
272
|
-
|
|
217
|
+
xe as DataTable
|
|
273
218
|
};
|
|
@@ -1,25 +1,23 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as i, jsxs as
|
|
3
|
-
import { cn as
|
|
2
|
+
import { jsx as i, jsxs as e } from "react/jsx-runtime";
|
|
3
|
+
import { cn as t } from "../../lib/utils.js";
|
|
4
4
|
import { buttonVariants as l } from "./button.js";
|
|
5
5
|
import c from "../../node_modules/lucide-react/dist/esm/icons/ellipsis.js";
|
|
6
6
|
import p from "../../node_modules/lucide-react/dist/esm/icons/chevron-right.js";
|
|
7
7
|
import m from "../../node_modules/lucide-react/dist/esm/icons/chevron-left.js";
|
|
8
|
-
|
|
9
|
-
import d from "../../node_modules/lucide-react/dist/esm/icons/chevron-last.js";
|
|
10
|
-
function k({ className: a, ...n }) {
|
|
8
|
+
function N({ className: a, ...n }) {
|
|
11
9
|
return /* @__PURE__ */ i(
|
|
12
10
|
"nav",
|
|
13
11
|
{
|
|
14
12
|
role: "navigation",
|
|
15
13
|
"aria-label": "pagination",
|
|
16
14
|
"data-slot": "pagination",
|
|
17
|
-
className:
|
|
15
|
+
className: t("mx-auto flex w-full justify-center", a),
|
|
18
16
|
...n
|
|
19
17
|
}
|
|
20
18
|
);
|
|
21
19
|
}
|
|
22
|
-
function
|
|
20
|
+
function P({
|
|
23
21
|
className: a,
|
|
24
22
|
...n
|
|
25
23
|
}) {
|
|
@@ -27,19 +25,19 @@ function z({
|
|
|
27
25
|
"ul",
|
|
28
26
|
{
|
|
29
27
|
"data-slot": "pagination-content",
|
|
30
|
-
className:
|
|
28
|
+
className: t("flex flex-row items-center gap-1", a),
|
|
31
29
|
...n
|
|
32
30
|
}
|
|
33
31
|
);
|
|
34
32
|
}
|
|
35
|
-
function
|
|
33
|
+
function v({ ...a }) {
|
|
36
34
|
return /* @__PURE__ */ i("li", { "data-slot": "pagination-item", ...a });
|
|
37
35
|
}
|
|
38
36
|
function o({
|
|
39
37
|
className: a,
|
|
40
38
|
isActive: n,
|
|
41
|
-
size:
|
|
42
|
-
...
|
|
39
|
+
size: r = "icon",
|
|
40
|
+
...s
|
|
43
41
|
}) {
|
|
44
42
|
return /* @__PURE__ */ i(
|
|
45
43
|
"a",
|
|
@@ -47,45 +45,27 @@ function o({
|
|
|
47
45
|
"aria-current": n ? "page" : void 0,
|
|
48
46
|
"data-slot": "pagination-link",
|
|
49
47
|
"data-active": n,
|
|
50
|
-
className:
|
|
48
|
+
className: t(
|
|
51
49
|
l({
|
|
52
50
|
variant: n ? "outline" : "ghost",
|
|
53
|
-
size:
|
|
51
|
+
size: r
|
|
54
52
|
}),
|
|
55
53
|
a
|
|
56
54
|
),
|
|
57
|
-
...
|
|
55
|
+
...s
|
|
58
56
|
}
|
|
59
57
|
);
|
|
60
58
|
}
|
|
61
|
-
function
|
|
59
|
+
function b({
|
|
62
60
|
className: a,
|
|
63
61
|
...n
|
|
64
62
|
}) {
|
|
65
|
-
return /* @__PURE__ */
|
|
63
|
+
return /* @__PURE__ */ e(
|
|
66
64
|
o,
|
|
67
65
|
{
|
|
68
66
|
"aria-label": "Go to previous page",
|
|
69
67
|
size: "default",
|
|
70
|
-
className:
|
|
71
|
-
...n,
|
|
72
|
-
children: [
|
|
73
|
-
/* @__PURE__ */ i(u, {}),
|
|
74
|
-
/* @__PURE__ */ i("span", { className: "hidden sm:block", children: "First" })
|
|
75
|
-
]
|
|
76
|
-
}
|
|
77
|
-
);
|
|
78
|
-
}
|
|
79
|
-
function j({
|
|
80
|
-
className: a,
|
|
81
|
-
...n
|
|
82
|
-
}) {
|
|
83
|
-
return /* @__PURE__ */ t(
|
|
84
|
-
o,
|
|
85
|
-
{
|
|
86
|
-
"aria-label": "Go to previous page",
|
|
87
|
-
size: "default",
|
|
88
|
-
className: e("gap-1 px-2.5 sm:pl-2.5", a),
|
|
68
|
+
className: t("gap-1 px-2.5 sm:pl-2.5", a),
|
|
89
69
|
...n,
|
|
90
70
|
children: [
|
|
91
71
|
/* @__PURE__ */ i(m, {}),
|
|
@@ -94,16 +74,16 @@ function j({
|
|
|
94
74
|
}
|
|
95
75
|
);
|
|
96
76
|
}
|
|
97
|
-
function
|
|
77
|
+
function j({
|
|
98
78
|
className: a,
|
|
99
79
|
...n
|
|
100
80
|
}) {
|
|
101
|
-
return /* @__PURE__ */
|
|
81
|
+
return /* @__PURE__ */ e(
|
|
102
82
|
o,
|
|
103
83
|
{
|
|
104
84
|
"aria-label": "Go to next page",
|
|
105
85
|
size: "default",
|
|
106
|
-
className:
|
|
86
|
+
className: t("gap-1 px-2.5 sm:pr-2.5", a),
|
|
107
87
|
...n,
|
|
108
88
|
children: [
|
|
109
89
|
/* @__PURE__ */ i("span", { className: "hidden sm:block", children: "Next" }),
|
|
@@ -112,34 +92,16 @@ function G({
|
|
|
112
92
|
}
|
|
113
93
|
);
|
|
114
94
|
}
|
|
115
|
-
function
|
|
116
|
-
className: a,
|
|
117
|
-
...n
|
|
118
|
-
}) {
|
|
119
|
-
return /* @__PURE__ */ t(
|
|
120
|
-
o,
|
|
121
|
-
{
|
|
122
|
-
"aria-label": "Go to next page",
|
|
123
|
-
size: "default",
|
|
124
|
-
className: e("gap-1 px-2.5 sm:pr-2.5", a),
|
|
125
|
-
...n,
|
|
126
|
-
children: [
|
|
127
|
-
/* @__PURE__ */ i("span", { className: "hidden sm:block", children: "Last" }),
|
|
128
|
-
/* @__PURE__ */ i(d, {})
|
|
129
|
-
]
|
|
130
|
-
}
|
|
131
|
-
);
|
|
132
|
-
}
|
|
133
|
-
function F({
|
|
95
|
+
function k({
|
|
134
96
|
className: a,
|
|
135
97
|
...n
|
|
136
98
|
}) {
|
|
137
|
-
return /* @__PURE__ */
|
|
99
|
+
return /* @__PURE__ */ e(
|
|
138
100
|
"span",
|
|
139
101
|
{
|
|
140
102
|
"aria-hidden": !0,
|
|
141
103
|
"data-slot": "pagination-ellipsis",
|
|
142
|
-
className:
|
|
104
|
+
className: t("flex size-9 items-center justify-center", a),
|
|
143
105
|
...n,
|
|
144
106
|
children: [
|
|
145
107
|
/* @__PURE__ */ i(c, { className: "size-4" }),
|
|
@@ -149,13 +111,11 @@ function F({
|
|
|
149
111
|
);
|
|
150
112
|
}
|
|
151
113
|
export {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
C as PaginationItem,
|
|
157
|
-
y as PaginationLast,
|
|
114
|
+
N as Pagination,
|
|
115
|
+
P as PaginationContent,
|
|
116
|
+
k as PaginationEllipsis,
|
|
117
|
+
v as PaginationItem,
|
|
158
118
|
o as PaginationLink,
|
|
159
|
-
|
|
160
|
-
|
|
119
|
+
j as PaginationNext,
|
|
120
|
+
b as PaginationPrevious
|
|
161
121
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -167,43 +167,24 @@ declare type AspectRatioProps = React.ComponentProps<typeof AspectRatioPrimitive
|
|
|
167
167
|
export declare function AsyncSelect<T>({ fetcher, preload, filterFn, renderOption, getOptionValue, getDisplayValue, notFound, loadingSkeleton, label, labelClassName, placeholder, value, onChange, disabled, width, className, triggerClassName, noResultsMessage, clearable, size, }: AsyncSelectProps<T>): JSX.Element;
|
|
168
168
|
|
|
169
169
|
declare interface AsyncSelectProps<T> extends VariantProps<typeof asyncSelectTriggerVariants> {
|
|
170
|
-
/** Async function to fetch options */
|
|
171
170
|
fetcher: (query?: string) => Promise<T[]>;
|
|
172
|
-
/** Preload all data ahead of time */
|
|
173
171
|
preload?: boolean;
|
|
174
|
-
/** Function to filter options */
|
|
175
172
|
filterFn?: (option: T, query: string) => boolean;
|
|
176
|
-
/** Function to render each option */
|
|
177
173
|
renderOption: (option: T) => React_2.ReactNode;
|
|
178
|
-
/** Function to get the value from an option */
|
|
179
174
|
getOptionValue: (option: T) => string;
|
|
180
|
-
/** Function to get the display value for the selected option */
|
|
181
175
|
getDisplayValue: (option: T) => React_2.ReactNode;
|
|
182
|
-
/** Custom not found message */
|
|
183
176
|
notFound?: React_2.ReactNode;
|
|
184
|
-
/** Custom loading skeleton */
|
|
185
177
|
loadingSkeleton?: React_2.ReactNode;
|
|
186
|
-
/** Currently selected value */
|
|
187
178
|
value: string;
|
|
188
|
-
/** Callback when selection changes */
|
|
189
179
|
onChange: (value: string) => void;
|
|
190
|
-
/** Label for the select field */
|
|
191
180
|
label?: string | React_2.ReactNode;
|
|
192
|
-
/** Custom class name for the label */
|
|
193
181
|
labelClassName?: string;
|
|
194
|
-
/** Placeholder text when no selection */
|
|
195
182
|
placeholder?: string;
|
|
196
|
-
/** Disable the entire select */
|
|
197
183
|
disabled?: boolean;
|
|
198
|
-
/** Custom width for the popover */
|
|
199
184
|
width?: string | number;
|
|
200
|
-
/** Custom class names */
|
|
201
185
|
className?: string;
|
|
202
|
-
/** Custom trigger button class names */
|
|
203
186
|
triggerClassName?: string;
|
|
204
|
-
/** Custom no results message */
|
|
205
187
|
noResultsMessage?: string;
|
|
206
|
-
/** Allow clearing the selection */
|
|
207
188
|
clearable?: boolean;
|
|
208
189
|
}
|
|
209
190
|
|