laif-ds 0.2.3 → 0.2.4
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.
|
@@ -1,43 +1,41 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as r, jsxs as l, Fragment as A } from "react/jsx-runtime";
|
|
3
3
|
import * as t from "react";
|
|
4
|
-
import { useEffect as
|
|
5
|
-
import { cn as
|
|
6
|
-
import { Label as
|
|
7
|
-
import { Badge as
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import { Checkbox as Y } from "./checkbox.js";
|
|
4
|
+
import { useEffect as B } from "react";
|
|
5
|
+
import { cn as u } from "../../lib/utils.js";
|
|
6
|
+
import { Label as E } from "./label.js";
|
|
7
|
+
import { Badge as F } from "./badge.js";
|
|
8
|
+
import { Popover as V, PopoverTrigger as G, PopoverContent as X } from "./popover.js";
|
|
9
|
+
import { Command as $, CommandList as q, CommandEmpty as H, CommandGroup as I, CommandItem as J } from "./command.js";
|
|
10
|
+
import { inputVariants as K } from "./input.js";
|
|
11
|
+
import { Checkbox as Q } from "./checkbox.js";
|
|
13
12
|
import { Icon as N } from "./icon.js";
|
|
14
|
-
import { selectTriggerVariants as
|
|
15
|
-
import
|
|
16
|
-
const
|
|
17
|
-
function
|
|
13
|
+
import { selectTriggerVariants as U } from "./async-select.js";
|
|
14
|
+
import Y from "../../node_modules/lucide-react/dist/esm/icons/chevron-down.js";
|
|
15
|
+
const Z = t.createContext({ size: "default" });
|
|
16
|
+
function ue({
|
|
18
17
|
options: a,
|
|
19
18
|
value: n,
|
|
20
19
|
onChange: o,
|
|
21
20
|
onClear: g,
|
|
22
|
-
placeholder:
|
|
23
|
-
disabled:
|
|
24
|
-
size:
|
|
21
|
+
placeholder: C = "Seleziona...",
|
|
22
|
+
disabled: y = !1,
|
|
23
|
+
size: m = "default",
|
|
25
24
|
label: b,
|
|
26
|
-
labelClassName:
|
|
25
|
+
labelClassName: k,
|
|
27
26
|
emptyMessage: M = "Nessun risultato trovato",
|
|
28
|
-
className:
|
|
29
|
-
searchPlaceholder:
|
|
30
|
-
searchable:
|
|
31
|
-
cancelLabel:
|
|
32
|
-
cancelButtonLabel: O = "Cancella",
|
|
27
|
+
className: z,
|
|
28
|
+
searchPlaceholder: P = "Cerca...",
|
|
29
|
+
searchable: R = !0,
|
|
30
|
+
cancelLabel: j = "Cancella selezione",
|
|
33
31
|
maxSelectedItems: i
|
|
34
32
|
}) {
|
|
35
|
-
const
|
|
33
|
+
const f = t.useId(), [s, D] = t.useState(!1), [c, v] = t.useState(""), [O, S] = t.useState(
|
|
36
34
|
void 0
|
|
37
|
-
),
|
|
35
|
+
), L = t.useRef(null), p = t.useRef(null), w = t.useCallback(
|
|
38
36
|
(e) => {
|
|
39
37
|
if (n.includes(e))
|
|
40
|
-
o(n.filter((
|
|
38
|
+
o(n.filter((d) => d !== e));
|
|
41
39
|
else {
|
|
42
40
|
if (i && n.length >= i)
|
|
43
41
|
return;
|
|
@@ -45,53 +43,53 @@ function pe({
|
|
|
45
43
|
}
|
|
46
44
|
},
|
|
47
45
|
[n, o, i]
|
|
48
|
-
),
|
|
46
|
+
), T = t.useCallback(() => {
|
|
49
47
|
o([]), v(""), g && g();
|
|
50
|
-
}, [o]),
|
|
51
|
-
(e) => e.label.toLowerCase().includes(
|
|
52
|
-
) : a, [a,
|
|
53
|
-
return
|
|
54
|
-
if (s &&
|
|
55
|
-
const e =
|
|
56
|
-
|
|
48
|
+
}, [o]), h = t.useMemo(() => a.filter((e) => n.includes(e.value)), [a, n]), W = t.useMemo(() => c ? a.filter(
|
|
49
|
+
(e) => e.label.toLowerCase().includes(c.toLowerCase())
|
|
50
|
+
) : a, [a, c]), x = t.useMemo(() => i ? n.length >= i : !1, [n, i]);
|
|
51
|
+
return B(() => {
|
|
52
|
+
if (s && p.current) {
|
|
53
|
+
const e = p.current.getBoundingClientRect();
|
|
54
|
+
S(e.width);
|
|
57
55
|
}
|
|
58
|
-
}, [s]), /* @__PURE__ */ r(
|
|
59
|
-
b && /* @__PURE__ */ r(
|
|
56
|
+
}, [s]), /* @__PURE__ */ r(Z.Provider, { value: { size: m, id: f }, children: /* @__PURE__ */ l("div", { className: "space-y-1.5", children: [
|
|
57
|
+
b && /* @__PURE__ */ r(E, { htmlFor: f, className: u(k, "w-fit"), children: b }),
|
|
60
58
|
/* @__PURE__ */ r(
|
|
61
59
|
"div",
|
|
62
60
|
{
|
|
63
|
-
ref:
|
|
61
|
+
ref: L,
|
|
64
62
|
className: "relative w-full",
|
|
65
63
|
"data-slot": "app-multiple-select-dropdown",
|
|
66
|
-
children: /* @__PURE__ */ l(
|
|
67
|
-
/* @__PURE__ */ r(
|
|
64
|
+
children: /* @__PURE__ */ l(V, { open: s, onOpenChange: D, children: [
|
|
65
|
+
/* @__PURE__ */ r(G, { asChild: !0, children: /* @__PURE__ */ l(
|
|
68
66
|
"button",
|
|
69
67
|
{
|
|
70
|
-
id:
|
|
68
|
+
id: f,
|
|
71
69
|
type: "button",
|
|
72
70
|
role: "combobox",
|
|
73
71
|
"aria-expanded": s,
|
|
74
|
-
disabled:
|
|
75
|
-
ref:
|
|
76
|
-
className:
|
|
77
|
-
|
|
72
|
+
disabled: y,
|
|
73
|
+
ref: p,
|
|
74
|
+
className: u(
|
|
75
|
+
U({ size: m }),
|
|
78
76
|
"!bg-d-input hover:bg-d-input/50 relative w-full justify-between font-normal",
|
|
79
77
|
"ring-offset-background border-d-border/50 flex items-center rounded-md border whitespace-nowrap focus:outline-none disabled:cursor-not-allowed disabled:opacity-50",
|
|
80
78
|
"aria-invalid:ring-d-destructive/20 dark:aria-invalid:ring-d-destructive/40 aria-invalid:border-d-destructive",
|
|
81
79
|
"focus-visible:ring-d-ring focus-visible:ring-1",
|
|
82
80
|
s && "ring-d-ring ring-1",
|
|
83
|
-
|
|
81
|
+
z
|
|
84
82
|
),
|
|
85
83
|
children: [
|
|
86
|
-
/* @__PURE__ */ r("div", { className: "flex w-full items-center justify-between gap-2 overflow-hidden", children:
|
|
84
|
+
/* @__PURE__ */ r("div", { className: "flex w-full items-center justify-between gap-2 overflow-hidden", children: h.length > 0 ? /* @__PURE__ */ l(A, { children: [
|
|
87
85
|
/* @__PURE__ */ l(
|
|
88
|
-
|
|
86
|
+
F,
|
|
89
87
|
{
|
|
90
88
|
variant: "secondary",
|
|
91
89
|
className: "!bg-d-accent flex items-center gap-1",
|
|
92
90
|
children: [
|
|
93
|
-
/* @__PURE__ */ r("span", { children:
|
|
94
|
-
|
|
91
|
+
/* @__PURE__ */ r("span", { children: h.length }),
|
|
92
|
+
h.length === 1 ? " elemento selezionato" : " elementi selezionati"
|
|
95
93
|
]
|
|
96
94
|
}
|
|
97
95
|
),
|
|
@@ -100,10 +98,10 @@ function pe({
|
|
|
100
98
|
{
|
|
101
99
|
className: "border-d-input bg-d-accent cursor-pointer rounded-full p-1",
|
|
102
100
|
onClick: (e) => {
|
|
103
|
-
e.stopPropagation(), e.preventDefault(),
|
|
101
|
+
e.stopPropagation(), e.preventDefault(), T();
|
|
104
102
|
},
|
|
105
103
|
onMouseDown: (e) => e.preventDefault(),
|
|
106
|
-
"aria-label":
|
|
104
|
+
"aria-label": j,
|
|
107
105
|
children: /* @__PURE__ */ r(
|
|
108
106
|
N,
|
|
109
107
|
{
|
|
@@ -114,73 +112,61 @@ function pe({
|
|
|
114
112
|
)
|
|
115
113
|
}
|
|
116
114
|
)
|
|
117
|
-
] }) : /* @__PURE__ */ r("span", { className: "text-d-muted-foreground", children:
|
|
118
|
-
/* @__PURE__ */ r(
|
|
115
|
+
] }) : /* @__PURE__ */ r("span", { className: "text-d-muted-foreground", children: C }) }),
|
|
116
|
+
/* @__PURE__ */ r(Y, { className: "ml-1 h-4 w-4 shrink-0 opacity-50" })
|
|
119
117
|
]
|
|
120
118
|
}
|
|
121
119
|
) }),
|
|
122
120
|
/* @__PURE__ */ r(
|
|
123
|
-
|
|
121
|
+
X,
|
|
124
122
|
{
|
|
125
|
-
className:
|
|
126
|
-
style: { width:
|
|
123
|
+
className: u("p-0"),
|
|
124
|
+
style: { width: O },
|
|
127
125
|
align: "start",
|
|
128
126
|
side: "bottom",
|
|
129
127
|
sideOffset: 4,
|
|
130
128
|
onWheel: (e) => e.stopPropagation(),
|
|
131
129
|
avoidCollisions: !1,
|
|
132
|
-
children: /* @__PURE__ */ l(
|
|
133
|
-
|
|
134
|
-
/* @__PURE__ */
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
"input",
|
|
145
|
-
{
|
|
146
|
-
id: "app-multiple-select-dropdown-filter",
|
|
147
|
-
placeholder: R,
|
|
148
|
-
value: d,
|
|
149
|
-
onChange: (e) => v(e.target.value),
|
|
150
|
-
className: `focus-visible:ring-none border-none focus-visible:border-none disabled:opacity-50 ${U({ size: f })} !shadow-none`
|
|
151
|
-
}
|
|
152
|
-
)
|
|
153
|
-
] }),
|
|
154
|
-
u.length > 0 && /* @__PURE__ */ r(
|
|
155
|
-
G,
|
|
130
|
+
children: /* @__PURE__ */ l($, { className: "bg-d-popover w-full rounded-md border border-none", children: [
|
|
131
|
+
R && /* @__PURE__ */ r("div", { className: "border-d-border flex items-center justify-between border-b px-3", children: /* @__PURE__ */ l("div", { className: "flex items-center", children: [
|
|
132
|
+
/* @__PURE__ */ r(
|
|
133
|
+
N,
|
|
134
|
+
{
|
|
135
|
+
name: "Search",
|
|
136
|
+
className: "text-d-accent-foreground opacity-50",
|
|
137
|
+
size: "sm"
|
|
138
|
+
}
|
|
139
|
+
),
|
|
140
|
+
/* @__PURE__ */ r(
|
|
141
|
+
"input",
|
|
156
142
|
{
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
143
|
+
id: "app-multiple-select-dropdown-filter",
|
|
144
|
+
placeholder: P,
|
|
145
|
+
value: c,
|
|
146
|
+
onChange: (e) => v(e.target.value),
|
|
147
|
+
className: `focus-visible:ring-none border-none focus-visible:border-none disabled:opacity-50 ${K({ size: m })} !shadow-none`
|
|
162
148
|
}
|
|
163
149
|
)
|
|
164
|
-
] }),
|
|
165
|
-
/* @__PURE__ */ l(
|
|
166
|
-
/* @__PURE__ */ r(
|
|
167
|
-
/* @__PURE__ */ r(
|
|
168
|
-
const
|
|
150
|
+
] }) }),
|
|
151
|
+
/* @__PURE__ */ l(q, { className: "max-h-60 w-full", children: [
|
|
152
|
+
/* @__PURE__ */ r(H, { children: M }),
|
|
153
|
+
/* @__PURE__ */ r(I, { children: W.map((e) => {
|
|
154
|
+
const d = n.includes(e.value);
|
|
169
155
|
return /* @__PURE__ */ l(
|
|
170
|
-
|
|
156
|
+
J,
|
|
171
157
|
{
|
|
172
158
|
value: e.value,
|
|
173
|
-
disabled: e.disabled || !
|
|
159
|
+
disabled: e.disabled || !d && x,
|
|
174
160
|
onSelect: () => w(e.value),
|
|
175
|
-
className:
|
|
161
|
+
className: u(
|
|
176
162
|
"aria-selected:!bg-d-accent aria-selected:text-d-accent-foreground flex cursor-pointer items-center gap-2 px-2 py-1.5",
|
|
177
|
-
(e.disabled || !
|
|
163
|
+
(e.disabled || !d && x) && "cursor-not-allowed opacity-50"
|
|
178
164
|
),
|
|
179
165
|
children: [
|
|
180
166
|
/* @__PURE__ */ r(
|
|
181
|
-
|
|
167
|
+
Q,
|
|
182
168
|
{
|
|
183
|
-
checked:
|
|
169
|
+
checked: d,
|
|
184
170
|
className: "z-10 mr-2 flex-shrink-0",
|
|
185
171
|
onCheckedChange: () => {
|
|
186
172
|
console.log("checkbox change for:", e.value), w(e.value);
|
|
@@ -203,5 +189,5 @@ function pe({
|
|
|
203
189
|
] }) });
|
|
204
190
|
}
|
|
205
191
|
export {
|
|
206
|
-
|
|
192
|
+
ue as AppMultipleSelectDropdown
|
|
207
193
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -143,7 +143,7 @@ declare interface AppEditorProps {
|
|
|
143
143
|
|
|
144
144
|
declare type AppEditorToolbar = "block-format" | "font-format" | "history";
|
|
145
145
|
|
|
146
|
-
export declare function AppMultipleSelectDropdown({ options, value, onChange, onClear, placeholder, disabled, size, label, labelClassName, emptyMessage, className, searchPlaceholder, searchable, cancelLabel,
|
|
146
|
+
export declare function AppMultipleSelectDropdown({ options, value, onChange, onClear, placeholder, disabled, size, label, labelClassName, emptyMessage, className, searchPlaceholder, searchable, cancelLabel, maxSelectedItems, }: MultipleSelectDropdownProps): JSX.Element;
|
|
147
147
|
|
|
148
148
|
export declare interface AppMultipleSelectOption {
|
|
149
149
|
value: string;
|
|
@@ -1209,7 +1209,6 @@ declare interface MultipleSelectDropdownProps {
|
|
|
1209
1209
|
searchable?: boolean;
|
|
1210
1210
|
maxSelectedItems?: number;
|
|
1211
1211
|
cancelLabel?: string;
|
|
1212
|
-
cancelButtonLabel?: string;
|
|
1213
1212
|
}
|
|
1214
1213
|
|
|
1215
1214
|
export declare const MultipleSelector: React_2.ForwardRefExoticComponent<MultipleSelectorProps & React_2.RefAttributes<MultipleSelectorRef>>;
|