bs-ad-calendar-react 1.3.1 → 1.3.3
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/bs-ad-calendar.js
CHANGED
|
@@ -1,78 +1,78 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { useMemo as
|
|
3
|
-
const
|
|
1
|
+
import { jsxs as C, jsx as g, Fragment as pe } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo as mt, useState as H, useEffect as Dt, useRef as xt } from "react";
|
|
3
|
+
const tt = [1943, 4, 14], Lt = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31], Se = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31], _ = [[[30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31], 365], [[31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], 365], [[31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30], 365], [[31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], 366], [[30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31], 365], [[31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], 365], [[31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30], 365], [[31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], 366], [[31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 29, 31], 365], [[31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], 365], [[31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30], 365], [[31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], 366], [[31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30], 365], [[31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], 365], [[31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30], 365], [[31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], 366], [[31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30], 365], [[31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], 365], [[31, 32, 31, 32, 31, 30, 30, 29, 30, 29, 30, 30], 365], [[31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31], 366], [[31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30], 365], [[31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], 365], [[31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30], 365], [[31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31], 366], [[31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30], 365], [[31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], 365], [[31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], 366], [[30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31], 365], [[31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], 365], [[31, 31, 32, 31, 32, 30, 30, 29, 30, 29, 30, 30], 365], [[31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], 366], [[30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31], 365], [[31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], 365], [[31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30], 365], [[31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], 366], [[30, 32, 31, 32, 31, 31, 29, 30, 30, 29, 29, 31], 365], [[31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], 365], [[31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30], 365], [[31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], 366], [[31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30], 365], [[31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], 365], [[31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30], 365], [[31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], 366], [[31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30], 365], [[31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], 365], [[31, 32, 31, 32, 31, 30, 30, 29, 30, 29, 30, 30], 365], [[31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], 366], [[31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30], 365], [[31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], 365], [[31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30], 365], [[31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31], 366], [[31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30], 365], [[31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], 365], [[31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30], 365], [[31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31], 366], [[31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], 365], [[31, 31, 32, 31, 32, 30, 30, 29, 30, 29, 30, 30], 365], [[31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], 366], [[30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31], 365], [[31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], 365], [[31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30], 365], [[31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], 366], [[30, 32, 31, 32, 31, 31, 29, 30, 29, 30, 29, 31], 365], [[31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], 365], [[31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30], 365], [[31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], 366], [[31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 29, 31], 365], [[31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], 365], [[31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30], 365], [[31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], 366], [[31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30], 365], [[31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], 365], [[31, 32, 31, 32, 31, 30, 30, 29, 30, 29, 30, 30], 365], [[31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], 366], [[31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30], 365], [[31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], 365], [[31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30], 365], [[31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31], 366], [[31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30], 365], [[31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], 365], [[31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30], 365], [[31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31], 366], [[31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], 365], [[31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], 365], [[31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], 366], [[30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31], 365], [[31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], 365], [[31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30], 365], [[31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], 366], [[30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31], 365], [[31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], 365], [[31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30], 365], [[31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], 366], [[31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 29, 31], 365], [[31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], 365], [[31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30], 365], [[31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], 366], [[31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30], 365], [[31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], 365], [[31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30], 365]];
|
|
4
4
|
let Rt = class extends Error {
|
|
5
5
|
constructor(t) {
|
|
6
6
|
super(t), this.name = "DateOutOfRangeError";
|
|
7
7
|
}
|
|
8
8
|
};
|
|
9
|
-
const _t = () =>
|
|
9
|
+
const _t = () => tt[0] + 1, jt = () => tt[0] + _.length - 1, Pt = () => 2e3, Wt = () => 2e3 + _.length - 1, yt = (e) => e % 400 === 0 || e % 4 === 0 && e % 100 !== 0, Ct = (e) => yt(e) ? Se : Lt, be = (e, t, n) => !(e < _t() || e > jt() || t < 1 || t > 12 || n < 1 || n > Ct(e)[t - 1]), Nt = (e, t, n) => {
|
|
10
10
|
let a = e * 365 + n;
|
|
11
11
|
for (let s = 0; s < t - 1; s++) a += Lt[s];
|
|
12
12
|
return t <= 2 && (e -= 1), a += Math.floor(e / 4) - Math.floor(e / 100) + Math.floor(e / 400), a;
|
|
13
13
|
};
|
|
14
14
|
function Ee(e, t, n) {
|
|
15
15
|
const a = t + 1;
|
|
16
|
-
if (!
|
|
17
|
-
let s = 2e3, r = 1, o = 1,
|
|
18
|
-
for (;
|
|
16
|
+
if (!be(e, a, n)) throw new Rt("Date out of range");
|
|
17
|
+
let s = 2e3, r = 1, o = 1, i = Math.abs(Nt(e, a, n) - Nt(...tt)), u = 0;
|
|
18
|
+
for (; i >= _[u][1]; ) i -= _[u][1], s += 1, u += 1;
|
|
19
19
|
let h = 0;
|
|
20
|
-
for (;
|
|
21
|
-
return o +=
|
|
20
|
+
for (; i >= _[u][0][h]; ) i -= _[u][0][h], r += 1, h += 1;
|
|
21
|
+
return o += i, [s, r - 1, o];
|
|
22
22
|
}
|
|
23
|
-
const we = (e, t, n) => !(e < Pt() || e > Wt() || t < 1 || t > 12 || n < 1 || n >
|
|
23
|
+
const we = (e, t, n) => !(e < Pt() || e > Wt() || t < 1 || t > 12 || n < 1 || n > _[e - 2e3][0][t - 1]), Ye = (e, t, n) => {
|
|
24
24
|
let a = n - 1;
|
|
25
25
|
const s = e - 2e3;
|
|
26
|
-
for (let r = 0; r < t - 1; r++) a +=
|
|
27
|
-
for (let r = 0; r < s; r++) a +=
|
|
26
|
+
for (let r = 0; r < t - 1; r++) a += _[s][0][r];
|
|
27
|
+
for (let r = 0; r < s; r++) a += _[r][1];
|
|
28
28
|
return a;
|
|
29
29
|
}, ke = (e, t, n) => {
|
|
30
30
|
const a = t + 1;
|
|
31
31
|
if (!we(e, a, n)) throw new Rt("Date out of range");
|
|
32
|
-
let [s, r, o] = [
|
|
33
|
-
const
|
|
34
|
-
let
|
|
35
|
-
for (;
|
|
36
|
-
const h =
|
|
32
|
+
let [s, r, o] = [tt[0], 1, 1];
|
|
33
|
+
const i = Ct(s).slice(0, tt[1] - 1).reduce((f, l) => f + l, 0) + tt[2] - 1;
|
|
34
|
+
let u = Math.abs(Ye(e, a, n) + i);
|
|
35
|
+
for (; u >= 366 && yt(s) || u >= 365 && !yt(s); ) u -= yt(s) ? 366 : 365, s += 1;
|
|
36
|
+
const h = Ct(s);
|
|
37
37
|
let c = 0;
|
|
38
|
-
for (;
|
|
39
|
-
return o +=
|
|
40
|
-
},
|
|
41
|
-
const t = e.getTime(), n = t < Ce ?
|
|
42
|
-
return { year: s, month0: r, day: o, hour:
|
|
43
|
-
},
|
|
44
|
-
const
|
|
45
|
-
let
|
|
46
|
-
const h = -1 *
|
|
47
|
-
return new Date(
|
|
38
|
+
for (; u >= h[c]; ) u -= h[c], r += 1, c += 1;
|
|
39
|
+
return o += u, [s, r - 1, o];
|
|
40
|
+
}, W = { enMinYear: _t, enMaxYear: jt, npMinYear: Pt, npMaxYear: Wt, englishToNepali: Ee, nepaliToEnglish: ke }, Ut = "en", T = "ne", Jt = 207e5, Kt = 198e5, Ce = 5049018e5, $e = new Date(1986, 0, 1, 0, 15), pt = ["Baisakh", "Jestha", "Asar", "Shrawan", "Bhadra", "Aswin", "Kartik", "Mangsir", "Poush", "Magh", "Falgun", "Chaitra"], $t = ["Bai", "Jes", "Asa", "Shr", "Bhd", "Asw", "Kar", "Man", "Pou", "Mag", "Fal", "Cha"], Gt = ["बैशाख", "जेठ", "असार", "श्रावण", "भाद्र", "आश्विन", "कार्तिक", "मंसिर", "पौष", "माघ", "फाल्गुण", "चैत्र"], Ae = ["बै", "जे", "अ", "श्रा", "भा", "आ", "का", "मं", "पौ", "मा", "फा", "चै"], At = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"], vt = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], ve = ["जनवरी", "फेब्रुअरी", "मार्च", "अप्रिल", "मे", "जुन", "जुलाई", "अगस्ट", "सेप्टेम्बर", "अक्टोबर", "नोभेम्बर", "डिसेम्बर"], Fe = ["जन", "फेब", "मार", "अप्रि", "मे", "जुन", "जुला", "अग", "सेप", "अक्टो", "नोभे", "डिसे"], zt = ["०", "१", "२", "३", "४", "५", "६", "७", "८", "९"], et = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], St = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], Vt = ["आइत", "सोम", "मंगल", "बुध", "बिहि", "शुक्र", "शनि"], qt = ["आइतबार", "सोमबार", "मंगलबार", "बुधबार", "बिहिबार", "शुक्रबार", "शनिबार"], xe = /(\[[^\[]*\])|(\\)?([Hh]mm(ss)?|Mo|MM?M?M?|Do|DD?|ddd?d?|do?|YYYY|YY|y{2,4}|yo?|a|A|hh?|HH?|mm?|ss?|SSS|x|X|.)/g, Ne = (e) => {
|
|
41
|
+
const t = e.getTime(), n = t < Ce ? Kt : Jt, a = new Date(t + n), s = a.getUTCFullYear(), r = a.getUTCMonth(), o = a.getUTCDate(), i = a.getUTCHours(), u = a.getUTCMinutes(), h = a.getUTCSeconds(), c = a.getUTCMilliseconds(), f = a.getUTCDay();
|
|
42
|
+
return { year: s, month0: r, day: o, hour: i, minute: u, second: h, ms: c, weekDay: f };
|
|
43
|
+
}, Ht = (e, t, n, a, s, r, o) => {
|
|
44
|
+
const i = new Date(e, t, n, a, s, r, o);
|
|
45
|
+
let u = i < $e ? Kt : Jt;
|
|
46
|
+
const h = -1 * i.getTimezoneOffset() * 60 * 1e3;
|
|
47
|
+
return new Date(i.getTime() - u + h);
|
|
48
48
|
}, bt = (e) => {
|
|
49
|
-
const t = e.match(
|
|
49
|
+
const t = e.match(xe);
|
|
50
50
|
return t ? t.map((n) => n.startsWith("[") && n.endsWith("]") ? n.slice(1, -1) : n) : [];
|
|
51
|
-
},
|
|
51
|
+
}, R = (e) => {
|
|
52
52
|
if (e.length === 0) return new RegExp("");
|
|
53
53
|
let t = [...e];
|
|
54
54
|
if (t = t.sort((a, s) => s.length - a.length), t[0] === "") return new RegExp("");
|
|
55
55
|
const n = `(${t.join("|")})`;
|
|
56
56
|
return new RegExp(n);
|
|
57
|
-
},
|
|
57
|
+
}, x = (e) => e.toString().padStart(2, "0"), Xt = (e) => e.toString().padStart(3, "0"), He = (e) => e.split("").map((t) => zt[t.charCodeAt(0) - 48]).join(""), Y = (e, t) => {
|
|
58
58
|
const n = typeof e == "string" ? e : String(e);
|
|
59
|
-
return t !==
|
|
60
|
-
},
|
|
59
|
+
return t !== T ? n : He(n);
|
|
60
|
+
}, Oe = (e, t) => Y(e.getYear(), t).substring(2), Be = (e, t) => Y(e.getYear(), t), Te = (e, t) => Y(e.getEnglishYear(), t).substring(2), Ie = (e, t) => Y(e.getEnglishYear(), t), Le = (e, t) => Y(e.getMonth() + 1, t), Re = (e, t) => Y(x(e.getMonth() + 1), t), _e = (e, t) => t === T ? Ae[e.getMonth()] : $t[e.getMonth()], je = (e, t) => t === T ? Gt[e.getMonth()] : pt[e.getMonth()], Pe = (e, t) => Y(e.getEnglishMonth() + 1, t), We = (e, t) => Y(x(e.getEnglishMonth() + 1), t), Ue = (e, t) => t === T ? Fe[e.getEnglishMonth()] : vt[e.getEnglishMonth()], Je = (e, t) => t === T ? ve[e.getEnglishMonth()] : At[e.getEnglishMonth()], Ke = (e, t) => Y(e.getDate(), t), Ge = (e, t) => Y(x(e.getDate()), t), ze = (e, t) => Y(e.getEnglishDate(), t), Ve = (e, t) => Y(x(e.getEnglishDate()), t), Zt = (e, t) => Y(e.getDay(), t), ft = (e, t) => t === T ? Vt[e.getDay()] : et[e.getDay()], Qt = (e, t) => t === T ? qt[e.getDay()] : St[e.getDay()], te = (e, t) => Y(e.getHours(), t), ee = (e, t) => Y(x(e.getHours()), t), ne = (e, t) => {
|
|
61
61
|
const n = e.getHours(), a = n > 12 ? n - 12 : n;
|
|
62
|
-
return
|
|
62
|
+
return Y(a, t);
|
|
63
63
|
}, se = (e, t) => {
|
|
64
64
|
const n = e.getHours(), a = n > 12 ? n - 12 : n;
|
|
65
|
-
return
|
|
66
|
-
}, ae = (e, t) =>
|
|
67
|
-
const a = bt(t), s = (r) => r in
|
|
65
|
+
return Y(x(a), t);
|
|
66
|
+
}, ae = (e, t) => Y(e.getMinutes(), t), re = (e, t) => Y(x(e.getMinutes()), t), oe = (e, t) => Y(e.getSeconds(), t), ie = (e, t) => Y(x(e.getSeconds()), t), ue = (e, t) => Y(Xt(e.getMilliseconds()), t), ce = (e, t) => t === T ? e.getHours() >= 12 ? "पिम" : "एम" : e.getHours() >= 12 ? "PM" : "AM", he = (e, t) => t === T ? e.getHours() >= 12 ? "पिम" : "एम" : e.getHours() >= 12 ? "pm" : "am", Ot = { YY: Oe, YYYY: Be, M: Le, MM: Re, MMM: _e, MMMM: je, D: Ke, DD: Ge, d: Zt, dd: ft, ddd: ft, dddd: Qt, H: te, HH: ee, h: ne, hh: se, m: ae, mm: re, s: oe, ss: ie, SSS: ue, A: ce, a: he }, le = (e, t, n) => {
|
|
67
|
+
const a = bt(t), s = (r) => r in Ot ? Ot[r](e, n) : r;
|
|
68
68
|
return a.map(s).join("");
|
|
69
|
-
}, qe = (e, t) => le(e, t, Ut), Xe = (e, t) => le(e, t,
|
|
70
|
-
const t =
|
|
71
|
-
return `${t}-${n}-${a} ${s}:${r}:${o}${
|
|
72
|
-
},
|
|
73
|
-
const a = bt(t), s = (r) => r in
|
|
69
|
+
}, qe = (e, t) => le(e, t, Ut), Xe = (e, t) => le(e, t, T), Ze = (e) => {
|
|
70
|
+
const t = x(e.getYear()), n = x(e.getMonth() + 1), a = x(e.getDate()), s = x(e.getHours()), r = x(e.getMinutes()), o = x(e.getSeconds()), i = e.getMilliseconds(), u = i === 0 ? "" : `.${Xt(i)}`;
|
|
71
|
+
return `${t}-${n}-${a} ${s}:${r}:${o}${u}`;
|
|
72
|
+
}, Bt = { YY: Te, YYYY: Ie, M: Pe, MM: We, MMM: Ue, MMMM: Je, D: ze, DD: Ve, d: Zt, dd: ft, ddd: ft, dddd: Qt, H: te, HH: ee, h: ne, hh: se, m: ae, mm: re, s: oe, ss: ie, SSS: ue, A: ce, a: he }, de = (e, t, n) => {
|
|
73
|
+
const a = bt(t), s = (r) => r in Bt ? Bt[r](e, n) : r;
|
|
74
74
|
return a.map(s).join("");
|
|
75
|
-
}, Qe = (e, t) => de(e, t, Ut), t3 = (e, t) => de(e, t,
|
|
75
|
+
}, Qe = (e, t) => de(e, t, Ut), t3 = (e, t) => de(e, t, T);
|
|
76
76
|
function e3(e) {
|
|
77
77
|
const t = e.split(/[-./]/, 3), [n, a = 1, s = 1] = t.map((r) => {
|
|
78
78
|
const o = parseInt(r, 10);
|
|
@@ -83,149 +83,149 @@ function e3(e) {
|
|
|
83
83
|
}
|
|
84
84
|
function n3(e) {
|
|
85
85
|
if (!e) return [0, 0, 0, 0];
|
|
86
|
-
const [t, n = "0"] = e.split(".", 2), a = t.split(":", 3), [s, r = 0, o = 0] = a.map((
|
|
87
|
-
const h = parseInt(
|
|
86
|
+
const [t, n = "0"] = e.split(".", 2), a = t.split(":", 3), [s, r = 0, o = 0] = a.map((u) => {
|
|
87
|
+
const h = parseInt(u, 10);
|
|
88
88
|
if (Number.isNaN(h)) throw new Error("Invalid time");
|
|
89
89
|
return h;
|
|
90
90
|
});
|
|
91
|
-
let
|
|
92
|
-
return Number.isNaN(
|
|
91
|
+
let i = parseInt(n, 10);
|
|
92
|
+
return Number.isNaN(i) && (i = 0), [s, r, o, i];
|
|
93
93
|
}
|
|
94
94
|
function s3(e) {
|
|
95
|
-
const [t, n] = e.split(" ", 2), [a, s, r] = e3(t), [o,
|
|
96
|
-
return [a, s, r, o,
|
|
95
|
+
const [t, n] = e.split(" ", 2), [a, s, r] = e3(t), [o, i, u, h] = n3(n);
|
|
96
|
+
return [a, s, r, o, i, u, h];
|
|
97
97
|
}
|
|
98
|
-
const
|
|
98
|
+
const Tt = { YY: /(\d\d)/, YYYY: /(\d\d\d\d)/, M: /(1[0-2]|0[1-9]|[1-9])/, MM: /(1[0-2]|0[1-9]|[1-9])/, D: /(3[0-2]|[1-2]\d|0[1-9]|[1-9]| [1-9])/, DD: /(3[0-2]|[1-2]\d|0[1-9]|[1-9]| [1-9])/, H: /(2[0-3]|[0-1]\d|\d)/, HH: /(2[0-3]|[0-1]\d|\d)/, hh: /(1[0-2]|0[1-9]|[1-9])/, mm: /([0-5]\d|\d)/, ss: /([0-5]\d|\d)/, SSS: /(\d\d\d)/, A: /(AM|PM)/, a: /(am|pm)/, MMMM: R(pt), MMM: R($t), dddd: R(St), ddd: R(et), dd: R(et), d: /([0-6])/ };
|
|
99
99
|
function a3(e) {
|
|
100
100
|
const t = [], n = [];
|
|
101
|
-
for (const s of e) s in
|
|
101
|
+
for (const s of e) s in Tt ? (t.push(s), n.push(Tt[s].source)) : n.push(s.replace(/[-\/\\^$*+?.()|[\]{}]/g, "\\$&"));
|
|
102
102
|
const a = n.join("");
|
|
103
103
|
return { dateTokens: t, regex: new RegExp(`^${a}$`) };
|
|
104
104
|
}
|
|
105
105
|
function r3(e, t) {
|
|
106
|
-
let [n, a, s, r, o,
|
|
107
|
-
for (let
|
|
108
|
-
const
|
|
109
|
-
switch (
|
|
106
|
+
let [n, a, s, r, o, i, u, h] = [0, 1, 1, 0, 0, 0, 0, 0], c = !1, f = !1;
|
|
107
|
+
for (let l = 0; l < e.length; l++) {
|
|
108
|
+
const $ = e[l], D = parseInt(t[l + 1]);
|
|
109
|
+
switch ($) {
|
|
110
110
|
case "YYYY":
|
|
111
|
-
n =
|
|
111
|
+
n = D;
|
|
112
112
|
break;
|
|
113
113
|
case "YY":
|
|
114
|
-
n = 2e3 + parseInt(t[
|
|
114
|
+
n = 2e3 + parseInt(t[l]);
|
|
115
115
|
break;
|
|
116
116
|
case "MM":
|
|
117
117
|
case "M":
|
|
118
|
-
a =
|
|
118
|
+
a = D;
|
|
119
119
|
break;
|
|
120
120
|
case "MMMM":
|
|
121
|
-
a =
|
|
121
|
+
a = pt.indexOf(t[l + 1]) + 1;
|
|
122
122
|
break;
|
|
123
123
|
case "MMM":
|
|
124
|
-
a =
|
|
124
|
+
a = $t.indexOf(t[l + 1]) + 1;
|
|
125
125
|
break;
|
|
126
126
|
case "DD":
|
|
127
127
|
case "D":
|
|
128
|
-
s =
|
|
128
|
+
s = D;
|
|
129
129
|
break;
|
|
130
130
|
case "HH":
|
|
131
131
|
case "H":
|
|
132
|
-
r =
|
|
132
|
+
r = D;
|
|
133
133
|
break;
|
|
134
134
|
case "hh":
|
|
135
135
|
case "h":
|
|
136
|
-
o =
|
|
136
|
+
o = D, f = !0;
|
|
137
137
|
break;
|
|
138
138
|
case "mm":
|
|
139
139
|
case "m":
|
|
140
|
-
|
|
140
|
+
i = D;
|
|
141
141
|
break;
|
|
142
142
|
case "ss":
|
|
143
143
|
case "s":
|
|
144
|
-
|
|
144
|
+
u = D;
|
|
145
145
|
break;
|
|
146
146
|
case "SSS":
|
|
147
|
-
h =
|
|
147
|
+
h = D;
|
|
148
148
|
break;
|
|
149
149
|
case "A":
|
|
150
150
|
case "a":
|
|
151
|
-
c = t[
|
|
151
|
+
c = t[l + 1].toLowerCase() === "pm";
|
|
152
152
|
}
|
|
153
153
|
}
|
|
154
|
-
return
|
|
154
|
+
return f && (r = o + (c ? 12 : 0)), { year: n, month0: a - 1, day: s, hour: r, minute: i, second: u, ms: h };
|
|
155
155
|
}
|
|
156
156
|
function ge(e, t) {
|
|
157
157
|
const n = bt(t), { dateTokens: a, regex: s } = a3(n), r = RegExp(s).exec(e);
|
|
158
158
|
if (!r) throw new Error("Invalid date format");
|
|
159
|
-
const { year: o, month0:
|
|
160
|
-
return [o,
|
|
159
|
+
const { year: o, month0: i, day: u, hour: h, minute: c, second: f, ms: l } = r3(a, r);
|
|
160
|
+
return [o, i, u, h, c, f, l];
|
|
161
161
|
}
|
|
162
|
-
const
|
|
162
|
+
const It = { YY: /(\d\d)/, YYYY: /(\d\d\d\d)/, M: /(1[0-2]|0[1-9]|[1-9])/, MM: /(1[0-2]|0[1-9]|[1-9])/, D: /(3[0-2]|[1-2]\d|0[1-9]|[1-9]| [1-9])/, DD: /(3[0-2]|[1-2]\d|0[1-9]|[1-9]| [1-9])/, H: /(2[0-3]|[0-1]\d|\d)/, HH: /(2[0-3]|[0-1]\d|\d)/, hh: /(1[0-2]|0[1-9]|[1-9])/, mm: /([0-5]\d|\d)/, ss: /([0-5]\d|\d)/, SSS: /(\d\d\d)/, A: /(AM|PM)/, a: /(am|pm)/, MMMM: R(At), MMM: R(vt), dddd: R(St), ddd: R(et), dd: R(et), d: /([0-6])/ };
|
|
163
163
|
function o3(e) {
|
|
164
164
|
const t = [], n = [];
|
|
165
|
-
for (const s of e) s in
|
|
165
|
+
for (const s of e) s in It ? (t.push(s), n.push(It[s].source)) : n.push(s.replace(/[-\/\\^$*+?.()|[\]{}]/g, "\\$&"));
|
|
166
166
|
const a = n.join("");
|
|
167
167
|
return { dateTokens: t, regex: new RegExp(`^${a}$`) };
|
|
168
168
|
}
|
|
169
169
|
function i3(e, t) {
|
|
170
|
-
let [n, a, s, r, o,
|
|
171
|
-
for (let
|
|
172
|
-
const
|
|
173
|
-
switch (
|
|
170
|
+
let [n, a, s, r, o, i, u, h] = [0, 1, 1, 0, 0, 0, 0, 0], c = !1, f = !1;
|
|
171
|
+
for (let l = 0; l < e.length; l++) {
|
|
172
|
+
const $ = e[l], D = parseInt(t[l + 1]);
|
|
173
|
+
switch ($) {
|
|
174
174
|
case "YYYY":
|
|
175
|
-
n =
|
|
175
|
+
n = D;
|
|
176
176
|
break;
|
|
177
177
|
case "YY":
|
|
178
|
-
n = 2e3 + parseInt(t[
|
|
178
|
+
n = 2e3 + parseInt(t[l]);
|
|
179
179
|
break;
|
|
180
180
|
case "MM":
|
|
181
181
|
case "M":
|
|
182
|
-
a =
|
|
182
|
+
a = D;
|
|
183
183
|
break;
|
|
184
184
|
case "MMMM":
|
|
185
|
-
a = At.indexOf(t[
|
|
185
|
+
a = At.indexOf(t[l + 1]) + 1;
|
|
186
186
|
break;
|
|
187
187
|
case "MMM":
|
|
188
|
-
a = vt.indexOf(t[
|
|
188
|
+
a = vt.indexOf(t[l + 1]) + 1;
|
|
189
189
|
break;
|
|
190
190
|
case "DD":
|
|
191
191
|
case "D":
|
|
192
|
-
s =
|
|
192
|
+
s = D;
|
|
193
193
|
break;
|
|
194
194
|
case "HH":
|
|
195
195
|
case "H":
|
|
196
|
-
r =
|
|
196
|
+
r = D;
|
|
197
197
|
break;
|
|
198
198
|
case "hh":
|
|
199
199
|
case "h":
|
|
200
|
-
o =
|
|
200
|
+
o = D, f = !0;
|
|
201
201
|
break;
|
|
202
202
|
case "mm":
|
|
203
203
|
case "m":
|
|
204
|
-
|
|
204
|
+
i = D;
|
|
205
205
|
break;
|
|
206
206
|
case "ss":
|
|
207
207
|
case "s":
|
|
208
|
-
|
|
208
|
+
u = D;
|
|
209
209
|
break;
|
|
210
210
|
case "SSS":
|
|
211
|
-
h =
|
|
211
|
+
h = D;
|
|
212
212
|
break;
|
|
213
213
|
case "A":
|
|
214
214
|
case "a":
|
|
215
|
-
c = t[
|
|
215
|
+
c = t[l + 1].toLowerCase() === "pm";
|
|
216
216
|
}
|
|
217
217
|
}
|
|
218
|
-
return
|
|
218
|
+
return f && (r = o + (c ? 12 : 0)), { year: n, month0: a - 1, day: s, hour: r, minute: i, second: u, ms: h };
|
|
219
219
|
}
|
|
220
220
|
function u3(e, t) {
|
|
221
221
|
const n = bt(t), { dateTokens: a, regex: s } = o3(n), r = RegExp(s).exec(e);
|
|
222
222
|
if (!r) throw new Error("Invalid date format");
|
|
223
|
-
const { year: o, month0:
|
|
224
|
-
return [o,
|
|
223
|
+
const { year: o, month0: i, day: u, hour: h, minute: c, second: f, ms: l } = i3(a, r);
|
|
224
|
+
return [o, i, u, h, c, f, l];
|
|
225
225
|
}
|
|
226
226
|
function c3(e) {
|
|
227
227
|
const t = { एम: "AM", पिम: "PM" };
|
|
228
|
-
|
|
228
|
+
Gt.forEach((a, s) => t[a] = pt[s]), qt.forEach((a, s) => t[a] = St[s]), Vt.forEach((a, s) => t[a] = et[s]), zt.forEach((a, s) => t[a] = String(s));
|
|
229
229
|
const n = new RegExp(Object.keys(t).join("|"), "g");
|
|
230
230
|
return e.replace(n, (a) => t[a]);
|
|
231
231
|
}
|
|
@@ -233,23 +233,23 @@ function h3(e, t) {
|
|
|
233
233
|
const n = c3(e);
|
|
234
234
|
return ge(n, t);
|
|
235
235
|
}
|
|
236
|
-
class
|
|
236
|
+
class Et extends Error {
|
|
237
237
|
constructor(t) {
|
|
238
238
|
super(t), this.name = "ValidationError";
|
|
239
239
|
}
|
|
240
240
|
}
|
|
241
241
|
const l3 = (e) => {
|
|
242
|
-
if (e < 0 || e > 23) throw new
|
|
242
|
+
if (e < 0 || e > 23) throw new Et("Hour should be in the range 0-23");
|
|
243
243
|
}, d3 = (e) => {
|
|
244
|
-
if (e < 0 || e > 59) throw new
|
|
244
|
+
if (e < 0 || e > 59) throw new Et("Minute should be in the range 0-59");
|
|
245
245
|
}, g3 = (e) => {
|
|
246
|
-
if (e < 0 || e > 59) throw new
|
|
246
|
+
if (e < 0 || e > 59) throw new Et("Second should be in the range 0-59");
|
|
247
247
|
}, m3 = (e) => {
|
|
248
|
-
if (e < 0 || e > 999) throw new
|
|
248
|
+
if (e < 0 || e > 999) throw new Et("Millisecond should be in the range 0-999");
|
|
249
249
|
}, D3 = (e, t, n, a) => {
|
|
250
250
|
l3(e), d3(t), g3(n), m3(a);
|
|
251
251
|
};
|
|
252
|
-
class
|
|
252
|
+
class w {
|
|
253
253
|
timestamp;
|
|
254
254
|
year;
|
|
255
255
|
yearEn;
|
|
@@ -263,7 +263,7 @@ class Y {
|
|
|
263
263
|
constructor(...t) {
|
|
264
264
|
if (t.length === 0) this.initFromCurrentDate();
|
|
265
265
|
else if (t.length === 1 && t[0] instanceof Date) this.initFromEnglishDate(t[0]);
|
|
266
|
-
else if (t.length === 1 && t[0] instanceof
|
|
266
|
+
else if (t.length === 1 && t[0] instanceof w) this.initFromNepaliDate(t[0]);
|
|
267
267
|
else if (t.length === 1 && typeof t[0] == "string") this.parseFromString(t[0]);
|
|
268
268
|
else if (t.length === 1 && typeof t[0] == "number") this.initFromTimestamp(t[0]);
|
|
269
269
|
else if (t.length === 2 && typeof t[0] == "string" && typeof t[1] == "string") this.parseFromStringWithFormat(t[0], t[1]);
|
|
@@ -295,10 +295,10 @@ class Y {
|
|
|
295
295
|
}
|
|
296
296
|
_setDateObject(t, n = !0) {
|
|
297
297
|
this.timestamp = t;
|
|
298
|
-
const { year: a, month0: s, day: r, hour: o, minute:
|
|
299
|
-
if (this.yearEn = a, this.monthEn = s, this.dayEn = r, this.hour = o, this.minute =
|
|
300
|
-
const [h, c,
|
|
301
|
-
this.year = h, this.month = c, this.day =
|
|
298
|
+
const { year: a, month0: s, day: r, hour: o, minute: i, weekDay: u } = Ne(t);
|
|
299
|
+
if (this.yearEn = a, this.monthEn = s, this.dayEn = r, this.hour = o, this.minute = i, this.weekDay = u, n) {
|
|
300
|
+
const [h, c, f] = W.englishToNepali(a, s, r);
|
|
301
|
+
this.year = h, this.month = c, this.day = f;
|
|
302
302
|
}
|
|
303
303
|
}
|
|
304
304
|
getDateObject() {
|
|
@@ -364,10 +364,10 @@ class Y {
|
|
|
364
364
|
setTime(t) {
|
|
365
365
|
this._setDateObject(new Date(t));
|
|
366
366
|
}
|
|
367
|
-
set(t, n, a, s, r, o,
|
|
368
|
-
D3(s, r, o,
|
|
369
|
-
const [
|
|
370
|
-
this.year = t, this.month = n, this.day = a, this._setDateObject(
|
|
367
|
+
set(t, n, a, s, r, o, i) {
|
|
368
|
+
D3(s, r, o, i);
|
|
369
|
+
const [u, h, c] = W.nepaliToEnglish(t, n, a);
|
|
370
|
+
this.year = t, this.month = n, this.day = a, this._setDateObject(Ht(u, h, c, s, r, o, i), !1);
|
|
371
371
|
}
|
|
372
372
|
setDateObject(t) {
|
|
373
373
|
this._setDateObject(t, !0);
|
|
@@ -387,35 +387,35 @@ class Y {
|
|
|
387
387
|
formatEnglishDateInNepali(t) {
|
|
388
388
|
return t3(this, t);
|
|
389
389
|
}
|
|
390
|
-
static fromEnglishDate(t, n, a, s = 0, r = 0, o = 0,
|
|
391
|
-
const
|
|
392
|
-
return new
|
|
390
|
+
static fromEnglishDate(t, n, a, s = 0, r = 0, o = 0, i = 0) {
|
|
391
|
+
const u = Ht(t, n, a, s, r, o, i);
|
|
392
|
+
return new w(u);
|
|
393
393
|
}
|
|
394
394
|
static parseNepaliFormat(t, n) {
|
|
395
|
-
const [a, s, r, o,
|
|
396
|
-
return new
|
|
395
|
+
const [a, s, r, o, i, u, h] = h3(t, n);
|
|
396
|
+
return new w(a, s, r, o, i, u, h);
|
|
397
397
|
}
|
|
398
398
|
static parseEnglishDate(t, n) {
|
|
399
|
-
const [a, s, r, o,
|
|
400
|
-
return
|
|
399
|
+
const [a, s, r, o, i, u, h] = u3(t, n);
|
|
400
|
+
return w.fromEnglishDate(a, s, r, o, i, u, h);
|
|
401
401
|
}
|
|
402
402
|
static getDaysOfMonth(t, n) {
|
|
403
|
-
if (t <
|
|
403
|
+
if (t < W.npMinYear() || t > W.npMaxYear()) throw new Error("Year out of range");
|
|
404
404
|
if (n < 0 || n > 11) throw new Error("Month out of range");
|
|
405
|
-
return
|
|
405
|
+
return _[t - W.npMinYear()][0][n];
|
|
406
406
|
}
|
|
407
407
|
static minSupportedDate() {
|
|
408
|
-
return
|
|
408
|
+
return w.fromEnglishDate(W.enMinYear(), 0, 1).getDateObject();
|
|
409
409
|
}
|
|
410
410
|
static maxSupportedDate() {
|
|
411
|
-
return
|
|
411
|
+
return w.fromEnglishDate(W.enMaxYear(), 11, 31).getDateObject();
|
|
412
412
|
}
|
|
413
413
|
static minSupportedNepaliDate() {
|
|
414
|
-
return new
|
|
414
|
+
return new w(W.npMinYear(), 0, 1);
|
|
415
415
|
}
|
|
416
416
|
static maxSupportedNepaliDate() {
|
|
417
|
-
const t =
|
|
418
|
-
return new
|
|
417
|
+
const t = W.npMaxYear();
|
|
418
|
+
return new w(t, 11, this.getDaysOfMonth(t, 11));
|
|
419
419
|
}
|
|
420
420
|
static minimum() {
|
|
421
421
|
return console.warn("`NepaliDate.minimum()` is deprecated and will be removed in a future version. Please use `NepaliDate.minSupportedDate()` instead."), this.minSupportedDate();
|
|
@@ -463,7 +463,7 @@ const y3 = [
|
|
|
463
463
|
"October",
|
|
464
464
|
"November",
|
|
465
465
|
"December"
|
|
466
|
-
], M3 = ["आइत", "सोम", "मंगल", "बुध", "बिहि", "शुक्र", "शनि"], p3 = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
|
|
466
|
+
], M3 = ["आइत", "सोम", "मंगल", "बुध", "बिहि", "शुक्र", "शनि"], p3 = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], S3 = ["०", "१", "२", "३", "४", "५", "६", "७", "८", "९"], N3 = {
|
|
467
467
|
light: {
|
|
468
468
|
primary: "#3b82f6",
|
|
469
469
|
background: "#ffffff",
|
|
@@ -484,19 +484,19 @@ const y3 = [
|
|
|
484
484
|
today: "#1e40af",
|
|
485
485
|
disabled: "#6b7280"
|
|
486
486
|
}
|
|
487
|
-
},
|
|
487
|
+
}, U = (e) => e.toString().split("").map((t) => S3[parseInt(t)]).join(""), De = (e, t, n) => {
|
|
488
488
|
if (e === "BS")
|
|
489
489
|
try {
|
|
490
|
-
const a = n === 11 ? new
|
|
491
|
-
return new
|
|
490
|
+
const a = n === 11 ? new w(t + 1, 0, 1) : new w(t, n + 1, 1);
|
|
491
|
+
return new w(a.getTime() - 1440 * 60 * 1e3).getDate();
|
|
492
492
|
} catch {
|
|
493
493
|
return 30;
|
|
494
494
|
}
|
|
495
495
|
return new Date(t, n + 1, 0).getDate();
|
|
496
|
-
},
|
|
496
|
+
}, b3 = (e, t, n) => {
|
|
497
497
|
if (e === "BS")
|
|
498
498
|
try {
|
|
499
|
-
return new
|
|
499
|
+
return new w(t, n, 1).getDay() || 0;
|
|
500
500
|
} catch {
|
|
501
501
|
return 0;
|
|
502
502
|
}
|
|
@@ -505,30 +505,22 @@ const y3 = [
|
|
|
505
505
|
const t = /* @__PURE__ */ new Date();
|
|
506
506
|
if (e === "BS")
|
|
507
507
|
try {
|
|
508
|
-
const n =
|
|
508
|
+
const n = w.fromEnglishDate(t.getFullYear(), t.getMonth(), t.getDate());
|
|
509
509
|
return { year: n.getYear(), month: n.getMonth(), day: n.getDate() };
|
|
510
510
|
} catch {
|
|
511
511
|
return { year: 2081, month: 0, day: 1 };
|
|
512
512
|
}
|
|
513
513
|
return { year: t.getFullYear(), month: t.getMonth(), day: t.getDate() };
|
|
514
|
-
},
|
|
514
|
+
}, kt = (e, t, n, a, s) => {
|
|
515
515
|
if (e === "BS")
|
|
516
516
|
try {
|
|
517
|
-
const r = new
|
|
518
|
-
r.getEnglishYear(),
|
|
519
|
-
r.getEnglishMonth(),
|
|
520
|
-
r.getEnglishDate()
|
|
521
|
-
).toISOString().split("T")[0];
|
|
517
|
+
const r = new w(t, n, a), o = r.getEnglishYear(), i = r.getEnglishMonth(), u = r.getEnglishDate(), h = `${o}-${String(i + 1).padStart(2, "0")}-${String(u).padStart(2, "0")}`;
|
|
522
518
|
return {
|
|
523
519
|
bs: `${t}-${String(n + 1).padStart(2, "0")}-${String(a).padStart(2, "0")}`,
|
|
524
|
-
ad:
|
|
520
|
+
ad: h,
|
|
525
521
|
formatted: {
|
|
526
522
|
bs: `${s[n]} ${a}, ${t}`,
|
|
527
|
-
ad: new Date(
|
|
528
|
-
r.getEnglishYear(),
|
|
529
|
-
r.getEnglishMonth(),
|
|
530
|
-
r.getEnglishDate()
|
|
531
|
-
).toLocaleDateString("en-US", { year: "numeric", month: "long", day: "numeric" })
|
|
523
|
+
ad: new Date(o, i, u).toLocaleDateString("en-US", { year: "numeric", month: "long", day: "numeric" })
|
|
532
524
|
}
|
|
533
525
|
};
|
|
534
526
|
} catch {
|
|
@@ -543,119 +535,120 @@ const y3 = [
|
|
|
543
535
|
};
|
|
544
536
|
}
|
|
545
537
|
else {
|
|
546
|
-
const r =
|
|
538
|
+
const r = `${t}-${String(n + 1).padStart(2, "0")}-${String(a).padStart(2, "0")}`, o = new Date(t, n, a);
|
|
547
539
|
try {
|
|
548
|
-
const
|
|
540
|
+
const i = w.fromEnglishDate(t, n, a), u = `${i.getYear()}-${String(i.getMonth() + 1).padStart(2, "0")}-${String(i.getDate()).padStart(2, "0")}`;
|
|
549
541
|
return {
|
|
550
|
-
ad:
|
|
551
|
-
bs:
|
|
542
|
+
ad: r,
|
|
543
|
+
bs: u,
|
|
552
544
|
formatted: {
|
|
553
|
-
ad:
|
|
545
|
+
ad: o.toLocaleDateString("en-US", {
|
|
554
546
|
year: "numeric",
|
|
555
547
|
month: "long",
|
|
556
548
|
day: "numeric"
|
|
557
549
|
}),
|
|
558
|
-
bs: `${me[
|
|
550
|
+
bs: `${me[i.getMonth()]} ${i.getDate()}, ${i.getYear()}`
|
|
559
551
|
}
|
|
560
552
|
};
|
|
561
553
|
} catch {
|
|
562
554
|
return {
|
|
563
|
-
ad:
|
|
564
|
-
bs:
|
|
555
|
+
ad: r,
|
|
556
|
+
bs: r,
|
|
565
557
|
formatted: {
|
|
566
|
-
ad:
|
|
558
|
+
ad: o.toLocaleDateString("en-US", {
|
|
567
559
|
year: "numeric",
|
|
568
560
|
month: "long",
|
|
569
561
|
day: "numeric"
|
|
570
562
|
}),
|
|
571
|
-
bs:
|
|
563
|
+
bs: o.toLocaleDateString("en-US", { year: "numeric", month: "long", day: "numeric" })
|
|
572
564
|
}
|
|
573
565
|
};
|
|
574
566
|
}
|
|
575
567
|
}
|
|
576
|
-
},
|
|
568
|
+
}, H3 = (e, t, n) => {
|
|
577
569
|
const a = new Date(e.year, e.month, e.day).getTime(), s = new Date(t.year, t.month, t.day).getTime(), r = new Date(n.year, n.month, n.day).getTime();
|
|
578
570
|
return a >= s && a <= r;
|
|
579
|
-
},
|
|
571
|
+
}, Mt = (e) => {
|
|
580
572
|
try {
|
|
581
573
|
const [t, n, a] = e.split("-").map(Number);
|
|
582
574
|
return !t || !n || !a ? null : { year: t, month: n - 1, day: a };
|
|
583
575
|
} catch {
|
|
584
576
|
return null;
|
|
585
577
|
}
|
|
586
|
-
},
|
|
578
|
+
}, nt = (e, t, n) => {
|
|
587
579
|
if (!t && !n) return !1;
|
|
588
580
|
const a = new Date(e.year, e.month, e.day).getTime();
|
|
589
581
|
if (t) {
|
|
590
|
-
const s =
|
|
582
|
+
const s = Mt(t);
|
|
591
583
|
if (s) {
|
|
592
584
|
const r = new Date(s.year, s.month, s.day).getTime();
|
|
593
585
|
if (a < r) return !0;
|
|
594
586
|
}
|
|
595
587
|
}
|
|
596
588
|
if (n) {
|
|
597
|
-
const s =
|
|
589
|
+
const s = Mt(n);
|
|
598
590
|
if (s) {
|
|
599
591
|
const r = new Date(s.year, s.month, s.day).getTime();
|
|
600
592
|
if (a > r) return !0;
|
|
601
593
|
}
|
|
602
594
|
}
|
|
603
595
|
return !1;
|
|
604
|
-
}, E3 = (e = "AD") => {
|
|
605
|
-
const
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
596
|
+
}, E3 = (e = "AD", t) => {
|
|
597
|
+
const n = mt(() => N(e), [e]), a = mt(() => t ? Mt(t) : null, [t]), [s, r] = H(a?.year ?? n.year), [o, i] = H(a?.month ?? n.month), [u, h] = H(a), [c, f] = H(null), [l, $] = H(null);
|
|
598
|
+
Dt(() => {
|
|
599
|
+
const M = t ? Mt(t) : null;
|
|
600
|
+
M ? (r(M.year), i(M.month)) : (r(n.year), i(n.month));
|
|
601
|
+
}, [e]);
|
|
602
|
+
const D = mt(() => {
|
|
603
|
+
const M = De(e, s, o), B = b3(e, s, o), k = [];
|
|
604
|
+
for (let b = 0; b < B; b++)
|
|
605
|
+
k.push(null);
|
|
606
|
+
for (let b = 1; b <= M; b++)
|
|
607
|
+
k.push(b);
|
|
608
|
+
return k;
|
|
609
|
+
}, [s, o, e]);
|
|
617
610
|
return {
|
|
618
611
|
// State
|
|
619
|
-
currentYear:
|
|
620
|
-
currentMonth:
|
|
621
|
-
selectedDate:
|
|
622
|
-
rangeStart:
|
|
623
|
-
rangeEnd:
|
|
624
|
-
today:
|
|
625
|
-
calendarDays:
|
|
612
|
+
currentYear: s,
|
|
613
|
+
currentMonth: o,
|
|
614
|
+
selectedDate: u,
|
|
615
|
+
rangeStart: c,
|
|
616
|
+
rangeEnd: l,
|
|
617
|
+
today: n,
|
|
618
|
+
calendarDays: D,
|
|
626
619
|
// Actions
|
|
627
|
-
setCurrentYear:
|
|
628
|
-
setCurrentMonth:
|
|
629
|
-
setSelectedDate:
|
|
630
|
-
setRangeStart:
|
|
631
|
-
setRangeEnd:
|
|
632
|
-
navigateMonth: (
|
|
633
|
-
let
|
|
634
|
-
for (;
|
|
635
|
-
|
|
636
|
-
for (;
|
|
637
|
-
|
|
638
|
-
|
|
620
|
+
setCurrentYear: r,
|
|
621
|
+
setCurrentMonth: i,
|
|
622
|
+
setSelectedDate: h,
|
|
623
|
+
setRangeStart: f,
|
|
624
|
+
setRangeEnd: $,
|
|
625
|
+
navigateMonth: (M) => {
|
|
626
|
+
let k = o + M, b = s;
|
|
627
|
+
for (; k > 11; )
|
|
628
|
+
k -= 12, b += 1;
|
|
629
|
+
for (; k < 0; )
|
|
630
|
+
k += 12, b -= 1;
|
|
631
|
+
i(k), r(b);
|
|
639
632
|
},
|
|
640
633
|
// Helpers
|
|
641
|
-
isToday: (
|
|
642
|
-
isSelected: (
|
|
643
|
-
isInRange: (
|
|
644
|
-
if (!
|
|
645
|
-
const
|
|
646
|
-
return
|
|
634
|
+
isToday: (M) => s === n.year && o === n.month && M === n.day,
|
|
635
|
+
isSelected: (M, B = "single") => B === "range" ? !!(c && c.year === s && c.month === o && c.day === M) || !!(l && l.year === s && l.month === o && l.day === M) : !!(u && u.year === s && u.month === o && u.day === M),
|
|
636
|
+
isInRange: (M) => {
|
|
637
|
+
if (!c || !l) return !1;
|
|
638
|
+
const B = new Date(s, o, M).getTime(), k = new Date(c.year, c.month, c.day).getTime(), b = new Date(l.year, l.month, l.day).getTime();
|
|
639
|
+
return B >= k && B <= b;
|
|
647
640
|
}
|
|
648
641
|
};
|
|
649
|
-
},
|
|
642
|
+
}, Q = (e, t, n) => {
|
|
650
643
|
if (n === "BS")
|
|
651
644
|
try {
|
|
652
|
-
const a = new
|
|
645
|
+
const a = new w(e.year, e.month, e.day), s = new Date(
|
|
653
646
|
a.getEnglishYear(),
|
|
654
647
|
a.getEnglishMonth(),
|
|
655
648
|
a.getEnglishDate()
|
|
656
649
|
);
|
|
657
650
|
s.setDate(s.getDate() + t);
|
|
658
|
-
const r =
|
|
651
|
+
const r = w.fromEnglishDate(
|
|
659
652
|
s.getFullYear(),
|
|
660
653
|
s.getMonth(),
|
|
661
654
|
s.getDate()
|
|
@@ -668,7 +661,7 @@ const y3 = [
|
|
|
668
661
|
const a = new Date(e.year, e.month, e.day);
|
|
669
662
|
return a.setDate(a.getDate() + t), { year: a.getFullYear(), month: a.getMonth(), day: a.getDate() };
|
|
670
663
|
}
|
|
671
|
-
},
|
|
664
|
+
}, ht = (e, t, n) => {
|
|
672
665
|
if (n === "BS")
|
|
673
666
|
try {
|
|
674
667
|
let a = e.year, s = e.month + t;
|
|
@@ -685,11 +678,11 @@ const y3 = [
|
|
|
685
678
|
const a = new Date(e.year, e.month, e.day);
|
|
686
679
|
return a.setMonth(a.getMonth() + t), { year: a.getFullYear(), month: a.getMonth(), day: a.getDate() };
|
|
687
680
|
}
|
|
688
|
-
},
|
|
681
|
+
}, V = (e) => ({ year: e.year, month: e.month, day: 1 }), w3 = (e, t) => {
|
|
689
682
|
if (t === "BS")
|
|
690
683
|
try {
|
|
691
|
-
const a = new
|
|
692
|
-
return
|
|
684
|
+
const a = new w(e.year, e.month, e.day).getDay();
|
|
685
|
+
return Q(e, -a, "BS");
|
|
693
686
|
} catch {
|
|
694
687
|
return e;
|
|
695
688
|
}
|
|
@@ -697,7 +690,7 @@ const y3 = [
|
|
|
697
690
|
const n = new Date(e.year, e.month, e.day), a = n.getDay();
|
|
698
691
|
return n.setDate(n.getDate() - a), { year: n.getFullYear(), month: n.getMonth(), day: n.getDate() };
|
|
699
692
|
}
|
|
700
|
-
},
|
|
693
|
+
}, O3 = {
|
|
701
694
|
TODAY: "today",
|
|
702
695
|
YESTERDAY: "yesterday",
|
|
703
696
|
THIS_WEEK: "thisWeek",
|
|
@@ -724,7 +717,7 @@ const y3 = [
|
|
|
724
717
|
key: "yesterday",
|
|
725
718
|
label: "Yesterday",
|
|
726
719
|
getValue: (s) => {
|
|
727
|
-
const r = N(s), o =
|
|
720
|
+
const r = N(s), o = Q(r, -1, s);
|
|
728
721
|
return { start: o, end: o };
|
|
729
722
|
}
|
|
730
723
|
},
|
|
@@ -741,7 +734,7 @@ const y3 = [
|
|
|
741
734
|
label: "Last 7 Days",
|
|
742
735
|
getValue: (s) => {
|
|
743
736
|
const r = N(s);
|
|
744
|
-
return { start:
|
|
737
|
+
return { start: Q(r, -6, s), end: r };
|
|
745
738
|
}
|
|
746
739
|
},
|
|
747
740
|
{
|
|
@@ -749,7 +742,7 @@ const y3 = [
|
|
|
749
742
|
label: "Last 30 Days",
|
|
750
743
|
getValue: (s) => {
|
|
751
744
|
const r = N(s);
|
|
752
|
-
return { start:
|
|
745
|
+
return { start: Q(r, -29, s), end: r };
|
|
753
746
|
}
|
|
754
747
|
},
|
|
755
748
|
{
|
|
@@ -757,31 +750,31 @@ const y3 = [
|
|
|
757
750
|
label: "This Month",
|
|
758
751
|
getValue: (s) => {
|
|
759
752
|
const r = N(s);
|
|
760
|
-
return { start:
|
|
753
|
+
return { start: V(r), end: r };
|
|
761
754
|
}
|
|
762
755
|
},
|
|
763
756
|
{
|
|
764
757
|
key: "lastMonth",
|
|
765
758
|
label: "Last Month",
|
|
766
759
|
getValue: (s) => {
|
|
767
|
-
const r = N(s), o =
|
|
768
|
-
return { start:
|
|
760
|
+
const r = N(s), o = Q(V(r), -1, s);
|
|
761
|
+
return { start: V(o), end: o };
|
|
769
762
|
}
|
|
770
763
|
},
|
|
771
764
|
{
|
|
772
765
|
key: "last3months",
|
|
773
766
|
label: "Last 3 Months",
|
|
774
767
|
getValue: (s) => {
|
|
775
|
-
const r = N(s), o =
|
|
776
|
-
return { start:
|
|
768
|
+
const r = N(s), o = ht(r, -2, s);
|
|
769
|
+
return { start: V(o), end: r };
|
|
777
770
|
}
|
|
778
771
|
},
|
|
779
772
|
{
|
|
780
773
|
key: "last6months",
|
|
781
774
|
label: "Last 6 Months",
|
|
782
775
|
getValue: (s) => {
|
|
783
|
-
const r = N(s), o =
|
|
784
|
-
return { start:
|
|
776
|
+
const r = N(s), o = ht(r, -5, s);
|
|
777
|
+
return { start: V(o), end: r };
|
|
785
778
|
}
|
|
786
779
|
},
|
|
787
780
|
{
|
|
@@ -789,23 +782,23 @@ const y3 = [
|
|
|
789
782
|
label: "Last 180 Days",
|
|
790
783
|
getValue: (s) => {
|
|
791
784
|
const r = N(s);
|
|
792
|
-
return { start:
|
|
785
|
+
return { start: Q(r, -179, s), end: r };
|
|
793
786
|
}
|
|
794
787
|
},
|
|
795
788
|
{
|
|
796
789
|
key: "last9months",
|
|
797
790
|
label: "Last 9 Months",
|
|
798
791
|
getValue: (s) => {
|
|
799
|
-
const r = N(s), o =
|
|
800
|
-
return { start:
|
|
792
|
+
const r = N(s), o = ht(r, -8, s);
|
|
793
|
+
return { start: V(o), end: r };
|
|
801
794
|
}
|
|
802
795
|
},
|
|
803
796
|
{
|
|
804
797
|
key: "lastYear",
|
|
805
798
|
label: "Last Year",
|
|
806
799
|
getValue: (s) => {
|
|
807
|
-
const r = N(s), o =
|
|
808
|
-
return { start:
|
|
800
|
+
const r = N(s), o = ht(r, -11, s);
|
|
801
|
+
return { start: V(o), end: r };
|
|
809
802
|
}
|
|
810
803
|
}
|
|
811
804
|
], a = e ? n.filter((s) => e.includes(s.key)) : n;
|
|
@@ -818,59 +811,59 @@ const y3 = [
|
|
|
818
811
|
onMonthChange: s,
|
|
819
812
|
onClose: r,
|
|
820
813
|
showNepaliNumbers: o = !1,
|
|
821
|
-
convertToNepaliNumber:
|
|
822
|
-
calendarType:
|
|
814
|
+
convertToNepaliNumber: i = (h) => h.toString(),
|
|
815
|
+
calendarType: u
|
|
823
816
|
}) => {
|
|
824
|
-
const [h, c] =
|
|
825
|
-
return /* @__PURE__ */
|
|
826
|
-
/* @__PURE__ */
|
|
817
|
+
const [h, c] = H(Math.floor(e / 12) * 12), f = u === "BS" ? 2e3 : 1944, l = u === "BS" ? 2100 : 2043;
|
|
818
|
+
return /* @__PURE__ */ C("div", { className: "bsac-picker-inline", onClick: ($) => $.stopPropagation(), children: [
|
|
819
|
+
/* @__PURE__ */ C("div", { className: "bsac-picker-header", children: [
|
|
827
820
|
/* @__PURE__ */ g("h3", { children: "Select Month & Year" }),
|
|
828
821
|
/* @__PURE__ */ g("button", { className: "bsac-close-btn", onClick: r, children: "×" })
|
|
829
822
|
] }),
|
|
830
|
-
/* @__PURE__ */
|
|
831
|
-
/* @__PURE__ */
|
|
832
|
-
/* @__PURE__ */
|
|
823
|
+
/* @__PURE__ */ C("div", { className: "bsac-picker-body", children: [
|
|
824
|
+
/* @__PURE__ */ C("div", { className: "bsac-picker-section", children: [
|
|
825
|
+
/* @__PURE__ */ C("div", { className: "bsac-picker-section-header", children: [
|
|
833
826
|
/* @__PURE__ */ g("label", { children: "Year" }),
|
|
834
|
-
/* @__PURE__ */
|
|
835
|
-
/* @__PURE__ */ g("button", { onClick: () => c(Math.max(
|
|
836
|
-
/* @__PURE__ */
|
|
837
|
-
o ?
|
|
827
|
+
/* @__PURE__ */ C("div", { className: "bsac-year-nav", children: [
|
|
828
|
+
/* @__PURE__ */ g("button", { onClick: () => c(Math.max(f, h - 12)), disabled: h <= f, children: "«" }),
|
|
829
|
+
/* @__PURE__ */ C("span", { children: [
|
|
830
|
+
o ? i(h) : h,
|
|
838
831
|
" – ",
|
|
839
|
-
o ?
|
|
832
|
+
o ? i(h + 11) : h + 11
|
|
840
833
|
] }),
|
|
841
|
-
/* @__PURE__ */ g("button", { onClick: () => c(Math.min(
|
|
834
|
+
/* @__PURE__ */ g("button", { onClick: () => c(Math.min(l - 11, h + 12)), disabled: h + 11 >= l, children: "»" })
|
|
842
835
|
] })
|
|
843
836
|
] }),
|
|
844
|
-
/* @__PURE__ */ g("div", { className: "bsac-year-grid", children: Array.from({ length: 12 }, (
|
|
845
|
-
const
|
|
846
|
-
return
|
|
837
|
+
/* @__PURE__ */ g("div", { className: "bsac-year-grid", children: Array.from({ length: 12 }, ($, D) => {
|
|
838
|
+
const F = h + D;
|
|
839
|
+
return F > l ? null : /* @__PURE__ */ g(
|
|
847
840
|
"button",
|
|
848
841
|
{
|
|
849
|
-
onClick: () => a(
|
|
850
|
-
className:
|
|
851
|
-
children: o ?
|
|
842
|
+
onClick: () => a(F),
|
|
843
|
+
className: F === e ? "bsac-selected" : "",
|
|
844
|
+
children: o ? i(F) : F
|
|
852
845
|
},
|
|
853
|
-
|
|
846
|
+
F
|
|
854
847
|
);
|
|
855
848
|
}) })
|
|
856
849
|
] }),
|
|
857
|
-
/* @__PURE__ */
|
|
850
|
+
/* @__PURE__ */ C("div", { className: "bsac-picker-section", children: [
|
|
858
851
|
/* @__PURE__ */ g("label", { children: "Month" }),
|
|
859
|
-
/* @__PURE__ */ g("div", { className: "bsac-month-grid", children: n.map((
|
|
852
|
+
/* @__PURE__ */ g("div", { className: "bsac-month-grid", children: n.map(($, D) => /* @__PURE__ */ g(
|
|
860
853
|
"button",
|
|
861
854
|
{
|
|
862
855
|
onClick: () => {
|
|
863
|
-
s(
|
|
856
|
+
s(D), r();
|
|
864
857
|
},
|
|
865
|
-
className:
|
|
866
|
-
children:
|
|
858
|
+
className: D === t ? "bsac-selected" : "",
|
|
859
|
+
children: $
|
|
867
860
|
},
|
|
868
|
-
|
|
861
|
+
D
|
|
869
862
|
)) })
|
|
870
863
|
] })
|
|
871
864
|
] })
|
|
872
|
-
] })
|
|
873
|
-
},
|
|
865
|
+
] });
|
|
866
|
+
}, lt = ({
|
|
874
867
|
currentMonth: e,
|
|
875
868
|
currentYear: t,
|
|
876
869
|
months: n,
|
|
@@ -878,18 +871,18 @@ const y3 = [
|
|
|
878
871
|
onYearChange: s,
|
|
879
872
|
onMonthChange: r,
|
|
880
873
|
disabled: o = !1,
|
|
881
|
-
showNepaliNumbers:
|
|
882
|
-
convertToNepaliNumber:
|
|
874
|
+
showNepaliNumbers: i = !1,
|
|
875
|
+
convertToNepaliNumber: u,
|
|
883
876
|
calendarType: h
|
|
884
877
|
}) => {
|
|
885
|
-
const [c,
|
|
886
|
-
return /* @__PURE__ */
|
|
878
|
+
const [c, f] = H(!1);
|
|
879
|
+
return /* @__PURE__ */ C("div", { className: "bsac-header", children: [
|
|
887
880
|
/* @__PURE__ */ g("button", { className: "bsac-nav-btn", onClick: () => a(-12), disabled: o, "aria-label": "Previous year", children: "«" }),
|
|
888
881
|
/* @__PURE__ */ g("button", { className: "bsac-nav-btn", onClick: () => a(-1), disabled: o, "aria-label": "Previous month", children: "‹" }),
|
|
889
|
-
/* @__PURE__ */
|
|
882
|
+
/* @__PURE__ */ C("button", { className: "bsac-month-year-btn", onClick: () => f(!0), disabled: o, children: [
|
|
890
883
|
n[e],
|
|
891
884
|
" ",
|
|
892
|
-
|
|
885
|
+
i ? u(t) : t
|
|
893
886
|
] }),
|
|
894
887
|
/* @__PURE__ */ g("button", { className: "bsac-nav-btn", onClick: () => a(1), disabled: o, "aria-label": "Next month", children: "›" }),
|
|
895
888
|
/* @__PURE__ */ g("button", { className: "bsac-nav-btn", onClick: () => a(12), disabled: o, "aria-label": "Next year", children: "»" }),
|
|
@@ -901,14 +894,14 @@ const y3 = [
|
|
|
901
894
|
months: n,
|
|
902
895
|
onYearChange: s,
|
|
903
896
|
onMonthChange: r,
|
|
904
|
-
onClose: () =>
|
|
905
|
-
showNepaliNumbers:
|
|
906
|
-
convertToNepaliNumber:
|
|
897
|
+
onClose: () => f(!1),
|
|
898
|
+
showNepaliNumbers: i,
|
|
899
|
+
convertToNepaliNumber: u,
|
|
907
900
|
calendarType: h
|
|
908
901
|
}
|
|
909
902
|
)
|
|
910
903
|
] });
|
|
911
|
-
},
|
|
904
|
+
}, dt = ({
|
|
912
905
|
calendarDays: e,
|
|
913
906
|
days: t,
|
|
914
907
|
onDateSelect: n,
|
|
@@ -916,27 +909,27 @@ const y3 = [
|
|
|
916
909
|
isInRange: s,
|
|
917
910
|
isToday: r,
|
|
918
911
|
isDisabled: o,
|
|
919
|
-
disabled:
|
|
920
|
-
showNepaliNumbers:
|
|
912
|
+
disabled: i = !1,
|
|
913
|
+
showNepaliNumbers: u = !1,
|
|
921
914
|
convertToNepaliNumber: h
|
|
922
|
-
}) => /* @__PURE__ */
|
|
915
|
+
}) => /* @__PURE__ */ C("div", { className: "bsac-grid", children: [
|
|
923
916
|
t.map((c) => /* @__PURE__ */ g("div", { className: "bsac-day-header", children: c }, c)),
|
|
924
|
-
e.map((c,
|
|
925
|
-
const
|
|
917
|
+
e.map((c, f) => {
|
|
918
|
+
const l = c ? o?.(c) || i : !1, $ = c ? a(c) : !1, D = c ? s(c) : !1, F = c ? r(c) : !1, I = [
|
|
926
919
|
"bsac-day",
|
|
927
|
-
c ?
|
|
920
|
+
c ? l ? "bsac-day-disabled" : $ ? "bsac-day-selected" : D ? "bsac-day-in-range" : F ? "bsac-day-today" : "" : "bsac-day-empty"
|
|
928
921
|
].filter(Boolean).join(" ");
|
|
929
922
|
return /* @__PURE__ */ g(
|
|
930
923
|
"div",
|
|
931
924
|
{
|
|
932
|
-
className:
|
|
933
|
-
onClick: () => c && !
|
|
934
|
-
children: c ?
|
|
925
|
+
className: I,
|
|
926
|
+
onClick: () => c && !l && n(c),
|
|
927
|
+
children: c ? u ? h(c) : c : ""
|
|
935
928
|
},
|
|
936
|
-
|
|
929
|
+
f
|
|
937
930
|
);
|
|
938
931
|
})
|
|
939
|
-
] }),
|
|
932
|
+
] }), gt = ({
|
|
940
933
|
presets: e,
|
|
941
934
|
calendarType: t,
|
|
942
935
|
onPresetSelect: n,
|
|
@@ -944,8 +937,8 @@ const y3 = [
|
|
|
944
937
|
position: s = "top"
|
|
945
938
|
}) => {
|
|
946
939
|
const r = (o) => {
|
|
947
|
-
const
|
|
948
|
-
n(o,
|
|
940
|
+
const i = o.getValue(t);
|
|
941
|
+
n(o, i);
|
|
949
942
|
};
|
|
950
943
|
return /* @__PURE__ */ g("div", { className: `bsac-presets bsac-presets--${s}`, children: e.map((o) => /* @__PURE__ */ g(
|
|
951
944
|
"button",
|
|
@@ -964,290 +957,290 @@ const y3 = [
|
|
|
964
957
|
showToday: s = !0,
|
|
965
958
|
disabled: r = !1,
|
|
966
959
|
outputFormat: o = "both",
|
|
967
|
-
onDateSelect:
|
|
968
|
-
mode:
|
|
960
|
+
onDateSelect: i,
|
|
961
|
+
mode: u = "single",
|
|
969
962
|
onRangeSelect: h,
|
|
970
963
|
showRangePresets: c = !1,
|
|
971
|
-
rangePresetsPosition:
|
|
972
|
-
predefinedRanges:
|
|
973
|
-
presetKeys:
|
|
974
|
-
presetLabels:
|
|
975
|
-
onPresetSelect:
|
|
976
|
-
renderPresets:
|
|
977
|
-
showNepaliMonths:
|
|
978
|
-
showNepaliDays:
|
|
979
|
-
showNepaliNumbers:
|
|
980
|
-
theme:
|
|
981
|
-
colors:
|
|
982
|
-
minDate:
|
|
983
|
-
maxDate:
|
|
964
|
+
rangePresetsPosition: f = "top",
|
|
965
|
+
predefinedRanges: l,
|
|
966
|
+
presetKeys: $,
|
|
967
|
+
presetLabels: D,
|
|
968
|
+
onPresetSelect: F,
|
|
969
|
+
renderPresets: I,
|
|
970
|
+
showNepaliMonths: st = !1,
|
|
971
|
+
showNepaliDays: q = !1,
|
|
972
|
+
showNepaliNumbers: M = !1,
|
|
973
|
+
theme: B = "light",
|
|
974
|
+
colors: k,
|
|
975
|
+
minDate: b,
|
|
976
|
+
maxDate: J
|
|
984
977
|
}) => {
|
|
985
978
|
const {
|
|
986
|
-
currentYear:
|
|
987
|
-
currentMonth:
|
|
988
|
-
rangeStart:
|
|
989
|
-
rangeEnd:
|
|
990
|
-
calendarDays:
|
|
991
|
-
setSelectedDate:
|
|
992
|
-
setRangeStart:
|
|
993
|
-
setRangeEnd:
|
|
994
|
-
setCurrentYear:
|
|
995
|
-
setCurrentMonth:
|
|
996
|
-
navigateMonth:
|
|
997
|
-
isToday:
|
|
998
|
-
isSelected:
|
|
999
|
-
isInRange:
|
|
1000
|
-
} = E3(e), [
|
|
1001
|
-
start:
|
|
1002
|
-
end:
|
|
1003
|
-
}),
|
|
1004
|
-
|
|
1005
|
-
}, ye = (
|
|
1006
|
-
|
|
1007
|
-
},
|
|
979
|
+
currentYear: O,
|
|
980
|
+
currentMonth: v,
|
|
981
|
+
rangeStart: L,
|
|
982
|
+
rangeEnd: wt,
|
|
983
|
+
calendarDays: K,
|
|
984
|
+
setSelectedDate: Ft,
|
|
985
|
+
setRangeStart: m,
|
|
986
|
+
setRangeEnd: S,
|
|
987
|
+
setCurrentYear: A,
|
|
988
|
+
setCurrentMonth: y,
|
|
989
|
+
navigateMonth: E,
|
|
990
|
+
isToday: j,
|
|
991
|
+
isSelected: P,
|
|
992
|
+
isInRange: G
|
|
993
|
+
} = E3(e, t), [at, Yt] = H(), rt = l || Y3($, D), ot = (d, p) => ({
|
|
994
|
+
start: kt(e, d.year, d.month, d.day, z),
|
|
995
|
+
end: kt(e, p.year, p.month, p.day, z)
|
|
996
|
+
}), z = e === "BS" && st ? y3 : e === "BS" ? me : f3, it = e === "BS" && q ? M3 : p3, ut = (d, p) => {
|
|
997
|
+
p.start && p.end && (m(p.start), S(p.end), A(p.start.year), y(p.start.month), Yt(d.key), F?.(d, p), h?.(ot(p.start, p.end)));
|
|
998
|
+
}, ye = (d, p) => {
|
|
999
|
+
m(d), S(p), Yt(void 0), h?.(ot(d, p));
|
|
1000
|
+
}, ct = (d) => {
|
|
1008
1001
|
if (r) return;
|
|
1009
|
-
const
|
|
1010
|
-
if (
|
|
1011
|
-
if (
|
|
1012
|
-
if (
|
|
1013
|
-
|
|
1002
|
+
const p = { year: O, month: v, day: d };
|
|
1003
|
+
if (nt(p, b, J)) return;
|
|
1004
|
+
if (u === "range") {
|
|
1005
|
+
if (Yt(void 0), !L || L && wt)
|
|
1006
|
+
m(p), S(null);
|
|
1014
1007
|
else {
|
|
1015
|
-
const
|
|
1016
|
-
new Date(
|
|
1008
|
+
const Z = new Date(L.year, L.month, L.day).getTime();
|
|
1009
|
+
new Date(p.year, p.month, p.day).getTime() < Z ? (m(p), S(L), h?.(ot(p, L))) : (S(p), h?.(ot(L, p)));
|
|
1017
1010
|
}
|
|
1018
1011
|
return;
|
|
1019
1012
|
}
|
|
1020
|
-
|
|
1021
|
-
const
|
|
1022
|
-
if (
|
|
1023
|
-
let
|
|
1013
|
+
Ft(p);
|
|
1014
|
+
const X = kt(e, O, v, d, z);
|
|
1015
|
+
if (i?.(X), n) {
|
|
1016
|
+
let Z;
|
|
1024
1017
|
switch (o) {
|
|
1025
1018
|
case "iso":
|
|
1026
|
-
|
|
1019
|
+
Z = X.ad;
|
|
1027
1020
|
break;
|
|
1028
1021
|
case "object":
|
|
1029
|
-
|
|
1022
|
+
Z = JSON.stringify(X);
|
|
1030
1023
|
break;
|
|
1031
1024
|
default:
|
|
1032
|
-
|
|
1025
|
+
Z = JSON.stringify(X);
|
|
1033
1026
|
break;
|
|
1034
1027
|
}
|
|
1035
|
-
n(
|
|
1028
|
+
n(Z);
|
|
1036
1029
|
}
|
|
1037
|
-
}, fe = (
|
|
1030
|
+
}, fe = (d) => {
|
|
1038
1031
|
if (!r) {
|
|
1039
|
-
switch (
|
|
1032
|
+
switch (d.key) {
|
|
1040
1033
|
case "ArrowLeft":
|
|
1041
|
-
|
|
1034
|
+
E(-1);
|
|
1042
1035
|
break;
|
|
1043
1036
|
case "ArrowRight":
|
|
1044
|
-
|
|
1037
|
+
E(1);
|
|
1045
1038
|
break;
|
|
1046
1039
|
case "ArrowUp":
|
|
1047
|
-
|
|
1040
|
+
E(-12);
|
|
1048
1041
|
break;
|
|
1049
1042
|
case "ArrowDown":
|
|
1050
|
-
|
|
1043
|
+
E(12);
|
|
1051
1044
|
break;
|
|
1052
1045
|
case "PageUp":
|
|
1053
|
-
|
|
1046
|
+
d.shiftKey ? E(-12) : E(-1);
|
|
1054
1047
|
break;
|
|
1055
1048
|
case "PageDown":
|
|
1056
|
-
|
|
1049
|
+
d.shiftKey ? E(12) : E(1);
|
|
1057
1050
|
break;
|
|
1058
1051
|
default:
|
|
1059
1052
|
return;
|
|
1060
1053
|
}
|
|
1061
|
-
|
|
1054
|
+
d.preventDefault();
|
|
1062
1055
|
}
|
|
1063
1056
|
}, Me = {
|
|
1064
|
-
...
|
|
1065
|
-
(
|
|
1057
|
+
...k ? Object.entries(k).reduce(
|
|
1058
|
+
(d, [p, X]) => (d[`--calendar-${p}`] = X, d),
|
|
1066
1059
|
{}
|
|
1067
1060
|
) : {}
|
|
1068
1061
|
};
|
|
1069
|
-
return /* @__PURE__ */
|
|
1062
|
+
return /* @__PURE__ */ C(
|
|
1070
1063
|
"div",
|
|
1071
1064
|
{
|
|
1072
1065
|
className: `bsac-calendar ${a}`,
|
|
1073
1066
|
style: Me,
|
|
1074
|
-
"data-theme":
|
|
1067
|
+
"data-theme": B,
|
|
1075
1068
|
onKeyDown: fe,
|
|
1076
1069
|
tabIndex: 0,
|
|
1077
1070
|
role: "application",
|
|
1078
1071
|
"aria-label": "Calendar",
|
|
1079
1072
|
children: [
|
|
1080
|
-
|
|
1081
|
-
/* @__PURE__ */ g("div", { children:
|
|
1082
|
-
/* @__PURE__ */
|
|
1073
|
+
u === "range" && I && /* @__PURE__ */ C("div", { style: { display: "flex", gap: "16px" }, children: [
|
|
1074
|
+
/* @__PURE__ */ g("div", { children: I({ onRangeChange: ye }) }),
|
|
1075
|
+
/* @__PURE__ */ C("div", { style: { flex: 1 }, children: [
|
|
1083
1076
|
/* @__PURE__ */ g(
|
|
1084
|
-
|
|
1077
|
+
lt,
|
|
1085
1078
|
{
|
|
1086
|
-
currentMonth:
|
|
1087
|
-
currentYear:
|
|
1088
|
-
months:
|
|
1089
|
-
onNavigateMonth:
|
|
1090
|
-
onYearChange:
|
|
1091
|
-
onMonthChange:
|
|
1079
|
+
currentMonth: v,
|
|
1080
|
+
currentYear: O,
|
|
1081
|
+
months: z,
|
|
1082
|
+
onNavigateMonth: E,
|
|
1083
|
+
onYearChange: A,
|
|
1084
|
+
onMonthChange: y,
|
|
1092
1085
|
disabled: r,
|
|
1093
|
-
showNepaliNumbers:
|
|
1094
|
-
convertToNepaliNumber:
|
|
1086
|
+
showNepaliNumbers: M,
|
|
1087
|
+
convertToNepaliNumber: U,
|
|
1095
1088
|
calendarType: e
|
|
1096
1089
|
}
|
|
1097
1090
|
),
|
|
1098
1091
|
/* @__PURE__ */ g(
|
|
1099
|
-
|
|
1092
|
+
dt,
|
|
1100
1093
|
{
|
|
1101
|
-
calendarDays:
|
|
1102
|
-
days:
|
|
1103
|
-
onDateSelect:
|
|
1104
|
-
isSelected: (
|
|
1105
|
-
isInRange:
|
|
1106
|
-
isToday: (
|
|
1107
|
-
isDisabled: (
|
|
1094
|
+
calendarDays: K,
|
|
1095
|
+
days: it,
|
|
1096
|
+
onDateSelect: ct,
|
|
1097
|
+
isSelected: (d) => P(d, u),
|
|
1098
|
+
isInRange: G,
|
|
1099
|
+
isToday: (d) => s && j(d),
|
|
1100
|
+
isDisabled: (d) => nt({ year: O, month: v, day: d }, b, J),
|
|
1108
1101
|
disabled: r,
|
|
1109
|
-
showNepaliNumbers:
|
|
1110
|
-
convertToNepaliNumber:
|
|
1102
|
+
showNepaliNumbers: M,
|
|
1103
|
+
convertToNepaliNumber: U
|
|
1111
1104
|
}
|
|
1112
1105
|
)
|
|
1113
1106
|
] })
|
|
1114
1107
|
] }),
|
|
1115
|
-
|
|
1108
|
+
u === "range" && c && f === "left" && !I && /* @__PURE__ */ C("div", { style: { display: "flex", gap: "16px", flexWrap: "nowrap" }, children: [
|
|
1116
1109
|
/* @__PURE__ */ g(
|
|
1117
|
-
|
|
1110
|
+
gt,
|
|
1118
1111
|
{
|
|
1119
|
-
presets:
|
|
1112
|
+
presets: rt,
|
|
1120
1113
|
calendarType: e,
|
|
1121
|
-
onPresetSelect:
|
|
1122
|
-
activePreset:
|
|
1114
|
+
onPresetSelect: ut,
|
|
1115
|
+
activePreset: at,
|
|
1123
1116
|
position: "left"
|
|
1124
1117
|
}
|
|
1125
1118
|
),
|
|
1126
|
-
/* @__PURE__ */
|
|
1119
|
+
/* @__PURE__ */ C("div", { children: [
|
|
1127
1120
|
/* @__PURE__ */ g(
|
|
1128
|
-
|
|
1121
|
+
lt,
|
|
1129
1122
|
{
|
|
1130
|
-
currentMonth:
|
|
1131
|
-
currentYear:
|
|
1132
|
-
months:
|
|
1133
|
-
onNavigateMonth:
|
|
1134
|
-
onYearChange:
|
|
1135
|
-
onMonthChange:
|
|
1123
|
+
currentMonth: v,
|
|
1124
|
+
currentYear: O,
|
|
1125
|
+
months: z,
|
|
1126
|
+
onNavigateMonth: E,
|
|
1127
|
+
onYearChange: A,
|
|
1128
|
+
onMonthChange: y,
|
|
1136
1129
|
disabled: r,
|
|
1137
|
-
showNepaliNumbers:
|
|
1138
|
-
convertToNepaliNumber:
|
|
1130
|
+
showNepaliNumbers: M,
|
|
1131
|
+
convertToNepaliNumber: U,
|
|
1139
1132
|
calendarType: e
|
|
1140
1133
|
}
|
|
1141
1134
|
),
|
|
1142
1135
|
/* @__PURE__ */ g(
|
|
1143
|
-
|
|
1136
|
+
dt,
|
|
1144
1137
|
{
|
|
1145
|
-
calendarDays:
|
|
1146
|
-
days:
|
|
1147
|
-
onDateSelect:
|
|
1148
|
-
isSelected: (
|
|
1149
|
-
isInRange:
|
|
1150
|
-
isToday: (
|
|
1151
|
-
isDisabled: (
|
|
1138
|
+
calendarDays: K,
|
|
1139
|
+
days: it,
|
|
1140
|
+
onDateSelect: ct,
|
|
1141
|
+
isSelected: (d) => P(d, u),
|
|
1142
|
+
isInRange: G,
|
|
1143
|
+
isToday: (d) => s && j(d),
|
|
1144
|
+
isDisabled: (d) => nt({ year: O, month: v, day: d }, b, J),
|
|
1152
1145
|
disabled: r,
|
|
1153
|
-
showNepaliNumbers:
|
|
1154
|
-
convertToNepaliNumber:
|
|
1146
|
+
showNepaliNumbers: M,
|
|
1147
|
+
convertToNepaliNumber: U
|
|
1155
1148
|
}
|
|
1156
1149
|
)
|
|
1157
1150
|
] })
|
|
1158
1151
|
] }),
|
|
1159
|
-
|
|
1160
|
-
/* @__PURE__ */
|
|
1152
|
+
u === "range" && c && f === "right" && !I && /* @__PURE__ */ C("div", { style: { display: "flex", gap: "16px", flexWrap: "nowrap" }, children: [
|
|
1153
|
+
/* @__PURE__ */ C("div", { children: [
|
|
1161
1154
|
/* @__PURE__ */ g(
|
|
1162
|
-
|
|
1155
|
+
lt,
|
|
1163
1156
|
{
|
|
1164
|
-
currentMonth:
|
|
1165
|
-
currentYear:
|
|
1166
|
-
months:
|
|
1167
|
-
onNavigateMonth:
|
|
1168
|
-
onYearChange:
|
|
1169
|
-
onMonthChange:
|
|
1157
|
+
currentMonth: v,
|
|
1158
|
+
currentYear: O,
|
|
1159
|
+
months: z,
|
|
1160
|
+
onNavigateMonth: E,
|
|
1161
|
+
onYearChange: A,
|
|
1162
|
+
onMonthChange: y,
|
|
1170
1163
|
disabled: r,
|
|
1171
|
-
showNepaliNumbers:
|
|
1172
|
-
convertToNepaliNumber:
|
|
1164
|
+
showNepaliNumbers: M,
|
|
1165
|
+
convertToNepaliNumber: U,
|
|
1173
1166
|
calendarType: e
|
|
1174
1167
|
}
|
|
1175
1168
|
),
|
|
1176
1169
|
/* @__PURE__ */ g(
|
|
1177
|
-
|
|
1170
|
+
dt,
|
|
1178
1171
|
{
|
|
1179
|
-
calendarDays:
|
|
1180
|
-
days:
|
|
1181
|
-
onDateSelect:
|
|
1182
|
-
isSelected: (
|
|
1183
|
-
isInRange:
|
|
1184
|
-
isToday: (
|
|
1185
|
-
isDisabled: (
|
|
1172
|
+
calendarDays: K,
|
|
1173
|
+
days: it,
|
|
1174
|
+
onDateSelect: ct,
|
|
1175
|
+
isSelected: (d) => P(d, u),
|
|
1176
|
+
isInRange: G,
|
|
1177
|
+
isToday: (d) => s && j(d),
|
|
1178
|
+
isDisabled: (d) => nt({ year: O, month: v, day: d }, b, J),
|
|
1186
1179
|
disabled: r,
|
|
1187
|
-
showNepaliNumbers:
|
|
1188
|
-
convertToNepaliNumber:
|
|
1180
|
+
showNepaliNumbers: M,
|
|
1181
|
+
convertToNepaliNumber: U
|
|
1189
1182
|
}
|
|
1190
1183
|
)
|
|
1191
1184
|
] }),
|
|
1192
1185
|
/* @__PURE__ */ g(
|
|
1193
|
-
|
|
1186
|
+
gt,
|
|
1194
1187
|
{
|
|
1195
|
-
presets:
|
|
1188
|
+
presets: rt,
|
|
1196
1189
|
calendarType: e,
|
|
1197
|
-
onPresetSelect:
|
|
1198
|
-
activePreset:
|
|
1190
|
+
onPresetSelect: ut,
|
|
1191
|
+
activePreset: at,
|
|
1199
1192
|
position: "right"
|
|
1200
1193
|
}
|
|
1201
1194
|
)
|
|
1202
1195
|
] }),
|
|
1203
|
-
(!
|
|
1204
|
-
|
|
1205
|
-
|
|
1196
|
+
(!u || u === "single" || !c && !I || f === "top" || f === "bottom") && /* @__PURE__ */ C(pe, { children: [
|
|
1197
|
+
u === "range" && c && f === "top" && /* @__PURE__ */ g(
|
|
1198
|
+
gt,
|
|
1206
1199
|
{
|
|
1207
|
-
presets:
|
|
1200
|
+
presets: rt,
|
|
1208
1201
|
calendarType: e,
|
|
1209
|
-
onPresetSelect:
|
|
1210
|
-
activePreset:
|
|
1202
|
+
onPresetSelect: ut,
|
|
1203
|
+
activePreset: at,
|
|
1211
1204
|
position: "top"
|
|
1212
1205
|
}
|
|
1213
1206
|
),
|
|
1214
1207
|
/* @__PURE__ */ g(
|
|
1215
|
-
|
|
1208
|
+
lt,
|
|
1216
1209
|
{
|
|
1217
|
-
currentMonth:
|
|
1218
|
-
currentYear:
|
|
1219
|
-
months:
|
|
1220
|
-
onNavigateMonth:
|
|
1221
|
-
onYearChange:
|
|
1222
|
-
onMonthChange:
|
|
1210
|
+
currentMonth: v,
|
|
1211
|
+
currentYear: O,
|
|
1212
|
+
months: z,
|
|
1213
|
+
onNavigateMonth: E,
|
|
1214
|
+
onYearChange: A,
|
|
1215
|
+
onMonthChange: y,
|
|
1223
1216
|
disabled: r,
|
|
1224
|
-
showNepaliNumbers:
|
|
1225
|
-
convertToNepaliNumber:
|
|
1217
|
+
showNepaliNumbers: M,
|
|
1218
|
+
convertToNepaliNumber: U,
|
|
1226
1219
|
calendarType: e
|
|
1227
1220
|
}
|
|
1228
1221
|
),
|
|
1229
1222
|
/* @__PURE__ */ g(
|
|
1230
|
-
|
|
1223
|
+
dt,
|
|
1231
1224
|
{
|
|
1232
|
-
calendarDays:
|
|
1233
|
-
days:
|
|
1234
|
-
onDateSelect:
|
|
1235
|
-
isSelected: (
|
|
1236
|
-
isInRange:
|
|
1237
|
-
isToday: (
|
|
1238
|
-
isDisabled: (
|
|
1225
|
+
calendarDays: K,
|
|
1226
|
+
days: it,
|
|
1227
|
+
onDateSelect: ct,
|
|
1228
|
+
isSelected: (d) => P(d, u),
|
|
1229
|
+
isInRange: G,
|
|
1230
|
+
isToday: (d) => s && j(d),
|
|
1231
|
+
isDisabled: (d) => nt({ year: O, month: v, day: d }, b, J),
|
|
1239
1232
|
disabled: r,
|
|
1240
|
-
showNepaliNumbers:
|
|
1241
|
-
convertToNepaliNumber:
|
|
1233
|
+
showNepaliNumbers: M,
|
|
1234
|
+
convertToNepaliNumber: U
|
|
1242
1235
|
}
|
|
1243
1236
|
),
|
|
1244
|
-
|
|
1245
|
-
|
|
1237
|
+
u === "range" && c && f === "bottom" && /* @__PURE__ */ g(
|
|
1238
|
+
gt,
|
|
1246
1239
|
{
|
|
1247
|
-
presets:
|
|
1240
|
+
presets: rt,
|
|
1248
1241
|
calendarType: e,
|
|
1249
|
-
onPresetSelect:
|
|
1250
|
-
activePreset:
|
|
1242
|
+
onPresetSelect: ut,
|
|
1243
|
+
activePreset: at,
|
|
1251
1244
|
position: "bottom"
|
|
1252
1245
|
}
|
|
1253
1246
|
)
|
|
@@ -1255,7 +1248,7 @@ const y3 = [
|
|
|
1255
1248
|
]
|
|
1256
1249
|
}
|
|
1257
1250
|
);
|
|
1258
|
-
},
|
|
1251
|
+
}, B3 = ({
|
|
1259
1252
|
placeholder: e = "Select date",
|
|
1260
1253
|
format: t = "YYYY-MM-DD",
|
|
1261
1254
|
defaultValue: n,
|
|
@@ -1263,92 +1256,117 @@ const y3 = [
|
|
|
1263
1256
|
inputClassName: s = "",
|
|
1264
1257
|
popupClassName: r = "",
|
|
1265
1258
|
style: o,
|
|
1266
|
-
inputStyle:
|
|
1267
|
-
icon:
|
|
1259
|
+
inputStyle: i,
|
|
1260
|
+
icon: u,
|
|
1268
1261
|
showIcon: h = !0,
|
|
1269
1262
|
calendarType: c = "AD",
|
|
1270
|
-
...
|
|
1263
|
+
...f
|
|
1271
1264
|
}) => {
|
|
1272
|
-
const [
|
|
1265
|
+
const [l, $] = H(!1), [D, F] = H(null), [I, st] = H(void 0), [q, M] = H(() => {
|
|
1273
1266
|
if (!n) return "";
|
|
1274
1267
|
if (c === "BS")
|
|
1275
1268
|
try {
|
|
1276
|
-
const [
|
|
1277
|
-
return `${
|
|
1269
|
+
const [m, S, A] = n.split("-").map(Number), y = w.fromEnglishDate(m, S - 1, A);
|
|
1270
|
+
return `${y.getYear()}-${String(y.getMonth() + 1).padStart(2, "0")}-${String(y.getDate()).padStart(2, "0")}`;
|
|
1278
1271
|
} catch {
|
|
1279
1272
|
return n;
|
|
1280
1273
|
}
|
|
1281
1274
|
return n;
|
|
1282
|
-
})
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1275
|
+
});
|
|
1276
|
+
Dt(() => {
|
|
1277
|
+
if (n)
|
|
1278
|
+
if (c === "BS")
|
|
1279
|
+
try {
|
|
1280
|
+
const [m, S, A] = n.split("-").map(Number), y = w.fromEnglishDate(m, S - 1, A);
|
|
1281
|
+
M(`${y.getYear()}-${String(y.getMonth() + 1).padStart(2, "0")}-${String(y.getDate()).padStart(2, "0")}`);
|
|
1282
|
+
} catch {
|
|
1283
|
+
M(n);
|
|
1284
|
+
}
|
|
1285
|
+
else
|
|
1286
|
+
M(n);
|
|
1287
|
+
}, [n, c]);
|
|
1288
|
+
const B = mt(() => {
|
|
1289
|
+
if (n) {
|
|
1290
|
+
if (c === "BS")
|
|
1291
|
+
try {
|
|
1292
|
+
const [m, S, A] = n.split("-").map(Number), y = w.fromEnglishDate(m, S - 1, A);
|
|
1293
|
+
return `${y.getYear()}-${String(y.getMonth() + 1).padStart(2, "0")}-${String(y.getDate()).padStart(2, "0")}`;
|
|
1294
|
+
} catch {
|
|
1295
|
+
return n;
|
|
1296
|
+
}
|
|
1297
|
+
return n;
|
|
1298
|
+
}
|
|
1299
|
+
}, [n, c]), k = xt(null), b = xt(null), [J, O] = H({ visibility: "hidden" }), v = () => {
|
|
1300
|
+
if (!k.current) return;
|
|
1301
|
+
const m = k.current.getBoundingClientRect(), S = b.current?.offsetHeight || 360, A = b.current?.offsetWidth || 280, y = window.innerHeight - m.bottom, E = window.innerWidth - m.left, j = y >= S + 8 ? m.bottom + 8 : Math.max(8, m.top - S - 8), P = E >= A ? m.left : Math.max(8, m.right - A);
|
|
1302
|
+
O({ top: j, left: P, visibility: "visible" });
|
|
1286
1303
|
};
|
|
1287
|
-
|
|
1288
|
-
window.removeEventListener("scroll",
|
|
1289
|
-
}), [
|
|
1290
|
-
const
|
|
1291
|
-
|
|
1304
|
+
Dt(() => (l && (requestAnimationFrame(v), window.addEventListener("scroll", v, !0), window.addEventListener("resize", v)), () => {
|
|
1305
|
+
window.removeEventListener("scroll", v, !0), window.removeEventListener("resize", v);
|
|
1306
|
+
}), [l]), Dt(() => {
|
|
1307
|
+
const m = (S) => {
|
|
1308
|
+
k.current && !k.current.contains(S.target) && $(!1);
|
|
1292
1309
|
};
|
|
1293
|
-
return
|
|
1294
|
-
}, [
|
|
1295
|
-
const
|
|
1296
|
-
|
|
1297
|
-
},
|
|
1298
|
-
const
|
|
1299
|
-
if (
|
|
1300
|
-
|
|
1310
|
+
return l && document.addEventListener("mousedown", m), () => document.removeEventListener("mousedown", m);
|
|
1311
|
+
}, [l]);
|
|
1312
|
+
const L = (m) => {
|
|
1313
|
+
F(m), st(c === "BS" ? m.bs : m.ad), M(c === "BS" ? m.bs : m.ad), $(!1), a?.(m);
|
|
1314
|
+
}, wt = (m) => {
|
|
1315
|
+
const S = m.target.value;
|
|
1316
|
+
if (S === "") {
|
|
1317
|
+
M("");
|
|
1301
1318
|
return;
|
|
1302
1319
|
}
|
|
1303
|
-
if ((
|
|
1304
|
-
const
|
|
1305
|
-
let
|
|
1306
|
-
|
|
1320
|
+
if ((m.target.selectionStart || 0) === S.length && S.length > q.length) {
|
|
1321
|
+
const y = S.replace(/[^0-9]/g, "");
|
|
1322
|
+
let E = y;
|
|
1323
|
+
y.length > 4 && y.length <= 6 ? E = y.slice(0, 4) + "-" + y.slice(4) : y.length > 6 && (E = y.slice(0, 4) + "-" + y.slice(4, 6) + "-" + y.slice(6, 8)), M(E);
|
|
1307
1324
|
} else {
|
|
1308
|
-
const
|
|
1309
|
-
|
|
1325
|
+
const y = S.replace(/[^0-9-]/g, "");
|
|
1326
|
+
y.length <= 10 && M(y);
|
|
1310
1327
|
}
|
|
1311
|
-
},
|
|
1312
|
-
const
|
|
1313
|
-
if (!
|
|
1314
|
-
|
|
1328
|
+
}, K = () => {
|
|
1329
|
+
const m = q.trim();
|
|
1330
|
+
if (!m) {
|
|
1331
|
+
F(null);
|
|
1315
1332
|
return;
|
|
1316
1333
|
}
|
|
1317
|
-
const
|
|
1318
|
-
if (
|
|
1319
|
-
const [,
|
|
1320
|
-
if (
|
|
1321
|
-
|
|
1334
|
+
const S = m.match(/^(\d{4})-(\d{2})-(\d{2})$/);
|
|
1335
|
+
if (S) {
|
|
1336
|
+
const [, A, y, E] = S, j = parseInt(y), P = parseInt(E);
|
|
1337
|
+
if (j < 1 || j > 12 || P < 1 || P > 32) {
|
|
1338
|
+
M(D ? c === "BS" ? D.bs : D.ad : "");
|
|
1322
1339
|
return;
|
|
1323
1340
|
}
|
|
1324
|
-
const
|
|
1325
|
-
bs: c === "BS" ? `${
|
|
1326
|
-
ad: c === "AD" ? `${
|
|
1341
|
+
const G = {
|
|
1342
|
+
bs: c === "BS" ? `${A}-${y}-${E}` : "",
|
|
1343
|
+
ad: c === "AD" ? `${A}-${y}-${E}` : "",
|
|
1327
1344
|
formatted: {
|
|
1328
|
-
bs: c === "BS" ?
|
|
1329
|
-
ad: c === "AD" ?
|
|
1345
|
+
bs: c === "BS" ? m : "",
|
|
1346
|
+
ad: c === "AD" ? m : ""
|
|
1330
1347
|
}
|
|
1331
1348
|
};
|
|
1332
|
-
|
|
1333
|
-
|
|
1349
|
+
if (F(G), D === null) return;
|
|
1350
|
+
a?.(G);
|
|
1351
|
+
} else m.length < 10 && M(D ? c === "BS" ? D.bs : D.ad : "");
|
|
1334
1352
|
};
|
|
1335
|
-
return /* @__PURE__ */
|
|
1353
|
+
return /* @__PURE__ */ C("div", { className: "bsac-datepicker", ref: k, style: o, children: [
|
|
1336
1354
|
/* @__PURE__ */ g(
|
|
1337
1355
|
"input",
|
|
1338
1356
|
{
|
|
1339
1357
|
type: "text",
|
|
1340
|
-
value:
|
|
1358
|
+
value: q,
|
|
1341
1359
|
placeholder: e,
|
|
1342
|
-
onChange:
|
|
1343
|
-
onBlur:
|
|
1344
|
-
onKeyDown: (
|
|
1345
|
-
|
|
1360
|
+
onChange: wt,
|
|
1361
|
+
onBlur: K,
|
|
1362
|
+
onKeyDown: (m) => {
|
|
1363
|
+
m.key === "Enter" ? (K(), $(!1)) : m.key === "Escape" && $(!1);
|
|
1346
1364
|
},
|
|
1347
1365
|
className: `bsac-input ${s}`,
|
|
1348
|
-
style:
|
|
1366
|
+
style: i,
|
|
1349
1367
|
"aria-label": "Date picker input",
|
|
1350
1368
|
"aria-haspopup": "dialog",
|
|
1351
|
-
"aria-expanded":
|
|
1369
|
+
"aria-expanded": l,
|
|
1352
1370
|
maxLength: 10
|
|
1353
1371
|
}
|
|
1354
1372
|
),
|
|
@@ -1357,10 +1375,10 @@ const y3 = [
|
|
|
1357
1375
|
{
|
|
1358
1376
|
type: "button",
|
|
1359
1377
|
className: "bsac-icon-btn",
|
|
1360
|
-
onClick: () =>
|
|
1378
|
+
onClick: () => $(!l),
|
|
1361
1379
|
"aria-label": "Toggle calendar",
|
|
1362
1380
|
style: { display: h ? "flex" : "none" },
|
|
1363
|
-
children:
|
|
1381
|
+
children: u || /* @__PURE__ */ C("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
|
|
1364
1382
|
/* @__PURE__ */ g("rect", { x: "3", y: "4", width: "18", height: "18", rx: "2", ry: "2" }),
|
|
1365
1383
|
/* @__PURE__ */ g("line", { x1: "16", y1: "2", x2: "16", y2: "6" }),
|
|
1366
1384
|
/* @__PURE__ */ g("line", { x1: "8", y1: "2", x2: "8", y2: "6" }),
|
|
@@ -1368,27 +1386,27 @@ const y3 = [
|
|
|
1368
1386
|
] })
|
|
1369
1387
|
}
|
|
1370
1388
|
),
|
|
1371
|
-
|
|
1389
|
+
/* @__PURE__ */ g("div", { ref: b, className: `bsac-popup ${r}`, style: { ...J, display: l ? void 0 : "none" }, children: /* @__PURE__ */ g(C3, { calendarType: c, onDateSelect: L, value: I ?? B, ...f }) })
|
|
1372
1390
|
] });
|
|
1373
1391
|
};
|
|
1374
1392
|
export {
|
|
1375
1393
|
C3 as Calendar,
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1394
|
+
B3 as CalendarInput,
|
|
1395
|
+
N3 as DEFAULT_COLORS,
|
|
1396
|
+
B3 as DatePicker,
|
|
1379
1397
|
p3 as ENGLISH_DAYS,
|
|
1380
1398
|
f3 as ENGLISH_MONTHS_AD,
|
|
1381
1399
|
me as ENGLISH_MONTHS_BS,
|
|
1382
1400
|
M3 as NEPALI_DAYS,
|
|
1383
|
-
|
|
1401
|
+
S3 as NEPALI_DIGITS,
|
|
1384
1402
|
y3 as NEPALI_MONTHS,
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1403
|
+
O3 as PRESET_KEYS,
|
|
1404
|
+
U as convertToNepaliNumber,
|
|
1405
|
+
kt as createDateOutput,
|
|
1388
1406
|
Y3 as createPredefinedRanges,
|
|
1389
1407
|
De as getDaysInMonth,
|
|
1390
|
-
|
|
1408
|
+
b3 as getFirstDayOfMonth,
|
|
1391
1409
|
N as getTodayDate,
|
|
1392
|
-
|
|
1410
|
+
H3 as isDateInRange,
|
|
1393
1411
|
E3 as useCalendar
|
|
1394
1412
|
};
|