@trsys-tech/matrix-library 0.3.4 → 0.3.6
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/accordion.es.js +40 -0
- package/dist/accordion.es.js.map +1 -0
- package/dist/avatar.es.js +20 -0
- package/dist/avatar.es.js.map +1 -0
- package/dist/badge.es.js.map +1 -1
- package/dist/breadcrumb.es.js.map +1 -1
- package/dist/button.es.js.map +1 -1
- package/dist/calendar.es.js.map +1 -1
- package/dist/card.es.js.map +1 -1
- package/dist/chip.es.js.map +1 -1
- package/dist/collapsible.es.js.map +1 -1
- package/dist/combobox.es.js +84 -32
- package/dist/combobox.es.js.map +1 -1
- package/dist/command.es.js +58 -50
- package/dist/command.es.js.map +1 -1
- package/dist/components/badge/Badge.d.ts.map +1 -1
- package/dist/components/breadcrumb/Breadcrumb.d.ts.map +1 -1
- package/dist/components/button/Button.d.ts.map +1 -1
- package/dist/components/card/Card.d.ts.map +1 -1
- package/dist/components/chip/Chip.d.ts.map +1 -1
- package/dist/components/collapsible/Collapsible.d.ts.map +1 -1
- package/dist/components/combobox/Combobox.d.ts +68 -59
- package/dist/components/combobox/Combobox.d.ts.map +1 -1
- package/dist/components/command/Command.d.ts +12 -9
- package/dist/components/command/Command.d.ts.map +1 -1
- package/dist/components/confirm/Confirm.d.ts.map +1 -1
- package/dist/components/data-grid/DataGrid.d.ts.map +1 -1
- package/dist/components/date-picker/DatePicker.d.ts.map +1 -1
- package/dist/components/date-picker/DateRangePicker.d.ts.map +1 -1
- package/dist/components/date-picker/DesktopTimePicker.d.ts.map +1 -1
- package/dist/components/date-picker/MobileTimePicker.d.ts.map +1 -1
- package/dist/components/date-picker/TimePicker.d.ts.map +1 -1
- package/dist/components/date-picker/calendar.d.ts.map +1 -1
- package/dist/components/dialog/Dialog.d.ts.map +1 -1
- package/dist/components/form/Form.d.ts.map +1 -1
- package/dist/components/form-checkbox/FormCheckbox.d.ts.map +1 -1
- package/dist/components/form-combobox/FormCombobox.d.ts +2 -7
- package/dist/components/form-combobox/FormCombobox.d.ts.map +1 -1
- package/dist/components/form-date-picker/FormDatePicker.d.ts.map +1 -1
- package/dist/components/form-date-range-picker/FormDateRangePicker.d.ts.map +1 -1
- package/dist/components/form-input/FormInput.d.ts.map +1 -1
- package/dist/components/form-multi-select/FormMultiSelect.d.ts.map +1 -1
- package/dist/components/form-rating/FormRating.d.ts.map +1 -1
- package/dist/components/form-select/FormSelect.d.ts.map +1 -1
- package/dist/components/form-switch/FormSwitch.d.ts.map +1 -1
- package/dist/components/form-textarea/FormTextarea.d.ts.map +1 -1
- package/dist/components/form-time-picker/FormTimePicker.d.ts.map +1 -1
- package/dist/components/icon-botton/IconButton.d.ts.map +1 -1
- package/dist/components/modal/Modal.d.ts.map +1 -1
- package/dist/components/multi-select/MultiSelect.d.ts.map +1 -1
- package/dist/components/select/Select.d.ts.map +1 -1
- package/dist/components/tabs/Tabs.d.ts.map +1 -1
- package/dist/components/text-field/TextField.d.ts.map +1 -1
- package/dist/components/toast/Toast.d.ts.map +1 -1
- package/dist/components/toast/toast-components.d.ts.map +1 -1
- package/dist/components/toast/use-toast.d.ts.map +1 -1
- package/dist/confirm.es.js.map +1 -1
- package/dist/contextmenu.es.js +116 -0
- package/dist/contextmenu.es.js.map +1 -0
- package/dist/datagrid.es.js.map +1 -1
- package/dist/datepicker.es.js.map +1 -1
- package/dist/daterangepicker.es.js.map +1 -1
- package/dist/desktopdatepicker.es.js +33 -33
- package/dist/desktopdatepicker.es.js.map +1 -1
- package/dist/desktopdaterangepicker.es.js +33 -33
- package/dist/desktopdaterangepicker.es.js.map +1 -1
- package/dist/desktoptimepicker.es.js +27 -23
- package/dist/desktoptimepicker.es.js.map +1 -1
- package/dist/dialog.es.js.map +1 -1
- package/dist/form.es.js.map +1 -1
- package/dist/formcheckbox.es.js.map +1 -1
- package/dist/formcombobox.es.js +47 -104
- package/dist/formcombobox.es.js.map +1 -1
- package/dist/formdatepicker.es.js.map +1 -1
- package/dist/formdaterangepicker.es.js.map +1 -1
- package/dist/forminput.es.js.map +1 -1
- package/dist/formmultiselect.es.js.map +1 -1
- package/dist/formrating.es.js.map +1 -1
- package/dist/formselect.es.js.map +1 -1
- package/dist/formswitch.es.js.map +1 -1
- package/dist/formtextarea.es.js.map +1 -1
- package/dist/formtimepicker.es.js.map +1 -1
- package/dist/iconbutton.es.js.map +1 -1
- package/dist/index.d.ts +11 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.es.js +246 -215
- package/dist/index.es.js.map +1 -1
- package/dist/mobiledatepicker.es.js +38 -38
- package/dist/mobiledatepicker.es.js.map +1 -1
- package/dist/mobiledaterangepicker.es.js +51 -51
- package/dist/mobiledaterangepicker.es.js.map +1 -1
- package/dist/mobiletimepicker.es.js +30 -26
- package/dist/mobiletimepicker.es.js.map +1 -1
- package/dist/modal.es.js.map +1 -1
- package/dist/multiselect.es.js +114 -106
- package/dist/multiselect.es.js.map +1 -1
- package/dist/select.es.js.map +1 -1
- package/dist/style.css +1 -1
- package/dist/tabs.es.js.map +1 -1
- package/dist/textfield.es.js.map +1 -1
- package/dist/timepicker.es.js.map +1 -1
- package/dist/toast-components.es.js.map +1 -1
- package/dist/toast.es.js.map +1 -1
- package/dist/use-toast.es.js.map +1 -1
- package/package.json +1 -1
package/dist/multiselect.es.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import * as
|
|
1
|
+
import { jsxs as a, jsx as r, Fragment as x } from "react/jsx-runtime";
|
|
2
|
+
import * as s from "react";
|
|
3
3
|
import { tv as H } from "tailwind-variants";
|
|
4
|
-
import {
|
|
5
|
-
import { cn as
|
|
6
|
-
import { Badge as
|
|
7
|
-
import { Button as
|
|
8
|
-
import { Separator as
|
|
9
|
-
import { Popover as
|
|
10
|
-
import { Command as
|
|
11
|
-
const
|
|
4
|
+
import { ChevronDown as J, XMark as k, CircleXmark as Q, Check as j } from "@trsys-tech/matrix-icons";
|
|
5
|
+
import { cn as d } from "./utils.es.js";
|
|
6
|
+
import { Badge as P } from "./badge.es.js";
|
|
7
|
+
import { Button as U } from "./button.es.js";
|
|
8
|
+
import { Separator as E } from "./separator.es.js";
|
|
9
|
+
import { Popover as Y, PopoverTrigger as Z, PopoverContent as ee } from "./popover.es.js";
|
|
10
|
+
import { Command as re, CommandInput as te, CommandList as ae, CommandEmpty as oe, CommandGroup as I, CommandItem as g, CommandSeparator as se } from "./command.es.js";
|
|
11
|
+
const O = H({
|
|
12
12
|
base: "flex gap-1 items-center py-0.5 px-2 rounded-xl",
|
|
13
13
|
variants: {
|
|
14
14
|
variant: {
|
|
@@ -21,180 +21,188 @@ const I = H({
|
|
|
21
21
|
defaultVariants: {
|
|
22
22
|
variant: "default"
|
|
23
23
|
}
|
|
24
|
-
}),
|
|
24
|
+
}), le = s.forwardRef(
|
|
25
25
|
({
|
|
26
|
-
options:
|
|
27
|
-
onValueChange:
|
|
28
|
-
value:
|
|
29
|
-
variant:
|
|
30
|
-
disabled:
|
|
31
|
-
defaultValue:
|
|
32
|
-
placeholder:
|
|
33
|
-
maxCount:
|
|
26
|
+
options: n,
|
|
27
|
+
onValueChange: c,
|
|
28
|
+
value: b,
|
|
29
|
+
variant: w,
|
|
30
|
+
disabled: N,
|
|
31
|
+
defaultValue: D = [],
|
|
32
|
+
placeholder: R = "Select options",
|
|
33
|
+
maxCount: m = 3,
|
|
34
34
|
modalPopover: V = !1,
|
|
35
35
|
// asChild = false,
|
|
36
36
|
className: B,
|
|
37
37
|
moreText: K = "more",
|
|
38
|
-
clearText:
|
|
39
|
-
closeText:
|
|
40
|
-
selectAllText:
|
|
41
|
-
noResultsText:
|
|
42
|
-
loading:
|
|
43
|
-
loadingText:
|
|
44
|
-
...
|
|
45
|
-
},
|
|
46
|
-
const [
|
|
47
|
-
|
|
48
|
-
l(
|
|
49
|
-
}, [
|
|
38
|
+
clearText: L = "Clear",
|
|
39
|
+
closeText: M = "Close",
|
|
40
|
+
selectAllText: _ = "Select All",
|
|
41
|
+
noResultsText: A = "No results found.",
|
|
42
|
+
loading: p,
|
|
43
|
+
loadingText: u = "Loading...",
|
|
44
|
+
...T
|
|
45
|
+
}, W) => {
|
|
46
|
+
const [t, l] = s.useState(D ?? b), [X, i] = s.useState(!1), f = s.useRef(null), [$, S] = s.useState(!1);
|
|
47
|
+
s.useEffect(() => {
|
|
48
|
+
l(b ?? []);
|
|
49
|
+
}, [b]);
|
|
50
50
|
const F = (e) => {
|
|
51
51
|
if (e.key === "Enter")
|
|
52
|
-
|
|
52
|
+
i(!0);
|
|
53
53
|
else if (e.key === "Backspace" && !e.currentTarget.value) {
|
|
54
|
-
const o = [...
|
|
55
|
-
o.pop(), l(o),
|
|
54
|
+
const o = [...t];
|
|
55
|
+
o.pop(), l(o), c(o);
|
|
56
56
|
}
|
|
57
|
-
},
|
|
58
|
-
const o =
|
|
59
|
-
l(o),
|
|
60
|
-
},
|
|
61
|
-
l([]),
|
|
57
|
+
}, C = (e) => {
|
|
58
|
+
const o = t.includes(e) ? t.filter((h) => h !== e) : [...t, e];
|
|
59
|
+
l(o), c(o);
|
|
60
|
+
}, y = () => {
|
|
61
|
+
l([]), c([]);
|
|
62
62
|
}, G = () => {
|
|
63
|
-
|
|
63
|
+
i((e) => !e);
|
|
64
64
|
}, q = () => {
|
|
65
|
-
const e =
|
|
66
|
-
l(e),
|
|
65
|
+
const e = t.slice(0, m);
|
|
66
|
+
l(e), c(e);
|
|
67
67
|
}, z = () => {
|
|
68
|
-
if (
|
|
69
|
-
|
|
68
|
+
if (t.length === n.length)
|
|
69
|
+
y();
|
|
70
70
|
else {
|
|
71
|
-
const e =
|
|
72
|
-
l(e),
|
|
71
|
+
const e = n.map((o) => o.value);
|
|
72
|
+
l(e), c(e);
|
|
73
73
|
}
|
|
74
74
|
};
|
|
75
|
-
return
|
|
76
|
-
|
|
77
|
-
|
|
75
|
+
return s.useLayoutEffect(() => {
|
|
76
|
+
f.current && (f?.current?.firstChild?.offsetTop < f?.current?.lastChild?.offsetTop ? S(!0) : S(!1));
|
|
77
|
+
}, [t]), /* @__PURE__ */ a(Y, { open: X, onOpenChange: i, modal: V, children: [
|
|
78
|
+
/* @__PURE__ */ r(Z, { asChild: !0, children: /* @__PURE__ */ r(
|
|
79
|
+
U,
|
|
78
80
|
{
|
|
79
|
-
ref:
|
|
81
|
+
ref: W,
|
|
80
82
|
variant: "text",
|
|
81
|
-
loading:
|
|
82
|
-
disabled:
|
|
83
|
-
...
|
|
83
|
+
loading: p,
|
|
84
|
+
disabled: N,
|
|
85
|
+
...T,
|
|
84
86
|
onClick: G,
|
|
85
|
-
className:
|
|
86
|
-
"flex max-h-14 h-
|
|
87
|
+
className: d(
|
|
88
|
+
"group flex max-h-14 h-8 w-full items-center justify-between whitespace-nowrap rounded-sm border border-input bg-transparent px-3 py-1.5 text-sm ring-offset-background data-[placeholder]:text-muted-foreground hover:border hover:border-primary hover:bg-transparent focus:border focus:border-primary focus:outline-none focus:ring focus:ring-primary-100 disabled:cursor-not-allowed disabled:bg-gray-100 disabled:text-text-300 disabled:border-gray-100 [&>span]:line-clamp-1 [&_svg]:disabled:text-text-300",
|
|
89
|
+
$ && "h-auto",
|
|
87
90
|
B
|
|
88
91
|
),
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
92
|
+
"data-placeholder": t.length ? void 0 : "",
|
|
93
|
+
endIcon: /* @__PURE__ */ r(
|
|
94
|
+
J,
|
|
95
|
+
{
|
|
96
|
+
role: "button",
|
|
97
|
+
"aria-label": "Expand dropdown",
|
|
98
|
+
className: "!h-4.5 !w-4.5 cursor-pointer group-data-[state=open]:rotate-180 transition-transform"
|
|
99
|
+
}
|
|
100
|
+
),
|
|
101
|
+
children: /* @__PURE__ */ r(x, { children: t.length > 0 ? /* @__PURE__ */ a("div", { className: "flex justify-between items-center w-full", children: [
|
|
102
|
+
/* @__PURE__ */ a("div", { className: "flex flex-wrap items-center gap-2", ref: f, children: [
|
|
103
|
+
t.slice(0, m).map((e) => {
|
|
104
|
+
const o = n.find((v) => v.value === e), h = o?.icon;
|
|
105
|
+
return /* @__PURE__ */ a(P, { className: d(O({ variant: w }), { "text-gray-400 bg-gray-200": N || p }), children: [
|
|
94
106
|
/* @__PURE__ */ r(
|
|
95
|
-
|
|
107
|
+
k,
|
|
96
108
|
{
|
|
97
109
|
className: "h-4 w-4 cursor-pointer",
|
|
98
|
-
onClick: (
|
|
99
|
-
|
|
110
|
+
onClick: (v) => {
|
|
111
|
+
v.stopPropagation(), C(e);
|
|
100
112
|
}
|
|
101
113
|
}
|
|
102
114
|
),
|
|
103
|
-
|
|
115
|
+
h && /* @__PURE__ */ r(h, { className: "h-4 w-4 mr-2" }),
|
|
104
116
|
o?.label
|
|
105
117
|
] }, e);
|
|
106
118
|
}),
|
|
107
|
-
|
|
108
|
-
`+ ${
|
|
119
|
+
t.length > m && /* @__PURE__ */ a(P, { className: d(O({ variant: w })), children: [
|
|
120
|
+
`+ ${t.length - m} ${K}`,
|
|
109
121
|
/* @__PURE__ */ r(
|
|
110
|
-
|
|
122
|
+
Q,
|
|
111
123
|
{
|
|
112
124
|
role: "button",
|
|
113
|
-
className: "ml-2 h-4 w-4 cursor-pointer",
|
|
125
|
+
className: "ml-2 h-4.5 w-4.5 cursor-pointer",
|
|
114
126
|
onClick: (e) => {
|
|
115
127
|
e.stopPropagation(), q();
|
|
116
128
|
}
|
|
117
129
|
}
|
|
118
130
|
)
|
|
119
131
|
] }),
|
|
120
|
-
|
|
132
|
+
p && u ? u : null
|
|
121
133
|
] }),
|
|
122
|
-
/* @__PURE__ */
|
|
134
|
+
/* @__PURE__ */ a("div", { className: "flex items-center justify-between gap-1", children: [
|
|
123
135
|
/* @__PURE__ */ r(
|
|
124
|
-
|
|
136
|
+
k,
|
|
125
137
|
{
|
|
126
138
|
role: "button",
|
|
127
|
-
className: "h-
|
|
139
|
+
className: "h-5 w-5 text-muted-foreground cursor-pointer",
|
|
128
140
|
onClick: (e) => {
|
|
129
|
-
e.stopPropagation(),
|
|
141
|
+
e.stopPropagation(), y();
|
|
130
142
|
},
|
|
131
143
|
"aria-label": "Clear"
|
|
132
144
|
}
|
|
133
145
|
),
|
|
134
|
-
/* @__PURE__ */ r(
|
|
135
|
-
/* @__PURE__ */ r(C, { role: "button", "aria-label": "Expand dropdown", className: "h-4 w-4 text-muted-foreground cursor-pointer" })
|
|
146
|
+
/* @__PURE__ */ r(E, { orientation: "vertical", className: "flex min-h-5 h-full" })
|
|
136
147
|
] })
|
|
137
|
-
] }) : /* @__PURE__ */
|
|
138
|
-
/* @__PURE__ */ r("span", { className: "text-sm text-muted-foreground mx-3", children: m && p ? p : D }),
|
|
139
|
-
/* @__PURE__ */ r(C, { role: "button", "aria-label": "Expand dropdown", className: "h-4 w-4 text-muted-foreground cursor-pointer" })
|
|
140
|
-
] }) })
|
|
148
|
+
] }) : /* @__PURE__ */ r(x, { children: p && u ? u : R }) })
|
|
141
149
|
}
|
|
142
150
|
) }),
|
|
143
|
-
/* @__PURE__ */ r(
|
|
144
|
-
/* @__PURE__ */ r(
|
|
145
|
-
/* @__PURE__ */
|
|
146
|
-
/* @__PURE__ */ r(
|
|
147
|
-
/* @__PURE__ */
|
|
148
|
-
/* @__PURE__ */
|
|
151
|
+
/* @__PURE__ */ r(ee, { className: "w-auto p-0", align: "start", onEscapeKeyDown: () => i(!1), children: /* @__PURE__ */ a(re, { className: "w-[--radix-popper-anchor-width]", children: [
|
|
152
|
+
/* @__PURE__ */ r(te, { placeholder: "Search...", onKeyDown: F }),
|
|
153
|
+
/* @__PURE__ */ a(ae, { className: "max-h-[--radix-popper-available-height]", children: [
|
|
154
|
+
/* @__PURE__ */ r(oe, { children: A }),
|
|
155
|
+
/* @__PURE__ */ a(I, { children: [
|
|
156
|
+
/* @__PURE__ */ a(g, { onSelect: z, className: "cursor-pointer", children: [
|
|
149
157
|
/* @__PURE__ */ r(
|
|
150
158
|
"div",
|
|
151
159
|
{
|
|
152
|
-
className:
|
|
153
|
-
"mr-2 flex h-4 w-4 items-center justify-center rounded-sm border border-primary",
|
|
154
|
-
|
|
160
|
+
className: d(
|
|
161
|
+
"mr-2 flex h-4.5 w-4.5 items-center justify-center rounded-sm border border-primary",
|
|
162
|
+
t.length === n.length ? "bg-primary text-primary-foreground" : "opacity-50 [&_svg]:invisible"
|
|
155
163
|
),
|
|
156
|
-
children: /* @__PURE__ */ r(j, { className: "h-4 w-4" })
|
|
164
|
+
children: /* @__PURE__ */ r(j, { className: "h-4.5 w-4.5" })
|
|
157
165
|
}
|
|
158
166
|
),
|
|
159
|
-
/* @__PURE__ */
|
|
167
|
+
/* @__PURE__ */ a("span", { children: [
|
|
160
168
|
"(",
|
|
161
|
-
|
|
169
|
+
_,
|
|
162
170
|
")"
|
|
163
171
|
] })
|
|
164
172
|
] }, "all"),
|
|
165
|
-
|
|
166
|
-
const o =
|
|
167
|
-
return /* @__PURE__ */
|
|
173
|
+
n.map((e) => {
|
|
174
|
+
const o = t.includes(e.value);
|
|
175
|
+
return /* @__PURE__ */ a(g, { onSelect: () => C(e.value), className: "cursor-pointer", children: [
|
|
168
176
|
/* @__PURE__ */ r(
|
|
169
177
|
"div",
|
|
170
178
|
{
|
|
171
|
-
className:
|
|
172
|
-
"mr-2 flex h-4 w-4 items-center justify-center rounded-sm border border-primary",
|
|
179
|
+
className: d(
|
|
180
|
+
"mr-2 flex h-4.5 w-4.5 items-center justify-center rounded-sm border border-primary",
|
|
173
181
|
o ? "bg-primary text-primary-foreground" : "opacity-50 [&_svg]:invisible"
|
|
174
182
|
),
|
|
175
|
-
children: /* @__PURE__ */ r(j, { className: "h-4 w-4" })
|
|
183
|
+
children: /* @__PURE__ */ r(j, { className: "h-4.5 w-4.5" })
|
|
176
184
|
}
|
|
177
185
|
),
|
|
178
|
-
e.icon && /* @__PURE__ */ r(e.icon, { className: "mr-2 h-4 w-4 text-muted-foreground" }),
|
|
186
|
+
e.icon && /* @__PURE__ */ r(e.icon, { className: "mr-2 h-4.5 w-4.5 text-muted-foreground" }),
|
|
179
187
|
/* @__PURE__ */ r("span", { children: e.label })
|
|
180
188
|
] }, e.value);
|
|
181
189
|
})
|
|
182
190
|
] }),
|
|
183
|
-
/* @__PURE__ */ r(
|
|
184
|
-
/* @__PURE__ */ r(
|
|
185
|
-
|
|
186
|
-
/* @__PURE__ */ r(
|
|
187
|
-
/* @__PURE__ */ r(
|
|
191
|
+
/* @__PURE__ */ r(se, {}),
|
|
192
|
+
/* @__PURE__ */ r(I, { children: /* @__PURE__ */ a("div", { className: "flex items-center justify-between", children: [
|
|
193
|
+
t.length > 0 && /* @__PURE__ */ a(x, { children: [
|
|
194
|
+
/* @__PURE__ */ r(g, { onSelect: y, className: "flex-1 justify-center cursor-pointer", children: L }),
|
|
195
|
+
/* @__PURE__ */ r(E, { orientation: "vertical", className: "flex min-h-6 h-full" })
|
|
188
196
|
] }),
|
|
189
|
-
/* @__PURE__ */ r(
|
|
197
|
+
/* @__PURE__ */ r(g, { onSelect: () => i(!1), className: "flex-1 justify-center cursor-pointer max-w-full", children: M })
|
|
190
198
|
] }) })
|
|
191
199
|
] })
|
|
192
200
|
] }) })
|
|
193
201
|
] });
|
|
194
202
|
}
|
|
195
203
|
);
|
|
196
|
-
|
|
204
|
+
le.displayName = "MultiSelect";
|
|
197
205
|
export {
|
|
198
|
-
|
|
206
|
+
le as MultiSelect
|
|
199
207
|
};
|
|
200
208
|
//# sourceMappingURL=multiselect.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"multiselect.es.js","sources":["../src/components/multi-select/MultiSelect.tsx"],"sourcesContent":["import * as React from \"react\";\r\nimport { tv, type VariantProps } from \"tailwind-variants\";\r\nimport { Check, ChevronDown, CircleXmark, XMark } from \"@trsys-tech/matrix-icons\";\r\n\r\nimport { cn } from \"../../lib/utils\";\r\nimport { Badge } from \"../badge/Badge\";\r\nimport { Button } from \"../button/Button\";\r\nimport { Separator } from \"../separator/Separator\";\r\nimport { Popover, PopoverContent, PopoverTrigger } from \"../popover/Popover\";\r\nimport { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator } from \"../command/Command\";\r\n\r\n/**\r\n * Variants for the multi-select component to handle different styles.\r\n * Uses tailwind-variants (cva) to define different styles based on \"variant\" prop.\r\n */\r\nconst multiSelectVariants = tv({\r\n base: \"flex gap-1 items-center py-0.5 px-2 rounded-xl\",\r\n variants: {\r\n variant: {\r\n default: \"border-none shadow-none bg-primary-50 text-primary hover:bg-primary-50\",\r\n secondary: \"border-foreground/10 bg-secondary text-secondary-foreground hover:bg-secondary/80\",\r\n destructive: \"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80\",\r\n inverted: \"inverted\",\r\n },\r\n },\r\n defaultVariants: {\r\n variant: \"default\",\r\n },\r\n});\r\n\r\n/**\r\n * Props for MultiSelect component\r\n */\r\ninterface MultiSelectProps extends React.ButtonHTMLAttributes<HTMLButtonElement>, VariantProps<typeof multiSelectVariants> {\r\n /**\r\n * An array of option objects to be displayed in the multi-select component.\r\n * Each option object has a label, value, and an optional icon.\r\n */\r\n options: {\r\n /** The text to display for the option. */\r\n label: string;\r\n /** The unique value associated with the option. */\r\n value: string;\r\n /** Optional icon component to display alongside the option. */\r\n icon?: React.ComponentType<{ className?: string }>;\r\n }[];\r\n\r\n /**\r\n * Callback function triggered when the selected values change.\r\n * Receives an array of the new selected values.\r\n */\r\n onValueChange: (value: string[]) => void;\r\n\r\n /**\r\n * selected values in the multi-select component.\r\n */\r\n value?: string[];\r\n\r\n /** The default selected values when the component mounts. */\r\n defaultValue?: string[];\r\n\r\n /**\r\n * Placeholder text to be displayed when no values are selected.\r\n * Optional, defaults to \"Select options\".\r\n */\r\n placeholder?: string;\r\n\r\n /**\r\n * Maximum number of items to display. Extra selected items will be summarized.\r\n * Optional, defaults to 3.\r\n */\r\n maxCount?: number;\r\n\r\n /**\r\n * The modality of the popover. When set to true, interaction with outside elements\r\n * will be disabled and only popover content will be visible to screen readers.\r\n * Optional, defaults to false.\r\n */\r\n modalPopover?: boolean;\r\n\r\n /**\r\n * If true, renders the multi-select component as a child of another component.\r\n * Optional, defaults to false.\r\n */\r\n asChild?: boolean;\r\n\r\n /**\r\n * Additional class names to apply custom styles to the multi-select component.\r\n * Optional, can be used to add custom styles.\r\n */\r\n className?: string;\r\n\r\n /**\r\n * Text to display on the close button when the multi-select component is open.\r\n */\r\n closeText?: string;\r\n\r\n /**\r\n * Text to display on the select all button when the multi-select component is open.\r\n */\r\n selectAllText?: string;\r\n\r\n /**\r\n * Text to display on the clear button when the multi-select component is open.\r\n */\r\n clearText?: string;\r\n\r\n /**\r\n * Text to display on the more button when the multi-select component is open.\r\n */\r\n moreText?: string;\r\n\r\n /**\r\n * Text to display when no results are found in the search input.\r\n */\r\n noResultsText?: string;\r\n\r\n /**\r\n * If true, the multi-select component will be in a loading state.\r\n */\r\n loading?: boolean;\r\n\r\n /**\r\n * Text to display when the multi-select component is in a loading state.\r\n */\r\n loadingText?: string;\r\n}\r\n\r\nconst MultiSelect = React.forwardRef<HTMLButtonElement, MultiSelectProps>(\r\n (\r\n {\r\n options,\r\n onValueChange,\r\n value,\r\n variant,\r\n disabled,\r\n defaultValue = [],\r\n placeholder = \"Select options\",\r\n maxCount = 3,\r\n modalPopover = false,\r\n // asChild = false,\r\n className,\r\n moreText = \"more\",\r\n clearText = \"Clear\",\r\n closeText = \"Close\",\r\n selectAllText = \"Select All\",\r\n noResultsText = \"No results found.\",\r\n loading,\r\n loadingText = \"Loading...\",\r\n ...props\r\n },\r\n ref,\r\n ) => {\r\n const [selectedValues, setSelectedValues] = React.useState<string[]>(defaultValue ?? value);\r\n const [isPopoverOpen, setIsPopoverOpen] = React.useState(false);\r\n\r\n React.useEffect(() => {\r\n setSelectedValues(value ?? []);\r\n }, [value]);\r\n\r\n const handleInputKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => {\r\n if (event.key === \"Enter\") {\r\n setIsPopoverOpen(true);\r\n } else if (event.key === \"Backspace\" && !event.currentTarget.value) {\r\n const newSelectedValues = [...selectedValues];\r\n newSelectedValues.pop();\r\n setSelectedValues(newSelectedValues);\r\n onValueChange(newSelectedValues);\r\n }\r\n };\r\n\r\n const toggleOption = (option: string) => {\r\n const newSelectedValues = selectedValues.includes(option) ? selectedValues.filter(value => value !== option) : [...selectedValues, option];\r\n setSelectedValues(newSelectedValues);\r\n onValueChange(newSelectedValues);\r\n };\r\n\r\n const handleClear = () => {\r\n setSelectedValues([]);\r\n onValueChange([]);\r\n };\r\n\r\n const handleTogglePopover = () => {\r\n setIsPopoverOpen(prev => !prev);\r\n };\r\n\r\n const clearExtraOptions = () => {\r\n const newSelectedValues = selectedValues.slice(0, maxCount);\r\n setSelectedValues(newSelectedValues);\r\n onValueChange(newSelectedValues);\r\n };\r\n\r\n const toggleAll = () => {\r\n if (selectedValues.length === options.length) {\r\n handleClear();\r\n } else {\r\n const allValues = options.map(option => option.value);\r\n setSelectedValues(allValues);\r\n onValueChange(allValues);\r\n }\r\n };\r\n\r\n return (\r\n <Popover open={isPopoverOpen} onOpenChange={setIsPopoverOpen} modal={modalPopover}>\r\n <PopoverTrigger asChild>\r\n <Button\r\n ref={ref}\r\n variant=\"text\"\r\n loading={loading}\r\n disabled={disabled}\r\n {...props}\r\n onClick={handleTogglePopover}\r\n className={cn(\r\n \"flex max-h-14 h-auto w-full items-center justify-between whitespace-nowrap rounded-sm border border-input bg-transparent px-3 py-1.5 text-sm shadow-sm ring-offset-background placeholder:text-muted-foreground hover:border hover:border-primary hover:bg-transparent focus:border focus:border-primary focus:outline-none focus:ring focus:ring-primary-100 disabled:cursor-not-allowed disabled:bg-gray-100 disabled:text-text-300 disabled:border-gray-100 [&>span]:line-clamp-1 [&_svg]:disabled:text-text-300\",\r\n className,\r\n )}\r\n >\r\n <>\r\n {selectedValues.length > 0 ? (\r\n <div className=\"flex justify-between items-center w-full\">\r\n <div className=\"flex flex-wrap items-center gap-2\">\r\n {selectedValues.slice(0, maxCount).map(value => {\r\n const option = options.find(o => o.value === value);\r\n const IconComponent = option?.icon;\r\n return (\r\n <Badge key={value} className={cn(multiSelectVariants({ variant }), { \"text-gray-400 bg-gray-200\": disabled || loading })}>\r\n <XMark\r\n className=\"h-4 w-4 cursor-pointer\"\r\n onClick={event => {\r\n event.stopPropagation();\r\n toggleOption(value);\r\n }}\r\n />\r\n {IconComponent && <IconComponent className=\"h-4 w-4 mr-2\" />}\r\n {option?.label}\r\n </Badge>\r\n );\r\n })}\r\n {selectedValues.length > maxCount && (\r\n <Badge className={cn(multiSelectVariants({ variant }))}>\r\n {`+ ${selectedValues.length - maxCount} ${moreText}`}\r\n <CircleXmark\r\n role=\"button\"\r\n className=\"ml-2 h-4 w-4 cursor-pointer\"\r\n onClick={event => {\r\n event.stopPropagation();\r\n clearExtraOptions();\r\n }}\r\n />\r\n </Badge>\r\n )}\r\n {loading && loadingText ? loadingText : null}\r\n </div>\r\n <div className=\"flex items-center justify-between gap-1\">\r\n <XMark\r\n role=\"button\"\r\n className=\"h-4.5 w-4.5 text-muted-foreground cursor-pointer\"\r\n onClick={event => {\r\n event.stopPropagation();\r\n handleClear();\r\n }}\r\n aria-label=\"Clear\"\r\n />\r\n <Separator orientation=\"vertical\" className=\"flex min-h-5 h-full\" />\r\n\r\n <ChevronDown role=\"button\" aria-label=\"Expand dropdown\" className=\"h-4 w-4 text-muted-foreground cursor-pointer\" />\r\n </div>\r\n </div>\r\n ) : (\r\n <div className=\"flex items-center justify-between w-full mx-auto\">\r\n <span className=\"text-sm text-muted-foreground mx-3\">{loading && loadingText ? loadingText : placeholder}</span>\r\n\r\n <ChevronDown role=\"button\" aria-label=\"Expand dropdown\" className=\"h-4 w-4 text-muted-foreground cursor-pointer\" />\r\n </div>\r\n )}\r\n </>\r\n </Button>\r\n </PopoverTrigger>\r\n <PopoverContent className=\"w-auto p-0\" align=\"start\" onEscapeKeyDown={() => setIsPopoverOpen(false)}>\r\n <Command className=\"w-[--radix-popper-anchor-width]\">\r\n <CommandInput placeholder=\"Search...\" onKeyDown={handleInputKeyDown} />\r\n <CommandList className=\"max-h-[--radix-popper-available-height]\">\r\n <CommandEmpty>{noResultsText}</CommandEmpty>\r\n <CommandGroup>\r\n <CommandItem key=\"all\" onSelect={toggleAll} className=\"cursor-pointer\">\r\n <div\r\n className={cn(\r\n \"mr-2 flex h-4 w-4 items-center justify-center rounded-sm border border-primary\",\r\n selectedValues.length === options.length ? \"bg-primary text-primary-foreground\" : \"opacity-50 [&_svg]:invisible\",\r\n )}\r\n >\r\n <Check className=\"h-4 w-4\" />\r\n </div>\r\n <span>({selectAllText})</span>\r\n </CommandItem>\r\n {options.map(option => {\r\n const isSelected = selectedValues.includes(option.value);\r\n return (\r\n <CommandItem key={option.value} onSelect={() => toggleOption(option.value)} className=\"cursor-pointer\">\r\n <div\r\n className={cn(\r\n \"mr-2 flex h-4 w-4 items-center justify-center rounded-sm border border-primary\",\r\n isSelected ? \"bg-primary text-primary-foreground\" : \"opacity-50 [&_svg]:invisible\",\r\n )}\r\n >\r\n <Check className=\"h-4 w-4\" />\r\n </div>\r\n {option.icon && <option.icon className=\"mr-2 h-4 w-4 text-muted-foreground\" />}\r\n <span>{option.label}</span>\r\n </CommandItem>\r\n );\r\n })}\r\n </CommandGroup>\r\n <CommandSeparator />\r\n <CommandGroup>\r\n <div className=\"flex items-center justify-between\">\r\n {selectedValues.length > 0 && (\r\n <>\r\n <CommandItem onSelect={handleClear} className=\"flex-1 justify-center cursor-pointer\">\r\n {clearText}\r\n </CommandItem>\r\n <Separator orientation=\"vertical\" className=\"flex min-h-6 h-full\" />\r\n </>\r\n )}\r\n <CommandItem onSelect={() => setIsPopoverOpen(false)} className=\"flex-1 justify-center cursor-pointer max-w-full\">\r\n {closeText}\r\n </CommandItem>\r\n </div>\r\n </CommandGroup>\r\n </CommandList>\r\n </Command>\r\n </PopoverContent>\r\n </Popover>\r\n );\r\n },\r\n);\r\n\r\nMultiSelect.displayName = \"MultiSelect\";\r\n\r\nexport { MultiSelect, type MultiSelectProps };\r\n"],"names":["multiSelectVariants","tv","MultiSelect","React","options","onValueChange","value","variant","disabled","defaultValue","placeholder","maxCount","modalPopover","className","moreText","clearText","closeText","selectAllText","noResultsText","loading","loadingText","props","ref","selectedValues","setSelectedValues","isPopoverOpen","setIsPopoverOpen","handleInputKeyDown","event","newSelectedValues","toggleOption","option","handleClear","handleTogglePopover","prev","clearExtraOptions","toggleAll","allValues","Popover","jsx","PopoverTrigger","Button","cn","jsxs","o","IconComponent","Badge","XMark","CircleXmark","Separator","ChevronDown","PopoverContent","Command","CommandInput","CommandList","CommandEmpty","CommandGroup","CommandItem","Check","isSelected","CommandSeparator","Fragment"],"mappings":";;;;;;;;;;AAeA,MAAMA,IAAsBC,EAAG;AAAA,EAC7B,MAAM;AAAA,EACN,UAAU;AAAA,IACR,SAAS;AAAA,MACP,SAAS;AAAA,MACT,WAAW;AAAA,MACX,aAAa;AAAA,MACb,UAAU;AAAA,IAAA;AAAA,EAEd;AAAA,EACA,iBAAiB;AAAA,IACf,SAAS;AAAA,EAAA;AAEb,CAAC,GAoGKC,KAAcC,EAAM;AAAA,EACxB,CACE;AAAA,IACE,SAAAC;AAAA,IACA,eAAAC;AAAA,IACA,OAAAC;AAAA,IACA,SAAAC;AAAA,IACA,UAAAC;AAAA,IACA,cAAAC,IAAe,CAAC;AAAA,IAChB,aAAAC,IAAc;AAAA,IACd,UAAAC,IAAW;AAAA,IACX,cAAAC,IAAe;AAAA;AAAA,IAEf,WAAAC;AAAA,IACA,UAAAC,IAAW;AAAA,IACX,WAAAC,IAAY;AAAA,IACZ,WAAAC,IAAY;AAAA,IACZ,eAAAC,IAAgB;AAAA,IAChB,eAAAC,IAAgB;AAAA,IAChB,SAAAC;AAAA,IACA,aAAAC,IAAc;AAAA,IACd,GAAGC;AAAA,KAELC,MACG;AACH,UAAM,CAACC,GAAgBC,CAAiB,IAAIrB,EAAM,SAAmBM,KAAgBH,CAAK,GACpF,CAACmB,GAAeC,CAAgB,IAAIvB,EAA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,gBAAAb,EAAA,OAAA,EAAI,WAAU,qCACZ,UAAA;AAAA,YAAepB,EAAA,SAAS,KAErB,gBAAAoB,EAAAkB,GAAA,EAAA,UAAA;AAAA,cAAA,gBAAAtB,EAACkB,GAAY,EAAA,UAAUzB,GAAa,WAAU,wCAC3C,UACHjB,GAAA;AAAA,cACC,gBAAAwB,EAAAU,GAAA,EAAU,aAAY,YAAW,WAAU,sBAAsB,CAAA;AAAA,YAAA,GACpE;AAAA,YAEF,gBAAAV,EAACkB,KAAY,UAAU,MAAM/B,EAAiB,EAAK,GAAG,WAAU,mDAC7D,UACHV,EAAA,CAAA;AAAA,UAAA,EAAA,CACF,EACF,CAAA;AAAA,QAAA,EACF,CAAA;AAAA,MAAA,EAAA,CACF,EACF,CAAA;AAAA,IAAA,GACF;AAAA,EAAA;AAGN;AAEAd,GAAY,cAAc;"}
|
|
1
|
+
{"version":3,"file":"multiselect.es.js","sources":["../src/components/multi-select/MultiSelect.tsx"],"sourcesContent":["\"use client\";\r\n\r\nimport * as React from \"react\";\r\nimport { tv, type VariantProps } from \"tailwind-variants\";\r\nimport { Check, ChevronDown, CircleXmark, XMark } from \"@trsys-tech/matrix-icons\";\r\n\r\nimport { cn } from \"../../lib/utils\";\r\nimport { Badge } from \"../badge/Badge\";\r\nimport { Button } from \"../button/Button\";\r\nimport { Separator } from \"../separator/Separator\";\r\nimport { Popover, PopoverContent, PopoverTrigger } from \"../popover/Popover\";\r\nimport { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator } from \"../command/Command\";\r\n\r\n/**\r\n * Variants for the multi-select component to handle different styles.\r\n * Uses tailwind-variants (cva) to define different styles based on \"variant\" prop.\r\n */\r\nconst multiSelectVariants = tv({\r\n base: \"flex gap-1 items-center py-0.5 px-2 rounded-xl\",\r\n variants: {\r\n variant: {\r\n default: \"border-none shadow-none bg-primary-50 text-primary hover:bg-primary-50\",\r\n secondary: \"border-foreground/10 bg-secondary text-secondary-foreground hover:bg-secondary/80\",\r\n destructive: \"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80\",\r\n inverted: \"inverted\",\r\n },\r\n },\r\n defaultVariants: {\r\n variant: \"default\",\r\n },\r\n});\r\n\r\n/**\r\n * Props for MultiSelect component\r\n */\r\ninterface MultiSelectProps extends React.ButtonHTMLAttributes<HTMLButtonElement>, VariantProps<typeof multiSelectVariants> {\r\n /**\r\n * An array of option objects to be displayed in the multi-select component.\r\n * Each option object has a label, value, and an optional icon.\r\n */\r\n options: {\r\n /** The text to display for the option. */\r\n label: string;\r\n /** The unique value associated with the option. */\r\n value: string;\r\n /** Optional icon component to display alongside the option. */\r\n icon?: React.ComponentType<{ className?: string }>;\r\n }[];\r\n\r\n /**\r\n * Callback function triggered when the selected values change.\r\n * Receives an array of the new selected values.\r\n */\r\n onValueChange: (value: string[]) => void;\r\n\r\n /**\r\n * selected values in the multi-select component.\r\n */\r\n value?: string[];\r\n\r\n /** The default selected values when the component mounts. */\r\n defaultValue?: string[];\r\n\r\n /**\r\n * Placeholder text to be displayed when no values are selected.\r\n * Optional, defaults to \"Select options\".\r\n */\r\n placeholder?: string;\r\n\r\n /**\r\n * Maximum number of items to display. Extra selected items will be summarized.\r\n * Optional, defaults to 3.\r\n */\r\n maxCount?: number;\r\n\r\n /**\r\n * The modality of the popover. When set to true, interaction with outside elements\r\n * will be disabled and only popover content will be visible to screen readers.\r\n * Optional, defaults to false.\r\n */\r\n modalPopover?: boolean;\r\n\r\n /**\r\n * If true, renders the multi-select component as a child of another component.\r\n * Optional, defaults to false.\r\n */\r\n asChild?: boolean;\r\n\r\n /**\r\n * Additional class names to apply custom styles to the multi-select component.\r\n * Optional, can be used to add custom styles.\r\n */\r\n className?: string;\r\n\r\n /**\r\n * Text to display on the close button when the multi-select component is open.\r\n */\r\n closeText?: string;\r\n\r\n /**\r\n * Text to display on the select all button when the multi-select component is open.\r\n */\r\n selectAllText?: string;\r\n\r\n /**\r\n * Text to display on the clear button when the multi-select component is open.\r\n */\r\n clearText?: string;\r\n\r\n /**\r\n * Text to display on the more button when the multi-select component is open.\r\n */\r\n moreText?: string;\r\n\r\n /**\r\n * Text to display when no results are found in the search input.\r\n */\r\n noResultsText?: string;\r\n\r\n /**\r\n * If true, the multi-select component will be in a loading state.\r\n */\r\n loading?: boolean;\r\n\r\n /**\r\n * Text to display when the multi-select component is in a loading state.\r\n */\r\n loadingText?: string;\r\n}\r\n\r\nconst MultiSelect = React.forwardRef<HTMLButtonElement, MultiSelectProps>(\r\n (\r\n {\r\n options,\r\n onValueChange,\r\n value,\r\n variant,\r\n disabled,\r\n defaultValue = [],\r\n placeholder = \"Select options\",\r\n maxCount = 3,\r\n modalPopover = false,\r\n // asChild = false,\r\n className,\r\n moreText = \"more\",\r\n clearText = \"Clear\",\r\n closeText = \"Close\",\r\n selectAllText = \"Select All\",\r\n noResultsText = \"No results found.\",\r\n loading,\r\n loadingText = \"Loading...\",\r\n ...props\r\n },\r\n ref,\r\n ) => {\r\n const [selectedValues, setSelectedValues] = React.useState<string[]>(defaultValue ?? value);\r\n const [isPopoverOpen, setIsPopoverOpen] = React.useState(false);\r\n const containerRef = React.useRef<HTMLDivElement>(null);\r\n const [isWrapped, setIsWrapped] = React.useState(false);\r\n\r\n React.useEffect(() => {\r\n setSelectedValues(value ?? []);\r\n }, [value]);\r\n\r\n const handleInputKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => {\r\n if (event.key === \"Enter\") {\r\n setIsPopoverOpen(true);\r\n } else if (event.key === \"Backspace\" && !event.currentTarget.value) {\r\n const newSelectedValues = [...selectedValues];\r\n newSelectedValues.pop();\r\n setSelectedValues(newSelectedValues);\r\n onValueChange(newSelectedValues);\r\n }\r\n };\r\n\r\n const toggleOption = (option: string) => {\r\n const newSelectedValues = selectedValues.includes(option) ? selectedValues.filter(value => value !== option) : [...selectedValues, option];\r\n setSelectedValues(newSelectedValues);\r\n onValueChange(newSelectedValues);\r\n };\r\n\r\n const handleClear = () => {\r\n setSelectedValues([]);\r\n onValueChange([]);\r\n };\r\n\r\n const handleTogglePopover = () => {\r\n setIsPopoverOpen(prev => !prev);\r\n };\r\n\r\n const clearExtraOptions = () => {\r\n const newSelectedValues = selectedValues.slice(0, maxCount);\r\n setSelectedValues(newSelectedValues);\r\n onValueChange(newSelectedValues);\r\n };\r\n\r\n const toggleAll = () => {\r\n if (selectedValues.length === options.length) {\r\n handleClear();\r\n } else {\r\n const allValues = options.map(option => option.value);\r\n setSelectedValues(allValues);\r\n onValueChange(allValues);\r\n }\r\n };\r\n\r\n React.useLayoutEffect(() => {\r\n if (containerRef.current) {\r\n if ((containerRef?.current?.firstChild as HTMLElement)?.offsetTop < (containerRef?.current?.lastChild as HTMLElement)?.offsetTop) {\r\n setIsWrapped(true);\r\n } else {\r\n setIsWrapped(false);\r\n }\r\n }\r\n }, [selectedValues]);\r\n\r\n return (\r\n <Popover open={isPopoverOpen} onOpenChange={setIsPopoverOpen} modal={modalPopover}>\r\n <PopoverTrigger asChild>\r\n <Button\r\n ref={ref}\r\n variant=\"text\"\r\n loading={loading}\r\n disabled={disabled}\r\n {...props}\r\n onClick={handleTogglePopover}\r\n className={cn(\r\n \"group flex max-h-14 h-8 w-full items-center justify-between whitespace-nowrap rounded-sm border border-input bg-transparent px-3 py-1.5 text-sm ring-offset-background data-[placeholder]:text-muted-foreground hover:border hover:border-primary hover:bg-transparent focus:border focus:border-primary focus:outline-none focus:ring focus:ring-primary-100 disabled:cursor-not-allowed disabled:bg-gray-100 disabled:text-text-300 disabled:border-gray-100 [&>span]:line-clamp-1 [&_svg]:disabled:text-text-300\",\r\n isWrapped && \"h-auto\",\r\n className,\r\n )}\r\n data-placeholder={!selectedValues.length ? \"\" : undefined}\r\n endIcon={\r\n <ChevronDown\r\n role=\"button\"\r\n aria-label=\"Expand dropdown\"\r\n className=\"!h-4.5 !w-4.5 cursor-pointer group-data-[state=open]:rotate-180 transition-transform\"\r\n />\r\n }\r\n >\r\n <>\r\n {selectedValues.length > 0 ? (\r\n <div className=\"flex justify-between items-center w-full\">\r\n <div className=\"flex flex-wrap items-center gap-2\" ref={containerRef}>\r\n {selectedValues.slice(0, maxCount).map(value => {\r\n const option = options.find(o => o.value === value);\r\n const IconComponent = option?.icon;\r\n return (\r\n <Badge key={value} className={cn(multiSelectVariants({ variant }), { \"text-gray-400 bg-gray-200\": disabled || loading })}>\r\n <XMark\r\n className=\"h-4 w-4 cursor-pointer\"\r\n onClick={event => {\r\n event.stopPropagation();\r\n toggleOption(value);\r\n }}\r\n />\r\n {IconComponent && <IconComponent className=\"h-4 w-4 mr-2\" />}\r\n {option?.label}\r\n </Badge>\r\n );\r\n })}\r\n {selectedValues.length > maxCount && (\r\n <Badge className={cn(multiSelectVariants({ variant }))}>\r\n {`+ ${selectedValues.length - maxCount} ${moreText}`}\r\n <CircleXmark\r\n role=\"button\"\r\n className=\"ml-2 h-4.5 w-4.5 cursor-pointer\"\r\n onClick={event => {\r\n event.stopPropagation();\r\n clearExtraOptions();\r\n }}\r\n />\r\n </Badge>\r\n )}\r\n {loading && loadingText ? loadingText : null}\r\n </div>\r\n <div className=\"flex items-center justify-between gap-1\">\r\n <XMark\r\n role=\"button\"\r\n className=\"h-5 w-5 text-muted-foreground cursor-pointer\"\r\n onClick={event => {\r\n event.stopPropagation();\r\n handleClear();\r\n }}\r\n aria-label=\"Clear\"\r\n />\r\n <Separator orientation=\"vertical\" className=\"flex min-h-5 h-full\" />\r\n </div>\r\n </div>\r\n ) : (\r\n <>{loading && loadingText ? loadingText : placeholder}</>\r\n )}\r\n </>\r\n </Button>\r\n </PopoverTrigger>\r\n <PopoverContent className=\"w-auto p-0\" align=\"start\" onEscapeKeyDown={() => setIsPopoverOpen(false)}>\r\n <Command className=\"w-[--radix-popper-anchor-width]\">\r\n <CommandInput placeholder=\"Search...\" onKeyDown={handleInputKeyDown} />\r\n <CommandList className=\"max-h-[--radix-popper-available-height]\">\r\n <CommandEmpty>{noResultsText}</CommandEmpty>\r\n <CommandGroup>\r\n <CommandItem key=\"all\" onSelect={toggleAll} className=\"cursor-pointer\">\r\n <div\r\n className={cn(\r\n \"mr-2 flex h-4.5 w-4.5 items-center justify-center rounded-sm border border-primary\",\r\n selectedValues.length === options.length ? \"bg-primary text-primary-foreground\" : \"opacity-50 [&_svg]:invisible\",\r\n )}\r\n >\r\n <Check className=\"h-4.5 w-4.5\" />\r\n </div>\r\n <span>({selectAllText})</span>\r\n </CommandItem>\r\n {options.map(option => {\r\n const isSelected = selectedValues.includes(option.value);\r\n return (\r\n <CommandItem key={option.value} onSelect={() => toggleOption(option.value)} className=\"cursor-pointer\">\r\n <div\r\n className={cn(\r\n \"mr-2 flex h-4.5 w-4.5 items-center justify-center rounded-sm border border-primary\",\r\n isSelected ? \"bg-primary text-primary-foreground\" : \"opacity-50 [&_svg]:invisible\",\r\n )}\r\n >\r\n <Check className=\"h-4.5 w-4.5\" />\r\n </div>\r\n {option.icon && <option.icon className=\"mr-2 h-4.5 w-4.5 text-muted-foreground\" />}\r\n <span>{option.label}</span>\r\n </CommandItem>\r\n );\r\n })}\r\n </CommandGroup>\r\n <CommandSeparator />\r\n <CommandGroup>\r\n <div className=\"flex items-center justify-between\">\r\n {selectedValues.length > 0 && (\r\n <>\r\n <CommandItem onSelect={handleClear} className=\"flex-1 justify-center cursor-pointer\">\r\n {clearText}\r\n </CommandItem>\r\n <Separator orientation=\"vertical\" className=\"flex min-h-6 h-full\" />\r\n </>\r\n )}\r\n <CommandItem onSelect={() => setIsPopoverOpen(false)} className=\"flex-1 justify-center cursor-pointer max-w-full\">\r\n {closeText}\r\n </CommandItem>\r\n </div>\r\n </CommandGroup>\r\n </CommandList>\r\n </Command>\r\n </PopoverContent>\r\n </Popover>\r\n );\r\n },\r\n);\r\n\r\nMultiSelect.displayName = \"MultiSelect\";\r\n\r\nexport { MultiSelect, type MultiSelectProps };\r\n"],"names":["multiSelectVariants","tv","MultiSelect","React","options","onValueChange","value","variant","disabled","defaultValue","placeholder","maxCount","modalPopover","className","moreText","clearText","closeText","selectAllText","noResultsText","loading","loadingText","props","ref","selectedValues","setSelectedValues","isPopoverOpen","setIsPopoverOpen","containerRef","isWrapped","setIsWrapped","handleInputKeyDown","event","newSelectedValues","toggleOption","option","handleClear","handleTogglePopover","prev","clearExtraOptions","toggleAll","allValues","Popover","jsx","PopoverTrigger","Button","cn","ChevronDown","jsxs","o","IconComponent","Badge","XMark","CircleXmark","Separator","Fragment","PopoverContent","Command","CommandInput","CommandList","CommandEmpty","CommandGroup","CommandItem","Check","isSelected","CommandSeparator"],"mappings":";;;;;;;;;;AAiBA,MAAMA,IAAsBC,EAAG;AAAA,EAC7B,MAAM;AAAA,EACN,UAAU;AAAA,IACR,SAAS;AAAA,MACP,SAAS;AAAA,MACT,WAAW;AAAA,MACX,aAAa;AAAA,MACb,UAAU;AAAA,IAAA;AAAA,EAEd;AAAA,EACA,iBAAiB;AAAA,IACf,SAAS;AAAA,EAAA;AAEb,CAAC,GAoGKC,KAAcC,EAAM;AAAA,EACxB,CACE;AAAA,IACE,SAAAC;AAAA,IACA,eAAAC;AAAA,IACA,OAAAC;AAAA,IACA,SAAAC;AAAA,IACA,UAAAC;AAAA,IACA,cAAAC,IAAe,CAAC;AAAA,IAChB,aAAAC,IAAc;AAAA,IACd,UAAAC,IAAW;AAAA,IACX,cAAAC,IAAe;AAAA;AAAA,IAEf,WAAAC;AAAA,IACA,UAAAC,IAAW;AAAA,IACX,WAAAC,IAAY;AAAA,IACZ,WAAAC,IAAY;AAAA,IACZ,eAAAC,IAAgB;AAAA,IAChB,eAAAC,IAAgB;AAAA,IAChB,SAAAC;AAAA,IACA,aAAAC,IAAc;AAAA,IACd,GAAGC;AAAA,KAELC,MACG;AACH,UAAM,CAACC,GAAgBC,CAAiB,IAAIrB,EAAM,SAAmBM,KAAgBH,CAAK,GACpF,CAACmB,GAAeC,CAAgB,IAAIvB,EAAM,SAAS,EAAK,GACxDwB,IAAexB,EAAM,OAAuB,IAAI,GAChD,CAACyB,GAAWC,CAAY,IAAI1B,EAAM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A,EAAA,GAVJA,EAAO,KAWzB;AAAA,YAEH,CAAA;AAAA,UAAA,GACH;AAAA,4BACC8B,IAAiB,EAAA;AAAA,UACjB,gBAAAtB,EAAAkB,GAAA,EACC,UAAC,gBAAAb,EAAA,OAAA,EAAI,WAAU,qCACZ,UAAA;AAAA,YAAexB,EAAA,SAAS,KAErB,gBAAAwB,EAAAO,GAAA,EAAA,UAAA;AAAA,cAAA,gBAAAZ,EAACmB,GAAY,EAAA,UAAU1B,GAAa,WAAU,wCAC3C,UACHpB,GAAA;AAAA,cACC,gBAAA2B,EAAAW,GAAA,EAAU,aAAY,YAAW,WAAU,sBAAsB,CAAA;AAAA,YAAA,GACpE;AAAA,YAEF,gBAAAX,EAACmB,KAAY,UAAU,MAAMnC,EAAiB,EAAK,GAAG,WAAU,mDAC7D,UACHV,EAAA,CAAA;AAAA,UAAA,EAAA,CACF,EACF,CAAA;AAAA,QAAA,EACF,CAAA;AAAA,MAAA,EAAA,CACF,EACF,CAAA;AAAA,IAAA,GACF;AAAA,EAAA;AAGN;AAEAd,GAAY,cAAc;"}
|
package/dist/select.es.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"select.es.js","sources":["../src/components/select/Select.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { Check, ChevronDown, ChevronUp, XMark } from \"@trsys-tech/matrix-icons\";\nimport * as SelectPrimitive from \"@radix-ui/react-select\";\nimport type { SelectValueProps, SelectGroupProps } from \"@radix-ui/react-select\";\n\nimport { cn } from \"../../lib/utils\";\n\ntype ClearSelectContextValue = {\n onClear: () => void;\n value: string | undefined;\n};\n\nconst SelectContext = React.createContext<ClearSelectContextValue>({ onClear: () => {}, value: undefined });\n\nconst Select = ({ onValueChange, value, ...props }: SelectPrimitive.SelectProps) => {\n const onClear = () => {\n onValueChange?.(\"\");\n };\n\n return (\n <SelectContext.Provider value={{ onClear, value }}>\n <SelectPrimitive.Root {...props} value={value} onValueChange={onValueChange} />\n </SelectContext.Provider>\n );\n};\nSelect.displayName = SelectPrimitive.Root.displayName;\ntype SelectProps = React.ComponentProps<typeof Select>;\n\nconst SelectGroup = SelectPrimitive.Group;\n\nconst SelectValue = SelectPrimitive.Value;\n\ntype SelectTriggerProps = React.ComponentProps<typeof SelectPrimitive.Trigger> & {\n clearable?: boolean;\n};\n\nconst SelectTrigger = React.forwardRef<React.ElementRef<typeof SelectPrimitive.Trigger>, SelectTriggerProps>(\n ({ className, children, clearable, ...props }: SelectTriggerProps, ref) => {\n const { onClear, value } = React.useContext(SelectContext);\n\n const handlePointerDown = (e: React.PointerEvent) => {\n e.stopPropagation();\n };\n\n return (\n <SelectPrimitive.Trigger\n ref={ref}\n className={cn(\n \"group flex h-8 w-full items-center justify-between whitespace-nowrap rounded-sm border border-input bg-transparent px-3 py-2 text-sm ring-offset-background data-[placeholder]:text-muted-foreground hover:border hover:border-primary focus:border focus:border-primary focus:outline-none focus:ring focus:ring-primary-100 disabled:cursor-not-allowed disabled:bg-gray-100 disabled:text-text-300 disabled:border-none [&>span]:line-clamp-1 [&_svg]:disabled:text-text-300\",\n className,\n )}\n data-value={value}\n {...props}\n >\n {children}\n <div className=\"flex items-center gap-2\">\n {clearable && value ? (\n <SelectPrimitive.Icon asChild onPointerDown={handlePointerDown} onClickCapture={onClear}>\n <XMark className=\"h-4.5 w-4.5\" />\n </SelectPrimitive.Icon>\n ) : null}\n <SelectPrimitive.Icon asChild>\n <ChevronDown className=\"h-4.5 w-4.5 text-primary group-data-[state=open]:rotate-180 transition-transform\" />\n </SelectPrimitive.Icon>\n </div>\n </SelectPrimitive.Trigger>\n );\n },\n);\nSelectTrigger.displayName = SelectPrimitive.Trigger.displayName;\n// type SelectTriggerProps = React.ComponentProps<typeof SelectTrigger>;\n\nconst SelectScrollUpButton = React.forwardRef<\n React.ElementRef<typeof SelectPrimitive.ScrollUpButton>,\n React.ComponentPropsWithoutRef<typeof SelectPrimitive.ScrollUpButton>\n>(({ className, ...props }, ref) => (\n <SelectPrimitive.ScrollUpButton ref={ref} className={cn(\"flex cursor-default items-center justify-center py-1\", className)} {...props}>\n <ChevronUp />\n </SelectPrimitive.ScrollUpButton>\n));\nSelectScrollUpButton.displayName = SelectPrimitive.ScrollUpButton.displayName;\ntype SelectScrollUpButtonProps = React.ComponentProps<typeof SelectScrollUpButton>;\n\nconst SelectScrollDownButton = React.forwardRef<\n React.ElementRef<typeof SelectPrimitive.ScrollDownButton>,\n React.ComponentPropsWithoutRef<typeof SelectPrimitive.ScrollDownButton>\n>(({ className, ...props }, ref) => (\n <SelectPrimitive.ScrollDownButton ref={ref} className={cn(\"flex cursor-default items-center justify-center py-1\", className)} {...props}>\n <ChevronDown />\n </SelectPrimitive.ScrollDownButton>\n));\nSelectScrollDownButton.displayName = SelectPrimitive.ScrollDownButton.displayName;\ntype SelectScrollDownButtonProps = React.ComponentProps<typeof SelectScrollDownButton>;\n\nconst SelectContent = React.forwardRef<\n React.ElementRef<typeof SelectPrimitive.Content>,\n React.ComponentPropsWithoutRef<typeof SelectPrimitive.Content>\n>(({ className, children, position = \"popper\", ...props }, ref) => (\n <SelectPrimitive.Portal>\n <SelectPrimitive.Content\n ref={ref}\n className={cn(\n \"relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2\",\n position === \"popper\" &&\n \"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1 max-h-[--radix-select-content-available-height]\",\n className,\n )}\n position={position}\n {...props}\n >\n <SelectScrollUpButton />\n <SelectPrimitive.Viewport\n className={cn(\"p-1\", position === \"popper\" && \"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]\")}\n >\n {children}\n </SelectPrimitive.Viewport>\n <SelectScrollDownButton />\n </SelectPrimitive.Content>\n </SelectPrimitive.Portal>\n));\nSelectContent.displayName = SelectPrimitive.Content.displayName;\ntype SelectContentProps = React.ComponentProps<typeof SelectContent>;\n\nconst SelectLabel = React.forwardRef<React.ElementRef<typeof SelectPrimitive.Label>, React.ComponentPropsWithoutRef<typeof SelectPrimitive.Label>>(\n ({ className, ...props }, ref) => <SelectPrimitive.Label ref={ref} className={cn(\"px-2 py-1.5 text-sm font-semibold\", className)} {...props} />,\n);\nSelectLabel.displayName = SelectPrimitive.Label.displayName;\ntype SelectLabelProps = React.ComponentProps<typeof SelectLabel>;\n\nconst SelectItem = React.forwardRef<React.ElementRef<typeof SelectPrimitive.Item>, React.ComponentPropsWithoutRef<typeof SelectPrimitive.Item>>(\n ({ className, children, ...props }, ref) => (\n <SelectPrimitive.Item\n ref={ref}\n className={cn(\n \"relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-gray-200 data-[active=true]:bg-gray-300 data-[active=true]:font-bold data-[disabled]:pointer-events-none data-[disabled]:opacity-50\",\n className,\n )}\n {...props}\n >\n <span className=\"absolute right-2 flex h-3.5 w-3.5 items-center justify-center\">\n <SelectPrimitive.ItemIndicator>\n <Check className=\"h-4 w-4\" />\n </SelectPrimitive.ItemIndicator>\n </span>\n <SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>\n </SelectPrimitive.Item>\n ),\n);\nSelectItem.displayName = SelectPrimitive.Item.displayName;\ntype SelectItemProps = React.ComponentProps<typeof SelectItem>;\n\nconst SelectSeparator = React.forwardRef<\n React.ElementRef<typeof SelectPrimitive.Separator>,\n React.ComponentPropsWithoutRef<typeof SelectPrimitive.Separator>\n>(({ className, ...props }, ref) => <SelectPrimitive.Separator ref={ref} className={cn(\"-mx-1 my-1 h-px bg-muted\", className)} {...props} />);\nSelectSeparator.displayName = SelectPrimitive.Separator.displayName;\ntype SelectSeparatorProps = React.ComponentProps<typeof SelectSeparator>;\n\nexport {\n Select,\n SelectGroup,\n SelectValue,\n SelectTrigger,\n SelectContent,\n SelectLabel,\n SelectItem,\n SelectSeparator,\n SelectScrollUpButton,\n SelectScrollDownButton,\n type SelectProps,\n type SelectGroupProps,\n type SelectValueProps,\n type SelectTriggerProps,\n type SelectContentProps,\n type SelectLabelProps,\n type SelectItemProps,\n type SelectSeparatorProps,\n type SelectScrollUpButtonProps,\n type SelectScrollDownButtonProps,\n};\n"],"names":["SelectContext","React","Select","onValueChange","value","props","onClear","jsx","SelectPrimitive","SelectGroup","SelectValue","SelectTrigger","className","children","clearable","ref","handlePointerDown","e","jsxs","cn","XMark","ChevronDown","SelectScrollUpButton","ChevronUp","SelectScrollDownButton","SelectContent","position","SelectLabel","SelectItem","Check","SelectSeparator"],"mappings":";;;;;AAYA,MAAMA,IAAgBC,EAAM,cAAuC,EAAE,SAAS,MAAM;AAAC,GAAG,OAAO,QAAW,GAEpGC,IAAS,CAAC,EAAE,eAAAC,GAAe,OAAAC,GAAO,GAAGC,QAAyC;AAClF,QAAMC,IAAU,MAAM;AACpB,IAAAH,IAAgB,EAAE;AAAA,EACpB;AAEA,2BACGH,EAAc,UAAd,EAAuB,OAAO,EAAE,SAAAM,GAAS,OAAAF,KACxC,UAAA,gBAAAG,EAACC,EAAgB,MAAhB,EAAsB,GAAGH,GAAO,OAAAD,GAAc,eAAAD,EAA8B,CAAA,GAC/E;AAEJ;AACAD,EAAO,cAAcM,EAAgB,KAAK;AAG1C,MAAMC,IAAcD,EAAgB,OAE9BE,IAAcF,EAAgB,OAM9BG,IAAgBV,EAAM;AAAA,EAC1B,CAAC,EAAE,WAAAW,GAAW,UAAAC,GAAU,WAAAC,GAAW,GAAGT,KAA6BU,MAAQ;AACzE,UAAM,EAAE,SAAAT,GAAS,OAAAF,EAAA,IAAUH,EAAM,WAAWD,CAAa,GAEnDgB,IAAoB,CAACC,MAA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C,EAAgB,eAAhB,EACC,UAAA,gBAAAD,EAACsB,GAAM,EAAA,WAAU,UAAU,CAAA,EAC7B,CAAA,GACF;AAAA,QACC,gBAAAtB,EAAAC,EAAgB,UAAhB,EAA0B,UAAAK,EAAS,CAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAG1C;AACAe,EAAW,cAAcpB,EAAgB,KAAK;AAGxC,MAAAsB,IAAkB7B,EAAM,WAG5B,CAAC,EAAE,WAAAW,GAAW,GAAGP,EAAM,GAAGU,MAAQ,gBAAAR,EAACC,EAAgB,WAAhB,EAA0B,KAAAO,GAAU,WAAWI,EAAG,4BAA4BP,CAAS,GAAI,GAAGP,GAAO,CAAE;AAC5IyB,EAAgB,cAActB,EAAgB,UAAU;"}
|
|
1
|
+
{"version":3,"file":"select.es.js","sources":["../src/components/select/Select.tsx"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport { Check, ChevronDown, ChevronUp, XMark } from \"@trsys-tech/matrix-icons\";\nimport * as SelectPrimitive from \"@radix-ui/react-select\";\nimport type { SelectValueProps, SelectGroupProps } from \"@radix-ui/react-select\";\n\nimport { cn } from \"../../lib/utils\";\n\ntype ClearSelectContextValue = {\n onClear: () => void;\n value: string | undefined;\n};\n\nconst SelectContext = React.createContext<ClearSelectContextValue>({ onClear: () => {}, value: undefined });\n\nconst Select = ({ onValueChange, value, ...props }: SelectPrimitive.SelectProps) => {\n const onClear = () => {\n onValueChange?.(\"\");\n };\n\n return (\n <SelectContext.Provider value={{ onClear, value }}>\n <SelectPrimitive.Root {...props} value={value} onValueChange={onValueChange} />\n </SelectContext.Provider>\n );\n};\nSelect.displayName = SelectPrimitive.Root.displayName;\ntype SelectProps = React.ComponentProps<typeof Select>;\n\nconst SelectGroup = SelectPrimitive.Group;\n\nconst SelectValue = SelectPrimitive.Value;\n\ntype SelectTriggerProps = React.ComponentProps<typeof SelectPrimitive.Trigger> & {\n clearable?: boolean;\n};\n\nconst SelectTrigger = React.forwardRef<React.ElementRef<typeof SelectPrimitive.Trigger>, SelectTriggerProps>(\n ({ className, children, clearable, ...props }: SelectTriggerProps, ref) => {\n const { onClear, value } = React.useContext(SelectContext);\n\n const handlePointerDown = (e: React.PointerEvent) => {\n e.stopPropagation();\n };\n\n return (\n <SelectPrimitive.Trigger\n ref={ref}\n className={cn(\n \"group flex h-8 w-full items-center justify-between whitespace-nowrap rounded-sm border border-input bg-transparent px-3 py-2 text-sm ring-offset-background data-[placeholder]:text-muted-foreground hover:border hover:border-primary focus:border focus:border-primary focus:outline-none focus:ring focus:ring-primary-100 disabled:cursor-not-allowed disabled:bg-gray-100 disabled:text-text-300 disabled:border-none [&>span]:line-clamp-1 [&_svg]:disabled:text-text-300\",\n className,\n )}\n data-value={value}\n {...props}\n >\n {children}\n <div className=\"flex items-center gap-2\">\n {clearable && value ? (\n <SelectPrimitive.Icon asChild onPointerDown={handlePointerDown} onClickCapture={onClear}>\n <XMark className=\"h-4.5 w-4.5\" />\n </SelectPrimitive.Icon>\n ) : null}\n <SelectPrimitive.Icon asChild>\n <ChevronDown className=\"h-4.5 w-4.5 text-primary group-data-[state=open]:rotate-180 transition-transform\" />\n </SelectPrimitive.Icon>\n </div>\n </SelectPrimitive.Trigger>\n );\n },\n);\nSelectTrigger.displayName = SelectPrimitive.Trigger.displayName;\n// type SelectTriggerProps = React.ComponentProps<typeof SelectTrigger>;\n\nconst SelectScrollUpButton = React.forwardRef<\n React.ElementRef<typeof SelectPrimitive.ScrollUpButton>,\n React.ComponentPropsWithoutRef<typeof SelectPrimitive.ScrollUpButton>\n>(({ className, ...props }, ref) => (\n <SelectPrimitive.ScrollUpButton ref={ref} className={cn(\"flex cursor-default items-center justify-center py-1\", className)} {...props}>\n <ChevronUp />\n </SelectPrimitive.ScrollUpButton>\n));\nSelectScrollUpButton.displayName = SelectPrimitive.ScrollUpButton.displayName;\ntype SelectScrollUpButtonProps = React.ComponentProps<typeof SelectScrollUpButton>;\n\nconst SelectScrollDownButton = React.forwardRef<\n React.ElementRef<typeof SelectPrimitive.ScrollDownButton>,\n React.ComponentPropsWithoutRef<typeof SelectPrimitive.ScrollDownButton>\n>(({ className, ...props }, ref) => (\n <SelectPrimitive.ScrollDownButton ref={ref} className={cn(\"flex cursor-default items-center justify-center py-1\", className)} {...props}>\n <ChevronDown />\n </SelectPrimitive.ScrollDownButton>\n));\nSelectScrollDownButton.displayName = SelectPrimitive.ScrollDownButton.displayName;\ntype SelectScrollDownButtonProps = React.ComponentProps<typeof SelectScrollDownButton>;\n\nconst SelectContent = React.forwardRef<\n React.ElementRef<typeof SelectPrimitive.Content>,\n React.ComponentPropsWithoutRef<typeof SelectPrimitive.Content>\n>(({ className, children, position = \"popper\", ...props }, ref) => (\n <SelectPrimitive.Portal>\n <SelectPrimitive.Content\n ref={ref}\n className={cn(\n \"relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2\",\n position === \"popper\" &&\n \"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1 max-h-[--radix-select-content-available-height]\",\n className,\n )}\n position={position}\n {...props}\n >\n <SelectScrollUpButton />\n <SelectPrimitive.Viewport\n className={cn(\"p-1\", position === \"popper\" && \"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]\")}\n >\n {children}\n </SelectPrimitive.Viewport>\n <SelectScrollDownButton />\n </SelectPrimitive.Content>\n </SelectPrimitive.Portal>\n));\nSelectContent.displayName = SelectPrimitive.Content.displayName;\ntype SelectContentProps = React.ComponentProps<typeof SelectContent>;\n\nconst SelectLabel = React.forwardRef<React.ElementRef<typeof SelectPrimitive.Label>, React.ComponentPropsWithoutRef<typeof SelectPrimitive.Label>>(\n ({ className, ...props }, ref) => <SelectPrimitive.Label ref={ref} className={cn(\"px-2 py-1.5 text-sm font-semibold\", className)} {...props} />,\n);\nSelectLabel.displayName = SelectPrimitive.Label.displayName;\ntype SelectLabelProps = React.ComponentProps<typeof SelectLabel>;\n\nconst SelectItem = React.forwardRef<React.ElementRef<typeof SelectPrimitive.Item>, React.ComponentPropsWithoutRef<typeof SelectPrimitive.Item>>(\n ({ className, children, ...props }, ref) => (\n <SelectPrimitive.Item\n ref={ref}\n className={cn(\n \"relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-gray-200 data-[active=true]:bg-gray-300 data-[active=true]:font-bold data-[disabled]:pointer-events-none data-[disabled]:opacity-50\",\n className,\n )}\n {...props}\n >\n <span className=\"absolute right-2 flex h-3.5 w-3.5 items-center justify-center\">\n <SelectPrimitive.ItemIndicator>\n <Check className=\"h-4 w-4\" />\n </SelectPrimitive.ItemIndicator>\n </span>\n <SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>\n </SelectPrimitive.Item>\n ),\n);\nSelectItem.displayName = SelectPrimitive.Item.displayName;\ntype SelectItemProps = React.ComponentProps<typeof SelectItem>;\n\nconst SelectSeparator = React.forwardRef<\n React.ElementRef<typeof SelectPrimitive.Separator>,\n React.ComponentPropsWithoutRef<typeof SelectPrimitive.Separator>\n>(({ className, ...props }, ref) => <SelectPrimitive.Separator ref={ref} className={cn(\"-mx-1 my-1 h-px bg-muted\", className)} {...props} />);\nSelectSeparator.displayName = SelectPrimitive.Separator.displayName;\ntype SelectSeparatorProps = React.ComponentProps<typeof SelectSeparator>;\n\nexport {\n Select,\n SelectGroup,\n SelectValue,\n SelectTrigger,\n SelectContent,\n SelectLabel,\n SelectItem,\n SelectSeparator,\n SelectScrollUpButton,\n SelectScrollDownButton,\n type SelectProps,\n type SelectGroupProps,\n type SelectValueProps,\n type SelectTriggerProps,\n type SelectContentProps,\n type SelectLabelProps,\n type SelectItemProps,\n type SelectSeparatorProps,\n type SelectScrollUpButtonProps,\n type SelectScrollDownButtonProps,\n};\n"],"names":["SelectContext","React","Select","onValueChange","value","props","onClear","jsx","SelectPrimitive","SelectGroup","SelectValue","SelectTrigger","className","children","clearable","ref","handlePointerDown","e","jsxs","cn","XMark","ChevronDown","SelectScrollUpButton","ChevronUp","SelectScrollDownButton","SelectContent","position","SelectLabel","SelectItem","Check","SelectSeparator"],"mappings":";;;;;AAcA,MAAMA,IAAgBC,EAAM,cAAuC,EAAE,SAAS,MAAM;AAAC,GAAG,OAAO,QAAW,GAEpGC,IAAS,CAAC,EAAE,eAAAC,GAAe,OAAAC,GAAO,GAAGC,QAAyC;AAClF,QAAMC,IAAU,MAAM;AACpB,IAAAH,IAAgB,EAAE;AAAA,EACpB;AAEA,2BACGH,EAAc,UAAd,EAAuB,OAAO,EAAE,SAAAM,GAAS,OAAAF,KACxC,UAAA,gBAAAG,EAACC,EAAgB,MAAhB,EAAsB,GAAGH,GAAO,OAAAD,GAAc,eAAAD,EAA8B,CAAA,GAC/E;AAEJ;AACAD,EAAO,cAAcM,EAAgB,KAAK;AAG1C,MAAMC,IAAcD,EAAgB,OAE9BE,IAAcF,EAAgB,OAM9BG,IAAgBV,EAAM;AAAA,EAC1B,CAAC,EAAE,WAAAW,GAAW,UAAAC,GAAU,WAAAC,GAAW,GAAGT,KAA6BU,MAAQ;AACzE,UAAM,EAAE,SAAAT,GAAS,OAAAF,EAAA,IAAUH,EAAM,WAAWD,CAAa,GAEnDgB,IAAoB,CAACC,MAA0B;AACnD,MAAAA,EAAE,gBAAgB;AAAA,IACpB;AAGE,WAAA,gBAAAC;AAAA,MAACV,EAAgB;AAAA,MAAhB;AAAA,QACC,KAAAO;AAAA,QACA,WAAWI;AAAA,UACT;AAAA,UACAP;AAAA,QACF;AAAA,QACA,cAAYR;AAAA,QACX,GAAGC;AAAA,QAEH,UAAA;AAAA,UAAA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