@patrojs/core 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +487 -0
- package/dist/index.d.cts +127 -0
- package/dist/index.d.ts +127 -0
- package/dist/index.js +487 -0
- package/package.json +40 -0
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,487 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
3
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
+
var __spreadValues = (a, b) => {
|
|
7
|
+
for (var prop in b || (b = {}))
|
|
8
|
+
if (__hasOwnProp.call(b, prop))
|
|
9
|
+
__defNormalProp(a, prop, b[prop]);
|
|
10
|
+
if (__getOwnPropSymbols)
|
|
11
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
12
|
+
if (__propIsEnum.call(b, prop))
|
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
|
14
|
+
}
|
|
15
|
+
return a;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
// src/data.ts
|
|
19
|
+
var BIKRAM_SAMBAT = {};
|
|
20
|
+
BIKRAM_SAMBAT[2e3] = [2e3, 30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31];
|
|
21
|
+
BIKRAM_SAMBAT[2001] = [2001, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30];
|
|
22
|
+
BIKRAM_SAMBAT[2002] = [2002, 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30];
|
|
23
|
+
BIKRAM_SAMBAT[2003] = [2003, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31];
|
|
24
|
+
BIKRAM_SAMBAT[2004] = [2004, 30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31];
|
|
25
|
+
BIKRAM_SAMBAT[2005] = [2005, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30];
|
|
26
|
+
BIKRAM_SAMBAT[2006] = [2006, 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30];
|
|
27
|
+
BIKRAM_SAMBAT[2007] = [2007, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31];
|
|
28
|
+
BIKRAM_SAMBAT[2008] = [2008, 31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 29, 31];
|
|
29
|
+
BIKRAM_SAMBAT[2009] = [2009, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30];
|
|
30
|
+
BIKRAM_SAMBAT[2010] = [2010, 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30];
|
|
31
|
+
BIKRAM_SAMBAT[2011] = [2011, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31];
|
|
32
|
+
BIKRAM_SAMBAT[2012] = [2012, 31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30];
|
|
33
|
+
BIKRAM_SAMBAT[2013] = [2013, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30];
|
|
34
|
+
BIKRAM_SAMBAT[2014] = [2014, 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30];
|
|
35
|
+
BIKRAM_SAMBAT[2015] = [2015, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31];
|
|
36
|
+
BIKRAM_SAMBAT[2016] = [2016, 31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30];
|
|
37
|
+
BIKRAM_SAMBAT[2017] = [2017, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30];
|
|
38
|
+
BIKRAM_SAMBAT[2018] = [2018, 31, 32, 31, 32, 31, 30, 30, 29, 30, 29, 30, 30];
|
|
39
|
+
BIKRAM_SAMBAT[2019] = [2019, 31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31];
|
|
40
|
+
BIKRAM_SAMBAT[2020] = [2020, 31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30];
|
|
41
|
+
BIKRAM_SAMBAT[2021] = [2021, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30];
|
|
42
|
+
BIKRAM_SAMBAT[2022] = [2022, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30];
|
|
43
|
+
BIKRAM_SAMBAT[2023] = [2023, 31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31];
|
|
44
|
+
BIKRAM_SAMBAT[2024] = [2024, 31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30];
|
|
45
|
+
BIKRAM_SAMBAT[2025] = [2025, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30];
|
|
46
|
+
BIKRAM_SAMBAT[2026] = [2026, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31];
|
|
47
|
+
BIKRAM_SAMBAT[2027] = [2027, 30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31];
|
|
48
|
+
BIKRAM_SAMBAT[2028] = [2028, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30];
|
|
49
|
+
BIKRAM_SAMBAT[2029] = [2029, 31, 31, 32, 31, 32, 30, 30, 29, 30, 29, 30, 30];
|
|
50
|
+
BIKRAM_SAMBAT[2030] = [2030, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31];
|
|
51
|
+
BIKRAM_SAMBAT[2031] = [2031, 30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31];
|
|
52
|
+
BIKRAM_SAMBAT[2032] = [2032, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30];
|
|
53
|
+
BIKRAM_SAMBAT[2033] = [2033, 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30];
|
|
54
|
+
BIKRAM_SAMBAT[2034] = [2034, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31];
|
|
55
|
+
BIKRAM_SAMBAT[2035] = [2035, 30, 32, 31, 32, 31, 31, 29, 30, 30, 29, 29, 31];
|
|
56
|
+
BIKRAM_SAMBAT[2036] = [2036, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30];
|
|
57
|
+
BIKRAM_SAMBAT[2037] = [2037, 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30];
|
|
58
|
+
BIKRAM_SAMBAT[2038] = [2038, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31];
|
|
59
|
+
BIKRAM_SAMBAT[2039] = [2039, 31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30];
|
|
60
|
+
BIKRAM_SAMBAT[2040] = [2040, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30];
|
|
61
|
+
BIKRAM_SAMBAT[2041] = [2041, 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30];
|
|
62
|
+
BIKRAM_SAMBAT[2042] = [2042, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31];
|
|
63
|
+
BIKRAM_SAMBAT[2043] = [2043, 31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30];
|
|
64
|
+
BIKRAM_SAMBAT[2044] = [2044, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30];
|
|
65
|
+
BIKRAM_SAMBAT[2045] = [2045, 31, 32, 31, 32, 31, 30, 30, 29, 30, 29, 30, 30];
|
|
66
|
+
BIKRAM_SAMBAT[2046] = [2046, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31];
|
|
67
|
+
BIKRAM_SAMBAT[2047] = [2047, 31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30];
|
|
68
|
+
BIKRAM_SAMBAT[2048] = [2048, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30];
|
|
69
|
+
BIKRAM_SAMBAT[2049] = [2049, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30];
|
|
70
|
+
BIKRAM_SAMBAT[2050] = [2050, 31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31];
|
|
71
|
+
BIKRAM_SAMBAT[2051] = [2051, 31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30];
|
|
72
|
+
BIKRAM_SAMBAT[2052] = [2052, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30];
|
|
73
|
+
BIKRAM_SAMBAT[2053] = [2053, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30];
|
|
74
|
+
BIKRAM_SAMBAT[2054] = [2054, 31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31];
|
|
75
|
+
BIKRAM_SAMBAT[2055] = [2055, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30];
|
|
76
|
+
BIKRAM_SAMBAT[2056] = [2056, 31, 31, 32, 31, 32, 30, 30, 29, 30, 29, 30, 30];
|
|
77
|
+
BIKRAM_SAMBAT[2057] = [2057, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31];
|
|
78
|
+
BIKRAM_SAMBAT[2058] = [2058, 30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31];
|
|
79
|
+
BIKRAM_SAMBAT[2059] = [2059, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30];
|
|
80
|
+
BIKRAM_SAMBAT[2060] = [2060, 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30];
|
|
81
|
+
BIKRAM_SAMBAT[2061] = [2061, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31];
|
|
82
|
+
BIKRAM_SAMBAT[2062] = [2062, 30, 32, 31, 32, 31, 31, 29, 30, 29, 30, 29, 31];
|
|
83
|
+
BIKRAM_SAMBAT[2063] = [2063, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30];
|
|
84
|
+
BIKRAM_SAMBAT[2064] = [2064, 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30];
|
|
85
|
+
BIKRAM_SAMBAT[2065] = [2065, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31];
|
|
86
|
+
BIKRAM_SAMBAT[2066] = [2066, 31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 29, 31];
|
|
87
|
+
BIKRAM_SAMBAT[2067] = [2067, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30];
|
|
88
|
+
BIKRAM_SAMBAT[2068] = [2068, 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30];
|
|
89
|
+
BIKRAM_SAMBAT[2069] = [2069, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31];
|
|
90
|
+
BIKRAM_SAMBAT[2070] = [2070, 31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30];
|
|
91
|
+
BIKRAM_SAMBAT[2071] = [2071, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30];
|
|
92
|
+
BIKRAM_SAMBAT[2072] = [2072, 31, 32, 31, 32, 31, 30, 30, 29, 30, 29, 30, 30];
|
|
93
|
+
BIKRAM_SAMBAT[2073] = [2073, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31];
|
|
94
|
+
BIKRAM_SAMBAT[2074] = [2074, 31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30];
|
|
95
|
+
BIKRAM_SAMBAT[2075] = [2075, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30];
|
|
96
|
+
BIKRAM_SAMBAT[2076] = [2076, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30];
|
|
97
|
+
BIKRAM_SAMBAT[2077] = [2077, 31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31];
|
|
98
|
+
BIKRAM_SAMBAT[2078] = [2078, 31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30];
|
|
99
|
+
BIKRAM_SAMBAT[2079] = [2079, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30];
|
|
100
|
+
BIKRAM_SAMBAT[2080] = [2080, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30];
|
|
101
|
+
BIKRAM_SAMBAT[2081] = [2081, 31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31];
|
|
102
|
+
BIKRAM_SAMBAT[2082] = [2082, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30];
|
|
103
|
+
BIKRAM_SAMBAT[2083] = [2083, 31, 31, 32, 31, 31, 30, 30, 30, 29, 30, 30, 30];
|
|
104
|
+
BIKRAM_SAMBAT[2084] = [2084, 31, 31, 32, 31, 31, 30, 30, 30, 29, 30, 30, 30];
|
|
105
|
+
BIKRAM_SAMBAT[2085] = [2085, 31, 32, 31, 32, 30, 31, 30, 30, 29, 30, 30, 30];
|
|
106
|
+
BIKRAM_SAMBAT[2086] = [2086, 30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30];
|
|
107
|
+
BIKRAM_SAMBAT[2087] = [2087, 31, 31, 32, 31, 31, 31, 30, 30, 29, 30, 30, 30];
|
|
108
|
+
BIKRAM_SAMBAT[2088] = [2088, 30, 31, 32, 32, 30, 31, 30, 30, 29, 30, 30, 30];
|
|
109
|
+
BIKRAM_SAMBAT[2089] = [2089, 30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30];
|
|
110
|
+
BIKRAM_SAMBAT[2090] = [2090, 30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30];
|
|
111
|
+
BIKRAM_SAMBAT[2091] = [2091, 31, 31, 32, 31, 31, 31, 30, 30, 29, 30, 30, 30];
|
|
112
|
+
BIKRAM_SAMBAT[2092] = [2092, 30, 31, 32, 32, 31, 30, 30, 30, 29, 30, 30, 30];
|
|
113
|
+
BIKRAM_SAMBAT[2093] = [2093, 30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30];
|
|
114
|
+
BIKRAM_SAMBAT[2094] = [2094, 31, 31, 32, 31, 31, 30, 30, 30, 29, 30, 30, 30];
|
|
115
|
+
BIKRAM_SAMBAT[2095] = [2095, 31, 31, 32, 31, 31, 31, 30, 29, 30, 30, 30, 30];
|
|
116
|
+
BIKRAM_SAMBAT[2096] = [2096, 30, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30];
|
|
117
|
+
BIKRAM_SAMBAT[2097] = [2097, 31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30];
|
|
118
|
+
BIKRAM_SAMBAT[2098] = [2098, 31, 31, 32, 31, 31, 31, 29, 30, 29, 30, 29, 31];
|
|
119
|
+
BIKRAM_SAMBAT[2099] = [2099, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31];
|
|
120
|
+
var AD_EPOCH = "1943-04-14";
|
|
121
|
+
var BS_START_YEAR = 2e3;
|
|
122
|
+
var BS_END_YEAR = 2099;
|
|
123
|
+
var MONTHS_EN = [
|
|
124
|
+
"Baishakh",
|
|
125
|
+
"Jestha",
|
|
126
|
+
"Ashad",
|
|
127
|
+
"Shrawan",
|
|
128
|
+
"Bhadra",
|
|
129
|
+
"Ashwin",
|
|
130
|
+
"Kartik",
|
|
131
|
+
"Mangsir",
|
|
132
|
+
"Poush",
|
|
133
|
+
"Magh",
|
|
134
|
+
"Falgun",
|
|
135
|
+
"Chaitra"
|
|
136
|
+
];
|
|
137
|
+
var MONTHS_NE = [
|
|
138
|
+
"\u092C\u0948\u0936\u093E\u0916",
|
|
139
|
+
"\u091C\u0947\u0920",
|
|
140
|
+
"\u0905\u0938\u093E\u0930",
|
|
141
|
+
"\u0936\u094D\u0930\u093E\u0935\u0923",
|
|
142
|
+
"\u092D\u0926\u094C",
|
|
143
|
+
"\u0905\u0938\u094B\u091C",
|
|
144
|
+
"\u0915\u093E\u0930\u094D\u0924\u093F\u0915",
|
|
145
|
+
"\u092E\u0902\u0938\u093F\u0930",
|
|
146
|
+
"\u092A\u0941\u0937",
|
|
147
|
+
"\u092E\u093E\u0918",
|
|
148
|
+
"\u092B\u093E\u0932\u094D\u0917\u0941\u0928",
|
|
149
|
+
"\u091A\u0948\u0924\u094D\u0930"
|
|
150
|
+
];
|
|
151
|
+
var DAYS_SHORT_EN = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
|
|
152
|
+
var DAYS_SHORT_NE = ["\u0906\u0907\u0924", "\u0938\u094B\u092E", "\u092E\u0902\u0917\u0932", "\u092C\u0941\u0927", "\u092C\u093F\u0939\u093F", "\u0936\u0941\u0915\u094D\u0930", "\u0936\u0928\u093F"];
|
|
153
|
+
var NEPALI_DIGITS = ["\u0966", "\u0967", "\u0968", "\u0969", "\u096A", "\u096B", "\u096C", "\u096D", "\u096E", "\u096F"];
|
|
154
|
+
|
|
155
|
+
// src/converter.ts
|
|
156
|
+
function bsToAd(bsDate) {
|
|
157
|
+
const { year, month, day } = bsDate;
|
|
158
|
+
let daysDiff = 0;
|
|
159
|
+
for (let i = 2e3; i <= year; i++) {
|
|
160
|
+
if (i === year) {
|
|
161
|
+
for (let j = 1; j < month; j++) {
|
|
162
|
+
daysDiff += BIKRAM_SAMBAT[i][j];
|
|
163
|
+
}
|
|
164
|
+
daysDiff += day - 1;
|
|
165
|
+
} else {
|
|
166
|
+
for (let j = 1; j <= 12; j++) {
|
|
167
|
+
daysDiff += BIKRAM_SAMBAT[i][j];
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
const result = new Date(AD_EPOCH);
|
|
172
|
+
result.setDate(result.getDate() + daysDiff);
|
|
173
|
+
const y = result.getFullYear();
|
|
174
|
+
const m = result.getMonth() + 1;
|
|
175
|
+
const d = result.getDate();
|
|
176
|
+
return `${y}-${m > 9 ? m : "0" + m}-${d > 9 ? d : "0" + d}`;
|
|
177
|
+
}
|
|
178
|
+
function bsToAdDate(bsDate) {
|
|
179
|
+
return new Date(bsToAd(bsDate));
|
|
180
|
+
}
|
|
181
|
+
function adToBs(adDate) {
|
|
182
|
+
const startDate = new Date(AD_EPOCH);
|
|
183
|
+
const daysElapsed = Math.floor(
|
|
184
|
+
(adDate.getTime() - startDate.getTime()) / 864e5
|
|
185
|
+
);
|
|
186
|
+
let totalD = 0;
|
|
187
|
+
let year = 0;
|
|
188
|
+
let month = 0;
|
|
189
|
+
let day = 0;
|
|
190
|
+
let found = false;
|
|
191
|
+
for (let i = 2e3; i < 2100 && !found; i++) {
|
|
192
|
+
for (let j = 1; j <= 12; j++) {
|
|
193
|
+
totalD += BIKRAM_SAMBAT[i][j];
|
|
194
|
+
if (daysElapsed - totalD < 0) {
|
|
195
|
+
day = daysElapsed - totalD + BIKRAM_SAMBAT[i][j] + 1;
|
|
196
|
+
year = i;
|
|
197
|
+
month = j;
|
|
198
|
+
found = true;
|
|
199
|
+
break;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
return { year, month, day };
|
|
204
|
+
}
|
|
205
|
+
function todayBs() {
|
|
206
|
+
return adToBs(/* @__PURE__ */ new Date());
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
// src/utils.ts
|
|
210
|
+
function toNepaliDigits(value) {
|
|
211
|
+
return value.toString().split("").map((ch) => {
|
|
212
|
+
var _a;
|
|
213
|
+
return (_a = NEPALI_DIGITS[parseInt(ch)]) != null ? _a : ch;
|
|
214
|
+
}).join("");
|
|
215
|
+
}
|
|
216
|
+
function toEnglishDigits(value) {
|
|
217
|
+
return parseInt(
|
|
218
|
+
value.split("").map((ch) => {
|
|
219
|
+
const idx = NEPALI_DIGITS.indexOf(ch);
|
|
220
|
+
return idx >= 0 ? idx.toString() : ch;
|
|
221
|
+
}).join("")
|
|
222
|
+
);
|
|
223
|
+
}
|
|
224
|
+
function getMonthName(month, language) {
|
|
225
|
+
return language === "ne" ? MONTHS_NE[month - 1] : MONTHS_EN[month - 1];
|
|
226
|
+
}
|
|
227
|
+
function getDayLabel(dayIndex, language) {
|
|
228
|
+
return language === "ne" ? DAYS_SHORT_NE[dayIndex] : DAYS_SHORT_EN[dayIndex];
|
|
229
|
+
}
|
|
230
|
+
function formatBsDate(year, month, day, language = "en") {
|
|
231
|
+
if (language === "ne") {
|
|
232
|
+
return `${toNepaliDigits(year)}-${toNepaliDigits(month > 9 ? month : "0" + month)}-${toNepaliDigits(day > 9 ? day : "0" + day)}`;
|
|
233
|
+
}
|
|
234
|
+
return `${year}-${month > 9 ? month : "0" + month}-${day > 9 ? day : "0" + day}`;
|
|
235
|
+
}
|
|
236
|
+
function formatBsDatePattern(date, language = "en", pattern = "YYYY-MM-DD") {
|
|
237
|
+
const { year, month, day } = date;
|
|
238
|
+
const monthName = getMonthName(month, language);
|
|
239
|
+
const pad2 = (n) => n > 9 ? n : "0" + n;
|
|
240
|
+
if (language === "ne") {
|
|
241
|
+
switch (pattern) {
|
|
242
|
+
case "YYYY-MM-DD":
|
|
243
|
+
return `${toNepaliDigits(year)}-${toNepaliDigits(pad2(month))}-${toNepaliDigits(pad2(day))}`;
|
|
244
|
+
case "DD/MM/YYYY":
|
|
245
|
+
return `${toNepaliDigits(pad2(day))}/${toNepaliDigits(pad2(month))}/${toNepaliDigits(year)}`;
|
|
246
|
+
case "DD-MM-YYYY":
|
|
247
|
+
return `${toNepaliDigits(pad2(day))}-${toNepaliDigits(pad2(month))}-${toNepaliDigits(year)}`;
|
|
248
|
+
case "YYYY_MM_DD":
|
|
249
|
+
return `${toNepaliDigits(year)}_${toNepaliDigits(pad2(month))}_${toNepaliDigits(pad2(day))}`;
|
|
250
|
+
case "DD Month YYYY":
|
|
251
|
+
return `${toNepaliDigits(pad2(day))} ${monthName} ${toNepaliDigits(year)}`;
|
|
252
|
+
case "MMMM DD, YYYY":
|
|
253
|
+
return `${monthName} ${toNepaliDigits(pad2(day))}, ${toNepaliDigits(year)}`;
|
|
254
|
+
default:
|
|
255
|
+
return pattern.replace(/YYYY/g, toNepaliDigits(year)).replace(/MM/g, toNepaliDigits(pad2(month))).replace(/DD/g, toNepaliDigits(pad2(day))).replace(/M/g, toNepaliDigits(month)).replace(/D/g, toNepaliDigits(day));
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
switch (pattern) {
|
|
259
|
+
case "YYYY-MM-DD":
|
|
260
|
+
return `${year}-${pad2(month)}-${pad2(day)}`;
|
|
261
|
+
case "DD/MM/YYYY":
|
|
262
|
+
return `${pad2(day)}/${pad2(month)}/${year}`;
|
|
263
|
+
case "DD-MM-YYYY":
|
|
264
|
+
return `${pad2(day)}-${pad2(month)}-${year}`;
|
|
265
|
+
case "YYYY_MM_DD":
|
|
266
|
+
return `${year}_${pad2(month)}_${pad2(day)}`;
|
|
267
|
+
case "DD Month YYYY":
|
|
268
|
+
return `${pad2(day)} ${monthName} ${year}`;
|
|
269
|
+
case "MMMM DD, YYYY":
|
|
270
|
+
return `${monthName} ${pad2(day)}, ${year}`;
|
|
271
|
+
default:
|
|
272
|
+
return pattern.replace(/YYYY/g, String(year)).replace(/MM/g, String(pad2(month))).replace(/DD/g, String(pad2(day))).replace(/MMMM/g, monthName).replace(/M/g, String(month)).replace(/D/g, String(day));
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
function createDefaultFormatter() {
|
|
276
|
+
return {
|
|
277
|
+
format(date, language = "en", pattern = "YYYY-MM-DD") {
|
|
278
|
+
return formatBsDatePattern(date, language, pattern);
|
|
279
|
+
},
|
|
280
|
+
parse(value, _language = "en") {
|
|
281
|
+
const nepalDigits = /[०१२३४५६७८९]/;
|
|
282
|
+
if (nepalDigits.test(value)) {
|
|
283
|
+
const latin = value.split("").map((ch) => {
|
|
284
|
+
const idx = NEPALI_DIGITS.indexOf(ch);
|
|
285
|
+
return idx >= 0 ? String(idx) : ch;
|
|
286
|
+
}).join("");
|
|
287
|
+
const clean = latin.replace(/[^\d-]/g, "");
|
|
288
|
+
const parts2 = clean.split("-").filter(Boolean);
|
|
289
|
+
if (parts2.length === 3) {
|
|
290
|
+
const [y, m, d] = parts2.map(Number);
|
|
291
|
+
if (!isNaN(y) && !isNaN(m) && !isNaN(d)) return { year: y, month: m, day: d };
|
|
292
|
+
}
|
|
293
|
+
return null;
|
|
294
|
+
}
|
|
295
|
+
const cleaned = value.replace(/[^\d\-/.]/g, "");
|
|
296
|
+
const sep = cleaned.includes("/") ? "/" : cleaned.includes("-") ? "-" : null;
|
|
297
|
+
if (!sep) return null;
|
|
298
|
+
const parts = cleaned.split(sep).map((s) => {
|
|
299
|
+
const latin = s.split("").map((ch) => {
|
|
300
|
+
const idx = NEPALI_DIGITS.indexOf(ch);
|
|
301
|
+
return idx >= 0 ? String(idx) : ch;
|
|
302
|
+
}).join("");
|
|
303
|
+
return parseInt(latin, 10);
|
|
304
|
+
});
|
|
305
|
+
if (parts.length !== 3 || parts.some(isNaN)) return null;
|
|
306
|
+
if (parts[0] > 999) return { year: parts[0], month: parts[1], day: parts[2] };
|
|
307
|
+
return { year: parts[2], month: parts[1], day: parts[0] };
|
|
308
|
+
},
|
|
309
|
+
isValid(value, language = "en") {
|
|
310
|
+
var _a, _b;
|
|
311
|
+
const parsed = this.parse(value, language);
|
|
312
|
+
if (!parsed) return false;
|
|
313
|
+
if (parsed.year < 2e3 || parsed.year > 2099) return false;
|
|
314
|
+
if (parsed.month < 1 || parsed.month > 12) return false;
|
|
315
|
+
const dim = (_b = (_a = BIKRAM_SAMBAT[parsed.year]) == null ? void 0 : _a[parsed.month]) != null ? _b : 30;
|
|
316
|
+
return parsed.day >= 1 && parsed.day <= dim;
|
|
317
|
+
},
|
|
318
|
+
placeholder(language = "en", pattern = "YYYY-MM-DD") {
|
|
319
|
+
const demo = { year: 2081, month: 1, day: 15 };
|
|
320
|
+
return formatBsDatePattern(demo, language, pattern);
|
|
321
|
+
}
|
|
322
|
+
};
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
// src/calendar.ts
|
|
326
|
+
function getDaysInMonth(year, month) {
|
|
327
|
+
var _a, _b;
|
|
328
|
+
return (_b = (_a = BIKRAM_SAMBAT[year]) == null ? void 0 : _a[month]) != null ? _b : 30;
|
|
329
|
+
}
|
|
330
|
+
function isLeapYear(year) {
|
|
331
|
+
const days = BIKRAM_SAMBAT[year];
|
|
332
|
+
if (!days) return false;
|
|
333
|
+
const total = days.slice(1).reduce((sum, d) => sum + d, 0);
|
|
334
|
+
return total > 365;
|
|
335
|
+
}
|
|
336
|
+
function isValidBsYear(year) {
|
|
337
|
+
return year >= BS_START_YEAR && year <= BS_END_YEAR && BIKRAM_SAMBAT[year] !== void 0;
|
|
338
|
+
}
|
|
339
|
+
function isValidBsDate(date) {
|
|
340
|
+
if (!isValidBsYear(date.year)) return false;
|
|
341
|
+
if (date.month < 1 || date.month > 12) return false;
|
|
342
|
+
const dim = getDaysInMonth(date.year, date.month);
|
|
343
|
+
return date.day >= 1 && date.day <= dim;
|
|
344
|
+
}
|
|
345
|
+
function getBsWeekday(date) {
|
|
346
|
+
return bsToAdDate(date).getDay();
|
|
347
|
+
}
|
|
348
|
+
function getMonthData(year, month, selected, language = "en") {
|
|
349
|
+
const daysInMonth = getDaysInMonth(year, month);
|
|
350
|
+
const firstDayAD = bsToAdDate({ year, month, day: 1 });
|
|
351
|
+
const startWeekday = firstDayAD.getDay();
|
|
352
|
+
const today = todayBs();
|
|
353
|
+
const days = [
|
|
354
|
+
...Array(startWeekday).fill(null)
|
|
355
|
+
];
|
|
356
|
+
for (let d = 1; d <= daysInMonth; d++) {
|
|
357
|
+
const isSelected = selected !== null && selected.year === year && selected.month === month && selected.day === d;
|
|
358
|
+
const isToday = today.year === year && today.month === month && today.day === d;
|
|
359
|
+
days.push({
|
|
360
|
+
day: d,
|
|
361
|
+
isToday,
|
|
362
|
+
isSelected,
|
|
363
|
+
isDisabled: false,
|
|
364
|
+
adDate: bsToAdDate({ year, month, day: d })
|
|
365
|
+
});
|
|
366
|
+
}
|
|
367
|
+
const weekDays = language === "ne" ? DAYS_SHORT_NE : DAYS_SHORT_EN;
|
|
368
|
+
const months = language === "ne" ? MONTHS_NE : MONTHS_EN;
|
|
369
|
+
return {
|
|
370
|
+
year,
|
|
371
|
+
month,
|
|
372
|
+
days,
|
|
373
|
+
weekDays,
|
|
374
|
+
monthName: getMonthName(month, language),
|
|
375
|
+
allMonths: months
|
|
376
|
+
};
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
// src/theme.ts
|
|
380
|
+
var SIZE_PRESETS = {
|
|
381
|
+
sm: {
|
|
382
|
+
calendarWidth: 260,
|
|
383
|
+
dayCell: 30,
|
|
384
|
+
fontSize: 12,
|
|
385
|
+
headerFontSize: 13,
|
|
386
|
+
weekdayFontSize: 10,
|
|
387
|
+
inputPadding: "7px 10px",
|
|
388
|
+
calendarPadding: "8px"
|
|
389
|
+
},
|
|
390
|
+
md: {
|
|
391
|
+
calendarWidth: 320,
|
|
392
|
+
dayCell: 36,
|
|
393
|
+
fontSize: 13,
|
|
394
|
+
headerFontSize: 14,
|
|
395
|
+
weekdayFontSize: 11,
|
|
396
|
+
inputPadding: "10px 12px",
|
|
397
|
+
calendarPadding: "10px"
|
|
398
|
+
},
|
|
399
|
+
lg: {
|
|
400
|
+
calendarWidth: 380,
|
|
401
|
+
dayCell: 44,
|
|
402
|
+
fontSize: 15,
|
|
403
|
+
headerFontSize: 16,
|
|
404
|
+
weekdayFontSize: 12,
|
|
405
|
+
inputPadding: "12px 16px",
|
|
406
|
+
calendarPadding: "14px"
|
|
407
|
+
}
|
|
408
|
+
};
|
|
409
|
+
var DEFAULT_COLORS = {
|
|
410
|
+
primary: "#0d6efd",
|
|
411
|
+
primaryBg: "#ffffff",
|
|
412
|
+
todayBorder: "",
|
|
413
|
+
// falls back to primary when empty
|
|
414
|
+
background: "#ffffff",
|
|
415
|
+
surface: "#f9fafb",
|
|
416
|
+
border: "#e5e7eb",
|
|
417
|
+
text: "#111827",
|
|
418
|
+
muted: "#9ca3af",
|
|
419
|
+
accent: "#f3f4f6"
|
|
420
|
+
};
|
|
421
|
+
var DEFAULT_RADIUS = {
|
|
422
|
+
calendar: "8px",
|
|
423
|
+
input: "10px",
|
|
424
|
+
day: "8px",
|
|
425
|
+
select: "8px",
|
|
426
|
+
navBtn: "10px",
|
|
427
|
+
todayBtn: "8px"
|
|
428
|
+
};
|
|
429
|
+
var DEFAULT_NAV_ICONS = {
|
|
430
|
+
prev: "\u2039",
|
|
431
|
+
next: "\u203A"
|
|
432
|
+
};
|
|
433
|
+
var DEFAULT_CONFIG = {
|
|
434
|
+
size: "md",
|
|
435
|
+
sizeTokens: {},
|
|
436
|
+
colors: DEFAULT_COLORS,
|
|
437
|
+
radius: DEFAULT_RADIUS,
|
|
438
|
+
gridStyle: "borderless",
|
|
439
|
+
navIcons: DEFAULT_NAV_ICONS
|
|
440
|
+
};
|
|
441
|
+
function resolveConfig(config = {}) {
|
|
442
|
+
var _a, _b;
|
|
443
|
+
const tokens = __spreadValues(__spreadValues({}, SIZE_PRESETS[(_a = config.size) != null ? _a : "md"]), config.sizeTokens);
|
|
444
|
+
const colors = __spreadValues(__spreadValues({}, DEFAULT_COLORS), config.colors);
|
|
445
|
+
const radius = __spreadValues(__spreadValues({}, DEFAULT_RADIUS), config.radius);
|
|
446
|
+
return {
|
|
447
|
+
tokens,
|
|
448
|
+
colors,
|
|
449
|
+
radius,
|
|
450
|
+
gridStyle: (_b = config.gridStyle) != null ? _b : "borderless",
|
|
451
|
+
navIcons: __spreadValues(__spreadValues({}, DEFAULT_NAV_ICONS), config.navIcons)
|
|
452
|
+
};
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
|
|
456
|
+
|
|
457
|
+
|
|
458
|
+
|
|
459
|
+
|
|
460
|
+
|
|
461
|
+
|
|
462
|
+
|
|
463
|
+
|
|
464
|
+
|
|
465
|
+
|
|
466
|
+
|
|
467
|
+
|
|
468
|
+
|
|
469
|
+
|
|
470
|
+
|
|
471
|
+
|
|
472
|
+
|
|
473
|
+
|
|
474
|
+
|
|
475
|
+
|
|
476
|
+
|
|
477
|
+
|
|
478
|
+
|
|
479
|
+
|
|
480
|
+
|
|
481
|
+
|
|
482
|
+
|
|
483
|
+
|
|
484
|
+
|
|
485
|
+
|
|
486
|
+
|
|
487
|
+
exports.AD_EPOCH = AD_EPOCH; exports.BIKRAM_SAMBAT = BIKRAM_SAMBAT; exports.BS_END_YEAR = BS_END_YEAR; exports.BS_START_YEAR = BS_START_YEAR; exports.DAYS_SHORT_EN = DAYS_SHORT_EN; exports.DAYS_SHORT_NE = DAYS_SHORT_NE; exports.DEFAULT_COLORS = DEFAULT_COLORS; exports.DEFAULT_CONFIG = DEFAULT_CONFIG; exports.DEFAULT_NAV_ICONS = DEFAULT_NAV_ICONS; exports.DEFAULT_RADIUS = DEFAULT_RADIUS; exports.MONTHS_EN = MONTHS_EN; exports.MONTHS_NE = MONTHS_NE; exports.NEPALI_DIGITS = NEPALI_DIGITS; exports.SIZE_PRESETS = SIZE_PRESETS; exports.adToBs = adToBs; exports.bsToAd = bsToAd; exports.bsToAdDate = bsToAdDate; exports.createDefaultFormatter = createDefaultFormatter; exports.formatBsDate = formatBsDate; exports.formatBsDatePattern = formatBsDatePattern; exports.getBsWeekday = getBsWeekday; exports.getDayLabel = getDayLabel; exports.getDaysInMonth = getDaysInMonth; exports.getMonthData = getMonthData; exports.getMonthName = getMonthName; exports.isLeapYear = isLeapYear; exports.isValidBsDate = isValidBsDate; exports.isValidBsYear = isValidBsYear; exports.resolveConfig = resolveConfig; exports.toEnglishDigits = toEnglishDigits; exports.toNepaliDigits = toNepaliDigits; exports.todayBs = todayBs;
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
interface PatroJsDateProps {
|
|
2
|
+
year: number;
|
|
3
|
+
month: number;
|
|
4
|
+
day: number;
|
|
5
|
+
}
|
|
6
|
+
interface PatroJsDay {
|
|
7
|
+
day: number;
|
|
8
|
+
isToday: boolean;
|
|
9
|
+
isSelected: boolean;
|
|
10
|
+
isDisabled: boolean;
|
|
11
|
+
adDate: Date;
|
|
12
|
+
}
|
|
13
|
+
interface PatroJsMonth {
|
|
14
|
+
year: number;
|
|
15
|
+
month: number;
|
|
16
|
+
monthName: string;
|
|
17
|
+
weekDays: string[];
|
|
18
|
+
days: (PatroJsDay | null)[];
|
|
19
|
+
allMonths: string[];
|
|
20
|
+
}
|
|
21
|
+
type PatroJsFormatPattern = 'YYYY-MM-DD' | 'DD/MM/YYYY' | 'DD Month YYYY' | 'MMMM DD, YYYY' | 'YYYY_MM_DD' | 'DD-MM-YYYY' | (string & {});
|
|
22
|
+
interface PatroJsDateFormatter {
|
|
23
|
+
format(date: PatroJsDateProps, language: PatroJsLanguage, pattern?: PatroJsFormatPattern): string;
|
|
24
|
+
parse(value: string, language: PatroJsLanguage): PatroJsDateProps | null;
|
|
25
|
+
isValid(value: string, language: PatroJsLanguage): boolean;
|
|
26
|
+
placeholder(language: PatroJsLanguage, pattern?: PatroJsFormatPattern): string;
|
|
27
|
+
}
|
|
28
|
+
interface PatroJsAdapterFormatter {
|
|
29
|
+
name: string;
|
|
30
|
+
format: PatroJsDateFormatter['format'];
|
|
31
|
+
parse: PatroJsDateFormatter['parse'];
|
|
32
|
+
isValid: PatroJsDateFormatter['isValid'];
|
|
33
|
+
placeholder: PatroJsDateFormatter['placeholder'];
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
declare function toNepaliDigits(value: number | string): string;
|
|
37
|
+
declare function toEnglishDigits(value: string): number;
|
|
38
|
+
type PatroJsLanguage = 'en' | 'ne';
|
|
39
|
+
declare function getMonthName(month: number, language: PatroJsLanguage): string;
|
|
40
|
+
declare function getDayLabel(dayIndex: number, language: PatroJsLanguage): string;
|
|
41
|
+
declare function formatBsDate(year: number, month: number, day: number, language?: PatroJsLanguage): string;
|
|
42
|
+
declare function formatBsDatePattern(date: PatroJsDateProps, language?: PatroJsLanguage, pattern?: PatroJsFormatPattern): string;
|
|
43
|
+
declare function createDefaultFormatter(): {
|
|
44
|
+
format: (date: PatroJsDateProps, language?: PatroJsLanguage, pattern?: PatroJsFormatPattern) => string;
|
|
45
|
+
parse: (value: string, language?: PatroJsLanguage) => PatroJsDateProps | null;
|
|
46
|
+
isValid: (value: string, language?: PatroJsLanguage) => boolean;
|
|
47
|
+
placeholder: (language?: PatroJsLanguage, pattern?: PatroJsFormatPattern) => string;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
declare function getDaysInMonth(year: number, month: number): number;
|
|
51
|
+
declare function isLeapYear(year: number): boolean;
|
|
52
|
+
declare function isValidBsYear(year: number): boolean;
|
|
53
|
+
declare function isValidBsDate(date: PatroJsDateProps): boolean;
|
|
54
|
+
declare function getBsWeekday(date: PatroJsDateProps): number;
|
|
55
|
+
declare function getMonthData(year: number, month: number, selected: PatroJsDateProps | null, language?: PatroJsLanguage): PatroJsMonth;
|
|
56
|
+
|
|
57
|
+
declare function bsToAd(bsDate: PatroJsDateProps): string;
|
|
58
|
+
declare function bsToAdDate(bsDate: PatroJsDateProps): Date;
|
|
59
|
+
declare function adToBs(adDate: Date): PatroJsDateProps;
|
|
60
|
+
declare function todayBs(): PatroJsDateProps;
|
|
61
|
+
|
|
62
|
+
declare const BIKRAM_SAMBAT: Record<number, number[]>;
|
|
63
|
+
declare const AD_EPOCH = "1943-04-14";
|
|
64
|
+
declare const BS_START_YEAR = 2000;
|
|
65
|
+
declare const BS_END_YEAR = 2099;
|
|
66
|
+
declare const MONTHS_EN: string[];
|
|
67
|
+
declare const MONTHS_NE: string[];
|
|
68
|
+
declare const DAYS_SHORT_EN: string[];
|
|
69
|
+
declare const DAYS_SHORT_NE: string[];
|
|
70
|
+
declare const NEPALI_DIGITS: string[];
|
|
71
|
+
|
|
72
|
+
type PatroJsCalendarSize = 'sm' | 'md' | 'lg';
|
|
73
|
+
interface PatroJsSizeTokens {
|
|
74
|
+
calendarWidth: number;
|
|
75
|
+
dayCell: number;
|
|
76
|
+
fontSize: number;
|
|
77
|
+
headerFontSize: number;
|
|
78
|
+
weekdayFontSize: number;
|
|
79
|
+
inputPadding: string;
|
|
80
|
+
calendarPadding: string;
|
|
81
|
+
}
|
|
82
|
+
declare const SIZE_PRESETS: Record<PatroJsCalendarSize, PatroJsSizeTokens>;
|
|
83
|
+
interface ColorConfig {
|
|
84
|
+
primary?: string;
|
|
85
|
+
primaryBg?: string;
|
|
86
|
+
todayBorder?: string;
|
|
87
|
+
background?: string;
|
|
88
|
+
surface?: string;
|
|
89
|
+
border?: string;
|
|
90
|
+
text?: string;
|
|
91
|
+
muted?: string;
|
|
92
|
+
accent?: string;
|
|
93
|
+
}
|
|
94
|
+
declare const DEFAULT_COLORS: Required<ColorConfig>;
|
|
95
|
+
interface RadiusConfig {
|
|
96
|
+
calendar?: string;
|
|
97
|
+
input?: string;
|
|
98
|
+
day?: string;
|
|
99
|
+
select?: string;
|
|
100
|
+
navBtn?: string;
|
|
101
|
+
todayBtn?: string;
|
|
102
|
+
}
|
|
103
|
+
declare const DEFAULT_RADIUS: Required<RadiusConfig>;
|
|
104
|
+
type GridStyle = 'borderless' | 'bordered';
|
|
105
|
+
interface NavIconConfig {
|
|
106
|
+
prev?: string;
|
|
107
|
+
next?: string;
|
|
108
|
+
}
|
|
109
|
+
declare const DEFAULT_NAV_ICONS: Required<NavIconConfig>;
|
|
110
|
+
interface PatroJsPickerConfig {
|
|
111
|
+
size?: PatroJsCalendarSize;
|
|
112
|
+
sizeTokens?: Partial<PatroJsSizeTokens>;
|
|
113
|
+
colors?: ColorConfig;
|
|
114
|
+
radius?: RadiusConfig;
|
|
115
|
+
gridStyle?: GridStyle;
|
|
116
|
+
navIcons?: NavIconConfig;
|
|
117
|
+
}
|
|
118
|
+
declare const DEFAULT_CONFIG: Required<PatroJsPickerConfig>;
|
|
119
|
+
declare function resolveConfig(config?: PatroJsPickerConfig): {
|
|
120
|
+
tokens: PatroJsSizeTokens;
|
|
121
|
+
colors: Required<ColorConfig>;
|
|
122
|
+
radius: Required<RadiusConfig>;
|
|
123
|
+
gridStyle: GridStyle;
|
|
124
|
+
navIcons: Required<NavIconConfig>;
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
export { AD_EPOCH, BIKRAM_SAMBAT, BS_END_YEAR, BS_START_YEAR, type ColorConfig, DAYS_SHORT_EN, DAYS_SHORT_NE, DEFAULT_COLORS, DEFAULT_CONFIG, DEFAULT_NAV_ICONS, DEFAULT_RADIUS, type GridStyle, MONTHS_EN, MONTHS_NE, NEPALI_DIGITS, type NavIconConfig, type PatroJsAdapterFormatter, type PatroJsCalendarSize, type PatroJsDateFormatter, type PatroJsDateProps, type PatroJsDay, type PatroJsFormatPattern, type PatroJsLanguage, type PatroJsMonth, type PatroJsPickerConfig, type PatroJsSizeTokens, type RadiusConfig, SIZE_PRESETS, adToBs, bsToAd, bsToAdDate, createDefaultFormatter, formatBsDate, formatBsDatePattern, getBsWeekday, getDayLabel, getDaysInMonth, getMonthData, getMonthName, isLeapYear, isValidBsDate, isValidBsYear, resolveConfig, toEnglishDigits, toNepaliDigits, todayBs };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
interface PatroJsDateProps {
|
|
2
|
+
year: number;
|
|
3
|
+
month: number;
|
|
4
|
+
day: number;
|
|
5
|
+
}
|
|
6
|
+
interface PatroJsDay {
|
|
7
|
+
day: number;
|
|
8
|
+
isToday: boolean;
|
|
9
|
+
isSelected: boolean;
|
|
10
|
+
isDisabled: boolean;
|
|
11
|
+
adDate: Date;
|
|
12
|
+
}
|
|
13
|
+
interface PatroJsMonth {
|
|
14
|
+
year: number;
|
|
15
|
+
month: number;
|
|
16
|
+
monthName: string;
|
|
17
|
+
weekDays: string[];
|
|
18
|
+
days: (PatroJsDay | null)[];
|
|
19
|
+
allMonths: string[];
|
|
20
|
+
}
|
|
21
|
+
type PatroJsFormatPattern = 'YYYY-MM-DD' | 'DD/MM/YYYY' | 'DD Month YYYY' | 'MMMM DD, YYYY' | 'YYYY_MM_DD' | 'DD-MM-YYYY' | (string & {});
|
|
22
|
+
interface PatroJsDateFormatter {
|
|
23
|
+
format(date: PatroJsDateProps, language: PatroJsLanguage, pattern?: PatroJsFormatPattern): string;
|
|
24
|
+
parse(value: string, language: PatroJsLanguage): PatroJsDateProps | null;
|
|
25
|
+
isValid(value: string, language: PatroJsLanguage): boolean;
|
|
26
|
+
placeholder(language: PatroJsLanguage, pattern?: PatroJsFormatPattern): string;
|
|
27
|
+
}
|
|
28
|
+
interface PatroJsAdapterFormatter {
|
|
29
|
+
name: string;
|
|
30
|
+
format: PatroJsDateFormatter['format'];
|
|
31
|
+
parse: PatroJsDateFormatter['parse'];
|
|
32
|
+
isValid: PatroJsDateFormatter['isValid'];
|
|
33
|
+
placeholder: PatroJsDateFormatter['placeholder'];
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
declare function toNepaliDigits(value: number | string): string;
|
|
37
|
+
declare function toEnglishDigits(value: string): number;
|
|
38
|
+
type PatroJsLanguage = 'en' | 'ne';
|
|
39
|
+
declare function getMonthName(month: number, language: PatroJsLanguage): string;
|
|
40
|
+
declare function getDayLabel(dayIndex: number, language: PatroJsLanguage): string;
|
|
41
|
+
declare function formatBsDate(year: number, month: number, day: number, language?: PatroJsLanguage): string;
|
|
42
|
+
declare function formatBsDatePattern(date: PatroJsDateProps, language?: PatroJsLanguage, pattern?: PatroJsFormatPattern): string;
|
|
43
|
+
declare function createDefaultFormatter(): {
|
|
44
|
+
format: (date: PatroJsDateProps, language?: PatroJsLanguage, pattern?: PatroJsFormatPattern) => string;
|
|
45
|
+
parse: (value: string, language?: PatroJsLanguage) => PatroJsDateProps | null;
|
|
46
|
+
isValid: (value: string, language?: PatroJsLanguage) => boolean;
|
|
47
|
+
placeholder: (language?: PatroJsLanguage, pattern?: PatroJsFormatPattern) => string;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
declare function getDaysInMonth(year: number, month: number): number;
|
|
51
|
+
declare function isLeapYear(year: number): boolean;
|
|
52
|
+
declare function isValidBsYear(year: number): boolean;
|
|
53
|
+
declare function isValidBsDate(date: PatroJsDateProps): boolean;
|
|
54
|
+
declare function getBsWeekday(date: PatroJsDateProps): number;
|
|
55
|
+
declare function getMonthData(year: number, month: number, selected: PatroJsDateProps | null, language?: PatroJsLanguage): PatroJsMonth;
|
|
56
|
+
|
|
57
|
+
declare function bsToAd(bsDate: PatroJsDateProps): string;
|
|
58
|
+
declare function bsToAdDate(bsDate: PatroJsDateProps): Date;
|
|
59
|
+
declare function adToBs(adDate: Date): PatroJsDateProps;
|
|
60
|
+
declare function todayBs(): PatroJsDateProps;
|
|
61
|
+
|
|
62
|
+
declare const BIKRAM_SAMBAT: Record<number, number[]>;
|
|
63
|
+
declare const AD_EPOCH = "1943-04-14";
|
|
64
|
+
declare const BS_START_YEAR = 2000;
|
|
65
|
+
declare const BS_END_YEAR = 2099;
|
|
66
|
+
declare const MONTHS_EN: string[];
|
|
67
|
+
declare const MONTHS_NE: string[];
|
|
68
|
+
declare const DAYS_SHORT_EN: string[];
|
|
69
|
+
declare const DAYS_SHORT_NE: string[];
|
|
70
|
+
declare const NEPALI_DIGITS: string[];
|
|
71
|
+
|
|
72
|
+
type PatroJsCalendarSize = 'sm' | 'md' | 'lg';
|
|
73
|
+
interface PatroJsSizeTokens {
|
|
74
|
+
calendarWidth: number;
|
|
75
|
+
dayCell: number;
|
|
76
|
+
fontSize: number;
|
|
77
|
+
headerFontSize: number;
|
|
78
|
+
weekdayFontSize: number;
|
|
79
|
+
inputPadding: string;
|
|
80
|
+
calendarPadding: string;
|
|
81
|
+
}
|
|
82
|
+
declare const SIZE_PRESETS: Record<PatroJsCalendarSize, PatroJsSizeTokens>;
|
|
83
|
+
interface ColorConfig {
|
|
84
|
+
primary?: string;
|
|
85
|
+
primaryBg?: string;
|
|
86
|
+
todayBorder?: string;
|
|
87
|
+
background?: string;
|
|
88
|
+
surface?: string;
|
|
89
|
+
border?: string;
|
|
90
|
+
text?: string;
|
|
91
|
+
muted?: string;
|
|
92
|
+
accent?: string;
|
|
93
|
+
}
|
|
94
|
+
declare const DEFAULT_COLORS: Required<ColorConfig>;
|
|
95
|
+
interface RadiusConfig {
|
|
96
|
+
calendar?: string;
|
|
97
|
+
input?: string;
|
|
98
|
+
day?: string;
|
|
99
|
+
select?: string;
|
|
100
|
+
navBtn?: string;
|
|
101
|
+
todayBtn?: string;
|
|
102
|
+
}
|
|
103
|
+
declare const DEFAULT_RADIUS: Required<RadiusConfig>;
|
|
104
|
+
type GridStyle = 'borderless' | 'bordered';
|
|
105
|
+
interface NavIconConfig {
|
|
106
|
+
prev?: string;
|
|
107
|
+
next?: string;
|
|
108
|
+
}
|
|
109
|
+
declare const DEFAULT_NAV_ICONS: Required<NavIconConfig>;
|
|
110
|
+
interface PatroJsPickerConfig {
|
|
111
|
+
size?: PatroJsCalendarSize;
|
|
112
|
+
sizeTokens?: Partial<PatroJsSizeTokens>;
|
|
113
|
+
colors?: ColorConfig;
|
|
114
|
+
radius?: RadiusConfig;
|
|
115
|
+
gridStyle?: GridStyle;
|
|
116
|
+
navIcons?: NavIconConfig;
|
|
117
|
+
}
|
|
118
|
+
declare const DEFAULT_CONFIG: Required<PatroJsPickerConfig>;
|
|
119
|
+
declare function resolveConfig(config?: PatroJsPickerConfig): {
|
|
120
|
+
tokens: PatroJsSizeTokens;
|
|
121
|
+
colors: Required<ColorConfig>;
|
|
122
|
+
radius: Required<RadiusConfig>;
|
|
123
|
+
gridStyle: GridStyle;
|
|
124
|
+
navIcons: Required<NavIconConfig>;
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
export { AD_EPOCH, BIKRAM_SAMBAT, BS_END_YEAR, BS_START_YEAR, type ColorConfig, DAYS_SHORT_EN, DAYS_SHORT_NE, DEFAULT_COLORS, DEFAULT_CONFIG, DEFAULT_NAV_ICONS, DEFAULT_RADIUS, type GridStyle, MONTHS_EN, MONTHS_NE, NEPALI_DIGITS, type NavIconConfig, type PatroJsAdapterFormatter, type PatroJsCalendarSize, type PatroJsDateFormatter, type PatroJsDateProps, type PatroJsDay, type PatroJsFormatPattern, type PatroJsLanguage, type PatroJsMonth, type PatroJsPickerConfig, type PatroJsSizeTokens, type RadiusConfig, SIZE_PRESETS, adToBs, bsToAd, bsToAdDate, createDefaultFormatter, formatBsDate, formatBsDatePattern, getBsWeekday, getDayLabel, getDaysInMonth, getMonthData, getMonthName, isLeapYear, isValidBsDate, isValidBsYear, resolveConfig, toEnglishDigits, toNepaliDigits, todayBs };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,487 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
3
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
+
var __spreadValues = (a, b) => {
|
|
7
|
+
for (var prop in b || (b = {}))
|
|
8
|
+
if (__hasOwnProp.call(b, prop))
|
|
9
|
+
__defNormalProp(a, prop, b[prop]);
|
|
10
|
+
if (__getOwnPropSymbols)
|
|
11
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
12
|
+
if (__propIsEnum.call(b, prop))
|
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
|
14
|
+
}
|
|
15
|
+
return a;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
// src/data.ts
|
|
19
|
+
var BIKRAM_SAMBAT = {};
|
|
20
|
+
BIKRAM_SAMBAT[2e3] = [2e3, 30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31];
|
|
21
|
+
BIKRAM_SAMBAT[2001] = [2001, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30];
|
|
22
|
+
BIKRAM_SAMBAT[2002] = [2002, 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30];
|
|
23
|
+
BIKRAM_SAMBAT[2003] = [2003, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31];
|
|
24
|
+
BIKRAM_SAMBAT[2004] = [2004, 30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31];
|
|
25
|
+
BIKRAM_SAMBAT[2005] = [2005, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30];
|
|
26
|
+
BIKRAM_SAMBAT[2006] = [2006, 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30];
|
|
27
|
+
BIKRAM_SAMBAT[2007] = [2007, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31];
|
|
28
|
+
BIKRAM_SAMBAT[2008] = [2008, 31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 29, 31];
|
|
29
|
+
BIKRAM_SAMBAT[2009] = [2009, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30];
|
|
30
|
+
BIKRAM_SAMBAT[2010] = [2010, 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30];
|
|
31
|
+
BIKRAM_SAMBAT[2011] = [2011, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31];
|
|
32
|
+
BIKRAM_SAMBAT[2012] = [2012, 31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30];
|
|
33
|
+
BIKRAM_SAMBAT[2013] = [2013, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30];
|
|
34
|
+
BIKRAM_SAMBAT[2014] = [2014, 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30];
|
|
35
|
+
BIKRAM_SAMBAT[2015] = [2015, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31];
|
|
36
|
+
BIKRAM_SAMBAT[2016] = [2016, 31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30];
|
|
37
|
+
BIKRAM_SAMBAT[2017] = [2017, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30];
|
|
38
|
+
BIKRAM_SAMBAT[2018] = [2018, 31, 32, 31, 32, 31, 30, 30, 29, 30, 29, 30, 30];
|
|
39
|
+
BIKRAM_SAMBAT[2019] = [2019, 31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31];
|
|
40
|
+
BIKRAM_SAMBAT[2020] = [2020, 31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30];
|
|
41
|
+
BIKRAM_SAMBAT[2021] = [2021, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30];
|
|
42
|
+
BIKRAM_SAMBAT[2022] = [2022, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30];
|
|
43
|
+
BIKRAM_SAMBAT[2023] = [2023, 31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31];
|
|
44
|
+
BIKRAM_SAMBAT[2024] = [2024, 31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30];
|
|
45
|
+
BIKRAM_SAMBAT[2025] = [2025, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30];
|
|
46
|
+
BIKRAM_SAMBAT[2026] = [2026, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31];
|
|
47
|
+
BIKRAM_SAMBAT[2027] = [2027, 30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31];
|
|
48
|
+
BIKRAM_SAMBAT[2028] = [2028, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30];
|
|
49
|
+
BIKRAM_SAMBAT[2029] = [2029, 31, 31, 32, 31, 32, 30, 30, 29, 30, 29, 30, 30];
|
|
50
|
+
BIKRAM_SAMBAT[2030] = [2030, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31];
|
|
51
|
+
BIKRAM_SAMBAT[2031] = [2031, 30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31];
|
|
52
|
+
BIKRAM_SAMBAT[2032] = [2032, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30];
|
|
53
|
+
BIKRAM_SAMBAT[2033] = [2033, 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30];
|
|
54
|
+
BIKRAM_SAMBAT[2034] = [2034, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31];
|
|
55
|
+
BIKRAM_SAMBAT[2035] = [2035, 30, 32, 31, 32, 31, 31, 29, 30, 30, 29, 29, 31];
|
|
56
|
+
BIKRAM_SAMBAT[2036] = [2036, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30];
|
|
57
|
+
BIKRAM_SAMBAT[2037] = [2037, 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30];
|
|
58
|
+
BIKRAM_SAMBAT[2038] = [2038, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31];
|
|
59
|
+
BIKRAM_SAMBAT[2039] = [2039, 31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30];
|
|
60
|
+
BIKRAM_SAMBAT[2040] = [2040, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30];
|
|
61
|
+
BIKRAM_SAMBAT[2041] = [2041, 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30];
|
|
62
|
+
BIKRAM_SAMBAT[2042] = [2042, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31];
|
|
63
|
+
BIKRAM_SAMBAT[2043] = [2043, 31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30];
|
|
64
|
+
BIKRAM_SAMBAT[2044] = [2044, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30];
|
|
65
|
+
BIKRAM_SAMBAT[2045] = [2045, 31, 32, 31, 32, 31, 30, 30, 29, 30, 29, 30, 30];
|
|
66
|
+
BIKRAM_SAMBAT[2046] = [2046, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31];
|
|
67
|
+
BIKRAM_SAMBAT[2047] = [2047, 31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30];
|
|
68
|
+
BIKRAM_SAMBAT[2048] = [2048, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30];
|
|
69
|
+
BIKRAM_SAMBAT[2049] = [2049, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30];
|
|
70
|
+
BIKRAM_SAMBAT[2050] = [2050, 31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31];
|
|
71
|
+
BIKRAM_SAMBAT[2051] = [2051, 31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30];
|
|
72
|
+
BIKRAM_SAMBAT[2052] = [2052, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30];
|
|
73
|
+
BIKRAM_SAMBAT[2053] = [2053, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30];
|
|
74
|
+
BIKRAM_SAMBAT[2054] = [2054, 31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31];
|
|
75
|
+
BIKRAM_SAMBAT[2055] = [2055, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30];
|
|
76
|
+
BIKRAM_SAMBAT[2056] = [2056, 31, 31, 32, 31, 32, 30, 30, 29, 30, 29, 30, 30];
|
|
77
|
+
BIKRAM_SAMBAT[2057] = [2057, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31];
|
|
78
|
+
BIKRAM_SAMBAT[2058] = [2058, 30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31];
|
|
79
|
+
BIKRAM_SAMBAT[2059] = [2059, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30];
|
|
80
|
+
BIKRAM_SAMBAT[2060] = [2060, 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30];
|
|
81
|
+
BIKRAM_SAMBAT[2061] = [2061, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31];
|
|
82
|
+
BIKRAM_SAMBAT[2062] = [2062, 30, 32, 31, 32, 31, 31, 29, 30, 29, 30, 29, 31];
|
|
83
|
+
BIKRAM_SAMBAT[2063] = [2063, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30];
|
|
84
|
+
BIKRAM_SAMBAT[2064] = [2064, 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30];
|
|
85
|
+
BIKRAM_SAMBAT[2065] = [2065, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31];
|
|
86
|
+
BIKRAM_SAMBAT[2066] = [2066, 31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 29, 31];
|
|
87
|
+
BIKRAM_SAMBAT[2067] = [2067, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30];
|
|
88
|
+
BIKRAM_SAMBAT[2068] = [2068, 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30];
|
|
89
|
+
BIKRAM_SAMBAT[2069] = [2069, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31];
|
|
90
|
+
BIKRAM_SAMBAT[2070] = [2070, 31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30];
|
|
91
|
+
BIKRAM_SAMBAT[2071] = [2071, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30];
|
|
92
|
+
BIKRAM_SAMBAT[2072] = [2072, 31, 32, 31, 32, 31, 30, 30, 29, 30, 29, 30, 30];
|
|
93
|
+
BIKRAM_SAMBAT[2073] = [2073, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31];
|
|
94
|
+
BIKRAM_SAMBAT[2074] = [2074, 31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30];
|
|
95
|
+
BIKRAM_SAMBAT[2075] = [2075, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30];
|
|
96
|
+
BIKRAM_SAMBAT[2076] = [2076, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30];
|
|
97
|
+
BIKRAM_SAMBAT[2077] = [2077, 31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31];
|
|
98
|
+
BIKRAM_SAMBAT[2078] = [2078, 31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30];
|
|
99
|
+
BIKRAM_SAMBAT[2079] = [2079, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30];
|
|
100
|
+
BIKRAM_SAMBAT[2080] = [2080, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30];
|
|
101
|
+
BIKRAM_SAMBAT[2081] = [2081, 31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31];
|
|
102
|
+
BIKRAM_SAMBAT[2082] = [2082, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30];
|
|
103
|
+
BIKRAM_SAMBAT[2083] = [2083, 31, 31, 32, 31, 31, 30, 30, 30, 29, 30, 30, 30];
|
|
104
|
+
BIKRAM_SAMBAT[2084] = [2084, 31, 31, 32, 31, 31, 30, 30, 30, 29, 30, 30, 30];
|
|
105
|
+
BIKRAM_SAMBAT[2085] = [2085, 31, 32, 31, 32, 30, 31, 30, 30, 29, 30, 30, 30];
|
|
106
|
+
BIKRAM_SAMBAT[2086] = [2086, 30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30];
|
|
107
|
+
BIKRAM_SAMBAT[2087] = [2087, 31, 31, 32, 31, 31, 31, 30, 30, 29, 30, 30, 30];
|
|
108
|
+
BIKRAM_SAMBAT[2088] = [2088, 30, 31, 32, 32, 30, 31, 30, 30, 29, 30, 30, 30];
|
|
109
|
+
BIKRAM_SAMBAT[2089] = [2089, 30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30];
|
|
110
|
+
BIKRAM_SAMBAT[2090] = [2090, 30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30];
|
|
111
|
+
BIKRAM_SAMBAT[2091] = [2091, 31, 31, 32, 31, 31, 31, 30, 30, 29, 30, 30, 30];
|
|
112
|
+
BIKRAM_SAMBAT[2092] = [2092, 30, 31, 32, 32, 31, 30, 30, 30, 29, 30, 30, 30];
|
|
113
|
+
BIKRAM_SAMBAT[2093] = [2093, 30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30];
|
|
114
|
+
BIKRAM_SAMBAT[2094] = [2094, 31, 31, 32, 31, 31, 30, 30, 30, 29, 30, 30, 30];
|
|
115
|
+
BIKRAM_SAMBAT[2095] = [2095, 31, 31, 32, 31, 31, 31, 30, 29, 30, 30, 30, 30];
|
|
116
|
+
BIKRAM_SAMBAT[2096] = [2096, 30, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30];
|
|
117
|
+
BIKRAM_SAMBAT[2097] = [2097, 31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30];
|
|
118
|
+
BIKRAM_SAMBAT[2098] = [2098, 31, 31, 32, 31, 31, 31, 29, 30, 29, 30, 29, 31];
|
|
119
|
+
BIKRAM_SAMBAT[2099] = [2099, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31];
|
|
120
|
+
var AD_EPOCH = "1943-04-14";
|
|
121
|
+
var BS_START_YEAR = 2e3;
|
|
122
|
+
var BS_END_YEAR = 2099;
|
|
123
|
+
var MONTHS_EN = [
|
|
124
|
+
"Baishakh",
|
|
125
|
+
"Jestha",
|
|
126
|
+
"Ashad",
|
|
127
|
+
"Shrawan",
|
|
128
|
+
"Bhadra",
|
|
129
|
+
"Ashwin",
|
|
130
|
+
"Kartik",
|
|
131
|
+
"Mangsir",
|
|
132
|
+
"Poush",
|
|
133
|
+
"Magh",
|
|
134
|
+
"Falgun",
|
|
135
|
+
"Chaitra"
|
|
136
|
+
];
|
|
137
|
+
var MONTHS_NE = [
|
|
138
|
+
"\u092C\u0948\u0936\u093E\u0916",
|
|
139
|
+
"\u091C\u0947\u0920",
|
|
140
|
+
"\u0905\u0938\u093E\u0930",
|
|
141
|
+
"\u0936\u094D\u0930\u093E\u0935\u0923",
|
|
142
|
+
"\u092D\u0926\u094C",
|
|
143
|
+
"\u0905\u0938\u094B\u091C",
|
|
144
|
+
"\u0915\u093E\u0930\u094D\u0924\u093F\u0915",
|
|
145
|
+
"\u092E\u0902\u0938\u093F\u0930",
|
|
146
|
+
"\u092A\u0941\u0937",
|
|
147
|
+
"\u092E\u093E\u0918",
|
|
148
|
+
"\u092B\u093E\u0932\u094D\u0917\u0941\u0928",
|
|
149
|
+
"\u091A\u0948\u0924\u094D\u0930"
|
|
150
|
+
];
|
|
151
|
+
var DAYS_SHORT_EN = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
|
|
152
|
+
var DAYS_SHORT_NE = ["\u0906\u0907\u0924", "\u0938\u094B\u092E", "\u092E\u0902\u0917\u0932", "\u092C\u0941\u0927", "\u092C\u093F\u0939\u093F", "\u0936\u0941\u0915\u094D\u0930", "\u0936\u0928\u093F"];
|
|
153
|
+
var NEPALI_DIGITS = ["\u0966", "\u0967", "\u0968", "\u0969", "\u096A", "\u096B", "\u096C", "\u096D", "\u096E", "\u096F"];
|
|
154
|
+
|
|
155
|
+
// src/converter.ts
|
|
156
|
+
function bsToAd(bsDate) {
|
|
157
|
+
const { year, month, day } = bsDate;
|
|
158
|
+
let daysDiff = 0;
|
|
159
|
+
for (let i = 2e3; i <= year; i++) {
|
|
160
|
+
if (i === year) {
|
|
161
|
+
for (let j = 1; j < month; j++) {
|
|
162
|
+
daysDiff += BIKRAM_SAMBAT[i][j];
|
|
163
|
+
}
|
|
164
|
+
daysDiff += day - 1;
|
|
165
|
+
} else {
|
|
166
|
+
for (let j = 1; j <= 12; j++) {
|
|
167
|
+
daysDiff += BIKRAM_SAMBAT[i][j];
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
const result = new Date(AD_EPOCH);
|
|
172
|
+
result.setDate(result.getDate() + daysDiff);
|
|
173
|
+
const y = result.getFullYear();
|
|
174
|
+
const m = result.getMonth() + 1;
|
|
175
|
+
const d = result.getDate();
|
|
176
|
+
return `${y}-${m > 9 ? m : "0" + m}-${d > 9 ? d : "0" + d}`;
|
|
177
|
+
}
|
|
178
|
+
function bsToAdDate(bsDate) {
|
|
179
|
+
return new Date(bsToAd(bsDate));
|
|
180
|
+
}
|
|
181
|
+
function adToBs(adDate) {
|
|
182
|
+
const startDate = new Date(AD_EPOCH);
|
|
183
|
+
const daysElapsed = Math.floor(
|
|
184
|
+
(adDate.getTime() - startDate.getTime()) / 864e5
|
|
185
|
+
);
|
|
186
|
+
let totalD = 0;
|
|
187
|
+
let year = 0;
|
|
188
|
+
let month = 0;
|
|
189
|
+
let day = 0;
|
|
190
|
+
let found = false;
|
|
191
|
+
for (let i = 2e3; i < 2100 && !found; i++) {
|
|
192
|
+
for (let j = 1; j <= 12; j++) {
|
|
193
|
+
totalD += BIKRAM_SAMBAT[i][j];
|
|
194
|
+
if (daysElapsed - totalD < 0) {
|
|
195
|
+
day = daysElapsed - totalD + BIKRAM_SAMBAT[i][j] + 1;
|
|
196
|
+
year = i;
|
|
197
|
+
month = j;
|
|
198
|
+
found = true;
|
|
199
|
+
break;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
return { year, month, day };
|
|
204
|
+
}
|
|
205
|
+
function todayBs() {
|
|
206
|
+
return adToBs(/* @__PURE__ */ new Date());
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
// src/utils.ts
|
|
210
|
+
function toNepaliDigits(value) {
|
|
211
|
+
return value.toString().split("").map((ch) => {
|
|
212
|
+
var _a;
|
|
213
|
+
return (_a = NEPALI_DIGITS[parseInt(ch)]) != null ? _a : ch;
|
|
214
|
+
}).join("");
|
|
215
|
+
}
|
|
216
|
+
function toEnglishDigits(value) {
|
|
217
|
+
return parseInt(
|
|
218
|
+
value.split("").map((ch) => {
|
|
219
|
+
const idx = NEPALI_DIGITS.indexOf(ch);
|
|
220
|
+
return idx >= 0 ? idx.toString() : ch;
|
|
221
|
+
}).join("")
|
|
222
|
+
);
|
|
223
|
+
}
|
|
224
|
+
function getMonthName(month, language) {
|
|
225
|
+
return language === "ne" ? MONTHS_NE[month - 1] : MONTHS_EN[month - 1];
|
|
226
|
+
}
|
|
227
|
+
function getDayLabel(dayIndex, language) {
|
|
228
|
+
return language === "ne" ? DAYS_SHORT_NE[dayIndex] : DAYS_SHORT_EN[dayIndex];
|
|
229
|
+
}
|
|
230
|
+
function formatBsDate(year, month, day, language = "en") {
|
|
231
|
+
if (language === "ne") {
|
|
232
|
+
return `${toNepaliDigits(year)}-${toNepaliDigits(month > 9 ? month : "0" + month)}-${toNepaliDigits(day > 9 ? day : "0" + day)}`;
|
|
233
|
+
}
|
|
234
|
+
return `${year}-${month > 9 ? month : "0" + month}-${day > 9 ? day : "0" + day}`;
|
|
235
|
+
}
|
|
236
|
+
function formatBsDatePattern(date, language = "en", pattern = "YYYY-MM-DD") {
|
|
237
|
+
const { year, month, day } = date;
|
|
238
|
+
const monthName = getMonthName(month, language);
|
|
239
|
+
const pad2 = (n) => n > 9 ? n : "0" + n;
|
|
240
|
+
if (language === "ne") {
|
|
241
|
+
switch (pattern) {
|
|
242
|
+
case "YYYY-MM-DD":
|
|
243
|
+
return `${toNepaliDigits(year)}-${toNepaliDigits(pad2(month))}-${toNepaliDigits(pad2(day))}`;
|
|
244
|
+
case "DD/MM/YYYY":
|
|
245
|
+
return `${toNepaliDigits(pad2(day))}/${toNepaliDigits(pad2(month))}/${toNepaliDigits(year)}`;
|
|
246
|
+
case "DD-MM-YYYY":
|
|
247
|
+
return `${toNepaliDigits(pad2(day))}-${toNepaliDigits(pad2(month))}-${toNepaliDigits(year)}`;
|
|
248
|
+
case "YYYY_MM_DD":
|
|
249
|
+
return `${toNepaliDigits(year)}_${toNepaliDigits(pad2(month))}_${toNepaliDigits(pad2(day))}`;
|
|
250
|
+
case "DD Month YYYY":
|
|
251
|
+
return `${toNepaliDigits(pad2(day))} ${monthName} ${toNepaliDigits(year)}`;
|
|
252
|
+
case "MMMM DD, YYYY":
|
|
253
|
+
return `${monthName} ${toNepaliDigits(pad2(day))}, ${toNepaliDigits(year)}`;
|
|
254
|
+
default:
|
|
255
|
+
return pattern.replace(/YYYY/g, toNepaliDigits(year)).replace(/MM/g, toNepaliDigits(pad2(month))).replace(/DD/g, toNepaliDigits(pad2(day))).replace(/M/g, toNepaliDigits(month)).replace(/D/g, toNepaliDigits(day));
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
switch (pattern) {
|
|
259
|
+
case "YYYY-MM-DD":
|
|
260
|
+
return `${year}-${pad2(month)}-${pad2(day)}`;
|
|
261
|
+
case "DD/MM/YYYY":
|
|
262
|
+
return `${pad2(day)}/${pad2(month)}/${year}`;
|
|
263
|
+
case "DD-MM-YYYY":
|
|
264
|
+
return `${pad2(day)}-${pad2(month)}-${year}`;
|
|
265
|
+
case "YYYY_MM_DD":
|
|
266
|
+
return `${year}_${pad2(month)}_${pad2(day)}`;
|
|
267
|
+
case "DD Month YYYY":
|
|
268
|
+
return `${pad2(day)} ${monthName} ${year}`;
|
|
269
|
+
case "MMMM DD, YYYY":
|
|
270
|
+
return `${monthName} ${pad2(day)}, ${year}`;
|
|
271
|
+
default:
|
|
272
|
+
return pattern.replace(/YYYY/g, String(year)).replace(/MM/g, String(pad2(month))).replace(/DD/g, String(pad2(day))).replace(/MMMM/g, monthName).replace(/M/g, String(month)).replace(/D/g, String(day));
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
function createDefaultFormatter() {
|
|
276
|
+
return {
|
|
277
|
+
format(date, language = "en", pattern = "YYYY-MM-DD") {
|
|
278
|
+
return formatBsDatePattern(date, language, pattern);
|
|
279
|
+
},
|
|
280
|
+
parse(value, _language = "en") {
|
|
281
|
+
const nepalDigits = /[०१२३४५६७८९]/;
|
|
282
|
+
if (nepalDigits.test(value)) {
|
|
283
|
+
const latin = value.split("").map((ch) => {
|
|
284
|
+
const idx = NEPALI_DIGITS.indexOf(ch);
|
|
285
|
+
return idx >= 0 ? String(idx) : ch;
|
|
286
|
+
}).join("");
|
|
287
|
+
const clean = latin.replace(/[^\d-]/g, "");
|
|
288
|
+
const parts2 = clean.split("-").filter(Boolean);
|
|
289
|
+
if (parts2.length === 3) {
|
|
290
|
+
const [y, m, d] = parts2.map(Number);
|
|
291
|
+
if (!isNaN(y) && !isNaN(m) && !isNaN(d)) return { year: y, month: m, day: d };
|
|
292
|
+
}
|
|
293
|
+
return null;
|
|
294
|
+
}
|
|
295
|
+
const cleaned = value.replace(/[^\d\-/.]/g, "");
|
|
296
|
+
const sep = cleaned.includes("/") ? "/" : cleaned.includes("-") ? "-" : null;
|
|
297
|
+
if (!sep) return null;
|
|
298
|
+
const parts = cleaned.split(sep).map((s) => {
|
|
299
|
+
const latin = s.split("").map((ch) => {
|
|
300
|
+
const idx = NEPALI_DIGITS.indexOf(ch);
|
|
301
|
+
return idx >= 0 ? String(idx) : ch;
|
|
302
|
+
}).join("");
|
|
303
|
+
return parseInt(latin, 10);
|
|
304
|
+
});
|
|
305
|
+
if (parts.length !== 3 || parts.some(isNaN)) return null;
|
|
306
|
+
if (parts[0] > 999) return { year: parts[0], month: parts[1], day: parts[2] };
|
|
307
|
+
return { year: parts[2], month: parts[1], day: parts[0] };
|
|
308
|
+
},
|
|
309
|
+
isValid(value, language = "en") {
|
|
310
|
+
var _a, _b;
|
|
311
|
+
const parsed = this.parse(value, language);
|
|
312
|
+
if (!parsed) return false;
|
|
313
|
+
if (parsed.year < 2e3 || parsed.year > 2099) return false;
|
|
314
|
+
if (parsed.month < 1 || parsed.month > 12) return false;
|
|
315
|
+
const dim = (_b = (_a = BIKRAM_SAMBAT[parsed.year]) == null ? void 0 : _a[parsed.month]) != null ? _b : 30;
|
|
316
|
+
return parsed.day >= 1 && parsed.day <= dim;
|
|
317
|
+
},
|
|
318
|
+
placeholder(language = "en", pattern = "YYYY-MM-DD") {
|
|
319
|
+
const demo = { year: 2081, month: 1, day: 15 };
|
|
320
|
+
return formatBsDatePattern(demo, language, pattern);
|
|
321
|
+
}
|
|
322
|
+
};
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
// src/calendar.ts
|
|
326
|
+
function getDaysInMonth(year, month) {
|
|
327
|
+
var _a, _b;
|
|
328
|
+
return (_b = (_a = BIKRAM_SAMBAT[year]) == null ? void 0 : _a[month]) != null ? _b : 30;
|
|
329
|
+
}
|
|
330
|
+
function isLeapYear(year) {
|
|
331
|
+
const days = BIKRAM_SAMBAT[year];
|
|
332
|
+
if (!days) return false;
|
|
333
|
+
const total = days.slice(1).reduce((sum, d) => sum + d, 0);
|
|
334
|
+
return total > 365;
|
|
335
|
+
}
|
|
336
|
+
function isValidBsYear(year) {
|
|
337
|
+
return year >= BS_START_YEAR && year <= BS_END_YEAR && BIKRAM_SAMBAT[year] !== void 0;
|
|
338
|
+
}
|
|
339
|
+
function isValidBsDate(date) {
|
|
340
|
+
if (!isValidBsYear(date.year)) return false;
|
|
341
|
+
if (date.month < 1 || date.month > 12) return false;
|
|
342
|
+
const dim = getDaysInMonth(date.year, date.month);
|
|
343
|
+
return date.day >= 1 && date.day <= dim;
|
|
344
|
+
}
|
|
345
|
+
function getBsWeekday(date) {
|
|
346
|
+
return bsToAdDate(date).getDay();
|
|
347
|
+
}
|
|
348
|
+
function getMonthData(year, month, selected, language = "en") {
|
|
349
|
+
const daysInMonth = getDaysInMonth(year, month);
|
|
350
|
+
const firstDayAD = bsToAdDate({ year, month, day: 1 });
|
|
351
|
+
const startWeekday = firstDayAD.getDay();
|
|
352
|
+
const today = todayBs();
|
|
353
|
+
const days = [
|
|
354
|
+
...Array(startWeekday).fill(null)
|
|
355
|
+
];
|
|
356
|
+
for (let d = 1; d <= daysInMonth; d++) {
|
|
357
|
+
const isSelected = selected !== null && selected.year === year && selected.month === month && selected.day === d;
|
|
358
|
+
const isToday = today.year === year && today.month === month && today.day === d;
|
|
359
|
+
days.push({
|
|
360
|
+
day: d,
|
|
361
|
+
isToday,
|
|
362
|
+
isSelected,
|
|
363
|
+
isDisabled: false,
|
|
364
|
+
adDate: bsToAdDate({ year, month, day: d })
|
|
365
|
+
});
|
|
366
|
+
}
|
|
367
|
+
const weekDays = language === "ne" ? DAYS_SHORT_NE : DAYS_SHORT_EN;
|
|
368
|
+
const months = language === "ne" ? MONTHS_NE : MONTHS_EN;
|
|
369
|
+
return {
|
|
370
|
+
year,
|
|
371
|
+
month,
|
|
372
|
+
days,
|
|
373
|
+
weekDays,
|
|
374
|
+
monthName: getMonthName(month, language),
|
|
375
|
+
allMonths: months
|
|
376
|
+
};
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
// src/theme.ts
|
|
380
|
+
var SIZE_PRESETS = {
|
|
381
|
+
sm: {
|
|
382
|
+
calendarWidth: 260,
|
|
383
|
+
dayCell: 30,
|
|
384
|
+
fontSize: 12,
|
|
385
|
+
headerFontSize: 13,
|
|
386
|
+
weekdayFontSize: 10,
|
|
387
|
+
inputPadding: "7px 10px",
|
|
388
|
+
calendarPadding: "8px"
|
|
389
|
+
},
|
|
390
|
+
md: {
|
|
391
|
+
calendarWidth: 320,
|
|
392
|
+
dayCell: 36,
|
|
393
|
+
fontSize: 13,
|
|
394
|
+
headerFontSize: 14,
|
|
395
|
+
weekdayFontSize: 11,
|
|
396
|
+
inputPadding: "10px 12px",
|
|
397
|
+
calendarPadding: "10px"
|
|
398
|
+
},
|
|
399
|
+
lg: {
|
|
400
|
+
calendarWidth: 380,
|
|
401
|
+
dayCell: 44,
|
|
402
|
+
fontSize: 15,
|
|
403
|
+
headerFontSize: 16,
|
|
404
|
+
weekdayFontSize: 12,
|
|
405
|
+
inputPadding: "12px 16px",
|
|
406
|
+
calendarPadding: "14px"
|
|
407
|
+
}
|
|
408
|
+
};
|
|
409
|
+
var DEFAULT_COLORS = {
|
|
410
|
+
primary: "#0d6efd",
|
|
411
|
+
primaryBg: "#ffffff",
|
|
412
|
+
todayBorder: "",
|
|
413
|
+
// falls back to primary when empty
|
|
414
|
+
background: "#ffffff",
|
|
415
|
+
surface: "#f9fafb",
|
|
416
|
+
border: "#e5e7eb",
|
|
417
|
+
text: "#111827",
|
|
418
|
+
muted: "#9ca3af",
|
|
419
|
+
accent: "#f3f4f6"
|
|
420
|
+
};
|
|
421
|
+
var DEFAULT_RADIUS = {
|
|
422
|
+
calendar: "8px",
|
|
423
|
+
input: "10px",
|
|
424
|
+
day: "8px",
|
|
425
|
+
select: "8px",
|
|
426
|
+
navBtn: "10px",
|
|
427
|
+
todayBtn: "8px"
|
|
428
|
+
};
|
|
429
|
+
var DEFAULT_NAV_ICONS = {
|
|
430
|
+
prev: "\u2039",
|
|
431
|
+
next: "\u203A"
|
|
432
|
+
};
|
|
433
|
+
var DEFAULT_CONFIG = {
|
|
434
|
+
size: "md",
|
|
435
|
+
sizeTokens: {},
|
|
436
|
+
colors: DEFAULT_COLORS,
|
|
437
|
+
radius: DEFAULT_RADIUS,
|
|
438
|
+
gridStyle: "borderless",
|
|
439
|
+
navIcons: DEFAULT_NAV_ICONS
|
|
440
|
+
};
|
|
441
|
+
function resolveConfig(config = {}) {
|
|
442
|
+
var _a, _b;
|
|
443
|
+
const tokens = __spreadValues(__spreadValues({}, SIZE_PRESETS[(_a = config.size) != null ? _a : "md"]), config.sizeTokens);
|
|
444
|
+
const colors = __spreadValues(__spreadValues({}, DEFAULT_COLORS), config.colors);
|
|
445
|
+
const radius = __spreadValues(__spreadValues({}, DEFAULT_RADIUS), config.radius);
|
|
446
|
+
return {
|
|
447
|
+
tokens,
|
|
448
|
+
colors,
|
|
449
|
+
radius,
|
|
450
|
+
gridStyle: (_b = config.gridStyle) != null ? _b : "borderless",
|
|
451
|
+
navIcons: __spreadValues(__spreadValues({}, DEFAULT_NAV_ICONS), config.navIcons)
|
|
452
|
+
};
|
|
453
|
+
}
|
|
454
|
+
export {
|
|
455
|
+
AD_EPOCH,
|
|
456
|
+
BIKRAM_SAMBAT,
|
|
457
|
+
BS_END_YEAR,
|
|
458
|
+
BS_START_YEAR,
|
|
459
|
+
DAYS_SHORT_EN,
|
|
460
|
+
DAYS_SHORT_NE,
|
|
461
|
+
DEFAULT_COLORS,
|
|
462
|
+
DEFAULT_CONFIG,
|
|
463
|
+
DEFAULT_NAV_ICONS,
|
|
464
|
+
DEFAULT_RADIUS,
|
|
465
|
+
MONTHS_EN,
|
|
466
|
+
MONTHS_NE,
|
|
467
|
+
NEPALI_DIGITS,
|
|
468
|
+
SIZE_PRESETS,
|
|
469
|
+
adToBs,
|
|
470
|
+
bsToAd,
|
|
471
|
+
bsToAdDate,
|
|
472
|
+
createDefaultFormatter,
|
|
473
|
+
formatBsDate,
|
|
474
|
+
formatBsDatePattern,
|
|
475
|
+
getBsWeekday,
|
|
476
|
+
getDayLabel,
|
|
477
|
+
getDaysInMonth,
|
|
478
|
+
getMonthData,
|
|
479
|
+
getMonthName,
|
|
480
|
+
isLeapYear,
|
|
481
|
+
isValidBsDate,
|
|
482
|
+
isValidBsYear,
|
|
483
|
+
resolveConfig,
|
|
484
|
+
toEnglishDigits,
|
|
485
|
+
toNepaliDigits,
|
|
486
|
+
todayBs
|
|
487
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@patrojs/core",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./dist/index.cjs",
|
|
6
|
+
"module": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js",
|
|
12
|
+
"require": "./dist/index.cjs"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": ["dist"],
|
|
16
|
+
"scripts": {
|
|
17
|
+
"build": "tsup",
|
|
18
|
+
"clean": "rm -rf dist",
|
|
19
|
+
"prepublishOnly": "pnpm build",
|
|
20
|
+
"test": "vitest run",
|
|
21
|
+
"test:watch": "vitest"
|
|
22
|
+
},
|
|
23
|
+
"repository": {
|
|
24
|
+
"type": "git",
|
|
25
|
+
"url": "https://github.com/lizuzsusil/patrojs.git",
|
|
26
|
+
"directory": "packages/core"
|
|
27
|
+
},
|
|
28
|
+
"bugs": {
|
|
29
|
+
"url": "https://github.com/lizuzsusil/patrojs/issues"
|
|
30
|
+
},
|
|
31
|
+
"homepage": "https://github.com/lizuzsusil/patrojs#readme",
|
|
32
|
+
"publishConfig": {
|
|
33
|
+
"access": "public"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"tsup": "^8.0.0",
|
|
37
|
+
"typescript": "^5.0.0",
|
|
38
|
+
"vitest": "^4.1.9"
|
|
39
|
+
}
|
|
40
|
+
}
|