persian-date-kit 0.0.3 → 0.0.5

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,113 +1,150 @@
1
- import { t as b, b as Ae, i as B, a as Fe, p as Be, c as V, d as R, f as C, e as ye, g as D } from "./PersianDatePicker-BicyzfQH.js";
2
- import { P as We, k as qe, h as Qe, l as Xe, j as Ze } from "./PersianDatePicker-BicyzfQH.js";
3
- import { jsxs as E, jsx as d, Fragment as Ve } from "react/jsx-runtime";
4
- import * as s from "react";
5
- function o(...u) {
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 he, g as D } from "./PersianDatePicker-DFMNtlIF.js";
2
+ import { P as it, k as lt, h as ut, l as ct, j as pt } from "./PersianDatePicker-DFMNtlIF.js";
3
+ import { jsxs as L, jsx as d, Fragment as Qe } from "react/jsx-runtime";
4
+ import * as o from "react";
5
+ import { createPortal as Xe } from "react-dom";
6
+ function s(...u) {
6
7
  return u.filter(Boolean).join(" ");
7
8
  }
8
- function Ye(u) {
9
- return Fe(u).formatted;
9
+ function Ze(u) {
10
+ return We(u).formatted;
10
11
  }
11
- function Oe(u) {
12
- return Be(u, { allowLooseSeparators: !0 });
12
+ function et(u) {
13
+ return qe(u, { allowLooseSeparators: !0 });
13
14
  }
14
15
  function k() {
15
16
  const u = /* @__PURE__ */ new Date();
16
17
  return u.setHours(0, 0, 0, 0), u;
17
18
  }
18
- function Y(u) {
19
+ function U(u) {
19
20
  const { start: a, end: c } = u;
20
21
  return a && c && D(a, c) > 0 ? { start: c, end: a } : u;
21
22
  }
22
- function Ue(u, a, c) {
23
- const m = D(a, c) <= 0 ? a : c, y = D(a, c) <= 0 ? c : a;
24
- return D(u, m) >= 0 && D(u, y) <= 0;
23
+ function tt(u, a, c) {
24
+ const v = D(a, c) <= 0 ? a : c, y = D(a, c) <= 0 ? c : a;
25
+ return D(u, v) >= 0 && D(u, y) <= 0;
25
26
  }
26
- function He(u) {
27
+ function ot(u) {
27
28
  const {
28
29
  value: a,
29
30
  onChange: c,
30
- minDate: m,
31
+ minDate: v,
31
32
  maxDate: y,
32
- disabled: w,
33
- inputVariant: K = "two",
34
- placeholder: ve,
35
- rangeSeparator: $ = " - ",
36
- placeholderStart: je,
37
- placeholderEnd: ge,
38
- open: z,
39
- onOpenChange: he,
40
- mode: v = "popover",
41
- formatValue: j = Ye,
42
- parseValue: O = Oe,
43
- weekdays: L,
33
+ disabled: R,
34
+ inputVariant: G = "two",
35
+ placeholder: xe,
36
+ rangeSeparator: P = " - ",
37
+ placeholderStart: _e,
38
+ placeholderEnd: be,
39
+ open: H,
40
+ onOpenChange: ne,
41
+ mode: m = "popover",
42
+ popover: ke,
43
+ formatValue: g = Ze,
44
+ parseValue: K = et,
45
+ weekdays: T,
44
46
  monthLabels: h,
45
- renderMonthLabel: U,
46
- className: xe,
47
- classes: l
48
- } = u, W = s.useRef(null), q = s.useRef(null), Q = s.useRef(null), X = s.useRef(null), Z = s.useRef(null), [_e, be] = s.useState(!1), f = v === "inline" ? !0 : z ?? _e;
49
- function G(e) {
50
- he?.(e), v !== "inline" && z === void 0 && be(e);
51
- }
52
- const [ee, te] = s.useState("start"), [x, N] = s.useState("days"), [ke, S] = s.useState(() => {
47
+ renderMonthLabel: z,
48
+ prevIcon: De,
49
+ nextIcon: Re,
50
+ className: we,
51
+ 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), [Ne, Se] = o.useState(!1), [Ce, Pe] = o.useState(!1), f = m === "inline" ? !0 : H ?? Ce, J = o.useCallback(
53
+ (e) => {
54
+ ne?.(e), m !== "inline" && H === void 0 && Pe(e);
55
+ },
56
+ [m, ne, H]
57
+ );
58
+ o.useEffect(() => {
59
+ Se(!0);
60
+ }, []);
61
+ const [X, oe] = o.useState(
62
+ "start"
63
+ ), [x, w] = o.useState("days"), [Me, M] = o.useState(() => {
53
64
  const e = a.start ?? a.end ?? k(), t = b(e).jy;
54
65
  return t - t % 12;
55
- }), [T, J] = s.useState(() => {
66
+ }), [F, B] = o.useState(() => {
56
67
  const e = a.start ?? a.end ?? k();
57
68
  return b(e).jy;
58
- }), [i, M] = s.useState(() => {
69
+ }), [l, E] = o.useState(() => {
59
70
  const e = a.start ?? a.end ?? k(), t = b(e);
60
71
  return { jy: t.jy, jm: t.jm };
61
- }), [P, g] = s.useState(() => a.start ?? a.end ?? k()), [ne, ae] = s.useState(null), [re, se] = s.useState(() => a.start ? j(a.start) : ""), [oe, ie] = s.useState(() => a.end ? j(a.end) : ""), [de, A] = s.useState(() => {
62
- const e = a.start ? j(a.start) : "", t = a.end ? j(a.end) : "";
63
- return !e && !t ? "" : e && !t ? `${e}${$}` : `${e}${$}${t}`;
72
+ }), [$, j] = o.useState(
73
+ () => a.start ?? a.end ?? k()
74
+ ), [se, de] = o.useState(null), [ie, le] = o.useState(
75
+ () => a.start ? g(a.start) : ""
76
+ ), [ue, ce] = o.useState(
77
+ () => a.end ? g(a.end) : ""
78
+ ), [pe, V] = o.useState(() => {
79
+ const e = a.start ? g(a.start) : "", t = a.end ? g(a.end) : "";
80
+ return !e && !t ? "" : e && !t ? `${e}${P}` : `${e}${P}${t}`;
64
81
  });
65
- s.useEffect(() => {
66
- se(a.start ? j(a.start) : ""), ie(a.end ? j(a.end) : "");
67
- const e = a.start ? j(a.start) : "", t = a.end ? j(a.end) : "";
68
- A(!e && !t ? "" : e && !t ? `${e}${$}` : `${e}${$}${t}`);
82
+ o.useEffect(() => {
83
+ le(a.start ? g(a.start) : ""), ce(a.end ? g(a.end) : "");
84
+ const e = a.start ? g(a.start) : "", t = a.end ? g(a.end) : "";
85
+ V(!e && !t ? "" : e && !t ? `${e}${P}` : `${e}${P}${t}`);
69
86
  const n = a.start ?? a.end ?? k(), r = b(n);
70
- M({ jy: r.jy, jm: r.jm }), g(n), J(r.jy), S(r.jy - r.jy % 12);
71
- }, [j, a.end, a.start]), s.useEffect(() => {
72
- if (v !== "popover" || !f) return;
87
+ E({ jy: r.jy, jm: r.jm }), j(n), B(r.jy), M(r.jy - r.jy % 12);
88
+ }, [g, P, a.end, a.start]), o.useEffect(() => {
89
+ if (m !== "popover" || !f) return;
73
90
  const e = (t) => {
74
- const n = W.current;
75
- n && t.target instanceof Node && !n.contains(t.target) && G(!1);
91
+ const n = ae.current;
92
+ if (!n) return;
93
+ const r = A.current;
94
+ t.target instanceof Node && !n.contains(t.target) && !(r && r.contains(t.target)) && J(!1);
76
95
  };
77
96
  return document.addEventListener("pointerdown", e), () => document.removeEventListener("pointerdown", e);
78
- }, [v, f]), s.useEffect(() => {
79
- f && Z.current?.focus();
80
- }, [f]), s.useEffect(() => {
97
+ }, [m, f, J]), o.useEffect(() => {
98
+ f && re.current?.focus();
99
+ }, [f]);
100
+ const N = ke ?? {}, fe = N.portal ?? !0, Ee = G === "single" ? W : X === "start" ? q : Q, { style: $e } = Ke(
101
+ m === "popover" && f && fe,
102
+ Ee,
103
+ A,
104
+ {
105
+ gutter: N.gutter,
106
+ padding: N.padding,
107
+ strategy: N.strategy,
108
+ placements: N.placements,
109
+ align: N.align ?? "end"
110
+ }
111
+ );
112
+ o.useEffect(() => {
81
113
  if (!f) return;
82
- const e = b(P);
83
- M((t) => t.jy === e.jy && t.jm === e.jm ? t : { jy: e.jy, jm: e.jm });
84
- }, [P, f]);
85
- const De = s.useMemo(() => U ? U(i.jy, i.jm) : h && h.length === 12 ? `${h[i.jm - 1] ?? String(i.jm)} ${i.jy}` : `${i.jy} / ${i.jm}`, [h, U, i.jm, i.jy]), we = s.useMemo(() => L && L.length === 7 ? L : ["1", "2", "3", "4", "5", "6", "7"], [L]), Ne = s.useMemo(() => Ae({ jy: i.jy, jm: i.jm }), [i.jm, i.jy]);
86
- function I(e) {
87
- if (w) return;
88
- te(e), G(!0);
114
+ const e = b($);
115
+ E(
116
+ (t) => t.jy === e.jy && t.jm === e.jm ? t : { jy: e.jy, jm: e.jm }
117
+ );
118
+ }, [$, f]);
119
+ 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(
120
+ () => ze({ jy: l.jy, jm: l.jm }),
121
+ [l.jm, l.jy]
122
+ );
123
+ function Z(e) {
124
+ if (R) return;
125
+ oe(e), J(!0);
89
126
  const t = (e === "start" ? a.start : a.end) ?? a.start ?? a.end ?? k(), n = b(t);
90
- M({ jy: n.jy, jm: n.jm }), g(t), N("days"), J(n.jy), S(n.jy - n.jy % 12);
127
+ E({ jy: n.jy, jm: n.jm }), j(t), w("days"), B(n.jy), M(n.jy - n.jy % 12);
91
128
  }
92
- function le() {
93
- G(!1), N("days"), v === "popover" && (K === "single" ? q.current?.focus() : (ee === "start" ? Q : X).current?.focus());
129
+ function me() {
130
+ J(!1), w("days"), m === "popover" && (G === "single" ? W.current?.focus() : (X === "start" ? q : Q).current?.focus());
94
131
  }
95
- function ue(e) {
96
- return w ? !0 : !R(e.gregorian, m, y);
132
+ function ve(e) {
133
+ return R ? !0 : !S(e.gregorian, v, y);
97
134
  }
98
- function ce(e, t) {
135
+ function ye(e, t) {
99
136
  const n = t.trim();
100
137
  if (!n) {
101
- const _ = Y({ ...a, [e]: null });
138
+ const _ = U({ ...a, [e]: null });
102
139
  c(_);
103
140
  return;
104
141
  }
105
- const r = O(n);
106
- if (!r || !R(r, m, y)) return;
107
- const p = Y({ ...a, [e]: r });
142
+ const r = K(n);
143
+ if (!r || !S(r, v, y)) return;
144
+ const p = U({ ...a, [e]: r });
108
145
  c(p);
109
146
  }
110
- function Re(e) {
147
+ function Je(e) {
111
148
  const t = e.trim();
112
149
  if (!t) {
113
150
  c({ start: null, end: null });
@@ -115,250 +152,325 @@ function He(u) {
115
152
  }
116
153
  const n = t.match(/\d{4}[^\d]\d{1,2}[^\d]\d{1,2}/g) ?? [], r = n[0], p = n[1];
117
154
  if (!r) return;
118
- const _ = O(r), H = p ? O(p) : null;
119
- _ && R(_, m, y) && (H && !R(H, m, y) || c(Y({ start: _, end: H })));
155
+ const _ = K(r), te = p ? K(p) : null;
156
+ _ && S(_, v, y) && (te && !S(te, v, y) || c(U({ start: _, end: te })));
120
157
  }
121
- function Ce(e) {
122
- if (f && !w) {
158
+ function Fe(e) {
159
+ if (f && !R) {
123
160
  if (e.key === "Escape") {
124
- e.preventDefault(), le();
161
+ e.preventDefault(), me();
125
162
  return;
126
163
  }
127
164
  if (x === "days") {
128
165
  if (e.key === "ArrowLeft") {
129
- e.preventDefault(), g((t) => V(t, -1));
166
+ e.preventDefault(), j((t) => Y(t, -1));
130
167
  return;
131
168
  }
132
169
  if (e.key === "ArrowRight") {
133
- e.preventDefault(), g((t) => V(t, 1));
170
+ e.preventDefault(), j((t) => Y(t, 1));
134
171
  return;
135
172
  }
136
173
  if (e.key === "ArrowUp") {
137
- e.preventDefault(), g((t) => V(t, -7));
174
+ e.preventDefault(), j((t) => Y(t, -7));
138
175
  return;
139
176
  }
140
177
  if (e.key === "ArrowDown") {
141
- e.preventDefault(), g((t) => V(t, 7));
178
+ e.preventDefault(), j((t) => Y(t, 7));
142
179
  return;
143
180
  }
144
181
  if (e.key === "PageUp") {
145
- e.preventDefault(), F(-1);
182
+ e.preventDefault(), I(-1);
146
183
  return;
147
184
  }
148
185
  if (e.key === "PageDown") {
149
- e.preventDefault(), F(1);
186
+ e.preventDefault(), I(1);
150
187
  return;
151
188
  }
152
189
  if (e.key === "Enter") {
153
- if (e.preventDefault(), !R(P, m, y)) return;
154
- fe(P);
190
+ if (e.preventDefault(), !S($, v, y)) return;
191
+ je($);
155
192
  }
156
193
  }
157
194
  }
158
195
  }
159
- function F(e) {
160
- const t = C({ jy: i.jy, jm: i.jm, jd: 1 }), n = ye(t, e), r = b(n);
161
- M({ jy: r.jy, jm: r.jm }), g((p) => ye(p, e));
196
+ function I(e) {
197
+ const t = C({
198
+ jy: l.jy,
199
+ jm: l.jm,
200
+ jd: 1
201
+ }), n = he(t, e), r = b(n);
202
+ E({ jy: r.jy, jm: r.jm }), j((p) => he(p, e));
162
203
  }
163
- function Se(e) {
204
+ function Be(e) {
164
205
  const t = C({ jy: e, jm: 1, jd: 1 }), n = C({ jy: e + 1, jm: 1, jd: 1 });
165
206
  return { start: t, endExclusive: n };
166
207
  }
167
- function Me(e, t) {
208
+ function Ve(e, t) {
168
209
  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 });
169
210
  return { start: n, endExclusive: p };
170
211
  }
171
- function pe(e) {
172
- return !(m && D(e.endExclusive, m) <= 0 || y && D(e.start, y) > 0);
212
+ function ge(e) {
213
+ return !(v && D(e.endExclusive, v) <= 0 || y && D(e.start, y) > 0);
173
214
  }
174
- function Pe() {
215
+ function Ie() {
175
216
  if (x === "days") {
176
- N("years");
177
- const e = i.jy;
178
- J(e), S(e - e % 12);
217
+ w("years");
218
+ const e = l.jy;
219
+ B(e), M(e - e % 12);
179
220
  } else
180
- N("days");
221
+ w("days");
181
222
  }
182
- function Ee(e) {
183
- J(e), N("months");
223
+ function Oe(e) {
224
+ B(e), w("months");
184
225
  }
185
- function $e(e) {
186
- const t = { jy: T, jm: e };
187
- M(t), g(() => C({ jy: t.jy, jm: t.jm, jd: 1 })), N("days");
226
+ function Ye(e) {
227
+ const t = { jy: F, jm: e };
228
+ E(t), j(
229
+ () => C({ jy: t.jy, jm: t.jm, jd: 1 })
230
+ ), w("days");
188
231
  }
189
- function fe(e) {
190
- if (!R(e, m, y)) return;
232
+ function je(e) {
233
+ if (!S(e, v, y)) return;
191
234
  const t = a.start, n = a.end;
192
235
  if (!t || t && n) {
193
- c({ start: e, end: null }), te("end");
236
+ c({ start: e, end: null }), oe("end");
194
237
  return;
195
238
  }
196
- const r = Y({ start: t, end: e });
197
- c(r), v === "popover" && le();
239
+ const r = U({ start: t, end: e });
240
+ c(r), m === "popover" && me();
198
241
  }
199
- const Le = a.end ?? ne, Te = !!(a.start && !a.end && ne);
200
- function Je(e) {
201
- const t = o(
242
+ const Ue = a.end ?? se, Ge = !!(a.start && !a.end && se);
243
+ function He(e) {
244
+ const t = s(
202
245
  "dvx-pdp__day",
203
- l?.day,
204
- !e.inCurrentMonth && o("dvx-pdp__day--outside", l?.dayOutside),
205
- ue(e) && o("dvx-pdp__day--disabled", l?.dayDisabled),
206
- B(e.gregorian, k()) && o("dvx-pdp__day--today", l?.dayToday)
207
- ), n = a.start, r = n ? Le : null;
208
- return n && B(e.gregorian, n) ? o(t, "dvx-pdp__day--rangeStart", l?.dayRangeStart) : r && a.end && B(e.gregorian, a.end) ? o(t, "dvx-pdp__day--rangeEnd", l?.dayRangeEnd) : n && r && (a.end || Te) && Ue(e.gregorian, n, r) ? o(t, "dvx-pdp__day--inRange", l?.dayInRange) : t;
246
+ i?.day,
247
+ !e.inCurrentMonth && s("dvx-pdp__day--outside", i?.dayOutside),
248
+ ve(e) && s("dvx-pdp__day--disabled", i?.dayDisabled),
249
+ O(e.gregorian, k()) && s("dvx-pdp__day--today", i?.dayToday)
250
+ ), n = a.start, r = n ? Ue : null;
251
+ 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;
209
252
  }
210
- const me = /* @__PURE__ */ E("div", { ref: Z, tabIndex: -1, className: "dvx-pdp__calendar", onKeyDown: Ce, children: [
211
- /* @__PURE__ */ E("div", { className: o("dvx-pdp__header", l?.header), children: [
212
- /* @__PURE__ */ d(
213
- "button",
214
- {
215
- type: "button",
216
- className: o("dvx-pdp__nav", l?.navButton),
217
- onClick: x === "days" ? () => F(-1) : () => S((e) => e - 12),
218
- "aria-label": "Previous month",
219
- children: "‹"
220
- }
221
- ),
222
- /* @__PURE__ */ d(
223
- "button",
224
- {
225
- type: "button",
226
- className: o("dvx-pdp__monthLabel", l?.monthLabel),
227
- onClick: Pe,
228
- "aria-label": "Choose month and year",
229
- children: x === "days" ? De : T
230
- }
231
- ),
232
- /* @__PURE__ */ d(
233
- "button",
234
- {
235
- type: "button",
236
- className: o("dvx-pdp__nav", l?.navButton),
237
- onClick: x === "days" ? () => F(1) : () => S((e) => e + 12),
238
- "aria-label": "Next month",
239
- children: "›"
240
- }
241
- )
242
- ] }),
243
- x === "days" ? /* @__PURE__ */ E("div", { className: o("dvx-pdp__grid", l?.grid), children: [
244
- /* @__PURE__ */ d("div", { className: "dvx-pdp__weekdays", "aria-hidden": "true", children: we.map((e, t) => /* @__PURE__ */ d("div", { className: o("dvx-pdp__weekday", l?.weekday), children: e }, t)) }),
245
- /* @__PURE__ */ d("div", { className: "dvx-pdp__days", children: Ne.map((e, t) => /* @__PURE__ */ d("div", { className: "dvx-pdp__row", children: e.map((n) => {
246
- const r = ue(n), p = B(n.gregorian, P);
247
- return /* @__PURE__ */ d(
248
- "button",
249
- {
250
- type: "button",
251
- className: o(Je(n), p && "dvx-pdp__day--focused"),
252
- disabled: r,
253
- onClick: () => fe(n.gregorian),
254
- onMouseEnter: () => {
255
- n.inCurrentMonth && (g(n.gregorian), a.start && !a.end && ae(n.gregorian));
253
+ const ee = /* @__PURE__ */ L(
254
+ "div",
255
+ {
256
+ ref: re,
257
+ tabIndex: -1,
258
+ className: "dvx-pdp__calendar",
259
+ onKeyDown: Fe,
260
+ children: [
261
+ /* @__PURE__ */ L("div", { className: s("dvx-pdp__header", i?.header), children: [
262
+ /* @__PURE__ */ d(
263
+ "button",
264
+ {
265
+ type: "button",
266
+ className: s("dvx-pdp__nav", i?.navButton),
267
+ onClick: x === "days" ? () => I(-1) : () => M((e) => e - 12),
268
+ "aria-label": "Previous month",
269
+ children: De ?? ""
270
+ }
271
+ ),
272
+ /* @__PURE__ */ d(
273
+ "button",
274
+ {
275
+ type: "button",
276
+ className: s("dvx-pdp__monthLabel", i?.monthLabel),
277
+ onClick: Ie,
278
+ "aria-label": "Choose month and year",
279
+ children: x === "days" ? Le : F
280
+ }
281
+ ),
282
+ /* @__PURE__ */ d(
283
+ "button",
284
+ {
285
+ type: "button",
286
+ className: s("dvx-pdp__nav", i?.navButton),
287
+ onClick: x === "days" ? () => I(1) : () => M((e) => e + 12),
288
+ "aria-label": "Next month",
289
+ children: Re ?? "›"
290
+ }
291
+ )
292
+ ] }),
293
+ x === "days" ? /* @__PURE__ */ L("div", { className: s("dvx-pdp__grid", i?.grid), children: [
294
+ /* @__PURE__ */ d("div", { className: "dvx-pdp__weekdays", "aria-hidden": "true", children: Te.map((e, t) => /* @__PURE__ */ d(
295
+ "div",
296
+ {
297
+ className: s("dvx-pdp__weekday", i?.weekday),
298
+ children: e
256
299
  },
257
- onMouseLeave: () => ae(null),
258
- children: n.jalali.jd
259
- },
260
- `${n.jalali.jy}-${n.jalali.jm}-${n.jalali.jd}`
261
- );
262
- }) }, t)) })
263
- ] }) : 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) => {
264
- const n = ke + t, r = pe(Se(n)), p = n === i.jy;
265
- return /* @__PURE__ */ d(
266
- "button",
267
- {
268
- type: "button",
269
- className: o("dvx-pdp__cell", p && "dvx-pdp__cell--active"),
270
- disabled: !r,
271
- onClick: () => Ee(n),
272
- children: n
273
- },
274
- n
275
- );
276
- }) }) }) : /* @__PURE__ */ d("div", { className: "dvx-pdp__panel", children: /* @__PURE__ */ d("div", { className: "dvx-pdp__panelGrid", children: Array.from({ length: 12 }).map((e, t) => {
277
- const n = t + 1, r = pe(Me(T, n)), p = T === i.jy && n === i.jm, _ = h && h.length === 12 ? h[n - 1] ?? String(n) : String(n);
278
- return /* @__PURE__ */ d(
279
- "button",
280
- {
281
- type: "button",
282
- className: o("dvx-pdp__cell", p && "dvx-pdp__cell--active"),
283
- disabled: !r,
284
- onClick: () => $e(n),
285
- children: _
286
- },
287
- n
288
- );
289
- }) }) })
290
- ] });
291
- return /* @__PURE__ */ E("div", { ref: W, className: o("dvx-pdp", v === "inline" && "dvx-pdp--inline", xe, l?.root), dir: "rtl", children: [
292
- v === "inline" ? null : /* @__PURE__ */ d("div", { className: "dvx-pdp__control", children: K === "single" ? /* @__PURE__ */ d(
293
- "input",
294
- {
295
- ref: q,
296
- className: o("dvx-pdp__input", l?.input),
297
- disabled: w,
298
- placeholder: ve,
299
- inputMode: "numeric",
300
- autoComplete: "off",
301
- value: de,
302
- onChange: (e) => A(e.target.value),
303
- onClick: () => I(ee),
304
- onBlur: () => Re(de),
305
- "aria-haspopup": "dialog",
306
- "aria-expanded": f
307
- }
308
- ) : /* @__PURE__ */ E(Ve, { children: [
309
- /* @__PURE__ */ d(
310
- "input",
311
- {
312
- ref: Q,
313
- className: o("dvx-pdp__input", l?.input),
314
- disabled: w,
315
- placeholder: je,
316
- inputMode: "numeric",
317
- autoComplete: "off",
318
- value: re,
319
- onChange: (e) => se(e.target.value),
320
- onClick: () => I("start"),
321
- onBlur: () => ce("start", re),
322
- "aria-haspopup": "dialog",
323
- "aria-expanded": f
324
- }
300
+ t
301
+ )) }),
302
+ /* @__PURE__ */ d("div", { className: "dvx-pdp__days", children: Ae.map((e, t) => /* @__PURE__ */ d("div", { className: "dvx-pdp__row", children: e.map((n) => {
303
+ const r = ve(n), p = O(n.gregorian, $);
304
+ return /* @__PURE__ */ d(
305
+ "button",
306
+ {
307
+ type: "button",
308
+ className: s(
309
+ He(n),
310
+ p && "dvx-pdp__day--focused"
311
+ ),
312
+ disabled: r,
313
+ onClick: () => je(n.gregorian),
314
+ onMouseEnter: () => {
315
+ n.inCurrentMonth && (j(n.gregorian), a.start && !a.end && de(n.gregorian));
316
+ },
317
+ onMouseLeave: () => de(null),
318
+ children: n.jalali.jd
319
+ },
320
+ `${n.jalali.jy}-${n.jalali.jm}-${n.jalali.jd}`
321
+ );
322
+ }) }, t)) })
323
+ ] }) : 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) => {
324
+ const n = Me + t, r = ge(
325
+ Be(n)
326
+ ), p = n === l.jy;
327
+ return /* @__PURE__ */ d(
328
+ "button",
329
+ {
330
+ type: "button",
331
+ className: s(
332
+ "dvx-pdp__cell",
333
+ p && "dvx-pdp__cell--active"
334
+ ),
335
+ disabled: !r,
336
+ onClick: () => Oe(n),
337
+ children: n
338
+ },
339
+ n
340
+ );
341
+ }) }) }) : /* @__PURE__ */ d("div", { className: "dvx-pdp__panel", children: /* @__PURE__ */ d("div", { className: "dvx-pdp__panelGrid", children: Array.from({ length: 12 }).map((e, t) => {
342
+ const n = t + 1, r = ge(
343
+ Ve(F, n)
344
+ ), p = F === l.jy && n === l.jm, _ = h && h.length === 12 ? h[n - 1] ?? String(n) : String(n);
345
+ return /* @__PURE__ */ d(
346
+ "button",
347
+ {
348
+ type: "button",
349
+ className: s(
350
+ "dvx-pdp__cell",
351
+ p && "dvx-pdp__cell--active"
352
+ ),
353
+ disabled: !r,
354
+ onClick: () => Ye(n),
355
+ children: _
356
+ },
357
+ n
358
+ );
359
+ }) }) })
360
+ ]
361
+ }
362
+ );
363
+ return /* @__PURE__ */ L(
364
+ "div",
365
+ {
366
+ ref: ae,
367
+ className: s(
368
+ "dvx-pdp",
369
+ m === "inline" && "dvx-pdp--inline",
370
+ we,
371
+ i?.root
325
372
  ),
326
- /* @__PURE__ */ d(
327
- "input",
328
- {
329
- ref: X,
330
- className: o("dvx-pdp__input", l?.input),
331
- disabled: w,
332
- placeholder: ge,
333
- inputMode: "numeric",
334
- autoComplete: "off",
335
- value: oe,
336
- onChange: (e) => ie(e.target.value),
337
- onClick: () => I("end"),
338
- onBlur: () => ce("end", oe),
339
- "aria-haspopup": "dialog",
340
- "aria-expanded": f
341
- }
342
- )
343
- ] }) }),
344
- v === "inline" ? me : f ? /* @__PURE__ */ d("div", { className: o("dvx-pdp__popover", l?.popover), role: "dialog", "aria-modal": "false", children: me }) : null
345
- ] });
373
+ dir: "rtl",
374
+ children: [
375
+ m === "inline" ? null : /* @__PURE__ */ d("div", { className: "dvx-pdp__control", children: G === "single" ? /* @__PURE__ */ d(
376
+ "input",
377
+ {
378
+ ref: W,
379
+ className: s("dvx-pdp__input", i?.input),
380
+ disabled: R,
381
+ placeholder: xe,
382
+ inputMode: "numeric",
383
+ autoComplete: "off",
384
+ value: pe,
385
+ onChange: (e) => V(e.target.value),
386
+ onClick: () => Z(X),
387
+ onBlur: () => Je(pe),
388
+ "aria-haspopup": "dialog",
389
+ "aria-expanded": f
390
+ }
391
+ ) : /* @__PURE__ */ L(Qe, { children: [
392
+ /* @__PURE__ */ d(
393
+ "input",
394
+ {
395
+ ref: q,
396
+ className: s("dvx-pdp__input", i?.input),
397
+ disabled: R,
398
+ placeholder: _e,
399
+ inputMode: "numeric",
400
+ autoComplete: "off",
401
+ value: ie,
402
+ onChange: (e) => le(e.target.value),
403
+ onClick: () => Z("start"),
404
+ onBlur: () => ye("start", ie),
405
+ "aria-haspopup": "dialog",
406
+ "aria-expanded": f
407
+ }
408
+ ),
409
+ /* @__PURE__ */ d(
410
+ "input",
411
+ {
412
+ ref: Q,
413
+ className: s("dvx-pdp__input", i?.input),
414
+ disabled: R,
415
+ placeholder: be,
416
+ inputMode: "numeric",
417
+ autoComplete: "off",
418
+ value: ue,
419
+ onChange: (e) => ce(e.target.value),
420
+ onClick: () => Z("end"),
421
+ onBlur: () => ye("end", ue),
422
+ "aria-haspopup": "dialog",
423
+ "aria-expanded": f
424
+ }
425
+ )
426
+ ] }) }),
427
+ m === "inline" ? ee : f ? fe && Ne ? Xe(
428
+ /* @__PURE__ */ d(
429
+ "div",
430
+ {
431
+ ref: A,
432
+ className: s(
433
+ "dvx-pdp__popover",
434
+ "dvx-pdp__popover--portal",
435
+ i?.popover
436
+ ),
437
+ dir: "rtl",
438
+ style: { ...$e, right: "auto", bottom: "auto" },
439
+ role: "dialog",
440
+ "aria-modal": "false",
441
+ children: ee
442
+ }
443
+ ),
444
+ document.body
445
+ ) : /* @__PURE__ */ d(
446
+ "div",
447
+ {
448
+ ref: A,
449
+ className: s("dvx-pdp__popover", i?.popover),
450
+ role: "dialog",
451
+ "aria-modal": "false",
452
+ children: ee
453
+ }
454
+ ) : null
455
+ ]
456
+ }
457
+ );
346
458
  }
347
459
  export {
348
- We as PersianDatePicker,
349
- He as PersianDateRangePicker,
350
- V as addDays,
351
- ye as addJalaliMonths,
352
- Ae as buildJalaliMonthGrid,
353
- qe as clampToRange,
460
+ it as PersianDatePicker,
461
+ ot as PersianDateRangePicker,
462
+ Y as addDays,
463
+ he as addJalaliMonths,
464
+ ze as buildJalaliMonthGrid,
465
+ lt as clampToRange,
354
466
  D as compareDays,
355
- Qe as formatJalali,
467
+ ut as formatJalali,
356
468
  C as fromJalaliParts,
357
- Xe as getJalaliMonthLength,
358
- B as isSameDay,
359
- R as isWithinRange,
360
- Be as parseJalaliText,
361
- Ze as toGregorian,
362
- Fe as toJalali,
469
+ ct as getJalaliMonthLength,
470
+ O as isSameDay,
471
+ S as isWithinRange,
472
+ qe as parseJalaliText,
473
+ pt as toGregorian,
474
+ We as toJalali,
363
475
  b as toJalaliParts
364
476
  };