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