qaema-ui 0.0.23 → 0.0.24
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.
|
@@ -26,6 +26,7 @@ export type DropDownProps = {
|
|
|
26
26
|
isInteractive?: boolean;
|
|
27
27
|
onScroll?: (e: React.UIEvent<HTMLDivElement>) => void;
|
|
28
28
|
variant?: 'light-primary' | 'default';
|
|
29
|
+
endIcon?: React.ReactNode;
|
|
29
30
|
};
|
|
30
31
|
declare const DropDown: React.FC<DropDownProps>;
|
|
31
32
|
export default DropDown;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { j as r } from "../_virtual/jsx-runtime.js";
|
|
2
|
-
import { useRef as g, useState as w, useCallback as
|
|
3
|
-
import { FaTimes as L, FaAngleDown as
|
|
4
|
-
import { ImCheckboxChecked as
|
|
5
|
-
import { useTheme as
|
|
6
|
-
import
|
|
7
|
-
import { useQaemaCoreTranslation as
|
|
8
|
-
import { StyledDropDownContainer as
|
|
9
|
-
import { HelperTextWrapper as
|
|
10
|
-
import
|
|
11
|
-
import
|
|
2
|
+
import { useRef as g, useState as w, useCallback as _, useEffect as C } from "react";
|
|
3
|
+
import { FaTimes as L, FaAngleDown as ee } from "../node_modules/react-icons/fa/index.js";
|
|
4
|
+
import { ImCheckboxChecked as re, ImCheckboxUnchecked as ne } from "../node_modules/react-icons/im/index.js";
|
|
5
|
+
import { useTheme as le } from "styled-components";
|
|
6
|
+
import te from "../hooks/useZIndex.js";
|
|
7
|
+
import { useQaemaCoreTranslation as ae } from "../i18n/i18n.js";
|
|
8
|
+
import { StyledDropDownContainer as se, StyledlabelContainer as oe, StyledDropDown as ce, StyledDropDownToggle as ue, StyledDropDownTitle as de, IconsContainer as ie, StyledDropDownMenu as fe, SearchContainer as he, StyledOptionsContainer as ve, StyledDropItem as W, SelectedTagsContainer as xe, SelectedTag as je } from "../styles/Dropdown.styles.js";
|
|
9
|
+
import { HelperTextWrapper as pe } from "./PhoneInputField.js";
|
|
10
|
+
import Se from "./SearchBar.js";
|
|
11
|
+
import me from "./Spinner.js";
|
|
12
12
|
import z from "./Typography.js";
|
|
13
|
-
const
|
|
13
|
+
const Le = (f) => {
|
|
14
14
|
const {
|
|
15
15
|
label: b,
|
|
16
16
|
options: m,
|
|
@@ -31,25 +31,26 @@ const Ee = (f) => {
|
|
|
31
31
|
multiSelect: c = !1,
|
|
32
32
|
isLoading: B = !1,
|
|
33
33
|
currentSelectedOptions: y = [],
|
|
34
|
-
isInteractive: I = !1
|
|
35
|
-
|
|
34
|
+
isInteractive: I = !1,
|
|
35
|
+
endIcon: Q
|
|
36
|
+
} = f, u = g(null), p = g(null), d = le(), { t: T } = ae(), U = g(null), [a, v] = w(y), [i, k] = w(!1), [Z, q] = w(0), O = N ?? /* @__PURE__ */ r.jsx(r.Fragment, {}), G = te("dropdown"), S = _(() => {
|
|
36
37
|
var e, n;
|
|
37
|
-
(e = u == null ? void 0 : u.current) != null && e.offsetWidth && p.current &&
|
|
38
|
+
(e = u == null ? void 0 : u.current) != null && e.offsetWidth && p.current && q(((n = u.current) == null ? void 0 : n.offsetWidth) / 16);
|
|
38
39
|
}, []);
|
|
39
40
|
C(() => (i && (S(), window.addEventListener("resize", S)), () => window.removeEventListener("resize", S)), [i, S]), C(() => {
|
|
40
41
|
v(y);
|
|
41
42
|
}, [y]);
|
|
42
|
-
const
|
|
43
|
+
const J = (e, n, l, t = "default") => l ? d.colors.grey.n400 : e ? d.colors.state.error.n450 : n ? d.colors.primary.dark.n600 : t === "light-primary" ? d.colors.primary.purple.n450 : d.colors.grey.n300, $ = (e) => a.some((n) => typeof n.value == "object" && typeof e.value == "object" ? n.value[h] === e.value[h] : n.value === e.value), K = (e) => {
|
|
43
44
|
if (c) {
|
|
44
45
|
const n = $(e);
|
|
45
46
|
let l;
|
|
46
47
|
n ? l = a.filter((t) => typeof t.value == "object" && typeof e.value == "object" ? t.value[h] !== e.value[h] : t.value !== e.value) : l = [...a, e], v(l), j(l.map((t) => t.value));
|
|
47
48
|
} else
|
|
48
49
|
v([e]), j(e.value);
|
|
49
|
-
},
|
|
50
|
+
}, V = (e) => {
|
|
50
51
|
const n = a.filter((l) => typeof l.value == "object" && typeof e.value == "object" ? l.value[h] !== e.value[h] : l.value !== e.value);
|
|
51
52
|
v(n), j(n.map((l) => l.value));
|
|
52
|
-
},
|
|
53
|
+
}, X = () => {
|
|
53
54
|
var e;
|
|
54
55
|
return a.length === 0 ? F : c ? `${a.length} ${T("SELECTED")}` : (e = a[0]) == null ? void 0 : e.label;
|
|
55
56
|
};
|
|
@@ -61,14 +62,14 @@ const Ee = (f) => {
|
|
|
61
62
|
document.removeEventListener("mousedown", e);
|
|
62
63
|
};
|
|
63
64
|
}, [i, o]);
|
|
64
|
-
const
|
|
65
|
-
return /* @__PURE__ */ r.jsxs(
|
|
66
|
-
b && /* @__PURE__ */ r.jsxs(
|
|
65
|
+
const Y = () => I || (s == null ? void 0 : s.length) === 0 ? null : /* @__PURE__ */ r.jsx(pe, { error: s, children: s });
|
|
66
|
+
return /* @__PURE__ */ r.jsxs(se, { children: [
|
|
67
|
+
b && /* @__PURE__ */ r.jsxs(oe, { children: [
|
|
67
68
|
/* @__PURE__ */ r.jsx("label", { children: b }),
|
|
68
69
|
H && /* @__PURE__ */ r.jsx("span", { children: T("OPTIONAL") })
|
|
69
70
|
] }),
|
|
70
71
|
/* @__PURE__ */ r.jsxs(
|
|
71
|
-
|
|
72
|
+
ce,
|
|
72
73
|
{
|
|
73
74
|
show: i,
|
|
74
75
|
onToggle: () => {
|
|
@@ -77,7 +78,7 @@ const Ee = (f) => {
|
|
|
77
78
|
placement: "bottom-start",
|
|
78
79
|
autoClose: c ? "outside" : !0,
|
|
79
80
|
children: [
|
|
80
|
-
/* @__PURE__ */ r.jsx(
|
|
81
|
+
/* @__PURE__ */ r.jsx(ue, { disabled: x, ref: u, $valid: !s, $variant: f.variant || "default", children: /* @__PURE__ */ r.jsx(de, { $valid: !s, $isInteractive: I, children: /* @__PURE__ */ r.jsxs("div", { className: "title-container", children: [
|
|
81
82
|
/* @__PURE__ */ r.jsxs("div", { className: "heading-container", children: [
|
|
82
83
|
M && typeof O == "function" && /* @__PURE__ */ r.jsx(O, {}),
|
|
83
84
|
/* @__PURE__ */ r.jsx(
|
|
@@ -85,12 +86,13 @@ const Ee = (f) => {
|
|
|
85
86
|
{
|
|
86
87
|
component: "span",
|
|
87
88
|
variant: "mdText",
|
|
88
|
-
color:
|
|
89
|
-
children:
|
|
89
|
+
color: J(s, a.length > 0, x, f.variant || "default"),
|
|
90
|
+
children: X()
|
|
90
91
|
}
|
|
91
92
|
)
|
|
92
93
|
] }),
|
|
93
|
-
/* @__PURE__ */ r.jsxs(
|
|
94
|
+
/* @__PURE__ */ r.jsxs(ie, { children: [
|
|
95
|
+
Q,
|
|
94
96
|
!c && a.length > 0 && !x && /* @__PURE__ */ r.jsx(
|
|
95
97
|
L,
|
|
96
98
|
{
|
|
@@ -100,15 +102,15 @@ const Ee = (f) => {
|
|
|
100
102
|
}
|
|
101
103
|
}
|
|
102
104
|
),
|
|
103
|
-
!x && /* @__PURE__ */ r.jsx(
|
|
105
|
+
!x && /* @__PURE__ */ r.jsx(ee, {})
|
|
104
106
|
] })
|
|
105
107
|
] }) }) }),
|
|
106
|
-
i && /* @__PURE__ */ r.jsxs(
|
|
107
|
-
P && /* @__PURE__ */ r.jsx(
|
|
108
|
+
i && /* @__PURE__ */ r.jsxs(fe, { ref: p, $menuWidth: Z, $zIndex: G, children: [
|
|
109
|
+
P && /* @__PURE__ */ r.jsx(he, { children: /* @__PURE__ */ r.jsx(Se, { placeholder: A, onSearch: R }) }),
|
|
108
110
|
/* @__PURE__ */ r.jsxs(
|
|
109
|
-
|
|
111
|
+
ve,
|
|
110
112
|
{
|
|
111
|
-
ref:
|
|
113
|
+
ref: U,
|
|
112
114
|
onScroll: (e) => {
|
|
113
115
|
var n;
|
|
114
116
|
(n = f.onScroll) == null || n.call(f, e);
|
|
@@ -120,10 +122,10 @@ const Ee = (f) => {
|
|
|
120
122
|
return /* @__PURE__ */ r.jsxs(
|
|
121
123
|
W,
|
|
122
124
|
{
|
|
123
|
-
onClick: () =>
|
|
125
|
+
onClick: () => K(e),
|
|
124
126
|
$selected: n,
|
|
125
127
|
children: [
|
|
126
|
-
c && (n ? /* @__PURE__ */ r.jsx(
|
|
128
|
+
c && (n ? /* @__PURE__ */ r.jsx(re, { color: d.colors.primary.purple.n500 }) : /* @__PURE__ */ r.jsx(ne, { color: d.colors.primary.purple.n450 })),
|
|
127
129
|
" ",
|
|
128
130
|
/* @__PURE__ */ r.jsx(z, { variant: "smText", children: e == null ? void 0 : e.label })
|
|
129
131
|
]
|
|
@@ -131,7 +133,7 @@ const Ee = (f) => {
|
|
|
131
133
|
typeof (e == null ? void 0 : e.value) == "object" && (e == null ? void 0 : e.value) !== null ? (t = (l = e == null ? void 0 : e.value) == null ? void 0 : l[D]) == null ? void 0 : t.toString() : (E = e == null ? void 0 : e.value) == null ? void 0 : E.toString()
|
|
132
134
|
);
|
|
133
135
|
}),
|
|
134
|
-
B && /* @__PURE__ */ r.jsx(W, { $selected: !1, children: /* @__PURE__ */ r.jsx(
|
|
136
|
+
B && /* @__PURE__ */ r.jsx(W, { $selected: !1, children: /* @__PURE__ */ r.jsx(me, {}) })
|
|
135
137
|
]
|
|
136
138
|
}
|
|
137
139
|
)
|
|
@@ -139,22 +141,22 @@ const Ee = (f) => {
|
|
|
139
141
|
]
|
|
140
142
|
}
|
|
141
143
|
),
|
|
142
|
-
c && a.length > 0 && /* @__PURE__ */ r.jsx(
|
|
144
|
+
c && a.length > 0 && /* @__PURE__ */ r.jsx(xe, { children: a.map((e) => {
|
|
143
145
|
var n, l, t;
|
|
144
146
|
return /* @__PURE__ */ r.jsxs(
|
|
145
|
-
|
|
147
|
+
je,
|
|
146
148
|
{
|
|
147
149
|
children: [
|
|
148
150
|
e.label,
|
|
149
|
-
/* @__PURE__ */ r.jsx(L, { onClick: () =>
|
|
151
|
+
/* @__PURE__ */ r.jsx(L, { onClick: () => V(e) })
|
|
150
152
|
]
|
|
151
153
|
},
|
|
152
154
|
typeof (e == null ? void 0 : e.value) == "object" ? (l = (n = e == null ? void 0 : e.value) == null ? void 0 : n[D]) == null ? void 0 : l.toString() : (t = e == null ? void 0 : e.value) == null ? void 0 : t.toString()
|
|
153
155
|
);
|
|
154
156
|
}) }),
|
|
155
|
-
|
|
157
|
+
Y()
|
|
156
158
|
] });
|
|
157
159
|
};
|
|
158
160
|
export {
|
|
159
|
-
|
|
161
|
+
Le as default
|
|
160
162
|
};
|