ngx-np-datepicker 0.0.1
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/README.md +24 -0
- package/esm2020/lib/mapping.mjs +40 -0
- package/esm2020/lib/np-datepicker.component.mjs +248 -0
- package/esm2020/lib/np-datepicker.module.mjs +33 -0
- package/esm2020/lib/np-datepicker.service.mjs +295 -0
- package/esm2020/lib/to-np.pipe.mjs +50 -0
- package/esm2020/lib/types.mjs +2 -0
- package/esm2020/ngx-np-datepicker.mjs +5 -0
- package/esm2020/public-api.mjs +7 -0
- package/fesm2015/ngx-np-datepicker.mjs +665 -0
- package/fesm2015/ngx-np-datepicker.mjs.map +1 -0
- package/fesm2020/ngx-np-datepicker.mjs +664 -0
- package/fesm2020/ngx-np-datepicker.mjs.map +1 -0
- package/lib/mapping.d.ts +5 -0
- package/lib/np-datepicker.component.d.ts +53 -0
- package/lib/np-datepicker.module.d.ts +10 -0
- package/lib/np-datepicker.service.d.ts +46 -0
- package/lib/to-np.pipe.d.ts +7 -0
- package/lib/types.d.ts +33 -0
- package/ngx-np-datepicker.d.ts +5 -0
- package/package.json +31 -0
- package/public-api.d.ts +3 -0
|
@@ -0,0 +1,665 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { Injectable, Pipe, forwardRef, Component, ViewEncapsulation, Input, HostListener, NgModule } from '@angular/core';
|
|
3
|
+
import * as i3 from '@angular/forms';
|
|
4
|
+
import { NG_VALUE_ACCESSOR, FormsModule } from '@angular/forms';
|
|
5
|
+
import * as i2 from '@angular/common';
|
|
6
|
+
import { BrowserModule } from '@angular/platform-browser';
|
|
7
|
+
|
|
8
|
+
class NpDatePickerService {
|
|
9
|
+
constructor() {
|
|
10
|
+
this.englishMonths = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
|
11
|
+
this.englishLeapMonths = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
|
12
|
+
this.nepaliMonths = [
|
|
13
|
+
[30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31],
|
|
14
|
+
[31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
|
|
15
|
+
[31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30],
|
|
16
|
+
[31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
|
|
17
|
+
[30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31],
|
|
18
|
+
[31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
|
|
19
|
+
[31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30],
|
|
20
|
+
[31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
|
|
21
|
+
[31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 29, 31],
|
|
22
|
+
[31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
|
|
23
|
+
[31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30],
|
|
24
|
+
[31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
|
|
25
|
+
[31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30],
|
|
26
|
+
[31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
|
|
27
|
+
[31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30],
|
|
28
|
+
[31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
|
|
29
|
+
[31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30],
|
|
30
|
+
[31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
|
|
31
|
+
[31, 32, 31, 32, 31, 30, 30, 29, 30, 29, 30, 30],
|
|
32
|
+
[31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31],
|
|
33
|
+
[31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30],
|
|
34
|
+
[31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
|
|
35
|
+
[31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30],
|
|
36
|
+
[31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31],
|
|
37
|
+
[31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30],
|
|
38
|
+
[31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
|
|
39
|
+
[31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
|
|
40
|
+
[30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31],
|
|
41
|
+
[31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
|
|
42
|
+
[31, 31, 32, 31, 32, 30, 30, 29, 30, 29, 30, 30],
|
|
43
|
+
[31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
|
|
44
|
+
[30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31],
|
|
45
|
+
[31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
|
|
46
|
+
[31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30],
|
|
47
|
+
[31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
|
|
48
|
+
[30, 32, 31, 32, 31, 31, 29, 30, 30, 29, 29, 31],
|
|
49
|
+
[31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
|
|
50
|
+
[31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30],
|
|
51
|
+
[31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
|
|
52
|
+
[31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30],
|
|
53
|
+
[31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
|
|
54
|
+
[31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30],
|
|
55
|
+
[31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
|
|
56
|
+
[31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30],
|
|
57
|
+
[31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
|
|
58
|
+
[31, 32, 31, 32, 31, 30, 30, 29, 30, 29, 30, 30],
|
|
59
|
+
[31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
|
|
60
|
+
[31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30],
|
|
61
|
+
[31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
|
|
62
|
+
[31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30],
|
|
63
|
+
[31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31],
|
|
64
|
+
[31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30],
|
|
65
|
+
[31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
|
|
66
|
+
[31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30],
|
|
67
|
+
[31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31],
|
|
68
|
+
[31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
|
|
69
|
+
[31, 31, 32, 31, 32, 30, 30, 29, 30, 29, 30, 30],
|
|
70
|
+
[31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
|
|
71
|
+
[30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31],
|
|
72
|
+
[31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
|
|
73
|
+
[31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30],
|
|
74
|
+
[31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
|
|
75
|
+
[30, 32, 31, 32, 31, 31, 29, 30, 29, 30, 29, 31],
|
|
76
|
+
[31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
|
|
77
|
+
[31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30],
|
|
78
|
+
[31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
|
|
79
|
+
[31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 29, 31],
|
|
80
|
+
[31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
|
|
81
|
+
[31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30],
|
|
82
|
+
[31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
|
|
83
|
+
[31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30],
|
|
84
|
+
[31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
|
|
85
|
+
[31, 32, 31, 32, 31, 30, 30, 29, 30, 29, 30, 30],
|
|
86
|
+
[31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
|
|
87
|
+
[31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30],
|
|
88
|
+
[31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
|
|
89
|
+
[31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30],
|
|
90
|
+
[31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31],
|
|
91
|
+
[31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30],
|
|
92
|
+
[31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
|
|
93
|
+
[31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30],
|
|
94
|
+
[31, 31, 32, 32, 31, 30, 30, 30, 29, 30, 30, 30],
|
|
95
|
+
[30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30],
|
|
96
|
+
[31, 31, 32, 31, 31, 30, 30, 30, 29, 30, 30, 30],
|
|
97
|
+
[31, 31, 32, 31, 31, 30, 30, 30, 29, 30, 30, 30],
|
|
98
|
+
[31, 32, 31, 32, 30, 31, 30, 30, 29, 30, 30, 30],
|
|
99
|
+
[30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30],
|
|
100
|
+
[31, 31, 32, 31, 31, 31, 30, 30, 29, 30, 30, 30],
|
|
101
|
+
[30, 31, 32, 32, 30, 31, 30, 30, 29, 30, 30, 30],
|
|
102
|
+
[30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30],
|
|
103
|
+
[30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30],
|
|
104
|
+
[31, 31, 32, 31, 31, 31, 30, 30, 29, 30, 30, 30],
|
|
105
|
+
[30, 31, 32, 32, 31, 30, 30, 30, 29, 30, 30, 30],
|
|
106
|
+
[30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30],
|
|
107
|
+
[31, 31, 32, 31, 31, 30, 30, 30, 29, 30, 30, 30],
|
|
108
|
+
[31, 31, 32, 31, 31, 31, 30, 29, 30, 30, 30, 30],
|
|
109
|
+
[30, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30],
|
|
110
|
+
[31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30],
|
|
111
|
+
[31, 31, 32, 31, 31, 31, 29, 30, 29, 30, 29, 31],
|
|
112
|
+
[31, 31, 32, 31, 31, 31, 30, 29, 29, 30, 30, 30], //2099
|
|
113
|
+
];
|
|
114
|
+
this.format = '.';
|
|
115
|
+
var d = new Date();
|
|
116
|
+
}
|
|
117
|
+
setCurrentNepaliDate() {
|
|
118
|
+
var d = new Date();
|
|
119
|
+
return this.engToNepDate(d.getDate(), d.getMonth() + 1, d.getFullYear());
|
|
120
|
+
}
|
|
121
|
+
//English to Nepali date conversion
|
|
122
|
+
engToNepDate(date, month, year) {
|
|
123
|
+
if (!this.isEnglishRange(date, month, year))
|
|
124
|
+
console.log('Invalid date format.');
|
|
125
|
+
this.englishYear = year;
|
|
126
|
+
this.englishMonth = month;
|
|
127
|
+
this.englishDate = date;
|
|
128
|
+
//Setting nepali reference to 2000/1/1 with english date 1943/4/14
|
|
129
|
+
this.nepaliYear = 2000;
|
|
130
|
+
this.nepaliMonth = 1;
|
|
131
|
+
this.nepaliDate = 0;
|
|
132
|
+
var difference = this.getEnglishDateDifference(1943, 4, 14);
|
|
133
|
+
//Getting nepali year untill the difference remains less than 365
|
|
134
|
+
var index = 0;
|
|
135
|
+
while (difference >= this.nepaliYearDays(index)) {
|
|
136
|
+
this.nepaliYear++;
|
|
137
|
+
difference = difference - this.nepaliYearDays(index);
|
|
138
|
+
index++;
|
|
139
|
+
}
|
|
140
|
+
//Getting nepali month untill the difference remains less than 31
|
|
141
|
+
var i = 0;
|
|
142
|
+
while (difference >= this.nepaliMonths[index][i]) {
|
|
143
|
+
difference = difference - this.nepaliMonths[index][i];
|
|
144
|
+
this.nepaliMonth++;
|
|
145
|
+
i++;
|
|
146
|
+
}
|
|
147
|
+
//Remaning days is the date;
|
|
148
|
+
this.nepaliDate = this.nepaliDate + difference;
|
|
149
|
+
this.getDay();
|
|
150
|
+
return {
|
|
151
|
+
day: this.nepaliDate,
|
|
152
|
+
month: this.nepaliMonth,
|
|
153
|
+
year: this.nepaliYear
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
toEnglishString(format) {
|
|
157
|
+
if (typeof format === 'undefined')
|
|
158
|
+
format = '-';
|
|
159
|
+
return (this.englishYear + format + this.englishMonth + format + this.englishDate);
|
|
160
|
+
}
|
|
161
|
+
getEnglishDateDifference(year, month, date) {
|
|
162
|
+
//Getting difference from the current date with the date provided
|
|
163
|
+
var difference = this.countTotalEnglishDays(this.englishYear, this.englishMonth, this.englishDate) - this.countTotalEnglishDays(year, month, date);
|
|
164
|
+
return difference < 0 ? -difference : difference;
|
|
165
|
+
}
|
|
166
|
+
countTotalEnglishDays(year, month, date) {
|
|
167
|
+
var totalDays = year * 365 + date;
|
|
168
|
+
for (var i = 0; i < month - 1; i++)
|
|
169
|
+
totalDays = totalDays + this.englishMonths[i];
|
|
170
|
+
totalDays = totalDays + this.countleap(year, month);
|
|
171
|
+
return totalDays;
|
|
172
|
+
}
|
|
173
|
+
countleap(year, month) {
|
|
174
|
+
if (month <= 2)
|
|
175
|
+
year--;
|
|
176
|
+
return (Math.floor(year / 4) - Math.floor(year / 100) + Math.floor(year / 400));
|
|
177
|
+
}
|
|
178
|
+
isEnglishRange(date, month, year) {
|
|
179
|
+
if (year < 1944 || year > 2042)
|
|
180
|
+
return false;
|
|
181
|
+
if (month < 1 || month > 12)
|
|
182
|
+
return false;
|
|
183
|
+
if (date < 1 || date > 31)
|
|
184
|
+
return false;
|
|
185
|
+
return true;
|
|
186
|
+
}
|
|
187
|
+
isLeapYear(year) {
|
|
188
|
+
if (year % 4 === 0) {
|
|
189
|
+
return year % 100 === 0 ? year % 400 === 0 : true;
|
|
190
|
+
}
|
|
191
|
+
else
|
|
192
|
+
return false;
|
|
193
|
+
}
|
|
194
|
+
//Nepali to English conversion
|
|
195
|
+
nepToEngDate(date, month, year) {
|
|
196
|
+
if (!this.isNepaliRange(date, month, year)) {
|
|
197
|
+
console.log('Invalid Date Format');
|
|
198
|
+
// throw new Exception("Invalid date format.");
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
this.nepaliYear = year;
|
|
202
|
+
this.nepaliMonth = month;
|
|
203
|
+
this.nepaliDate = date;
|
|
204
|
+
//Setting english reference to 1944/1/1 with nepali date 2000/9/17
|
|
205
|
+
this.englishYear = 1944;
|
|
206
|
+
this.englishMonth = 1;
|
|
207
|
+
this.englishDate = 1;
|
|
208
|
+
var difference = this.getNepaliDateDifference(2000, 9, 17);
|
|
209
|
+
//Getting english year untill the difference remains less than 365
|
|
210
|
+
while (difference >= (this.isLeapYear(this.englishYear) ? 366 : 365)) {
|
|
211
|
+
difference = difference - (this.isLeapYear(this.englishYear) ? 366 : 365);
|
|
212
|
+
this.englishYear++;
|
|
213
|
+
}
|
|
214
|
+
//Getting english month untill the difference remains less than 31
|
|
215
|
+
var monthDays = this.isLeapYear(this.englishYear)
|
|
216
|
+
? this.englishLeapMonths
|
|
217
|
+
: this.englishMonths;
|
|
218
|
+
var i = 0;
|
|
219
|
+
while (difference >= monthDays[i]) {
|
|
220
|
+
this.englishMonth++;
|
|
221
|
+
difference = difference - monthDays[i];
|
|
222
|
+
i++;
|
|
223
|
+
}
|
|
224
|
+
//Remaning days is the date;
|
|
225
|
+
this.englishDate = this.englishDate + difference;
|
|
226
|
+
this.getDay();
|
|
227
|
+
return new Date(this.englishYear + '-' + this.englishMonth + '-' + this.englishDate);
|
|
228
|
+
}
|
|
229
|
+
toNepaliString(format) {
|
|
230
|
+
if (typeof format === 'undefined')
|
|
231
|
+
format = '-';
|
|
232
|
+
return (this.nepaliYear + format + this.nepaliMonth + format + this.nepaliDate);
|
|
233
|
+
}
|
|
234
|
+
getNepaliDateDifference(year, month, date) {
|
|
235
|
+
//Getting difference from the current date with the date provided
|
|
236
|
+
var difference = this.countTotalNepaliDays(this.nepaliYear, this.nepaliMonth, this.nepaliDate) - this.countTotalNepaliDays(year, month, date);
|
|
237
|
+
return difference < 0 ? -difference : difference;
|
|
238
|
+
}
|
|
239
|
+
countTotalNepaliDays(year, month, date) {
|
|
240
|
+
var total = 0;
|
|
241
|
+
if (year < 2000)
|
|
242
|
+
return 0;
|
|
243
|
+
total = total + (date - 1);
|
|
244
|
+
var yearIndex = year - 2000;
|
|
245
|
+
for (var i = 0; i < month - 1; i++)
|
|
246
|
+
total = total + this.nepaliMonths[yearIndex][i];
|
|
247
|
+
for (var i = 0; i < yearIndex; i++)
|
|
248
|
+
total = total + this.nepaliYearDays(i);
|
|
249
|
+
return total;
|
|
250
|
+
}
|
|
251
|
+
nepaliYearDays(index) {
|
|
252
|
+
var total = 0;
|
|
253
|
+
for (var i = 0; i < 12; i++)
|
|
254
|
+
total += this.nepaliMonths[index][i];
|
|
255
|
+
return total;
|
|
256
|
+
}
|
|
257
|
+
isNepaliRange(date, month, year) {
|
|
258
|
+
if (year < 2000 || year > 2099)
|
|
259
|
+
return false;
|
|
260
|
+
if (month < 1 || month > 12)
|
|
261
|
+
return false;
|
|
262
|
+
if (date < 1 || date > this.nepaliMonths[year - 2000][month - 1])
|
|
263
|
+
return false;
|
|
264
|
+
return true;
|
|
265
|
+
}
|
|
266
|
+
//Class Regular methods
|
|
267
|
+
getDay() {
|
|
268
|
+
//Reference date 1943/4/14 Wednesday
|
|
269
|
+
var difference = this.getEnglishDateDifference(1943, 4, 14);
|
|
270
|
+
this.weekDay = ((3 + (difference % 7)) % 7) + 1;
|
|
271
|
+
return this.weekDay;
|
|
272
|
+
}
|
|
273
|
+
getEnglishYear() {
|
|
274
|
+
return this.englishYear;
|
|
275
|
+
}
|
|
276
|
+
getEnglishMonth() {
|
|
277
|
+
return this.englishMonth;
|
|
278
|
+
}
|
|
279
|
+
getEnglishDate() {
|
|
280
|
+
return this.englishDate;
|
|
281
|
+
}
|
|
282
|
+
getNepaliYear() {
|
|
283
|
+
return this.nepaliYear;
|
|
284
|
+
}
|
|
285
|
+
getNepaliMonth() {
|
|
286
|
+
return this.nepaliMonth;
|
|
287
|
+
}
|
|
288
|
+
getNepaliDate() {
|
|
289
|
+
return this.nepaliDate;
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
NpDatePickerService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.3", ngImport: i0, type: NpDatePickerService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
293
|
+
NpDatePickerService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.1.3", ngImport: i0, type: NpDatePickerService, providedIn: 'root' });
|
|
294
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.3", ngImport: i0, type: NpDatePickerService, decorators: [{
|
|
295
|
+
type: Injectable,
|
|
296
|
+
args: [{
|
|
297
|
+
providedIn: 'root',
|
|
298
|
+
}]
|
|
299
|
+
}], ctorParameters: function () { return []; } });
|
|
300
|
+
|
|
301
|
+
const numberMapping = ['०', '१', '२', '३', '४', '५', '६', '७', '८', '९'];
|
|
302
|
+
const wordsMapping = {
|
|
303
|
+
year: 'साल',
|
|
304
|
+
month: 'महिना'
|
|
305
|
+
};
|
|
306
|
+
const daysMapping = {
|
|
307
|
+
en: {
|
|
308
|
+
default: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
|
|
309
|
+
short: ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa']
|
|
310
|
+
},
|
|
311
|
+
ne: {
|
|
312
|
+
default: ['आइत', 'सोम', 'मंगल्', 'बुध', 'बिही', 'शुक्र', 'शनि'],
|
|
313
|
+
short: ['आ', 'सो', 'मं', 'बु', 'बि', 'शु', 'श']
|
|
314
|
+
}
|
|
315
|
+
};
|
|
316
|
+
const monthsMapping = {
|
|
317
|
+
en: {
|
|
318
|
+
default: [
|
|
319
|
+
'Baisakh', 'Jestha', 'Asadh', 'Shrawan', 'Bhadra', 'Ashwin', 'Kartik', 'Mangsir', 'Poush', 'Marga', 'Falgun', 'Chaitra'
|
|
320
|
+
],
|
|
321
|
+
modern: [
|
|
322
|
+
'Baisakh', 'Jeth', 'Asaar', 'Saawn', 'Bhadau', 'Aashoj', 'Kartik', 'Mangsir', 'Push', 'Magh', 'Fagun', 'Chait'
|
|
323
|
+
],
|
|
324
|
+
short: [
|
|
325
|
+
'Bai', 'Jes', 'Asa', 'Shr', 'Bha', 'Ash', 'Kar', 'Man', 'Pou', 'Mar', 'Fal', 'Cha'
|
|
326
|
+
]
|
|
327
|
+
},
|
|
328
|
+
ne: {
|
|
329
|
+
default: [
|
|
330
|
+
'बैशाख', 'जेष्ठ', 'आषाढ', 'श्रवण', 'भाद्र', 'आश्विन', 'कार्तिक', 'मंसिर', 'पौष', 'मार्ग', 'फाल्गुन', 'चैत्र'
|
|
331
|
+
],
|
|
332
|
+
modern: [
|
|
333
|
+
'बैशाख', 'जेठ', 'असार', 'साउन', 'भदौ', 'अशोज', 'कार्तिक', 'मंसिर', 'पुष', 'माघ', 'फागुन', 'चैत'
|
|
334
|
+
],
|
|
335
|
+
short: [
|
|
336
|
+
'बै', 'जे', 'अ', 'श्रा', 'भा', 'आ', 'का', 'मं', 'पौ', 'मा', 'फा', 'चै'
|
|
337
|
+
]
|
|
338
|
+
}
|
|
339
|
+
};
|
|
340
|
+
|
|
341
|
+
class ToNpPipe {
|
|
342
|
+
transform(value, language = 'ne', type = 'number') {
|
|
343
|
+
if (value) {
|
|
344
|
+
if (language === 'ne') {
|
|
345
|
+
switch (type) {
|
|
346
|
+
case 'number':
|
|
347
|
+
const split = value.toString().split('');
|
|
348
|
+
return split
|
|
349
|
+
.map((n) => {
|
|
350
|
+
if (n === ' ') {
|
|
351
|
+
return ' ';
|
|
352
|
+
}
|
|
353
|
+
return numberMapping[+n] ? numberMapping[+n] : n;
|
|
354
|
+
})
|
|
355
|
+
.join('');
|
|
356
|
+
case 'word':
|
|
357
|
+
let wrd = value.toString().toLowerCase();
|
|
358
|
+
if (wrd === 'month') {
|
|
359
|
+
return wordsMapping['month'];
|
|
360
|
+
}
|
|
361
|
+
else if (wrd === 'year') {
|
|
362
|
+
return wordsMapping['year'];
|
|
363
|
+
}
|
|
364
|
+
else {
|
|
365
|
+
return wrd;
|
|
366
|
+
}
|
|
367
|
+
default:
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
else {
|
|
371
|
+
return value;
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
else {
|
|
375
|
+
return '';
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
ToNpPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.3", ngImport: i0, type: ToNpPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
380
|
+
ToNpPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "12.0.0", version: "13.1.3", ngImport: i0, type: ToNpPipe, name: "toNp" });
|
|
381
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.3", ngImport: i0, type: ToNpPipe, decorators: [{
|
|
382
|
+
type: Pipe,
|
|
383
|
+
args: [{
|
|
384
|
+
name: 'toNp',
|
|
385
|
+
}]
|
|
386
|
+
}] });
|
|
387
|
+
|
|
388
|
+
class NpDatePickerComponent {
|
|
389
|
+
constructor(_nepaliDate, eRef) {
|
|
390
|
+
this._nepaliDate = _nepaliDate;
|
|
391
|
+
this.eRef = eRef;
|
|
392
|
+
this.nepaliDateToday = { day: 0, month: 0, year: 0 };
|
|
393
|
+
this.currentNepaliDate = { day: 0, month: 0, year: 0 };
|
|
394
|
+
this.formattedDate = '';
|
|
395
|
+
this.years = [];
|
|
396
|
+
this.daysMapping = daysMapping;
|
|
397
|
+
this.monthsMapping = monthsMapping;
|
|
398
|
+
this.isOpen = false;
|
|
399
|
+
this.hideInput = false;
|
|
400
|
+
this.alwaysVisible = false;
|
|
401
|
+
this.language = 'ne';
|
|
402
|
+
this.monthDisplayType = 'modern';
|
|
403
|
+
this.dayDisplayType = 'short';
|
|
404
|
+
this.dateFormatter = (selectedDate) => {
|
|
405
|
+
const dd = selectedDate.day < 10 ? '0' + selectedDate.day : selectedDate.day;
|
|
406
|
+
const mm = selectedDate.month < 10 ? '0' + selectedDate.month : selectedDate.month;
|
|
407
|
+
return `${dd}/${mm}/${this.selectedDate.year}`;
|
|
408
|
+
};
|
|
409
|
+
this.propagateChange = (_) => { };
|
|
410
|
+
this.propagateTouch = (_) => { };
|
|
411
|
+
this.currentDate = new Date();
|
|
412
|
+
}
|
|
413
|
+
clickout(event) {
|
|
414
|
+
if (!this.eRef.nativeElement.contains(event.target)) {
|
|
415
|
+
this.close();
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
ngOnInit() {
|
|
419
|
+
this.nepaliDateToday = this._nepaliDate.setCurrentNepaliDate();
|
|
420
|
+
this.setCurrentDate();
|
|
421
|
+
this.populateYears();
|
|
422
|
+
this.setCurrentMonthData();
|
|
423
|
+
this.selectDate(this.currentNepaliDate.day);
|
|
424
|
+
}
|
|
425
|
+
populateYears() {
|
|
426
|
+
for (let i = 2001; i <= 2099; i++) {
|
|
427
|
+
this.years.push(i);
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
selectYear(e) {
|
|
431
|
+
this.currentNepaliDate.year = e.target.value;
|
|
432
|
+
const newDate = {
|
|
433
|
+
day: this.currentNepaliDate.day,
|
|
434
|
+
month: this.currentNepaliDate.month,
|
|
435
|
+
year: this.currentNepaliDate.year,
|
|
436
|
+
};
|
|
437
|
+
this.currentDate = this._nepaliDate.nepToEngDate(newDate.day, newDate.month + 1, newDate.year);
|
|
438
|
+
this.setCurrentMonthData();
|
|
439
|
+
}
|
|
440
|
+
selectMonth(e) {
|
|
441
|
+
var _a, _b;
|
|
442
|
+
let month = e.target.value;
|
|
443
|
+
let nep_month_index = (_b = (_a = this.monthsMapping[this.language][this.monthDisplayType]) === null || _a === void 0 ? void 0 : _a.indexOf(month)) !== null && _b !== void 0 ? _b : 0;
|
|
444
|
+
this.currentNepaliDate.month = nep_month_index;
|
|
445
|
+
const newNepaliDate = {
|
|
446
|
+
day: this.currentNepaliDate.day,
|
|
447
|
+
month: this.currentNepaliDate.month,
|
|
448
|
+
year: this.currentNepaliDate.year,
|
|
449
|
+
};
|
|
450
|
+
this.currentDate = this._nepaliDate.nepToEngDate(newNepaliDate.day, newNepaliDate.month + 1, newNepaliDate.year);
|
|
451
|
+
this.setCurrentMonthData();
|
|
452
|
+
}
|
|
453
|
+
resetCurrentMonthData() {
|
|
454
|
+
this.currentMonthData = {
|
|
455
|
+
0: [],
|
|
456
|
+
1: [],
|
|
457
|
+
2: [],
|
|
458
|
+
3: [],
|
|
459
|
+
4: [],
|
|
460
|
+
5: [],
|
|
461
|
+
6: [],
|
|
462
|
+
};
|
|
463
|
+
}
|
|
464
|
+
formatValue() {
|
|
465
|
+
if (this.selectedDate) {
|
|
466
|
+
this.formattedDate = this.dateFormatter(this.selectedDate);
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
writeValue(value) {
|
|
470
|
+
if (value) {
|
|
471
|
+
this.selectedDate = value;
|
|
472
|
+
this.currentNepaliDate = value;
|
|
473
|
+
this.formatValue();
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
registerOnTouched() { }
|
|
477
|
+
registerOnChange(fn) {
|
|
478
|
+
this.propagateChange = fn;
|
|
479
|
+
}
|
|
480
|
+
setCurrentDate() {
|
|
481
|
+
if (!this.selectedDate) {
|
|
482
|
+
this.currentNepaliDate = this._nepaliDate.engToNepDate(this.currentDate.getDate(), this.currentDate.getMonth(), this.currentDate.getFullYear());
|
|
483
|
+
}
|
|
484
|
+
else {
|
|
485
|
+
const { day, month, year } = this.selectedDate;
|
|
486
|
+
this.currentNepaliDate = this._nepaliDate.engToNepDate(day, month, year);
|
|
487
|
+
this.currentDate = this._nepaliDate.nepToEngDate(this.selectedDate.year, this.selectedDate.month + 1, this.selectedDate.day);
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
setCurrentMonthData() {
|
|
491
|
+
this.resetCurrentMonthData();
|
|
492
|
+
// fill the currentMonthData with current date
|
|
493
|
+
let day = this.currentDate.getDay();
|
|
494
|
+
this.currentMonthData[day] = [this.currentNepaliDate.day];
|
|
495
|
+
// fill the currentMonthData with day before the current date
|
|
496
|
+
this.setMonthDataBefore(day - 1, this.currentNepaliDate.day - 1);
|
|
497
|
+
var currentMonthMaxValue = this._nepaliDate.nepaliMonths[this.currentNepaliDate.year - 2000][this.currentNepaliDate.month];
|
|
498
|
+
// fill the currentMonthData with day after the current date
|
|
499
|
+
this.setMonthDataAfter(day + 1, this.currentNepaliDate.day + 1, currentMonthMaxValue);
|
|
500
|
+
// we need some empty spaces in place so that the dates are shown in correct order
|
|
501
|
+
// eg if the 1st day starts on monday then we need 1 empty space for non existingn date on Sunday
|
|
502
|
+
this.createEmptySpaces();
|
|
503
|
+
}
|
|
504
|
+
setMonthDataBefore(day, date) {
|
|
505
|
+
if (date >= 1) {
|
|
506
|
+
if (day < 0) {
|
|
507
|
+
day = 6;
|
|
508
|
+
}
|
|
509
|
+
this.currentMonthData[day] = [date, ...this.currentMonthData[day]];
|
|
510
|
+
this.setMonthDataBefore(--day, --date);
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
setMonthDataAfter(day, date, currentMonthMaxValue) {
|
|
514
|
+
const nepaliDate = {
|
|
515
|
+
day: date,
|
|
516
|
+
month: this.currentNepaliDate.month,
|
|
517
|
+
year: this.currentNepaliDate.year,
|
|
518
|
+
};
|
|
519
|
+
// only add the data if the current month matches
|
|
520
|
+
if (date <= currentMonthMaxValue) {
|
|
521
|
+
if (day > 6) {
|
|
522
|
+
day = 0;
|
|
523
|
+
}
|
|
524
|
+
this.currentMonthData[day] = [...this.currentMonthData[day], date];
|
|
525
|
+
this.setMonthDataAfter(++day, ++date, currentMonthMaxValue);
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
createEmptySpaces() {
|
|
529
|
+
// first find out which day has the 1st
|
|
530
|
+
// if its a Sunday, then don't do anything else add 1 space on each previous day
|
|
531
|
+
let dayIndex = 0;
|
|
532
|
+
let value;
|
|
533
|
+
Object.values(this.currentMonthData).map((item, index) => {
|
|
534
|
+
value = item;
|
|
535
|
+
if (value.includes(1)) {
|
|
536
|
+
dayIndex = index;
|
|
537
|
+
}
|
|
538
|
+
return value.includes(1);
|
|
539
|
+
});
|
|
540
|
+
if (dayIndex) {
|
|
541
|
+
for (dayIndex; dayIndex > 0; dayIndex--) {
|
|
542
|
+
const monthData = this.currentMonthData[dayIndex - 1];
|
|
543
|
+
this.currentMonthData[dayIndex - 1] = [null, ...monthData];
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
selectDate(day) {
|
|
548
|
+
console.log(this.currentNepaliDate);
|
|
549
|
+
this.selectedDate = Object.assign(Object.assign({}, this.currentNepaliDate), { day });
|
|
550
|
+
console.log(this.selectedDate);
|
|
551
|
+
this.formatValue();
|
|
552
|
+
this.close();
|
|
553
|
+
this.propagateChange(this.selectedDate);
|
|
554
|
+
}
|
|
555
|
+
prevMonth() {
|
|
556
|
+
if (this.currentNepaliDate.month <= 0) {
|
|
557
|
+
this.currentNepaliDate.month = 11;
|
|
558
|
+
this.currentNepaliDate.year--;
|
|
559
|
+
}
|
|
560
|
+
else {
|
|
561
|
+
this.currentNepaliDate.month--;
|
|
562
|
+
}
|
|
563
|
+
const newNepaliDate = {
|
|
564
|
+
day: this.currentNepaliDate.day,
|
|
565
|
+
month: this.currentNepaliDate.month,
|
|
566
|
+
year: this.currentNepaliDate.year,
|
|
567
|
+
};
|
|
568
|
+
this.currentDate = this._nepaliDate.nepToEngDate(newNepaliDate.day, newNepaliDate.month + 1, newNepaliDate.year);
|
|
569
|
+
this.setCurrentMonthData();
|
|
570
|
+
}
|
|
571
|
+
nextMonth() {
|
|
572
|
+
if (this.currentNepaliDate.month >= 11) {
|
|
573
|
+
this.currentNepaliDate.month = 0;
|
|
574
|
+
this.currentNepaliDate.year++;
|
|
575
|
+
}
|
|
576
|
+
else {
|
|
577
|
+
this.currentNepaliDate.month++;
|
|
578
|
+
}
|
|
579
|
+
console.log(this.currentNepaliDate);
|
|
580
|
+
const newDate = {
|
|
581
|
+
day: this.currentNepaliDate.day,
|
|
582
|
+
month: this.currentNepaliDate.month,
|
|
583
|
+
year: this.currentNepaliDate.year,
|
|
584
|
+
};
|
|
585
|
+
this.currentDate = this._nepaliDate.nepToEngDate(newDate.day, newDate.month + 1, newDate.year);
|
|
586
|
+
this.setCurrentMonthData();
|
|
587
|
+
}
|
|
588
|
+
toggleOpen() {
|
|
589
|
+
if (!this.alwaysVisible) {
|
|
590
|
+
this.isOpen = !this.isOpen;
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
open() {
|
|
594
|
+
this.isOpen = true;
|
|
595
|
+
}
|
|
596
|
+
close() {
|
|
597
|
+
this.isOpen = false;
|
|
598
|
+
//this.setCurrentDate();
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
NpDatePickerComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.3", ngImport: i0, type: NpDatePickerComponent, deps: [{ token: NpDatePickerService }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component });
|
|
602
|
+
NpDatePickerComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.1.3", type: NpDatePickerComponent, selector: "np-datepicker", inputs: { theme: "theme", language: "language", monthDisplayType: "monthDisplayType" }, host: { listeners: { "document:click": "clickout($event)" } }, providers: [
|
|
603
|
+
{
|
|
604
|
+
provide: NG_VALUE_ACCESSOR,
|
|
605
|
+
useExisting: forwardRef(() => NpDatePickerComponent),
|
|
606
|
+
multi: true,
|
|
607
|
+
},
|
|
608
|
+
], ngImport: i0, template: "<div class=\"nepali-date-picker\" [ngClass]=\"theme\">\n \n <input\n class=\"np_datepicker_input\"\n type=\"text\"\n [value]=\"formattedDate\"\n (focus)=\"open()\"\n (keydown)=\"$event.preventDefault()\"\n aria-hidden=\"true\"\n [hidden]=\"hideInput\"\n />\n <a class=\"form-icon\" (click)=\"toggleOpen()\" [ngClass]=\"isOpen ? 'active' : ''\">\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 448 512\">\n <path\n d=\"M152 64H296V24C296 10.75 306.7 0 320 0C333.3 0 344 10.75 344 24V64H384C419.3 64 448 92.65 448 128V448C448 483.3 419.3 512 384 512H64C28.65 512 0 483.3 0 448V128C0 92.65 28.65 64 64 64H104V24C104 10.75 114.7 0 128 0C141.3 0 152 10.75 152 24V64zM48 448C48 456.8 55.16 464 64 464H384C392.8 464 400 456.8 400 448V192H48V448z\"\n />\n </svg>\n </a>\n <ng-container [ngTemplateOutlet]=\"dp\" *ngIf=\"isOpen\"></ng-container>\n</div>\n<!--.nepali-date-picker-->\n\n<ng-template #dp>\n <div class=\"datepicker__container\">\n <div class=\"datepicker__options-container\">\n <a class=\"prev-month\" (click)=\"prevMonth()\">\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 320 512\">\n <path\n d=\"M224 480c-8.188 0-16.38-3.125-22.62-9.375l-192-192c-12.5-12.5-12.5-32.75 0-45.25l192-192c12.5-12.5 32.75-12.5 45.25 0s12.5 32.75 0 45.25L77.25 256l169.4 169.4c12.5 12.5 12.5 32.75 0 45.25C240.4 476.9 232.2 480 224 480z\"\n />\n </svg>\n </a>\n <span class=\"datepicker__options-year-container\">\n <span> {{ \"Year\" | toNp: language:\"word\" }}: </span>\n <select (change)=\"selectYear($event)\">\n <option\n *ngFor=\"let year of years; index as i\"\n [value]=\"year\"\n [selected]=\"year == currentNepaliDate?.year\"\n >\n {{ year | toNp: language:\"number\" }}\n </option>\n </select>\n </span>\n <span class=\"datepicker__options-month-container\">\n <span>{{ \"Month\" | toNp: language:\"word\" }}: </span>\n <select (change)=\"selectMonth($event)\">\n <option\n *ngFor=\"\n let month of monthsMapping[language][monthDisplayType];\n index as i\n \"\n [value]=\"month\"\n [selected]=\" i === currentNepaliDate?.month\"\n >\n {{ month }}\n </option>\n </select>\n </span>\n <a class=\"next-month\" (click)=\"nextMonth()\">\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 320 512\">\n <path\n d=\"M96 480c-8.188 0-16.38-3.125-22.62-9.375c-12.5-12.5-12.5-32.75 0-45.25L242.8 256L73.38 86.63c-12.5-12.5-12.5-32.75 0-45.25s32.75-12.5 45.25 0l192 192c12.5 12.5 12.5 32.75 0 45.25l-192 192C112.4 476.9 104.2 480 96 480z\"\n />\n </svg>\n </a>\n </div>\n <div class=\"datepicker__days-container\">\n <div\n class=\"datepicker__days\"\n *ngFor=\"let day of daysMapping[language][dayDisplayType]; index as i\"\n >\n <div class=\"datepicker__weekday\">{{ day }}</div>\n <div\n class=\"datepicker__date-container\"\n *ngFor=\"let date of currentMonthData[i]\"\n >\n <div\n *ngIf=\"date\"\n class=\"datepicker__date\"\n [class.datepicker__date--active]=\"\n date === selectedDate?.day &&\n currentNepaliDate.month === selectedDate?.month &&\n currentNepaliDate.year === selectedDate?.year\n \"\n [class.datepicker__date--current-day]=\"\n date === nepaliDateToday.day &&\n currentNepaliDate.month === nepaliDateToday.month &&\n currentNepaliDate.year === nepaliDateToday.year\n \"\n (click)=\"selectDate(date)\"\n >\n {{ date | toNp: language:\"number\" }}\n </div>\n <div *ngIf=\"!date\" class=\"datepicker__date--disabled\">\n <span> </span>\n </div>\n </div>\n </div>\n </div>\n </div>\n</ng-template>\n", styles: [".nepali-date-picker.nepali-date-picker{position:relative;display:inline-block;font-family:Arial,Helvetica,sans-serif;font-size:1em}.nepali-date-picker a.active svg{fill:#e45415;opacity:.9}.nepali-date-picker .form-icon svg{width:14px;opacity:.3;position:absolute;right:8px;top:12px;cursor:pointer}.datepicker__container{border:1px solid #eee;background:#fff;width:294px;box-shadow:#64646f33 0 7px 29px;position:absolute;z-index:99999}.datepicker__options-container{padding:18px 8px;border-bottom:1px solid #eee;display:flex;justify-content:space-between;background-color:#e45415;color:#fff;line-height:30px}.datepicker__days-container{display:flex;justify-content:space-evenly;color:#777}.datepicker__days{text-align:center;border:1px solid #eee}.datepicker__weekday{padding:10px;background-color:#f3f3f3;margin-bottom:1px;font-weight:700}.datepicker__date-container{width:40px;height:40px;line-height:40px;border-bottom:1px solid #eee}.datepicker__date{cursor:pointer}.datepicker__date:hover{background-color:#eee}.datepicker__date--active.datepicker__date--active{background-color:#e45415;color:#fff}.datepicker__options-container span{font-size:14px}select:focus,select:focus-visible{outline:1px solid #fff}select{border:none;color:#fff;background:none;font-size:14px}select option{color:#333}.np_datepicker_input{border:1px solid #eee;padding:10px;font-size:16px;color:#777}.np_datepicker_input:focus-visible{outline:2px solid #e45415}.prev-month,.next-month{padding:5px;width:20px;height:20px;display:block;opacity:.5;border-radius:50%;background:#f3f3f3;cursor:pointer;text-align:center;line-height:25px}.next-month:hover,.prev-month:hover{background:#ccc}.prev-month svg,.next-month svg{max-width:10px;height:auto}.prev-month{margin-right:5px}.next-month{margin-left:5px}.dark.nepali-date-picker a.active svg{fill:#000}.dark .datepicker__options-container{border-bottom:1px solid #000;background-color:#000;color:#fff}.dark select{color:#fff}.dark .datepicker__date--active.datepicker__date--active{background-color:#000;color:#fff}.dark .np_datepicker_input:focus-visible{outline:2px solid #000}.dark .datepicker__weekday{background-color:#111}.dark .datepicker__days{background-color:#333;border:1px solid #111}.dark .datepicker__date:hover{background-color:#111;color:#fff}.dark .datepicker__date-container{border-bottom:1px solid #222}.light.nepali-date-picker a.active svg{fill:#777}.light .datepicker__options-container{border-bottom:none;background-color:#fff;color:#777}.light select{color:#777}.light .datepicker__date--active.datepicker__date--active{background-color:#aaa;color:#fff}.light .np_datepicker_input:focus-visible{outline:1px solid #ddd}.lightblue.nepali-date-picker a.active svg{fill:#38c5f0da}.lightblue .datepicker__options-container{background-color:#38c5f0da;color:#fff}.lightblue select{color:#fff}.lightblue .datepicker__date--active.datepicker__date--active{background-color:#38c5f0da;color:#fff}.lightblue .np_datepicker_input:focus-visible{outline:2px solid #38c5f0da}.lightblue .np_datepicker_input:focus-visible{outline:1px solid #38c5f0da}\n"], directives: [{ type: i2.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i2.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet"] }, { type: i2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i3.NgSelectOption, selector: "option", inputs: ["ngValue", "value"] }, { type: i3.ɵNgSelectMultipleOption, selector: "option", inputs: ["ngValue", "value"] }], pipes: { "toNp": ToNpPipe }, encapsulation: i0.ViewEncapsulation.None });
|
|
609
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.3", ngImport: i0, type: NpDatePickerComponent, decorators: [{
|
|
610
|
+
type: Component,
|
|
611
|
+
args: [{ selector: 'np-datepicker', providers: [
|
|
612
|
+
{
|
|
613
|
+
provide: NG_VALUE_ACCESSOR,
|
|
614
|
+
useExisting: forwardRef(() => NpDatePickerComponent),
|
|
615
|
+
multi: true,
|
|
616
|
+
},
|
|
617
|
+
], encapsulation: ViewEncapsulation.None, template: "<div class=\"nepali-date-picker\" [ngClass]=\"theme\">\n \n <input\n class=\"np_datepicker_input\"\n type=\"text\"\n [value]=\"formattedDate\"\n (focus)=\"open()\"\n (keydown)=\"$event.preventDefault()\"\n aria-hidden=\"true\"\n [hidden]=\"hideInput\"\n />\n <a class=\"form-icon\" (click)=\"toggleOpen()\" [ngClass]=\"isOpen ? 'active' : ''\">\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 448 512\">\n <path\n d=\"M152 64H296V24C296 10.75 306.7 0 320 0C333.3 0 344 10.75 344 24V64H384C419.3 64 448 92.65 448 128V448C448 483.3 419.3 512 384 512H64C28.65 512 0 483.3 0 448V128C0 92.65 28.65 64 64 64H104V24C104 10.75 114.7 0 128 0C141.3 0 152 10.75 152 24V64zM48 448C48 456.8 55.16 464 64 464H384C392.8 464 400 456.8 400 448V192H48V448z\"\n />\n </svg>\n </a>\n <ng-container [ngTemplateOutlet]=\"dp\" *ngIf=\"isOpen\"></ng-container>\n</div>\n<!--.nepali-date-picker-->\n\n<ng-template #dp>\n <div class=\"datepicker__container\">\n <div class=\"datepicker__options-container\">\n <a class=\"prev-month\" (click)=\"prevMonth()\">\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 320 512\">\n <path\n d=\"M224 480c-8.188 0-16.38-3.125-22.62-9.375l-192-192c-12.5-12.5-12.5-32.75 0-45.25l192-192c12.5-12.5 32.75-12.5 45.25 0s12.5 32.75 0 45.25L77.25 256l169.4 169.4c12.5 12.5 12.5 32.75 0 45.25C240.4 476.9 232.2 480 224 480z\"\n />\n </svg>\n </a>\n <span class=\"datepicker__options-year-container\">\n <span> {{ \"Year\" | toNp: language:\"word\" }}: </span>\n <select (change)=\"selectYear($event)\">\n <option\n *ngFor=\"let year of years; index as i\"\n [value]=\"year\"\n [selected]=\"year == currentNepaliDate?.year\"\n >\n {{ year | toNp: language:\"number\" }}\n </option>\n </select>\n </span>\n <span class=\"datepicker__options-month-container\">\n <span>{{ \"Month\" | toNp: language:\"word\" }}: </span>\n <select (change)=\"selectMonth($event)\">\n <option\n *ngFor=\"\n let month of monthsMapping[language][monthDisplayType];\n index as i\n \"\n [value]=\"month\"\n [selected]=\" i === currentNepaliDate?.month\"\n >\n {{ month }}\n </option>\n </select>\n </span>\n <a class=\"next-month\" (click)=\"nextMonth()\">\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 320 512\">\n <path\n d=\"M96 480c-8.188 0-16.38-3.125-22.62-9.375c-12.5-12.5-12.5-32.75 0-45.25L242.8 256L73.38 86.63c-12.5-12.5-12.5-32.75 0-45.25s32.75-12.5 45.25 0l192 192c12.5 12.5 12.5 32.75 0 45.25l-192 192C112.4 476.9 104.2 480 96 480z\"\n />\n </svg>\n </a>\n </div>\n <div class=\"datepicker__days-container\">\n <div\n class=\"datepicker__days\"\n *ngFor=\"let day of daysMapping[language][dayDisplayType]; index as i\"\n >\n <div class=\"datepicker__weekday\">{{ day }}</div>\n <div\n class=\"datepicker__date-container\"\n *ngFor=\"let date of currentMonthData[i]\"\n >\n <div\n *ngIf=\"date\"\n class=\"datepicker__date\"\n [class.datepicker__date--active]=\"\n date === selectedDate?.day &&\n currentNepaliDate.month === selectedDate?.month &&\n currentNepaliDate.year === selectedDate?.year\n \"\n [class.datepicker__date--current-day]=\"\n date === nepaliDateToday.day &&\n currentNepaliDate.month === nepaliDateToday.month &&\n currentNepaliDate.year === nepaliDateToday.year\n \"\n (click)=\"selectDate(date)\"\n >\n {{ date | toNp: language:\"number\" }}\n </div>\n <div *ngIf=\"!date\" class=\"datepicker__date--disabled\">\n <span> </span>\n </div>\n </div>\n </div>\n </div>\n </div>\n</ng-template>\n", styles: [".nepali-date-picker.nepali-date-picker{position:relative;display:inline-block;font-family:Arial,Helvetica,sans-serif;font-size:1em}.nepali-date-picker a.active svg{fill:#e45415;opacity:.9}.nepali-date-picker .form-icon svg{width:14px;opacity:.3;position:absolute;right:8px;top:12px;cursor:pointer}.datepicker__container{border:1px solid #eee;background:#fff;width:294px;box-shadow:#64646f33 0 7px 29px;position:absolute;z-index:99999}.datepicker__options-container{padding:18px 8px;border-bottom:1px solid #eee;display:flex;justify-content:space-between;background-color:#e45415;color:#fff;line-height:30px}.datepicker__days-container{display:flex;justify-content:space-evenly;color:#777}.datepicker__days{text-align:center;border:1px solid #eee}.datepicker__weekday{padding:10px;background-color:#f3f3f3;margin-bottom:1px;font-weight:700}.datepicker__date-container{width:40px;height:40px;line-height:40px;border-bottom:1px solid #eee}.datepicker__date{cursor:pointer}.datepicker__date:hover{background-color:#eee}.datepicker__date--active.datepicker__date--active{background-color:#e45415;color:#fff}.datepicker__options-container span{font-size:14px}select:focus,select:focus-visible{outline:1px solid #fff}select{border:none;color:#fff;background:none;font-size:14px}select option{color:#333}.np_datepicker_input{border:1px solid #eee;padding:10px;font-size:16px;color:#777}.np_datepicker_input:focus-visible{outline:2px solid #e45415}.prev-month,.next-month{padding:5px;width:20px;height:20px;display:block;opacity:.5;border-radius:50%;background:#f3f3f3;cursor:pointer;text-align:center;line-height:25px}.next-month:hover,.prev-month:hover{background:#ccc}.prev-month svg,.next-month svg{max-width:10px;height:auto}.prev-month{margin-right:5px}.next-month{margin-left:5px}.dark.nepali-date-picker a.active svg{fill:#000}.dark .datepicker__options-container{border-bottom:1px solid #000;background-color:#000;color:#fff}.dark select{color:#fff}.dark .datepicker__date--active.datepicker__date--active{background-color:#000;color:#fff}.dark .np_datepicker_input:focus-visible{outline:2px solid #000}.dark .datepicker__weekday{background-color:#111}.dark .datepicker__days{background-color:#333;border:1px solid #111}.dark .datepicker__date:hover{background-color:#111;color:#fff}.dark .datepicker__date-container{border-bottom:1px solid #222}.light.nepali-date-picker a.active svg{fill:#777}.light .datepicker__options-container{border-bottom:none;background-color:#fff;color:#777}.light select{color:#777}.light .datepicker__date--active.datepicker__date--active{background-color:#aaa;color:#fff}.light .np_datepicker_input:focus-visible{outline:1px solid #ddd}.lightblue.nepali-date-picker a.active svg{fill:#38c5f0da}.lightblue .datepicker__options-container{background-color:#38c5f0da;color:#fff}.lightblue select{color:#fff}.lightblue .datepicker__date--active.datepicker__date--active{background-color:#38c5f0da;color:#fff}.lightblue .np_datepicker_input:focus-visible{outline:2px solid #38c5f0da}.lightblue .np_datepicker_input:focus-visible{outline:1px solid #38c5f0da}\n"] }]
|
|
618
|
+
}], ctorParameters: function () { return [{ type: NpDatePickerService }, { type: i0.ElementRef }]; }, propDecorators: { theme: [{
|
|
619
|
+
type: Input
|
|
620
|
+
}], language: [{
|
|
621
|
+
type: Input
|
|
622
|
+
}], monthDisplayType: [{
|
|
623
|
+
type: Input
|
|
624
|
+
}], clickout: [{
|
|
625
|
+
type: HostListener,
|
|
626
|
+
args: ['document:click', ['$event']]
|
|
627
|
+
}] } });
|
|
628
|
+
|
|
629
|
+
class NepaliDatepickerModule {
|
|
630
|
+
}
|
|
631
|
+
NepaliDatepickerModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.3", ngImport: i0, type: NepaliDatepickerModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
632
|
+
NepaliDatepickerModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.1.3", ngImport: i0, type: NepaliDatepickerModule, declarations: [ToNpPipe,
|
|
633
|
+
NpDatePickerComponent], imports: [BrowserModule,
|
|
634
|
+
FormsModule], exports: [NpDatePickerComponent] });
|
|
635
|
+
NepaliDatepickerModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.1.3", ngImport: i0, type: NepaliDatepickerModule, imports: [[
|
|
636
|
+
BrowserModule,
|
|
637
|
+
FormsModule
|
|
638
|
+
]] });
|
|
639
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.3", ngImport: i0, type: NepaliDatepickerModule, decorators: [{
|
|
640
|
+
type: NgModule,
|
|
641
|
+
args: [{
|
|
642
|
+
declarations: [
|
|
643
|
+
ToNpPipe,
|
|
644
|
+
NpDatePickerComponent
|
|
645
|
+
],
|
|
646
|
+
imports: [
|
|
647
|
+
BrowserModule,
|
|
648
|
+
FormsModule
|
|
649
|
+
],
|
|
650
|
+
exports: [
|
|
651
|
+
NpDatePickerComponent
|
|
652
|
+
]
|
|
653
|
+
}]
|
|
654
|
+
}] });
|
|
655
|
+
|
|
656
|
+
/*
|
|
657
|
+
* Public API Surface of npx-np-datepicker
|
|
658
|
+
*/
|
|
659
|
+
|
|
660
|
+
/**
|
|
661
|
+
* Generated bundle index. Do not edit.
|
|
662
|
+
*/
|
|
663
|
+
|
|
664
|
+
export { NepaliDatepickerModule, NpDatePickerComponent, NpDatePickerService };
|
|
665
|
+
//# sourceMappingURL=ngx-np-datepicker.mjs.map
|