qaema-ui 0.0.22 → 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.
|
@@ -11,8 +11,8 @@ import { isAfter as z } from "../node_modules/date-fns/isAfter.js";
|
|
|
11
11
|
import { isValid as ce } from "../node_modules/date-fns/isValid.js";
|
|
12
12
|
import { arSA as de } from "../node_modules/date-fns/locale/ar-SA.js";
|
|
13
13
|
import { enUS as pe } from "../node_modules/date-fns/locale/en-US.js";
|
|
14
|
-
import { addMonths as
|
|
15
|
-
import { subMonths as
|
|
14
|
+
import { addMonths as ge } from "../node_modules/date-fns/addMonths.js";
|
|
15
|
+
import { subMonths as me } from "../node_modules/date-fns/subMonths.js";
|
|
16
16
|
import { startOfWeek as fe } from "../node_modules/date-fns/startOfWeek.js";
|
|
17
17
|
import { startOfMonth as ue } from "../node_modules/date-fns/startOfMonth.js";
|
|
18
18
|
import { endOfWeek as he } from "../node_modules/date-fns/endOfWeek.js";
|
|
@@ -156,6 +156,7 @@ const De = i.div`
|
|
|
156
156
|
font-size: ${({ theme: e }) => e.typography.sizes.s4};
|
|
157
157
|
font-weight: 400;
|
|
158
158
|
text-align: ${({ theme: e }) => e.dir === "rtl" ? "right" : "left"};
|
|
159
|
+
line-height: ${({ theme: e }) => e.typography.lineHeights.s};
|
|
159
160
|
`, Ee = i.span`
|
|
160
161
|
color: ${({ theme: e }) => e.colors.grey.n300};
|
|
161
162
|
font-size: ${({ theme: e }) => e.typography.sizes.s2};
|
|
@@ -164,7 +165,7 @@ const De = i.div`
|
|
|
164
165
|
justify-content: ${({ theme: e }) => e.dir === "rtl" ? "flex-end" : "flex-start"};
|
|
165
166
|
text-align: ${({ theme: e }) => e.dir === "rtl" ? "right" : "left"};
|
|
166
167
|
`, fr = ({ value: e, onChange: a, minDate: d, maxDate: x, label: v, optional: O, disabled: W, error: D }) => {
|
|
167
|
-
const [E, $] = f(!1), [p,
|
|
168
|
+
const [E, $] = f(!1), [p, g] = f(e || /* @__PURE__ */ new Date()), [w, u] = f(e || null), [I, h] = f(e ? b(e, "dd/MM/yyyy") : ""), [M, j] = f("calendar"), [T, R] = f(0), S = re(null), k = /* @__PURE__ */ new Date(), C = ie(), { t: V, i18n: H } = te(), l = (H.language || "").toLowerCase().startsWith("ar") || C.dir === "rtl", y = l ? "rtl" : "ltr", P = l ? de : pe, J = l ? ["أح", "اث", "ثل", "أر", "خم", "جم", "سب"] : ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"], B = l ? ["يناير", "فبراير", "مارس", "أبريل", "مايو", "يونيو", "يوليو", "أغسطس", "سبتمبر", "أكتوبر", "نوفمبر", "ديسمبر"] : ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], m = (r) => {
|
|
168
169
|
const s = ["٠", "١", "٢", "٣", "٤", "٥", "٦", "٧", "٨", "٩"];
|
|
169
170
|
return r.toString().replace(/\d/g, (n) => s[Number(n)]);
|
|
170
171
|
}, _ = (r) => {
|
|
@@ -179,7 +180,7 @@ const De = i.div`
|
|
|
179
180
|
}, []), A(() => {
|
|
180
181
|
if (e) {
|
|
181
182
|
const r = b(e, "dd/MM/yyyy");
|
|
182
|
-
u(e),
|
|
183
|
+
u(e), g(e), h(l ? m(r) : r);
|
|
183
184
|
} else
|
|
184
185
|
u(null), h("");
|
|
185
186
|
}, [e, l]);
|
|
@@ -191,10 +192,10 @@ const De = i.div`
|
|
|
191
192
|
return;
|
|
192
193
|
}
|
|
193
194
|
n.length >= 3 && (n = n.slice(0, 2) + "/" + n.slice(2)), n.length >= 6 && (n = n.slice(0, 5) + "/" + n.slice(5, 9));
|
|
194
|
-
const t = l ?
|
|
195
|
+
const t = l ? m(n) : n;
|
|
195
196
|
if (h(t), n.length === 10) {
|
|
196
197
|
const c = le(n, "dd/MM/yyyy", /* @__PURE__ */ new Date()), ee = d && L(c, d) || x && z(c, x);
|
|
197
|
-
ce(c) && !ee && (u(c),
|
|
198
|
+
ce(c) && !ee && (u(c), g(c), a(c));
|
|
198
199
|
}
|
|
199
200
|
}, U = () => {
|
|
200
201
|
const r = fe(ue(p), { weekStartsOn: 0 }), s = he(ye(p), { weekStartsOn: 0 }), n = [];
|
|
@@ -208,9 +209,9 @@ const De = i.div`
|
|
|
208
209
|
disabled: c,
|
|
209
210
|
selected: w ? $e(t, w) : !1,
|
|
210
211
|
onClick: () => {
|
|
211
|
-
c || (u(t), h(l ?
|
|
212
|
+
c || (u(t), h(l ? m(b(t, "dd/MM/yyyy")) : b(t, "dd/MM/yyyy")), a(t), $(!1));
|
|
212
213
|
},
|
|
213
|
-
children: l ?
|
|
214
|
+
children: l ? m(t.getDate()) : t.getDate()
|
|
214
215
|
},
|
|
215
216
|
t.toISOString()
|
|
216
217
|
)
|
|
@@ -221,15 +222,15 @@ const De = i.div`
|
|
|
221
222
|
const s = we(/* @__PURE__ */ new Date()) + T * 12;
|
|
222
223
|
return Array.from({ length: 12 }, (n, t) => s + t);
|
|
223
224
|
}, K = (r) => {
|
|
224
|
-
|
|
225
|
+
g(Me(p, r)), j("month");
|
|
225
226
|
}, Q = (r) => {
|
|
226
227
|
const s = je(p, r);
|
|
227
|
-
|
|
228
|
+
g(s), j("calendar");
|
|
228
229
|
}, X = () => {
|
|
229
230
|
const r = y === "rtl", s = () => {
|
|
230
|
-
M === "calendar" ?
|
|
231
|
+
M === "calendar" ? g(me(p)) : R((t) => t - 1);
|
|
231
232
|
}, n = () => {
|
|
232
|
-
M === "calendar" ?
|
|
233
|
+
M === "calendar" ? g(ge(p, 1)) : R((t) => t + 1);
|
|
233
234
|
};
|
|
234
235
|
return /* @__PURE__ */ o.jsxs(Re, { children: [
|
|
235
236
|
/* @__PURE__ */ o.jsx(
|
|
@@ -245,7 +246,7 @@ const De = i.div`
|
|
|
245
246
|
/* @__PURE__ */ o.jsxs("div", { onClick: () => j("year"), children: [
|
|
246
247
|
(() => {
|
|
247
248
|
const t = b(p, "MMMM yyyy", { locale: P });
|
|
248
|
-
return l ?
|
|
249
|
+
return l ? m(t) : t;
|
|
249
250
|
})(),
|
|
250
251
|
/* @__PURE__ */ o.jsx(ne, { color: C.colors.grey.n300, size: 12 })
|
|
251
252
|
] }),
|
|
@@ -272,7 +273,7 @@ const De = i.div`
|
|
|
272
273
|
children: V("SET_DATE")
|
|
273
274
|
}
|
|
274
275
|
) })
|
|
275
|
-
] }) : M === "year" ? /* @__PURE__ */ o.jsx(F, { children: /* @__PURE__ */ o.jsx(Fe, { children: q().map((r) => /* @__PURE__ */ o.jsx(N, { onClick: () => K(r), children: l ?
|
|
276
|
+
] }) : M === "year" ? /* @__PURE__ */ o.jsx(F, { children: /* @__PURE__ */ o.jsx(Fe, { children: q().map((r) => /* @__PURE__ */ o.jsx(N, { onClick: () => K(r), children: l ? m(r) : r }, r)) }) }) : /* @__PURE__ */ o.jsx(F, { children: /* @__PURE__ */ o.jsx(Ne, { children: B.map((r, s) => /* @__PURE__ */ o.jsx(N, { onClick: () => Q(s), children: r }, `${r}-${s}`)) }) });
|
|
276
277
|
return /* @__PURE__ */ o.jsxs(De, { ref: S, children: [
|
|
277
278
|
v && /* @__PURE__ */ o.jsxs(We, { children: [
|
|
278
279
|
v,
|
|
@@ -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,83 +1,84 @@
|
|
|
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,
|
|
17
17
|
// value,
|
|
18
18
|
placeholder: F = "Select Something",
|
|
19
19
|
optional: H = !1,
|
|
20
|
-
error:
|
|
20
|
+
error: s = "",
|
|
21
21
|
disabled: x = !1,
|
|
22
22
|
selectIdentifier: D,
|
|
23
|
-
keyIdentifier:
|
|
23
|
+
keyIdentifier: h = "id",
|
|
24
24
|
selectCallBack: j,
|
|
25
25
|
showLeadIcon: M,
|
|
26
26
|
icon: N,
|
|
27
27
|
allowSearch: P,
|
|
28
28
|
searchHandler: R,
|
|
29
29
|
searchPlaceholder: A,
|
|
30
|
-
onToggle:
|
|
31
|
-
multiSelect:
|
|
30
|
+
onToggle: o,
|
|
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 =
|
|
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
|
-
C(() => (
|
|
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
|
-
if (
|
|
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) => {
|
|
44
|
+
if (c) {
|
|
44
45
|
const n = $(e);
|
|
45
46
|
let l;
|
|
46
|
-
n ? l = a.filter((t) => typeof t.value == "object" && typeof e.value == "object" ? t.value[
|
|
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
|
-
const n = a.filter((l) => typeof l.value == "object" && typeof e.value == "object" ? l.value[
|
|
50
|
+
}, V = (e) => {
|
|
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
|
-
return a.length === 0 ? F :
|
|
55
|
+
return a.length === 0 ? F : c ? `${a.length} ${T("SELECTED")}` : (e = a[0]) == null ? void 0 : e.label;
|
|
55
56
|
};
|
|
56
57
|
C(() => {
|
|
57
58
|
const e = (n) => {
|
|
58
|
-
p.current &&
|
|
59
|
+
p.current && u.current && !p.current.contains(n.target) && !u.current.contains(n.target) && (k(!1), o == null || o(!1));
|
|
59
60
|
};
|
|
60
|
-
return
|
|
61
|
+
return i && document.addEventListener("mousedown", e), () => {
|
|
61
62
|
document.removeEventListener("mousedown", e);
|
|
62
63
|
};
|
|
63
|
-
}, [
|
|
64
|
-
const
|
|
65
|
-
return /* @__PURE__ */ r.jsxs(
|
|
66
|
-
b && /* @__PURE__ */ r.jsxs(
|
|
64
|
+
}, [i, o]);
|
|
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
|
-
show:
|
|
74
|
+
show: i,
|
|
74
75
|
onToggle: () => {
|
|
75
|
-
|
|
76
|
+
o == null || o(!i), k((e) => !e);
|
|
76
77
|
},
|
|
77
78
|
placement: "bottom-start",
|
|
78
|
-
autoClose:
|
|
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,33 +86,34 @@ const Ee = (i) => {
|
|
|
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
|
-
|
|
94
|
+
/* @__PURE__ */ r.jsxs(ie, { children: [
|
|
95
|
+
Q,
|
|
96
|
+
!c && a.length > 0 && !x && /* @__PURE__ */ r.jsx(
|
|
95
97
|
L,
|
|
96
98
|
{
|
|
97
99
|
style: { cursor: "pointer", marginLeft: "0.5rem" },
|
|
98
100
|
onClick: (e) => {
|
|
99
|
-
e.stopPropagation(), v([]), j(
|
|
101
|
+
e.stopPropagation(), v([]), j(c ? [] : "");
|
|
100
102
|
}
|
|
101
103
|
}
|
|
102
104
|
),
|
|
103
|
-
!x && /* @__PURE__ */ r.jsx(
|
|
105
|
+
!x && /* @__PURE__ */ r.jsx(ee, {})
|
|
104
106
|
] })
|
|
105
107
|
] }) }) }),
|
|
106
|
-
|
|
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
|
-
(n =
|
|
116
|
+
(n = f.onScroll) == null || n.call(f, e);
|
|
115
117
|
},
|
|
116
118
|
children: [
|
|
117
119
|
m == null ? void 0 : m.map((e) => {
|
|
@@ -120,10 +122,10 @@ const Ee = (i) => {
|
|
|
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
|
-
|
|
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 = (i) => {
|
|
|
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 = (i) => {
|
|
|
139
141
|
]
|
|
140
142
|
}
|
|
141
143
|
),
|
|
142
|
-
|
|
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
|
};
|