tawuniya 0.7.7 → 0.7.8
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/base/command.js +0 -1
- package/dist/components/compound/card-button.js +2 -2
- package/dist/components/ui/checkbox.js +4 -4
- package/dist/components/ui/date-selector.d.ts +1 -0
- package/dist/components/ui/date-selector.js +60 -57
- package/dist/context/main-provider.d.ts +3 -1
- package/package.json +1 -1
|
@@ -113,7 +113,7 @@ const U = ({
|
|
|
113
113
|
{
|
|
114
114
|
className: r(
|
|
115
115
|
"relative flex flex-col justify-center size-full gap-y-2 p-3 rounded-2xl overflow-hidden group transition-colors duration-300",
|
|
116
|
-
!a && "border
|
|
116
|
+
!a && "border",
|
|
117
117
|
n ? "border-primary" : "border-transparent",
|
|
118
118
|
t?.mainWrapper
|
|
119
119
|
),
|
|
@@ -154,7 +154,7 @@ const U = ({
|
|
|
154
154
|
children: f
|
|
155
155
|
}
|
|
156
156
|
),
|
|
157
|
-
!n
|
|
157
|
+
d && (!n || !c) && !a && !o && /* @__PURE__ */ e(
|
|
158
158
|
"div",
|
|
159
159
|
{
|
|
160
160
|
className: r(
|
|
@@ -3,21 +3,21 @@ import * as s from "react";
|
|
|
3
3
|
import * as r from "@radix-ui/react-checkbox";
|
|
4
4
|
import { Check as c } from "lucide-react";
|
|
5
5
|
import { cn as t } from "../../lib/utils.js";
|
|
6
|
-
const d = s.forwardRef(({ className:
|
|
6
|
+
const d = s.forwardRef(({ className: i, ...o }, a) => /* @__PURE__ */ e(
|
|
7
7
|
r.Root,
|
|
8
8
|
{
|
|
9
9
|
ref: a,
|
|
10
10
|
className: t(
|
|
11
11
|
"tawn peer h-5 w-5 shrink-0 rounded-sm bg-secondary-200 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",
|
|
12
|
-
|
|
12
|
+
i
|
|
13
13
|
),
|
|
14
14
|
"data-testid": "checkbox",
|
|
15
|
-
...
|
|
15
|
+
...o,
|
|
16
16
|
children: /* @__PURE__ */ e(
|
|
17
17
|
r.Indicator,
|
|
18
18
|
{
|
|
19
19
|
className: t("flex items-center justify-center text-current"),
|
|
20
|
-
children: /* @__PURE__ */ e(c, { size:
|
|
20
|
+
children: /* @__PURE__ */ e(c, { size: 14, strokeWidth: 4, className: "shrink-0" })
|
|
21
21
|
}
|
|
22
22
|
)
|
|
23
23
|
}
|
|
@@ -1,57 +1,58 @@
|
|
|
1
1
|
import { jsx as m, jsxs as E } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef as
|
|
2
|
+
import { forwardRef as Ce, useState as A, useRef as q, useMemo as T, useCallback as re, useEffect as G } from "react";
|
|
3
3
|
import a from "moment";
|
|
4
4
|
import o from "moment-hijri";
|
|
5
5
|
import "moment/dist/locale/ar.js";
|
|
6
6
|
import { getMessages as ae, cn as L } from "../../lib/utils.js";
|
|
7
|
-
import
|
|
7
|
+
import Ee from "./typography.js";
|
|
8
8
|
import J from "./select.js";
|
|
9
|
-
import
|
|
9
|
+
import Ae from "./switch.js";
|
|
10
10
|
import "nuqs/adapters/react";
|
|
11
11
|
import "react-dom";
|
|
12
|
-
import
|
|
12
|
+
import we from "../../hooks/use-language.js";
|
|
13
13
|
import "nuqs";
|
|
14
14
|
import "../../context/main-context.js";
|
|
15
|
-
const
|
|
15
|
+
const ze = ({ error: V }) => V ? /* @__PURE__ */ m("div", { className: "text-sm !text-destructive", "data-testid": "dateSelectorError", children: /* @__PURE__ */ m("span", { children: V }) }) : null, _e = Ce(
|
|
16
16
|
({
|
|
17
|
-
label:
|
|
17
|
+
label: V,
|
|
18
18
|
views: f = ["Day", "Month", "Year"],
|
|
19
19
|
outputDate: x = "gregorian",
|
|
20
20
|
isHijri: ne = !1,
|
|
21
21
|
format: g = "DD/MM/YYYY",
|
|
22
22
|
onChange: b,
|
|
23
23
|
onDateChange: U,
|
|
24
|
+
onToggle: ie,
|
|
24
25
|
value: K,
|
|
25
|
-
className:
|
|
26
|
+
className: oe,
|
|
26
27
|
error: I,
|
|
27
28
|
min: w,
|
|
28
29
|
max: z,
|
|
29
30
|
form: S,
|
|
30
|
-
hideToggle:
|
|
31
|
+
hideToggle: se,
|
|
31
32
|
disabled: _
|
|
32
|
-
},
|
|
33
|
-
const [i,
|
|
34
|
-
muharram:
|
|
35
|
-
safar:
|
|
36
|
-
rabiAlAwwal:
|
|
37
|
-
rabiAlThaani:
|
|
38
|
-
jumadaAlAwwal:
|
|
39
|
-
jumadaAlThaani:
|
|
40
|
-
rajab:
|
|
41
|
-
shabaan:
|
|
42
|
-
ramadan:
|
|
43
|
-
shawwaal:
|
|
44
|
-
dhulHijjah:
|
|
45
|
-
dhulQadah:
|
|
46
|
-
} = ae(Q, "arabicMonth"), { day:
|
|
33
|
+
}, le) => {
|
|
34
|
+
const [i, ce] = A(ne), [y, j] = A(""), [p, N] = A(""), [u, v] = A(""), [O, B] = A(!1), Q = we(), {
|
|
35
|
+
muharram: de,
|
|
36
|
+
safar: he,
|
|
37
|
+
rabiAlAwwal: me,
|
|
38
|
+
rabiAlThaani: ue,
|
|
39
|
+
jumadaAlAwwal: fe,
|
|
40
|
+
jumadaAlThaani: ge,
|
|
41
|
+
rajab: Ye,
|
|
42
|
+
shabaan: ye,
|
|
43
|
+
ramadan: pe,
|
|
44
|
+
shawwaal: Me,
|
|
45
|
+
dhulHijjah: De,
|
|
46
|
+
dhulQadah: Se
|
|
47
|
+
} = ae(Q, "arabicMonth"), { day: xe, month: je, year: be, hijri: Ie } = ae(Q, "date"), k = q(!1), P = q(""), C = q(
|
|
47
48
|
() => {
|
|
48
49
|
}
|
|
49
50
|
);
|
|
50
51
|
a.locale(Q === "ar" ? "ar" : "en");
|
|
51
|
-
const F = a().year(), R =
|
|
52
|
+
const F = a().year(), R = T(() => Array.from({ length: 101 }, (r, e) => F - e), [F]), H = o().iYear(), W = T(() => Array.from({ length: 101 }, (r, e) => H - e), [H]), X = re(
|
|
52
53
|
(r) => r ? r instanceof Date ? a(r).locale("en").format(g) : r : "",
|
|
53
54
|
[g]
|
|
54
|
-
), { minDate: c, maxDate: d } =
|
|
55
|
+
), { minDate: c, maxDate: d } = T(() => {
|
|
55
56
|
let r = null, e = null;
|
|
56
57
|
if (w)
|
|
57
58
|
try {
|
|
@@ -79,7 +80,6 @@ const we = ({ error: T }) => T ? /* @__PURE__ */ m("div", { className: "text-sm
|
|
|
79
80
|
}
|
|
80
81
|
return { minDate: r, maxDate: e };
|
|
81
82
|
}, [w, z, g, x]), Z = a.months(), $ = [
|
|
82
|
-
ce,
|
|
83
83
|
de,
|
|
84
84
|
he,
|
|
85
85
|
me,
|
|
@@ -90,8 +90,9 @@ const we = ({ error: T }) => T ? /* @__PURE__ */ m("div", { className: "text-sm
|
|
|
90
90
|
ye,
|
|
91
91
|
pe,
|
|
92
92
|
Me,
|
|
93
|
-
De
|
|
94
|
-
|
|
93
|
+
De,
|
|
94
|
+
Se
|
|
95
|
+
], Ne = T(() => {
|
|
95
96
|
const r = p || (i ? (o().iMonth() + 1).toString() : (a().month() + 1).toString()), e = u || (i ? o().iYear().toString() : a().year().toString());
|
|
96
97
|
let t;
|
|
97
98
|
return i ? t = o().iYear(parseInt(e)).iMonth(parseInt(r) - 1).iDaysInMonth() : t = a().year(parseInt(e)).month(parseInt(r) - 1).daysInMonth(), Array.from({ length: t }, (h, n) => {
|
|
@@ -101,8 +102,8 @@ const we = ({ error: T }) => T ? /* @__PURE__ */ m("div", { className: "text-sm
|
|
|
101
102
|
try {
|
|
102
103
|
let D;
|
|
103
104
|
if (i) {
|
|
104
|
-
const
|
|
105
|
-
D = a(
|
|
105
|
+
const ke = o().iYear(parseInt(e)).iMonth(parseInt(r) - 1).iDate(n + 1);
|
|
106
|
+
D = a(ke.format("YYYY-MM-DD"));
|
|
106
107
|
} else
|
|
107
108
|
D = a().year(parseInt(e)).month(parseInt(r) - 1).date(n + 1);
|
|
108
109
|
c && D.isBefore(c, "day") && (M = !0), d && D.isAfter(d, "day") && (M = !0);
|
|
@@ -115,7 +116,7 @@ const we = ({ error: T }) => T ? /* @__PURE__ */ m("div", { className: "text-sm
|
|
|
115
116
|
disabled: M
|
|
116
117
|
};
|
|
117
118
|
}).filter((h) => !h.disabled);
|
|
118
|
-
}, [p, u, i, c, d]),
|
|
119
|
+
}, [p, u, i, c, d]), ve = T(() => (i ? $ : Z).map((e, t) => {
|
|
119
120
|
const Y = (t + 1).toString().padStart(2, "0");
|
|
120
121
|
let h = !1;
|
|
121
122
|
if (c || d)
|
|
@@ -145,7 +146,7 @@ const we = ({ error: T }) => T ? /* @__PURE__ */ m("div", { className: "text-sm
|
|
|
145
146
|
d,
|
|
146
147
|
F,
|
|
147
148
|
H
|
|
148
|
-
]),
|
|
149
|
+
]), Te = T(() => (i ? W : R).map((e) => {
|
|
149
150
|
let t = !1;
|
|
150
151
|
if (c || d)
|
|
151
152
|
try {
|
|
@@ -169,7 +170,9 @@ const we = ({ error: T }) => T ? /* @__PURE__ */ m("div", { className: "text-sm
|
|
|
169
170
|
if (!(!r || !p || !u))
|
|
170
171
|
try {
|
|
171
172
|
let e, t;
|
|
172
|
-
if (i ? (t = o().iYear(parseInt(u)).iMonth(parseInt(p) - 1).iDate(parseInt(r)), e = a(t.format("YYYY-MM-DD"))) : (e = a().year(parseInt(u)).month(parseInt(p) - 1).date(parseInt(r)), t = o(
|
|
173
|
+
if (i ? (t = o().iYear(parseInt(u)).iMonth(parseInt(p) - 1).iDate(parseInt(r)), e = a(t.format("YYYY-MM-DD"))) : (e = a().year(parseInt(u)).month(parseInt(p) - 1).date(parseInt(r)), t = o(
|
|
174
|
+
e.locale("en").format("YYYY-MM-DD")
|
|
175
|
+
)), c && e.isBefore(c, "day") || d && e.isAfter(d, "day"))
|
|
173
176
|
return;
|
|
174
177
|
const Y = e.locale("en").format(g), h = {
|
|
175
178
|
YYYY: "iYYYY",
|
|
@@ -184,7 +187,7 @@ const we = ({ error: T }) => T ? /* @__PURE__ */ m("div", { className: "text-sm
|
|
|
184
187
|
n = n.replace(M, h[M]);
|
|
185
188
|
});
|
|
186
189
|
const s = t.format(n).replace(/i/g, "");
|
|
187
|
-
|
|
190
|
+
k.current = !0;
|
|
188
191
|
const l = x === "hijri" ? s : Y;
|
|
189
192
|
C.current && C.current(l), b && b(l), U && U(Y, s);
|
|
190
193
|
} catch (e) {
|
|
@@ -210,7 +213,7 @@ const we = ({ error: T }) => T ? /* @__PURE__ */ m("div", { className: "text-sm
|
|
|
210
213
|
}
|
|
211
214
|
}, [f, y, O]), G(() => {
|
|
212
215
|
const e = X(S ? void 0 : K);
|
|
213
|
-
if (e && e !== P.current && !
|
|
216
|
+
if (e && e !== P.current && !k.current)
|
|
214
217
|
try {
|
|
215
218
|
if (x === "hijri") {
|
|
216
219
|
const t = o(e, g);
|
|
@@ -222,7 +225,7 @@ const we = ({ error: T }) => T ? /* @__PURE__ */ m("div", { className: "text-sm
|
|
|
222
225
|
} catch (t) {
|
|
223
226
|
console.error("Error parsing date value:", t);
|
|
224
227
|
}
|
|
225
|
-
P.current = e,
|
|
228
|
+
P.current = e, k.current = !1;
|
|
226
229
|
}, [K, g, x, S, X]), G(() => {
|
|
227
230
|
if (O && (f.includes("Day") ? y : y || "1") && p && u) {
|
|
228
231
|
const e = setTimeout(() => {
|
|
@@ -238,9 +241,9 @@ const we = ({ error: T }) => T ? /* @__PURE__ */ m("div", { className: "text-sm
|
|
|
238
241
|
ee,
|
|
239
242
|
f
|
|
240
243
|
]);
|
|
241
|
-
const
|
|
242
|
-
|
|
243
|
-
|
|
244
|
+
const Ve = (r) => {
|
|
245
|
+
ce(r), ie?.(r), j(""), N(""), v(""), B(!1), k.current = !0, C.current && C.current(""), b && b(""), setTimeout(() => {
|
|
246
|
+
k.current = !1;
|
|
244
247
|
}, 0);
|
|
245
248
|
}, te = (r, e) => {
|
|
246
249
|
C.current = r;
|
|
@@ -271,19 +274,19 @@ const we = ({ error: T }) => T ? /* @__PURE__ */ m("div", { className: "text-sm
|
|
|
271
274
|
className: L(
|
|
272
275
|
"w-full p-2 sm:h-[62px] flex flex-col gap-y-1.5 rounded-lg overflow-x-auto overflow-y-hidden",
|
|
273
276
|
I ? "!bg-destructive/5" : "bg-background",
|
|
274
|
-
|
|
277
|
+
oe
|
|
275
278
|
),
|
|
276
279
|
"data-testid": "dateSelector",
|
|
277
280
|
children: [
|
|
278
|
-
|
|
279
|
-
|
|
281
|
+
V && /* @__PURE__ */ m(
|
|
282
|
+
Ee,
|
|
280
283
|
{
|
|
281
284
|
as: "label",
|
|
282
285
|
size: "xs",
|
|
283
286
|
weight: "medium",
|
|
284
287
|
color: I ? "destructive" : "muted_foreground",
|
|
285
288
|
"data-testid": "dateSelectorLabel",
|
|
286
|
-
children:
|
|
289
|
+
children: V
|
|
287
290
|
}
|
|
288
291
|
),
|
|
289
292
|
/* @__PURE__ */ m("div", { className: "size-full animate-fade-in", children: /* @__PURE__ */ E("div", { className: "flex flex-col gap-3 h-full sm:flex-row! sm:items-center", children: [
|
|
@@ -297,8 +300,8 @@ const we = ({ error: T }) => T ? /* @__PURE__ */ m("div", { className: "text-sm
|
|
|
297
300
|
J,
|
|
298
301
|
{
|
|
299
302
|
ref: e,
|
|
300
|
-
label:
|
|
301
|
-
options:
|
|
303
|
+
label: xe,
|
|
304
|
+
options: Ne,
|
|
302
305
|
value: y,
|
|
303
306
|
onChange: t,
|
|
304
307
|
embedded: !0,
|
|
@@ -324,8 +327,8 @@ const we = ({ error: T }) => T ? /* @__PURE__ */ m("div", { className: "text-sm
|
|
|
324
327
|
J,
|
|
325
328
|
{
|
|
326
329
|
ref: e,
|
|
327
|
-
label:
|
|
328
|
-
options:
|
|
330
|
+
label: je,
|
|
331
|
+
options: ve,
|
|
329
332
|
value: p,
|
|
330
333
|
onChange: Y,
|
|
331
334
|
embedded: !0,
|
|
@@ -352,8 +355,8 @@ const we = ({ error: T }) => T ? /* @__PURE__ */ m("div", { className: "text-sm
|
|
|
352
355
|
J,
|
|
353
356
|
{
|
|
354
357
|
ref: e,
|
|
355
|
-
label:
|
|
356
|
-
options:
|
|
358
|
+
label: be,
|
|
359
|
+
options: Te,
|
|
357
360
|
value: u,
|
|
358
361
|
onChange: h,
|
|
359
362
|
embedded: !0,
|
|
@@ -372,7 +375,7 @@ const we = ({ error: T }) => T ? /* @__PURE__ */ m("div", { className: "text-sm
|
|
|
372
375
|
}
|
|
373
376
|
)
|
|
374
377
|
] }),
|
|
375
|
-
!
|
|
378
|
+
!se && /* @__PURE__ */ E(
|
|
376
379
|
"div",
|
|
377
380
|
{
|
|
378
381
|
className: "flex items-center gap-2 justify-end sm:ml-auto",
|
|
@@ -383,16 +386,16 @@ const we = ({ error: T }) => T ? /* @__PURE__ */ m("div", { className: "text-sm
|
|
|
383
386
|
{
|
|
384
387
|
htmlFor: "hijri-toggle",
|
|
385
388
|
className: "text-sm text-muted-foreground",
|
|
386
|
-
children:
|
|
389
|
+
children: Ie
|
|
387
390
|
}
|
|
388
391
|
),
|
|
389
392
|
/* @__PURE__ */ m(
|
|
390
|
-
|
|
393
|
+
Ae,
|
|
391
394
|
{
|
|
392
395
|
size: "sm",
|
|
393
396
|
id: "hijri-toggle",
|
|
394
397
|
checked: i,
|
|
395
|
-
onChange:
|
|
398
|
+
onChange: Ve,
|
|
396
399
|
className: "data-[state=checked]:bg-gradient-primary",
|
|
397
400
|
disabled: _
|
|
398
401
|
}
|
|
@@ -404,7 +407,7 @@ const we = ({ error: T }) => T ? /* @__PURE__ */ m("div", { className: "text-sm
|
|
|
404
407
|
]
|
|
405
408
|
}
|
|
406
409
|
),
|
|
407
|
-
/* @__PURE__ */ m(
|
|
410
|
+
/* @__PURE__ */ m(ze, { error: I })
|
|
408
411
|
] });
|
|
409
412
|
};
|
|
410
413
|
if (S?.controller && S?.control && S?.name) {
|
|
@@ -418,10 +421,10 @@ const we = ({ error: T }) => T ? /* @__PURE__ */ m("div", { className: "text-sm
|
|
|
418
421
|
}
|
|
419
422
|
) });
|
|
420
423
|
}
|
|
421
|
-
return te(b,
|
|
424
|
+
return te(b, le);
|
|
422
425
|
}
|
|
423
426
|
);
|
|
424
|
-
|
|
427
|
+
_e.displayName = "DateSelector";
|
|
425
428
|
export {
|
|
426
|
-
|
|
429
|
+
_e as default
|
|
427
430
|
};
|