persian-date-kit 0.0.12 → 1.0.0

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/index.mjs CHANGED
@@ -1,16 +1,16 @@
1
- import { t as b, u as Ke, b as ze, i as O, a as We, p as qe, c as Y, d as S, f as C, e as xe, g as D } from "./PersianDatePicker-BYF8CIZO.js";
2
- import { P as it, k as lt, h as ut, l as ct, j as pt } from "./PersianDatePicker-BYF8CIZO.js";
3
- import { jsxs as L, jsx as d, Fragment as Qe } from "react/jsx-runtime";
1
+ import { t as b, u as We, b as qe, i as O, a as Qe, p as Xe, c as Y, d as N, f as S, e as be, g as D } from "./PersianDatePicker-BEj7IYGl.js";
2
+ import { P as ut, k as ct, h as pt, l as ft, j as mt } from "./PersianDatePicker-BEj7IYGl.js";
3
+ import { jsxs as L, jsx as d, Fragment as Ze } from "react/jsx-runtime";
4
4
  import * as o from "react";
5
- import { createPortal as Xe } from "react-dom";
5
+ import { createPortal as et } from "react-dom";
6
6
  function s(...u) {
7
7
  return u.filter(Boolean).join(" ");
8
8
  }
9
- function Ze(u) {
10
- return We(u).formatted;
9
+ function tt(u) {
10
+ return Qe(u).formatted;
11
11
  }
12
- function et(u) {
13
- return qe(u, { allowLooseSeparators: !0 });
12
+ function nt(u) {
13
+ return Xe(u, { allowLooseSeparators: !0 });
14
14
  }
15
15
  function k() {
16
16
  const u = /* @__PURE__ */ new Date();
@@ -20,11 +20,11 @@ function U(u) {
20
20
  const { start: a, end: c } = u;
21
21
  return a && c && D(a, c) > 0 ? { start: c, end: a } : u;
22
22
  }
23
- function tt(u, a, c) {
23
+ function at(u, a, c) {
24
24
  const v = D(a, c) <= 0 ? a : c, y = D(a, c) <= 0 ? c : a;
25
25
  return D(u, v) >= 0 && D(u, y) <= 0;
26
26
  }
27
- function ot(u) {
27
+ function dt(u) {
28
28
  const {
29
29
  value: a,
30
30
  onChange: c,
@@ -32,35 +32,36 @@ function ot(u) {
32
32
  maxDate: y,
33
33
  disabled: R,
34
34
  inputVariant: G = "two",
35
- placeholder: _e,
35
+ placeholder: ke,
36
36
  rangeSeparator: P = " - ",
37
- placeholderStart: be,
38
- placeholderEnd: ke,
37
+ placeholderStart: De,
38
+ placeholderEnd: Re,
39
39
  open: H,
40
40
  onOpenChange: ne,
41
41
  mode: m = "popover",
42
- popover: De,
43
- formatValue: g = Ze,
44
- parseValue: K = et,
42
+ theme: ae = "light",
43
+ popover: we,
44
+ formatValue: g = tt,
45
+ parseValue: K = nt,
45
46
  weekdays: T,
46
47
  monthLabels: h,
47
48
  renderMonthLabel: z,
48
- prevIcon: Re,
49
- nextIcon: we,
50
- className: Ne,
49
+ prevIcon: Ce,
50
+ nextIcon: Ne,
51
+ className: Se,
51
52
  classes: i
52
- } = u, ae = o.useRef(null), A = o.useRef(null), W = o.useRef(null), q = o.useRef(null), Q = o.useRef(null), re = o.useRef(null), [Se, Ce] = o.useState(!1), [Pe, Me] = o.useState(!1), f = m === "inline" ? !0 : H ?? Pe, J = o.useCallback(
53
+ } = u, re = ae === "dark" ? "dvx-pdp--theme-dark" : ae === "auto" ? "dvx-pdp--theme-auto" : void 0, oe = o.useRef(null), A = o.useRef(null), W = o.useRef(null), q = o.useRef(null), Q = o.useRef(null), se = o.useRef(null), [Pe, Me] = o.useState(!1), [Ee, $e] = o.useState(!1), f = m === "inline" ? !0 : H ?? Ee, J = o.useCallback(
53
54
  (e) => {
54
- ne?.(e), m !== "inline" && H === void 0 && Me(e);
55
+ ne?.(e), m !== "inline" && H === void 0 && $e(e);
55
56
  },
56
57
  [m, ne, H]
57
58
  );
58
59
  o.useEffect(() => {
59
- Ce(!0);
60
+ Me(!0);
60
61
  }, []);
61
- const [X, oe] = o.useState(
62
+ const [X, de] = o.useState(
62
63
  "start"
63
- ), [x, w] = o.useState("days"), [Ee, M] = o.useState(() => {
64
+ ), [x, w] = o.useState("days"), [Le, M] = o.useState(() => {
64
65
  const e = a.start ?? a.end ?? k(), t = b(e).jy;
65
66
  return t - t % 12;
66
67
  }), [F, B] = o.useState(() => {
@@ -71,16 +72,16 @@ function ot(u) {
71
72
  return { jy: t.jy, jm: t.jm };
72
73
  }), [$, j] = o.useState(
73
74
  () => a.start ?? a.end ?? k()
74
- ), [se, de] = o.useState(null), [ie, le] = o.useState(
75
+ ), [ie, le] = o.useState(null), [ue, ce] = o.useState(
75
76
  () => a.start ? g(a.start) : ""
76
- ), [ue, ce] = o.useState(
77
+ ), [pe, fe] = o.useState(
77
78
  () => a.end ? g(a.end) : ""
78
- ), [pe, V] = o.useState(() => {
79
+ ), [me, V] = o.useState(() => {
79
80
  const e = a.start ? g(a.start) : "", t = a.end ? g(a.end) : "";
80
81
  return !e && !t ? "" : e && !t ? `${e}${P}` : `${e}${P}${t}`;
81
82
  });
82
83
  o.useEffect(() => {
83
- le(a.start ? g(a.start) : ""), ce(a.end ? g(a.end) : "");
84
+ ce(a.start ? g(a.start) : ""), fe(a.end ? g(a.end) : "");
84
85
  const e = a.start ? g(a.start) : "", t = a.end ? g(a.end) : "";
85
86
  V(!e && !t ? "" : e && !t ? `${e}${P}` : `${e}${P}${t}`);
86
87
  const n = a.start ?? a.end ?? k(), r = b(n);
@@ -88,27 +89,27 @@ function ot(u) {
88
89
  }, [g, P, a.end, a.start]), o.useEffect(() => {
89
90
  if (m !== "popover" || !f) return;
90
91
  const e = (t) => {
91
- const n = ae.current;
92
+ const n = oe.current;
92
93
  if (!n) return;
93
94
  const r = A.current;
94
95
  t.target instanceof Node && !n.contains(t.target) && !(r && r.contains(t.target)) && J(!1);
95
96
  };
96
97
  return document.addEventListener("pointerdown", e), () => document.removeEventListener("pointerdown", e);
97
98
  }, [m, f, J]), o.useEffect(() => {
98
- f && re.current?.focus();
99
+ f && se.current?.focus();
99
100
  }, [f]);
100
- const N = De ?? {}, fe = N.portal ?? !0, $e = G === "single" ? W : X === "start" ? q : Q, { style: me } = Ke(
101
+ const C = we ?? {}, ve = C.portal ?? !0, Te = G === "single" ? W : X === "start" ? q : Q, { style: ye } = We(
101
102
  m === "popover" && f,
102
- $e,
103
+ Te,
103
104
  A,
104
105
  {
105
- gutter: N.gutter,
106
- padding: N.padding,
106
+ gutter: C.gutter,
107
+ padding: C.padding,
107
108
  // If we're not using a portal, `absolute` would require offset-parent math.
108
109
  // Force `fixed` so we can clamp reliably to the viewport.
109
- strategy: fe ? N.strategy : "fixed",
110
- placements: N.placements,
111
- align: N.align ?? "end"
110
+ strategy: ve ? C.strategy : "fixed",
111
+ placements: C.placements,
112
+ align: C.align ?? "end"
112
113
  }
113
114
  );
114
115
  o.useEffect(() => {
@@ -118,23 +119,23 @@ function ot(u) {
118
119
  (t) => t.jy === e.jy && t.jm === e.jm ? t : { jy: e.jy, jm: e.jm }
119
120
  );
120
121
  }, [$, f]);
121
- const Le = o.useMemo(() => z ? z(l.jy, l.jm) : h && h.length === 12 ? `${h[l.jm - 1] ?? String(l.jm)} ${l.jy}` : `${l.jy} / ${l.jm}`, [h, z, l.jm, l.jy]), Te = o.useMemo(() => T && T.length === 7 ? T : ["1", "2", "3", "4", "5", "6", "7"], [T]), Ae = o.useMemo(
122
- () => ze({ jy: l.jy, jm: l.jm }),
122
+ const Ae = o.useMemo(() => z ? z(l.jy, l.jm) : h && h.length === 12 ? `${h[l.jm - 1] ?? String(l.jm)} ${l.jy}` : `${l.jy} / ${l.jm}`, [h, z, l.jm, l.jy]), Je = o.useMemo(() => T && T.length === 7 ? T : ["1", "2", "3", "4", "5", "6", "7"], [T]), Fe = o.useMemo(
123
+ () => qe({ jy: l.jy, jm: l.jm }),
123
124
  [l.jm, l.jy]
124
125
  );
125
126
  function Z(e) {
126
127
  if (R) return;
127
- oe(e), J(!0);
128
+ de(e), J(!0);
128
129
  const t = (e === "start" ? a.start : a.end) ?? a.start ?? a.end ?? k(), n = b(t);
129
130
  E({ jy: n.jy, jm: n.jm }), j(t), w("days"), B(n.jy), M(n.jy - n.jy % 12);
130
131
  }
131
- function ve() {
132
+ function ge() {
132
133
  J(!1), w("days"), m === "popover" && (G === "single" ? W.current?.focus() : (X === "start" ? q : Q).current?.focus());
133
134
  }
134
- function ye(e) {
135
- return R ? !0 : !S(e.gregorian, v, y);
135
+ function je(e) {
136
+ return R ? !0 : !N(e.gregorian, v, y);
136
137
  }
137
- function ge(e, t) {
138
+ function he(e, t) {
138
139
  const n = t.trim();
139
140
  if (!n) {
140
141
  const _ = U({ ...a, [e]: null });
@@ -142,11 +143,11 @@ function ot(u) {
142
143
  return;
143
144
  }
144
145
  const r = K(n);
145
- if (!r || !S(r, v, y)) return;
146
+ if (!r || !N(r, v, y)) return;
146
147
  const p = U({ ...a, [e]: r });
147
148
  c(p);
148
149
  }
149
- function Je(e) {
150
+ function Be(e) {
150
151
  const t = e.trim();
151
152
  if (!t) {
152
153
  c({ start: null, end: null });
@@ -155,12 +156,12 @@ function ot(u) {
155
156
  const n = t.match(/\d{4}[^\d]\d{1,2}[^\d]\d{1,2}/g) ?? [], r = n[0], p = n[1];
156
157
  if (!r) return;
157
158
  const _ = K(r), te = p ? K(p) : null;
158
- _ && S(_, v, y) && (te && !S(te, v, y) || c(U({ start: _, end: te })));
159
+ _ && N(_, v, y) && (te && !N(te, v, y) || c(U({ start: _, end: te })));
159
160
  }
160
- function Fe(e) {
161
+ function Ve(e) {
161
162
  if (f && !R) {
162
163
  if (e.key === "Escape") {
163
- e.preventDefault(), ve();
164
+ e.preventDefault(), ge();
164
165
  return;
165
166
  }
166
167
  if (x === "days") {
@@ -189,32 +190,32 @@ function ot(u) {
189
190
  return;
190
191
  }
191
192
  if (e.key === "Enter") {
192
- if (e.preventDefault(), !S($, v, y)) return;
193
- he($);
193
+ if (e.preventDefault(), !N($, v, y)) return;
194
+ _e($);
194
195
  }
195
196
  }
196
197
  }
197
198
  }
198
199
  function I(e) {
199
- const t = C({
200
+ const t = S({
200
201
  jy: l.jy,
201
202
  jm: l.jm,
202
203
  jd: 1
203
- }), n = xe(t, e), r = b(n);
204
- E({ jy: r.jy, jm: r.jm }), j((p) => xe(p, e));
204
+ }), n = be(t, e), r = b(n);
205
+ E({ jy: r.jy, jm: r.jm }), j((p) => be(p, e));
205
206
  }
206
- function Be(e) {
207
- const t = C({ jy: e, jm: 1, jd: 1 }), n = C({ jy: e + 1, jm: 1, jd: 1 });
207
+ function Ie(e) {
208
+ const t = S({ jy: e, jm: 1, jd: 1 }), n = S({ jy: e + 1, jm: 1, jd: 1 });
208
209
  return { start: t, endExclusive: n };
209
210
  }
210
- function Ve(e, t) {
211
- const n = C({ jy: e, jm: t, jd: 1 }), r = t === 12 ? { jy: e + 1, jm: 1 } : { jy: e, jm: t + 1 }, p = C({ jy: r.jy, jm: r.jm, jd: 1 });
211
+ function Oe(e, t) {
212
+ const n = S({ jy: e, jm: t, jd: 1 }), r = t === 12 ? { jy: e + 1, jm: 1 } : { jy: e, jm: t + 1 }, p = S({ jy: r.jy, jm: r.jm, jd: 1 });
212
213
  return { start: n, endExclusive: p };
213
214
  }
214
- function je(e) {
215
+ function xe(e) {
215
216
  return !(v && D(e.endExclusive, v) <= 0 || y && D(e.start, y) > 0);
216
217
  }
217
- function Ie() {
218
+ function Ye() {
218
219
  if (x === "days") {
219
220
  w("years");
220
221
  const e = l.jy;
@@ -222,43 +223,43 @@ function ot(u) {
222
223
  } else
223
224
  w("days");
224
225
  }
225
- function Oe(e) {
226
+ function Ue(e) {
226
227
  B(e), w("months");
227
228
  }
228
- function Ye(e) {
229
+ function Ge(e) {
229
230
  const t = { jy: F, jm: e };
230
231
  E(t), j(
231
- () => C({ jy: t.jy, jm: t.jm, jd: 1 })
232
+ () => S({ jy: t.jy, jm: t.jm, jd: 1 })
232
233
  ), w("days");
233
234
  }
234
- function he(e) {
235
- if (!S(e, v, y)) return;
235
+ function _e(e) {
236
+ if (!N(e, v, y)) return;
236
237
  const t = a.start, n = a.end;
237
238
  if (!t || t && n) {
238
- c({ start: e, end: null }), oe("end");
239
+ c({ start: e, end: null }), de("end");
239
240
  return;
240
241
  }
241
242
  const r = U({ start: t, end: e });
242
- c(r), m === "popover" && ve();
243
+ c(r), m === "popover" && ge();
243
244
  }
244
- const Ue = a.end ?? se, Ge = !!(a.start && !a.end && se);
245
- function He(e) {
245
+ const He = a.end ?? ie, Ke = !!(a.start && !a.end && ie);
246
+ function ze(e) {
246
247
  const t = s(
247
248
  "dvx-pdp__day",
248
249
  i?.day,
249
250
  !e.inCurrentMonth && s("dvx-pdp__day--outside", i?.dayOutside),
250
- ye(e) && s("dvx-pdp__day--disabled", i?.dayDisabled),
251
+ je(e) && s("dvx-pdp__day--disabled", i?.dayDisabled),
251
252
  O(e.gregorian, k()) && s("dvx-pdp__day--today", i?.dayToday)
252
- ), n = a.start, r = n ? Ue : null;
253
- return n && O(e.gregorian, n) ? s(t, "dvx-pdp__day--rangeStart", i?.dayRangeStart) : r && a.end && O(e.gregorian, a.end) ? s(t, "dvx-pdp__day--rangeEnd", i?.dayRangeEnd) : n && r && (a.end || Ge) && tt(e.gregorian, n, r) ? s(t, "dvx-pdp__day--inRange", i?.dayInRange) : t;
253
+ ), n = a.start, r = n ? He : null;
254
+ return n && O(e.gregorian, n) ? s(t, "dvx-pdp__day--rangeStart", i?.dayRangeStart) : r && a.end && O(e.gregorian, a.end) ? s(t, "dvx-pdp__day--rangeEnd", i?.dayRangeEnd) : n && r && (a.end || Ke) && at(e.gregorian, n, r) ? s(t, "dvx-pdp__day--inRange", i?.dayInRange) : t;
254
255
  }
255
256
  const ee = /* @__PURE__ */ L(
256
257
  "div",
257
258
  {
258
- ref: re,
259
+ ref: se,
259
260
  tabIndex: -1,
260
261
  className: "dvx-pdp__calendar",
261
- onKeyDown: Fe,
262
+ onKeyDown: Ve,
262
263
  children: [
263
264
  /* @__PURE__ */ L("div", { className: s("dvx-pdp__header", i?.header), children: [
264
265
  /* @__PURE__ */ d(
@@ -268,7 +269,7 @@ function ot(u) {
268
269
  className: s("dvx-pdp__nav", i?.navButton),
269
270
  onClick: x === "days" ? () => I(-1) : () => M((e) => e - 12),
270
271
  "aria-label": "Previous month",
271
- children: Re ?? "‹"
272
+ children: Ce ?? "‹"
272
273
  }
273
274
  ),
274
275
  /* @__PURE__ */ d(
@@ -276,9 +277,9 @@ function ot(u) {
276
277
  {
277
278
  type: "button",
278
279
  className: s("dvx-pdp__monthLabel", i?.monthLabel),
279
- onClick: Ie,
280
+ onClick: Ye,
280
281
  "aria-label": "Choose month and year",
281
- children: x === "days" ? Le : F
282
+ children: x === "days" ? Ae : F
282
283
  }
283
284
  ),
284
285
  /* @__PURE__ */ d(
@@ -288,12 +289,12 @@ function ot(u) {
288
289
  className: s("dvx-pdp__nav", i?.navButton),
289
290
  onClick: x === "days" ? () => I(1) : () => M((e) => e + 12),
290
291
  "aria-label": "Next month",
291
- children: we ?? "›"
292
+ children: Ne ?? "›"
292
293
  }
293
294
  )
294
295
  ] }),
295
296
  x === "days" ? /* @__PURE__ */ L("div", { className: s("dvx-pdp__grid", i?.grid), children: [
296
- /* @__PURE__ */ d("div", { className: "dvx-pdp__weekdays", "aria-hidden": "true", children: Te.map((e, t) => /* @__PURE__ */ d(
297
+ /* @__PURE__ */ d("div", { className: "dvx-pdp__weekdays", "aria-hidden": "true", children: Je.map((e, t) => /* @__PURE__ */ d(
297
298
  "div",
298
299
  {
299
300
  className: s("dvx-pdp__weekday", i?.weekday),
@@ -301,30 +302,30 @@ function ot(u) {
301
302
  },
302
303
  t
303
304
  )) }),
304
- /* @__PURE__ */ d("div", { className: "dvx-pdp__days", children: Ae.map((e, t) => /* @__PURE__ */ d("div", { className: "dvx-pdp__row", children: e.map((n) => {
305
- const r = ye(n), p = O(n.gregorian, $);
305
+ /* @__PURE__ */ d("div", { className: "dvx-pdp__days", children: Fe.map((e, t) => /* @__PURE__ */ d("div", { className: "dvx-pdp__row", children: e.map((n) => {
306
+ const r = je(n), p = O(n.gregorian, $);
306
307
  return /* @__PURE__ */ d(
307
308
  "button",
308
309
  {
309
310
  type: "button",
310
311
  className: s(
311
- He(n),
312
+ ze(n),
312
313
  p && "dvx-pdp__day--focused"
313
314
  ),
314
315
  disabled: r,
315
- onClick: () => he(n.gregorian),
316
+ onClick: () => _e(n.gregorian),
316
317
  onMouseEnter: () => {
317
- n.inCurrentMonth && (j(n.gregorian), a.start && !a.end && de(n.gregorian));
318
+ n.inCurrentMonth && (j(n.gregorian), a.start && !a.end && le(n.gregorian));
318
319
  },
319
- onMouseLeave: () => de(null),
320
+ onMouseLeave: () => le(null),
320
321
  children: n.jalali.jd
321
322
  },
322
323
  `${n.jalali.jy}-${n.jalali.jm}-${n.jalali.jd}`
323
324
  );
324
325
  }) }, t)) })
325
326
  ] }) : x === "years" ? /* @__PURE__ */ d("div", { className: "dvx-pdp__panel", children: /* @__PURE__ */ d("div", { className: "dvx-pdp__panelGrid", children: Array.from({ length: 12 }).map((e, t) => {
326
- const n = Ee + t, r = je(
327
- Be(n)
327
+ const n = Le + t, r = xe(
328
+ Ie(n)
328
329
  ), p = n === l.jy;
329
330
  return /* @__PURE__ */ d(
330
331
  "button",
@@ -335,14 +336,14 @@ function ot(u) {
335
336
  p && "dvx-pdp__cell--active"
336
337
  ),
337
338
  disabled: !r,
338
- onClick: () => Oe(n),
339
+ onClick: () => Ue(n),
339
340
  children: n
340
341
  },
341
342
  n
342
343
  );
343
344
  }) }) }) : /* @__PURE__ */ d("div", { className: "dvx-pdp__panel", children: /* @__PURE__ */ d("div", { className: "dvx-pdp__panelGrid", children: Array.from({ length: 12 }).map((e, t) => {
344
- const n = t + 1, r = je(
345
- Ve(F, n)
345
+ const n = t + 1, r = xe(
346
+ Oe(F, n)
346
347
  ), p = F === l.jy && n === l.jm, _ = h && h.length === 12 ? h[n - 1] ?? String(n) : String(n);
347
348
  return /* @__PURE__ */ d(
348
349
  "button",
@@ -353,7 +354,7 @@ function ot(u) {
353
354
  p && "dvx-pdp__cell--active"
354
355
  ),
355
356
  disabled: !r,
356
- onClick: () => Ye(n),
357
+ onClick: () => Ge(n),
357
358
  children: _
358
359
  },
359
360
  n
@@ -365,11 +366,12 @@ function ot(u) {
365
366
  return /* @__PURE__ */ L(
366
367
  "div",
367
368
  {
368
- ref: ae,
369
+ ref: oe,
369
370
  className: s(
370
371
  "dvx-pdp",
372
+ re,
371
373
  m === "inline" && "dvx-pdp--inline",
372
- Ne,
374
+ Se,
373
375
  i?.root
374
376
  ),
375
377
  dir: "rtl",
@@ -380,30 +382,30 @@ function ot(u) {
380
382
  ref: W,
381
383
  className: s("dvx-pdp__input", i?.input),
382
384
  disabled: R,
383
- placeholder: _e,
385
+ placeholder: ke,
384
386
  inputMode: "numeric",
385
387
  autoComplete: "off",
386
- value: pe,
388
+ value: me,
387
389
  onChange: (e) => V(e.target.value),
388
390
  onClick: () => Z(X),
389
- onBlur: () => Je(pe),
391
+ onBlur: () => Be(me),
390
392
  "aria-haspopup": "dialog",
391
393
  "aria-expanded": f
392
394
  }
393
- ) : /* @__PURE__ */ L(Qe, { children: [
395
+ ) : /* @__PURE__ */ L(Ze, { children: [
394
396
  /* @__PURE__ */ d(
395
397
  "input",
396
398
  {
397
399
  ref: q,
398
400
  className: s("dvx-pdp__input", i?.input),
399
401
  disabled: R,
400
- placeholder: be,
402
+ placeholder: De,
401
403
  inputMode: "numeric",
402
404
  autoComplete: "off",
403
- value: ie,
404
- onChange: (e) => le(e.target.value),
405
+ value: ue,
406
+ onChange: (e) => ce(e.target.value),
405
407
  onClick: () => Z("start"),
406
- onBlur: () => ge("start", ie),
408
+ onBlur: () => he("start", ue),
407
409
  "aria-haspopup": "dialog",
408
410
  "aria-expanded": f
409
411
  }
@@ -414,30 +416,32 @@ function ot(u) {
414
416
  ref: Q,
415
417
  className: s("dvx-pdp__input", i?.input),
416
418
  disabled: R,
417
- placeholder: ke,
419
+ placeholder: Re,
418
420
  inputMode: "numeric",
419
421
  autoComplete: "off",
420
- value: ue,
421
- onChange: (e) => ce(e.target.value),
422
+ value: pe,
423
+ onChange: (e) => fe(e.target.value),
422
424
  onClick: () => Z("end"),
423
- onBlur: () => ge("end", ue),
425
+ onBlur: () => he("end", pe),
424
426
  "aria-haspopup": "dialog",
425
427
  "aria-expanded": f
426
428
  }
427
429
  )
428
430
  ] }) }),
429
- m === "inline" ? ee : f ? fe && Se ? Xe(
431
+ m === "inline" ? ee : f ? ve && Pe ? et(
430
432
  /* @__PURE__ */ d(
431
433
  "div",
432
434
  {
433
435
  ref: A,
434
436
  className: s(
437
+ "dvx-pdp",
435
438
  "dvx-pdp__popover",
436
439
  "dvx-pdp__popover--portal",
440
+ re,
437
441
  i?.popover
438
442
  ),
439
443
  dir: "rtl",
440
- style: { ...me, right: "auto", bottom: "auto" },
444
+ style: { ...ye, right: "auto", bottom: "auto" },
441
445
  role: "dialog",
442
446
  "aria-modal": "false",
443
447
  children: ee
@@ -449,7 +453,7 @@ function ot(u) {
449
453
  {
450
454
  ref: A,
451
455
  className: s("dvx-pdp__popover", i?.popover),
452
- style: { ...me, right: "auto", bottom: "auto" },
456
+ style: { ...ye, right: "auto", bottom: "auto" },
453
457
  role: "dialog",
454
458
  "aria-modal": "false",
455
459
  children: ee
@@ -460,20 +464,20 @@ function ot(u) {
460
464
  );
461
465
  }
462
466
  export {
463
- it as PersianDatePicker,
464
- ot as PersianDateRangePicker,
467
+ ut as PersianDatePicker,
468
+ dt as PersianDateRangePicker,
465
469
  Y as addDays,
466
- xe as addJalaliMonths,
467
- ze as buildJalaliMonthGrid,
468
- lt as clampToRange,
470
+ be as addJalaliMonths,
471
+ qe as buildJalaliMonthGrid,
472
+ ct as clampToRange,
469
473
  D as compareDays,
470
- ut as formatJalali,
471
- C as fromJalaliParts,
472
- ct as getJalaliMonthLength,
474
+ pt as formatJalali,
475
+ S as fromJalaliParts,
476
+ ft as getJalaliMonthLength,
473
477
  O as isSameDay,
474
- S as isWithinRange,
475
- qe as parseJalaliText,
476
- pt as toGregorian,
477
- We as toJalali,
478
+ N as isWithinRange,
479
+ Xe as parseJalaliText,
480
+ mt as toGregorian,
481
+ Qe as toJalali,
478
482
  b as toJalaliParts
479
483
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const k=require("react/jsx-runtime"),b=require("react"),g=require("react-hook-form"),m=require("./PersianDatePicker-BLIBy0yJ.cjs");function D(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:()=>e[r]})}}return t.default=e,Object.freeze(t)}const j=D(b);function c(e){const{name:t,control:r,rules:n,defaultValue:i,shouldUnregister:s,disabled:a,...l}=e,{field:o,fieldState:u,formState:P}=g.useController({name:t,control:r,rules:n,defaultValue:i??null,shouldUnregister:s,disabled:a}),f=o.value??null,d=j.useCallback(p=>{o.onChange(p)},[o]);return{field:o,fieldState:u,formState:P,pickerProps:{...l,value:f,onChange:d,disabled:a}}}function C(e){const{pickerProps:t}=c(e);return k.jsx(m.PersianDatePicker,{...t})}exports.RHF_PersianDatePicker=C;exports.usePersianDatePickerController=c;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const k=require("react/jsx-runtime"),b=require("react"),g=require("react-hook-form"),m=require("./PersianDatePicker-D7P5lkvA.cjs");function D(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:()=>e[r]})}}return t.default=e,Object.freeze(t)}const j=D(b);function c(e){const{name:t,control:r,rules:n,defaultValue:i,shouldUnregister:s,disabled:a,...l}=e,{field:o,fieldState:u,formState:P}=g.useController({name:t,control:r,rules:n,defaultValue:i??null,shouldUnregister:s,disabled:a}),f=o.value??null,d=j.useCallback(p=>{o.onChange(p)},[o]);return{field:o,fieldState:u,formState:P,pickerProps:{...l,value:f,onChange:d,disabled:a}}}function C(e){const{pickerProps:t}=c(e);return k.jsx(m.PersianDatePicker,{...t})}exports.RHF_PersianDatePicker=C;exports.usePersianDatePickerController=c;
@@ -29,6 +29,7 @@ export declare function usePersianDatePickerController<TFieldValues extends Fiel
29
29
  placeholder?: string | undefined;
30
30
  onOpenChange?: ((open: boolean) => void) | undefined;
31
31
  mode?: "popover" | "inline" | undefined;
32
+ theme?: "light" | "dark" | "auto" | undefined;
32
33
  formatValue?: ((date: Date) => string) | undefined;
33
34
  parseValue?: ((text: string) => Date | null) | undefined;
34
35
  weekdays?: string[] | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"react-hook-form.d.ts","sourceRoot":"","sources":["../src/react-hook-form.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAElF,OAAO,EAAqB,KAAK,sBAAsB,EAAE,MAAM,gCAAgC,CAAA;AAE/F,MAAM,MAAM,YAAY,GAAG,IAAI,GAAG,IAAI,CAAA;AAEtC,MAAM,MAAM,oCAAoC,CAAC,YAAY,SAAS,WAAW,IAAI;IACnF,IAAI,EAAE,IAAI,CAAC,YAAY,CAAC,CAAA;IACxB,OAAO,EAAE,OAAO,CAAC,YAAY,CAAC,CAAA;IAC9B,KAAK,CAAC,EAAE,eAAe,CAAC,YAAY,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC,CAAA;IACzD,YAAY,CAAC,EAAE,YAAY,CAAA;IAC3B,gBAAgB,CAAC,EAAE,OAAO,CAAA;CAC3B,GAAG,IAAI,CAAC,sBAAsB,EAAE,OAAO,GAAG,UAAU,CAAC,CAAA;AAEtD;;;;GAIG;AACH,wBAAgB,8BAA8B,CAAC,YAAY,SAAS,WAAW,EAC7E,MAAM,EAAE,oCAAoC,CAAC,YAAY,CAAC;;;;;;yBAgBjD,YAAY;;;;;;;;;;;;;;;;;;;EAiBtB;AAED,MAAM,MAAM,0BAA0B,CAAC,YAAY,SAAS,WAAW,IAAI,oCAAoC,CAAC,Y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@@
1
1
  import { jsx as P } from "react/jsx-runtime";
2
2
  import * as d from "react";
3
3
  import { useController as k } from "react-hook-form";
4
- import { P as C } from "./PersianDatePicker-BYF8CIZO.js";
4
+ import { P as C } from "./PersianDatePicker-BEj7IYGl.js";
5
5
  function g(r) {
6
6
  const { name: o, control: n, rules: a, defaultValue: l, shouldUnregister: s, disabled: t, ...i } = r, { field: e, fieldState: u, formState: c } = k({
7
7
  name: o,
package/dist/styles.css CHANGED
@@ -1,4 +1,9 @@
1
- :root {
1
+ .dvx-pdp,
2
+ .dvx-pdp__popover--portal {
3
+ position: relative;
4
+ display: inline-block;
5
+ direction: rtl;
6
+ /* Theme variables (default: light). */
2
7
  --dvx-pdp-bg: #ffffff;
3
8
  --dvx-pdp-fg: #111827;
4
9
  --dvx-pdp-muted: #6b7280;
@@ -8,10 +13,24 @@
8
13
  --dvx-pdp-accentFg: #ffffff;
9
14
  --dvx-pdp-ring: rgba(37, 99, 235, 0.3);
10
15
  --dvx-pdp-dayHover: rgba(37, 99, 235, 0.08);
16
+ color: var(--dvx-pdp-fg);
17
+ font: inherit;
18
+ }
19
+
20
+ .dvx-pdp--theme-dark {
21
+ --dvx-pdp-bg: #0b1220;
22
+ --dvx-pdp-fg: #e5e7eb;
23
+ --dvx-pdp-muted: #9ca3af;
24
+ --dvx-pdp-border: #243045;
25
+ --dvx-pdp-shadow: 0 10px 20px rgba(0, 0, 0, 0.35);
26
+ --dvx-pdp-accent: #60a5fa;
27
+ --dvx-pdp-accentFg: #0b1220;
28
+ --dvx-pdp-ring: rgba(96, 165, 250, 0.35);
29
+ --dvx-pdp-dayHover: rgba(96, 165, 250, 0.12);
11
30
  }
12
31
 
13
32
  @media (prefers-color-scheme: dark) {
14
- :root {
33
+ .dvx-pdp--theme-auto {
15
34
  --dvx-pdp-bg: #0b1220;
16
35
  --dvx-pdp-fg: #e5e7eb;
17
36
  --dvx-pdp-muted: #9ca3af;
@@ -24,14 +43,6 @@
24
43
  }
25
44
  }
26
45
 
27
- .dvx-pdp {
28
- position: relative;
29
- display: inline-block;
30
- direction: rtl;
31
- color: var(--dvx-pdp-fg);
32
- font: inherit;
33
- }
34
-
35
46
  .dvx-pdp--inline {
36
47
  display: block;
37
48
  }
@@ -60,6 +60,15 @@ export type BasePickerProps = {
60
60
  * - `inline`: always-visible calendar, no input
61
61
  */
62
62
  mode?: 'popover' | 'inline';
63
+ /**
64
+ * Theme mode for default stylesheet (default: `'light'`).
65
+ * - `light`: force light theme regardless of OS color scheme
66
+ * - `dark`: force dark theme regardless of OS color scheme
67
+ * - `auto`: follow `prefers-color-scheme`
68
+ *
69
+ * Note: this only affects the bundled `styles.css` variables/classes.
70
+ */
71
+ theme?: 'light' | 'dark' | 'auto';
63
72
  /**
64
73
  * Popover positioning options (popover mode only).
65
74
  */
@@ -1 +1 @@
1
- {"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../src/types/shared.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,KAAK,MAAM,OAAO,CAAA;AAEnC;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;IACf;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,GAAG,UAAU,CAAA;IAC/B;;OAEG;IACH,UAAU,CAAC,EAAE,KAAK,CAAC,QAAQ,GAAG,KAAK,GAAG,MAAM,GAAG,OAAO,CAAC,CAAA;IACvD;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,KAAK,CAAA;CACnC,CAAA;AAED;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B;;OAEG;IACH,OAAO,CAAC,EAAE,IAAI,CAAA;IACd;;OAEG;IACH,OAAO,CAAC,EAAE,IAAI,CAAA;IACd;;OAEG;IACH,QAAQ,CAAC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