qaema-ui 0.0.45 → 0.0.46
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 +106 -106
- package/package.json +1 -1
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
import { j as
|
|
2
|
-
import { useState as f, useRef as
|
|
3
|
-
import { useTranslation as
|
|
4
|
-
import { FaRegCalendarAlt as
|
|
5
|
-
import i, { useTheme as
|
|
6
|
-
import
|
|
1
|
+
import { j as n } from "../_virtual/jsx-runtime.js";
|
|
2
|
+
import { useState as f, useRef as te, useEffect as A } from "react";
|
|
3
|
+
import { useTranslation as oe } from "react-i18next";
|
|
4
|
+
import { FaRegCalendarAlt as ne, FaAngleDown as se, FaAngleLeft as ie } from "../node_modules/react-icons/fa/index.js";
|
|
5
|
+
import i, { useTheme as ae } from "styled-components";
|
|
6
|
+
import le from "./Hint.js";
|
|
7
7
|
import { formatDate as b } from "../node_modules/date-fns/format.js";
|
|
8
|
-
import { parse as
|
|
8
|
+
import { parse as ce } from "../node_modules/date-fns/parse.js";
|
|
9
9
|
import { isBefore as L } from "../node_modules/date-fns/isBefore.js";
|
|
10
10
|
import { isAfter as z } from "../node_modules/date-fns/isAfter.js";
|
|
11
|
-
import { isValid as
|
|
12
|
-
import { arSA as
|
|
13
|
-
import { enUS as
|
|
11
|
+
import { isValid as de } from "../node_modules/date-fns/isValid.js";
|
|
12
|
+
import { arSA as pe } from "../node_modules/date-fns/locale/ar-SA.js";
|
|
13
|
+
import { enUS as me } from "../node_modules/date-fns/locale/en-US.js";
|
|
14
14
|
import { addMonths as ge } from "../node_modules/date-fns/addMonths.js";
|
|
15
|
-
import { subMonths as
|
|
16
|
-
import { startOfWeek as
|
|
17
|
-
import { startOfMonth as
|
|
18
|
-
import { endOfWeek as
|
|
19
|
-
import { endOfMonth as
|
|
20
|
-
import { addDays as
|
|
21
|
-
import { isSameMonth as
|
|
22
|
-
import { isSameDay as
|
|
23
|
-
import { getYear as
|
|
24
|
-
import { setYear as
|
|
25
|
-
import { setMonth as
|
|
26
|
-
const
|
|
15
|
+
import { subMonths as fe } from "../node_modules/date-fns/subMonths.js";
|
|
16
|
+
import { startOfWeek as ue } from "../node_modules/date-fns/startOfWeek.js";
|
|
17
|
+
import { startOfMonth as he } from "../node_modules/date-fns/startOfMonth.js";
|
|
18
|
+
import { endOfWeek as ye } from "../node_modules/date-fns/endOfWeek.js";
|
|
19
|
+
import { endOfMonth as be } from "../node_modules/date-fns/endOfMonth.js";
|
|
20
|
+
import { addDays as xe } from "../node_modules/date-fns/addDays.js";
|
|
21
|
+
import { isSameMonth as $e } from "../node_modules/date-fns/isSameMonth.js";
|
|
22
|
+
import { isSameDay as we } from "../node_modules/date-fns/isSameDay.js";
|
|
23
|
+
import { getYear as Me } from "../node_modules/date-fns/getYear.js";
|
|
24
|
+
import { setYear as je } from "../node_modules/date-fns/setYear.js";
|
|
25
|
+
import { setMonth as De } from "../node_modules/date-fns/setMonth.js";
|
|
26
|
+
const Se = i.div`
|
|
27
27
|
position: relative;
|
|
28
28
|
display: flex;
|
|
29
29
|
flex-direction: column;
|
|
30
30
|
justify-content: space-between;
|
|
31
31
|
gap: 0.5rem;
|
|
32
|
-
`,
|
|
32
|
+
`, ke = i.div`
|
|
33
33
|
position: relative;
|
|
34
34
|
width: 100%;
|
|
35
35
|
height: 3.5rem;
|
|
@@ -40,7 +40,7 @@ const De = i.div`
|
|
|
40
40
|
align-items: center;
|
|
41
41
|
padding: ${({ theme: e }) => `${e.spacing.s} ${e.spacing.sm}`};
|
|
42
42
|
box-shadow: ${({ theme: e }) => e.boxShadow.s3};
|
|
43
|
-
`,
|
|
43
|
+
`, ve = i.input`
|
|
44
44
|
all: unset;
|
|
45
45
|
flex: 1;
|
|
46
46
|
height: 100%;
|
|
@@ -54,7 +54,7 @@ const De = i.div`
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
cursor: ${({ disabled: e }) => e ? "not-allowed" : "pointer"};
|
|
57
|
-
`,
|
|
57
|
+
`, Oe = i.div`
|
|
58
58
|
display: flex;
|
|
59
59
|
align-items: center;
|
|
60
60
|
justify-content: center;
|
|
@@ -62,7 +62,7 @@ const De = i.div`
|
|
|
62
62
|
color: ${({ theme: e }) => e.colors.grey.n400};
|
|
63
63
|
font-size: 1rem;
|
|
64
64
|
flex-shrink: 0;
|
|
65
|
-
`,
|
|
65
|
+
`, Fe = i.div`
|
|
66
66
|
position: absolute;
|
|
67
67
|
top: 110%;
|
|
68
68
|
left: 0;
|
|
@@ -78,7 +78,7 @@ const De = i.div`
|
|
|
78
78
|
font-weight: bold;
|
|
79
79
|
cursor: pointer;
|
|
80
80
|
margin-bottom: 0.5rem;
|
|
81
|
-
`, Y = i(
|
|
81
|
+
`, Y = i(ie)`
|
|
82
82
|
cursor: pointer;
|
|
83
83
|
font-size: 1.25rem;
|
|
84
84
|
color: ${({ theme: e }) => e.colors.primary.purple.n450};
|
|
@@ -107,9 +107,9 @@ const De = i.div`
|
|
|
107
107
|
opacity: ${(e) => e.disabled ? 0.2 : 1};
|
|
108
108
|
background-color: ${(e) => e.selected ? e.theme.colors.primary.purple.n450 : "transparent"};
|
|
109
109
|
color: ${(e) => e.selected ? "white" : "inherit"};
|
|
110
|
-
border-radius: ${({ theme: e, isToday: a }) => (
|
|
110
|
+
border-radius: ${({ theme: e, isToday: a }) => (c) => a && !c.selected ? e.borderRadius.circle : e.borderRadius.md};
|
|
111
111
|
|
|
112
|
-
background-color: ${({ theme: e, isToday: a }) => (
|
|
112
|
+
background-color: ${({ theme: e, isToday: a }) => (c) => a && !c.selected && e.colors.primary.purple.n100};
|
|
113
113
|
&:hover {
|
|
114
114
|
background-color: ${(e) => !e.disabled && !e.selected ? e.theme.colors.grey.n50 : ""};
|
|
115
115
|
}
|
|
@@ -123,23 +123,23 @@ const De = i.div`
|
|
|
123
123
|
border: none;
|
|
124
124
|
border-radius: ${({ theme: e }) => e.borderRadius.md};
|
|
125
125
|
cursor: pointer;
|
|
126
|
-
`,
|
|
126
|
+
`, N = i.div`
|
|
127
127
|
width: 100%;
|
|
128
128
|
background-color: white;
|
|
129
129
|
border-radius: ${({ theme: e }) => e.borderRadius.md};
|
|
130
|
-
`,
|
|
130
|
+
`, Ne = i.div`
|
|
131
131
|
display: grid;
|
|
132
132
|
grid-template-columns: repeat(4, 1fr);
|
|
133
133
|
gap: 0.313rem;
|
|
134
134
|
max-height: 12.5rem;
|
|
135
135
|
overflow-y: auto;
|
|
136
136
|
padding: ${({ theme: e }) => e.spacing.sm};
|
|
137
|
-
`,
|
|
137
|
+
`, We = i.div`
|
|
138
138
|
display: grid;
|
|
139
139
|
grid-template-columns: repeat(3, 1fr);
|
|
140
140
|
gap: 0.313rem;
|
|
141
141
|
padding: ${({ theme: e }) => e.spacing.sm};
|
|
142
|
-
`,
|
|
142
|
+
`, W = i.div`
|
|
143
143
|
text-align: center;
|
|
144
144
|
padding: ${({ theme: e }) => e.spacing.sm};
|
|
145
145
|
cursor: pointer;
|
|
@@ -148,7 +148,7 @@ const De = i.div`
|
|
|
148
148
|
&:hover {
|
|
149
149
|
background-color: #eee;
|
|
150
150
|
}
|
|
151
|
-
`,
|
|
151
|
+
`, Ee = i.label`
|
|
152
152
|
display: flex;
|
|
153
153
|
align-items: flex-end;
|
|
154
154
|
column-gap: ${({ theme: e }) => e.spacing.xs};
|
|
@@ -157,59 +157,59 @@ const De = i.div`
|
|
|
157
157
|
font-weight: 400;
|
|
158
158
|
text-align: ${({ theme: e }) => e.dir === "rtl" ? "right" : "left"};
|
|
159
159
|
line-height: ${({ theme: e }) => e.typography.lineHeights.s};
|
|
160
|
-
`,
|
|
160
|
+
`, Ie = i.span`
|
|
161
161
|
color: ${({ theme: e }) => e.colors.grey.n300};
|
|
162
162
|
font-size: ${({ theme: e }) => e.typography.sizes.s2};
|
|
163
163
|
|
|
164
164
|
display: flex;
|
|
165
165
|
justify-content: ${({ theme: e }) => e.dir === "rtl" ? "flex-end" : "flex-start"};
|
|
166
166
|
text-align: ${({ theme: e }) => e.dir === "rtl" ? "right" : "left"};
|
|
167
|
-
`,
|
|
168
|
-
const [
|
|
167
|
+
`, ur = ({ value: e, onChange: a, minDate: c, maxDate: x, label: O, optional: F, disabled: E, error: D }) => {
|
|
168
|
+
const [I, $] = f(!1), [d, p] = f(e || /* @__PURE__ */ new Date()), [w, u] = f(e || null), [T, h] = f(e ? b(e, "dd/MM/yyyy") : ""), [M, j] = f("calendar"), [V, R] = f(0), S = te(null), k = /* @__PURE__ */ new Date(), C = ae(), { t: H, i18n: P } = oe(), l = (P.language || "").toLowerCase().startsWith("ar") || C.dir === "rtl", y = l ? "rtl" : "ltr", J = l ? pe : me, B = l ? ["أح", "اث", "ثل", "أر", "خم", "جم", "سب"] : ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"], _ = l ? ["يناير", "فبراير", "مارس", "أبريل", "مايو", "يونيو", "يوليو", "أغسطس", "سبتمبر", "أكتوبر", "نوفمبر", "ديسمبر"] : ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], m = (o) => {
|
|
169
169
|
const s = ["٠", "١", "٢", "٣", "٤", "٥", "٦", "٧", "٨", "٩"];
|
|
170
|
-
return
|
|
171
|
-
},
|
|
170
|
+
return o.toString().replace(/\d/g, (r) => s[Number(r)]);
|
|
171
|
+
}, G = (o) => {
|
|
172
172
|
const s = "٠١٢٣٤٥٦٧٨٩";
|
|
173
|
-
return
|
|
173
|
+
return o.replace(/[٠-٩]/g, (r) => s.indexOf(r).toString());
|
|
174
174
|
};
|
|
175
175
|
A(() => {
|
|
176
|
-
const
|
|
176
|
+
const o = (s) => {
|
|
177
177
|
S.current && !S.current.contains(s.target) && ($(!1), j("calendar"));
|
|
178
178
|
};
|
|
179
|
-
return document.addEventListener("mousedown",
|
|
179
|
+
return document.addEventListener("mousedown", o), () => document.removeEventListener("mousedown", o);
|
|
180
180
|
}, []), A(() => {
|
|
181
181
|
if (e) {
|
|
182
|
-
const
|
|
183
|
-
u(e),
|
|
182
|
+
const s = b(e, l ? "yyyy/MM/dd" : "dd/MM/yyyy");
|
|
183
|
+
u(e), p(e), h(l ? m(s) : s);
|
|
184
184
|
} else
|
|
185
185
|
u(null), h("");
|
|
186
186
|
}, [e, l]);
|
|
187
|
-
const
|
|
188
|
-
const s =
|
|
189
|
-
let
|
|
190
|
-
if (
|
|
187
|
+
const U = (o) => {
|
|
188
|
+
const s = o.target.value;
|
|
189
|
+
let r = G(s).replace(/\D/g, "");
|
|
190
|
+
if (r === "") {
|
|
191
191
|
h(""), u(null), a(null);
|
|
192
192
|
return;
|
|
193
193
|
}
|
|
194
|
-
|
|
195
|
-
const t = l ? m(
|
|
196
|
-
if (h(t),
|
|
197
|
-
const
|
|
198
|
-
|
|
194
|
+
l ? (r.length >= 5 && (r = r.slice(0, 4) + "/" + r.slice(4)), r.length >= 8 && (r = r.slice(0, 7) + "/" + r.slice(7, 9))) : (r.length >= 3 && (r = r.slice(0, 2) + "/" + r.slice(2)), r.length >= 6 && (r = r.slice(0, 5) + "/" + r.slice(5, 9)));
|
|
195
|
+
const t = l ? m(r) : r;
|
|
196
|
+
if (h(t), r.length === 10) {
|
|
197
|
+
const g = ce(r, l ? "yyyy/MM/dd" : "dd/MM/yyyy", /* @__PURE__ */ new Date()), re = c && L(g, c) || x && z(g, x);
|
|
198
|
+
de(g) && !re && (u(g), p(g), a(g));
|
|
199
199
|
}
|
|
200
|
-
},
|
|
201
|
-
const
|
|
202
|
-
for (let t =
|
|
203
|
-
const
|
|
204
|
-
|
|
205
|
-
/* @__PURE__ */
|
|
200
|
+
}, q = () => {
|
|
201
|
+
const o = ue(he(d), { weekStartsOn: 0 }), s = ye(be(d), { weekStartsOn: 0 }), r = [];
|
|
202
|
+
for (let t = o; t <= s; t = xe(t, 1)) {
|
|
203
|
+
const v = c && L(t, c) || x && z(t, x) || !$e(t, d);
|
|
204
|
+
r.push(
|
|
205
|
+
/* @__PURE__ */ n.jsx(
|
|
206
206
|
Le,
|
|
207
207
|
{
|
|
208
208
|
isToday: k.getDate() === t.getDate() && k.getMonth() === t.getMonth() && k.getFullYear() === t.getFullYear(),
|
|
209
|
-
disabled:
|
|
210
|
-
selected: w ?
|
|
209
|
+
disabled: v,
|
|
210
|
+
selected: w ? we(t, w) : !1,
|
|
211
211
|
onClick: () => {
|
|
212
|
-
|
|
212
|
+
v || (u(t), h(l ? m(b(t, "dd/MM/yyyy")) : b(t, "dd/MM/yyyy")), a(t), $(!1));
|
|
213
213
|
},
|
|
214
214
|
children: l ? m(t.getDate()) : t.getDate()
|
|
215
215
|
},
|
|
@@ -217,89 +217,89 @@ const De = i.div`
|
|
|
217
217
|
)
|
|
218
218
|
);
|
|
219
219
|
}
|
|
220
|
-
return /* @__PURE__ */
|
|
221
|
-
},
|
|
222
|
-
const s =
|
|
223
|
-
return Array.from({ length: 12 }, (
|
|
224
|
-
},
|
|
225
|
-
|
|
226
|
-
},
|
|
227
|
-
const s =
|
|
228
|
-
|
|
229
|
-
},
|
|
230
|
-
const
|
|
231
|
-
M === "calendar" ?
|
|
232
|
-
},
|
|
233
|
-
M === "calendar" ?
|
|
220
|
+
return /* @__PURE__ */ n.jsx(Ae, { $dir: y, children: r });
|
|
221
|
+
}, K = () => {
|
|
222
|
+
const s = Me(/* @__PURE__ */ new Date()) + V * 12;
|
|
223
|
+
return Array.from({ length: 12 }, (r, t) => s + t);
|
|
224
|
+
}, Q = (o) => {
|
|
225
|
+
p(je(d, o)), j("month");
|
|
226
|
+
}, X = (o) => {
|
|
227
|
+
const s = De(d, o);
|
|
228
|
+
p(s), j("calendar");
|
|
229
|
+
}, Z = () => {
|
|
230
|
+
const o = y === "rtl", s = () => {
|
|
231
|
+
M === "calendar" ? p(fe(d)) : R((t) => t - 1);
|
|
232
|
+
}, r = () => {
|
|
233
|
+
M === "calendar" ? p(ge(d, 1)) : R((t) => t + 1);
|
|
234
234
|
};
|
|
235
|
-
return /* @__PURE__ */
|
|
236
|
-
/* @__PURE__ */
|
|
235
|
+
return /* @__PURE__ */ n.jsxs(Re, { children: [
|
|
236
|
+
/* @__PURE__ */ n.jsx(
|
|
237
237
|
Y,
|
|
238
238
|
{
|
|
239
239
|
$dir: y,
|
|
240
240
|
$position: "left",
|
|
241
241
|
onClick: (t) => {
|
|
242
|
-
t.stopPropagation(),
|
|
242
|
+
t.stopPropagation(), o ? r() : s();
|
|
243
243
|
}
|
|
244
244
|
}
|
|
245
245
|
),
|
|
246
|
-
/* @__PURE__ */
|
|
246
|
+
/* @__PURE__ */ n.jsxs("div", { onClick: () => j("year"), children: [
|
|
247
247
|
(() => {
|
|
248
|
-
const t = b(
|
|
248
|
+
const t = b(d, "MMMM yyyy", { locale: J });
|
|
249
249
|
return l ? m(t) : t;
|
|
250
250
|
})(),
|
|
251
|
-
/* @__PURE__ */
|
|
251
|
+
/* @__PURE__ */ n.jsx(se, { color: C.colors.grey.n300, size: 12 })
|
|
252
252
|
] }),
|
|
253
|
-
/* @__PURE__ */
|
|
253
|
+
/* @__PURE__ */ n.jsx(
|
|
254
254
|
Y,
|
|
255
255
|
{
|
|
256
256
|
$dir: y,
|
|
257
257
|
$position: "right",
|
|
258
258
|
onClick: (t) => {
|
|
259
|
-
t.stopPropagation(),
|
|
259
|
+
t.stopPropagation(), o ? s() : r();
|
|
260
260
|
}
|
|
261
261
|
}
|
|
262
262
|
)
|
|
263
263
|
] });
|
|
264
|
-
},
|
|
265
|
-
/* @__PURE__ */
|
|
266
|
-
|
|
267
|
-
/* @__PURE__ */
|
|
264
|
+
}, ee = () => M === "calendar" ? /* @__PURE__ */ n.jsxs(n.Fragment, { children: [
|
|
265
|
+
/* @__PURE__ */ n.jsx(Ce, { $dir: y, children: B.map((o) => /* @__PURE__ */ n.jsx("div", { children: o }, o)) }),
|
|
266
|
+
q(),
|
|
267
|
+
/* @__PURE__ */ n.jsx(ze, { children: /* @__PURE__ */ n.jsx(
|
|
268
268
|
Ye,
|
|
269
269
|
{
|
|
270
270
|
onClick: () => {
|
|
271
271
|
w && a(w), $(!1);
|
|
272
272
|
},
|
|
273
|
-
children:
|
|
273
|
+
children: H("SET_DATE")
|
|
274
274
|
}
|
|
275
275
|
) })
|
|
276
|
-
] }) : M === "year" ? /* @__PURE__ */
|
|
277
|
-
return /* @__PURE__ */
|
|
278
|
-
|
|
279
|
-
|
|
276
|
+
] }) : M === "year" ? /* @__PURE__ */ n.jsx(N, { children: /* @__PURE__ */ n.jsx(Ne, { children: K().map((o) => /* @__PURE__ */ n.jsx(W, { onClick: () => Q(o), children: l ? m(o) : o }, o)) }) }) : /* @__PURE__ */ n.jsx(N, { children: /* @__PURE__ */ n.jsx(We, { children: _.map((o, s) => /* @__PURE__ */ n.jsx(W, { onClick: () => X(s), children: o }, `${o}-${s}`)) }) });
|
|
277
|
+
return /* @__PURE__ */ n.jsxs(Se, { ref: S, children: [
|
|
278
|
+
O && /* @__PURE__ */ n.jsxs(Ee, { children: [
|
|
279
|
+
O,
|
|
280
280
|
" ",
|
|
281
|
-
|
|
281
|
+
F && /* @__PURE__ */ n.jsx(Ie, { children: F })
|
|
282
282
|
] }),
|
|
283
|
-
/* @__PURE__ */
|
|
284
|
-
/* @__PURE__ */
|
|
285
|
-
/* @__PURE__ */
|
|
286
|
-
|
|
283
|
+
/* @__PURE__ */ n.jsxs(ke, { $error: D, children: [
|
|
284
|
+
/* @__PURE__ */ n.jsx(Oe, { children: /* @__PURE__ */ n.jsx(ne, {}) }),
|
|
285
|
+
/* @__PURE__ */ n.jsx(
|
|
286
|
+
ve,
|
|
287
287
|
{
|
|
288
|
-
disabled:
|
|
289
|
-
value:
|
|
290
|
-
onChange:
|
|
288
|
+
disabled: E,
|
|
289
|
+
value: T,
|
|
290
|
+
onChange: U,
|
|
291
291
|
placeholder: l ? "يوم/شهر/سنة" : "dd/mm/yyyy",
|
|
292
292
|
onFocus: () => $(!0)
|
|
293
293
|
}
|
|
294
294
|
)
|
|
295
295
|
] }),
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
296
|
+
I && /* @__PURE__ */ n.jsxs(Fe, { children: [
|
|
297
|
+
Z(),
|
|
298
|
+
ee()
|
|
299
299
|
] }),
|
|
300
|
-
D && /* @__PURE__ */
|
|
300
|
+
D && /* @__PURE__ */ n.jsx(le, { variant: "error", showLeadIcon: !1, title: D, showLink: !1 })
|
|
301
301
|
] });
|
|
302
302
|
};
|
|
303
303
|
export {
|
|
304
|
-
|
|
304
|
+
ur as default
|
|
305
305
|
};
|