qaema-ui 0.0.22 → 0.0.23
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/components/DatePicker.js +15 -14
- package/dist/components/DropDown.js +28 -28
- package/package.json +1 -1
|
@@ -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,
|
|
@@ -10,58 +10,58 @@ import { HelperTextWrapper as je } from "./PhoneInputField.js";
|
|
|
10
10
|
import pe from "./SearchBar.js";
|
|
11
11
|
import Se from "./Spinner.js";
|
|
12
12
|
import z from "./Typography.js";
|
|
13
|
-
const Ee = (
|
|
13
|
+
const Ee = (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
34
|
isInteractive: I = !1
|
|
35
|
-
} =
|
|
35
|
+
} = f, u = g(null), p = g(null), d = ne(), { t: T } = te(), Q = g(null), [a, v] = w(y), [i, k] = w(!1), [U, Z] = w(0), O = N ?? /* @__PURE__ */ r.jsx(r.Fragment, {}), q = le("dropdown"), S = Y(() => {
|
|
36
36
|
var e, n;
|
|
37
|
-
(e =
|
|
37
|
+
(e = u == null ? void 0 : u.current) != null && e.offsetWidth && p.current && Z(((n = u.current) == null ? void 0 : n.offsetWidth) / 16);
|
|
38
38
|
}, []);
|
|
39
|
-
C(() => (
|
|
39
|
+
C(() => (i && (S(), window.addEventListener("resize", S)), () => window.removeEventListener("resize", S)), [i, S]), C(() => {
|
|
40
40
|
v(y);
|
|
41
41
|
}, [y]);
|
|
42
|
-
const G = (e, n, l, t = "default") => l ?
|
|
43
|
-
if (
|
|
42
|
+
const G = (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), J = (e) => {
|
|
43
|
+
if (c) {
|
|
44
44
|
const n = $(e);
|
|
45
45
|
let l;
|
|
46
|
-
n ? l = a.filter((t) => typeof t.value == "object" && typeof e.value == "object" ? t.value[
|
|
46
|
+
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
47
|
} else
|
|
48
48
|
v([e]), j(e.value);
|
|
49
49
|
}, K = (e) => {
|
|
50
|
-
const n = a.filter((l) => typeof l.value == "object" && typeof e.value == "object" ? l.value[
|
|
50
|
+
const n = a.filter((l) => typeof l.value == "object" && typeof e.value == "object" ? l.value[h] !== e.value[h] : l.value !== e.value);
|
|
51
51
|
v(n), j(n.map((l) => l.value));
|
|
52
52
|
}, V = () => {
|
|
53
53
|
var e;
|
|
54
|
-
return a.length === 0 ? F :
|
|
54
|
+
return a.length === 0 ? F : c ? `${a.length} ${T("SELECTED")}` : (e = a[0]) == null ? void 0 : e.label;
|
|
55
55
|
};
|
|
56
56
|
C(() => {
|
|
57
57
|
const e = (n) => {
|
|
58
|
-
p.current &&
|
|
58
|
+
p.current && u.current && !p.current.contains(n.target) && !u.current.contains(n.target) && (k(!1), o == null || o(!1));
|
|
59
59
|
};
|
|
60
|
-
return
|
|
60
|
+
return i && document.addEventListener("mousedown", e), () => {
|
|
61
61
|
document.removeEventListener("mousedown", e);
|
|
62
62
|
};
|
|
63
|
-
}, [
|
|
64
|
-
const X = () => I ? null : /* @__PURE__ */ r.jsx(je, { error:
|
|
63
|
+
}, [i, o]);
|
|
64
|
+
const X = () => I || (s == null ? void 0 : s.length) === 0 ? null : /* @__PURE__ */ r.jsx(je, { error: s, children: s });
|
|
65
65
|
return /* @__PURE__ */ r.jsxs(ae, { children: [
|
|
66
66
|
b && /* @__PURE__ */ r.jsxs(se, { children: [
|
|
67
67
|
/* @__PURE__ */ r.jsx("label", { children: b }),
|
|
@@ -70,14 +70,14 @@ const Ee = (i) => {
|
|
|
70
70
|
/* @__PURE__ */ r.jsxs(
|
|
71
71
|
oe,
|
|
72
72
|
{
|
|
73
|
-
show:
|
|
73
|
+
show: i,
|
|
74
74
|
onToggle: () => {
|
|
75
|
-
|
|
75
|
+
o == null || o(!i), k((e) => !e);
|
|
76
76
|
},
|
|
77
77
|
placement: "bottom-start",
|
|
78
|
-
autoClose:
|
|
78
|
+
autoClose: c ? "outside" : !0,
|
|
79
79
|
children: [
|
|
80
|
-
/* @__PURE__ */ r.jsx(ce, { disabled: x, ref:
|
|
80
|
+
/* @__PURE__ */ r.jsx(ce, { disabled: x, ref: u, $valid: !s, $variant: f.variant || "default", children: /* @__PURE__ */ r.jsx(ue, { $valid: !s, $isInteractive: I, children: /* @__PURE__ */ r.jsxs("div", { className: "title-container", children: [
|
|
81
81
|
/* @__PURE__ */ r.jsxs("div", { className: "heading-container", children: [
|
|
82
82
|
M && typeof O == "function" && /* @__PURE__ */ r.jsx(O, {}),
|
|
83
83
|
/* @__PURE__ */ r.jsx(
|
|
@@ -85,25 +85,25 @@ const Ee = (i) => {
|
|
|
85
85
|
{
|
|
86
86
|
component: "span",
|
|
87
87
|
variant: "mdText",
|
|
88
|
-
color: G(
|
|
88
|
+
color: G(s, a.length > 0, x, f.variant || "default"),
|
|
89
89
|
children: V()
|
|
90
90
|
}
|
|
91
91
|
)
|
|
92
92
|
] }),
|
|
93
93
|
/* @__PURE__ */ r.jsxs(de, { children: [
|
|
94
|
-
!
|
|
94
|
+
!c && a.length > 0 && !x && /* @__PURE__ */ r.jsx(
|
|
95
95
|
L,
|
|
96
96
|
{
|
|
97
97
|
style: { cursor: "pointer", marginLeft: "0.5rem" },
|
|
98
98
|
onClick: (e) => {
|
|
99
|
-
e.stopPropagation(), v([]), j(
|
|
99
|
+
e.stopPropagation(), v([]), j(c ? [] : "");
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
102
|
),
|
|
103
103
|
!x && /* @__PURE__ */ r.jsx(_, {})
|
|
104
104
|
] })
|
|
105
105
|
] }) }) }),
|
|
106
|
-
|
|
106
|
+
i && /* @__PURE__ */ r.jsxs(ie, { ref: p, $menuWidth: U, $zIndex: q, children: [
|
|
107
107
|
P && /* @__PURE__ */ r.jsx(fe, { children: /* @__PURE__ */ r.jsx(pe, { placeholder: A, onSearch: R }) }),
|
|
108
108
|
/* @__PURE__ */ r.jsxs(
|
|
109
109
|
he,
|
|
@@ -111,7 +111,7 @@ const Ee = (i) => {
|
|
|
111
111
|
ref: Q,
|
|
112
112
|
onScroll: (e) => {
|
|
113
113
|
var n;
|
|
114
|
-
(n =
|
|
114
|
+
(n = f.onScroll) == null || n.call(f, e);
|
|
115
115
|
},
|
|
116
116
|
children: [
|
|
117
117
|
m == null ? void 0 : m.map((e) => {
|
|
@@ -123,7 +123,7 @@ const Ee = (i) => {
|
|
|
123
123
|
onClick: () => J(e),
|
|
124
124
|
$selected: n,
|
|
125
125
|
children: [
|
|
126
|
-
|
|
126
|
+
c && (n ? /* @__PURE__ */ r.jsx(ee, { color: d.colors.primary.purple.n500 }) : /* @__PURE__ */ r.jsx(re, { color: d.colors.primary.purple.n450 })),
|
|
127
127
|
" ",
|
|
128
128
|
/* @__PURE__ */ r.jsx(z, { variant: "smText", children: e == null ? void 0 : e.label })
|
|
129
129
|
]
|
|
@@ -139,7 +139,7 @@ const Ee = (i) => {
|
|
|
139
139
|
]
|
|
140
140
|
}
|
|
141
141
|
),
|
|
142
|
-
|
|
142
|
+
c && a.length > 0 && /* @__PURE__ */ r.jsx(ve, { children: a.map((e) => {
|
|
143
143
|
var n, l, t;
|
|
144
144
|
return /* @__PURE__ */ r.jsxs(
|
|
145
145
|
xe,
|