@trsys-tech/matrix-library 0.6.0 → 1.0.0-canary.0
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 +27 -27
- package/dist/accordion.es.js.map +1 -1
- package/dist/avatar.es.js +28 -14
- package/dist/avatar.es.js.map +1 -1
- package/dist/badge.es.js +24 -24
- package/dist/badge.es.js.map +1 -1
- package/dist/breadcrumb.es.js +34 -24
- package/dist/breadcrumb.es.js.map +1 -1
- package/dist/button.es.js +28 -28
- package/dist/button.es.js.map +1 -1
- package/dist/calendar.es.js +64 -61
- package/dist/calendar.es.js.map +1 -1
- package/dist/card.es.js +21 -21
- package/dist/card.es.js.map +1 -1
- package/dist/checkbox.es.js +15 -15
- package/dist/checkbox.es.js.map +1 -1
- package/dist/chip.es.js +24 -24
- package/dist/chip.es.js.map +1 -1
- package/dist/collapsible.es.js +17 -17
- package/dist/collapsible.es.js.map +1 -1
- package/dist/combobox.es.js +79 -70
- package/dist/combobox.es.js.map +1 -1
- package/dist/command.es.js +62 -59
- package/dist/command.es.js.map +1 -1
- package/dist/components/accordion/Accordion.d.ts.map +1 -1
- package/dist/components/avatar/Avatar.d.ts.map +1 -1
- package/dist/components/badge/Badge.d.ts +2 -2
- package/dist/components/breadcrumb/Breadcrumb.d.ts.map +1 -1
- package/dist/components/button/Button.d.ts +2 -2
- package/dist/components/chip/Chip.d.ts +2 -2
- package/dist/components/combobox/Combobox.d.ts.map +1 -1
- package/dist/components/command/Command.d.ts.map +1 -1
- package/dist/components/confirm/Confirm.d.ts.map +1 -1
- package/dist/components/context-menu/ContextMenu.d.ts.map +1 -1
- package/dist/components/data-grid/DataGrid.d.ts.map +1 -1
- package/dist/components/date-picker/TimePickerContent.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/drawer/Drawer.d.ts.map +1 -1
- package/dist/components/drawer/SwipableDrawer.d.ts.map +1 -1
- package/dist/components/form/Form.d.ts.map +1 -1
- package/dist/components/icon-botton/IconButton.d.ts +2 -2
- package/dist/components/icon-botton/IconButton.d.ts.map +1 -1
- package/dist/components/label/Label.d.ts +1 -1
- package/dist/components/label/Label.d.ts.map +1 -1
- package/dist/components/modal/Modal.d.ts.map +1 -1
- package/dist/components/multi-select/MultiSelect.d.ts +2 -2
- package/dist/components/progress/Progress.d.ts.map +1 -1
- package/dist/components/rating/Rating.d.ts +2 -2
- package/dist/components/select/Select.d.ts.map +1 -1
- package/dist/components/sheet/Sheet.d.ts +2 -2
- package/dist/components/sheet/Sheet.d.ts.map +1 -1
- package/dist/components/sidebar/Sidebar.d.ts.map +1 -1
- package/dist/components/switch/Switch.d.ts +2 -2
- package/dist/components/text-field/TextField.d.ts.map +1 -1
- package/dist/components/toast/toast-components.d.ts +4 -4
- package/dist/components/toast/toast-components.d.ts.map +1 -1
- package/dist/confirm.es.js +18 -8
- package/dist/confirm.es.js.map +1 -1
- package/dist/contextmenu.es.js +77 -70
- package/dist/contextmenu.es.js.map +1 -1
- package/dist/datagrid.es.js +101 -97
- package/dist/datagrid.es.js.map +1 -1
- package/dist/desktopdatepicker.es.js +30 -30
- package/dist/desktopdatepicker.es.js.map +1 -1
- package/dist/desktopdaterangepicker.es.js +44 -44
- package/dist/desktopdaterangepicker.es.js.map +1 -1
- package/dist/desktoptimepicker.es.js +24 -24
- package/dist/desktoptimepicker.es.js.map +1 -1
- package/dist/dialog.es.js +43 -43
- package/dist/dialog.es.js.map +1 -1
- package/dist/drawer.es.js +27 -27
- package/dist/drawer.es.js.map +1 -1
- package/dist/duration.es.js +34 -34
- package/dist/duration.es.js.map +1 -1
- package/dist/form.es.js +20 -20
- package/dist/form.es.js.map +1 -1
- package/dist/formcheckbox.es.js +13 -13
- package/dist/formcheckbox.es.js.map +1 -1
- package/dist/formcombobox.es.js +17 -17
- package/dist/formcombobox.es.js.map +1 -1
- package/dist/formdatepicker.es.js +12 -12
- package/dist/formdatepicker.es.js.map +1 -1
- package/dist/formdaterangepicker.es.js +16 -16
- package/dist/formdaterangepicker.es.js.map +1 -1
- package/dist/formduration.es.js +13 -13
- package/dist/formduration.es.js.map +1 -1
- package/dist/forminput.es.js +10 -10
- package/dist/forminput.es.js.map +1 -1
- package/dist/formmultiselect.es.js +7 -7
- package/dist/formmultiselect.es.js.map +1 -1
- package/dist/formrating.es.js +21 -21
- package/dist/formrating.es.js.map +1 -1
- package/dist/formselect.es.js +28 -28
- package/dist/formselect.es.js.map +1 -1
- package/dist/formswitch.es.js +14 -14
- package/dist/formswitch.es.js.map +1 -1
- package/dist/formtextarea.es.js +12 -12
- package/dist/formtextarea.es.js.map +1 -1
- package/dist/formtimepicker.es.js +12 -12
- package/dist/formtimepicker.es.js.map +1 -1
- package/dist/iconbutton.es.js +22 -22
- package/dist/iconbutton.es.js.map +1 -1
- package/dist/label.es.js +6 -6
- package/dist/label.es.js.map +1 -1
- package/dist/lib/utils.d.ts.map +1 -1
- package/dist/mobiledatepicker.es.js +42 -42
- package/dist/mobiledatepicker.es.js.map +1 -1
- package/dist/mobiledaterangepicker.es.js +50 -50
- package/dist/mobiledaterangepicker.es.js.map +1 -1
- package/dist/mobiletimepicker.es.js +30 -30
- package/dist/mobiletimepicker.es.js.map +1 -1
- package/dist/modal.es.js +48 -44
- package/dist/modal.es.js.map +1 -1
- package/dist/multiselect.es.js +120 -120
- package/dist/multiselect.es.js.map +1 -1
- package/dist/popover.es.js +16 -16
- package/dist/popover.es.js.map +1 -1
- package/dist/progress.es.js +29 -21
- package/dist/progress.es.js.map +1 -1
- package/dist/radiogroup.es.js +16 -16
- package/dist/radiogroup.es.js.map +1 -1
- package/dist/rating.es.js +76 -76
- package/dist/rating.es.js.map +1 -1
- package/dist/select.es.js +82 -63
- package/dist/select.es.js.map +1 -1
- package/dist/separator.es.js +13 -13
- package/dist/separator.es.js.map +1 -1
- package/dist/sheet.es.js +44 -44
- package/dist/sheet.es.js.map +1 -1
- package/dist/sidebar.es.js +245 -233
- package/dist/sidebar.es.js.map +1 -1
- package/dist/skeleton.es.js +6 -6
- package/dist/skeleton.es.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/swipabledrawer.es.js +41 -38
- package/dist/swipabledrawer.es.js.map +1 -1
- package/dist/switch.es.js +16 -16
- package/dist/switch.es.js.map +1 -1
- package/dist/tabs.es.js +22 -22
- package/dist/tabs.es.js.map +1 -1
- package/dist/textarea.es.js +12 -12
- package/dist/textarea.es.js.map +1 -1
- package/dist/textfield.es.js +37 -37
- package/dist/textfield.es.js.map +1 -1
- package/dist/timepickercontent.es.js +63 -56
- package/dist/timepickercontent.es.js.map +1 -1
- package/dist/toast-components.es.js +47 -44
- package/dist/toast-components.es.js.map +1 -1
- package/dist/toast.es.js +24 -24
- package/dist/toast.es.js.map +1 -1
- package/dist/tooltip.es.js +16 -16
- package/dist/tooltip.es.js.map +1 -1
- package/dist/utils.es.js +6 -5
- package/dist/utils.es.js.map +1 -1
- package/package.json +5 -5
package/dist/multiselect.es.js
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import * as
|
|
3
|
-
import { tv as
|
|
4
|
-
import { XMark as I, CircleXmark as
|
|
5
|
-
import { cn as
|
|
1
|
+
import { jsxs as l, jsx as t, Fragment as S } from "react/jsx-runtime";
|
|
2
|
+
import * as a from "react";
|
|
3
|
+
import { tv as me } from "tailwind-variants";
|
|
4
|
+
import { XMark as I, CircleXmark as ae, ChevronDown as le, Check as D } from "@trsys-tech/matrix-icons";
|
|
5
|
+
import { cn as p } from "./utils.es.js";
|
|
6
6
|
import { Badge as T } from "./badge.es.js";
|
|
7
|
-
import { Button as
|
|
7
|
+
import { Button as se } from "./button.es.js";
|
|
8
8
|
import { Separator as A } from "./separator.es.js";
|
|
9
|
-
import { Popover as
|
|
10
|
-
import { Command as
|
|
11
|
-
const B =
|
|
12
|
-
base: "flex gap-1 items-center py-0.5 px-2 rounded-xl",
|
|
9
|
+
import { Popover as oe, PopoverTrigger as ne, PopoverContent as ce } from "./popover.es.js";
|
|
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 B = me({
|
|
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: {
|
|
15
|
-
default: "border-none shadow-none bg-primary-50 text-primary hover:bg-primary-50",
|
|
16
|
-
secondary: "border-foreground/10 bg-secondary text-secondary-foreground hover:bg-secondary/80",
|
|
17
|
-
destructive: "border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",
|
|
18
|
-
inverted: "inverted"
|
|
15
|
+
default: "mtx-border-none mtx-shadow-none mtx-bg-primary-50 mtx-text-primary hover:mtx-bg-primary-50",
|
|
16
|
+
secondary: "mtx-border-foreground/10 mtx-bg-secondary mtx-text-secondary-foreground hover:mtx-bg-secondary/80",
|
|
17
|
+
destructive: "mtx-border-transparent mtx-bg-destructive mtx-text-destructive-foreground hover:mtx-bg-destructive/80",
|
|
18
|
+
inverted: "mtx-inverted"
|
|
19
19
|
}
|
|
20
20
|
},
|
|
21
21
|
defaultVariants: {
|
|
22
22
|
variant: "default"
|
|
23
23
|
}
|
|
24
|
-
}),
|
|
25
|
-
options:
|
|
26
|
-
onValueChange:
|
|
24
|
+
}), fe = ({
|
|
25
|
+
options: d,
|
|
26
|
+
onValueChange: o,
|
|
27
27
|
value: k,
|
|
28
28
|
variant: C,
|
|
29
29
|
disabled: j,
|
|
30
30
|
defaultValue: K = [],
|
|
31
31
|
placeholder: L = "Select options",
|
|
32
|
-
maxCount:
|
|
32
|
+
maxCount: u = 3,
|
|
33
33
|
modalPopover: V = !1,
|
|
34
34
|
// asChild = false,
|
|
35
35
|
className: z,
|
|
@@ -39,185 +39,185 @@ const B = ae({
|
|
|
39
39
|
selectAllText: G = "Select All",
|
|
40
40
|
noResultsText: O = "No results found.",
|
|
41
41
|
searchText: q = "Search...",
|
|
42
|
-
addOptionOnSearchNotFound:
|
|
42
|
+
addOptionOnSearchNotFound: f = !1,
|
|
43
43
|
showSelectAll: H = !0,
|
|
44
|
-
loading:
|
|
45
|
-
loadingText:
|
|
44
|
+
loading: h,
|
|
45
|
+
loadingText: b = "Loading...",
|
|
46
46
|
...J
|
|
47
47
|
}, Q) => {
|
|
48
|
-
const
|
|
49
|
-
new Map(
|
|
50
|
-
), _ =
|
|
48
|
+
const s = k !== void 0, [U, x] = a.useState(K), r = s ? 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
|
+
new Map(d.map((e) => [e.value, e]))
|
|
50
|
+
), _ = a.useCallback(
|
|
51
51
|
(e) => {
|
|
52
|
-
if (e.key === "Enter" &&
|
|
53
|
-
if (
|
|
54
|
-
const
|
|
55
|
-
if (
|
|
56
|
-
|
|
57
|
-
const
|
|
58
|
-
|
|
52
|
+
if (e.key === "Enter" && f) {
|
|
53
|
+
if (i(!0), e.preventDefault(), e.stopPropagation(), !e.currentTarget.value) return;
|
|
54
|
+
const m = { value: e.currentTarget.value, label: e.currentTarget.value };
|
|
55
|
+
if (n.get(m.value) === void 0) {
|
|
56
|
+
w((N) => new Map(N).set(m.value, m));
|
|
57
|
+
const c = [...r, m.value];
|
|
58
|
+
s || 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
|
-
const
|
|
64
|
-
|
|
63
|
+
const m = [...r];
|
|
64
|
+
m.pop(), s || x(m), o(m);
|
|
65
65
|
}
|
|
66
66
|
},
|
|
67
|
-
[
|
|
68
|
-
), E =
|
|
67
|
+
[f, o, n, r, s]
|
|
68
|
+
), E = a.useCallback(
|
|
69
69
|
(e) => {
|
|
70
|
-
const
|
|
71
|
-
|
|
70
|
+
const m = r.includes(e) ? r.filter((c) => c !== e) : [...r, e];
|
|
71
|
+
s || x(m), o(m);
|
|
72
72
|
},
|
|
73
|
-
[
|
|
74
|
-
),
|
|
75
|
-
|
|
76
|
-
}, [
|
|
77
|
-
|
|
78
|
-
}, []),
|
|
79
|
-
const e =
|
|
80
|
-
|
|
81
|
-
}, [
|
|
82
|
-
if (
|
|
83
|
-
|
|
73
|
+
[o, r, s]
|
|
74
|
+
), v = a.useCallback(() => {
|
|
75
|
+
s || x([]), o([]), f && w(new Map(d.map((e) => [e.value, e])));
|
|
76
|
+
}, [o, f, d, s]), ee = a.useCallback(() => {
|
|
77
|
+
i((e) => !e);
|
|
78
|
+
}, []), te = a.useCallback(() => {
|
|
79
|
+
const e = r.slice(0, u);
|
|
80
|
+
s || x(e), o(e);
|
|
81
|
+
}, [u, r, o, s]), re = a.useCallback(() => {
|
|
82
|
+
if (r.length === n.size)
|
|
83
|
+
v();
|
|
84
84
|
else {
|
|
85
|
-
const e = Array.from(
|
|
86
|
-
|
|
85
|
+
const e = Array.from(n.keys());
|
|
86
|
+
s || x(e), o(e);
|
|
87
87
|
}
|
|
88
|
-
}, [
|
|
89
|
-
return
|
|
90
|
-
|
|
91
|
-
}, [
|
|
92
|
-
|
|
93
|
-
}, [
|
|
94
|
-
/* @__PURE__ */
|
|
95
|
-
|
|
88
|
+
}, [v, o, n, r.length, s]);
|
|
89
|
+
return a.useEffect(() => {
|
|
90
|
+
w(new Map(d.map((e) => [e.value, e])));
|
|
91
|
+
}, [d]), a.useLayoutEffect(() => {
|
|
92
|
+
g.current && (g?.current?.firstChild?.offsetTop < g?.current?.lastChild?.offsetTop ? M(!0) : M(!1));
|
|
93
|
+
}, [r]), /* @__PURE__ */ l(oe, { open: Y, onOpenChange: i, modal: V, children: [
|
|
94
|
+
/* @__PURE__ */ t(ne, { asChild: !0, children: /* @__PURE__ */ t(
|
|
95
|
+
se,
|
|
96
96
|
{
|
|
97
97
|
ref: Q,
|
|
98
98
|
variant: "text",
|
|
99
|
-
loading:
|
|
99
|
+
loading: h,
|
|
100
100
|
disabled: j,
|
|
101
101
|
...J,
|
|
102
102
|
onClick: ee,
|
|
103
|
-
className:
|
|
104
|
-
"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",
|
|
105
|
-
F && "h-auto",
|
|
103
|
+
className: p(
|
|
104
|
+
"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",
|
|
105
|
+
F && "mtx-h-auto",
|
|
106
106
|
z
|
|
107
107
|
),
|
|
108
|
-
"data-placeholder":
|
|
109
|
-
endIcon: /* @__PURE__ */
|
|
110
|
-
|
|
108
|
+
"data-placeholder": r.length ? void 0 : "",
|
|
109
|
+
endIcon: /* @__PURE__ */ t(
|
|
110
|
+
le,
|
|
111
111
|
{
|
|
112
112
|
role: "button",
|
|
113
113
|
"aria-label": "Expand dropdown",
|
|
114
|
-
className: "!h-4.5 !w-4.5 cursor-pointer group-data-[state=open]:rotate-180 transition-transform"
|
|
114
|
+
className: "!mtx-h-4.5 !mtx-w-4.5 mtx-cursor-pointer group-data-[state=open]:mtx-rotate-180 mtx-transition-transform"
|
|
115
115
|
}
|
|
116
116
|
),
|
|
117
|
-
children: /* @__PURE__ */
|
|
118
|
-
/* @__PURE__ */
|
|
119
|
-
|
|
120
|
-
const
|
|
121
|
-
return /* @__PURE__ */
|
|
122
|
-
/* @__PURE__ */
|
|
117
|
+
children: /* @__PURE__ */ t(S, { children: r.length > 0 ? /* @__PURE__ */ l("div", { className: "mtx-flex mtx-justify-between mtx-items-center mtx-w-full", children: [
|
|
118
|
+
/* @__PURE__ */ l("div", { className: "mtx-flex mtx-flex-wrap mtx-items-center mtx-gap-2", ref: g, children: [
|
|
119
|
+
r.slice(0, u).map((e) => {
|
|
120
|
+
const m = n.get(e), c = m?.icon;
|
|
121
|
+
return /* @__PURE__ */ l(T, { className: p(B({ variant: C }), { "text-gray-400 bg-gray-200": j || h }), children: [
|
|
122
|
+
/* @__PURE__ */ t(
|
|
123
123
|
I,
|
|
124
124
|
{
|
|
125
|
-
className: "h-4 w-4 cursor-pointer",
|
|
125
|
+
className: "mtx-h-4 mtx-w-4 mtx-cursor-pointer",
|
|
126
126
|
onClick: (N) => {
|
|
127
127
|
N.stopPropagation(), E(e);
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
130
|
),
|
|
131
|
-
|
|
132
|
-
|
|
131
|
+
c && /* @__PURE__ */ t(c, { className: "mtx-h-4 mtx-w-4 mtx-mr-2" }),
|
|
132
|
+
m?.label
|
|
133
133
|
] }, e);
|
|
134
134
|
}),
|
|
135
|
-
|
|
136
|
-
`+ ${
|
|
137
|
-
/* @__PURE__ */
|
|
138
|
-
|
|
135
|
+
r.length > u && /* @__PURE__ */ l(T, { className: p(B({ variant: C })), children: [
|
|
136
|
+
`+ ${r.length - u} ${W}`,
|
|
137
|
+
/* @__PURE__ */ t(
|
|
138
|
+
ae,
|
|
139
139
|
{
|
|
140
140
|
role: "button",
|
|
141
|
-
className: "ml-2 h-4.5 w-4.5 cursor-pointer",
|
|
141
|
+
className: "mtx-ml-2 mtx-h-4.5 mtx-w-4.5 mtx-cursor-pointer",
|
|
142
142
|
onClick: (e) => {
|
|
143
|
-
e.stopPropagation(),
|
|
143
|
+
e.stopPropagation(), te();
|
|
144
144
|
}
|
|
145
145
|
}
|
|
146
146
|
)
|
|
147
147
|
] }),
|
|
148
|
-
|
|
148
|
+
h && b ? b : null
|
|
149
149
|
] }),
|
|
150
|
-
/* @__PURE__ */
|
|
151
|
-
/* @__PURE__ */
|
|
150
|
+
/* @__PURE__ */ l("div", { className: "mtx-flex mtx-items-center mtx-justify-between mtx-gap-1", children: [
|
|
151
|
+
/* @__PURE__ */ t(
|
|
152
152
|
I,
|
|
153
153
|
{
|
|
154
154
|
role: "button",
|
|
155
|
-
className: "h-5 w-5 text-muted-foreground cursor-pointer",
|
|
155
|
+
className: "mtx-h-5 mtx-w-5 mtx-text-muted-foreground mtx-cursor-pointer",
|
|
156
156
|
onClick: (e) => {
|
|
157
|
-
e.stopPropagation(),
|
|
157
|
+
e.stopPropagation(), v();
|
|
158
158
|
},
|
|
159
159
|
"aria-label": "Clear"
|
|
160
160
|
}
|
|
161
161
|
),
|
|
162
|
-
/* @__PURE__ */
|
|
162
|
+
/* @__PURE__ */ t(A, { orientation: "vertical", className: "mtx-flex mtx-min-h-5 mtx-h-full" })
|
|
163
163
|
] })
|
|
164
|
-
] }) : /* @__PURE__ */
|
|
164
|
+
] }) : /* @__PURE__ */ t(S, { children: h && b ? b : L }) })
|
|
165
165
|
}
|
|
166
166
|
) }),
|
|
167
|
-
/* @__PURE__ */
|
|
168
|
-
/* @__PURE__ */
|
|
169
|
-
/* @__PURE__ */
|
|
170
|
-
/* @__PURE__ */
|
|
171
|
-
/* @__PURE__ */
|
|
172
|
-
H && /* @__PURE__ */
|
|
173
|
-
/* @__PURE__ */
|
|
167
|
+
/* @__PURE__ */ t(ce, { className: "mtx-w-auto mtx-p-0", align: "start", onEscapeKeyDown: () => i(!1), children: /* @__PURE__ */ l(xe, { className: "mtx-w-[--radix-popper-anchor-width] mtx-max-h-[--radix-popper-available-height]", children: [
|
|
168
|
+
/* @__PURE__ */ t(ie, { placeholder: q, onKeyDown: _, value: Z, onValueChange: P }),
|
|
169
|
+
/* @__PURE__ */ l(de, { className: "", children: [
|
|
170
|
+
/* @__PURE__ */ t(ue, { children: O }),
|
|
171
|
+
/* @__PURE__ */ l(R, { children: [
|
|
172
|
+
H && /* @__PURE__ */ l(y, { onSelect: re, className: "mtx-cursor-pointer", children: [
|
|
173
|
+
/* @__PURE__ */ t(
|
|
174
174
|
"div",
|
|
175
175
|
{
|
|
176
|
-
className:
|
|
177
|
-
"mr-2 flex h-4.5 w-4.5 items-center justify-center rounded-sm border border-primary",
|
|
178
|
-
|
|
176
|
+
className: p(
|
|
177
|
+
"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",
|
|
178
|
+
r.length === n.size ? "mtx-bg-primary mtx-text-primary-foreground" : "mtx-opacity-50 [&_svg]:mtx-invisible"
|
|
179
179
|
),
|
|
180
|
-
children: /* @__PURE__ */
|
|
180
|
+
children: /* @__PURE__ */ t(D, { className: "mtx-h-4.5 mtx-w-4.5" })
|
|
181
181
|
}
|
|
182
182
|
),
|
|
183
|
-
/* @__PURE__ */
|
|
183
|
+
/* @__PURE__ */ l("span", { children: [
|
|
184
184
|
"(",
|
|
185
185
|
G,
|
|
186
186
|
")"
|
|
187
187
|
] })
|
|
188
188
|
] }, "all"),
|
|
189
|
-
Array.from(
|
|
190
|
-
const
|
|
191
|
-
return /* @__PURE__ */
|
|
192
|
-
/* @__PURE__ */
|
|
189
|
+
Array.from(n.values()).map((e) => {
|
|
190
|
+
const m = r.includes(e.value);
|
|
191
|
+
return /* @__PURE__ */ l(y, { onSelect: () => E(e.value), className: "mtx-cursor-pointer", children: [
|
|
192
|
+
/* @__PURE__ */ t(
|
|
193
193
|
"div",
|
|
194
194
|
{
|
|
195
|
-
className:
|
|
196
|
-
"mr-2 flex h-4.5 w-4.5 items-center justify-center rounded-sm border border-primary",
|
|
197
|
-
|
|
195
|
+
className: p(
|
|
196
|
+
"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",
|
|
197
|
+
m ? "mtx-bg-primary mtx-text-primary-foreground" : "mtx-opacity-50 [&_svg]:mtx-invisible"
|
|
198
198
|
),
|
|
199
|
-
children: /* @__PURE__ */
|
|
199
|
+
children: /* @__PURE__ */ t(D, { className: "mtx-h-4.5 mtx-w-4.5" })
|
|
200
200
|
}
|
|
201
201
|
),
|
|
202
|
-
e.icon && /* @__PURE__ */
|
|
203
|
-
/* @__PURE__ */
|
|
202
|
+
e.icon && /* @__PURE__ */ t(e.icon, { className: "mtx-mr-2 mtx-h-4.5 mtx-w-4.5 mtx-text-muted-foreground" }),
|
|
203
|
+
/* @__PURE__ */ t("span", { children: e.label })
|
|
204
204
|
] }, e.value);
|
|
205
205
|
})
|
|
206
206
|
] }),
|
|
207
|
-
/* @__PURE__ */
|
|
208
|
-
/* @__PURE__ */
|
|
209
|
-
|
|
210
|
-
/* @__PURE__ */
|
|
211
|
-
/* @__PURE__ */
|
|
207
|
+
/* @__PURE__ */ t(pe, {}),
|
|
208
|
+
/* @__PURE__ */ t(R, { children: /* @__PURE__ */ l("div", { className: "mtx-flex mtx-items-center mtx-justify-between", children: [
|
|
209
|
+
r.length > 0 && /* @__PURE__ */ l(S, { children: [
|
|
210
|
+
/* @__PURE__ */ t(y, { onSelect: v, className: "mtx-flex-1 mtx-justify-center mtx-cursor-pointer", children: X }),
|
|
211
|
+
/* @__PURE__ */ t(A, { orientation: "vertical", className: "mtx-flex mtx-min-h-6 mtx-h-full" })
|
|
212
212
|
] }),
|
|
213
|
-
/* @__PURE__ */
|
|
213
|
+
/* @__PURE__ */ t(y, { onSelect: () => i(!1), className: "mtx-flex-1 mtx-justify-center mtx-cursor-pointer mtx-max-w-full", children: $ })
|
|
214
214
|
] }) })
|
|
215
215
|
] })
|
|
216
216
|
] }) })
|
|
217
217
|
] });
|
|
218
|
-
},
|
|
219
|
-
|
|
218
|
+
}, he = a.forwardRef(fe);
|
|
219
|
+
he.displayName = "MultiSelect";
|
|
220
220
|
export {
|
|
221
|
-
|
|
221
|
+
he as MultiSelect
|
|
222
222
|
};
|
|
223
223
|
//# sourceMappingURL=multiselect.es.js.map
|
|
@@ -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: \"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<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 {...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.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=\"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] 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=\"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.size ? \"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 )}\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=\"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\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,EACf,aAAAC,IAAc;AAAA,EACd,UAAAC,IAAW;AAAA,EACX,cAAAC,IAAe;AAAA;AAAA,EAEf,WAAAC;AAAA,EACA,UAAAC,IAAW;AAAA,EACX,WAAAC,IAAY;AAAA,EACZ,WAAAC,IAAY;AAAA,EACZ,eAAAC,IAAgB;AAAA,EAChB,eAAAC,IAAgB;AAAA,EAChB,YAAAC,IAAa;AAAA,EACb,2BAAAC,IAA4B;AAAA,EAC5B,eAAAC,IAA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N,EAAO,KAAK,GAAG,WAAU,kBACpF,UAAA;AAAA,cAAA,gBAAAa;AAAA,gBAAC;AAAA,gBAAA;AAAA,kBACC,WAAWG;AAAA,oBACT;AAAA,oBACAiB,IAAa,uCAAuC;AAAA,kBAAA;AAAA,kBAGtD,UAAA,gBAAApB,EAACmB,GAAA,EAAM,WAAU,cAAA,CAAc;AAAA,gBAAA;AAAA,cAAA;AAAA,cAEhChC,EAAO,QAAQ,gBAAAa,EAACb,EAAO,MAAP,EAAY,WAAU,0CAAyC;AAAA,cAChF,gBAAAa,EAAC,QAAA,EAAM,UAAAb,EAAO,MAAA,CAAM;AAAA,YAAA,EAAA,GAVJA,EAAO,KAWzB;AAAA,UAEJ,CAAC;AAAA,QAAA,GACH;AAAA,0BACCkC,IAAA,EAAiB;AAAA,QAClB,gBAAArB,EAACiB,GAAA,EACC,UAAA,gBAAAZ,EAAC,OAAA,EAAI,WAAU,qCACZ,UAAA;AAAA,UAAA5B,EAAe,SAAS,KACvB,gBAAA4B,EAAAM,GAAA,EACE,UAAA;AAAA,YAAA,gBAAAX,EAACkB,GAAA,EAAY,UAAUxB,GAAa,WAAU,wCAC3C,UAAAhC,GACH;AAAA,YACA,gBAAAsC,EAACU,GAAA,EAAU,aAAY,YAAW,WAAU,sBAAA,CAAsB;AAAA,UAAA,GACpE;AAAA,UAEF,gBAAAV,EAACkB,KAAY,UAAU,MAAMvC,EAAiB,EAAK,GAAG,WAAU,mDAC7D,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;"}
|
|
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 {...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,EACf,aAAAC,IAAc;AAAA,EACd,UAAAC,IAAW;AAAA,EACX,cAAAC,IAAe;AAAA;AAAA,EAEf,WAAAC;AAAA,EACA,UAAAC,IA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,KAAuB9C,EAAM,WAAW1B,EAAW;AAIzDwE,GAAqB,cAAc;"}
|
package/dist/popover.es.js
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import * as
|
|
3
|
-
import * as
|
|
4
|
-
import { cn as
|
|
5
|
-
const
|
|
6
|
-
|
|
1
|
+
import { jsx as o } from "react/jsx-runtime";
|
|
2
|
+
import * as i from "react";
|
|
3
|
+
import * as t from "@radix-ui/react-popover";
|
|
4
|
+
import { cn as n } from "./utils.es.js";
|
|
5
|
+
const f = t.Root, l = t.Trigger, c = t.Anchor, s = i.forwardRef(({ className: e, align: a = "center", sideOffset: m = 4, ...r }, d) => /* @__PURE__ */ o(t.Portal, { children: /* @__PURE__ */ o(
|
|
6
|
+
t.Content,
|
|
7
7
|
{
|
|
8
|
-
ref:
|
|
8
|
+
ref: d,
|
|
9
9
|
align: a,
|
|
10
|
-
sideOffset:
|
|
11
|
-
className:
|
|
12
|
-
"z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none 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",
|
|
10
|
+
sideOffset: m,
|
|
11
|
+
className: n(
|
|
12
|
+
"mtx-z-50 mtx-w-72 mtx-rounded-md mtx-border mtx-bg-popover mtx-p-4 mtx-text-popover-foreground mtx-shadow-md mtx-outline-none data-[state=open]:mtx-animate-in data-[state=closed]:mtx-animate-out data-[state=closed]:mtx-fade-out-0 data-[state=open]:mtx-fade-in-0 data-[state=closed]:mtx-zoom-out-95 data-[state=open]:mtx-zoom-in-95 data-[side=bottom]:mtx-slide-in-from-top-2 data-[side=left]:mtx-slide-in-from-right-2 data-[side=right]:mtx-slide-in-from-left-2 data-[side=top]:mtx-slide-in-from-bottom-2",
|
|
13
13
|
e
|
|
14
14
|
),
|
|
15
|
-
...
|
|
15
|
+
...r
|
|
16
16
|
}
|
|
17
17
|
) }));
|
|
18
|
-
|
|
18
|
+
s.displayName = t.Content.displayName;
|
|
19
19
|
export {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
f as Popover,
|
|
21
|
+
c as PopoverAnchor,
|
|
22
|
+
s as PopoverContent,
|
|
23
|
+
l as PopoverTrigger
|
|
24
24
|
};
|
|
25
25
|
//# sourceMappingURL=popover.es.js.map
|
package/dist/popover.es.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"popover.es.js","sources":["../src/components/popover/Popover.tsx"],"sourcesContent":["\"use client\";\r\n\r\nimport * as React from \"react\";\r\nimport * as PopoverPrimitive from \"@radix-ui/react-popover\";\r\nimport type { PopoverContentProps, PopoverProps, PopoverTriggerProps, PopoverAnchorProps } from \"@radix-ui/react-popover\";\r\n\r\nimport { cn } from \"../../lib/utils\";\r\n\r\nconst Popover = PopoverPrimitive.Root;\r\n\r\nconst PopoverTrigger = PopoverPrimitive.Trigger;\r\n\r\nconst PopoverAnchor = PopoverPrimitive.Anchor;\r\n\r\nconst PopoverContent = React.forwardRef<\r\n React.ElementRef<typeof PopoverPrimitive.Content>,\r\n React.ComponentPropsWithoutRef<typeof PopoverPrimitive.Content>\r\n>(({ className, align = \"center\", sideOffset = 4, ...props }, ref) => (\r\n <PopoverPrimitive.Portal>\r\n <PopoverPrimitive.Content\r\n ref={ref}\r\n align={align}\r\n sideOffset={sideOffset}\r\n className={cn(\r\n \"z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none 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\",\r\n className,\r\n )}\r\n {...props}\r\n />\r\n </PopoverPrimitive.Portal>\r\n));\r\nPopoverContent.displayName = PopoverPrimitive.Content.displayName;\r\n\r\nexport {\r\n Popover,\r\n PopoverTrigger,\r\n PopoverContent,\r\n PopoverAnchor,\r\n type PopoverProps,\r\n type PopoverContentProps,\r\n type PopoverTriggerProps,\r\n type PopoverAnchorProps,\r\n};\r\n"],"names":["Popover","PopoverPrimitive","PopoverTrigger","PopoverAnchor","PopoverContent","React","className","align","sideOffset","props","ref","jsx","cn"],"mappings":";;;;AAQA,MAAMA,IAAUC,EAAiB,MAE3BC,IAAiBD,EAAiB,SAElCE,IAAgBF,EAAiB,QAEjCG,IAAiBC,EAAM,WAG3B,CAAC,EAAE,WAAAC,GAAW,OAAAC,IAAQ,UAAU,YAAAC,IAAa,GAAG,GAAGC,EAAA,GAASC,MAC5D,gBAAAC,EAACV,EAAiB,QAAjB,EACC,UAAA,gBAAAU;AAAA,EAACV,EAAiB;AAAA,EAAjB;AAAA,IACC,KAAAS;AAAA,IACA,OAAAH;AAAA,IACA,YAAAC;AAAA,IACA,WAAWI;AAAA,MACT;AAAA,MACAN;AAAA,IAAA;AAAA,IAED,GAAGG;AAAA,EAAA;AACN,GACF,CACD;AACDL,EAAe,cAAcH,EAAiB,QAAQ;"}
|
|
1
|
+
{"version":3,"file":"popover.es.js","sources":["../src/components/popover/Popover.tsx"],"sourcesContent":["\"use client\";\r\n\r\nimport * as React from \"react\";\r\nimport * as PopoverPrimitive from \"@radix-ui/react-popover\";\r\nimport type { PopoverContentProps, PopoverProps, PopoverTriggerProps, PopoverAnchorProps } from \"@radix-ui/react-popover\";\r\n\r\nimport { cn } from \"../../lib/utils\";\r\n\r\nconst Popover = PopoverPrimitive.Root;\r\n\r\nconst PopoverTrigger = PopoverPrimitive.Trigger;\r\n\r\nconst PopoverAnchor = PopoverPrimitive.Anchor;\r\n\r\nconst PopoverContent = React.forwardRef<\r\n React.ElementRef<typeof PopoverPrimitive.Content>,\r\n React.ComponentPropsWithoutRef<typeof PopoverPrimitive.Content>\r\n>(({ className, align = \"center\", sideOffset = 4, ...props }, ref) => (\r\n <PopoverPrimitive.Portal>\r\n <PopoverPrimitive.Content\r\n ref={ref}\r\n align={align}\r\n sideOffset={sideOffset}\r\n className={cn(\r\n \"mtx-z-50 mtx-w-72 mtx-rounded-md mtx-border mtx-bg-popover mtx-p-4 mtx-text-popover-foreground mtx-shadow-md mtx-outline-none data-[state=open]:mtx-animate-in data-[state=closed]:mtx-animate-out data-[state=closed]:mtx-fade-out-0 data-[state=open]:mtx-fade-in-0 data-[state=closed]:mtx-zoom-out-95 data-[state=open]:mtx-zoom-in-95 data-[side=bottom]:mtx-slide-in-from-top-2 data-[side=left]:mtx-slide-in-from-right-2 data-[side=right]:mtx-slide-in-from-left-2 data-[side=top]:mtx-slide-in-from-bottom-2\",\r\n className,\r\n )}\r\n {...props}\r\n />\r\n </PopoverPrimitive.Portal>\r\n));\r\nPopoverContent.displayName = PopoverPrimitive.Content.displayName;\r\n\r\nexport {\r\n Popover,\r\n PopoverTrigger,\r\n PopoverContent,\r\n PopoverAnchor,\r\n type PopoverProps,\r\n type PopoverContentProps,\r\n type PopoverTriggerProps,\r\n type PopoverAnchorProps,\r\n};\r\n"],"names":["Popover","PopoverPrimitive","PopoverTrigger","PopoverAnchor","PopoverContent","React","className","align","sideOffset","props","ref","jsx","cn"],"mappings":";;;;AAQA,MAAMA,IAAUC,EAAiB,MAE3BC,IAAiBD,EAAiB,SAElCE,IAAgBF,EAAiB,QAEjCG,IAAiBC,EAAM,WAG3B,CAAC,EAAE,WAAAC,GAAW,OAAAC,IAAQ,UAAU,YAAAC,IAAa,GAAG,GAAGC,EAAA,GAASC,MAC5D,gBAAAC,EAACV,EAAiB,QAAjB,EACC,UAAA,gBAAAU;AAAA,EAACV,EAAiB;AAAA,EAAjB;AAAA,IACC,KAAAS;AAAA,IACA,OAAAH;AAAA,IACA,YAAAC;AAAA,IACA,WAAWI;AAAA,MACT;AAAA,MACAN;AAAA,IAAA;AAAA,IAED,GAAGG;AAAA,EAAA;AACN,GACF,CACD;AACDL,EAAe,cAAcH,EAAiB,QAAQ;"}
|
package/dist/progress.es.js
CHANGED
|
@@ -1,39 +1,47 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import * as
|
|
1
|
+
import { jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import * as l from "react";
|
|
3
3
|
import * as r from "@radix-ui/react-progress";
|
|
4
|
-
import { cn as
|
|
5
|
-
import { tv as
|
|
6
|
-
const
|
|
4
|
+
import { cn as a } from "./utils.es.js";
|
|
5
|
+
import { tv as f } from "tailwind-variants";
|
|
6
|
+
const m = f({
|
|
7
7
|
base: "",
|
|
8
8
|
variants: {
|
|
9
9
|
variant: {
|
|
10
|
-
primary: "bg-primary",
|
|
11
|
-
info: "bg-info",
|
|
12
|
-
success: "bg-success",
|
|
13
|
-
warning: "bg-warning",
|
|
14
|
-
danger: "bg-danger"
|
|
10
|
+
primary: "mtx-bg-primary",
|
|
11
|
+
info: "mtx-bg-info",
|
|
12
|
+
success: "mtx-bg-success",
|
|
13
|
+
warning: "mtx-bg-warning",
|
|
14
|
+
danger: "mtx-bg-danger"
|
|
15
15
|
},
|
|
16
16
|
size: {
|
|
17
|
-
sm: "h-[3px]",
|
|
18
|
-
md: "h-[4px]",
|
|
19
|
-
lg: "h-[5px]"
|
|
17
|
+
sm: "mtx-h-[3px]",
|
|
18
|
+
md: "mtx-h-[4px]",
|
|
19
|
+
lg: "mtx-h-[5px]"
|
|
20
20
|
}
|
|
21
21
|
},
|
|
22
22
|
defaultVariants: {
|
|
23
23
|
variant: "primary",
|
|
24
24
|
size: "md"
|
|
25
25
|
}
|
|
26
|
-
}),
|
|
27
|
-
({ className:
|
|
28
|
-
r.
|
|
26
|
+
}), g = l.forwardRef(
|
|
27
|
+
({ className: s, value: i, variant: o, size: e, ...n }, x) => /* @__PURE__ */ t(
|
|
28
|
+
r.Root,
|
|
29
29
|
{
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
ref: x,
|
|
31
|
+
className: a(m({ size: e }), "mtx-relative mtx-w-full mtx-overflow-hidden mtx-bg-gray-300", s),
|
|
32
|
+
...n,
|
|
33
|
+
children: /* @__PURE__ */ t(
|
|
34
|
+
r.Indicator,
|
|
35
|
+
{
|
|
36
|
+
className: a("mtx-h-full mtx-w-full mtx-flex-1 mtx-transition-all", m({ variant: o })),
|
|
37
|
+
style: { transform: `translateX(-${100 - (i || 0)}%)` }
|
|
38
|
+
}
|
|
39
|
+
)
|
|
32
40
|
}
|
|
33
|
-
)
|
|
41
|
+
)
|
|
34
42
|
);
|
|
35
|
-
|
|
43
|
+
g.displayName = r.Root.displayName;
|
|
36
44
|
export {
|
|
37
|
-
|
|
45
|
+
g as Progress
|
|
38
46
|
};
|
|
39
47
|
//# sourceMappingURL=progress.es.js.map
|