laif-ds 0.2.52 → 0.2.54
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-select.js +102 -99
- package/dist/components/ui/app-tooltip.js +123 -0
- package/dist/components/ui/async-select.js +54 -53
- package/dist/components/ui/button.js +1 -1
- package/dist/components/ui/date-picker.js +96 -86
- package/dist/components/ui/file-preview.js +233 -286
- package/dist/components/ui/input.js +28 -29
- package/dist/index.d.ts +56 -1
- package/dist/index.js +41 -39
- package/dist/lib/design-tokens.js +3 -1
- package/dist/styles.v3.css +1 -1
- package/package.json +1 -1
|
@@ -1,101 +1,104 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsxs as s, jsx as l, Fragment as re } from "react/jsx-runtime";
|
|
3
3
|
import { Badge as ne } from "./badge.js";
|
|
4
|
-
import { Command as
|
|
5
|
-
import { Label as
|
|
6
|
-
import { designTokens as
|
|
7
|
-
import { cn as
|
|
8
|
-
import { useState as h, useRef as
|
|
9
|
-
import { Checkbox as
|
|
10
|
-
import { Icon as
|
|
11
|
-
import { Popover as
|
|
12
|
-
import
|
|
13
|
-
const
|
|
14
|
-
sm:
|
|
15
|
-
default:
|
|
16
|
-
lg:
|
|
4
|
+
import { Command as te, CommandInput as se, CommandList as ie, CommandEmpty as oe, CommandGroup as R, CommandItem as A } from "./command.js";
|
|
5
|
+
import { Label as de } from "./label.js";
|
|
6
|
+
import { designTokens as d } from "../../lib/design-tokens.js";
|
|
7
|
+
import { cn as y } from "../../lib/utils.js";
|
|
8
|
+
import { useState as h, useRef as ce, useMemo as S, useCallback as ue, useEffect as me } from "react";
|
|
9
|
+
import { Checkbox as fe } from "./checkbox.js";
|
|
10
|
+
import { Icon as z } from "./icon.js";
|
|
11
|
+
import { Popover as pe, PopoverTrigger as he, PopoverContent as ge } from "./popover.js";
|
|
12
|
+
import ve from "../../node_modules/lucide-react/dist/esm/icons/chevron-down.js";
|
|
13
|
+
const be = {
|
|
14
|
+
sm: d.sizes.sm,
|
|
15
|
+
default: d.sizes.default,
|
|
16
|
+
lg: d.sizes.lg
|
|
17
17
|
};
|
|
18
|
-
function
|
|
18
|
+
function ke(P) {
|
|
19
19
|
const {
|
|
20
|
-
multiple:
|
|
21
|
-
options:
|
|
22
|
-
value:
|
|
20
|
+
multiple: r = !1,
|
|
21
|
+
options: c,
|
|
22
|
+
value: B,
|
|
23
23
|
defaultValue: T,
|
|
24
|
-
onValueChange:
|
|
24
|
+
onValueChange: W,
|
|
25
25
|
onClear: g,
|
|
26
|
-
placeholder:
|
|
27
|
-
emptyPlaceholder:
|
|
28
|
-
searchPlaceholder:
|
|
29
|
-
addItemPlaceholder:
|
|
26
|
+
placeholder: X = "Seleziona...",
|
|
27
|
+
emptyPlaceholder: E = "Nessun risultato",
|
|
28
|
+
searchPlaceholder: F = "Cerca...",
|
|
29
|
+
addItemPlaceholder: L = "Aggiungi",
|
|
30
30
|
itemCountMessage: $ = (e) => `${e} elementi selezionati`,
|
|
31
31
|
maxSelectedMessage: G = (e) => `Puoi selezionare fino a ${e} elementi`,
|
|
32
|
-
label:
|
|
32
|
+
label: D,
|
|
33
33
|
className: q = "",
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
labelClassName: H = "",
|
|
35
|
+
wrpClassName: J = "",
|
|
36
|
+
searchable: O = !1,
|
|
37
|
+
creatable: K = !1,
|
|
37
38
|
groupBy: v = "group",
|
|
38
39
|
maxSelected: o,
|
|
39
|
-
showChipsInsteadOfCount:
|
|
40
|
+
showChipsInsteadOfCount: Q = !1,
|
|
40
41
|
disabled: b,
|
|
41
|
-
size:
|
|
42
|
-
isSingleSelectClearable:
|
|
43
|
-
} =
|
|
44
|
-
k ||
|
|
45
|
-
},
|
|
46
|
-
const e =
|
|
47
|
-
if (
|
|
48
|
-
const t =
|
|
42
|
+
size: U = "default",
|
|
43
|
+
isSingleSelectClearable: Y = !1
|
|
44
|
+
} = P, [x, C] = h(!1), [u, N] = h(""), w = ce(null), [V, Z] = h(0), k = P.hasOwnProperty("value"), [_, ee] = h(T), i = k ? B : _, m = (e) => {
|
|
45
|
+
k || ee(e), W?.(e);
|
|
46
|
+
}, n = S(() => r ? Array.isArray(i) ? i : [] : i != null ? [i] : [], [i, r]), f = S(() => {
|
|
47
|
+
const e = c.filter((t) => n.includes(t.value));
|
|
48
|
+
if (r) {
|
|
49
|
+
const t = n.filter((a) => !e.find((p) => p.value === a)).map((a) => ({ value: a, label: a }));
|
|
49
50
|
return [...e, ...t];
|
|
50
|
-
} else if (
|
|
51
|
-
return [{ value:
|
|
51
|
+
} else if (n.length && !e.length)
|
|
52
|
+
return [{ value: n[0], label: n[0] }];
|
|
52
53
|
return e;
|
|
53
|
-
}, [
|
|
54
|
+
}, [c, n, r]), I = (e) => {
|
|
54
55
|
if (!e.disabled)
|
|
55
|
-
if (
|
|
56
|
-
const t =
|
|
57
|
-
if (!t && o !== void 0 &&
|
|
56
|
+
if (r) {
|
|
57
|
+
const t = n.includes(e.value);
|
|
58
|
+
if (!t && o !== void 0 && n.length >= o)
|
|
58
59
|
return;
|
|
59
|
-
|
|
60
|
-
t ?
|
|
60
|
+
m(
|
|
61
|
+
t ? n.filter((a) => a !== e.value) : [...n, e.value]
|
|
61
62
|
);
|
|
62
63
|
} else
|
|
63
|
-
|
|
64
|
-
}, j =
|
|
65
|
-
|
|
66
|
-
}, [
|
|
64
|
+
m(e.value), C(!1);
|
|
65
|
+
}, j = ue(() => {
|
|
66
|
+
m(r ? [] : void 0), N(""), g && g();
|
|
67
|
+
}, [m, g, r]), le = S(() => v ? c.reduce(
|
|
67
68
|
(e, t) => {
|
|
68
|
-
const
|
|
69
|
-
return e[
|
|
69
|
+
const a = t[v] || "";
|
|
70
|
+
return e[a] = e[a] || [], e[a].push(t), e;
|
|
70
71
|
},
|
|
71
72
|
{}
|
|
72
|
-
) : { "":
|
|
73
|
-
return
|
|
74
|
-
w.current &&
|
|
75
|
-
}, [
|
|
76
|
-
|
|
73
|
+
) : { "": c }, [c, v]);
|
|
74
|
+
return me(() => {
|
|
75
|
+
w.current && Z(w.current.getBoundingClientRect().width);
|
|
76
|
+
}, [x, n, c]), /* @__PURE__ */ s("div", { className: y("flex flex-col gap-1.5", J), children: [
|
|
77
|
+
D && /* @__PURE__ */ l(de, { className: H, children: D }),
|
|
77
78
|
/* @__PURE__ */ s(
|
|
78
|
-
|
|
79
|
+
pe,
|
|
79
80
|
{
|
|
80
|
-
open: b ? !1 :
|
|
81
|
-
onOpenChange: (e) => !b &&
|
|
81
|
+
open: b ? !1 : x,
|
|
82
|
+
onOpenChange: (e) => !b && C(e),
|
|
82
83
|
modal: !0,
|
|
83
84
|
children: [
|
|
84
|
-
/* @__PURE__ */ l(
|
|
85
|
+
/* @__PURE__ */ l(he, { asChild: !0, children: /* @__PURE__ */ s(
|
|
85
86
|
"div",
|
|
86
87
|
{
|
|
87
88
|
ref: w,
|
|
88
|
-
className:
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
89
|
+
className: y(
|
|
90
|
+
d.input.base,
|
|
91
|
+
d.radius.default,
|
|
92
|
+
d.focusRingWithin,
|
|
93
|
+
"flex w-full min-w-[100px] cursor-pointer items-center justify-between gap-2",
|
|
94
|
+
x && d.activeRing,
|
|
95
|
+
be[U],
|
|
93
96
|
b && "cursor-not-allowed opacity-50",
|
|
94
97
|
q
|
|
95
98
|
),
|
|
96
99
|
children: [
|
|
97
|
-
|
|
98
|
-
/* @__PURE__ */ l("div", { className: "flex min-w-0 flex-nowrap gap-1 overflow-auto", children:
|
|
100
|
+
f.length === 0 ? /* @__PURE__ */ l("span", { className: "text-d-muted-foreground", children: X }) : r ? /* @__PURE__ */ s("div", { className: "flex h-full w-full min-w-0 items-center justify-between gap-2", children: [
|
|
101
|
+
/* @__PURE__ */ l("div", { className: "flex min-w-0 flex-nowrap gap-1 overflow-auto", children: Q ? /* @__PURE__ */ l(re, { children: f.map((e) => /* @__PURE__ */ s(
|
|
99
102
|
ne,
|
|
100
103
|
{
|
|
101
104
|
variant: "secondary",
|
|
@@ -105,12 +108,12 @@ function Ve(z) {
|
|
|
105
108
|
},
|
|
106
109
|
children: [
|
|
107
110
|
e.label,
|
|
108
|
-
!e.fixed && /* @__PURE__ */ l(
|
|
111
|
+
!e.fixed && /* @__PURE__ */ l(z, { name: "X", size: "xs" })
|
|
109
112
|
]
|
|
110
113
|
},
|
|
111
114
|
e.value
|
|
112
|
-
)) }) : /* @__PURE__ */ l("div", { children: $(
|
|
113
|
-
|
|
115
|
+
)) }) : /* @__PURE__ */ l("div", { children: $(f.length) }) }),
|
|
116
|
+
r && /* @__PURE__ */ l(
|
|
114
117
|
"div",
|
|
115
118
|
{
|
|
116
119
|
className: "border-d-input bg-d-accent cursor-pointer rounded-full p-1",
|
|
@@ -120,7 +123,7 @@ function Ve(z) {
|
|
|
120
123
|
onMouseDown: (e) => e.preventDefault(),
|
|
121
124
|
"aria-label": "Clear selection",
|
|
122
125
|
children: /* @__PURE__ */ l(
|
|
123
|
-
|
|
126
|
+
z,
|
|
124
127
|
{
|
|
125
128
|
name: "X",
|
|
126
129
|
size: "xs",
|
|
@@ -130,8 +133,8 @@ function Ve(z) {
|
|
|
130
133
|
}
|
|
131
134
|
)
|
|
132
135
|
] }) : /* @__PURE__ */ s("div", { className: "flex h-full w-full min-w-0 items-center justify-between gap-2", children: [
|
|
133
|
-
/* @__PURE__ */ l("div", { className: "min-w-0 flex-1 truncate", children: typeof
|
|
134
|
-
|
|
136
|
+
/* @__PURE__ */ l("div", { className: "min-w-0 flex-1 truncate", children: typeof f[0]?.label == "string" ? /* @__PURE__ */ l("span", { children: f[0]?.label }) : f[0]?.label }),
|
|
137
|
+
Y && i !== void 0 && i !== null && /* @__PURE__ */ l(
|
|
135
138
|
"div",
|
|
136
139
|
{
|
|
137
140
|
className: "border-d-input bg-d-accent cursor-pointer rounded-full p-1",
|
|
@@ -141,7 +144,7 @@ function Ve(z) {
|
|
|
141
144
|
onMouseDown: (e) => e.preventDefault(),
|
|
142
145
|
"aria-label": "Clear selection",
|
|
143
146
|
children: /* @__PURE__ */ l(
|
|
144
|
-
|
|
147
|
+
z,
|
|
145
148
|
{
|
|
146
149
|
name: "X",
|
|
147
150
|
size: "xs",
|
|
@@ -151,66 +154,66 @@ function Ve(z) {
|
|
|
151
154
|
}
|
|
152
155
|
)
|
|
153
156
|
] }),
|
|
154
|
-
/* @__PURE__ */ l(
|
|
157
|
+
/* @__PURE__ */ l(ve, { className: "h-4 w-4 opacity-50" })
|
|
155
158
|
]
|
|
156
159
|
}
|
|
157
160
|
) }),
|
|
158
161
|
/* @__PURE__ */ l(
|
|
159
|
-
|
|
162
|
+
ge,
|
|
160
163
|
{
|
|
161
164
|
className: "p-0",
|
|
162
165
|
style: { width: V > 0 ? V : "auto" },
|
|
163
166
|
align: "start",
|
|
164
167
|
sideOffset: 4,
|
|
165
|
-
children: /* @__PURE__ */ s(
|
|
166
|
-
|
|
167
|
-
|
|
168
|
+
children: /* @__PURE__ */ s(te, { shouldFilter: !!O, className: "w-full", children: [
|
|
169
|
+
O && /* @__PURE__ */ l(
|
|
170
|
+
se,
|
|
168
171
|
{
|
|
169
|
-
placeholder:
|
|
172
|
+
placeholder: F,
|
|
170
173
|
className: "placeholder:text-d-muted-foreground",
|
|
171
|
-
value:
|
|
172
|
-
onValueChange:
|
|
174
|
+
value: u,
|
|
175
|
+
onValueChange: N
|
|
173
176
|
}
|
|
174
177
|
),
|
|
175
|
-
/* @__PURE__ */ s(
|
|
176
|
-
/* @__PURE__ */ l(
|
|
177
|
-
|
|
178
|
-
|
|
178
|
+
/* @__PURE__ */ s(ie, { className: "max-h-60 overflow-auto overscroll-contain", children: [
|
|
179
|
+
/* @__PURE__ */ l(oe, { children: E }),
|
|
180
|
+
K && u && /* @__PURE__ */ l(R, { children: /* @__PURE__ */ l(
|
|
181
|
+
A,
|
|
179
182
|
{
|
|
180
183
|
className: "cursor-pointer",
|
|
181
184
|
onSelect: () => {
|
|
182
|
-
|
|
185
|
+
u && (m(r ? [...n, u] : u), N(""), !r && C(!1));
|
|
183
186
|
},
|
|
184
187
|
children: /* @__PURE__ */ s("div", { className: "text-d-foreground text-xs", children: [
|
|
185
|
-
|
|
188
|
+
L,
|
|
186
189
|
" “",
|
|
187
|
-
|
|
190
|
+
u,
|
|
188
191
|
"”"
|
|
189
192
|
] })
|
|
190
193
|
}
|
|
191
194
|
) }),
|
|
192
|
-
Object.entries(
|
|
193
|
-
const
|
|
195
|
+
Object.entries(le).map(([e, t]) => /* @__PURE__ */ l(R, { heading: e || void 0, children: t.map((a) => {
|
|
196
|
+
const p = n.includes(a.value), ae = r && o !== void 0 && !p && n.length >= o, M = a.disabled || ae;
|
|
194
197
|
return /* @__PURE__ */ s(
|
|
195
|
-
|
|
198
|
+
A,
|
|
196
199
|
{
|
|
197
|
-
value: typeof
|
|
198
|
-
onSelect: () => !M && I(
|
|
199
|
-
className:
|
|
200
|
+
value: typeof a.label == "string" ? a.label : String(a.value),
|
|
201
|
+
onSelect: () => !M && I(a),
|
|
202
|
+
className: y(
|
|
200
203
|
"cursor-pointer",
|
|
201
204
|
M && "cursor-not-allowed opacity-50",
|
|
202
|
-
!
|
|
205
|
+
!r && p && "bg-d-accent/75 text-d-accent-foreground"
|
|
203
206
|
),
|
|
204
207
|
children: [
|
|
205
|
-
|
|
206
|
-
typeof
|
|
208
|
+
r && /* @__PURE__ */ l(fe, { checked: p, className: "mr-1" }),
|
|
209
|
+
typeof a.label == "string" ? /* @__PURE__ */ l("span", { children: a.label }) : a.label
|
|
207
210
|
]
|
|
208
211
|
},
|
|
209
|
-
|
|
212
|
+
a.value
|
|
210
213
|
);
|
|
211
214
|
}) }, e))
|
|
212
215
|
] }),
|
|
213
|
-
|
|
216
|
+
r && o !== void 0 && n.length >= o && /* @__PURE__ */ l("div", { className: "border-d-border text-d-muted-foreground border-t px-2 py-1 text-xs", children: G(o) })
|
|
214
217
|
] })
|
|
215
218
|
}
|
|
216
219
|
)
|
|
@@ -220,5 +223,5 @@ function Ve(z) {
|
|
|
220
223
|
] });
|
|
221
224
|
}
|
|
222
225
|
export {
|
|
223
|
-
|
|
226
|
+
ke as AppSelect
|
|
224
227
|
};
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsxs as d, jsx as e } from "react/jsx-runtime";
|
|
3
|
+
import { cn as r } from "../../lib/utils.js";
|
|
4
|
+
import { cva as k } from "../../node_modules/class-variance-authority/dist/index.js";
|
|
5
|
+
import * as c from "react";
|
|
6
|
+
import { Label as g } from "./label.js";
|
|
7
|
+
import { Tooltip as z, TooltipTrigger as B, TooltipContent as C } from "./tooltip.js";
|
|
8
|
+
const x = k(
|
|
9
|
+
"inline-flex items-center justify-center transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-d-ring focus-visible:ring-offset-2",
|
|
10
|
+
{
|
|
11
|
+
variants: {
|
|
12
|
+
variant: {
|
|
13
|
+
default: "hover:text-d-foreground text-d-muted-foreground",
|
|
14
|
+
primary: "hover:text-d-primary text-d-primary/70",
|
|
15
|
+
secondary: "hover:text-d-secondary-foreground text-d-secondary-foreground/70",
|
|
16
|
+
accent: "hover:text-d-accent-foreground text-d-accent-foreground/70",
|
|
17
|
+
muted: "hover:text-d-muted-foreground text-d-muted-foreground/50",
|
|
18
|
+
ghost: "hover:bg-d-accent hover:text-d-accent-foreground"
|
|
19
|
+
},
|
|
20
|
+
size: {
|
|
21
|
+
sm: "text-xs",
|
|
22
|
+
default: "text-sm",
|
|
23
|
+
lg: "text-base"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
defaultVariants: {
|
|
27
|
+
variant: "default",
|
|
28
|
+
size: "default"
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
);
|
|
32
|
+
function E({
|
|
33
|
+
content: o,
|
|
34
|
+
children: n,
|
|
35
|
+
label: t,
|
|
36
|
+
labelClassName: i,
|
|
37
|
+
header: f,
|
|
38
|
+
variant: v = "primary",
|
|
39
|
+
triggerVariant: l = "default",
|
|
40
|
+
size: u = "default",
|
|
41
|
+
className: m,
|
|
42
|
+
wrpClassName: p,
|
|
43
|
+
contentClassName: h,
|
|
44
|
+
side: b = "top",
|
|
45
|
+
align: y = "center",
|
|
46
|
+
sideOffset: T = 4,
|
|
47
|
+
matchTriggerWidth: s = !1,
|
|
48
|
+
delayDuration: N = 200,
|
|
49
|
+
disabled: R = !1,
|
|
50
|
+
asChild: j = !1
|
|
51
|
+
}) {
|
|
52
|
+
const [w, A] = c.useState(), a = c.useRef(null);
|
|
53
|
+
return c.useEffect(() => {
|
|
54
|
+
s && a.current && A(a.current.getBoundingClientRect().width);
|
|
55
|
+
}, [s]), R ? /* @__PURE__ */ d("div", { className: r("flex flex-col gap-2", p), children: [
|
|
56
|
+
t && /* @__PURE__ */ e(g, { className: i, children: t }),
|
|
57
|
+
/* @__PURE__ */ e(
|
|
58
|
+
"div",
|
|
59
|
+
{
|
|
60
|
+
className: r(
|
|
61
|
+
x({ variant: l, size: u }),
|
|
62
|
+
m
|
|
63
|
+
),
|
|
64
|
+
children: n
|
|
65
|
+
}
|
|
66
|
+
)
|
|
67
|
+
] }) : /* @__PURE__ */ d("div", { className: r("flex flex-col gap-2", p), children: [
|
|
68
|
+
t && /* @__PURE__ */ e(g, { className: i, children: t }),
|
|
69
|
+
/* @__PURE__ */ d(z, { delayDuration: N, children: [
|
|
70
|
+
/* @__PURE__ */ e(B, { asChild: j, children: /* @__PURE__ */ e(
|
|
71
|
+
"div",
|
|
72
|
+
{
|
|
73
|
+
ref: a,
|
|
74
|
+
className: r(
|
|
75
|
+
x({ variant: l, size: u }),
|
|
76
|
+
m
|
|
77
|
+
),
|
|
78
|
+
children: n
|
|
79
|
+
}
|
|
80
|
+
) }),
|
|
81
|
+
/* @__PURE__ */ d(
|
|
82
|
+
C,
|
|
83
|
+
{
|
|
84
|
+
variant: v,
|
|
85
|
+
side: b,
|
|
86
|
+
align: y,
|
|
87
|
+
sideOffset: T,
|
|
88
|
+
className: r(h),
|
|
89
|
+
style: {
|
|
90
|
+
width: s ? w : void 0
|
|
91
|
+
},
|
|
92
|
+
children: [
|
|
93
|
+
f && /* @__PURE__ */ e("div", { className: "border-d-border mb-2 border-b pb-2 font-semibold", children: f }),
|
|
94
|
+
o
|
|
95
|
+
]
|
|
96
|
+
}
|
|
97
|
+
)
|
|
98
|
+
] })
|
|
99
|
+
] });
|
|
100
|
+
}
|
|
101
|
+
function F({
|
|
102
|
+
text: o,
|
|
103
|
+
className: n,
|
|
104
|
+
variant: t = "primary",
|
|
105
|
+
truncate: i = !0
|
|
106
|
+
}) {
|
|
107
|
+
return /* @__PURE__ */ e(E, { content: o, variant: t, asChild: !0, children: /* @__PURE__ */ e(
|
|
108
|
+
"span",
|
|
109
|
+
{
|
|
110
|
+
className: r(
|
|
111
|
+
"text-d-secondary-foreground block w-full min-w-0",
|
|
112
|
+
i && "truncate",
|
|
113
|
+
n
|
|
114
|
+
),
|
|
115
|
+
children: o
|
|
116
|
+
}
|
|
117
|
+
) });
|
|
118
|
+
}
|
|
119
|
+
export {
|
|
120
|
+
F as AppTextTooltip,
|
|
121
|
+
E as AppTooltip,
|
|
122
|
+
E as default
|
|
123
|
+
};
|