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.
@@ -3,7 +3,6 @@ import * as d from "react";
3
3
  import "@radix-ui/react-dialog";
4
4
  import { Command as e } from "cmdk";
5
5
  import { cn as m } from "../../lib/utils.js";
6
- import "./dialog.js";
7
6
  const s = d.forwardRef(({ className: a, ...o }, r) => /* @__PURE__ */ t(
8
7
  e,
9
8
  {
@@ -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-2",
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 && d && !a && !o && /* @__PURE__ */ e(
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: o, ...i }, a) => /* @__PURE__ */ e(
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
- o
12
+ i
13
13
  ),
14
14
  "data-testid": "checkbox",
15
- ...i,
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: 16 })
20
+ children: /* @__PURE__ */ e(c, { size: 14, strokeWidth: 4, className: "shrink-0" })
21
21
  }
22
22
  )
23
23
  }
@@ -12,6 +12,7 @@ export interface DateSelectorProps {
12
12
  hideToggle?: boolean;
13
13
  onChange?: (value: string) => void;
14
14
  onDateChange?: (gregorianDate: string, hijriDate: string) => void;
15
+ onToggle?: (isHijri: boolean) => void;
15
16
  form?: {
16
17
  controller: any;
17
18
  control: any;
@@ -1,57 +1,58 @@
1
1
  import { jsx as m, jsxs as E } from "react/jsx-runtime";
2
- import { forwardRef as Ve, useState as A, useRef as q, useMemo as k, useCallback as re, useEffect as G } from "react";
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 Ce from "./typography.js";
7
+ import Ee from "./typography.js";
8
8
  import J from "./select.js";
9
- import Ee from "./switch.js";
9
+ import Ae from "./switch.js";
10
10
  import "nuqs/adapters/react";
11
11
  import "react-dom";
12
- import Ae from "../../hooks/use-language.js";
12
+ import we from "../../hooks/use-language.js";
13
13
  import "nuqs";
14
14
  import "../../context/main-context.js";
15
- const we = ({ error: T }) => T ? /* @__PURE__ */ m("div", { className: "text-sm !text-destructive", "data-testid": "dateSelectorError", children: /* @__PURE__ */ m("span", { children: T }) }) : null, ze = Ve(
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: T,
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: ie,
26
+ className: oe,
26
27
  error: I,
27
28
  min: w,
28
29
  max: z,
29
30
  form: S,
30
- hideToggle: oe,
31
+ hideToggle: se,
31
32
  disabled: _
32
- }, se) => {
33
- const [i, le] = A(ne), [y, j] = A(""), [p, N] = A(""), [u, v] = A(""), [O, B] = A(!1), Q = Ae(), {
34
- muharram: ce,
35
- safar: de,
36
- rabiAlAwwal: he,
37
- rabiAlThaani: me,
38
- jumadaAlAwwal: ue,
39
- jumadaAlThaani: fe,
40
- rajab: ge,
41
- shabaan: Ye,
42
- ramadan: ye,
43
- shawwaal: pe,
44
- dhulHijjah: Me,
45
- dhulQadah: De
46
- } = ae(Q, "arabicMonth"), { day: Se, month: xe, year: je, hijri: be } = ae(Q, "date"), V = q(!1), P = q(""), C = q(
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 = k(() => Array.from({ length: 101 }, (r, e) => F - e), [F]), H = o().iYear(), W = k(() => Array.from({ length: 101 }, (r, e) => H - e), [H]), X = re(
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 } = k(() => {
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
- ], Ie = k(() => {
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 Te = o().iYear(parseInt(e)).iMonth(parseInt(r) - 1).iDate(n + 1);
105
- D = a(Te.format("YYYY-MM-DD"));
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]), Ne = k(() => (i ? $ : Z).map((e, t) => {
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
- ]), ve = k(() => (i ? W : R).map((e) => {
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(e.locale("en").format("YYYY-MM-DD"))), c && e.isBefore(c, "day") || d && e.isAfter(d, "day"))
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
- V.current = !0;
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 && !V.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, V.current = !1;
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 ke = (r) => {
242
- le(r), j(""), N(""), v(""), B(!1), V.current = !0, C.current && C.current(""), b && b(""), setTimeout(() => {
243
- V.current = !1;
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
- ie
277
+ oe
275
278
  ),
276
279
  "data-testid": "dateSelector",
277
280
  children: [
278
- T && /* @__PURE__ */ m(
279
- Ce,
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: T
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: Se,
301
- options: Ie,
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: xe,
328
- options: Ne,
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: je,
356
- options: ve,
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
- !oe && /* @__PURE__ */ E(
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: be
389
+ children: Ie
387
390
  }
388
391
  ),
389
392
  /* @__PURE__ */ m(
390
- Ee,
393
+ Ae,
391
394
  {
392
395
  size: "sm",
393
396
  id: "hijri-toggle",
394
397
  checked: i,
395
- onChange: ke,
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(we, { error: I })
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, se);
424
+ return te(b, le);
422
425
  }
423
426
  );
424
- ze.displayName = "DateSelector";
427
+ _e.displayName = "DateSelector";
425
428
  export {
426
- ze as default
429
+ _e as default
427
430
  };
@@ -1,4 +1,6 @@
1
- interface MainProviderProps extends Children {
1
+ import { ReactNode } from 'react';
2
+ interface MainProviderProps {
3
+ children: ReactNode;
2
4
  showAccessibility?: boolean;
3
5
  accessibilityPosition?: AccessibilityPositionType;
4
6
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "tawuniya",
3
3
  "private": false,
4
- "version": "0.7.7",
4
+ "version": "0.7.8",
5
5
  "type": "module",
6
6
  "main": "./dist/components.js",
7
7
  "module": "./dist/components.js",