@trsys-tech/matrix-library 1.0.1-canary-4 → 1.0.2
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/badge.es.js +19 -25
- package/dist/badge.es.js.map +1 -1
- package/dist/components/badge/Badge.d.ts +41 -112
- package/dist/components/badge/Badge.d.ts.map +1 -1
- package/dist/components/icon-botton/IconButton.d.ts.map +1 -1
- package/dist/components/status/Status.d.ts +151 -0
- package/dist/components/status/Status.d.ts.map +1 -0
- package/dist/iconbutton.es.js +5 -5
- package/dist/iconbutton.es.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.es.js +50 -48
- package/dist/index.es.js.map +1 -1
- package/dist/multiselect.es.js +39 -39
- package/dist/multiselect.es.js.map +1 -1
- package/dist/status.es.js +34 -0
- package/dist/status.es.js.map +1 -0
- package/dist/styles.css +1 -1
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { Accordion as t, AccordionContent as a, AccordionItem as i, AccordionTrigger as m } from "./accordion.es.js";
|
|
3
3
|
import { Avatar as p, AvatarFallback as l, AvatarImage as x } from "./avatar.es.js";
|
|
4
4
|
import { Badge as d } from "./badge.es.js";
|
|
5
|
-
import { Breadcrumb as
|
|
5
|
+
import { Breadcrumb as u, BreadcrumbEllipsis as c, BreadcrumbItem as f, BreadcrumbLink as C, BreadcrumbList as g, BreadcrumbPage as D, BreadcrumbSeparator as s } from "./breadcrumb.es.js";
|
|
6
6
|
import { Button as T, buttonVariants as F } from "./button.es.js";
|
|
7
7
|
import { Calendar as h } from "./calendar.es.js";
|
|
8
8
|
import { Card as w, CardContent as A, CardDescription as I, CardFooter as B, CardHeader as G, CardTitle as v } from "./card.es.js";
|
|
@@ -12,7 +12,7 @@ import { Collapsible as O, CollapsibleContent as V, CollapsibleTrigger as z } fr
|
|
|
12
12
|
import { Combobox as j } from "./combobox.es.js";
|
|
13
13
|
import { Command as J, CommandDialog as K, CommandEmpty as N, CommandGroup as Q, CommandInput as W, CommandItem as X, CommandList as Y, CommandSeparator as Z, CommandShortcut as _ } from "./command.es.js";
|
|
14
14
|
import { ConfirmProvider as ee, useConfirm as re } from "./confirm.es.js";
|
|
15
|
-
import { ContextMenu as te, ContextMenuCheckboxItem as ae, ContextMenuContent as ie, ContextMenuGroup as me, ContextMenuItem as ne, ContextMenuLabel as pe, ContextMenuPortal as le, ContextMenuRadioGroup as xe, ContextMenuRadioItem as Se, ContextMenuSeparator as de, ContextMenuShortcut as be, ContextMenuSub as
|
|
15
|
+
import { ContextMenu as te, ContextMenuCheckboxItem as ae, ContextMenuContent as ie, ContextMenuGroup as me, ContextMenuItem as ne, ContextMenuLabel as pe, ContextMenuPortal as le, ContextMenuRadioGroup as xe, ContextMenuRadioItem as Se, ContextMenuSeparator as de, ContextMenuShortcut as be, ContextMenuSub as ue, ContextMenuSubContent as ce, ContextMenuSubTrigger as fe, ContextMenuTrigger as Ce } from "./contextmenu.es.js";
|
|
16
16
|
import { DataGrid as De, DataGridActionBar as se, DataGridContent as Me, DeleteAction as Te, ExtraActions as Fe, FreezeAction as Pe, PrintAction as he, RefreshAction as ke, SearchAction as we, dataGridDefaultTheme as Ae, useDataGrid as Ie } from "./datagrid.es.js";
|
|
17
17
|
import { DatePicker as Ge } from "./datepicker.es.js";
|
|
18
18
|
import { DateRangePicker as Re } from "./daterangepicker.es.js";
|
|
@@ -21,7 +21,7 @@ import { Dialog as Ee, DialogClose as Oe, DialogContent as Ve, DialogDescription
|
|
|
21
21
|
import { Drawer as We, DrawerContent as Xe, DrawerMain as Ye } from "./drawer.es.js";
|
|
22
22
|
import { Duration as _e } from "./duration.es.js";
|
|
23
23
|
import { SwipableDrawer as er, SwipableDrawerClose as rr, SwipableDrawerContent as or, SwipableDrawerDescription as tr, SwipableDrawerFooter as ar, SwipableDrawerHeader as ir, SwipableDrawerTitle as mr, SwipableDrawerTrigger as nr } from "./swipabledrawer.es.js";
|
|
24
|
-
import { Form as lr, FormControl as xr, FormDescription as Sr, FormField as dr, FormItem as br, FormLabel as
|
|
24
|
+
import { Form as lr, FormControl as xr, FormDescription as Sr, FormField as dr, FormItem as br, FormLabel as ur, FormMessage as cr } from "./form.es.js";
|
|
25
25
|
import { FormCheckbox as Cr } from "./formcheckbox.es.js";
|
|
26
26
|
import { FormCombobox as Dr } from "./formcombobox.es.js";
|
|
27
27
|
import { FormDatePicker as Mr } from "./formdatepicker.es.js";
|
|
@@ -42,26 +42,27 @@ import { Popover as Yr, PopoverAnchor as Zr, PopoverContent as _r, PopoverTrigge
|
|
|
42
42
|
import { Progress as ro } from "./progress.es.js";
|
|
43
43
|
import { RadioGroup as to, RadioGroupItem as ao } from "./radiogroup.es.js";
|
|
44
44
|
import { Rating as mo } from "./rating.es.js";
|
|
45
|
-
import { Select as po, SelectContent as lo, SelectGroup as xo, SelectItem as So, SelectLabel as bo, SelectScrollDownButton as
|
|
45
|
+
import { Select as po, SelectContent as lo, SelectGroup as xo, SelectItem as So, SelectLabel as bo, SelectScrollDownButton as uo, SelectScrollUpButton as co, SelectSeparator as fo, SelectTrigger as Co, SelectValue as go } from "./select.es.js";
|
|
46
46
|
import { Separator as so } from "./separator.es.js";
|
|
47
47
|
import { Sheet as To, SheetClose as Fo, SheetContent as Po, SheetDescription as ho, SheetFooter as ko, SheetHeader as wo, SheetOverlay as Ao, SheetPortal as Io, SheetTitle as Bo, SheetTrigger as Go } from "./sheet.es.js";
|
|
48
48
|
import { Sidebar as Ro, SidebarContent as Lo, SidebarFooter as Ho, SidebarGroup as yo, SidebarGroupAction as Eo, SidebarGroupContent as Oo, SidebarGroupLabel as Vo, SidebarHeader as zo, SidebarInset as Uo, SidebarMenu as jo, SidebarMenuAction as qo, SidebarMenuBadge as Jo, SidebarMenuButton as Ko, SidebarMenuItem as No, SidebarMenuSkeleton as Qo, SidebarMenuSub as Wo, SidebarMenuSubButton as Xo, SidebarMenuSubItem as Yo, SidebarProvider as Zo, SidebarRail as _o, SidebarSeparator as $o, SidebarTrigger as et, useSidebar as rt } from "./sidebar.es.js";
|
|
49
49
|
import { Skeleton as tt } from "./skeleton.es.js";
|
|
50
|
-
import {
|
|
51
|
-
import {
|
|
52
|
-
import {
|
|
53
|
-
import {
|
|
54
|
-
import {
|
|
55
|
-
import {
|
|
56
|
-
import {
|
|
57
|
-
import {
|
|
58
|
-
import {
|
|
59
|
-
import {
|
|
60
|
-
import {
|
|
61
|
-
import {
|
|
62
|
-
import {
|
|
63
|
-
import {
|
|
64
|
-
import {
|
|
50
|
+
import { Status as it } from "./status.es.js";
|
|
51
|
+
import { Switch as nt } from "./switch.es.js";
|
|
52
|
+
import { Tabs as lt, TabsContent as xt, TabsList as St, TabsTrigger as dt } from "./tabs.es.js";
|
|
53
|
+
import { TextField as ut } from "./textfield.es.js";
|
|
54
|
+
import { Textarea as ft } from "./textarea.es.js";
|
|
55
|
+
import { Toast as gt } from "./toast.es.js";
|
|
56
|
+
import { toast as st } from "./use-toast.es.js";
|
|
57
|
+
import { Tooltip as Tt, TooltipContent as Ft, TooltipProvider as Pt, TooltipTrigger as ht } from "./tooltip.es.js";
|
|
58
|
+
import { useIsMobile as wt } from "./use-mobile.es.js";
|
|
59
|
+
import { cn as It } from "./utils.es.js";
|
|
60
|
+
import { DesktopDatePicker as Gt } from "./desktopdatepicker.es.js";
|
|
61
|
+
import { DesktopDateRangePicker as Rt } from "./desktopdaterangepicker.es.js";
|
|
62
|
+
import { DesktopTimePicker as Ht } from "./desktoptimepicker.es.js";
|
|
63
|
+
import { MobileDatePicker as Et } from "./mobiledatepicker.es.js";
|
|
64
|
+
import { MobileDateRangePicker as Vt } from "./mobiledaterangepicker.es.js";
|
|
65
|
+
import { MobileTimePicker as Ut } from "./mobiletimepicker.es.js";
|
|
65
66
|
export {
|
|
66
67
|
t as Accordion,
|
|
67
68
|
a as AccordionContent,
|
|
@@ -71,8 +72,8 @@ export {
|
|
|
71
72
|
l as AvatarFallback,
|
|
72
73
|
x as AvatarImage,
|
|
73
74
|
d as Badge,
|
|
74
|
-
|
|
75
|
-
|
|
75
|
+
u as Breadcrumb,
|
|
76
|
+
c as BreadcrumbEllipsis,
|
|
76
77
|
f as BreadcrumbItem,
|
|
77
78
|
C as BreadcrumbLink,
|
|
78
79
|
g as BreadcrumbList,
|
|
@@ -113,8 +114,8 @@ export {
|
|
|
113
114
|
Se as ContextMenuRadioItem,
|
|
114
115
|
de as ContextMenuSeparator,
|
|
115
116
|
be as ContextMenuShortcut,
|
|
116
|
-
|
|
117
|
-
|
|
117
|
+
ue as ContextMenuSub,
|
|
118
|
+
ce as ContextMenuSubContent,
|
|
118
119
|
fe as ContextMenuSubTrigger,
|
|
119
120
|
Ce as ContextMenuTrigger,
|
|
120
121
|
De as DataGrid,
|
|
@@ -123,9 +124,9 @@ export {
|
|
|
123
124
|
Ge as DatePicker,
|
|
124
125
|
Re as DateRangePicker,
|
|
125
126
|
Te as DeleteAction,
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
127
|
+
Gt as DesktopDatePicker,
|
|
128
|
+
Rt as DesktopDateRangePicker,
|
|
129
|
+
Ht as DesktopTimePicker,
|
|
129
130
|
Ee as Dialog,
|
|
130
131
|
Oe as DialogClose,
|
|
131
132
|
Ve as DialogContent,
|
|
@@ -152,8 +153,8 @@ export {
|
|
|
152
153
|
dr as FormField,
|
|
153
154
|
wr as FormInput,
|
|
154
155
|
br as FormItem,
|
|
155
|
-
|
|
156
|
-
|
|
156
|
+
ur as FormLabel,
|
|
157
|
+
cr as FormMessage,
|
|
157
158
|
Ir as FormMultiSelect,
|
|
158
159
|
Gr as FormRating,
|
|
159
160
|
Rr as FormSelect,
|
|
@@ -163,9 +164,9 @@ export {
|
|
|
163
164
|
Pe as FreezeAction,
|
|
164
165
|
Ur as IconButton,
|
|
165
166
|
qr as Label,
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
167
|
+
Et as MobileDatePicker,
|
|
168
|
+
Vt as MobileDateRangePicker,
|
|
169
|
+
Ut as MobileTimePicker,
|
|
169
170
|
Kr as Modal,
|
|
170
171
|
Nr as ModalFooter,
|
|
171
172
|
Wr as MultiSelect,
|
|
@@ -185,8 +186,8 @@ export {
|
|
|
185
186
|
xo as SelectGroup,
|
|
186
187
|
So as SelectItem,
|
|
187
188
|
bo as SelectLabel,
|
|
188
|
-
|
|
189
|
-
|
|
189
|
+
uo as SelectScrollDownButton,
|
|
190
|
+
co as SelectScrollUpButton,
|
|
190
191
|
fo as SelectSeparator,
|
|
191
192
|
Co as SelectTrigger,
|
|
192
193
|
go as SelectValue,
|
|
@@ -224,6 +225,7 @@ export {
|
|
|
224
225
|
$o as SidebarSeparator,
|
|
225
226
|
et as SidebarTrigger,
|
|
226
227
|
tt as Skeleton,
|
|
228
|
+
it as Status,
|
|
227
229
|
er as SwipableDrawer,
|
|
228
230
|
rr as SwipableDrawerClose,
|
|
229
231
|
or as SwipableDrawerContent,
|
|
@@ -232,26 +234,26 @@ export {
|
|
|
232
234
|
ir as SwipableDrawerHeader,
|
|
233
235
|
mr as SwipableDrawerTitle,
|
|
234
236
|
nr as SwipableDrawerTrigger,
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
237
|
+
nt as Switch,
|
|
238
|
+
lt as Tabs,
|
|
239
|
+
xt as TabsContent,
|
|
240
|
+
St as TabsList,
|
|
241
|
+
dt as TabsTrigger,
|
|
242
|
+
ut as TextField,
|
|
243
|
+
ft as Textarea,
|
|
242
244
|
He as TimePicker,
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
245
|
+
gt as Toast,
|
|
246
|
+
Tt as Tooltip,
|
|
247
|
+
Ft as TooltipContent,
|
|
248
|
+
Pt as TooltipProvider,
|
|
249
|
+
ht as TooltipTrigger,
|
|
248
250
|
F as buttonVariants,
|
|
249
|
-
|
|
251
|
+
It as cn,
|
|
250
252
|
Ae as dataGridDefaultTheme,
|
|
251
|
-
|
|
253
|
+
st as toast,
|
|
252
254
|
re as useConfirm,
|
|
253
255
|
Ie as useDataGrid,
|
|
254
|
-
|
|
256
|
+
wt as useIsMobile,
|
|
255
257
|
rt as useSidebar
|
|
256
258
|
};
|
|
257
259
|
//# sourceMappingURL=index.es.js.map
|
package/dist/index.es.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.es.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.es.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/multiselect.es.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { jsxs as
|
|
1
|
+
import { jsxs as s, jsx as t, Fragment as S } from "react/jsx-runtime";
|
|
2
2
|
import * as a from "react";
|
|
3
3
|
import { tv as me } from "tailwind-variants";
|
|
4
|
-
import { XMark as I, CircleXmark as ae, ChevronDown as
|
|
4
|
+
import { XMark as I, CircleXmark as ae, ChevronDown as se, Check as D } from "@trsys-tech/matrix-icons";
|
|
5
5
|
import { cn as p } from "./utils.es.js";
|
|
6
|
-
import {
|
|
7
|
-
import { Button as
|
|
6
|
+
import { Status as T } from "./status.es.js";
|
|
7
|
+
import { Button as le } from "./button.es.js";
|
|
8
8
|
import { Separator as A } from "./separator.es.js";
|
|
9
9
|
import { Popover as oe, PopoverTrigger as ne, PopoverContent as ce } from "./popover.es.js";
|
|
10
10
|
import { Command as xe, CommandInput as ie, CommandList as de, CommandEmpty as ue, CommandGroup as R, CommandItem as y, CommandSeparator as pe } from "./command.es.js";
|
|
11
|
-
const
|
|
11
|
+
const K = me({
|
|
12
12
|
base: "mtx-flex mtx-gap-1 mtx-items-center mtx-py-0.5 mtx-px-2 mtx-rounded-xl",
|
|
13
13
|
variants: {
|
|
14
14
|
variant: {
|
|
@@ -27,12 +27,12 @@ const B = me({
|
|
|
27
27
|
value: k,
|
|
28
28
|
variant: C,
|
|
29
29
|
disabled: j,
|
|
30
|
-
defaultValue:
|
|
31
|
-
placeholder:
|
|
30
|
+
defaultValue: L = [],
|
|
31
|
+
placeholder: V = "Select options",
|
|
32
32
|
maxCount: u = 3,
|
|
33
|
-
modalPopover:
|
|
33
|
+
modalPopover: z = !1,
|
|
34
34
|
// asChild = false,
|
|
35
|
-
className:
|
|
35
|
+
className: B,
|
|
36
36
|
moreText: W = "more",
|
|
37
37
|
clearText: X = "Clear",
|
|
38
38
|
closeText: $ = "Close",
|
|
@@ -45,7 +45,7 @@ const B = me({
|
|
|
45
45
|
loadingText: b = "Loading...",
|
|
46
46
|
...J
|
|
47
47
|
}, Q) => {
|
|
48
|
-
const
|
|
48
|
+
const l = k !== void 0, [U, x] = a.useState(L), r = l ? k : U, [Y, i] = a.useState(!1), g = a.useRef(null), [Z, P] = a.useState(""), [F, M] = a.useState(!1), [n, w] = a.useState(
|
|
49
49
|
new Map(d.map((e) => [e.value, e]))
|
|
50
50
|
), _ = a.useCallback(
|
|
51
51
|
(e) => {
|
|
@@ -55,44 +55,44 @@ const B = me({
|
|
|
55
55
|
if (n.get(m.value) === void 0) {
|
|
56
56
|
w((N) => new Map(N).set(m.value, m));
|
|
57
57
|
const c = [...r, m.value];
|
|
58
|
-
|
|
58
|
+
l || x(c), o(c), P("");
|
|
59
59
|
}
|
|
60
60
|
} else if (e.key === "Enter")
|
|
61
61
|
i(!0);
|
|
62
62
|
else if (e.key === "Backspace" && !e.currentTarget.value) {
|
|
63
63
|
const m = [...r];
|
|
64
|
-
m.pop(),
|
|
64
|
+
m.pop(), l || x(m), o(m);
|
|
65
65
|
}
|
|
66
66
|
},
|
|
67
|
-
[f, o, n, r,
|
|
67
|
+
[f, o, n, r, l]
|
|
68
68
|
), E = a.useCallback(
|
|
69
69
|
(e) => {
|
|
70
70
|
const m = r.includes(e) ? r.filter((c) => c !== e) : [...r, e];
|
|
71
|
-
|
|
71
|
+
l || x(m), o(m);
|
|
72
72
|
},
|
|
73
|
-
[o, r,
|
|
73
|
+
[o, r, l]
|
|
74
74
|
), v = a.useCallback(() => {
|
|
75
|
-
|
|
76
|
-
}, [o, f, d,
|
|
75
|
+
l || x([]), o([]), f && w(new Map(d.map((e) => [e.value, e])));
|
|
76
|
+
}, [o, f, d, l]), ee = a.useCallback(() => {
|
|
77
77
|
i((e) => !e);
|
|
78
78
|
}, []), te = a.useCallback(() => {
|
|
79
79
|
const e = r.slice(0, u);
|
|
80
|
-
|
|
81
|
-
}, [u, r, o,
|
|
80
|
+
l || x(e), o(e);
|
|
81
|
+
}, [u, r, o, l]), re = a.useCallback(() => {
|
|
82
82
|
if (r.length === n.size)
|
|
83
83
|
v();
|
|
84
84
|
else {
|
|
85
85
|
const e = Array.from(n.keys());
|
|
86
|
-
|
|
86
|
+
l || x(e), o(e);
|
|
87
87
|
}
|
|
88
|
-
}, [v, o, n, r.length,
|
|
88
|
+
}, [v, o, n, r.length, l]);
|
|
89
89
|
return a.useEffect(() => {
|
|
90
90
|
w(new Map(d.map((e) => [e.value, e])));
|
|
91
91
|
}, [d]), a.useLayoutEffect(() => {
|
|
92
92
|
g.current && (g?.current?.firstChild?.offsetTop < g?.current?.lastChild?.offsetTop ? M(!0) : M(!1));
|
|
93
|
-
}, [r]), /* @__PURE__ */
|
|
93
|
+
}, [r]), /* @__PURE__ */ s(oe, { open: Y, onOpenChange: i, modal: z, children: [
|
|
94
94
|
/* @__PURE__ */ t(ne, { asChild: !0, children: /* @__PURE__ */ t(
|
|
95
|
-
|
|
95
|
+
le,
|
|
96
96
|
{
|
|
97
97
|
ref: Q,
|
|
98
98
|
variant: "text",
|
|
@@ -104,22 +104,22 @@ const B = me({
|
|
|
104
104
|
className: p(
|
|
105
105
|
"mtx-group mtx-flex mtx-max-h-14 mtx-h-8 mtx-w-full mtx-items-center mtx-justify-between mtx-whitespace-nowrap mtx-rounded-sm mtx-border mtx-border-input mtx-bg-transparent mtx-px-3 mtx-py-1.5 mtx-text-sm mtx-ring-offset-background data-[placeholder]:mtx-text-muted-foreground hover:mtx-border hover:mtx-border-primary hover:mtx-bg-transparent focus:mtx-border focus:mtx-border-primary focus:mtx-outline-none focus:mtx-ring focus:mtx-ring-primary-100 disabled:mtx-cursor-not-allowed disabled:mtx-bg-gray-100 disabled:mtx-text-text-300 disabled:mtx-border-gray-100 [&>span]:mtx-line-clamp-1 [&_svg]:disabled:mtx-text-text-300",
|
|
106
106
|
F && "mtx-h-auto",
|
|
107
|
-
|
|
107
|
+
B
|
|
108
108
|
),
|
|
109
109
|
"data-placeholder": r.length ? void 0 : "",
|
|
110
110
|
endIcon: /* @__PURE__ */ t(
|
|
111
|
-
|
|
111
|
+
se,
|
|
112
112
|
{
|
|
113
113
|
role: "button",
|
|
114
114
|
"aria-label": "Expand dropdown",
|
|
115
115
|
className: "!mtx-h-4.5 !mtx-w-4.5 mtx-cursor-pointer group-data-[state=open]:mtx-rotate-180 mtx-transition-transform"
|
|
116
116
|
}
|
|
117
117
|
),
|
|
118
|
-
children: /* @__PURE__ */ t(S, { children: r.length > 0 ? /* @__PURE__ */
|
|
119
|
-
/* @__PURE__ */
|
|
118
|
+
children: /* @__PURE__ */ t(S, { children: r.length > 0 ? /* @__PURE__ */ s("div", { className: "mtx-flex mtx-justify-between mtx-items-center mtx-w-full", children: [
|
|
119
|
+
/* @__PURE__ */ s("div", { className: "mtx-flex mtx-flex-wrap mtx-items-center mtx-gap-2", ref: g, children: [
|
|
120
120
|
r.slice(0, u).map((e) => {
|
|
121
121
|
const m = n.get(e), c = m?.icon;
|
|
122
|
-
return /* @__PURE__ */
|
|
122
|
+
return /* @__PURE__ */ s(T, { className: p(K({ variant: C }), { "text-gray-400 bg-gray-200": j || h }), children: [
|
|
123
123
|
/* @__PURE__ */ t(
|
|
124
124
|
I,
|
|
125
125
|
{
|
|
@@ -133,7 +133,7 @@ const B = me({
|
|
|
133
133
|
m?.label
|
|
134
134
|
] }, e);
|
|
135
135
|
}),
|
|
136
|
-
r.length > u && /* @__PURE__ */
|
|
136
|
+
r.length > u && /* @__PURE__ */ s(T, { className: p(K({ variant: C })), children: [
|
|
137
137
|
`+ ${r.length - u} ${W}`,
|
|
138
138
|
/* @__PURE__ */ t(
|
|
139
139
|
ae,
|
|
@@ -148,7 +148,7 @@ const B = me({
|
|
|
148
148
|
] }),
|
|
149
149
|
h && b ? b : null
|
|
150
150
|
] }),
|
|
151
|
-
/* @__PURE__ */
|
|
151
|
+
/* @__PURE__ */ s("div", { className: "mtx-flex mtx-items-center mtx-justify-between mtx-gap-1", children: [
|
|
152
152
|
/* @__PURE__ */ t(
|
|
153
153
|
I,
|
|
154
154
|
{
|
|
@@ -162,15 +162,15 @@ const B = me({
|
|
|
162
162
|
),
|
|
163
163
|
/* @__PURE__ */ t(A, { orientation: "vertical", className: "mtx-flex mtx-min-h-5 mtx-h-full" })
|
|
164
164
|
] })
|
|
165
|
-
] }) : /* @__PURE__ */ t(S, { children: h && b ? b :
|
|
165
|
+
] }) : /* @__PURE__ */ t(S, { children: h && b ? b : V }) })
|
|
166
166
|
}
|
|
167
167
|
) }),
|
|
168
|
-
/* @__PURE__ */ t(ce, { className: "mtx-w-auto mtx-p-0", align: "start", onEscapeKeyDown: () => i(!1), children: /* @__PURE__ */
|
|
168
|
+
/* @__PURE__ */ t(ce, { className: "mtx-w-auto mtx-p-0", align: "start", onEscapeKeyDown: () => i(!1), children: /* @__PURE__ */ s(xe, { className: "mtx-w-[--radix-popper-anchor-width] mtx-max-h-[--radix-popper-available-height]", children: [
|
|
169
169
|
/* @__PURE__ */ t(ie, { placeholder: q, onKeyDown: _, value: Z, onValueChange: P }),
|
|
170
|
-
/* @__PURE__ */
|
|
170
|
+
/* @__PURE__ */ s(de, { className: "", children: [
|
|
171
171
|
/* @__PURE__ */ t(ue, { children: O }),
|
|
172
|
-
/* @__PURE__ */
|
|
173
|
-
H && /* @__PURE__ */
|
|
172
|
+
/* @__PURE__ */ s(R, { children: [
|
|
173
|
+
H && /* @__PURE__ */ s(y, { onSelect: re, className: "mtx-cursor-pointer", children: [
|
|
174
174
|
/* @__PURE__ */ t(
|
|
175
175
|
"div",
|
|
176
176
|
{
|
|
@@ -181,7 +181,7 @@ const B = me({
|
|
|
181
181
|
children: /* @__PURE__ */ t(D, { className: "mtx-h-4.5 mtx-w-4.5" })
|
|
182
182
|
}
|
|
183
183
|
),
|
|
184
|
-
/* @__PURE__ */
|
|
184
|
+
/* @__PURE__ */ s("span", { children: [
|
|
185
185
|
"(",
|
|
186
186
|
G,
|
|
187
187
|
")"
|
|
@@ -189,7 +189,7 @@ const B = me({
|
|
|
189
189
|
] }, "all"),
|
|
190
190
|
Array.from(n.values()).map((e) => {
|
|
191
191
|
const m = r.includes(e.value);
|
|
192
|
-
return /* @__PURE__ */
|
|
192
|
+
return /* @__PURE__ */ s(y, { onSelect: () => E(e.value), className: "mtx-cursor-pointer", children: [
|
|
193
193
|
/* @__PURE__ */ t(
|
|
194
194
|
"div",
|
|
195
195
|
{
|
|
@@ -206,8 +206,8 @@ const B = me({
|
|
|
206
206
|
})
|
|
207
207
|
] }),
|
|
208
208
|
/* @__PURE__ */ t(pe, {}),
|
|
209
|
-
/* @__PURE__ */ t(R, { children: /* @__PURE__ */
|
|
210
|
-
r.length > 0 && /* @__PURE__ */
|
|
209
|
+
/* @__PURE__ */ t(R, { children: /* @__PURE__ */ s("div", { className: "mtx-flex mtx-items-center mtx-justify-between", children: [
|
|
210
|
+
r.length > 0 && /* @__PURE__ */ s(S, { children: [
|
|
211
211
|
/* @__PURE__ */ t(y, { onSelect: v, className: "mtx-flex-1 mtx-justify-center mtx-cursor-pointer", children: X }),
|
|
212
212
|
/* @__PURE__ */ t(A, { orientation: "vertical", className: "mtx-flex mtx-min-h-6 mtx-h-full" })
|
|
213
213
|
] }),
|
|
@@ -1 +1 @@
|
|
|
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: \"mtx-flex mtx-gap-1 mtx-items-center mtx-py-0.5 mtx-px-2 mtx-rounded-xl\",\r\n variants: {\r\n variant: {\r\n default: \"mtx-border-none mtx-shadow-none mtx-bg-primary-50 mtx-text-primary hover:mtx-bg-primary-50\",\r\n secondary: \"mtx-border-foreground/10 mtx-bg-secondary mtx-text-secondary-foreground hover:mtx-bg-secondary/80\",\r\n destructive: \"mtx-border-transparent mtx-bg-destructive mtx-text-destructive-foreground hover:mtx-bg-destructive/80\",\r\n inverted: \"mtx-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<T extends string | number>\r\n extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, \"value\" | \"defaultValue\">,\r\n 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 * *Important: Use a constant Array*\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: T;\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: T[]) => void;\r\n\r\n /**\r\n * selected values in the multi-select component.\r\n */\r\n value?: T[];\r\n\r\n /** The default selected values when the component mounts. */\r\n defaultValue?: T[];\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 * Whether to show the select all option or not\r\n */\r\n showSelectAll?: boolean;\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 in the search input.\r\n */\r\n searchText?: string;\r\n\r\n /**\r\n * If true, a new option will be added when the user submits a search query if it doesn't already exist.\r\n * Optional, defaults to false.\r\n */\r\n addOptionOnSearchNotFound?: boolean;\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 = <T extends string | number>(\r\n {\r\n options: _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 searchText = \"Search...\",\r\n addOptionOnSearchNotFound = false,\r\n showSelectAll = true,\r\n loading,\r\n loadingText = \"Loading...\",\r\n ...props\r\n }: MultiSelectProps<T>,\r\n ref: React.ForwardedRef<HTMLButtonElement>,\r\n) => {\r\n const isControlled = value !== undefined;\r\n const [internalSelectedValues, setInternalSelectedValues] = React.useState<T[]>(defaultValue);\r\n const selectedValues = isControlled ? value : internalSelectedValues;\r\n const [isPopoverOpen, setIsPopoverOpen] = React.useState(false);\r\n const containerRef = React.useRef<HTMLDivElement>(null);\r\n const [searchValue, setSearchValue] = React.useState(\"\");\r\n const [isWrapped, setIsWrapped] = React.useState(false);\r\n const [options, setOptions] = React.useState<Map<T, MultiSelectProps<T>[\"options\"][number]>>(\r\n new Map(_options.map(option => [option.value, option])),\r\n );\r\n\r\n const handleInputKeyDown = React.useCallback(\r\n (event: React.KeyboardEvent<HTMLInputElement>) => {\r\n if (event.key === \"Enter\" && addOptionOnSearchNotFound) {\r\n setIsPopoverOpen(true);\r\n event.preventDefault();\r\n event.stopPropagation();\r\n if (!event.currentTarget.value) return;\r\n const newOption = { value: event.currentTarget.value as T, label: event.currentTarget.value };\r\n if (options.get(newOption.value) === undefined) {\r\n setOptions(prev => {\r\n return new Map(prev).set(newOption.value, newOption);\r\n });\r\n const newSelectedValues = [...selectedValues, newOption.value];\r\n if (!isControlled) {\r\n setInternalSelectedValues(newSelectedValues);\r\n }\r\n onValueChange(newSelectedValues);\r\n setSearchValue(\"\");\r\n }\r\n } else 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 if (!isControlled) {\r\n setInternalSelectedValues(newSelectedValues);\r\n }\r\n onValueChange(newSelectedValues);\r\n }\r\n },\r\n [addOptionOnSearchNotFound, onValueChange, options, selectedValues, isControlled],\r\n );\r\n\r\n const toggleOption = React.useCallback(\r\n (option: T) => {\r\n const newSelectedValues = selectedValues.includes(option) ? selectedValues.filter(value => value !== option) : [...selectedValues, option];\r\n if (!isControlled) {\r\n setInternalSelectedValues(newSelectedValues);\r\n }\r\n onValueChange(newSelectedValues);\r\n },\r\n [onValueChange, selectedValues, isControlled],\r\n );\r\n\r\n const handleClear = React.useCallback(() => {\r\n if (!isControlled) {\r\n setInternalSelectedValues([]);\r\n }\r\n onValueChange([]);\r\n if (addOptionOnSearchNotFound) {\r\n setOptions(new Map(_options.map(option => [option.value, option])));\r\n }\r\n }, [onValueChange, addOptionOnSearchNotFound, _options, isControlled]);\r\n\r\n const handleTogglePopover = React.useCallback(() => {\r\n setIsPopoverOpen(prev => !prev);\r\n }, []);\r\n\r\n const clearExtraOptions = React.useCallback(() => {\r\n const newSelectedValues = selectedValues.slice(0, maxCount);\r\n if (!isControlled) {\r\n setInternalSelectedValues(newSelectedValues);\r\n }\r\n onValueChange(newSelectedValues);\r\n }, [maxCount, selectedValues, onValueChange, isControlled]);\r\n\r\n const toggleAll = React.useCallback(() => {\r\n if (selectedValues.length === options.size) {\r\n handleClear();\r\n } else {\r\n const allValues = Array.from(options.keys());\r\n if (!isControlled) {\r\n setInternalSelectedValues(allValues);\r\n }\r\n onValueChange(allValues);\r\n }\r\n }, [handleClear, onValueChange, options, selectedValues.length, isControlled]);\r\n\r\n React.useEffect(() => {\r\n setOptions(new Map(_options.map(option => [option.value, option])));\r\n }, [_options]);\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 type=\"button\"\r\n {...props}\r\n onClick={handleTogglePopover}\r\n className={cn(\r\n \"mtx-group mtx-flex mtx-max-h-14 mtx-h-8 mtx-w-full mtx-items-center mtx-justify-between mtx-whitespace-nowrap mtx-rounded-sm mtx-border mtx-border-input mtx-bg-transparent mtx-px-3 mtx-py-1.5 mtx-text-sm mtx-ring-offset-background data-[placeholder]:mtx-text-muted-foreground hover:mtx-border hover:mtx-border-primary hover:mtx-bg-transparent focus:mtx-border focus:mtx-border-primary focus:mtx-outline-none focus:mtx-ring focus:mtx-ring-primary-100 disabled:mtx-cursor-not-allowed disabled:mtx-bg-gray-100 disabled:mtx-text-text-300 disabled:mtx-border-gray-100 [&>span]:mtx-line-clamp-1 [&_svg]:disabled:mtx-text-text-300\",\r\n isWrapped && \"mtx-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=\"!mtx-h-4.5 !mtx-w-4.5 mtx-cursor-pointer group-data-[state=open]:mtx-rotate-180 mtx-transition-transform\"\r\n />\r\n }\r\n >\r\n <>\r\n {selectedValues.length > 0 ? (\r\n <div className=\"mtx-flex mtx-justify-between mtx-items-center mtx-w-full\">\r\n <div className=\"mtx-flex mtx-flex-wrap mtx-items-center mtx-gap-2\" ref={containerRef}>\r\n {selectedValues.slice(0, maxCount).map(value => {\r\n const option = options.get(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=\"mtx-h-4 mtx-w-4 mtx-cursor-pointer\"\r\n onClick={event => {\r\n event.stopPropagation();\r\n toggleOption(value);\r\n }}\r\n />\r\n {IconComponent && <IconComponent className=\"mtx-h-4 mtx-w-4 mtx-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=\"mtx-ml-2 mtx-h-4.5 mtx-w-4.5 mtx-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=\"mtx-flex mtx-items-center mtx-justify-between mtx-gap-1\">\r\n <XMark\r\n role=\"button\"\r\n className=\"mtx-h-5 mtx-w-5 mtx-text-muted-foreground mtx-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=\"mtx-flex mtx-min-h-5 mtx-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=\"mtx-w-auto mtx-p-0\" align=\"start\" onEscapeKeyDown={() => setIsPopoverOpen(false)}>\r\n <Command className=\"mtx-w-[--radix-popper-anchor-width] mtx-max-h-[--radix-popper-available-height]\">\r\n <CommandInput placeholder={searchText} onKeyDown={handleInputKeyDown} value={searchValue} onValueChange={setSearchValue} />\r\n <CommandList className=\"\">\r\n <CommandEmpty>{noResultsText}</CommandEmpty>\r\n <CommandGroup>\r\n {showSelectAll && (\r\n <CommandItem key=\"all\" onSelect={toggleAll} className=\"mtx-cursor-pointer\">\r\n <div\r\n className={cn(\r\n \"mtx-mr-2 mtx-flex mtx-h-4.5 mtx-w-4.5 mtx-items-center mtx-justify-center mtx-rounded-sm mtx-border mtx-border-primary\",\r\n selectedValues.length === options.size ? \"mtx-bg-primary mtx-text-primary-foreground\" : \"mtx-opacity-50 [&_svg]:mtx-invisible\",\r\n )}\r\n >\r\n <Check className=\"mtx-h-4.5 mtx-w-4.5\" />\r\n </div>\r\n <span>({selectAllText})</span>\r\n </CommandItem>\r\n )}\r\n {Array.from(options.values()).map(option => {\r\n const isSelected = selectedValues.includes(option.value);\r\n return (\r\n <CommandItem key={option.value} onSelect={() => toggleOption(option.value)} className=\"mtx-cursor-pointer\">\r\n <div\r\n className={cn(\r\n \"mtx-mr-2 mtx-flex mtx-h-4.5 mtx-w-4.5 mtx-items-center mtx-justify-center mtx-rounded-sm mtx-border mtx-border-primary\",\r\n isSelected ? \"mtx-bg-primary mtx-text-primary-foreground\" : \"mtx-opacity-50 [&_svg]:mtx-invisible\",\r\n )}\r\n >\r\n <Check className=\"mtx-h-4.5 mtx-w-4.5\" />\r\n </div>\r\n {option.icon && <option.icon className=\"mtx-mr-2 mtx-h-4.5 mtx-w-4.5 mtx-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=\"mtx-flex mtx-items-center mtx-justify-between\">\r\n {selectedValues.length > 0 && (\r\n <>\r\n <CommandItem onSelect={handleClear} className=\"mtx-flex-1 mtx-justify-center mtx-cursor-pointer\">\r\n {clearText}\r\n </CommandItem>\r\n <Separator orientation=\"vertical\" className=\"mtx-flex mtx-min-h-6 mtx-h-full\" />\r\n </>\r\n )}\r\n <CommandItem onSelect={() => setIsPopoverOpen(false)} className=\"mtx-flex-1 mtx-justify-center mtx-cursor-pointer mtx-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\nconst ForwardedMultiSelect = React.forwardRef(MultiSelect) as (<T extends string | number>(\r\n props: MultiSelectProps<T> & { ref?: React.Ref<HTMLButtonElement> },\r\n) => React.ReactElement) & { displayName?: string };\r\n\r\nForwardedMultiSelect.displayName = \"MultiSelect\";\r\n\r\nexport { ForwardedMultiSelect as MultiSelect, type MultiSelectProps };\r\n"],"names":["multiSelectVariants","tv","MultiSelect","_options","onValueChange","value","variant","disabled","defaultValue","placeholder","maxCount","modalPopover","className","moreText","clearText","closeText","selectAllText","noResultsText","searchText","addOptionOnSearchNotFound","showSelectAll","loading","loadingText","props","ref","isControlled","internalSelectedValues","setInternalSelectedValues","React","selectedValues","isPopoverOpen","setIsPopoverOpen","containerRef","searchValue","setSearchValue","isWrapped","setIsWrapped","options","setOptions","option","handleInputKeyDown","event","newOption","prev","newSelectedValues","toggleOption","handleClear","handleTogglePopover","clearExtraOptions","toggleAll","allValues","Popover","jsx","PopoverTrigger","Button","cn","ChevronDown","jsxs","IconComponent","Badge","XMark","CircleXmark","Separator","Fragment","PopoverContent","Command","CommandInput","CommandList","CommandEmpty","CommandGroup","CommandItem","Check","isSelected","CommandSeparator","ForwardedMultiSelect"],"mappings":";;;;;;;;;;AAiBA,MAAMA,IAAsBC,GAAG;AAAA,EAC7B,MAAM;AAAA,EACN,UAAU;AAAA,IACR,SAAS;AAAA,MACP,SAAS;AAAA,MACT,WAAW;AAAA,MACX,aAAa;AAAA,MACb,UAAU;AAAA,IAAA;AAAA,EACZ;AAAA,EAEF,iBAAiB;AAAA,IACf,SAAS;AAAA,EAAA;AAEb,CAAC,GAwHKC,KAAc,CAClB;AAAA,EACE,SAASC;AAAA,EACT,eAAAC;AAAA,EACA,OAAAC;AAAA,EACA,SAAAC;AAAA,EACA,UAAAC;AAAA,EACA,cAAAC,IAAe,CAAA;AAAA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AAA,CACH;AAAA,QAAA,EAAA,CACF,EAAA,CACF;AAAA,MAAA,EAAA,CACF;AAAA,IAAA,EAAA,CACF,EAAA,CACF;AAAA,EAAA,GACF;AAEJ,GAEM2D,KAAuB9C,EAAM,WAAW1B,EAAW;AAIzDwE,GAAqB,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 { Status } from \"../status/Status\";\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: \"mtx-flex mtx-gap-1 mtx-items-center mtx-py-0.5 mtx-px-2 mtx-rounded-xl\",\r\n variants: {\r\n variant: {\r\n default: \"mtx-border-none mtx-shadow-none mtx-bg-primary-50 mtx-text-primary hover:mtx-bg-primary-50\",\r\n secondary: \"mtx-border-foreground/10 mtx-bg-secondary mtx-text-secondary-foreground hover:mtx-bg-secondary/80\",\r\n destructive: \"mtx-border-transparent mtx-bg-destructive mtx-text-destructive-foreground hover:mtx-bg-destructive/80\",\r\n inverted: \"mtx-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<T extends string | number>\r\n extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, \"value\" | \"defaultValue\">,\r\n 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 * *Important: Use a constant Array*\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: T;\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: T[]) => void;\r\n\r\n /**\r\n * selected values in the multi-select component.\r\n */\r\n value?: T[];\r\n\r\n /** The default selected values when the component mounts. */\r\n defaultValue?: T[];\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 * Whether to show the select all option or not\r\n */\r\n showSelectAll?: boolean;\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 in the search input.\r\n */\r\n searchText?: string;\r\n\r\n /**\r\n * If true, a new option will be added when the user submits a search query if it doesn't already exist.\r\n * Optional, defaults to false.\r\n */\r\n addOptionOnSearchNotFound?: boolean;\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 = <T extends string | number>(\r\n {\r\n options: _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 searchText = \"Search...\",\r\n addOptionOnSearchNotFound = false,\r\n showSelectAll = true,\r\n loading,\r\n loadingText = \"Loading...\",\r\n ...props\r\n }: MultiSelectProps<T>,\r\n ref: React.ForwardedRef<HTMLButtonElement>,\r\n) => {\r\n const isControlled = value !== undefined;\r\n const [internalSelectedValues, setInternalSelectedValues] = React.useState<T[]>(defaultValue);\r\n const selectedValues = isControlled ? value : internalSelectedValues;\r\n const [isPopoverOpen, setIsPopoverOpen] = React.useState(false);\r\n const containerRef = React.useRef<HTMLDivElement>(null);\r\n const [searchValue, setSearchValue] = React.useState(\"\");\r\n const [isWrapped, setIsWrapped] = React.useState(false);\r\n const [options, setOptions] = React.useState<Map<T, MultiSelectProps<T>[\"options\"][number]>>(\r\n new Map(_options.map(option => [option.value, option])),\r\n );\r\n\r\n const handleInputKeyDown = React.useCallback(\r\n (event: React.KeyboardEvent<HTMLInputElement>) => {\r\n if (event.key === \"Enter\" && addOptionOnSearchNotFound) {\r\n setIsPopoverOpen(true);\r\n event.preventDefault();\r\n event.stopPropagation();\r\n if (!event.currentTarget.value) return;\r\n const newOption = { value: event.currentTarget.value as T, label: event.currentTarget.value };\r\n if (options.get(newOption.value) === undefined) {\r\n setOptions(prev => {\r\n return new Map(prev).set(newOption.value, newOption);\r\n });\r\n const newSelectedValues = [...selectedValues, newOption.value];\r\n if (!isControlled) {\r\n setInternalSelectedValues(newSelectedValues);\r\n }\r\n onValueChange(newSelectedValues);\r\n setSearchValue(\"\");\r\n }\r\n } else 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 if (!isControlled) {\r\n setInternalSelectedValues(newSelectedValues);\r\n }\r\n onValueChange(newSelectedValues);\r\n }\r\n },\r\n [addOptionOnSearchNotFound, onValueChange, options, selectedValues, isControlled],\r\n );\r\n\r\n const toggleOption = React.useCallback(\r\n (option: T) => {\r\n const newSelectedValues = selectedValues.includes(option) ? selectedValues.filter(value => value !== option) : [...selectedValues, option];\r\n if (!isControlled) {\r\n setInternalSelectedValues(newSelectedValues);\r\n }\r\n onValueChange(newSelectedValues);\r\n },\r\n [onValueChange, selectedValues, isControlled],\r\n );\r\n\r\n const handleClear = React.useCallback(() => {\r\n if (!isControlled) {\r\n setInternalSelectedValues([]);\r\n }\r\n onValueChange([]);\r\n if (addOptionOnSearchNotFound) {\r\n setOptions(new Map(_options.map(option => [option.value, option])));\r\n }\r\n }, [onValueChange, addOptionOnSearchNotFound, _options, isControlled]);\r\n\r\n const handleTogglePopover = React.useCallback(() => {\r\n setIsPopoverOpen(prev => !prev);\r\n }, []);\r\n\r\n const clearExtraOptions = React.useCallback(() => {\r\n const newSelectedValues = selectedValues.slice(0, maxCount);\r\n if (!isControlled) {\r\n setInternalSelectedValues(newSelectedValues);\r\n }\r\n onValueChange(newSelectedValues);\r\n }, [maxCount, selectedValues, onValueChange, isControlled]);\r\n\r\n const toggleAll = React.useCallback(() => {\r\n if (selectedValues.length === options.size) {\r\n handleClear();\r\n } else {\r\n const allValues = Array.from(options.keys());\r\n if (!isControlled) {\r\n setInternalSelectedValues(allValues);\r\n }\r\n onValueChange(allValues);\r\n }\r\n }, [handleClear, onValueChange, options, selectedValues.length, isControlled]);\r\n\r\n React.useEffect(() => {\r\n setOptions(new Map(_options.map(option => [option.value, option])));\r\n }, [_options]);\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 type=\"button\"\r\n {...props}\r\n onClick={handleTogglePopover}\r\n className={cn(\r\n \"mtx-group mtx-flex mtx-max-h-14 mtx-h-8 mtx-w-full mtx-items-center mtx-justify-between mtx-whitespace-nowrap mtx-rounded-sm mtx-border mtx-border-input mtx-bg-transparent mtx-px-3 mtx-py-1.5 mtx-text-sm mtx-ring-offset-background data-[placeholder]:mtx-text-muted-foreground hover:mtx-border hover:mtx-border-primary hover:mtx-bg-transparent focus:mtx-border focus:mtx-border-primary focus:mtx-outline-none focus:mtx-ring focus:mtx-ring-primary-100 disabled:mtx-cursor-not-allowed disabled:mtx-bg-gray-100 disabled:mtx-text-text-300 disabled:mtx-border-gray-100 [&>span]:mtx-line-clamp-1 [&_svg]:disabled:mtx-text-text-300\",\r\n isWrapped && \"mtx-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=\"!mtx-h-4.5 !mtx-w-4.5 mtx-cursor-pointer group-data-[state=open]:mtx-rotate-180 mtx-transition-transform\"\r\n />\r\n }\r\n >\r\n <>\r\n {selectedValues.length > 0 ? (\r\n <div className=\"mtx-flex mtx-justify-between mtx-items-center mtx-w-full\">\r\n <div className=\"mtx-flex mtx-flex-wrap mtx-items-center mtx-gap-2\" ref={containerRef}>\r\n {selectedValues.slice(0, maxCount).map(value => {\r\n const option = options.get(value);\r\n const IconComponent = option?.icon;\r\n return (\r\n <Status key={value} className={cn(multiSelectVariants({ variant }), { \"text-gray-400 bg-gray-200\": disabled || loading })}>\r\n <XMark\r\n className=\"mtx-h-4 mtx-w-4 mtx-cursor-pointer\"\r\n onClick={event => {\r\n event.stopPropagation();\r\n toggleOption(value);\r\n }}\r\n />\r\n {IconComponent && <IconComponent className=\"mtx-h-4 mtx-w-4 mtx-mr-2\" />}\r\n {option?.label}\r\n </Status>\r\n );\r\n })}\r\n {selectedValues.length > maxCount && (\r\n <Status className={cn(multiSelectVariants({ variant }))}>\r\n {`+ ${selectedValues.length - maxCount} ${moreText}`}\r\n <CircleXmark\r\n role=\"button\"\r\n className=\"mtx-ml-2 mtx-h-4.5 mtx-w-4.5 mtx-cursor-pointer\"\r\n onClick={event => {\r\n event.stopPropagation();\r\n clearExtraOptions();\r\n }}\r\n />\r\n </Status>\r\n )}\r\n {loading && loadingText ? loadingText : null}\r\n </div>\r\n <div className=\"mtx-flex mtx-items-center mtx-justify-between mtx-gap-1\">\r\n <XMark\r\n role=\"button\"\r\n className=\"mtx-h-5 mtx-w-5 mtx-text-muted-foreground mtx-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=\"mtx-flex mtx-min-h-5 mtx-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=\"mtx-w-auto mtx-p-0\" align=\"start\" onEscapeKeyDown={() => setIsPopoverOpen(false)}>\r\n <Command className=\"mtx-w-[--radix-popper-anchor-width] mtx-max-h-[--radix-popper-available-height]\">\r\n <CommandInput placeholder={searchText} onKeyDown={handleInputKeyDown} value={searchValue} onValueChange={setSearchValue} />\r\n <CommandList className=\"\">\r\n <CommandEmpty>{noResultsText}</CommandEmpty>\r\n <CommandGroup>\r\n {showSelectAll && (\r\n <CommandItem key=\"all\" onSelect={toggleAll} className=\"mtx-cursor-pointer\">\r\n <div\r\n className={cn(\r\n \"mtx-mr-2 mtx-flex mtx-h-4.5 mtx-w-4.5 mtx-items-center mtx-justify-center mtx-rounded-sm mtx-border mtx-border-primary\",\r\n selectedValues.length === options.size ? \"mtx-bg-primary mtx-text-primary-foreground\" : \"mtx-opacity-50 [&_svg]:mtx-invisible\",\r\n )}\r\n >\r\n <Check className=\"mtx-h-4.5 mtx-w-4.5\" />\r\n </div>\r\n <span>({selectAllText})</span>\r\n </CommandItem>\r\n )}\r\n {Array.from(options.values()).map(option => {\r\n const isSelected = selectedValues.includes(option.value);\r\n return (\r\n <CommandItem key={option.value} onSelect={() => toggleOption(option.value)} className=\"mtx-cursor-pointer\">\r\n <div\r\n className={cn(\r\n \"mtx-mr-2 mtx-flex mtx-h-4.5 mtx-w-4.5 mtx-items-center mtx-justify-center mtx-rounded-sm mtx-border mtx-border-primary\",\r\n isSelected ? \"mtx-bg-primary mtx-text-primary-foreground\" : \"mtx-opacity-50 [&_svg]:mtx-invisible\",\r\n )}\r\n >\r\n <Check className=\"mtx-h-4.5 mtx-w-4.5\" />\r\n </div>\r\n {option.icon && <option.icon className=\"mtx-mr-2 mtx-h-4.5 mtx-w-4.5 mtx-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=\"mtx-flex mtx-items-center mtx-justify-between\">\r\n {selectedValues.length > 0 && (\r\n <>\r\n <CommandItem onSelect={handleClear} className=\"mtx-flex-1 mtx-justify-center mtx-cursor-pointer\">\r\n {clearText}\r\n </CommandItem>\r\n <Separator orientation=\"vertical\" className=\"mtx-flex mtx-min-h-6 mtx-h-full\" />\r\n </>\r\n )}\r\n <CommandItem onSelect={() => setIsPopoverOpen(false)} className=\"mtx-flex-1 mtx-justify-center mtx-cursor-pointer mtx-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\nconst ForwardedMultiSelect = React.forwardRef(MultiSelect) as (<T extends string | number>(\r\n props: MultiSelectProps<T> & { ref?: React.Ref<HTMLButtonElement> },\r\n) => React.ReactElement) & { displayName?: string };\r\n\r\nForwardedMultiSelect.displayName = \"MultiSelect\";\r\n\r\nexport { ForwardedMultiSelect as MultiSelect, type MultiSelectProps };\r\n"],"names":["multiSelectVariants","tv","MultiSelect","_options","onValueChange","value","variant","disabled","defaultValue","placeholder","maxCount","modalPopover","className","moreText","clearText","closeText","selectAllText","noResultsText","searchText","addOptionOnSearchNotFound","showSelectAll","loading","loadingText","props","ref","isControlled","internalSelectedValues","setInternalSelectedValues","React","selectedValues","isPopoverOpen","setIsPopoverOpen","containerRef","searchValue","setSearchValue","isWrapped","setIsWrapped","options","setOptions","option","handleInputKeyDown","event","newOption","prev","newSelectedValues","toggleOption","handleClear","handleTogglePopover","clearExtraOptions","toggleAll","allValues","Popover","jsx","PopoverTrigger","Button","cn","ChevronDown","jsxs","IconComponent","Status","XMark","CircleXmark","Separator","Fragment","PopoverContent","Command","CommandInput","CommandList","CommandEmpty","CommandGroup","CommandItem","Check","isSelected","CommandSeparator","ForwardedMultiSelect"],"mappings":";;;;;;;;;;AAiBA,MAAMA,IAAsBC,GAAG;AAAA,EAC7B,MAAM;AAAA,EACN,UAAU;AAAA,IACR,SAAS;AAAA,MACP,SAAS;AAAA,MACT,WAAW;AAAA,MACX,aAAa;AAAA,MACb,UAAU;AAAA,IAAA;AAAA,E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,WAAU,oDAC3C,UAAAhC,GACH;AAAA,YACA,gBAAAsC,EAACU,GAAA,EAAU,aAAY,YAAW,WAAU,kCAAA,CAAkC;AAAA,UAAA,GAChF;AAAA,UAEF,gBAAAV,EAACkB,KAAY,UAAU,MAAMvC,EAAiB,EAAK,GAAG,WAAU,mEAC7D,UAAAhB,EAAA,CACH;AAAA,QAAA,EAAA,CACF,EAAA,CACF;AAAA,MAAA,EAAA,CACF;AAAA,IAAA,EAAA,CACF,EAAA,CACF;AAAA,EAAA,GACF;AAEJ,GAEM2D,KAAuB9C,EAAM,WAAW1B,EAAW;AAIzDwE,GAAqB,cAAc;"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { jsx as m } from "react/jsx-runtime";
|
|
2
|
+
import { tv as x } from "tailwind-variants";
|
|
3
|
+
import { cn as n } from "./utils.es.js";
|
|
4
|
+
const o = x({
|
|
5
|
+
base: "mtx-inline-flex mtx-items-center mtx-rounded-full mtx-border mtx-px-2.5 mtx-py-0.5 mtx-text-xs mtx-font-semibold mtx-transition-colors focus:mtx-outline-none focus:mtx-ring-2 focus:mtx-ring-ring focus:mtx-ring-offset-2 mtx-border-transparent",
|
|
6
|
+
variants: {
|
|
7
|
+
variant: {
|
|
8
|
+
primary: "mtx-bg-primary mtx-text-primary-foreground hover:mtx-bg-primary-600",
|
|
9
|
+
secondary: "mtx-bg-secondary mtx-text-secondary-foreground hover:mtx-bg-secondary-600",
|
|
10
|
+
outline: "mtx-border mtx-border-primary mtx-text-primary hover:mtx-bg-primary-50",
|
|
11
|
+
danger: "mtx-bg-danger mtx-text-danger-foreground hover:mtx-bg-danger-600",
|
|
12
|
+
success: "mtx-bg-success mtx-text-success-foreground hover:mtx-bg-success-600",
|
|
13
|
+
warning: "mtx-bg-warning mtx-text-warning-foreground hover:mtx-bg-warning-600",
|
|
14
|
+
info: "mtx-bg-info mtx-text-info-foreground hover:mtx-bg-info-600",
|
|
15
|
+
"primary-inverse": "mtx-bg-primary-100 mtx-text-primary-700 hover:mtx-bg-primary-50",
|
|
16
|
+
"success-inverse": "mtx-bg-success-300 mtx-text-success-700 hover:mtx-bg-success-200",
|
|
17
|
+
"danger-inverse": "mtx-bg-danger-300 mtx-text-danger-600 hover:mtx-bg-danger-200",
|
|
18
|
+
"warning-inverse": "mtx-bg-warning-300 mtx-text-warning-800 hover:mtx-bg-warning-200",
|
|
19
|
+
"info-inverse": "mtx-bg-info-300 mtx-text-info-700 hover:mtx-bg-info-200",
|
|
20
|
+
"purple-inverse": "mtx-bg-purple-200 mtx-text-purple-500 hover:mtx-bg-purple-100",
|
|
21
|
+
"coral-inverse": "mtx-bg-coral-300 mtx-text-coral-600 hover:mtx-bg-coral-200",
|
|
22
|
+
"turquoise-inverse": "mtx-bg-turquoise-200 mtx-text-turquoise-600 hover:mtx-bg-turquoise-100",
|
|
23
|
+
"lime-inverse": "mtx-bg-lime-300 mtx-text-lime-700 hover:mtx-bg-lime-200",
|
|
24
|
+
"gray-inverse": "mtx-bg-gray-300 mtx-text-text-500 hover:mtx-bg-gray-200"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
defaultVariants: {
|
|
28
|
+
variant: "primary"
|
|
29
|
+
}
|
|
30
|
+
}), a = ({ className: t, variant: r, ...e }) => /* @__PURE__ */ m("div", { className: n(o({ variant: r }), t), ...e });
|
|
31
|
+
export {
|
|
32
|
+
a as Status
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=status.es.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status.es.js","sources":["../src/components/status/Status.tsx"],"sourcesContent":["\"use client\";\r\n\r\nimport * as React from \"react\";\r\nimport { tv, type VariantProps } from \"tailwind-variants\";\r\n\r\nimport { cn } from \"../../lib/utils\";\r\n\r\nconst statusVariants = tv({\r\n base: \"mtx-inline-flex mtx-items-center mtx-rounded-full mtx-border mtx-px-2.5 mtx-py-0.5 mtx-text-xs mtx-font-semibold mtx-transition-colors focus:mtx-outline-none focus:mtx-ring-2 focus:mtx-ring-ring focus:mtx-ring-offset-2 mtx-border-transparent\",\r\n variants: {\r\n variant: {\r\n primary: \"mtx-bg-primary mtx-text-primary-foreground hover:mtx-bg-primary-600\",\r\n secondary: \"mtx-bg-secondary mtx-text-secondary-foreground hover:mtx-bg-secondary-600\",\r\n outline: \"mtx-border mtx-border-primary mtx-text-primary hover:mtx-bg-primary-50\",\r\n danger: \"mtx-bg-danger mtx-text-danger-foreground hover:mtx-bg-danger-600\",\r\n success: \"mtx-bg-success mtx-text-success-foreground hover:mtx-bg-success-600\",\r\n warning: \"mtx-bg-warning mtx-text-warning-foreground hover:mtx-bg-warning-600\",\r\n info: \"mtx-bg-info mtx-text-info-foreground hover:mtx-bg-info-600\",\r\n \"primary-inverse\": \"mtx-bg-primary-100 mtx-text-primary-700 hover:mtx-bg-primary-50\",\r\n \"success-inverse\": \"mtx-bg-success-300 mtx-text-success-700 hover:mtx-bg-success-200\",\r\n \"danger-inverse\": \"mtx-bg-danger-300 mtx-text-danger-600 hover:mtx-bg-danger-200\",\r\n \"warning-inverse\": \"mtx-bg-warning-300 mtx-text-warning-800 hover:mtx-bg-warning-200\",\r\n \"info-inverse\": \"mtx-bg-info-300 mtx-text-info-700 hover:mtx-bg-info-200\",\r\n \"purple-inverse\": \"mtx-bg-purple-200 mtx-text-purple-500 hover:mtx-bg-purple-100\",\r\n \"coral-inverse\": \"mtx-bg-coral-300 mtx-text-coral-600 hover:mtx-bg-coral-200\",\r\n \"turquoise-inverse\": \"mtx-bg-turquoise-200 mtx-text-turquoise-600 hover:mtx-bg-turquoise-100\",\r\n \"lime-inverse\": \"mtx-bg-lime-300 mtx-text-lime-700 hover:mtx-bg-lime-200\",\r\n \"gray-inverse\": \"mtx-bg-gray-300 mtx-text-text-500 hover:mtx-bg-gray-200\",\r\n },\r\n },\r\n defaultVariants: {\r\n variant: \"primary\",\r\n },\r\n});\r\n\r\nexport type StatusVariant = VariantProps<typeof statusVariants>[\"variant\"];\r\n\r\ninterface StatusProps extends React.HTMLAttributes<HTMLDivElement> {\r\n variant?: StatusVariant;\r\n}\r\n\r\nconst Status: React.FC<StatusProps> = ({ className, variant, ...props }) => {\r\n return <div className={cn(statusVariants({ variant }), className)} {...props} />;\r\n};\r\n\r\nexport { Status, type StatusProps };\r\n"],"names":["statusVariants","tv","Status","className","variant","props","jsx","cn"],"mappings":";;;AAOA,MAAMA,IAAiBC,EAAG;AAAA,EACxB,MAAM;AAAA,EACN,UAAU;AAAA,IACR,SAAS;AAAA,MACP,SAAS;AAAA,MACT,WAAW;AAAA,MACX,SAAS;AAAA,MACT,QAAQ;AAAA,MACR,SAAS;AAAA,MACT,SAAS;AAAA,MACT,MAAM;AAAA,MACN,mBAAmB;AAAA,MACnB,mBAAmB;AAAA,MACnB,kBAAkB;AAAA,MAClB,mBAAmB;AAAA,MACnB,gBAAgB;AAAA,MAChB,kBAAkB;AAAA,MAClB,iBAAiB;AAAA,MACjB,qBAAqB;AAAA,MACrB,gBAAgB;AAAA,MAChB,gBAAgB;AAAA,IAAA;AAAA,EAClB;AAAA,EAEF,iBAAiB;AAAA,IACf,SAAS;AAAA,EAAA;AAEb,CAAC,GAQKC,IAAgC,CAAC,EAAE,WAAAC,GAAW,SAAAC,GAAS,GAAGC,QACvD,gBAAAC,EAAC,OAAA,EAAI,WAAWC,EAAGP,EAAe,EAAE,SAAAI,EAAA,CAAS,GAAGD,CAAS,GAAI,GAAGE,EAAA,CAAO;"}
|