laif-ds 0.1.96 → 0.1.98
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/_virtual/index2.js +2 -5
- package/dist/_virtual/index3.js +5 -2
- package/dist/_virtual/index6.js +2 -2
- package/dist/_virtual/index7.js +2 -2
- package/dist/components/ui/async-select.js +249 -167
- package/dist/components/ui/data-table.js +166 -154
- package/dist/index.d.ts +28 -2
- package/dist/node_modules/eventemitter3/index.js +1 -1
- package/dist/node_modules/eventemitter3/index2.js +1 -1
- package/dist/node_modules/recharts/es6/util/Events.js +1 -1
- package/dist/node_modules/style-to-object/cjs/index.js +1 -1
- package/dist/node_modules/use-sync-external-store/shim/index.js +1 -1
- package/package.json +1 -1
package/dist/_virtual/index2.js
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
|
|
3
|
-
import { __require as t } from "../node_modules/eventemitter3/index2.js";
|
|
4
|
-
var r = t();
|
|
5
|
-
const m = /* @__PURE__ */ e(r);
|
|
2
|
+
var e = { exports: {} };
|
|
6
3
|
export {
|
|
7
|
-
|
|
4
|
+
e as __module
|
|
8
5
|
};
|
package/dist/_virtual/index3.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
|
|
2
|
+
import { getDefaultExportFromCjs as e } from "./_commonjsHelpers.js";
|
|
3
|
+
import { __require as t } from "../node_modules/eventemitter3/index2.js";
|
|
4
|
+
var r = t();
|
|
5
|
+
const m = /* @__PURE__ */ e(r);
|
|
3
6
|
export {
|
|
4
|
-
|
|
7
|
+
m as default
|
|
5
8
|
};
|
package/dist/_virtual/index6.js
CHANGED
package/dist/_virtual/index7.js
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
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 { Label as
|
|
9
|
-
import { Popover as
|
|
10
|
-
import { Command as
|
|
11
|
-
import { Icon as
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
|
|
2
|
+
import { jsxs as d, jsx as e } from "react/jsx-runtime";
|
|
3
|
+
import * as A from "react";
|
|
4
|
+
import { useState as N, useEffect as j, useCallback as $ } from "react";
|
|
5
|
+
import { useDebounce as ae } from "../../hooks/use-debounce.js";
|
|
6
|
+
import { cva as ce } from "../../node_modules/class-variance-authority/dist/index.js";
|
|
7
|
+
import { cn as L } from "../../lib/utils.js";
|
|
8
|
+
import { Label as le } from "./label.js";
|
|
9
|
+
import { Popover as ie, PopoverTrigger as de, PopoverContent as fe } from "./popover.js";
|
|
10
|
+
import { Command as me, CommandInput as ue, CommandList as he, CommandEmpty as pe, CommandGroup as q, CommandItem as H } from "./command.js";
|
|
11
|
+
import { Icon as X } from "./icon.js";
|
|
12
|
+
import { Checkbox as ge } from "./checkbox.js";
|
|
13
|
+
import xe from "../../node_modules/lucide-react/dist/esm/icons/loader-circle.js";
|
|
14
|
+
import we from "../../node_modules/lucide-react/dist/esm/icons/check.js";
|
|
15
|
+
const ye = ce(
|
|
15
16
|
"flex items-center justify-between whitespace-nowrap rounded-md border border-d-input bg-d-input px-3 py-2 data-[placeholder]:text-muted-foreground focus:outline-none disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1 ",
|
|
16
17
|
{
|
|
17
18
|
variants: {
|
|
@@ -26,141 +27,157 @@ const ue = ne(
|
|
|
26
27
|
}
|
|
27
28
|
}
|
|
28
29
|
);
|
|
29
|
-
function
|
|
30
|
-
fetcher:
|
|
31
|
-
preload:
|
|
32
|
-
filterFn:
|
|
33
|
-
renderOption:
|
|
34
|
-
getOptionValue:
|
|
35
|
-
getDisplayValue:
|
|
36
|
-
notFound:
|
|
37
|
-
loadingSkeleton:
|
|
38
|
-
label:
|
|
39
|
-
labelClassName:
|
|
40
|
-
placeholder:
|
|
41
|
-
value:
|
|
42
|
-
onChange:
|
|
43
|
-
disabled:
|
|
44
|
-
width:
|
|
45
|
-
triggerClassName:
|
|
46
|
-
noResultsMessage:
|
|
47
|
-
clearable:
|
|
48
|
-
|
|
30
|
+
function De({
|
|
31
|
+
fetcher: a,
|
|
32
|
+
preload: c,
|
|
33
|
+
filterFn: f,
|
|
34
|
+
renderOption: k,
|
|
35
|
+
getOptionValue: m,
|
|
36
|
+
getDisplayValue: s,
|
|
37
|
+
notFound: u,
|
|
38
|
+
loadingSkeleton: M,
|
|
39
|
+
label: h,
|
|
40
|
+
labelClassName: p,
|
|
41
|
+
placeholder: _ = "Select...",
|
|
42
|
+
value: r,
|
|
43
|
+
onChange: i,
|
|
44
|
+
disabled: T = !1,
|
|
45
|
+
width: x = "200px",
|
|
46
|
+
triggerClassName: z,
|
|
47
|
+
noResultsMessage: D,
|
|
48
|
+
clearable: b = !0,
|
|
49
|
+
multiple: l = !1,
|
|
50
|
+
size: J
|
|
49
51
|
}) {
|
|
50
|
-
const [
|
|
52
|
+
const [g, O] = N(!1), C = x === "auto", P = A.useRef(null), E = A.useRef(null), Q = A.useRef(null), Y = A.useRef(null), [Z, v] = N({ loading: !1, error: null }), [K, V] = N(""), S = ae(K, c ? 0 : 300), [I, F] = N(/* @__PURE__ */ new Map()), [w, R] = N([]), [B, ee] = N(
|
|
51
53
|
void 0
|
|
52
|
-
),
|
|
53
|
-
|
|
54
|
+
), [G, ne] = N([]), W = A.useMemo(() => l || !r || w.length === 0 ? null : w.find((n) => m(n) === r) || null, [r, w, m, l]);
|
|
55
|
+
j(() => {
|
|
56
|
+
if (l && Array.isArray(r) && w.length > 0) {
|
|
57
|
+
const n = w.filter(
|
|
58
|
+
(t) => r.includes(m(t))
|
|
59
|
+
);
|
|
60
|
+
ne(n);
|
|
61
|
+
}
|
|
62
|
+
}, [r, w, m, l]), j(() => ((async () => {
|
|
54
63
|
try {
|
|
55
|
-
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
} catch (
|
|
59
|
-
|
|
64
|
+
v({ loading: !0, error: null });
|
|
65
|
+
const t = c ? "__preload__" : "", o = await a("");
|
|
66
|
+
F((y) => new Map(y).set(t, o)), R(o);
|
|
67
|
+
} catch (t) {
|
|
68
|
+
v({
|
|
60
69
|
loading: !1,
|
|
61
|
-
error:
|
|
70
|
+
error: t instanceof Error ? t.message : "Failed to fetch options"
|
|
62
71
|
});
|
|
63
72
|
} finally {
|
|
64
|
-
|
|
73
|
+
v((t) => ({ ...t, loading: !1 }));
|
|
65
74
|
}
|
|
66
75
|
})(), () => {
|
|
67
|
-
|
|
68
|
-
}), [
|
|
69
|
-
if (
|
|
70
|
-
if (
|
|
71
|
-
const
|
|
72
|
-
if (
|
|
73
|
-
const
|
|
74
|
-
(
|
|
76
|
+
R([]), F(/* @__PURE__ */ new Map());
|
|
77
|
+
}), [a, c]), j(() => {
|
|
78
|
+
if (g)
|
|
79
|
+
if (c) {
|
|
80
|
+
const n = I.get("__preload__") || [];
|
|
81
|
+
if (S) {
|
|
82
|
+
const t = n.filter(
|
|
83
|
+
(o) => f ? f(o, S) : String(s(o)).toLowerCase().includes(S.toLowerCase())
|
|
75
84
|
);
|
|
76
|
-
|
|
85
|
+
R(t);
|
|
77
86
|
} else
|
|
78
|
-
|
|
87
|
+
R(n);
|
|
79
88
|
} else {
|
|
80
|
-
const
|
|
81
|
-
if (
|
|
82
|
-
const
|
|
83
|
-
|
|
89
|
+
const n = S || "";
|
|
90
|
+
if (I.has(n)) {
|
|
91
|
+
const t = I.get(n);
|
|
92
|
+
R(t);
|
|
84
93
|
} else
|
|
85
94
|
(async () => {
|
|
86
95
|
try {
|
|
87
|
-
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
} catch (
|
|
91
|
-
|
|
96
|
+
v({ loading: !0, error: null });
|
|
97
|
+
const o = await a(S);
|
|
98
|
+
F((y) => new Map(y).set(n, o)), R(o);
|
|
99
|
+
} catch (o) {
|
|
100
|
+
v({
|
|
92
101
|
loading: !1,
|
|
93
|
-
error:
|
|
102
|
+
error: o instanceof Error ? o.message : "Failed to fetch options"
|
|
94
103
|
});
|
|
95
104
|
} finally {
|
|
96
|
-
|
|
105
|
+
v((o) => ({ ...o, loading: !1 }));
|
|
97
106
|
}
|
|
98
107
|
})();
|
|
99
108
|
}
|
|
100
109
|
}, [
|
|
101
|
-
a,
|
|
102
|
-
m,
|
|
103
110
|
g,
|
|
104
111
|
S,
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
a
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
112
|
+
c,
|
|
113
|
+
f,
|
|
114
|
+
I,
|
|
115
|
+
s,
|
|
116
|
+
a
|
|
117
|
+
]), j(() => {
|
|
118
|
+
g && P.current && P.current.focus();
|
|
119
|
+
}, [g]), j(() => {
|
|
120
|
+
if (g && E.current && C) {
|
|
121
|
+
const n = E.current.getBoundingClientRect();
|
|
122
|
+
ee(n.width);
|
|
114
123
|
}
|
|
115
|
-
}, [
|
|
116
|
-
const
|
|
117
|
-
(
|
|
118
|
-
|
|
124
|
+
}, [g, C]);
|
|
125
|
+
const re = $(
|
|
126
|
+
(n) => {
|
|
127
|
+
i?.(b && n === r ? "" : n), O(!1);
|
|
128
|
+
},
|
|
129
|
+
[r, i, b]
|
|
130
|
+
), te = $(
|
|
131
|
+
(n) => {
|
|
132
|
+
if (!l) return;
|
|
133
|
+
const t = r, o = t.includes(n);
|
|
134
|
+
let y;
|
|
135
|
+
o ? y = t.filter((oe) => oe !== n) : y = [...t, n], i?.(y);
|
|
119
136
|
},
|
|
120
|
-
[
|
|
121
|
-
),
|
|
122
|
-
(
|
|
123
|
-
|
|
137
|
+
[r, i, l]
|
|
138
|
+
), se = $(
|
|
139
|
+
(n) => {
|
|
140
|
+
n.stopPropagation(), n.preventDefault(), i?.(l ? [] : ""), O(!1);
|
|
124
141
|
},
|
|
125
|
-
[
|
|
126
|
-
),
|
|
127
|
-
return /* @__PURE__ */
|
|
142
|
+
[i]
|
|
143
|
+
), U = A.useId();
|
|
144
|
+
return /* @__PURE__ */ d(
|
|
128
145
|
"div",
|
|
129
146
|
{
|
|
130
|
-
className:
|
|
147
|
+
className: L("grid grid-cols-1 space-y-1.5", C && "w-full"),
|
|
131
148
|
children: [
|
|
132
|
-
|
|
133
|
-
/* @__PURE__ */
|
|
134
|
-
/* @__PURE__ */
|
|
149
|
+
h && /* @__PURE__ */ e(le, { htmlFor: U, className: L(p, "w-fit"), children: h }),
|
|
150
|
+
/* @__PURE__ */ e("div", { ref: Q, className: "relative", "data-slot": "async-select", children: /* @__PURE__ */ d(ie, { open: g, onOpenChange: O, children: [
|
|
151
|
+
/* @__PURE__ */ e(de, { asChild: !0, children: /* @__PURE__ */ e(
|
|
135
152
|
"button",
|
|
136
153
|
{
|
|
137
|
-
id:
|
|
138
|
-
ref:
|
|
154
|
+
id: U,
|
|
155
|
+
ref: E,
|
|
139
156
|
type: "button",
|
|
140
|
-
disabled:
|
|
141
|
-
className:
|
|
142
|
-
|
|
157
|
+
disabled: T,
|
|
158
|
+
className: L(
|
|
159
|
+
ye({ size: J }),
|
|
143
160
|
"!border-d-border/50 border !shadow-none",
|
|
144
|
-
|
|
145
|
-
|
|
161
|
+
T && "cursor-not-allowed opacity-50",
|
|
162
|
+
z,
|
|
146
163
|
"font-normal",
|
|
147
|
-
|
|
164
|
+
C && "w-full",
|
|
148
165
|
"focus-visible:ring-d-ring focus-visible:ring-1",
|
|
149
|
-
|
|
166
|
+
g && "ring-d-ring ring-1"
|
|
150
167
|
),
|
|
151
|
-
style:
|
|
152
|
-
children: /* @__PURE__ */
|
|
153
|
-
|
|
154
|
-
/* @__PURE__ */
|
|
155
|
-
|
|
168
|
+
style: C ? void 0 : { width: x },
|
|
169
|
+
children: /* @__PURE__ */ d("div", { className: "flex w-full flex-1 items-center justify-between overflow-hidden", children: [
|
|
170
|
+
l ? Array.isArray(r) && r.length > 0 ? /* @__PURE__ */ e("div", { className: "min-w-0 flex-1 truncate text-left", children: r.length === 1 ? G[0] && s(G[0]) : `${r.length} elementi selezionati` }) : /* @__PURE__ */ e("span", { className: "text-d-muted-foreground truncate text-left", children: _ }) : W ? /* @__PURE__ */ e("div", { className: "min-w-0 flex-1 truncate text-left", children: s(W) }) : /* @__PURE__ */ e("span", { className: "text-d-muted-foreground truncate text-left", children: _ }),
|
|
171
|
+
/* @__PURE__ */ d("div", { className: "flex flex-shrink-0 items-center justify-end gap-1", children: [
|
|
172
|
+
b && (l && Array.isArray(r) && r.length > 0 || !l && W) && /* @__PURE__ */ e(
|
|
156
173
|
"div",
|
|
157
174
|
{
|
|
158
175
|
className: "border-d-input bg-d-accent cursor-pointer rounded-full p-1",
|
|
159
|
-
onClick:
|
|
160
|
-
onMouseDown: (
|
|
176
|
+
onClick: se,
|
|
177
|
+
onMouseDown: (n) => n.preventDefault(),
|
|
161
178
|
"aria-label": "Clear selection",
|
|
162
|
-
children: /* @__PURE__ */
|
|
163
|
-
|
|
179
|
+
children: /* @__PURE__ */ e(
|
|
180
|
+
X,
|
|
164
181
|
{
|
|
165
182
|
name: "X",
|
|
166
183
|
size: "xs",
|
|
@@ -169,8 +186,8 @@ function _e({
|
|
|
169
186
|
)
|
|
170
187
|
}
|
|
171
188
|
),
|
|
172
|
-
/* @__PURE__ */
|
|
173
|
-
|
|
189
|
+
/* @__PURE__ */ e(
|
|
190
|
+
X,
|
|
174
191
|
{
|
|
175
192
|
name: "ChevronsUpDown",
|
|
176
193
|
size: "xs",
|
|
@@ -181,62 +198,38 @@ function _e({
|
|
|
181
198
|
] })
|
|
182
199
|
}
|
|
183
200
|
) }),
|
|
184
|
-
/* @__PURE__ */
|
|
185
|
-
|
|
201
|
+
/* @__PURE__ */ e(
|
|
202
|
+
fe,
|
|
186
203
|
{
|
|
187
|
-
className:
|
|
204
|
+
className: L("p-0"),
|
|
188
205
|
style: {
|
|
189
|
-
width:
|
|
206
|
+
width: C ? B ? `${B}px` : void 0 : typeof x == "number" ? `${x}px` : x
|
|
190
207
|
},
|
|
191
208
|
align: "start",
|
|
192
209
|
side: "bottom",
|
|
193
210
|
sideOffset: 4,
|
|
194
|
-
onWheel: (
|
|
211
|
+
onWheel: (n) => n.stopPropagation(),
|
|
195
212
|
avoidCollisions: !1,
|
|
196
|
-
children: /* @__PURE__ */
|
|
197
|
-
|
|
213
|
+
children: /* @__PURE__ */ e(
|
|
214
|
+
be,
|
|
198
215
|
{
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
!o.loading && !o.error && l.length === 0 && (B || /* @__PURE__ */ t(de, { children: q || "No results found." })),
|
|
217
|
-
!o.loading && !o.error && l.length > 0 && /* @__PURE__ */ t($, { children: l.map((e) => /* @__PURE__ */ t(
|
|
218
|
-
A,
|
|
219
|
-
{
|
|
220
|
-
value: x(e),
|
|
221
|
-
onSelect: V,
|
|
222
|
-
className: "cursor-pointer",
|
|
223
|
-
children: /* @__PURE__ */ s("div", { className: "flex w-full items-center justify-between overflow-hidden", children: [
|
|
224
|
-
/* @__PURE__ */ t("div", { className: "min-w-0 flex-1", children: M ? /* @__PURE__ */ t("div", { className: "truncate", children: M(e) }) : /* @__PURE__ */ t("span", { className: "truncate", children: N(e) }) }),
|
|
225
|
-
/* @__PURE__ */ t(
|
|
226
|
-
me,
|
|
227
|
-
{
|
|
228
|
-
className: v(
|
|
229
|
-
"ml-2 h-4 w-4 flex-shrink-0",
|
|
230
|
-
c === x(e) ? "opacity-100" : "opacity-0"
|
|
231
|
-
)
|
|
232
|
-
}
|
|
233
|
-
)
|
|
234
|
-
] })
|
|
235
|
-
},
|
|
236
|
-
x(e)
|
|
237
|
-
)) })
|
|
238
|
-
] })
|
|
239
|
-
]
|
|
216
|
+
inputRef: P,
|
|
217
|
+
commandListRef: Y,
|
|
218
|
+
placeholder: _,
|
|
219
|
+
searchTerm: K,
|
|
220
|
+
onSearchTermChange: V,
|
|
221
|
+
fetchState: Z,
|
|
222
|
+
options: w,
|
|
223
|
+
loadingSkeleton: M,
|
|
224
|
+
notFound: u,
|
|
225
|
+
noResultsMessage: D,
|
|
226
|
+
multiple: l,
|
|
227
|
+
value: r,
|
|
228
|
+
getOptionValue: m,
|
|
229
|
+
getDisplayValue: s,
|
|
230
|
+
renderOption: k,
|
|
231
|
+
onSelect: re,
|
|
232
|
+
onSelectMultiple: te
|
|
240
233
|
}
|
|
241
234
|
)
|
|
242
235
|
}
|
|
@@ -246,16 +239,105 @@ function _e({
|
|
|
246
239
|
}
|
|
247
240
|
);
|
|
248
241
|
}
|
|
249
|
-
function
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
242
|
+
function Ne({
|
|
243
|
+
option: a,
|
|
244
|
+
multiple: c,
|
|
245
|
+
value: f,
|
|
246
|
+
getOptionValue: k,
|
|
247
|
+
getDisplayValue: m,
|
|
248
|
+
renderOption: s,
|
|
249
|
+
onSelect: u,
|
|
250
|
+
onSelectMultiple: M
|
|
251
|
+
}) {
|
|
252
|
+
const h = k(a);
|
|
253
|
+
let p = !1;
|
|
254
|
+
return c ? p = Array.isArray(f) && f.includes(h) : p = f === h, /* @__PURE__ */ e(
|
|
255
|
+
H,
|
|
256
|
+
{
|
|
257
|
+
value: h,
|
|
258
|
+
onSelect: c ? M : u,
|
|
259
|
+
className: "cursor-pointer",
|
|
260
|
+
children: /* @__PURE__ */ d("div", { className: "flex w-full items-center justify-between overflow-hidden", children: [
|
|
261
|
+
/* @__PURE__ */ d("div", { className: "flex min-w-0 flex-1 items-center gap-2", children: [
|
|
262
|
+
c && /* @__PURE__ */ e(ge, { checked: p }),
|
|
263
|
+
s ? /* @__PURE__ */ e("div", { className: "truncate", children: s(a) }) : /* @__PURE__ */ e("span", { className: "truncate", children: m(a) })
|
|
264
|
+
] }),
|
|
265
|
+
/* @__PURE__ */ e(
|
|
266
|
+
we,
|
|
267
|
+
{
|
|
268
|
+
className: L(
|
|
269
|
+
"ml-2 h-4 w-4 flex-shrink-0",
|
|
270
|
+
p ? "opacity-100" : "opacity-0"
|
|
271
|
+
)
|
|
272
|
+
}
|
|
273
|
+
)
|
|
274
|
+
] })
|
|
275
|
+
},
|
|
276
|
+
h
|
|
277
|
+
);
|
|
278
|
+
}
|
|
279
|
+
function be({
|
|
280
|
+
inputRef: a,
|
|
281
|
+
commandListRef: c,
|
|
282
|
+
placeholder: f,
|
|
283
|
+
searchTerm: k,
|
|
284
|
+
onSearchTermChange: m,
|
|
285
|
+
fetchState: s,
|
|
286
|
+
options: u,
|
|
287
|
+
loadingSkeleton: M,
|
|
288
|
+
notFound: h,
|
|
289
|
+
noResultsMessage: p,
|
|
290
|
+
multiple: _,
|
|
291
|
+
value: r,
|
|
292
|
+
getOptionValue: i,
|
|
293
|
+
getDisplayValue: T,
|
|
294
|
+
renderOption: x,
|
|
295
|
+
onSelect: z,
|
|
296
|
+
onSelectMultiple: D
|
|
297
|
+
}) {
|
|
298
|
+
return /* @__PURE__ */ d(me, { shouldFilter: !1, className: "w-full border-none shadow-sm", children: [
|
|
299
|
+
/* @__PURE__ */ e(
|
|
300
|
+
ue,
|
|
301
|
+
{
|
|
302
|
+
ref: a,
|
|
303
|
+
placeholder: f,
|
|
304
|
+
className: "placeholder:text-d-muted-foreground",
|
|
305
|
+
value: k,
|
|
306
|
+
onValueChange: m
|
|
307
|
+
}
|
|
308
|
+
),
|
|
309
|
+
s.loading && u.length > 0 && /* @__PURE__ */ e("div", { className: "flex items-center justify-center p-2", children: /* @__PURE__ */ e(xe, { className: "h-4 w-4 animate-spin" }) }),
|
|
310
|
+
/* @__PURE__ */ d(he, { ref: c, children: [
|
|
311
|
+
s.error && /* @__PURE__ */ e("div", { className: "text-d-destructive p-3 text-center", children: s.error }),
|
|
312
|
+
s.loading && u.length === 0 && (M || /* @__PURE__ */ e(Ce, {})),
|
|
313
|
+
!s.loading && !s.error && u.length === 0 && (h || /* @__PURE__ */ e(pe, { children: p || "No results found." })),
|
|
314
|
+
!s.loading && !s.error && u.length > 0 && /* @__PURE__ */ e(q, { children: u.map((b) => /* @__PURE__ */ e(
|
|
315
|
+
Ne,
|
|
316
|
+
{
|
|
317
|
+
option: b,
|
|
318
|
+
multiple: _,
|
|
319
|
+
value: r,
|
|
320
|
+
getOptionValue: i,
|
|
321
|
+
getDisplayValue: T,
|
|
322
|
+
renderOption: x,
|
|
323
|
+
onSelect: z,
|
|
324
|
+
onSelectMultiple: D
|
|
325
|
+
},
|
|
326
|
+
i(b)
|
|
327
|
+
)) })
|
|
328
|
+
] })
|
|
329
|
+
] });
|
|
330
|
+
}
|
|
331
|
+
function Ce() {
|
|
332
|
+
return /* @__PURE__ */ e(q, { children: [1, 2, 3].map((a) => /* @__PURE__ */ e(H, { disabled: !0, children: /* @__PURE__ */ d("div", { className: "flex w-full items-center gap-2", children: [
|
|
333
|
+
/* @__PURE__ */ e("div", { className: "bg-d-secondary h-6 w-6 animate-pulse rounded-full" }),
|
|
334
|
+
/* @__PURE__ */ d("div", { className: "flex flex-1 flex-col gap-1", children: [
|
|
335
|
+
/* @__PURE__ */ e("div", { className: "bg-d-secondary h-4 w-24 animate-pulse rounded" }),
|
|
336
|
+
/* @__PURE__ */ e("div", { className: "bg-d-secondary h-3 w-16 animate-pulse rounded" })
|
|
255
337
|
] })
|
|
256
|
-
] }) },
|
|
338
|
+
] }) }, a)) });
|
|
257
339
|
}
|
|
258
340
|
export {
|
|
259
|
-
|
|
260
|
-
|
|
341
|
+
De as AsyncSelect,
|
|
342
|
+
ye as selectTriggerVariants
|
|
261
343
|
};
|
|
@@ -1,31 +1,31 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as n, jsxs as h } from "react/jsx-runtime";
|
|
3
|
-
import { useReactTable as ce, flexRender as
|
|
4
|
-
import { useRef as
|
|
5
|
-
import { cn as
|
|
6
|
-
import { createCustomFilterFns as
|
|
7
|
-
import { Pagination as pe, PaginationContent as xe, PaginationItem as
|
|
3
|
+
import { useReactTable as ce, flexRender as G } from "../../node_modules/@tanstack/react-table/build/lib/index.js";
|
|
4
|
+
import { useRef as v, useState as u, useMemo as se, useEffect as z } from "react";
|
|
5
|
+
import { cn as de } from "../../lib/utils.js";
|
|
6
|
+
import { createCustomFilterFns as re, ELogicalFilterOperator as ue, debounce as me, createMultiValueFilterFn as fe, updatePageSizeFromContainer as he } from "./data-table.service.js";
|
|
7
|
+
import { Pagination as pe, PaginationContent as xe, PaginationItem as w, PaginationFirst as be, PaginationPrevious as Ce, PaginationLink as we, PaginationNext as Pe, PaginationLast as Se } from "./pagination.js";
|
|
8
8
|
import { Checkbox as E } from "./checkbox.js";
|
|
9
9
|
import { Input as Ie } from "./input.js";
|
|
10
10
|
import { ScrollArea as W, ScrollBar as F } from "./scroll-area.js";
|
|
11
|
-
import { AppMultipleSelectDropdown as
|
|
12
|
-
import { Table as
|
|
11
|
+
import { AppMultipleSelectDropdown as ze } from "./app-multiple-select-dropdown.js";
|
|
12
|
+
import { Table as Re, TableHeader as Ne, TableRow as R, TableHead as Me, TableBody as ye, TableCell as H } from "./table.js";
|
|
13
13
|
import { Skeleton as ke } from "./skeleton.js";
|
|
14
14
|
import { getPaginationRowModel as Fe, getFilteredRowModel as He, getSortedRowModel as De, getCoreRowModel as Ve } from "../../node_modules/@tanstack/table-core/build/lib/index.js";
|
|
15
15
|
function Ue({
|
|
16
16
|
columns: P,
|
|
17
17
|
data: D,
|
|
18
|
-
loading:
|
|
19
|
-
emptyComponent:
|
|
18
|
+
loading: J = !1,
|
|
19
|
+
emptyComponent: _,
|
|
20
20
|
className: K,
|
|
21
21
|
rowSelection: q = {},
|
|
22
22
|
onRowSelectionChange: V,
|
|
23
23
|
checkable: S = !1,
|
|
24
|
-
onCheckedRowsChange:
|
|
24
|
+
onCheckedRowsChange: N,
|
|
25
25
|
notFoundMessage: Q = "Nessun risultato trovato.",
|
|
26
|
-
searchBar:
|
|
27
|
-
dropdownFilters:
|
|
28
|
-
totalItems:
|
|
26
|
+
searchBar: m = void 0,
|
|
27
|
+
dropdownFilters: r = void 0,
|
|
28
|
+
totalItems: M = void 0,
|
|
29
29
|
datatableSizes: p = {
|
|
30
30
|
rowHeight: 32.5,
|
|
31
31
|
// default table row height in pixels
|
|
@@ -35,13 +35,13 @@ function Ue({
|
|
|
35
35
|
// default container height in pixels
|
|
36
36
|
},
|
|
37
37
|
paginationPlaceholders: x = void 0,
|
|
38
|
-
serverOptions:
|
|
39
|
-
setServerOptions:
|
|
38
|
+
serverOptions: g = void 0,
|
|
39
|
+
setServerOptions: c = void 0
|
|
40
40
|
}) {
|
|
41
|
-
const y =
|
|
41
|
+
const y = v(null), A = v(void 0), [U, X] = u([]), [Y, Z] = u([]), [B, O] = u({}), [C, ee] = u(""), [b, k] = u({
|
|
42
42
|
pageIndex: 0,
|
|
43
43
|
pageSize: 10
|
|
44
|
-
}), [te, j] =
|
|
44
|
+
}), [te, j] = u(0), [ne, ie] = u({}), L = V ? q : ne, ae = V || ie, [I, le] = u({}), s = !!g, oe = se(() => S ? [
|
|
45
45
|
{
|
|
46
46
|
id: "select",
|
|
47
47
|
header: ({ table: e }) => /* @__PURE__ */ n(
|
|
@@ -65,8 +65,8 @@ function Ue({
|
|
|
65
65
|
},
|
|
66
66
|
...P
|
|
67
67
|
] : P, [P, S]).map((e) => {
|
|
68
|
-
const t =
|
|
69
|
-
(
|
|
68
|
+
const t = r?.find(
|
|
69
|
+
(i) => i.column === e?.accessorKey
|
|
70
70
|
);
|
|
71
71
|
return {
|
|
72
72
|
...e,
|
|
@@ -79,33 +79,37 @@ function Ue({
|
|
|
79
79
|
onSortingChange: X,
|
|
80
80
|
getSortedRowModel: De(),
|
|
81
81
|
onColumnVisibilityChange: O,
|
|
82
|
-
onRowSelectionChange:
|
|
82
|
+
onRowSelectionChange: ae,
|
|
83
83
|
getFilteredRowModel: He(),
|
|
84
|
-
globalFilterFn: (e, t,
|
|
85
|
-
const
|
|
86
|
-
return String(
|
|
84
|
+
globalFilterFn: (e, t, i) => s || !i ? !0 : m?.columns.some((o) => {
|
|
85
|
+
const l = e.getValue(o);
|
|
86
|
+
return String(l).toLowerCase().includes(i.toLowerCase());
|
|
87
87
|
}) ?? !1,
|
|
88
88
|
filterFns: {
|
|
89
|
-
multiValue: (e, t,
|
|
89
|
+
multiValue: (e, t, i) => fe(
|
|
90
90
|
e,
|
|
91
91
|
t,
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
92
|
+
i,
|
|
93
|
+
r,
|
|
94
|
+
g
|
|
95
95
|
),
|
|
96
|
-
...
|
|
96
|
+
...re(r ?? [], g)
|
|
97
97
|
},
|
|
98
98
|
onPaginationChange: (e) => {
|
|
99
|
-
|
|
99
|
+
s ? typeof e == "object" && c && c?.((t) => ({
|
|
100
100
|
...t,
|
|
101
|
-
pagination: {
|
|
101
|
+
pagination: g.disableAutoPageSize ? {
|
|
102
102
|
...t.pagination,
|
|
103
103
|
pageIndex: e.pageIndex
|
|
104
|
+
} : {
|
|
105
|
+
...t.pagination,
|
|
106
|
+
pageIndex: e.pageIndex,
|
|
107
|
+
pageSize: e.pageSize
|
|
104
108
|
}
|
|
105
109
|
})) : k(e);
|
|
106
110
|
},
|
|
107
111
|
getPaginationRowModel: Fe(),
|
|
108
|
-
manualPagination:
|
|
112
|
+
manualPagination: s,
|
|
109
113
|
pageCount: te,
|
|
110
114
|
state: {
|
|
111
115
|
sorting: U,
|
|
@@ -113,88 +117,96 @@ function Ue({
|
|
|
113
117
|
columnVisibility: B,
|
|
114
118
|
rowSelection: L,
|
|
115
119
|
globalFilter: C,
|
|
116
|
-
pagination:
|
|
120
|
+
pagination: g?.pagination ?? b
|
|
117
121
|
}
|
|
118
|
-
},
|
|
119
|
-
|
|
122
|
+
}, a = ce(ge);
|
|
123
|
+
z(() => {
|
|
120
124
|
let e;
|
|
121
|
-
if (
|
|
125
|
+
if (m && C && (e || (e = {}), e.searchbarFilters = {
|
|
122
126
|
value: C,
|
|
123
|
-
columns:
|
|
124
|
-
}),
|
|
125
|
-
const
|
|
126
|
-
for (const
|
|
127
|
-
const f = I[
|
|
128
|
-
f && f.length > 0 && (
|
|
129
|
-
column:
|
|
127
|
+
columns: m.columns
|
|
128
|
+
}), r && Object.keys(I).length > 0) {
|
|
129
|
+
const l = {};
|
|
130
|
+
for (const d of r) {
|
|
131
|
+
const f = I[d.column];
|
|
132
|
+
f && f.length > 0 && (l[d.column] = {
|
|
133
|
+
column: d.column,
|
|
130
134
|
value: f,
|
|
131
|
-
logic:
|
|
135
|
+
logic: d.innerFiltersMode || ue.OR
|
|
132
136
|
});
|
|
133
137
|
}
|
|
134
|
-
Object.keys(
|
|
138
|
+
Object.keys(l).length > 0 && (e || (e = {}), e.dropdownFilters = l);
|
|
135
139
|
}
|
|
136
|
-
const t =
|
|
137
|
-
JSON.stringify(t ?? {}) !== JSON.stringify(
|
|
138
|
-
...
|
|
140
|
+
const t = A.current, i = e;
|
|
141
|
+
JSON.stringify(t ?? {}) !== JSON.stringify(i ?? {}) && c && (A.current = i, c((l) => ({
|
|
142
|
+
...l,
|
|
139
143
|
pagination: {
|
|
140
144
|
pageIndex: 0,
|
|
141
|
-
pageSize:
|
|
145
|
+
pageSize: g?.pagination.pageSize ?? 10
|
|
142
146
|
},
|
|
143
|
-
filters:
|
|
147
|
+
filters: i
|
|
144
148
|
})));
|
|
145
149
|
}, [
|
|
146
|
-
|
|
150
|
+
r,
|
|
147
151
|
I,
|
|
148
|
-
|
|
152
|
+
m,
|
|
149
153
|
C,
|
|
150
|
-
|
|
151
|
-
|
|
154
|
+
g,
|
|
155
|
+
c
|
|
152
156
|
]);
|
|
153
|
-
const T =
|
|
154
|
-
return
|
|
155
|
-
if (
|
|
157
|
+
const T = a.getFilteredRowModel();
|
|
158
|
+
return z(() => {
|
|
159
|
+
if (s)
|
|
156
160
|
j(
|
|
157
161
|
Math.ceil(
|
|
158
|
-
(
|
|
162
|
+
(M ?? 0) / (g.pagination?.pageSize || b.pageSize || 10)
|
|
159
163
|
)
|
|
160
164
|
);
|
|
161
165
|
else {
|
|
162
166
|
const e = T.rows.length;
|
|
163
|
-
j(Math.ceil(e /
|
|
167
|
+
j(Math.ceil(e / b.pageSize));
|
|
164
168
|
}
|
|
165
169
|
}, [
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
170
|
+
s,
|
|
171
|
+
M,
|
|
172
|
+
g?.pagination.pageSize,
|
|
173
|
+
g?.pagination.pageIndex,
|
|
174
|
+
a,
|
|
171
175
|
T,
|
|
172
|
-
|
|
173
|
-
]),
|
|
174
|
-
const e =
|
|
176
|
+
b.pageSize
|
|
177
|
+
]), z(() => {
|
|
178
|
+
const e = me(() => {
|
|
175
179
|
const t = y.current;
|
|
176
180
|
t && he(t, {
|
|
177
181
|
rowHeight: p.rowHeight,
|
|
178
182
|
headerHeight: p.headerHeight,
|
|
179
183
|
containerHeight: p.containerHeight,
|
|
180
|
-
onPageChange:
|
|
181
|
-
|
|
182
|
-
...
|
|
183
|
-
pagination: {
|
|
184
|
-
...
|
|
185
|
-
pageIndex:
|
|
184
|
+
onPageChange: s ? (i, o) => {
|
|
185
|
+
c?.((l) => ({
|
|
186
|
+
...l,
|
|
187
|
+
pagination: g.disableAutoPageSize ? {
|
|
188
|
+
...l.pagination,
|
|
189
|
+
pageIndex: i
|
|
190
|
+
} : {
|
|
191
|
+
...l.pagination,
|
|
192
|
+
pageIndex: i,
|
|
193
|
+
pageSize: o
|
|
186
194
|
}
|
|
187
195
|
}));
|
|
188
|
-
} : (
|
|
189
|
-
k({ pageIndex:
|
|
196
|
+
} : (i, o) => {
|
|
197
|
+
k({ pageIndex: i, pageSize: o });
|
|
190
198
|
},
|
|
191
|
-
setPagination: (
|
|
192
|
-
const o = typeof
|
|
193
|
-
|
|
194
|
-
...
|
|
195
|
-
pagination: {
|
|
196
|
-
...
|
|
199
|
+
setPagination: (i) => {
|
|
200
|
+
const o = typeof i == "function" ? i({ pageIndex: 0, pageSize: 10 }) : i;
|
|
201
|
+
s ? c?.((l) => ({
|
|
202
|
+
...l,
|
|
203
|
+
pagination: g.disableAutoPageSize ? {
|
|
204
|
+
...l.pagination,
|
|
197
205
|
pageIndex: o.pageIndex
|
|
206
|
+
} : {
|
|
207
|
+
...l.pagination,
|
|
208
|
+
pageIndex: o.pageIndex,
|
|
209
|
+
pageSize: o.pageSize
|
|
198
210
|
}
|
|
199
211
|
})) : k({
|
|
200
212
|
pageIndex: o.pageIndex,
|
|
@@ -207,32 +219,32 @@ function Ue({
|
|
|
207
219
|
window.removeEventListener("resize", e);
|
|
208
220
|
};
|
|
209
221
|
}, [
|
|
210
|
-
|
|
222
|
+
s,
|
|
211
223
|
p.containerHeight,
|
|
212
224
|
p.headerHeight,
|
|
213
225
|
p.rowHeight,
|
|
214
226
|
y,
|
|
215
|
-
|
|
227
|
+
c
|
|
216
228
|
// should be stable, but include for clarity
|
|
217
|
-
]),
|
|
218
|
-
if (
|
|
219
|
-
const e =
|
|
220
|
-
|
|
229
|
+
]), z(() => {
|
|
230
|
+
if (N && S) {
|
|
231
|
+
const e = a.getFilteredSelectedRowModel().rows.map((t) => t.original);
|
|
232
|
+
N(e);
|
|
221
233
|
}
|
|
222
|
-
}, [
|
|
234
|
+
}, [a, N, S, L]), /* @__PURE__ */ h(
|
|
223
235
|
"div",
|
|
224
236
|
{
|
|
225
|
-
className:
|
|
237
|
+
className: de(
|
|
226
238
|
"flex h-full max-h-full min-h-0 w-full max-w-full flex-col gap-2",
|
|
227
239
|
K
|
|
228
240
|
),
|
|
229
241
|
children: [
|
|
230
|
-
(
|
|
231
|
-
|
|
242
|
+
(m || r?.length) && /* @__PURE__ */ h("div", { className: "flex flex-col items-start justify-between gap-2 sm:flex-row sm:items-end", children: [
|
|
243
|
+
m && /* @__PURE__ */ n(
|
|
232
244
|
Ie,
|
|
233
245
|
{
|
|
234
246
|
iconLeft: "Search",
|
|
235
|
-
placeholder:
|
|
247
|
+
placeholder: m.placeholder ?? "Cerca...",
|
|
236
248
|
value: C,
|
|
237
249
|
onChange: (e) => {
|
|
238
250
|
ee(e.target.value);
|
|
@@ -240,28 +252,28 @@ function Ue({
|
|
|
240
252
|
className: "w-60"
|
|
241
253
|
}
|
|
242
254
|
),
|
|
243
|
-
/* @__PURE__ */ n("div", { className: "flex h-full max-w-full min-w-0 flex-1 items-center", children:
|
|
255
|
+
/* @__PURE__ */ n("div", { className: "flex h-full max-w-full min-w-0 flex-1 items-center", children: r && r.length > 0 && /* @__PURE__ */ h(W, { className: "h-full w-full", children: [
|
|
244
256
|
/* @__PURE__ */ n(F, { orientation: "horizontal" }),
|
|
245
|
-
/* @__PURE__ */ n("div", { className: "flex w-full max-w-full min-w-0 items-center justify-start gap-2 p-0.5 sm:justify-end", children:
|
|
246
|
-
const
|
|
257
|
+
/* @__PURE__ */ n("div", { className: "flex w-full max-w-full min-w-0 items-center justify-start gap-2 p-0.5 sm:justify-end", children: r.map((e, t) => {
|
|
258
|
+
const i = I[e.column] ?? [];
|
|
247
259
|
return /* @__PURE__ */ n(
|
|
248
|
-
|
|
260
|
+
ze,
|
|
249
261
|
{
|
|
250
262
|
className: "w-60",
|
|
251
263
|
options: e.items,
|
|
252
|
-
value:
|
|
264
|
+
value: i,
|
|
253
265
|
placeholder: e.placeholder,
|
|
254
266
|
label: e.label,
|
|
255
267
|
onChange: (o) => {
|
|
256
|
-
|
|
257
|
-
...
|
|
268
|
+
le((l) => ({
|
|
269
|
+
...l,
|
|
258
270
|
[e.column]: o
|
|
259
|
-
})), Z((
|
|
260
|
-
const
|
|
271
|
+
})), Z((l) => {
|
|
272
|
+
const d = l.filter(
|
|
261
273
|
(f) => f.id !== e.column
|
|
262
274
|
);
|
|
263
|
-
return o.length === 0 ?
|
|
264
|
-
...
|
|
275
|
+
return o.length === 0 ? d : [
|
|
276
|
+
...d,
|
|
265
277
|
{ id: e.column, value: o }
|
|
266
278
|
];
|
|
267
279
|
});
|
|
@@ -280,34 +292,34 @@ function Ue({
|
|
|
280
292
|
children: /* @__PURE__ */ h(W, { className: "border-d-border h-full min-h-0 w-full rounded-md border", children: [
|
|
281
293
|
/* @__PURE__ */ n(F, { orientation: "horizontal" }),
|
|
282
294
|
/* @__PURE__ */ n(F, { orientation: "vertical" }),
|
|
283
|
-
/* @__PURE__ */ h(
|
|
284
|
-
/* @__PURE__ */ n(
|
|
285
|
-
|
|
295
|
+
/* @__PURE__ */ h(Re, { children: [
|
|
296
|
+
/* @__PURE__ */ n(Ne, { children: a.getHeaderGroups().map((e) => /* @__PURE__ */ n(R, { children: e.headers.map((t) => /* @__PURE__ */ n(
|
|
297
|
+
Me,
|
|
286
298
|
{
|
|
287
299
|
className: `bg-d-secondary sticky top-0 z-10 ${t.column.columnDef.sticky ? "left-0" : ""}`,
|
|
288
|
-
children: t.isPlaceholder ? null :
|
|
300
|
+
children: t.isPlaceholder ? null : G(
|
|
289
301
|
t.column.columnDef.header,
|
|
290
302
|
t.getContext()
|
|
291
303
|
)
|
|
292
304
|
},
|
|
293
305
|
t.id
|
|
294
306
|
)) }, e.id)) }),
|
|
295
|
-
/* @__PURE__ */ n(ye, { children:
|
|
307
|
+
/* @__PURE__ */ n(ye, { children: J ? Array.from({ length: D.length || 8 }).map((e, t) => /* @__PURE__ */ n(R, { children: a.getHeaderGroups()[0].headers.map((i, o) => /* @__PURE__ */ n(
|
|
296
308
|
H,
|
|
297
309
|
{
|
|
298
|
-
className: `w-full ${
|
|
310
|
+
className: `w-full ${i.column.columnDef.sticky ? "bg-d-background sticky left-0 z-10" : ""}`,
|
|
299
311
|
children: /* @__PURE__ */ n(ke, { className: "h-6 w-full" })
|
|
300
312
|
},
|
|
301
313
|
`skeleton-cell-${t}-${o}`
|
|
302
|
-
)) }, `skeleton-row-${t}`)) :
|
|
303
|
-
|
|
314
|
+
)) }, `skeleton-row-${t}`)) : a.getRowModel().rows?.length ? a.getRowModel().rows.map((e) => /* @__PURE__ */ n(
|
|
315
|
+
R,
|
|
304
316
|
{
|
|
305
317
|
"data-state": e.getIsSelected() && "selected",
|
|
306
318
|
children: e.getVisibleCells().map((t) => /* @__PURE__ */ n(
|
|
307
319
|
H,
|
|
308
320
|
{
|
|
309
321
|
className: `${t.column.columnDef.sticky ? "bg-d-background sticky left-0 z-10" : ""}`,
|
|
310
|
-
children:
|
|
322
|
+
children: G(
|
|
311
323
|
t.column.columnDef.cell,
|
|
312
324
|
t.getContext()
|
|
313
325
|
)
|
|
@@ -316,12 +328,12 @@ function Ue({
|
|
|
316
328
|
))
|
|
317
329
|
},
|
|
318
330
|
e.id
|
|
319
|
-
)) : /* @__PURE__ */ n(
|
|
331
|
+
)) : /* @__PURE__ */ n(R, { children: /* @__PURE__ */ n(
|
|
320
332
|
H,
|
|
321
333
|
{
|
|
322
334
|
colSpan: P.length,
|
|
323
335
|
className: "pt-4 text-center",
|
|
324
|
-
children:
|
|
336
|
+
children: _ || Q
|
|
325
337
|
}
|
|
326
338
|
) }) })
|
|
327
339
|
] })
|
|
@@ -330,115 +342,115 @@ function Ue({
|
|
|
330
342
|
),
|
|
331
343
|
/* @__PURE__ */ h(pe, { className: "h-9", children: [
|
|
332
344
|
/* @__PURE__ */ n("div", { className: "flex h-full flex-1 items-center align-middle", children: /* @__PURE__ */ n("div", { className: "text-d-foreground hidden text-sm md:flex", children: Math.min(
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
) + " / " + (
|
|
345
|
+
g?.pagination?.pageSize ?? b.pageSize,
|
|
346
|
+
a.getFilteredRowModel().rows.length ?? 9999
|
|
347
|
+
) + " / " + (g ? M ?? "missing totalItems" : a.getFilteredRowModel().rows.length) + " " + (x?.rows ?? "Righe") }) }),
|
|
336
348
|
/* @__PURE__ */ h(xe, { children: [
|
|
337
|
-
/* @__PURE__ */ n(
|
|
338
|
-
|
|
349
|
+
/* @__PURE__ */ n(w, { children: /* @__PURE__ */ n(
|
|
350
|
+
be,
|
|
339
351
|
{
|
|
340
352
|
size: "sm",
|
|
341
|
-
isDisabled: !
|
|
353
|
+
isDisabled: !a.getCanPreviousPage(),
|
|
342
354
|
label: x?.first,
|
|
343
355
|
onClick: () => {
|
|
344
|
-
|
|
356
|
+
s ? c?.((e) => ({
|
|
345
357
|
...e,
|
|
346
358
|
pagination: {
|
|
347
359
|
...e.pagination,
|
|
348
360
|
pageIndex: 0
|
|
349
361
|
}
|
|
350
|
-
})) :
|
|
362
|
+
})) : a.setPageIndex(0);
|
|
351
363
|
},
|
|
352
364
|
"aria-label": "Go to first page"
|
|
353
365
|
}
|
|
354
366
|
) }),
|
|
355
|
-
/* @__PURE__ */ n(
|
|
367
|
+
/* @__PURE__ */ n(w, { children: /* @__PURE__ */ n(
|
|
356
368
|
Ce,
|
|
357
369
|
{
|
|
358
370
|
size: "sm",
|
|
359
|
-
isDisabled: !
|
|
371
|
+
isDisabled: !a.getCanPreviousPage(),
|
|
360
372
|
label: x?.previous,
|
|
361
373
|
onClick: () => {
|
|
362
|
-
if (
|
|
363
|
-
if (
|
|
364
|
-
const e =
|
|
365
|
-
|
|
366
|
-
...
|
|
374
|
+
if (a.getCanPreviousPage())
|
|
375
|
+
if (s) {
|
|
376
|
+
const e = g?.pagination.pageIndex ?? b.pageIndex, t = Math.max(e - 1, 0);
|
|
377
|
+
c?.((i) => ({
|
|
378
|
+
...i,
|
|
367
379
|
pagination: {
|
|
368
|
-
...
|
|
380
|
+
...i.pagination,
|
|
369
381
|
pageIndex: t
|
|
370
382
|
}
|
|
371
383
|
}));
|
|
372
384
|
} else
|
|
373
|
-
|
|
385
|
+
a.previousPage();
|
|
374
386
|
}
|
|
375
387
|
}
|
|
376
388
|
) }),
|
|
377
389
|
(() => {
|
|
378
|
-
const e =
|
|
390
|
+
const e = a.getState().pagination.pageIndex, t = a.getPageCount(), i = 5;
|
|
379
391
|
let o = Math.max(
|
|
380
392
|
0,
|
|
381
|
-
e - Math.floor(
|
|
382
|
-
),
|
|
383
|
-
return
|
|
384
|
-
|
|
393
|
+
e - Math.floor(i / 2)
|
|
394
|
+
), l = o + i;
|
|
395
|
+
return l > t && (l = t, o = Math.max(0, l - i)), a.getPageOptions().slice(o, l).map((d, f) => /* @__PURE__ */ n(w, { children: /* @__PURE__ */ n(
|
|
396
|
+
we,
|
|
385
397
|
{
|
|
386
398
|
size: "icon",
|
|
387
|
-
isActive: e ===
|
|
399
|
+
isActive: e === d,
|
|
388
400
|
onClick: () => {
|
|
389
|
-
if (
|
|
390
|
-
if (e ===
|
|
391
|
-
|
|
392
|
-
|
|
401
|
+
if (s) {
|
|
402
|
+
if (e === d) return;
|
|
403
|
+
c?.(($) => ({
|
|
404
|
+
...$,
|
|
393
405
|
pagination: {
|
|
394
|
-
|
|
395
|
-
pageIndex:
|
|
406
|
+
...$.pagination,
|
|
407
|
+
pageIndex: d
|
|
396
408
|
}
|
|
397
409
|
}));
|
|
398
410
|
} else
|
|
399
|
-
|
|
411
|
+
a.setPageIndex(d);
|
|
400
412
|
},
|
|
401
|
-
children:
|
|
413
|
+
children: d + 1
|
|
402
414
|
}
|
|
403
415
|
) }, f));
|
|
404
416
|
})(),
|
|
405
|
-
/* @__PURE__ */ n(
|
|
417
|
+
/* @__PURE__ */ n(w, { children: /* @__PURE__ */ n(
|
|
406
418
|
Pe,
|
|
407
419
|
{
|
|
408
420
|
size: "sm",
|
|
409
|
-
isDisabled: !
|
|
421
|
+
isDisabled: !a.getCanNextPage(),
|
|
410
422
|
label: x?.next,
|
|
411
423
|
onClick: () => {
|
|
412
|
-
|
|
424
|
+
a.getCanNextPage() && (s ? c?.((e) => ({
|
|
413
425
|
...e,
|
|
414
426
|
pagination: {
|
|
415
427
|
...e.pagination,
|
|
416
428
|
pageIndex: e.pagination.pageIndex + 1
|
|
417
429
|
}
|
|
418
|
-
})) :
|
|
430
|
+
})) : a.nextPage());
|
|
419
431
|
}
|
|
420
432
|
}
|
|
421
433
|
) }),
|
|
422
|
-
/* @__PURE__ */ n(
|
|
434
|
+
/* @__PURE__ */ n(w, { children: /* @__PURE__ */ n(
|
|
423
435
|
Se,
|
|
424
436
|
{
|
|
425
437
|
size: "sm",
|
|
426
|
-
isDisabled: !
|
|
438
|
+
isDisabled: !a.getCanNextPage(),
|
|
427
439
|
label: x?.last,
|
|
428
440
|
onClick: () => {
|
|
429
|
-
|
|
441
|
+
s ? c?.((e) => ({
|
|
430
442
|
...e,
|
|
431
443
|
pagination: {
|
|
432
444
|
...e.pagination,
|
|
433
|
-
pageIndex:
|
|
445
|
+
pageIndex: a.getPageCount() - 1
|
|
434
446
|
}
|
|
435
|
-
})) :
|
|
447
|
+
})) : a.setPageIndex(a.getPageCount() - 1);
|
|
436
448
|
},
|
|
437
449
|
"aria-label": "Go to last page"
|
|
438
450
|
}
|
|
439
451
|
) })
|
|
440
452
|
] }),
|
|
441
|
-
/* @__PURE__ */ n("div", { className: "flex h-full flex-1 items-center justify-end align-middle", children: /* @__PURE__ */ n("div", { className: "text-d-foreground hidden text-sm md:flex", children: (
|
|
453
|
+
/* @__PURE__ */ n("div", { className: "flex h-full flex-1 items-center justify-end align-middle", children: /* @__PURE__ */ n("div", { className: "text-d-foreground hidden text-sm md:flex", children: (a.getPageCount() ? a.getState().pagination.pageIndex + 1 : 0) + " / " + a.getPageCount() + " " + (x?.pages ?? "Pagine") }) })
|
|
442
454
|
] })
|
|
443
455
|
]
|
|
444
456
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -189,9 +189,34 @@ export declare function AspectRatio({ ...props }: AspectRatioProps): JSX.Element
|
|
|
189
189
|
|
|
190
190
|
declare type AspectRatioProps = React.ComponentProps<typeof AspectRatioPrimitive.Root>;
|
|
191
191
|
|
|
192
|
-
export declare function AsyncSelect<T>({ fetcher, preload, filterFn, renderOption, getOptionValue, getDisplayValue, notFound, loadingSkeleton, label, labelClassName, placeholder, value, onChange, disabled, width, triggerClassName, noResultsMessage, clearable, size, }: AsyncSelectProps<T>): JSX.Element;
|
|
192
|
+
export declare function AsyncSelect<T>({ fetcher, preload, filterFn, renderOption, getOptionValue, getDisplayValue, notFound, loadingSkeleton, label, labelClassName, placeholder, value, onChange, disabled, width, triggerClassName, noResultsMessage, clearable, multiple, size, }: AsyncSelectProps<T>): JSX.Element;
|
|
193
193
|
|
|
194
|
-
declare interface
|
|
194
|
+
declare interface AsyncSelectMultipleProps<T> extends VariantProps<typeof selectTriggerVariants> {
|
|
195
|
+
multiple: true;
|
|
196
|
+
fetcher: (query?: string) => Promise<T[]>;
|
|
197
|
+
preload?: boolean;
|
|
198
|
+
filterFn?: (option: T, query: string) => boolean;
|
|
199
|
+
renderOption: (option: T) => React_2.ReactNode;
|
|
200
|
+
getOptionValue: (option: T) => string;
|
|
201
|
+
getDisplayValue: (option: T) => React_2.ReactNode;
|
|
202
|
+
notFound?: React_2.ReactNode;
|
|
203
|
+
loadingSkeleton?: React_2.ReactNode;
|
|
204
|
+
value?: string[];
|
|
205
|
+
onChange?: (value: string[]) => void;
|
|
206
|
+
label?: string | React_2.ReactNode;
|
|
207
|
+
labelClassName?: string;
|
|
208
|
+
placeholder?: string;
|
|
209
|
+
disabled?: boolean;
|
|
210
|
+
width?: string | number | "auto";
|
|
211
|
+
triggerClassName?: string;
|
|
212
|
+
noResultsMessage?: string;
|
|
213
|
+
clearable?: boolean;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
declare type AsyncSelectProps<T> = AsyncSelectSingleProps<T> | AsyncSelectMultipleProps<T>;
|
|
217
|
+
|
|
218
|
+
declare interface AsyncSelectSingleProps<T> extends VariantProps<typeof selectTriggerVariants> {
|
|
219
|
+
multiple?: false;
|
|
195
220
|
fetcher: (query?: string) => Promise<T[]>;
|
|
196
221
|
preload?: boolean;
|
|
197
222
|
filterFn?: (option: T, query: string) => boolean;
|
|
@@ -1059,6 +1084,7 @@ export declare interface IServerFilterProps {
|
|
|
1059
1084
|
export declare interface IServerOptionsProps {
|
|
1060
1085
|
pagination: IPaginationProps;
|
|
1061
1086
|
filters?: IServerFilterProps;
|
|
1087
|
+
disableAutoPageSize?: boolean;
|
|
1062
1088
|
}
|
|
1063
1089
|
|
|
1064
1090
|
export declare function Label({ className, ...props }: React_2.ComponentProps<typeof LabelPrimitive.Root>): JSX.Element;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { __module as e } from "../../../_virtual/
|
|
2
|
+
import { __module as e } from "../../../_virtual/index2.js";
|
|
3
3
|
import { __require as i } from "../cjs/use-sync-external-store-shim.production.js";
|
|
4
4
|
import { __require as o } from "../cjs/use-sync-external-store-shim.development.js";
|
|
5
5
|
var r;
|