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 me } from "../node_modules/date-fns/addMonths.js";
15
- import { subMonths as ge } from "../node_modules/date-fns/subMonths.js";
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, m] = 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"], g = (r) => {
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), m(e), h(l ? g(r) : r);
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 ? g(n) : n;
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), m(c), a(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 ? g(b(t, "dd/MM/yyyy")) : b(t, "dd/MM/yyyy")), a(t), $(!1));
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 ? g(t.getDate()) : t.getDate()
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
- m(Me(p, r)), j("month");
225
+ g(Me(p, r)), j("month");
225
226
  }, Q = (r) => {
226
227
  const s = je(p, r);
227
- m(s), j("calendar");
228
+ g(s), j("calendar");
228
229
  }, X = () => {
229
230
  const r = y === "rtl", s = () => {
230
- M === "calendar" ? m(ge(p)) : R((t) => t - 1);
231
+ M === "calendar" ? g(me(p)) : R((t) => t - 1);
231
232
  }, n = () => {
232
- M === "calendar" ? m(me(p, 1)) : R((t) => t + 1);
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 ? g(t) : t;
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 ? g(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
+ ] }) : 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 Y, useEffect as C } from "react";
3
- import { FaTimes as L, FaAngleDown as _ } from "../node_modules/react-icons/fa/index.js";
4
- import { ImCheckboxChecked as ee, ImCheckboxUnchecked as re } from "../node_modules/react-icons/im/index.js";
5
- import { useTheme as ne } from "styled-components";
6
- import le from "../hooks/useZIndex.js";
7
- import { useQaemaCoreTranslation as te } from "../i18n/i18n.js";
8
- import { StyledDropDownContainer as ae, StyledlabelContainer as se, StyledDropDown as oe, StyledDropDownToggle as ce, StyledDropDownTitle as ue, IconsContainer as de, StyledDropDownMenu as ie, SearchContainer as fe, StyledOptionsContainer as he, StyledDropItem as W, SelectedTagsContainer as ve, SelectedTag as xe } from "../styles/Dropdown.styles.js";
9
- import { HelperTextWrapper as je } from "./PhoneInputField.js";
10
- import pe from "./SearchBar.js";
11
- import Se from "./Spinner.js";
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 Ee = (i) => {
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: h = "",
20
+ error: s = "",
21
21
  disabled: x = !1,
22
22
  selectIdentifier: D,
23
- keyIdentifier: f = "id",
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: s,
31
- multiSelect: o = !1,
30
+ onToggle: o,
31
+ multiSelect: c = !1,
32
32
  isLoading: B = !1,
33
33
  currentSelectedOptions: y = [],
34
- isInteractive: I = !1
35
- } = i, c = g(null), p = g(null), u = ne(), { t: T } = te(), Q = g(null), [a, v] = w(y), [d, k] = w(!1), [U, Z] = w(0), O = N ?? /* @__PURE__ */ r.jsx(r.Fragment, {}), q = le("dropdown"), S = Y(() => {
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 = c == null ? void 0 : c.current) != null && e.offsetWidth && p.current && Z(((n = c.current) == null ? void 0 : n.offsetWidth) / 16);
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(() => (d && (S(), window.addEventListener("resize", S)), () => window.removeEventListener("resize", S)), [d, S]), 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 G = (e, n, l, t = "default") => l ? u.colors.grey.n400 : e ? u.colors.state.error.n450 : n ? u.colors.primary.dark.n600 : t === "light-primary" ? u.colors.primary.purple.n450 : u.colors.grey.n300, $ = (e) => a.some((n) => typeof n.value == "object" && typeof e.value == "object" ? n.value[f] === e.value[f] : n.value === e.value), J = (e) => {
43
- if (o) {
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[f] !== e.value[f] : t.value !== e.value) : l = [...a, e], v(l), j(l.map((t) => 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
- }, K = (e) => {
50
- const n = a.filter((l) => typeof l.value == "object" && typeof e.value == "object" ? l.value[f] !== e.value[f] : l.value !== e.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
- }, V = () => {
53
+ }, X = () => {
53
54
  var e;
54
- return a.length === 0 ? F : o ? `${a.length} ${T("SELECTED")}` : (e = a[0]) == null ? void 0 : e.label;
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 && c.current && !p.current.contains(n.target) && !c.current.contains(n.target) && (k(!1), s == null || s(!1));
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 d && document.addEventListener("mousedown", e), () => {
61
+ return i && document.addEventListener("mousedown", e), () => {
61
62
  document.removeEventListener("mousedown", e);
62
63
  };
63
- }, [d, s]);
64
- const X = () => I ? null : /* @__PURE__ */ r.jsx(je, { error: h, children: h });
65
- return /* @__PURE__ */ r.jsxs(ae, { children: [
66
- b && /* @__PURE__ */ r.jsxs(se, { children: [
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
- oe,
72
+ ce,
72
73
  {
73
- show: d,
74
+ show: i,
74
75
  onToggle: () => {
75
- s == null || s(!d), k((e) => !e);
76
+ o == null || o(!i), k((e) => !e);
76
77
  },
77
78
  placement: "bottom-start",
78
- autoClose: o ? "outside" : !0,
79
+ autoClose: c ? "outside" : !0,
79
80
  children: [
80
- /* @__PURE__ */ r.jsx(ce, { disabled: x, ref: c, $valid: !h, $variant: i.variant || "default", children: /* @__PURE__ */ r.jsx(ue, { $valid: !h, $isInteractive: I, children: /* @__PURE__ */ r.jsxs("div", { className: "title-container", children: [
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: G(h, a.length > 0, x, i.variant || "default"),
89
- children: V()
89
+ color: J(s, a.length > 0, x, f.variant || "default"),
90
+ children: X()
90
91
  }
91
92
  )
92
93
  ] }),
93
- /* @__PURE__ */ r.jsxs(de, { children: [
94
- !o && a.length > 0 && !x && /* @__PURE__ */ r.jsx(
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(o ? [] : "");
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
- d && /* @__PURE__ */ r.jsxs(ie, { ref: p, $menuWidth: U, $zIndex: q, children: [
107
- P && /* @__PURE__ */ r.jsx(fe, { children: /* @__PURE__ */ r.jsx(pe, { placeholder: A, onSearch: R }) }),
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
- he,
111
+ ve,
110
112
  {
111
- ref: Q,
113
+ ref: U,
112
114
  onScroll: (e) => {
113
115
  var n;
114
- (n = i.onScroll) == null || n.call(i, e);
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: () => J(e),
125
+ onClick: () => K(e),
124
126
  $selected: n,
125
127
  children: [
126
- o && (n ? /* @__PURE__ */ r.jsx(ee, { color: u.colors.primary.purple.n500 }) : /* @__PURE__ */ r.jsx(re, { color: u.colors.primary.purple.n450 })),
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(Se, {}) })
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
- o && a.length > 0 && /* @__PURE__ */ r.jsx(ve, { children: a.map((e) => {
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
- xe,
147
+ je,
146
148
  {
147
149
  children: [
148
150
  e.label,
149
- /* @__PURE__ */ r.jsx(L, { onClick: () => K(e) })
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
- X()
157
+ Y()
156
158
  ] });
157
159
  };
158
160
  export {
159
- Ee as default
161
+ Le as default
160
162
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "qaema-ui",
3
3
  "private": false,
4
- "version": "0.0.22",
4
+ "version": "0.0.24",
5
5
  "type": "module",
6
6
  "publishConfig": {
7
7
  "access": "public"