@f1softinternational/f1-nepali-date-picker 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.
@@ -0,0 +1,871 @@
1
+ import * as i0 from '@angular/core';
2
+ import { Injectable, EventEmitter, forwardRef, Component, ChangeDetectionStrategy, Input, Output, HostListener, NgModule } from '@angular/core';
3
+ import * as i2 from '@angular/common';
4
+ import { CommonModule } from '@angular/common';
5
+ import * as i3 from '@angular/forms';
6
+ import { NG_VALUE_ACCESSOR, FormsModule } from '@angular/forms';
7
+
8
+ /**
9
+ * Bikram Sambat Calendar Data
10
+ * Contains month days mapping for each BS year and localization strings
11
+ */
12
+ /**
13
+ * BS Year to Month Days Mapping
14
+ * Each entry: [year]: [days in each month from Baisakh to Chaitra]
15
+ * Data range: 2000 BS to 2090 BS
16
+ */
17
+ const BS_CALENDAR_DATA = {
18
+ 2000: [30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31],
19
+ 2001: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
20
+ 2002: [31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30],
21
+ 2003: [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
22
+ 2004: [30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31],
23
+ 2005: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
24
+ 2006: [31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30],
25
+ 2007: [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
26
+ 2008: [31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 29, 31],
27
+ 2009: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
28
+ 2010: [31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30],
29
+ 2011: [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
30
+ 2012: [31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30],
31
+ 2013: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
32
+ 2014: [31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30],
33
+ 2015: [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
34
+ 2016: [31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30],
35
+ 2017: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
36
+ 2018: [31, 32, 31, 32, 31, 30, 30, 29, 30, 29, 30, 30],
37
+ 2019: [31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31],
38
+ 2020: [31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30],
39
+ 2021: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
40
+ 2022: [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30],
41
+ 2023: [31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31],
42
+ 2024: [31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30],
43
+ 2025: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
44
+ 2026: [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
45
+ 2027: [30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31],
46
+ 2028: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
47
+ 2029: [31, 31, 32, 31, 32, 30, 30, 29, 30, 29, 30, 30],
48
+ 2030: [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
49
+ 2031: [30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31],
50
+ 2032: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
51
+ 2033: [31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30],
52
+ 2034: [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
53
+ 2035: [30, 32, 31, 32, 31, 31, 29, 30, 30, 29, 29, 31],
54
+ 2036: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
55
+ 2037: [31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30],
56
+ 2038: [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
57
+ 2039: [31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30],
58
+ 2040: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
59
+ 2041: [31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30],
60
+ 2042: [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
61
+ 2043: [31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30],
62
+ 2044: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
63
+ 2045: [31, 32, 31, 32, 31, 30, 30, 29, 30, 29, 30, 30],
64
+ 2046: [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
65
+ 2047: [31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30],
66
+ 2048: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
67
+ 2049: [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30],
68
+ 2050: [31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31],
69
+ 2051: [31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30],
70
+ 2052: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
71
+ 2053: [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30],
72
+ 2054: [31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31],
73
+ 2055: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
74
+ 2056: [31, 31, 32, 31, 32, 30, 30, 29, 30, 29, 30, 30],
75
+ 2057: [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
76
+ 2058: [30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31],
77
+ 2059: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
78
+ 2060: [31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30],
79
+ 2061: [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
80
+ 2062: [30, 32, 31, 32, 31, 31, 29, 30, 29, 30, 29, 31],
81
+ 2063: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
82
+ 2064: [31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30],
83
+ 2065: [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
84
+ 2066: [31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 29, 31],
85
+ 2067: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
86
+ 2068: [31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30],
87
+ 2069: [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
88
+ 2070: [31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30],
89
+ 2071: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
90
+ 2072: [31, 32, 31, 32, 31, 30, 30, 29, 30, 29, 30, 30],
91
+ 2073: [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
92
+ 2074: [31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30],
93
+ 2075: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
94
+ 2076: [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30],
95
+ 2077: [31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31],
96
+ 2078: [31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30],
97
+ 2079: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
98
+ 2080: [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30],
99
+ 2081: [31, 31, 32, 32, 31, 30, 30, 30, 29, 30, 30, 30],
100
+ 2082: [30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30],
101
+ 2083: [31, 31, 32, 31, 31, 30, 30, 30, 29, 30, 30, 30],
102
+ 2084: [31, 31, 32, 31, 31, 30, 30, 30, 29, 30, 30, 30],
103
+ 2085: [31, 32, 31, 32, 30, 31, 30, 30, 29, 30, 30, 30],
104
+ 2086: [30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30],
105
+ 2087: [31, 31, 32, 31, 31, 31, 30, 30, 29, 30, 30, 30],
106
+ 2088: [30, 31, 32, 32, 30, 31, 30, 30, 29, 30, 30, 30],
107
+ 2089: [30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30],
108
+ 2090: [30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30],
109
+ };
110
+ /**
111
+ * Nepali month names
112
+ */
113
+ const BS_MONTHS_NP = [
114
+ 'बैशाख',
115
+ 'जेठ',
116
+ 'असार',
117
+ 'श्रावण',
118
+ 'भदौ',
119
+ 'आश्विन',
120
+ 'कार्तिक',
121
+ 'मंसिर',
122
+ 'पौष',
123
+ 'माघ',
124
+ 'फाल्गुन',
125
+ 'चैत्र',
126
+ ];
127
+ /**
128
+ * English month names (Romanized)
129
+ */
130
+ const BS_MONTHS_EN = [
131
+ 'Baisakh',
132
+ 'Jestha',
133
+ 'Ashar',
134
+ 'Shrawan',
135
+ 'Bhadra',
136
+ 'Ashwin',
137
+ 'Kartik',
138
+ 'Mangsir',
139
+ 'Poush',
140
+ 'Magh',
141
+ 'Falgun',
142
+ 'Chaitra',
143
+ ];
144
+ /**
145
+ * Nepali weekday names (Sunday first)
146
+ */
147
+ const BS_WEEKDAYS_NP = ['आइत', 'सोम', 'मंगल', 'बुध', 'बिही', 'शुक्र', 'शनि'];
148
+ /**
149
+ * English weekday names (Sunday first)
150
+ */
151
+ const BS_WEEKDAYS_EN = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
152
+ /**
153
+ * Nepali numerals mapping
154
+ */
155
+ const NEPALI_DIGITS = ['०', '१', '२', '३', '४', '५', '६', '७', '८', '९'];
156
+ /**
157
+ * Reference date for conversion calculations
158
+ * BS: 2000-01-01 corresponds to AD: 1943-04-14
159
+ */
160
+ const BS_EPOCH = {
161
+ year: 2000,
162
+ month: 1,
163
+ day: 1,
164
+ };
165
+ const AD_EPOCH = new Date(1943, 3, 14); // April 14, 1943
166
+ /**
167
+ * Get minimum supported BS year
168
+ */
169
+ const BS_MIN_YEAR = Math.min(...Object.keys(BS_CALENDAR_DATA).map(Number));
170
+ /**
171
+ * Get maximum supported BS year
172
+ */
173
+ const BS_MAX_YEAR = Math.max(...Object.keys(BS_CALENDAR_DATA).map(Number));
174
+ /**
175
+ * Convert number to Nepali digits
176
+ */
177
+ function toNepaliDigits(num) {
178
+ return String(num)
179
+ .split('')
180
+ .map((char) => {
181
+ const digit = parseInt(char, 10);
182
+ return isNaN(digit) ? char : NEPALI_DIGITS[digit];
183
+ })
184
+ .join('');
185
+ }
186
+ /**
187
+ * Get total days in a BS year
188
+ */
189
+ function getTotalDaysInBSYear(year) {
190
+ const monthDays = BS_CALENDAR_DATA[year];
191
+ if (!monthDays) {
192
+ throw new Error(`Year ${year} is out of supported range (${BS_MIN_YEAR}-${BS_MAX_YEAR})`);
193
+ }
194
+ return monthDays.reduce((sum, days) => sum + days, 0);
195
+ }
196
+ /**
197
+ * Get days in a specific BS month
198
+ */
199
+ function getDaysInBSMonth(year, month) {
200
+ const monthDays = BS_CALENDAR_DATA[year];
201
+ if (!monthDays) {
202
+ throw new Error(`Year ${year} is out of supported range (${BS_MIN_YEAR}-${BS_MAX_YEAR})`);
203
+ }
204
+ if (month < 1 || month > 12) {
205
+ throw new Error(`Month ${month} is invalid. Must be between 1 and 12.`);
206
+ }
207
+ return monthDays[month - 1];
208
+ }
209
+
210
+ /**
211
+ * NepaliDate - Represents a date in the Bikram Sambat (BS) calendar
212
+ */
213
+ class NepaliDate {
214
+ constructor(year, month, day) {
215
+ this._year = year;
216
+ this._month = month;
217
+ this._day = day;
218
+ }
219
+ // Getters
220
+ get year() {
221
+ return this._year;
222
+ }
223
+ get month() {
224
+ return this._month;
225
+ }
226
+ get day() {
227
+ return this._day;
228
+ }
229
+ /**
230
+ * Create NepaliDate from current date
231
+ */
232
+ static today() {
233
+ return NepaliDate.fromAD(new Date());
234
+ }
235
+ /**
236
+ * Create NepaliDate from AD Date
237
+ */
238
+ static fromAD(adDate) {
239
+ // Calculate days from epoch
240
+ const epochTime = AD_EPOCH.getTime();
241
+ const targetTime = new Date(adDate.getFullYear(), adDate.getMonth(), adDate.getDate()).getTime();
242
+ let daysDiff = Math.floor((targetTime - epochTime) / (1000 * 60 * 60 * 24));
243
+ if (daysDiff < 0) {
244
+ throw new Error('Date is before supported range');
245
+ }
246
+ let bsYear = BS_EPOCH.year;
247
+ let bsMonth = BS_EPOCH.month;
248
+ let bsDay = BS_EPOCH.day;
249
+ // Add days
250
+ while (daysDiff > 0) {
251
+ const daysInMonth = getDaysInBSMonth(bsYear, bsMonth);
252
+ const daysRemainingInMonth = daysInMonth - bsDay;
253
+ if (daysDiff <= daysRemainingInMonth) {
254
+ bsDay += daysDiff;
255
+ daysDiff = 0;
256
+ }
257
+ else {
258
+ daysDiff -= daysRemainingInMonth + 1;
259
+ bsMonth++;
260
+ bsDay = 1;
261
+ if (bsMonth > 12) {
262
+ bsMonth = 1;
263
+ bsYear++;
264
+ if (bsYear > BS_MAX_YEAR) {
265
+ throw new Error(`Date exceeds supported range (max: ${BS_MAX_YEAR} BS)`);
266
+ }
267
+ }
268
+ }
269
+ }
270
+ return new NepaliDate(bsYear, bsMonth, bsDay);
271
+ }
272
+ /**
273
+ * Convert to AD Date
274
+ */
275
+ toAD() {
276
+ if (!this.isValid()) {
277
+ throw new Error('Invalid NepaliDate');
278
+ }
279
+ let totalDays = 0;
280
+ // Add days for complete years
281
+ for (let year = BS_EPOCH.year; year < this._year; year++) {
282
+ const yearData = BS_CALENDAR_DATA[year];
283
+ if (yearData) {
284
+ totalDays += yearData.reduce((sum, days) => sum + days, 0);
285
+ }
286
+ }
287
+ // Add days for complete months in current year
288
+ for (let month = 1; month < this._month; month++) {
289
+ totalDays += getDaysInBSMonth(this._year, month);
290
+ }
291
+ // Add remaining days
292
+ totalDays += this._day - 1;
293
+ // Calculate AD date from epoch
294
+ const adDate = new Date(AD_EPOCH);
295
+ adDate.setDate(adDate.getDate() + totalDays);
296
+ return adDate;
297
+ }
298
+ /**
299
+ * Check if the date is valid
300
+ */
301
+ isValid() {
302
+ // Check year range
303
+ if (this._year < BS_MIN_YEAR || this._year > BS_MAX_YEAR) {
304
+ return false;
305
+ }
306
+ // Check month range
307
+ if (this._month < 1 || this._month > 12) {
308
+ return false;
309
+ }
310
+ // Check day range
311
+ const daysInMonth = getDaysInBSMonth(this._year, this._month);
312
+ if (this._day < 1 || this._day > daysInMonth) {
313
+ return false;
314
+ }
315
+ return true;
316
+ }
317
+ /**
318
+ * Get the day of week (0 = Sunday, 6 = Saturday)
319
+ */
320
+ getDay() {
321
+ return this.toAD().getDay();
322
+ }
323
+ /**
324
+ * Get month name in specified language
325
+ */
326
+ getMonthName(lang = 'en') {
327
+ return lang === 'np' ? BS_MONTHS_NP[this._month - 1] : BS_MONTHS_EN[this._month - 1];
328
+ }
329
+ /**
330
+ * Format date according to pattern
331
+ * Patterns:
332
+ * YYYY - 4-digit year
333
+ * YY - 2-digit year
334
+ * MM - 2-digit month
335
+ * M - month without leading zero
336
+ * DD - 2-digit day
337
+ * D - day without leading zero
338
+ * MMMM - full month name (English)
339
+ * mmmm - full month name (Nepali)
340
+ */
341
+ format(pattern = 'YYYY-MM-DD', useNepaliDigits = false) {
342
+ let result = pattern;
343
+ // Replace patterns (order matters - longer patterns first)
344
+ result = result.replace(/YYYY/g, String(this._year).padStart(4, '0'));
345
+ result = result.replace(/YY/g, String(this._year).slice(-2));
346
+ result = result.replace(/MMMM/g, BS_MONTHS_EN[this._month - 1]);
347
+ result = result.replace(/mmmm/g, BS_MONTHS_NP[this._month - 1]);
348
+ result = result.replace(/MM/g, String(this._month).padStart(2, '0'));
349
+ result = result.replace(/M/g, String(this._month));
350
+ result = result.replace(/DD/g, String(this._day).padStart(2, '0'));
351
+ result = result.replace(/D/g, String(this._day));
352
+ if (useNepaliDigits) {
353
+ result = toNepaliDigits(result);
354
+ }
355
+ return result;
356
+ }
357
+ /**
358
+ * Create a clone of this date
359
+ */
360
+ clone() {
361
+ return new NepaliDate(this._year, this._month, this._day);
362
+ }
363
+ /**
364
+ * Compare with another NepaliDate
365
+ * Returns: -1 if this < other, 0 if equal, 1 if this > other
366
+ */
367
+ compareTo(other) {
368
+ if (this._year !== other._year) {
369
+ return this._year < other._year ? -1 : 1;
370
+ }
371
+ if (this._month !== other._month) {
372
+ return this._month < other._month ? -1 : 1;
373
+ }
374
+ if (this._day !== other._day) {
375
+ return this._day < other._day ? -1 : 1;
376
+ }
377
+ return 0;
378
+ }
379
+ /**
380
+ * Check if this date is before another
381
+ */
382
+ isBefore(other) {
383
+ return this.compareTo(other) < 0;
384
+ }
385
+ /**
386
+ * Check if this date is after another
387
+ */
388
+ isAfter(other) {
389
+ return this.compareTo(other) > 0;
390
+ }
391
+ /**
392
+ * Check if this date equals another
393
+ */
394
+ equals(other) {
395
+ return this.compareTo(other) === 0;
396
+ }
397
+ /**
398
+ * Add days to date (returns new NepaliDate)
399
+ */
400
+ addDays(days) {
401
+ const adDate = this.toAD();
402
+ adDate.setDate(adDate.getDate() + days);
403
+ return NepaliDate.fromAD(adDate);
404
+ }
405
+ /**
406
+ * Add months to date (returns new NepaliDate)
407
+ */
408
+ addMonths(months) {
409
+ let newYear = this._year;
410
+ let newMonth = this._month + months;
411
+ while (newMonth > 12) {
412
+ newMonth -= 12;
413
+ newYear++;
414
+ }
415
+ while (newMonth < 1) {
416
+ newMonth += 12;
417
+ newYear--;
418
+ }
419
+ // Adjust day if it exceeds days in new month
420
+ const daysInNewMonth = getDaysInBSMonth(newYear, newMonth);
421
+ const newDay = Math.min(this._day, daysInNewMonth);
422
+ return new NepaliDate(newYear, newMonth, newDay);
423
+ }
424
+ /**
425
+ * Add years to date (returns new NepaliDate)
426
+ */
427
+ addYears(years) {
428
+ const newYear = this._year + years;
429
+ const daysInNewMonth = getDaysInBSMonth(newYear, this._month);
430
+ const newDay = Math.min(this._day, daysInNewMonth);
431
+ return new NepaliDate(newYear, this._month, newDay);
432
+ }
433
+ /**
434
+ * Get string representation
435
+ */
436
+ toString() {
437
+ return this.format('YYYY-MM-DD');
438
+ }
439
+ /**
440
+ * Convert to plain object
441
+ */
442
+ toObject() {
443
+ return {
444
+ year: this._year,
445
+ month: this._month,
446
+ day: this._day,
447
+ };
448
+ }
449
+ /**
450
+ * Create from plain object
451
+ */
452
+ static fromObject(obj) {
453
+ return new NepaliDate(obj.year, obj.month, obj.day);
454
+ }
455
+ /**
456
+ * Parse from string (YYYY-MM-DD format)
457
+ */
458
+ static parse(dateString) {
459
+ const parts = dateString.split('-').map(Number);
460
+ if (parts.length !== 3 || parts.some(isNaN)) {
461
+ throw new Error('Invalid date format. Expected YYYY-MM-DD');
462
+ }
463
+ return new NepaliDate(parts[0], parts[1], parts[2]);
464
+ }
465
+ }
466
+
467
+ /**
468
+ * DateConverterService - Service for BS/AD date conversions and utilities
469
+ */
470
+ class DateConverterService {
471
+ /**
472
+ * Convert AD Date to NepaliDate (BS)
473
+ */
474
+ convertToBS(adDate) {
475
+ return NepaliDate.fromAD(adDate);
476
+ }
477
+ /**
478
+ * Convert NepaliDate (BS) to AD Date
479
+ */
480
+ convertToAD(bsDate) {
481
+ return bsDate.toAD();
482
+ }
483
+ /**
484
+ * Get today's date in BS
485
+ */
486
+ getTodayBS() {
487
+ return NepaliDate.today();
488
+ }
489
+ /**
490
+ * Get number of days in a BS month
491
+ */
492
+ getDaysInMonth(year, month) {
493
+ return getDaysInBSMonth(year, month);
494
+ }
495
+ /**
496
+ * Get total days in a BS year
497
+ */
498
+ getDaysInYear(year) {
499
+ return getTotalDaysInBSYear(year);
500
+ }
501
+ /**
502
+ * Get month names
503
+ */
504
+ getMonthNames(lang = 'en') {
505
+ return lang === 'np' ? [...BS_MONTHS_NP] : [...BS_MONTHS_EN];
506
+ }
507
+ /**
508
+ * Get weekday names
509
+ */
510
+ getWeekdayNames(lang = 'en') {
511
+ return lang === 'np' ? [...BS_WEEKDAYS_NP] : [...BS_WEEKDAYS_EN];
512
+ }
513
+ /**
514
+ * Get minimum supported year
515
+ */
516
+ getMinYear() {
517
+ return BS_MIN_YEAR;
518
+ }
519
+ /**
520
+ * Get maximum supported year
521
+ */
522
+ getMaxYear() {
523
+ return BS_MAX_YEAR;
524
+ }
525
+ /**
526
+ * Validate a BS date
527
+ */
528
+ isValidDate(year, month, day) {
529
+ const date = new NepaliDate(year, month, day);
530
+ return date.isValid();
531
+ }
532
+ /**
533
+ * Format a NepaliDate
534
+ */
535
+ format(date, pattern = 'YYYY-MM-DD', useNepaliDigits = false) {
536
+ return date.format(pattern, useNepaliDigits);
537
+ }
538
+ /**
539
+ * Parse a date string to NepaliDate
540
+ */
541
+ parse(dateString) {
542
+ return NepaliDate.parse(dateString);
543
+ }
544
+ /**
545
+ * Convert number to Nepali digits
546
+ */
547
+ toNepaliDigits(num) {
548
+ return toNepaliDigits(num);
549
+ }
550
+ /**
551
+ * Get calendar grid for a month
552
+ * Returns a 2D array representing weeks (rows) and days (columns)
553
+ * Each cell contains the day number or null for empty cells
554
+ */
555
+ getMonthCalendarGrid(year, month) {
556
+ const daysInMonth = this.getDaysInMonth(year, month);
557
+ const firstDayOfMonth = new NepaliDate(year, month, 1);
558
+ const startDayOfWeek = firstDayOfMonth.getDay(); // 0 = Sunday
559
+ const grid = [];
560
+ let currentWeek = [];
561
+ // Fill empty cells before first day
562
+ for (let i = 0; i < startDayOfWeek; i++) {
563
+ currentWeek.push(null);
564
+ }
565
+ // Fill days
566
+ for (let day = 1; day <= daysInMonth; day++) {
567
+ currentWeek.push(day);
568
+ if (currentWeek.length === 7) {
569
+ grid.push(currentWeek);
570
+ currentWeek = [];
571
+ }
572
+ }
573
+ // Fill remaining empty cells in last week
574
+ if (currentWeek.length > 0) {
575
+ while (currentWeek.length < 7) {
576
+ currentWeek.push(null);
577
+ }
578
+ grid.push(currentWeek);
579
+ }
580
+ return grid;
581
+ }
582
+ /**
583
+ * Get years range for year selector
584
+ */
585
+ getYearRange(startYear, endYear) {
586
+ const start = startYear ?? BS_MIN_YEAR;
587
+ const end = endYear ?? BS_MAX_YEAR;
588
+ const years = [];
589
+ for (let year = start; year <= end; year++) {
590
+ if (BS_CALENDAR_DATA[year]) {
591
+ years.push(year);
592
+ }
593
+ }
594
+ return years;
595
+ }
596
+ /**
597
+ * Check if a date is within a range
598
+ */
599
+ isDateInRange(date, minDate, maxDate) {
600
+ if (minDate && date.isBefore(minDate)) {
601
+ return false;
602
+ }
603
+ if (maxDate && date.isAfter(maxDate)) {
604
+ return false;
605
+ }
606
+ return true;
607
+ }
608
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: DateConverterService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
609
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: DateConverterService, providedIn: 'root' }); }
610
+ }
611
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: DateConverterService, decorators: [{
612
+ type: Injectable,
613
+ args: [{
614
+ providedIn: 'root',
615
+ }]
616
+ }] });
617
+
618
+ class NepaliDatePickerComponent {
619
+ constructor(elementRef, cdr, dateConverter) {
620
+ this.elementRef = elementRef;
621
+ this.cdr = cdr;
622
+ this.dateConverter = dateConverter;
623
+ /** Placeholder text */
624
+ this.placeholder = 'Select date';
625
+ /** Display format for the input */
626
+ this.displayFormat = 'YYYY-MM-DD';
627
+ /** Theme: 'light' or 'dark' */
628
+ this.theme = 'light';
629
+ /** Language for month/day names */
630
+ this.language = 'en';
631
+ /** Show today button */
632
+ this.showTodayButton = true;
633
+ /** Disabled state */
634
+ this.disabled = false;
635
+ /** Use Nepali digits in display */
636
+ this.useNepaliDigits = false;
637
+ /** Event emitted when date changes */
638
+ this.dateChange = new EventEmitter();
639
+ // Internal state
640
+ this.isOpen = false;
641
+ this.selectedDate = null;
642
+ this.calendarGrid = [];
643
+ this.monthNames = [];
644
+ this.weekdayNames = [];
645
+ this.years = [];
646
+ // CVA callbacks
647
+ this.onChange = () => { };
648
+ this.onTouched = () => { };
649
+ this.viewDate = this.dateConverter.getTodayBS();
650
+ }
651
+ ngOnInit() {
652
+ this.monthNames = this.dateConverter.getMonthNames(this.language);
653
+ this.weekdayNames = this.dateConverter.getWeekdayNames(this.language);
654
+ this.years = this.dateConverter.getYearRange();
655
+ this.updateCalendarGrid();
656
+ }
657
+ ngOnDestroy() { }
658
+ // ControlValueAccessor implementation
659
+ writeValue(value) {
660
+ this.selectedDate = value;
661
+ if (value) {
662
+ this.viewDate = value.clone();
663
+ }
664
+ this.updateCalendarGrid();
665
+ this.cdr.markForCheck();
666
+ }
667
+ registerOnChange(fn) {
668
+ this.onChange = fn;
669
+ }
670
+ registerOnTouched(fn) {
671
+ this.onTouched = fn;
672
+ }
673
+ setDisabledState(isDisabled) {
674
+ this.disabled = isDisabled;
675
+ this.cdr.markForCheck();
676
+ }
677
+ // UI Methods
678
+ toggleCalendar() {
679
+ if (this.disabled)
680
+ return;
681
+ this.isOpen = !this.isOpen;
682
+ if (this.isOpen) {
683
+ this.onTouched();
684
+ this.updateCalendarGrid();
685
+ }
686
+ this.cdr.markForCheck();
687
+ }
688
+ closeCalendar() {
689
+ this.isOpen = false;
690
+ this.cdr.markForCheck();
691
+ }
692
+ onClickOutside(event) {
693
+ if (!this.elementRef.nativeElement.contains(event.target)) {
694
+ this.closeCalendar();
695
+ }
696
+ }
697
+ onEscapeKey() {
698
+ this.closeCalendar();
699
+ }
700
+ // Navigation
701
+ previousMonth() {
702
+ this.viewDate = this.viewDate.addMonths(-1);
703
+ this.updateCalendarGrid();
704
+ this.cdr.markForCheck();
705
+ }
706
+ nextMonth() {
707
+ this.viewDate = this.viewDate.addMonths(1);
708
+ this.updateCalendarGrid();
709
+ this.cdr.markForCheck();
710
+ }
711
+ onYearChange(event) {
712
+ const year = parseInt(event.target.value, 10);
713
+ this.viewDate = new NepaliDate(year, this.viewDate.month, 1);
714
+ // Adjust day if needed
715
+ const daysInMonth = this.dateConverter.getDaysInMonth(year, this.viewDate.month);
716
+ if (this.viewDate.day > daysInMonth) {
717
+ this.viewDate = new NepaliDate(year, this.viewDate.month, daysInMonth);
718
+ }
719
+ this.updateCalendarGrid();
720
+ this.cdr.markForCheck();
721
+ }
722
+ onMonthChange(event) {
723
+ const month = parseInt(event.target.value, 10);
724
+ const daysInMonth = this.dateConverter.getDaysInMonth(this.viewDate.year, month);
725
+ const newDay = Math.min(this.viewDate.day, daysInMonth);
726
+ this.viewDate = new NepaliDate(this.viewDate.year, month, newDay);
727
+ this.updateCalendarGrid();
728
+ this.cdr.markForCheck();
729
+ }
730
+ // Date selection
731
+ selectDate(day) {
732
+ if (day === null || this.disabled)
733
+ return;
734
+ const newDate = new NepaliDate(this.viewDate.year, this.viewDate.month, day);
735
+ if (!this.isDateSelectable(day))
736
+ return;
737
+ this.selectedDate = newDate;
738
+ this.onChange(this.selectedDate);
739
+ this.dateChange.emit(this.selectedDate);
740
+ this.closeCalendar();
741
+ this.cdr.markForCheck();
742
+ }
743
+ selectToday() {
744
+ const today = this.dateConverter.getTodayBS();
745
+ if (this.dateConverter.isDateInRange(today, this.minDate, this.maxDate)) {
746
+ this.selectedDate = today;
747
+ this.viewDate = today.clone();
748
+ this.onChange(this.selectedDate);
749
+ this.dateChange.emit(this.selectedDate);
750
+ this.updateCalendarGrid();
751
+ this.closeCalendar();
752
+ this.cdr.markForCheck();
753
+ }
754
+ }
755
+ clearDate() {
756
+ this.selectedDate = null;
757
+ this.onChange(null);
758
+ this.dateChange.emit(null);
759
+ this.cdr.markForCheck();
760
+ }
761
+ // Helper methods
762
+ updateCalendarGrid() {
763
+ this.calendarGrid = this.dateConverter.getMonthCalendarGrid(this.viewDate.year, this.viewDate.month);
764
+ }
765
+ isDateSelectable(day) {
766
+ if (day === null)
767
+ return false;
768
+ const date = new NepaliDate(this.viewDate.year, this.viewDate.month, day);
769
+ return this.dateConverter.isDateInRange(date, this.minDate, this.maxDate);
770
+ }
771
+ isToday(day) {
772
+ if (day === null)
773
+ return false;
774
+ const today = this.dateConverter.getTodayBS();
775
+ return (this.viewDate.year === today.year && this.viewDate.month === today.month && day === today.day);
776
+ }
777
+ isSelected(day) {
778
+ if (day === null || !this.selectedDate)
779
+ return false;
780
+ return (this.viewDate.year === this.selectedDate.year &&
781
+ this.viewDate.month === this.selectedDate.month &&
782
+ day === this.selectedDate.day);
783
+ }
784
+ get displayValue() {
785
+ if (!this.selectedDate)
786
+ return '';
787
+ return this.selectedDate.format(this.displayFormat, this.useNepaliDigits);
788
+ }
789
+ get currentMonthName() {
790
+ return this.monthNames[this.viewDate.month - 1];
791
+ }
792
+ trackByWeek(index) {
793
+ return index;
794
+ }
795
+ trackByDay(index) {
796
+ return index;
797
+ }
798
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: NepaliDatePickerComponent, deps: [{ token: i0.ElementRef }, { token: i0.ChangeDetectorRef }, { token: DateConverterService }], target: i0.ɵɵFactoryTarget.Component }); }
799
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: NepaliDatePickerComponent, isStandalone: true, selector: "f1-nepali-date-picker", inputs: { minDate: "minDate", maxDate: "maxDate", placeholder: "placeholder", displayFormat: "displayFormat", theme: "theme", language: "language", showTodayButton: "showTodayButton", disabled: "disabled", useNepaliDigits: "useNepaliDigits" }, outputs: { dateChange: "dateChange" }, host: { listeners: { "document:click": "onClickOutside($event)", "document:keydown.escape": "onEscapeKey()" } }, providers: [
800
+ {
801
+ provide: NG_VALUE_ACCESSOR,
802
+ useExisting: forwardRef(() => NepaliDatePickerComponent),
803
+ multi: true,
804
+ },
805
+ ], ngImport: i0, template: "<div class=\"f1-datepicker\" [class.f1-datepicker--dark]=\"theme === 'dark'\" [class.f1-datepicker--disabled]=\"disabled\">\n <!-- Input Field -->\n <div class=\"f1-datepicker__input-wrapper\" (click)=\"toggleCalendar()\">\n <input\n type=\"text\"\n class=\"f1-datepicker__input\"\n [value]=\"displayValue\"\n [placeholder]=\"placeholder\"\n [disabled]=\"disabled\"\n readonly\n />\n <span class=\"f1-datepicker__icon\">\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"18\" height=\"18\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\">\n <rect x=\"3\" y=\"4\" width=\"18\" height=\"18\" rx=\"2\" ry=\"2\"></rect>\n <line x1=\"16\" y1=\"2\" x2=\"16\" y2=\"6\"></line>\n <line x1=\"8\" y1=\"2\" x2=\"8\" y2=\"6\"></line>\n <line x1=\"3\" y1=\"10\" x2=\"21\" y2=\"10\"></line>\n </svg>\n </span>\n <button\n *ngIf=\"selectedDate && !disabled\"\n type=\"button\"\n class=\"f1-datepicker__clear\"\n (click)=\"clearDate(); $event.stopPropagation()\"\n aria-label=\"Clear date\"\n >\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\">\n <line x1=\"18\" y1=\"6\" x2=\"6\" y2=\"18\"></line>\n <line x1=\"6\" y1=\"6\" x2=\"18\" y2=\"18\"></line>\n </svg>\n </button>\n </div>\n\n <!-- Calendar Dropdown -->\n <div class=\"f1-datepicker__dropdown\" *ngIf=\"isOpen\" [@fadeIn]>\n <!-- Header -->\n <div class=\"f1-datepicker__header\">\n <button\n type=\"button\"\n class=\"f1-datepicker__nav-btn\"\n (click)=\"previousMonth()\"\n aria-label=\"Previous month\"\n >\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"18\" height=\"18\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\">\n <polyline points=\"15 18 9 12 15 6\"></polyline>\n </svg>\n </button>\n\n <div class=\"f1-datepicker__selectors\">\n <select\n class=\"f1-datepicker__select\"\n [value]=\"viewDate.month\"\n (change)=\"onMonthChange($event)\"\n >\n <option *ngFor=\"let month of monthNames; let i = index\" [value]=\"i + 1\">\n {{ month }}\n </option>\n </select>\n\n <select\n class=\"f1-datepicker__select\"\n [value]=\"viewDate.year\"\n (change)=\"onYearChange($event)\"\n >\n <option *ngFor=\"let year of years\" [value]=\"year\">\n {{ useNepaliDigits ? (year | number:'1.0-0') : year }}\n </option>\n </select>\n </div>\n\n <button\n type=\"button\"\n class=\"f1-datepicker__nav-btn\"\n (click)=\"nextMonth()\"\n aria-label=\"Next month\"\n >\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"18\" height=\"18\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\">\n <polyline points=\"9 18 15 12 9 6\"></polyline>\n </svg>\n </button>\n </div>\n\n <!-- Weekday Headers -->\n <div class=\"f1-datepicker__weekdays\">\n <div class=\"f1-datepicker__weekday\" *ngFor=\"let day of weekdayNames\">\n {{ day }}\n </div>\n </div>\n\n <!-- Calendar Grid -->\n <div class=\"f1-datepicker__grid\">\n <div class=\"f1-datepicker__week\" *ngFor=\"let week of calendarGrid; trackBy: trackByWeek\">\n <button\n type=\"button\"\n class=\"f1-datepicker__day\"\n *ngFor=\"let day of week; trackBy: trackByDay\"\n [class.f1-datepicker__day--empty]=\"day === null\"\n [class.f1-datepicker__day--today]=\"day !== null && isToday(day)\"\n [class.f1-datepicker__day--selected]=\"day !== null && isSelected(day)\"\n [class.f1-datepicker__day--disabled]=\"day !== null && !isDateSelectable(day)\"\n [disabled]=\"day === null || !isDateSelectable(day)\"\n (click)=\"selectDate(day)\"\n >\n {{ day !== null ? (useNepaliDigits ? day : day) : '' }}\n </button>\n </div>\n </div>\n\n <!-- Footer -->\n <div class=\"f1-datepicker__footer\" *ngIf=\"showTodayButton\">\n <button\n type=\"button\"\n class=\"f1-datepicker__today-btn\"\n (click)=\"selectToday()\"\n >\n {{ language === 'np' ? '\u0906\u091C' : 'Today' }}\n </button>\n </div>\n </div>\n</div>\n", styles: [":host{display:inline-block;font-family:var(--f1-datepicker-font-family, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, \"Helvetica Neue\", Arial, sans-serif)}.f1-datepicker{--f1-dp-bg: #ffffff;--f1-dp-text: #1a1a2e;--f1-dp-text-muted: #64748b;--f1-dp-border: #e2e8f0;--f1-dp-primary: #6366f1;--f1-dp-primary-hover: #4f46e5;--f1-dp-primary-text: #ffffff;--f1-dp-hover-bg: #f1f5f9;--f1-dp-today-bg: #eef2ff;--f1-dp-today-border: #6366f1;--f1-dp-disabled-text: #cbd5e1;--f1-dp-shadow: 0 10px 40px rgba(0, 0, 0, .12);--f1-dp-input-bg: #ffffff;--f1-dp-dropdown-bg: #ffffff;position:relative;width:280px}.f1-datepicker--dark{--f1-dp-bg: #1e1e2e;--f1-dp-text: #f8fafc;--f1-dp-text-muted: #94a3b8;--f1-dp-border: #334155;--f1-dp-primary: #818cf8;--f1-dp-primary-hover: #a5b4fc;--f1-dp-primary-text: #1e1e2e;--f1-dp-hover-bg: #2d2d44;--f1-dp-today-bg: #312e81;--f1-dp-today-border: #818cf8;--f1-dp-disabled-text: #475569;--f1-dp-shadow: 0 10px 40px rgba(0, 0, 0, .4);--f1-dp-input-bg: #1e1e2e;--f1-dp-dropdown-bg: #1e1e2e}.f1-datepicker--disabled{opacity:.6;cursor:not-allowed}.f1-datepicker__input-wrapper{position:relative;display:flex;align-items:center;cursor:pointer}.f1-datepicker--disabled .f1-datepicker__input-wrapper{cursor:not-allowed}.f1-datepicker__input{width:100%;padding:12px 44px 12px 14px;font-size:14px;font-weight:500;color:var(--f1-dp-text);background:var(--f1-dp-input-bg);border:2px solid var(--f1-dp-border);border-radius:10px;outline:none;cursor:pointer;transition:all .2s ease}.f1-datepicker__input::placeholder{color:var(--f1-dp-text-muted)}.f1-datepicker__input:hover:not(:disabled){border-color:var(--f1-dp-primary)}.f1-datepicker__input:focus{border-color:var(--f1-dp-primary);box-shadow:0 0 0 3px #6366f126}.f1-datepicker__input:disabled{cursor:not-allowed;background:var(--f1-dp-hover-bg)}.f1-datepicker__icon{position:absolute;right:12px;display:flex;align-items:center;justify-content:center;color:var(--f1-dp-text-muted);pointer-events:none;transition:color .2s ease}.f1-datepicker__input-wrapper:hover .f1-datepicker__icon{color:var(--f1-dp-primary)}.f1-datepicker__clear{position:absolute;right:38px;display:flex;align-items:center;justify-content:center;width:20px;height:20px;padding:0;color:var(--f1-dp-text-muted);background:transparent;border:none;border-radius:50%;cursor:pointer;transition:all .2s ease}.f1-datepicker__clear:hover{color:var(--f1-dp-text);background:var(--f1-dp-hover-bg)}.f1-datepicker__dropdown{position:absolute;top:calc(100% + 8px);left:0;z-index:1000;width:100%;min-width:300px;padding:16px;background:var(--f1-dp-dropdown-bg);border:1px solid var(--f1-dp-border);border-radius:14px;box-shadow:var(--f1-dp-shadow);animation:slideDown .2s ease}@keyframes slideDown{0%{opacity:0;transform:translateY(-8px)}to{opacity:1;transform:translateY(0)}}.f1-datepicker__header{display:flex;align-items:center;justify-content:space-between;margin-bottom:16px}.f1-datepicker__nav-btn{display:flex;align-items:center;justify-content:center;width:36px;height:36px;padding:0;color:var(--f1-dp-text);background:transparent;border:none;border-radius:8px;cursor:pointer;transition:all .2s ease}.f1-datepicker__nav-btn:hover{background:var(--f1-dp-hover-bg);color:var(--f1-dp-primary)}.f1-datepicker__nav-btn:active{transform:scale(.95)}.f1-datepicker__selectors{display:flex;gap:8px}.f1-datepicker__select{padding:8px 28px 8px 12px;font-size:14px;font-weight:600;color:var(--f1-dp-text);background:var(--f1-dp-hover-bg);border:none;border-radius:8px;cursor:pointer;transition:all .2s ease;appearance:none;background-image:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E\");background-repeat:no-repeat;background-position:right 8px center}.f1-datepicker__select:hover{background-color:var(--f1-dp-border)}.f1-datepicker__select:focus{outline:none;box-shadow:0 0 0 2px var(--f1-dp-primary)}.f1-datepicker__weekdays{display:grid;grid-template-columns:repeat(7,1fr);gap:4px;margin-bottom:8px}.f1-datepicker__weekday{padding:8px 0;font-size:12px;font-weight:600;color:var(--f1-dp-text-muted);text-align:center;text-transform:uppercase;letter-spacing:.5px}.f1-datepicker__grid{display:flex;flex-direction:column;gap:4px}.f1-datepicker__week{display:grid;grid-template-columns:repeat(7,1fr);gap:4px}.f1-datepicker__day{display:flex;align-items:center;justify-content:center;width:36px;height:36px;font-size:14px;font-weight:500;color:var(--f1-dp-text);background:transparent;border:none;border-radius:8px;cursor:pointer;transition:all .15s ease}.f1-datepicker__day:hover:not(:disabled):not(.f1-datepicker__day--selected):not(.f1-datepicker__day--empty){background:var(--f1-dp-hover-bg)}.f1-datepicker__day--empty{visibility:hidden;cursor:default}.f1-datepicker__day--today{background:var(--f1-dp-today-bg);border:2px solid var(--f1-dp-today-border);font-weight:700}.f1-datepicker__day--selected{background:var(--f1-dp-primary)!important;color:var(--f1-dp-primary-text)!important;font-weight:700}.f1-datepicker__day--selected:hover{background:var(--f1-dp-primary-hover)!important}.f1-datepicker__day--disabled{color:var(--f1-dp-disabled-text);cursor:not-allowed}.f1-datepicker__day--disabled:hover{background:transparent}.f1-datepicker__footer{display:flex;justify-content:center;margin-top:12px;padding-top:12px;border-top:1px solid var(--f1-dp-border)}.f1-datepicker__today-btn{padding:8px 20px;font-size:13px;font-weight:600;color:var(--f1-dp-primary);background:transparent;border:2px solid var(--f1-dp-primary);border-radius:8px;cursor:pointer;transition:all .2s ease}.f1-datepicker__today-btn:hover{background:var(--f1-dp-primary);color:var(--f1-dp-primary-text)}.f1-datepicker__today-btn:active{transform:scale(.98)}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "pipe", type: i2.DecimalPipe, name: "number" }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i3.NgSelectOption, selector: "option", inputs: ["ngValue", "value"] }, { kind: "directive", type: i3.ɵNgSelectMultipleOption, selector: "option", inputs: ["ngValue", "value"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
806
+ }
807
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: NepaliDatePickerComponent, decorators: [{
808
+ type: Component,
809
+ args: [{ selector: 'f1-nepali-date-picker', standalone: true, imports: [CommonModule, FormsModule], changeDetection: ChangeDetectionStrategy.OnPush, providers: [
810
+ {
811
+ provide: NG_VALUE_ACCESSOR,
812
+ useExisting: forwardRef(() => NepaliDatePickerComponent),
813
+ multi: true,
814
+ },
815
+ ], template: "<div class=\"f1-datepicker\" [class.f1-datepicker--dark]=\"theme === 'dark'\" [class.f1-datepicker--disabled]=\"disabled\">\n <!-- Input Field -->\n <div class=\"f1-datepicker__input-wrapper\" (click)=\"toggleCalendar()\">\n <input\n type=\"text\"\n class=\"f1-datepicker__input\"\n [value]=\"displayValue\"\n [placeholder]=\"placeholder\"\n [disabled]=\"disabled\"\n readonly\n />\n <span class=\"f1-datepicker__icon\">\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"18\" height=\"18\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\">\n <rect x=\"3\" y=\"4\" width=\"18\" height=\"18\" rx=\"2\" ry=\"2\"></rect>\n <line x1=\"16\" y1=\"2\" x2=\"16\" y2=\"6\"></line>\n <line x1=\"8\" y1=\"2\" x2=\"8\" y2=\"6\"></line>\n <line x1=\"3\" y1=\"10\" x2=\"21\" y2=\"10\"></line>\n </svg>\n </span>\n <button\n *ngIf=\"selectedDate && !disabled\"\n type=\"button\"\n class=\"f1-datepicker__clear\"\n (click)=\"clearDate(); $event.stopPropagation()\"\n aria-label=\"Clear date\"\n >\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\">\n <line x1=\"18\" y1=\"6\" x2=\"6\" y2=\"18\"></line>\n <line x1=\"6\" y1=\"6\" x2=\"18\" y2=\"18\"></line>\n </svg>\n </button>\n </div>\n\n <!-- Calendar Dropdown -->\n <div class=\"f1-datepicker__dropdown\" *ngIf=\"isOpen\" [@fadeIn]>\n <!-- Header -->\n <div class=\"f1-datepicker__header\">\n <button\n type=\"button\"\n class=\"f1-datepicker__nav-btn\"\n (click)=\"previousMonth()\"\n aria-label=\"Previous month\"\n >\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"18\" height=\"18\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\">\n <polyline points=\"15 18 9 12 15 6\"></polyline>\n </svg>\n </button>\n\n <div class=\"f1-datepicker__selectors\">\n <select\n class=\"f1-datepicker__select\"\n [value]=\"viewDate.month\"\n (change)=\"onMonthChange($event)\"\n >\n <option *ngFor=\"let month of monthNames; let i = index\" [value]=\"i + 1\">\n {{ month }}\n </option>\n </select>\n\n <select\n class=\"f1-datepicker__select\"\n [value]=\"viewDate.year\"\n (change)=\"onYearChange($event)\"\n >\n <option *ngFor=\"let year of years\" [value]=\"year\">\n {{ useNepaliDigits ? (year | number:'1.0-0') : year }}\n </option>\n </select>\n </div>\n\n <button\n type=\"button\"\n class=\"f1-datepicker__nav-btn\"\n (click)=\"nextMonth()\"\n aria-label=\"Next month\"\n >\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"18\" height=\"18\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\">\n <polyline points=\"9 18 15 12 9 6\"></polyline>\n </svg>\n </button>\n </div>\n\n <!-- Weekday Headers -->\n <div class=\"f1-datepicker__weekdays\">\n <div class=\"f1-datepicker__weekday\" *ngFor=\"let day of weekdayNames\">\n {{ day }}\n </div>\n </div>\n\n <!-- Calendar Grid -->\n <div class=\"f1-datepicker__grid\">\n <div class=\"f1-datepicker__week\" *ngFor=\"let week of calendarGrid; trackBy: trackByWeek\">\n <button\n type=\"button\"\n class=\"f1-datepicker__day\"\n *ngFor=\"let day of week; trackBy: trackByDay\"\n [class.f1-datepicker__day--empty]=\"day === null\"\n [class.f1-datepicker__day--today]=\"day !== null && isToday(day)\"\n [class.f1-datepicker__day--selected]=\"day !== null && isSelected(day)\"\n [class.f1-datepicker__day--disabled]=\"day !== null && !isDateSelectable(day)\"\n [disabled]=\"day === null || !isDateSelectable(day)\"\n (click)=\"selectDate(day)\"\n >\n {{ day !== null ? (useNepaliDigits ? day : day) : '' }}\n </button>\n </div>\n </div>\n\n <!-- Footer -->\n <div class=\"f1-datepicker__footer\" *ngIf=\"showTodayButton\">\n <button\n type=\"button\"\n class=\"f1-datepicker__today-btn\"\n (click)=\"selectToday()\"\n >\n {{ language === 'np' ? '\u0906\u091C' : 'Today' }}\n </button>\n </div>\n </div>\n</div>\n", styles: [":host{display:inline-block;font-family:var(--f1-datepicker-font-family, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, \"Helvetica Neue\", Arial, sans-serif)}.f1-datepicker{--f1-dp-bg: #ffffff;--f1-dp-text: #1a1a2e;--f1-dp-text-muted: #64748b;--f1-dp-border: #e2e8f0;--f1-dp-primary: #6366f1;--f1-dp-primary-hover: #4f46e5;--f1-dp-primary-text: #ffffff;--f1-dp-hover-bg: #f1f5f9;--f1-dp-today-bg: #eef2ff;--f1-dp-today-border: #6366f1;--f1-dp-disabled-text: #cbd5e1;--f1-dp-shadow: 0 10px 40px rgba(0, 0, 0, .12);--f1-dp-input-bg: #ffffff;--f1-dp-dropdown-bg: #ffffff;position:relative;width:280px}.f1-datepicker--dark{--f1-dp-bg: #1e1e2e;--f1-dp-text: #f8fafc;--f1-dp-text-muted: #94a3b8;--f1-dp-border: #334155;--f1-dp-primary: #818cf8;--f1-dp-primary-hover: #a5b4fc;--f1-dp-primary-text: #1e1e2e;--f1-dp-hover-bg: #2d2d44;--f1-dp-today-bg: #312e81;--f1-dp-today-border: #818cf8;--f1-dp-disabled-text: #475569;--f1-dp-shadow: 0 10px 40px rgba(0, 0, 0, .4);--f1-dp-input-bg: #1e1e2e;--f1-dp-dropdown-bg: #1e1e2e}.f1-datepicker--disabled{opacity:.6;cursor:not-allowed}.f1-datepicker__input-wrapper{position:relative;display:flex;align-items:center;cursor:pointer}.f1-datepicker--disabled .f1-datepicker__input-wrapper{cursor:not-allowed}.f1-datepicker__input{width:100%;padding:12px 44px 12px 14px;font-size:14px;font-weight:500;color:var(--f1-dp-text);background:var(--f1-dp-input-bg);border:2px solid var(--f1-dp-border);border-radius:10px;outline:none;cursor:pointer;transition:all .2s ease}.f1-datepicker__input::placeholder{color:var(--f1-dp-text-muted)}.f1-datepicker__input:hover:not(:disabled){border-color:var(--f1-dp-primary)}.f1-datepicker__input:focus{border-color:var(--f1-dp-primary);box-shadow:0 0 0 3px #6366f126}.f1-datepicker__input:disabled{cursor:not-allowed;background:var(--f1-dp-hover-bg)}.f1-datepicker__icon{position:absolute;right:12px;display:flex;align-items:center;justify-content:center;color:var(--f1-dp-text-muted);pointer-events:none;transition:color .2s ease}.f1-datepicker__input-wrapper:hover .f1-datepicker__icon{color:var(--f1-dp-primary)}.f1-datepicker__clear{position:absolute;right:38px;display:flex;align-items:center;justify-content:center;width:20px;height:20px;padding:0;color:var(--f1-dp-text-muted);background:transparent;border:none;border-radius:50%;cursor:pointer;transition:all .2s ease}.f1-datepicker__clear:hover{color:var(--f1-dp-text);background:var(--f1-dp-hover-bg)}.f1-datepicker__dropdown{position:absolute;top:calc(100% + 8px);left:0;z-index:1000;width:100%;min-width:300px;padding:16px;background:var(--f1-dp-dropdown-bg);border:1px solid var(--f1-dp-border);border-radius:14px;box-shadow:var(--f1-dp-shadow);animation:slideDown .2s ease}@keyframes slideDown{0%{opacity:0;transform:translateY(-8px)}to{opacity:1;transform:translateY(0)}}.f1-datepicker__header{display:flex;align-items:center;justify-content:space-between;margin-bottom:16px}.f1-datepicker__nav-btn{display:flex;align-items:center;justify-content:center;width:36px;height:36px;padding:0;color:var(--f1-dp-text);background:transparent;border:none;border-radius:8px;cursor:pointer;transition:all .2s ease}.f1-datepicker__nav-btn:hover{background:var(--f1-dp-hover-bg);color:var(--f1-dp-primary)}.f1-datepicker__nav-btn:active{transform:scale(.95)}.f1-datepicker__selectors{display:flex;gap:8px}.f1-datepicker__select{padding:8px 28px 8px 12px;font-size:14px;font-weight:600;color:var(--f1-dp-text);background:var(--f1-dp-hover-bg);border:none;border-radius:8px;cursor:pointer;transition:all .2s ease;appearance:none;background-image:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E\");background-repeat:no-repeat;background-position:right 8px center}.f1-datepicker__select:hover{background-color:var(--f1-dp-border)}.f1-datepicker__select:focus{outline:none;box-shadow:0 0 0 2px var(--f1-dp-primary)}.f1-datepicker__weekdays{display:grid;grid-template-columns:repeat(7,1fr);gap:4px;margin-bottom:8px}.f1-datepicker__weekday{padding:8px 0;font-size:12px;font-weight:600;color:var(--f1-dp-text-muted);text-align:center;text-transform:uppercase;letter-spacing:.5px}.f1-datepicker__grid{display:flex;flex-direction:column;gap:4px}.f1-datepicker__week{display:grid;grid-template-columns:repeat(7,1fr);gap:4px}.f1-datepicker__day{display:flex;align-items:center;justify-content:center;width:36px;height:36px;font-size:14px;font-weight:500;color:var(--f1-dp-text);background:transparent;border:none;border-radius:8px;cursor:pointer;transition:all .15s ease}.f1-datepicker__day:hover:not(:disabled):not(.f1-datepicker__day--selected):not(.f1-datepicker__day--empty){background:var(--f1-dp-hover-bg)}.f1-datepicker__day--empty{visibility:hidden;cursor:default}.f1-datepicker__day--today{background:var(--f1-dp-today-bg);border:2px solid var(--f1-dp-today-border);font-weight:700}.f1-datepicker__day--selected{background:var(--f1-dp-primary)!important;color:var(--f1-dp-primary-text)!important;font-weight:700}.f1-datepicker__day--selected:hover{background:var(--f1-dp-primary-hover)!important}.f1-datepicker__day--disabled{color:var(--f1-dp-disabled-text);cursor:not-allowed}.f1-datepicker__day--disabled:hover{background:transparent}.f1-datepicker__footer{display:flex;justify-content:center;margin-top:12px;padding-top:12px;border-top:1px solid var(--f1-dp-border)}.f1-datepicker__today-btn{padding:8px 20px;font-size:13px;font-weight:600;color:var(--f1-dp-primary);background:transparent;border:2px solid var(--f1-dp-primary);border-radius:8px;cursor:pointer;transition:all .2s ease}.f1-datepicker__today-btn:hover{background:var(--f1-dp-primary);color:var(--f1-dp-primary-text)}.f1-datepicker__today-btn:active{transform:scale(.98)}\n"] }]
816
+ }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.ChangeDetectorRef }, { type: DateConverterService }]; }, propDecorators: { minDate: [{
817
+ type: Input
818
+ }], maxDate: [{
819
+ type: Input
820
+ }], placeholder: [{
821
+ type: Input
822
+ }], displayFormat: [{
823
+ type: Input
824
+ }], theme: [{
825
+ type: Input
826
+ }], language: [{
827
+ type: Input
828
+ }], showTodayButton: [{
829
+ type: Input
830
+ }], disabled: [{
831
+ type: Input
832
+ }], useNepaliDigits: [{
833
+ type: Input
834
+ }], dateChange: [{
835
+ type: Output
836
+ }], onClickOutside: [{
837
+ type: HostListener,
838
+ args: ['document:click', ['$event']]
839
+ }], onEscapeKey: [{
840
+ type: HostListener,
841
+ args: ['document:keydown.escape']
842
+ }] } });
843
+
844
+ class F1NepaliDatePickerModule {
845
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: F1NepaliDatePickerModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
846
+ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.2.12", ngImport: i0, type: F1NepaliDatePickerModule, imports: [NepaliDatePickerComponent], exports: [NepaliDatePickerComponent] }); }
847
+ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: F1NepaliDatePickerModule, imports: [NepaliDatePickerComponent] }); }
848
+ }
849
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: F1NepaliDatePickerModule, decorators: [{
850
+ type: NgModule,
851
+ args: [{
852
+ imports: [
853
+ NepaliDatePickerComponent, // Standalone component, import directly
854
+ ],
855
+ exports: [
856
+ NepaliDatePickerComponent,
857
+ ],
858
+ }]
859
+ }] });
860
+
861
+ /*
862
+ * Public API Surface of f1-nepali-date-picker
863
+ */
864
+ // Module
865
+
866
+ /**
867
+ * Generated bundle index. Do not edit.
868
+ */
869
+
870
+ export { AD_EPOCH, BS_CALENDAR_DATA, BS_EPOCH, BS_MAX_YEAR, BS_MIN_YEAR, BS_MONTHS_EN, BS_MONTHS_NP, BS_WEEKDAYS_EN, BS_WEEKDAYS_NP, DateConverterService, F1NepaliDatePickerModule, NEPALI_DIGITS, NepaliDate, NepaliDatePickerComponent, getDaysInBSMonth, getTotalDaysInBSYear, toNepaliDigits };
871
+ //# sourceMappingURL=f1softinternational-f1-nepali-date-picker.mjs.map