hijri-date-time-picker 1.0.2 → 1.0.31
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/QUICKSTART.md +121 -0
- package/README.md +3 -0
- package/docs/INITIAL_DATE_BINDING.md +183 -0
- package/docs/MIN_MAX_DATE.md +326 -0
- package/ng-package.json +11 -0
- package/package.json +7 -9
- package/{dist/demo.js → src/demo.ts} +33 -36
- package/src/lib/hijri-date-picker.component.css +524 -0
- package/src/lib/hijri-date-picker.component.html +229 -0
- package/src/lib/hijri-date-picker.component.ts +795 -0
- package/src/lib/hijri-date-picker.types.ts +164 -0
- package/src/types/hijri-date.d.ts +43 -0
- package/tsconfig.json +39 -0
- package/dist/LICENSE +0 -21
- package/dist/README.md +0 -185
- package/dist/demo.d.ts +0 -12
- package/dist/esm2022/hijri-date-time-picker.mjs +0 -5
- package/dist/esm2022/index.mjs +0 -3
- package/dist/esm2022/lib/hijri-date-picker.component.mjs +0 -606
- package/dist/esm2022/lib/hijri-date-picker.types.mjs +0 -22
- package/dist/fesm2022/hijri-date-time-picker.mjs +0 -634
- package/dist/fesm2022/hijri-date-time-picker.mjs.map +0 -1
- package/dist/index.js +0 -2
- package/dist/lib/hijri-date-picker.component.d.ts +0 -88
- package/dist/lib/hijri-date-picker.component.js +0 -774
- package/dist/lib/hijri-date-picker.types.d.ts +0 -84
- package/dist/lib/hijri-date-picker.types.js +0 -77
- /package/{dist/index.d.ts → src/index.ts} +0 -0
|
@@ -1,634 +0,0 @@
|
|
|
1
|
-
import * as i0 from '@angular/core';
|
|
2
|
-
import { EventEmitter, Output, Input, Component } from '@angular/core';
|
|
3
|
-
import * as i1 from '@angular/common';
|
|
4
|
-
import { CommonModule } from '@angular/common';
|
|
5
|
-
import HijriDate, { toHijri } from 'hijri-date/lib/safe';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Month names in different locales
|
|
9
|
-
*/
|
|
10
|
-
const GREGORIAN_MONTHS_EN = [
|
|
11
|
-
'January', 'February', 'March', 'April', 'May', 'June',
|
|
12
|
-
'July', 'August', 'September', 'October', 'November', 'December'
|
|
13
|
-
];
|
|
14
|
-
const GREGORIAN_MONTHS_AR = [
|
|
15
|
-
'يناير', 'فبراير', 'مارس', 'أبريل', 'مايو', 'يونيو',
|
|
16
|
-
'يوليو', 'أغسطس', 'سبتمبر', 'أكتوبر', 'نوفمبر', 'ديسمبر'
|
|
17
|
-
];
|
|
18
|
-
const HIJRI_MONTHS_EN = [
|
|
19
|
-
'Muharram', 'Safar', 'Rabi\' al-Awwal', 'Rabi\' al-Thani', 'Jumada al-Awwal', 'Jumada al-Thani',
|
|
20
|
-
'Rajab', 'Sha\'ban', 'Ramadan', 'Shawwal', 'Dhu al-Qi\'dah', 'Dhu al-Hijjah'
|
|
21
|
-
];
|
|
22
|
-
const HIJRI_MONTHS_AR = [
|
|
23
|
-
'محرم', 'صفر', 'ربيع الأول', 'ربيع الثاني', 'جمادى الأولى', 'جمادى الثانية',
|
|
24
|
-
'رجب', 'شعبان', 'رمضان', 'شوال', 'ذو القعدة', 'ذو الحجة'
|
|
25
|
-
];
|
|
26
|
-
const WEEKDAY_NAMES_EN = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
|
|
27
|
-
const WEEKDAY_NAMES_AR = ['الأحد', 'الإثنين', 'الثلاثاء', 'الأربعاء', 'الخميس', 'الجمعة', 'السبت'];
|
|
28
|
-
|
|
29
|
-
class HijriDatePickerComponent {
|
|
30
|
-
// Mode & Configuration
|
|
31
|
-
canChangeMode = true;
|
|
32
|
-
mode = 'greg';
|
|
33
|
-
dir = 'ltr';
|
|
34
|
-
locale = 'en';
|
|
35
|
-
// Validation
|
|
36
|
-
futureValidation = true;
|
|
37
|
-
futureYearsLimit = 10;
|
|
38
|
-
isRequired = false;
|
|
39
|
-
minDate; // Minimum selectable date
|
|
40
|
-
maxDate; // Maximum selectable date
|
|
41
|
-
// Selection
|
|
42
|
-
multiple = false;
|
|
43
|
-
showConfirmButton = false;
|
|
44
|
-
initialSelectedDate; // For single selection mode - bind initial date
|
|
45
|
-
initialSelectedDates; // For multiple selection mode - bind initial dates
|
|
46
|
-
// Labels
|
|
47
|
-
submitTextButton = 'Submit';
|
|
48
|
-
todaysDateText = 'Today';
|
|
49
|
-
ummAlQuraDateText = 'Umm Al-Qura Calendar';
|
|
50
|
-
yearSelectLabel = 'Year';
|
|
51
|
-
monthSelectLabel = 'Month';
|
|
52
|
-
// Display Options
|
|
53
|
-
todaysDateSection = true;
|
|
54
|
-
markToday = true;
|
|
55
|
-
disableYearPicker = false;
|
|
56
|
-
disableMonthPicker = false;
|
|
57
|
-
disableDayPicker = false;
|
|
58
|
-
// Styling
|
|
59
|
-
styles = {};
|
|
60
|
-
// Time Configuration
|
|
61
|
-
enableTime = false;
|
|
62
|
-
timeFormat = '24';
|
|
63
|
-
minuteStep = 1;
|
|
64
|
-
enableSeconds = false;
|
|
65
|
-
defaultTime;
|
|
66
|
-
// Outputs
|
|
67
|
-
dateSelected = new EventEmitter();
|
|
68
|
-
modeChanged = new EventEmitter();
|
|
69
|
-
// Internal State
|
|
70
|
-
currentYear = new Date().getFullYear();
|
|
71
|
-
currentMonth = new Date().getMonth();
|
|
72
|
-
currentHijriYear = 0;
|
|
73
|
-
currentHijriMonth = 0;
|
|
74
|
-
selectedDates = [];
|
|
75
|
-
calendarDays = [];
|
|
76
|
-
today = new Date();
|
|
77
|
-
years = [];
|
|
78
|
-
months = [];
|
|
79
|
-
weekdays = [];
|
|
80
|
-
// Time state
|
|
81
|
-
selectedTime = {
|
|
82
|
-
hours: 0,
|
|
83
|
-
minutes: 0,
|
|
84
|
-
seconds: 0
|
|
85
|
-
};
|
|
86
|
-
isPM = false;
|
|
87
|
-
ngOnInit() {
|
|
88
|
-
this.initializeCalendar();
|
|
89
|
-
this.initializeSelectedDates();
|
|
90
|
-
this.initializeTime();
|
|
91
|
-
this.updateLocaleData();
|
|
92
|
-
this.generateYears();
|
|
93
|
-
this.generateCalendar();
|
|
94
|
-
}
|
|
95
|
-
ngOnChanges(changes) {
|
|
96
|
-
if (changes['mode'] || changes['locale']) {
|
|
97
|
-
this.updateLocaleData();
|
|
98
|
-
this.generateCalendar();
|
|
99
|
-
}
|
|
100
|
-
// Handle changes to initial selected dates
|
|
101
|
-
if (changes['initialSelectedDate'] || changes['initialSelectedDates']) {
|
|
102
|
-
this.initializeSelectedDates();
|
|
103
|
-
this.generateCalendar();
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
initializeCalendar() {
|
|
107
|
-
const hijriToday = new HijriDate();
|
|
108
|
-
this.currentHijriYear = hijriToday.getFullYear();
|
|
109
|
-
this.currentHijriMonth = hijriToday.getMonth();
|
|
110
|
-
}
|
|
111
|
-
initializeSelectedDates() {
|
|
112
|
-
// Handle single selection mode
|
|
113
|
-
if (!this.multiple && this.initialSelectedDate) {
|
|
114
|
-
this.selectedDates = [this.createSelectedDate(this.initialSelectedDate)];
|
|
115
|
-
}
|
|
116
|
-
// Handle multiple selection mode
|
|
117
|
-
if (this.multiple && this.initialSelectedDates && this.initialSelectedDates.length > 0) {
|
|
118
|
-
this.selectedDates = this.initialSelectedDates.map(date => this.createSelectedDate(date));
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
initializeTime() {
|
|
122
|
-
if (!this.enableTime) {
|
|
123
|
-
return;
|
|
124
|
-
}
|
|
125
|
-
// Set default time if provided
|
|
126
|
-
if (this.defaultTime) {
|
|
127
|
-
this.selectedTime = {
|
|
128
|
-
hours: this.defaultTime.hours,
|
|
129
|
-
minutes: this.defaultTime.minutes,
|
|
130
|
-
seconds: this.defaultTime.seconds || 0
|
|
131
|
-
};
|
|
132
|
-
// Set AM/PM for 12-hour format
|
|
133
|
-
if (this.timeFormat === '12') {
|
|
134
|
-
this.isPM = this.selectedTime.hours >= 12;
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
else {
|
|
138
|
-
// Default to current time
|
|
139
|
-
const now = new Date();
|
|
140
|
-
this.selectedTime = {
|
|
141
|
-
hours: now.getHours(),
|
|
142
|
-
minutes: now.getMinutes(),
|
|
143
|
-
seconds: now.getSeconds()
|
|
144
|
-
};
|
|
145
|
-
this.isPM = this.selectedTime.hours >= 12;
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
updateLocaleData() {
|
|
149
|
-
// Update weekday names
|
|
150
|
-
this.weekdays = this.locale === 'ar' ? WEEKDAY_NAMES_AR : WEEKDAY_NAMES_EN;
|
|
151
|
-
// Update month names based on mode and locale
|
|
152
|
-
if (this.mode === 'hijri') {
|
|
153
|
-
this.months = this.locale === 'ar' ? HIJRI_MONTHS_AR : HIJRI_MONTHS_EN;
|
|
154
|
-
}
|
|
155
|
-
else {
|
|
156
|
-
this.months = this.locale === 'ar' ? GREGORIAN_MONTHS_AR : GREGORIAN_MONTHS_EN;
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
generateYears() {
|
|
160
|
-
const currentYear = this.mode === 'hijri' ? this.currentHijriYear : this.currentYear;
|
|
161
|
-
const startYear = currentYear - 100;
|
|
162
|
-
const endYear = currentYear + this.futureYearsLimit;
|
|
163
|
-
this.years = [];
|
|
164
|
-
for (let year = startYear; year <= endYear; year++) {
|
|
165
|
-
this.years.push(year);
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
generateCalendar() {
|
|
169
|
-
this.calendarDays = [];
|
|
170
|
-
if (this.mode === 'hijri') {
|
|
171
|
-
this.generateHijriCalendar();
|
|
172
|
-
}
|
|
173
|
-
else {
|
|
174
|
-
this.generateGregorianCalendar();
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
generateGregorianCalendar() {
|
|
178
|
-
const firstDay = new Date(this.currentYear, this.currentMonth, 1);
|
|
179
|
-
const lastDay = new Date(this.currentYear, this.currentMonth + 1, 0);
|
|
180
|
-
const startingDayOfWeek = firstDay.getDay();
|
|
181
|
-
const daysInMonth = lastDay.getDate();
|
|
182
|
-
// Add empty cells for days before the first day of the month
|
|
183
|
-
for (let i = 0; i < startingDayOfWeek; i++) {
|
|
184
|
-
this.calendarDays.push({ day: null, disabled: true });
|
|
185
|
-
}
|
|
186
|
-
// Add days of the month
|
|
187
|
-
for (let day = 1; day <= daysInMonth; day++) {
|
|
188
|
-
const date = new Date(this.currentYear, this.currentMonth, day);
|
|
189
|
-
const isToday = this.isSameDay(date, this.today);
|
|
190
|
-
const isDisabled = this.isDateDisabled(date);
|
|
191
|
-
const isSelected = this.isDateSelected(date);
|
|
192
|
-
this.calendarDays.push({
|
|
193
|
-
day,
|
|
194
|
-
date,
|
|
195
|
-
isToday,
|
|
196
|
-
isDisabled,
|
|
197
|
-
isSelected,
|
|
198
|
-
disabled: false
|
|
199
|
-
});
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
generateHijriCalendar() {
|
|
203
|
-
const hijriDate = new HijriDate(this.currentHijriYear, this.currentHijriMonth, 1);
|
|
204
|
-
const gregorianDate = hijriDate.toGregorian();
|
|
205
|
-
const startingDayOfWeek = gregorianDate.getDay();
|
|
206
|
-
// Get days in Hijri month (typically 29 or 30)
|
|
207
|
-
const daysInMonth = this.getDaysInHijriMonth(this.currentHijriYear, this.currentHijriMonth);
|
|
208
|
-
// Add empty cells for days before the first day of the month
|
|
209
|
-
for (let i = 0; i < startingDayOfWeek; i++) {
|
|
210
|
-
this.calendarDays.push({ day: null, disabled: true });
|
|
211
|
-
}
|
|
212
|
-
// Add days of the month
|
|
213
|
-
for (let day = 1; day <= daysInMonth; day++) {
|
|
214
|
-
const hijriDay = new HijriDate(this.currentHijriYear, this.currentHijriMonth, day);
|
|
215
|
-
const gregorianDay = hijriDay.toGregorian();
|
|
216
|
-
const isToday = this.isSameDay(gregorianDay, this.today);
|
|
217
|
-
const isDisabled = this.isDateDisabled(gregorianDay);
|
|
218
|
-
const isSelected = this.isDateSelected(gregorianDay);
|
|
219
|
-
this.calendarDays.push({
|
|
220
|
-
day,
|
|
221
|
-
date: gregorianDay,
|
|
222
|
-
hijriDate: hijriDay,
|
|
223
|
-
isToday,
|
|
224
|
-
isDisabled,
|
|
225
|
-
isSelected,
|
|
226
|
-
disabled: false
|
|
227
|
-
});
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
getDaysInHijriMonth(year, month) {
|
|
231
|
-
// Try to create the 30th day; if it fails, the month has 29 days
|
|
232
|
-
try {
|
|
233
|
-
new HijriDate(year, month, 30);
|
|
234
|
-
return 30;
|
|
235
|
-
}
|
|
236
|
-
catch {
|
|
237
|
-
return 29;
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
isSameDay(date1, date2) {
|
|
241
|
-
return date1.getFullYear() === date2.getFullYear() &&
|
|
242
|
-
date1.getMonth() === date2.getMonth() &&
|
|
243
|
-
date1.getDate() === date2.getDate();
|
|
244
|
-
}
|
|
245
|
-
isDateDisabled(date) {
|
|
246
|
-
// Check minDate constraint
|
|
247
|
-
if (this.minDate) {
|
|
248
|
-
const minDateOnly = new Date(this.minDate);
|
|
249
|
-
minDateOnly.setHours(0, 0, 0, 0);
|
|
250
|
-
const checkDate = new Date(date);
|
|
251
|
-
checkDate.setHours(0, 0, 0, 0);
|
|
252
|
-
if (checkDate < minDateOnly) {
|
|
253
|
-
return true;
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
// Check maxDate constraint
|
|
257
|
-
if (this.maxDate) {
|
|
258
|
-
const maxDateOnly = new Date(this.maxDate);
|
|
259
|
-
maxDateOnly.setHours(23, 59, 59, 999);
|
|
260
|
-
const checkDate = new Date(date);
|
|
261
|
-
checkDate.setHours(0, 0, 0, 0);
|
|
262
|
-
if (checkDate > maxDateOnly) {
|
|
263
|
-
return true;
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
// Check futureValidation constraint
|
|
267
|
-
if (this.futureValidation) {
|
|
268
|
-
const maxDate = new Date();
|
|
269
|
-
maxDate.setFullYear(maxDate.getFullYear() + this.futureYearsLimit);
|
|
270
|
-
return date > maxDate;
|
|
271
|
-
}
|
|
272
|
-
return false;
|
|
273
|
-
}
|
|
274
|
-
isDateSelected(date) {
|
|
275
|
-
return this.selectedDates.some(selected => this.isSameDay(selected.gregorian, date));
|
|
276
|
-
}
|
|
277
|
-
onDayClick(dayInfo) {
|
|
278
|
-
if (dayInfo.disabled || dayInfo.isDisabled) {
|
|
279
|
-
return;
|
|
280
|
-
}
|
|
281
|
-
const selectedDate = this.createSelectedDate(dayInfo.date);
|
|
282
|
-
if (this.multiple) {
|
|
283
|
-
const index = this.selectedDates.findIndex(d => this.isSameDay(d.gregorian, dayInfo.date));
|
|
284
|
-
if (index > -1) {
|
|
285
|
-
this.selectedDates.splice(index, 1);
|
|
286
|
-
}
|
|
287
|
-
else {
|
|
288
|
-
this.selectedDates.push(selectedDate);
|
|
289
|
-
}
|
|
290
|
-
if (!this.showConfirmButton) {
|
|
291
|
-
this.dateSelected.emit([...this.selectedDates]);
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
else {
|
|
295
|
-
this.selectedDates = [selectedDate];
|
|
296
|
-
if (!this.showConfirmButton) {
|
|
297
|
-
this.dateSelected.emit(selectedDate);
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
this.generateCalendar();
|
|
301
|
-
}
|
|
302
|
-
createSelectedDate(date) {
|
|
303
|
-
const hijriDate = toHijri(date);
|
|
304
|
-
// If time is enabled, set the time on the date object
|
|
305
|
-
if (this.enableTime) {
|
|
306
|
-
let hours24 = this.selectedTime.hours;
|
|
307
|
-
if (this.timeFormat === '12') {
|
|
308
|
-
if (this.isPM && this.selectedTime.hours !== 12) {
|
|
309
|
-
hours24 = this.selectedTime.hours + 12;
|
|
310
|
-
}
|
|
311
|
-
else if (!this.isPM && this.selectedTime.hours === 12) {
|
|
312
|
-
hours24 = 0;
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
date.setHours(hours24, this.selectedTime.minutes, this.selectedTime.seconds);
|
|
316
|
-
}
|
|
317
|
-
return {
|
|
318
|
-
gregorian: date,
|
|
319
|
-
hijri: {
|
|
320
|
-
year: hijriDate.getFullYear(),
|
|
321
|
-
month: hijriDate.getMonth(),
|
|
322
|
-
day: hijriDate.getDate()
|
|
323
|
-
},
|
|
324
|
-
time: this.enableTime ? {
|
|
325
|
-
hours: date.getHours(),
|
|
326
|
-
minutes: date.getMinutes(),
|
|
327
|
-
seconds: date.getSeconds()
|
|
328
|
-
} : undefined,
|
|
329
|
-
formatted: {
|
|
330
|
-
gregorian: this.formatGregorianDate(date),
|
|
331
|
-
hijri: this.formatHijriDate(hijriDate),
|
|
332
|
-
time: this.enableTime ? this.formatTime(date.getHours(), date.getMinutes(), date.getSeconds()) : undefined
|
|
333
|
-
}
|
|
334
|
-
};
|
|
335
|
-
}
|
|
336
|
-
formatGregorianDate(date) {
|
|
337
|
-
const day = date.getDate();
|
|
338
|
-
const month = this.locale === 'ar' ? GREGORIAN_MONTHS_AR[date.getMonth()] : GREGORIAN_MONTHS_EN[date.getMonth()];
|
|
339
|
-
const year = date.getFullYear();
|
|
340
|
-
return this.locale === 'ar'
|
|
341
|
-
? `${day} ${month} ${year}`
|
|
342
|
-
: `${month} ${day}, ${year}`;
|
|
343
|
-
}
|
|
344
|
-
formatHijriDate(hijriDate) {
|
|
345
|
-
const day = hijriDate.getDate();
|
|
346
|
-
const month = this.locale === 'ar'
|
|
347
|
-
? HIJRI_MONTHS_AR[hijriDate.getMonth()]
|
|
348
|
-
: HIJRI_MONTHS_EN[hijriDate.getMonth()];
|
|
349
|
-
const year = hijriDate.getFullYear();
|
|
350
|
-
return this.locale === 'ar'
|
|
351
|
-
? `${day} ${month} ${year} هـ`
|
|
352
|
-
: `${day} ${month} ${year} AH`;
|
|
353
|
-
}
|
|
354
|
-
onYearChange(event) {
|
|
355
|
-
const year = parseInt(event.target.value);
|
|
356
|
-
if (this.mode === 'hijri') {
|
|
357
|
-
this.currentHijriYear = year;
|
|
358
|
-
}
|
|
359
|
-
else {
|
|
360
|
-
this.currentYear = year;
|
|
361
|
-
}
|
|
362
|
-
this.generateCalendar();
|
|
363
|
-
}
|
|
364
|
-
onMonthChange(event) {
|
|
365
|
-
const month = parseInt(event.target.value);
|
|
366
|
-
if (this.mode === 'hijri') {
|
|
367
|
-
this.currentHijriMonth = month;
|
|
368
|
-
}
|
|
369
|
-
else {
|
|
370
|
-
this.currentMonth = month;
|
|
371
|
-
}
|
|
372
|
-
this.generateCalendar();
|
|
373
|
-
}
|
|
374
|
-
previousMonth() {
|
|
375
|
-
if (this.mode === 'hijri') {
|
|
376
|
-
if (this.currentHijriMonth === 0) {
|
|
377
|
-
this.currentHijriMonth = 11;
|
|
378
|
-
this.currentHijriYear--;
|
|
379
|
-
}
|
|
380
|
-
else {
|
|
381
|
-
this.currentHijriMonth--;
|
|
382
|
-
}
|
|
383
|
-
}
|
|
384
|
-
else {
|
|
385
|
-
if (this.currentMonth === 0) {
|
|
386
|
-
this.currentMonth = 11;
|
|
387
|
-
this.currentYear--;
|
|
388
|
-
}
|
|
389
|
-
else {
|
|
390
|
-
this.currentMonth--;
|
|
391
|
-
}
|
|
392
|
-
}
|
|
393
|
-
this.generateCalendar();
|
|
394
|
-
}
|
|
395
|
-
nextMonth() {
|
|
396
|
-
if (this.mode === 'hijri') {
|
|
397
|
-
if (this.currentHijriMonth === 11) {
|
|
398
|
-
this.currentHijriMonth = 0;
|
|
399
|
-
this.currentHijriYear++;
|
|
400
|
-
}
|
|
401
|
-
else {
|
|
402
|
-
this.currentHijriMonth++;
|
|
403
|
-
}
|
|
404
|
-
}
|
|
405
|
-
else {
|
|
406
|
-
if (this.currentMonth === 11) {
|
|
407
|
-
this.currentMonth = 0;
|
|
408
|
-
this.currentYear++;
|
|
409
|
-
}
|
|
410
|
-
else {
|
|
411
|
-
this.currentMonth++;
|
|
412
|
-
}
|
|
413
|
-
}
|
|
414
|
-
this.generateCalendar();
|
|
415
|
-
}
|
|
416
|
-
toggleMode() {
|
|
417
|
-
if (!this.canChangeMode) {
|
|
418
|
-
return;
|
|
419
|
-
}
|
|
420
|
-
this.mode = this.mode === 'greg' ? 'hijri' : 'greg';
|
|
421
|
-
this.updateLocaleData();
|
|
422
|
-
this.generateYears();
|
|
423
|
-
this.generateCalendar();
|
|
424
|
-
this.modeChanged.emit(this.mode);
|
|
425
|
-
}
|
|
426
|
-
selectToday() {
|
|
427
|
-
const today = new Date();
|
|
428
|
-
this.onDayClick({ date: today, disabled: false, isDisabled: false });
|
|
429
|
-
}
|
|
430
|
-
onSubmit() {
|
|
431
|
-
if (this.isRequired && this.selectedDates.length === 0) {
|
|
432
|
-
return;
|
|
433
|
-
}
|
|
434
|
-
if (this.multiple) {
|
|
435
|
-
this.dateSelected.emit([...this.selectedDates]);
|
|
436
|
-
}
|
|
437
|
-
else if (this.selectedDates.length > 0) {
|
|
438
|
-
this.dateSelected.emit(this.selectedDates[0]);
|
|
439
|
-
}
|
|
440
|
-
}
|
|
441
|
-
// Time handling methods
|
|
442
|
-
incrementTime(type) {
|
|
443
|
-
if (type === 'hours') {
|
|
444
|
-
const max = this.timeFormat === '12' ? 12 : 23;
|
|
445
|
-
this.selectedTime.hours = (this.selectedTime.hours + 1) > max ? (this.timeFormat === '12' ? 1 : 0) : this.selectedTime.hours + 1;
|
|
446
|
-
}
|
|
447
|
-
else if (type === 'minutes') {
|
|
448
|
-
this.selectedTime.minutes = (this.selectedTime.minutes + this.minuteStep) > 59 ? 0 : this.selectedTime.minutes + this.minuteStep;
|
|
449
|
-
}
|
|
450
|
-
else if (type === 'seconds') {
|
|
451
|
-
this.selectedTime.seconds = (this.selectedTime.seconds + 1) > 59 ? 0 : this.selectedTime.seconds + 1;
|
|
452
|
-
}
|
|
453
|
-
this.updateSelectedDateTime();
|
|
454
|
-
}
|
|
455
|
-
decrementTime(type) {
|
|
456
|
-
if (type === 'hours') {
|
|
457
|
-
const min = this.timeFormat === '12' ? 1 : 0;
|
|
458
|
-
const max = this.timeFormat === '12' ? 12 : 23;
|
|
459
|
-
this.selectedTime.hours = (this.selectedTime.hours - 1) < min ? max : this.selectedTime.hours - 1;
|
|
460
|
-
}
|
|
461
|
-
else if (type === 'minutes') {
|
|
462
|
-
this.selectedTime.minutes = (this.selectedTime.minutes - this.minuteStep) < 0 ? 59 : this.selectedTime.minutes - this.minuteStep;
|
|
463
|
-
}
|
|
464
|
-
else if (type === 'seconds') {
|
|
465
|
-
this.selectedTime.seconds = (this.selectedTime.seconds - 1) < 0 ? 59 : this.selectedTime.seconds - 1;
|
|
466
|
-
}
|
|
467
|
-
this.updateSelectedDateTime();
|
|
468
|
-
}
|
|
469
|
-
onTimeChange(type, event) {
|
|
470
|
-
const value = parseInt(event.target.value) || 0;
|
|
471
|
-
if (type === 'hours') {
|
|
472
|
-
const min = this.timeFormat === '12' ? 1 : 0;
|
|
473
|
-
const max = this.timeFormat === '12' ? 12 : 23;
|
|
474
|
-
this.selectedTime.hours = Math.max(min, Math.min(max, value));
|
|
475
|
-
}
|
|
476
|
-
else if (type === 'minutes') {
|
|
477
|
-
this.selectedTime.minutes = Math.max(0, Math.min(59, value));
|
|
478
|
-
}
|
|
479
|
-
else if (type === 'seconds') {
|
|
480
|
-
this.selectedTime.seconds = Math.max(0, Math.min(59, value));
|
|
481
|
-
}
|
|
482
|
-
this.updateSelectedDateTime();
|
|
483
|
-
}
|
|
484
|
-
setAMPM(pm) {
|
|
485
|
-
this.isPM = pm;
|
|
486
|
-
this.updateSelectedDateTime();
|
|
487
|
-
}
|
|
488
|
-
formatTime(hours, minutes, seconds) {
|
|
489
|
-
if (this.timeFormat === '12') {
|
|
490
|
-
const displayHours = hours % 12 || 12;
|
|
491
|
-
const ampm = hours >= 12 ? 'PM' : 'AM';
|
|
492
|
-
const minutesStr = minutes.toString().padStart(2, '0');
|
|
493
|
-
if (this.enableSeconds) {
|
|
494
|
-
const secondsStr = seconds.toString().padStart(2, '0');
|
|
495
|
-
return `${displayHours}:${minutesStr}:${secondsStr} ${ampm}`;
|
|
496
|
-
}
|
|
497
|
-
return `${displayHours}:${minutesStr} ${ampm}`;
|
|
498
|
-
}
|
|
499
|
-
else {
|
|
500
|
-
const hoursStr = hours.toString().padStart(2, '0');
|
|
501
|
-
const minutesStr = minutes.toString().padStart(2, '0');
|
|
502
|
-
if (this.enableSeconds) {
|
|
503
|
-
const secondsStr = seconds.toString().padStart(2, '0');
|
|
504
|
-
return `${hoursStr}:${minutesStr}:${secondsStr}`;
|
|
505
|
-
}
|
|
506
|
-
return `${hoursStr}:${minutesStr}`;
|
|
507
|
-
}
|
|
508
|
-
}
|
|
509
|
-
updateSelectedDateTime() {
|
|
510
|
-
if (!this.enableTime || this.selectedDates.length === 0) {
|
|
511
|
-
return;
|
|
512
|
-
}
|
|
513
|
-
// Convert 12-hour to 24-hour if needed
|
|
514
|
-
let hours24 = this.selectedTime.hours;
|
|
515
|
-
if (this.timeFormat === '12') {
|
|
516
|
-
if (this.isPM && this.selectedTime.hours !== 12) {
|
|
517
|
-
hours24 = this.selectedTime.hours + 12;
|
|
518
|
-
}
|
|
519
|
-
else if (!this.isPM && this.selectedTime.hours === 12) {
|
|
520
|
-
hours24 = 0;
|
|
521
|
-
}
|
|
522
|
-
}
|
|
523
|
-
// Update all selected dates with new time
|
|
524
|
-
this.selectedDates = this.selectedDates.map(selectedDate => {
|
|
525
|
-
const newDate = new Date(selectedDate.gregorian);
|
|
526
|
-
newDate.setHours(hours24, this.selectedTime.minutes, this.selectedTime.seconds);
|
|
527
|
-
return {
|
|
528
|
-
...selectedDate,
|
|
529
|
-
gregorian: newDate,
|
|
530
|
-
time: {
|
|
531
|
-
hours: hours24,
|
|
532
|
-
minutes: this.selectedTime.minutes,
|
|
533
|
-
seconds: this.selectedTime.seconds
|
|
534
|
-
},
|
|
535
|
-
formatted: {
|
|
536
|
-
...selectedDate.formatted,
|
|
537
|
-
time: this.formatTime(hours24, this.selectedTime.minutes, this.selectedTime.seconds)
|
|
538
|
-
}
|
|
539
|
-
};
|
|
540
|
-
});
|
|
541
|
-
}
|
|
542
|
-
getCustomStyles() {
|
|
543
|
-
return {
|
|
544
|
-
'--primary-color': this.styles.primaryColor || '#4f46e5',
|
|
545
|
-
'--secondary-color': this.styles.secondaryColor || '#818cf8',
|
|
546
|
-
'--background-color': this.styles.backgroundColor || '#ffffff',
|
|
547
|
-
'--text-color': this.styles.textColor || '#1f2937',
|
|
548
|
-
'--selected-date-color': this.styles.selectedDateColor || '#ffffff',
|
|
549
|
-
'--selected-date-background': this.styles.selectedDateBackground || '#4f46e5',
|
|
550
|
-
'--today-color': this.styles.todayColor || '#10b981',
|
|
551
|
-
'--disabled-color': this.styles.disabledColor || '#d1d5db',
|
|
552
|
-
'--border-color': this.styles.borderColor || '#e5e7eb',
|
|
553
|
-
'--hover-color': this.styles.hoverColor || '#f3f4f6',
|
|
554
|
-
'--font-family': this.styles.fontFamily || 'system-ui, -apple-system, sans-serif',
|
|
555
|
-
'--font-size': this.styles.fontSize || '14px',
|
|
556
|
-
'--border-radius': this.styles.borderRadius || '8px'
|
|
557
|
-
};
|
|
558
|
-
}
|
|
559
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: HijriDatePickerComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
560
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.12", type: HijriDatePickerComponent, isStandalone: true, selector: "hijri-date-picker", inputs: { canChangeMode: "canChangeMode", mode: "mode", dir: "dir", locale: "locale", futureValidation: "futureValidation", futureYearsLimit: "futureYearsLimit", isRequired: "isRequired", minDate: "minDate", maxDate: "maxDate", multiple: "multiple", showConfirmButton: "showConfirmButton", initialSelectedDate: "initialSelectedDate", initialSelectedDates: "initialSelectedDates", submitTextButton: "submitTextButton", todaysDateText: "todaysDateText", ummAlQuraDateText: "ummAlQuraDateText", yearSelectLabel: "yearSelectLabel", monthSelectLabel: "monthSelectLabel", todaysDateSection: "todaysDateSection", markToday: "markToday", disableYearPicker: "disableYearPicker", disableMonthPicker: "disableMonthPicker", disableDayPicker: "disableDayPicker", styles: "styles", enableTime: "enableTime", timeFormat: "timeFormat", minuteStep: "minuteStep", enableSeconds: "enableSeconds", defaultTime: "defaultTime" }, outputs: { dateSelected: "dateSelected", modeChanged: "modeChanged" }, usesOnChanges: true, ngImport: i0, template: "<div class=\"hijri-date-picker\" [dir]=\"dir\" [style]=\"getCustomStyles()\">\n <!-- Header Section -->\n <div class=\"picker-header\">\n <!-- Mode Toggle Button -->\n <button \n *ngIf=\"canChangeMode\" \n class=\"mode-toggle-btn\"\n (click)=\"toggleMode()\"\n [attr.aria-label]=\"mode === 'greg' ? 'Switch to Hijri' : 'Switch to Gregorian'\">\n {{ mode === 'greg' ? (locale === 'ar' ? '\u062A\u0642\u0648\u064A\u0645 \u0647\u062C\u0631\u064A' : 'Hijri') : (locale === 'ar' ? '\u062A\u0642\u0648\u064A\u0645 \u0645\u064A\u0644\u0627\u062F\u064A' : 'Gregorian') }}\n </button>\n\n <!-- Today's Date Section -->\n <div *ngIf=\"todaysDateSection\" class=\"todays-date\">\n <button class=\"today-btn\" (click)=\"selectToday()\">\n {{ todaysDateText }}\n </button>\n </div>\n </div>\n\n <!-- Calendar Controls -->\n <div class=\"calendar-controls\">\n <!-- Year Picker -->\n <div class=\"control-group\" *ngIf=\"!disableYearPicker\">\n <label [attr.for]=\"'year-select'\">{{ yearSelectLabel }}</label>\n <select \n id=\"year-select\"\n [value]=\"mode === 'hijri' ? currentHijriYear : currentYear\"\n (change)=\"onYearChange($event)\"\n class=\"year-select\">\n <option *ngFor=\"let year of years\" [value]=\"year\">{{ year }}</option>\n </select>\n </div>\n\n <!-- Month Picker -->\n <div class=\"control-group\" *ngIf=\"!disableMonthPicker\">\n <label [attr.for]=\"'month-select'\">{{ monthSelectLabel }}</label>\n <select \n id=\"month-select\"\n [value]=\"mode === 'hijri' ? currentHijriMonth : currentMonth\"\n (change)=\"onMonthChange($event)\"\n class=\"month-select\">\n <option *ngFor=\"let month of months; let i = index\" [value]=\"i\">\n {{ month }}\n </option>\n </select>\n </div>\n\n <!-- Navigation Buttons -->\n <div class=\"navigation-buttons\">\n <button \n class=\"nav-btn prev-btn\"\n (click)=\"previousMonth()\"\n [attr.aria-label]=\"locale === 'ar' ? '\u0627\u0644\u0634\u0647\u0631 \u0627\u0644\u0633\u0627\u0628\u0642' : 'Previous Month'\">\n {{ dir === 'rtl' ? '\u2190' : '\u2192' }}\n </button>\n <button \n class=\"nav-btn next-btn\"\n (click)=\"nextMonth()\"\n [attr.aria-label]=\"locale === 'ar' ? '\u0627\u0644\u0634\u0647\u0631 \u0627\u0644\u062A\u0627\u0644\u064A' : 'Next Month'\">\n {{ dir === 'rtl' ? '\u2192' : '\u2190' }}\n </button>\n </div>\n </div>\n\n <!-- Calendar Grid -->\n <div class=\"calendar-grid\" *ngIf=\"!disableDayPicker\">\n <!-- Weekday Headers -->\n <div class=\"weekday-header\">\n <div class=\"weekday\" *ngFor=\"let weekday of weekdays\">\n {{ weekday }}\n </div>\n </div>\n\n <!-- Calendar Days -->\n <div class=\"calendar-days\">\n <div \n *ngFor=\"let dayInfo of calendarDays\"\n class=\"day-cell\"\n [class.empty]=\"dayInfo.day === null\"\n [class.today]=\"markToday && dayInfo.isToday\"\n [class.selected]=\"dayInfo.isSelected\"\n [class.disabled]=\"dayInfo.isDisabled\"\n (click)=\"onDayClick(dayInfo)\">\n <span *ngIf=\"dayInfo.day !== null\">{{ dayInfo.day }}</span>\n </div>\n </div>\n </div>\n\n <!-- Time Picker Section -->\n <div class=\"time-picker\" *ngIf=\"enableTime\">\n <div class=\"time-picker-label\">\n {{ locale === 'ar' ? '\u0627\u0644\u0648\u0642\u062A' : 'Time' }}\n </div>\n \n <div class=\"time-inputs\">\n <!-- Hours Input -->\n <div class=\"time-input-group\">\n <button class=\"time-btn\" (click)=\"incrementTime('hours')\">\u25B2</button>\n <input \n type=\"number\" \n class=\"time-input\"\n [value]=\"timeFormat === '12' ? (selectedTime.hours % 12 || 12) : selectedTime.hours\"\n (input)=\"onTimeChange('hours', $event)\"\n [min]=\"timeFormat === '12' ? 1 : 0\"\n [max]=\"timeFormat === '12' ? 12 : 23\"\n [attr.aria-label]=\"locale === 'ar' ? '\u0627\u0644\u0633\u0627\u0639\u0627\u062A' : 'Hours'\">\n <button class=\"time-btn\" (click)=\"decrementTime('hours')\">\u25BC</button>\n </div>\n \n <span class=\"time-separator\">:</span>\n \n <!-- Minutes Input -->\n <div class=\"time-input-group\">\n <button class=\"time-btn\" (click)=\"incrementTime('minutes')\">\u25B2</button>\n <input \n type=\"number\" \n class=\"time-input\"\n [value]=\"selectedTime.minutes\"\n (input)=\"onTimeChange('minutes', $event)\"\n [min]=\"0\"\n [max]=\"59\"\n [step]=\"minuteStep\"\n [attr.aria-label]=\"locale === 'ar' ? '\u0627\u0644\u062F\u0642\u0627\u0626\u0642' : 'Minutes'\">\n <button class=\"time-btn\" (click)=\"decrementTime('minutes')\">\u25BC</button>\n </div>\n \n <!-- Seconds Input (Optional) -->\n <ng-container *ngIf=\"enableSeconds\">\n <span class=\"time-separator\">:</span>\n <div class=\"time-input-group\">\n <button class=\"time-btn\" (click)=\"incrementTime('seconds')\">\u25B2</button>\n <input \n type=\"number\" \n class=\"time-input\"\n [value]=\"selectedTime.seconds\"\n (input)=\"onTimeChange('seconds', $event)\"\n [min]=\"0\"\n [max]=\"59\"\n [attr.aria-label]=\"locale === 'ar' ? '\u0627\u0644\u062B\u0648\u0627\u0646\u064A' : 'Seconds'\">\n <button class=\"time-btn\" (click)=\"decrementTime('seconds')\">\u25BC</button>\n </div>\n </ng-container>\n \n <!-- AM/PM Toggle (12-hour format) -->\n <div class=\"ampm-toggle\" *ngIf=\"timeFormat === '12'\">\n <button \n class=\"ampm-btn\"\n [class.active]=\"!isPM\"\n (click)=\"setAMPM(false)\">\n AM\n </button>\n <button \n class=\"ampm-btn\"\n [class.active]=\"isPM\"\n (click)=\"setAMPM(true)\">\n PM\n </button>\n </div>\n </div>\n </div>\n\n <!-- Selected Dates Display -->\n <div class=\"selected-dates\" *ngIf=\"selectedDates.length > 0\">\n <div class=\"selected-label\">\n {{ locale === 'ar' ? '\u0627\u0644\u062A\u0648\u0627\u0631\u064A\u062E \u0627\u0644\u0645\u062D\u062F\u062F\u0629:' : 'Selected Dates:' }}\n </div>\n <div class=\"selected-list\">\n <div class=\"selected-item\" *ngFor=\"let date of selectedDates\">\n <div class=\"selected-date-info\">\n <span class=\"date-text\">\n {{ mode === 'hijri' ? date.formatted.hijri : date.formatted.gregorian }}\n </span>\n <span class=\"time-text\" *ngIf=\"enableTime && date.formatted.time\">\n {{ date.formatted.time }}\n </span>\n </div>\n </div>\n </div>\n </div>\n\n <!-- Submit Button -->\n <div class=\"picker-footer\" *ngIf=\"showConfirmButton\">\n <button \n class=\"submit-btn\"\n (click)=\"onSubmit()\"\n [disabled]=\"isRequired && selectedDates.length === 0\">\n {{ submitTextButton }}\n </button>\n </div>\n\n <!-- Calendar Type Label -->\n <div class=\"calendar-type\" *ngIf=\"mode === 'hijri'\">\n <small>{{ ummAlQuraDateText }}</small>\n </div>\n</div>\n", styles: [".hijri-date-picker{font-family:var(--font-family);font-size:var(--font-size);background-color:var(--background-color);color:var(--text-color);border:1px solid var(--border-color);border-radius:var(--border-radius);padding:20px;max-width:400px;box-shadow:0 4px 6px #0000001a}.picker-header{display:flex;justify-content:space-between;align-items:center;margin-bottom:16px;gap:12px}.mode-toggle-btn{background-color:var(--secondary-color);color:#fff;border:none;padding:8px 16px;border-radius:calc(var(--border-radius) / 2);cursor:pointer;font-size:13px;font-weight:500;transition:all .2s ease}.mode-toggle-btn:hover{opacity:.9;transform:translateY(-1px)}.mode-toggle-btn:active{transform:translateY(0)}.todays-date{flex:1;display:flex;justify-content:flex-end}.today-btn{background-color:var(--today-color);color:#fff;border:none;padding:8px 16px;border-radius:calc(var(--border-radius) / 2);cursor:pointer;font-size:13px;font-weight:500;transition:all .2s ease}.today-btn:hover{opacity:.9;transform:translateY(-1px)}.calendar-controls{display:flex;flex-wrap:wrap;gap:12px;margin-bottom:16px;align-items:flex-end}.control-group{flex:1;min-width:120px;display:flex;flex-direction:column;gap:4px}.control-group label{font-size:12px;font-weight:500;color:var(--text-color);opacity:.8}.year-select,.month-select{padding:8px 12px;border:1px solid var(--border-color);border-radius:calc(var(--border-radius) / 2);background-color:var(--background-color);color:var(--text-color);font-size:14px;cursor:pointer;transition:border-color .2s ease}.year-select:hover,.month-select:hover{border-color:var(--primary-color)}.year-select:focus,.month-select:focus{outline:none;border-color:var(--primary-color);box-shadow:0 0 0 3px #4f46e51a}.navigation-buttons{display:flex;gap:8px}.nav-btn{background-color:var(--primary-color);color:#fff;border:none;width:36px;height:36px;border-radius:calc(var(--border-radius) / 2);cursor:pointer;font-size:18px;display:flex;align-items:center;justify-content:center;transition:all .2s ease}.nav-btn:hover{opacity:.9;transform:scale(1.05)}.nav-btn:active{transform:scale(.95)}.calendar-grid{margin-bottom:16px}.weekday-header{display:grid;grid-template-columns:repeat(7,1fr);gap:4px;margin-bottom:8px}.weekday{text-align:center;font-size:12px;font-weight:600;color:var(--text-color);opacity:.7;padding:8px 4px}.calendar-days{display:grid;grid-template-columns:repeat(7,1fr);gap:4px}.day-cell{aspect-ratio:1;display:flex;align-items:center;justify-content:center;border-radius:calc(var(--border-radius) / 2);cursor:pointer;font-size:14px;font-weight:500;transition:all .2s ease;position:relative}.day-cell:not(.empty):not(.disabled):hover{background-color:var(--hover-color);transform:scale(1.05)}.day-cell.empty{cursor:default;pointer-events:none}.day-cell.today{color:var(--today-color);font-weight:700}.day-cell.today:after{content:\"\";position:absolute;bottom:4px;left:50%;transform:translate(-50%);width:4px;height:4px;background-color:var(--today-color);border-radius:50%}.day-cell.selected{background-color:var(--selected-date-background);color:var(--selected-date-color);font-weight:700}.day-cell.disabled{color:var(--disabled-color);cursor:not-allowed;opacity:.5}.day-cell.disabled:hover{background-color:transparent;transform:none}.selected-dates{margin-bottom:16px;padding:12px;background-color:var(--hover-color);border-radius:calc(var(--border-radius) / 2)}.selected-label{font-size:12px;font-weight:600;margin-bottom:8px;color:var(--text-color);opacity:.8}.selected-list{display:flex;flex-wrap:wrap;gap:8px}.selected-item{background-color:var(--primary-color);color:#fff;padding:6px 12px;border-radius:calc(var(--border-radius) / 2);font-size:13px;font-weight:500}.picker-footer{margin-bottom:12px}.submit-btn{width:100%;background-color:var(--primary-color);color:#fff;border:none;padding:12px 24px;border-radius:calc(var(--border-radius) / 2);cursor:pointer;font-size:15px;font-weight:600;transition:all .2s ease}.submit-btn:hover:not(:disabled){opacity:.9;transform:translateY(-2px);box-shadow:0 4px 8px #00000026}.submit-btn:active:not(:disabled){transform:translateY(0)}.submit-btn:disabled{opacity:.5;cursor:not-allowed}.calendar-type{text-align:center;color:var(--text-color);opacity:.6;font-size:11px}.hijri-date-picker[dir=rtl]{direction:rtl}.hijri-date-picker[dir=rtl] .picker-header{flex-direction:row-reverse}.hijri-date-picker[dir=rtl] .todays-date{justify-content:flex-start}@media (max-width: 480px){.hijri-date-picker{padding:16px;max-width:100%}.calendar-controls{flex-direction:column}.control-group{width:100%}.navigation-buttons{width:100%;justify-content:space-between}.weekday{font-size:11px;padding:6px 2px}.day-cell{font-size:13px}}@media (prefers-color-scheme: dark){.hijri-date-picker{--background-color: #1f2937;--text-color: #f9fafb;--border-color: #374151;--hover-color: #374151}}.time-picker{margin-top:10px;margin-bottom:20px;padding:16px;background:linear-gradient(135deg,var(--hover-color) 0%,transparent 100%);border-radius:var(--border-radius);border:1px solid var(--border-color);box-shadow:inset 0 2px 4px #0000000d}.time-picker-label{font-size:13px;font-weight:600;margin-bottom:12px;color:var(--text-color);opacity:.9;text-align:center;text-transform:uppercase;letter-spacing:.5px}.time-inputs{display:flex;align-items:center;justify-content:center;gap:12px}.time-input-group{display:flex;flex-direction:column;align-items:center;gap:6px}.time-btn{background-color:var(--primary-color);color:#fff;border:none;width:36px;height:28px;border-radius:calc(var(--border-radius) / 3);cursor:pointer;font-size:12px;display:flex;align-items:center;justify-content:center;transition:all .2s ease;-webkit-user-select:none;user-select:none}.time-btn:hover{filter:brightness(1.1);transform:scale(1.05)}.time-btn:active{transform:scale(.95)}.time-input{width:60px;padding:10px 4px;text-align:center;border:2px solid var(--border-color);border-radius:calc(var(--border-radius) / 2);background-color:var(--background-color);color:var(--text-color);font-size:20px;font-weight:700;transition:all .2s ease;box-shadow:0 2px 4px #0000000d}.time-input:focus{outline:none;border-color:var(--primary-color);box-shadow:0 0 0 4px #4f46e526}.time-input::-webkit-inner-spin-button,.time-input::-webkit-outer-spin-button{-webkit-appearance:none;margin:0}.time-separator{font-size:28px;font-weight:700;color:var(--text-color);opacity:.4;padding-bottom:4px}.ampm-toggle{display:flex;flex-direction:column;gap:6px;margin-left:12px}.ampm-btn{background-color:var(--background-color);color:var(--text-color);border:1px solid var(--border-color);padding:8px 14px;border-radius:calc(var(--border-radius) / 3);cursor:pointer;font-size:11px;font-weight:700;transition:all .2s ease;box-shadow:0 2px 4px #0000000d}.ampm-btn.active{background-color:var(--primary-color);color:#fff;border-color:var(--primary-color);box-shadow:0 4px 6px #00000026}.ampm-btn:hover:not(.active){background-color:var(--hover-color);border-color:var(--primary-color)}.selected-date-info{display:flex;flex-direction:column;align-items:center;gap:2px}.selected-item .time-text{font-size:11px;opacity:.85;font-weight:500;background-color:#fff3;padding:2px 8px;border-radius:10px;margin-top:2px}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
|
|
561
|
-
}
|
|
562
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: HijriDatePickerComponent, decorators: [{
|
|
563
|
-
type: Component,
|
|
564
|
-
args: [{ selector: 'hijri-date-picker', standalone: true, imports: [CommonModule], template: "<div class=\"hijri-date-picker\" [dir]=\"dir\" [style]=\"getCustomStyles()\">\n <!-- Header Section -->\n <div class=\"picker-header\">\n <!-- Mode Toggle Button -->\n <button \n *ngIf=\"canChangeMode\" \n class=\"mode-toggle-btn\"\n (click)=\"toggleMode()\"\n [attr.aria-label]=\"mode === 'greg' ? 'Switch to Hijri' : 'Switch to Gregorian'\">\n {{ mode === 'greg' ? (locale === 'ar' ? '\u062A\u0642\u0648\u064A\u0645 \u0647\u062C\u0631\u064A' : 'Hijri') : (locale === 'ar' ? '\u062A\u0642\u0648\u064A\u0645 \u0645\u064A\u0644\u0627\u062F\u064A' : 'Gregorian') }}\n </button>\n\n <!-- Today's Date Section -->\n <div *ngIf=\"todaysDateSection\" class=\"todays-date\">\n <button class=\"today-btn\" (click)=\"selectToday()\">\n {{ todaysDateText }}\n </button>\n </div>\n </div>\n\n <!-- Calendar Controls -->\n <div class=\"calendar-controls\">\n <!-- Year Picker -->\n <div class=\"control-group\" *ngIf=\"!disableYearPicker\">\n <label [attr.for]=\"'year-select'\">{{ yearSelectLabel }}</label>\n <select \n id=\"year-select\"\n [value]=\"mode === 'hijri' ? currentHijriYear : currentYear\"\n (change)=\"onYearChange($event)\"\n class=\"year-select\">\n <option *ngFor=\"let year of years\" [value]=\"year\">{{ year }}</option>\n </select>\n </div>\n\n <!-- Month Picker -->\n <div class=\"control-group\" *ngIf=\"!disableMonthPicker\">\n <label [attr.for]=\"'month-select'\">{{ monthSelectLabel }}</label>\n <select \n id=\"month-select\"\n [value]=\"mode === 'hijri' ? currentHijriMonth : currentMonth\"\n (change)=\"onMonthChange($event)\"\n class=\"month-select\">\n <option *ngFor=\"let month of months; let i = index\" [value]=\"i\">\n {{ month }}\n </option>\n </select>\n </div>\n\n <!-- Navigation Buttons -->\n <div class=\"navigation-buttons\">\n <button \n class=\"nav-btn prev-btn\"\n (click)=\"previousMonth()\"\n [attr.aria-label]=\"locale === 'ar' ? '\u0627\u0644\u0634\u0647\u0631 \u0627\u0644\u0633\u0627\u0628\u0642' : 'Previous Month'\">\n {{ dir === 'rtl' ? '\u2190' : '\u2192' }}\n </button>\n <button \n class=\"nav-btn next-btn\"\n (click)=\"nextMonth()\"\n [attr.aria-label]=\"locale === 'ar' ? '\u0627\u0644\u0634\u0647\u0631 \u0627\u0644\u062A\u0627\u0644\u064A' : 'Next Month'\">\n {{ dir === 'rtl' ? '\u2192' : '\u2190' }}\n </button>\n </div>\n </div>\n\n <!-- Calendar Grid -->\n <div class=\"calendar-grid\" *ngIf=\"!disableDayPicker\">\n <!-- Weekday Headers -->\n <div class=\"weekday-header\">\n <div class=\"weekday\" *ngFor=\"let weekday of weekdays\">\n {{ weekday }}\n </div>\n </div>\n\n <!-- Calendar Days -->\n <div class=\"calendar-days\">\n <div \n *ngFor=\"let dayInfo of calendarDays\"\n class=\"day-cell\"\n [class.empty]=\"dayInfo.day === null\"\n [class.today]=\"markToday && dayInfo.isToday\"\n [class.selected]=\"dayInfo.isSelected\"\n [class.disabled]=\"dayInfo.isDisabled\"\n (click)=\"onDayClick(dayInfo)\">\n <span *ngIf=\"dayInfo.day !== null\">{{ dayInfo.day }}</span>\n </div>\n </div>\n </div>\n\n <!-- Time Picker Section -->\n <div class=\"time-picker\" *ngIf=\"enableTime\">\n <div class=\"time-picker-label\">\n {{ locale === 'ar' ? '\u0627\u0644\u0648\u0642\u062A' : 'Time' }}\n </div>\n \n <div class=\"time-inputs\">\n <!-- Hours Input -->\n <div class=\"time-input-group\">\n <button class=\"time-btn\" (click)=\"incrementTime('hours')\">\u25B2</button>\n <input \n type=\"number\" \n class=\"time-input\"\n [value]=\"timeFormat === '12' ? (selectedTime.hours % 12 || 12) : selectedTime.hours\"\n (input)=\"onTimeChange('hours', $event)\"\n [min]=\"timeFormat === '12' ? 1 : 0\"\n [max]=\"timeFormat === '12' ? 12 : 23\"\n [attr.aria-label]=\"locale === 'ar' ? '\u0627\u0644\u0633\u0627\u0639\u0627\u062A' : 'Hours'\">\n <button class=\"time-btn\" (click)=\"decrementTime('hours')\">\u25BC</button>\n </div>\n \n <span class=\"time-separator\">:</span>\n \n <!-- Minutes Input -->\n <div class=\"time-input-group\">\n <button class=\"time-btn\" (click)=\"incrementTime('minutes')\">\u25B2</button>\n <input \n type=\"number\" \n class=\"time-input\"\n [value]=\"selectedTime.minutes\"\n (input)=\"onTimeChange('minutes', $event)\"\n [min]=\"0\"\n [max]=\"59\"\n [step]=\"minuteStep\"\n [attr.aria-label]=\"locale === 'ar' ? '\u0627\u0644\u062F\u0642\u0627\u0626\u0642' : 'Minutes'\">\n <button class=\"time-btn\" (click)=\"decrementTime('minutes')\">\u25BC</button>\n </div>\n \n <!-- Seconds Input (Optional) -->\n <ng-container *ngIf=\"enableSeconds\">\n <span class=\"time-separator\">:</span>\n <div class=\"time-input-group\">\n <button class=\"time-btn\" (click)=\"incrementTime('seconds')\">\u25B2</button>\n <input \n type=\"number\" \n class=\"time-input\"\n [value]=\"selectedTime.seconds\"\n (input)=\"onTimeChange('seconds', $event)\"\n [min]=\"0\"\n [max]=\"59\"\n [attr.aria-label]=\"locale === 'ar' ? '\u0627\u0644\u062B\u0648\u0627\u0646\u064A' : 'Seconds'\">\n <button class=\"time-btn\" (click)=\"decrementTime('seconds')\">\u25BC</button>\n </div>\n </ng-container>\n \n <!-- AM/PM Toggle (12-hour format) -->\n <div class=\"ampm-toggle\" *ngIf=\"timeFormat === '12'\">\n <button \n class=\"ampm-btn\"\n [class.active]=\"!isPM\"\n (click)=\"setAMPM(false)\">\n AM\n </button>\n <button \n class=\"ampm-btn\"\n [class.active]=\"isPM\"\n (click)=\"setAMPM(true)\">\n PM\n </button>\n </div>\n </div>\n </div>\n\n <!-- Selected Dates Display -->\n <div class=\"selected-dates\" *ngIf=\"selectedDates.length > 0\">\n <div class=\"selected-label\">\n {{ locale === 'ar' ? '\u0627\u0644\u062A\u0648\u0627\u0631\u064A\u062E \u0627\u0644\u0645\u062D\u062F\u062F\u0629:' : 'Selected Dates:' }}\n </div>\n <div class=\"selected-list\">\n <div class=\"selected-item\" *ngFor=\"let date of selectedDates\">\n <div class=\"selected-date-info\">\n <span class=\"date-text\">\n {{ mode === 'hijri' ? date.formatted.hijri : date.formatted.gregorian }}\n </span>\n <span class=\"time-text\" *ngIf=\"enableTime && date.formatted.time\">\n {{ date.formatted.time }}\n </span>\n </div>\n </div>\n </div>\n </div>\n\n <!-- Submit Button -->\n <div class=\"picker-footer\" *ngIf=\"showConfirmButton\">\n <button \n class=\"submit-btn\"\n (click)=\"onSubmit()\"\n [disabled]=\"isRequired && selectedDates.length === 0\">\n {{ submitTextButton }}\n </button>\n </div>\n\n <!-- Calendar Type Label -->\n <div class=\"calendar-type\" *ngIf=\"mode === 'hijri'\">\n <small>{{ ummAlQuraDateText }}</small>\n </div>\n</div>\n", styles: [".hijri-date-picker{font-family:var(--font-family);font-size:var(--font-size);background-color:var(--background-color);color:var(--text-color);border:1px solid var(--border-color);border-radius:var(--border-radius);padding:20px;max-width:400px;box-shadow:0 4px 6px #0000001a}.picker-header{display:flex;justify-content:space-between;align-items:center;margin-bottom:16px;gap:12px}.mode-toggle-btn{background-color:var(--secondary-color);color:#fff;border:none;padding:8px 16px;border-radius:calc(var(--border-radius) / 2);cursor:pointer;font-size:13px;font-weight:500;transition:all .2s ease}.mode-toggle-btn:hover{opacity:.9;transform:translateY(-1px)}.mode-toggle-btn:active{transform:translateY(0)}.todays-date{flex:1;display:flex;justify-content:flex-end}.today-btn{background-color:var(--today-color);color:#fff;border:none;padding:8px 16px;border-radius:calc(var(--border-radius) / 2);cursor:pointer;font-size:13px;font-weight:500;transition:all .2s ease}.today-btn:hover{opacity:.9;transform:translateY(-1px)}.calendar-controls{display:flex;flex-wrap:wrap;gap:12px;margin-bottom:16px;align-items:flex-end}.control-group{flex:1;min-width:120px;display:flex;flex-direction:column;gap:4px}.control-group label{font-size:12px;font-weight:500;color:var(--text-color);opacity:.8}.year-select,.month-select{padding:8px 12px;border:1px solid var(--border-color);border-radius:calc(var(--border-radius) / 2);background-color:var(--background-color);color:var(--text-color);font-size:14px;cursor:pointer;transition:border-color .2s ease}.year-select:hover,.month-select:hover{border-color:var(--primary-color)}.year-select:focus,.month-select:focus{outline:none;border-color:var(--primary-color);box-shadow:0 0 0 3px #4f46e51a}.navigation-buttons{display:flex;gap:8px}.nav-btn{background-color:var(--primary-color);color:#fff;border:none;width:36px;height:36px;border-radius:calc(var(--border-radius) / 2);cursor:pointer;font-size:18px;display:flex;align-items:center;justify-content:center;transition:all .2s ease}.nav-btn:hover{opacity:.9;transform:scale(1.05)}.nav-btn:active{transform:scale(.95)}.calendar-grid{margin-bottom:16px}.weekday-header{display:grid;grid-template-columns:repeat(7,1fr);gap:4px;margin-bottom:8px}.weekday{text-align:center;font-size:12px;font-weight:600;color:var(--text-color);opacity:.7;padding:8px 4px}.calendar-days{display:grid;grid-template-columns:repeat(7,1fr);gap:4px}.day-cell{aspect-ratio:1;display:flex;align-items:center;justify-content:center;border-radius:calc(var(--border-radius) / 2);cursor:pointer;font-size:14px;font-weight:500;transition:all .2s ease;position:relative}.day-cell:not(.empty):not(.disabled):hover{background-color:var(--hover-color);transform:scale(1.05)}.day-cell.empty{cursor:default;pointer-events:none}.day-cell.today{color:var(--today-color);font-weight:700}.day-cell.today:after{content:\"\";position:absolute;bottom:4px;left:50%;transform:translate(-50%);width:4px;height:4px;background-color:var(--today-color);border-radius:50%}.day-cell.selected{background-color:var(--selected-date-background);color:var(--selected-date-color);font-weight:700}.day-cell.disabled{color:var(--disabled-color);cursor:not-allowed;opacity:.5}.day-cell.disabled:hover{background-color:transparent;transform:none}.selected-dates{margin-bottom:16px;padding:12px;background-color:var(--hover-color);border-radius:calc(var(--border-radius) / 2)}.selected-label{font-size:12px;font-weight:600;margin-bottom:8px;color:var(--text-color);opacity:.8}.selected-list{display:flex;flex-wrap:wrap;gap:8px}.selected-item{background-color:var(--primary-color);color:#fff;padding:6px 12px;border-radius:calc(var(--border-radius) / 2);font-size:13px;font-weight:500}.picker-footer{margin-bottom:12px}.submit-btn{width:100%;background-color:var(--primary-color);color:#fff;border:none;padding:12px 24px;border-radius:calc(var(--border-radius) / 2);cursor:pointer;font-size:15px;font-weight:600;transition:all .2s ease}.submit-btn:hover:not(:disabled){opacity:.9;transform:translateY(-2px);box-shadow:0 4px 8px #00000026}.submit-btn:active:not(:disabled){transform:translateY(0)}.submit-btn:disabled{opacity:.5;cursor:not-allowed}.calendar-type{text-align:center;color:var(--text-color);opacity:.6;font-size:11px}.hijri-date-picker[dir=rtl]{direction:rtl}.hijri-date-picker[dir=rtl] .picker-header{flex-direction:row-reverse}.hijri-date-picker[dir=rtl] .todays-date{justify-content:flex-start}@media (max-width: 480px){.hijri-date-picker{padding:16px;max-width:100%}.calendar-controls{flex-direction:column}.control-group{width:100%}.navigation-buttons{width:100%;justify-content:space-between}.weekday{font-size:11px;padding:6px 2px}.day-cell{font-size:13px}}@media (prefers-color-scheme: dark){.hijri-date-picker{--background-color: #1f2937;--text-color: #f9fafb;--border-color: #374151;--hover-color: #374151}}.time-picker{margin-top:10px;margin-bottom:20px;padding:16px;background:linear-gradient(135deg,var(--hover-color) 0%,transparent 100%);border-radius:var(--border-radius);border:1px solid var(--border-color);box-shadow:inset 0 2px 4px #0000000d}.time-picker-label{font-size:13px;font-weight:600;margin-bottom:12px;color:var(--text-color);opacity:.9;text-align:center;text-transform:uppercase;letter-spacing:.5px}.time-inputs{display:flex;align-items:center;justify-content:center;gap:12px}.time-input-group{display:flex;flex-direction:column;align-items:center;gap:6px}.time-btn{background-color:var(--primary-color);color:#fff;border:none;width:36px;height:28px;border-radius:calc(var(--border-radius) / 3);cursor:pointer;font-size:12px;display:flex;align-items:center;justify-content:center;transition:all .2s ease;-webkit-user-select:none;user-select:none}.time-btn:hover{filter:brightness(1.1);transform:scale(1.05)}.time-btn:active{transform:scale(.95)}.time-input{width:60px;padding:10px 4px;text-align:center;border:2px solid var(--border-color);border-radius:calc(var(--border-radius) / 2);background-color:var(--background-color);color:var(--text-color);font-size:20px;font-weight:700;transition:all .2s ease;box-shadow:0 2px 4px #0000000d}.time-input:focus{outline:none;border-color:var(--primary-color);box-shadow:0 0 0 4px #4f46e526}.time-input::-webkit-inner-spin-button,.time-input::-webkit-outer-spin-button{-webkit-appearance:none;margin:0}.time-separator{font-size:28px;font-weight:700;color:var(--text-color);opacity:.4;padding-bottom:4px}.ampm-toggle{display:flex;flex-direction:column;gap:6px;margin-left:12px}.ampm-btn{background-color:var(--background-color);color:var(--text-color);border:1px solid var(--border-color);padding:8px 14px;border-radius:calc(var(--border-radius) / 3);cursor:pointer;font-size:11px;font-weight:700;transition:all .2s ease;box-shadow:0 2px 4px #0000000d}.ampm-btn.active{background-color:var(--primary-color);color:#fff;border-color:var(--primary-color);box-shadow:0 4px 6px #00000026}.ampm-btn:hover:not(.active){background-color:var(--hover-color);border-color:var(--primary-color)}.selected-date-info{display:flex;flex-direction:column;align-items:center;gap:2px}.selected-item .time-text{font-size:11px;opacity:.85;font-weight:500;background-color:#fff3;padding:2px 8px;border-radius:10px;margin-top:2px}\n"] }]
|
|
565
|
-
}], propDecorators: { canChangeMode: [{
|
|
566
|
-
type: Input
|
|
567
|
-
}], mode: [{
|
|
568
|
-
type: Input
|
|
569
|
-
}], dir: [{
|
|
570
|
-
type: Input
|
|
571
|
-
}], locale: [{
|
|
572
|
-
type: Input
|
|
573
|
-
}], futureValidation: [{
|
|
574
|
-
type: Input
|
|
575
|
-
}], futureYearsLimit: [{
|
|
576
|
-
type: Input
|
|
577
|
-
}], isRequired: [{
|
|
578
|
-
type: Input
|
|
579
|
-
}], minDate: [{
|
|
580
|
-
type: Input
|
|
581
|
-
}], maxDate: [{
|
|
582
|
-
type: Input
|
|
583
|
-
}], multiple: [{
|
|
584
|
-
type: Input
|
|
585
|
-
}], showConfirmButton: [{
|
|
586
|
-
type: Input
|
|
587
|
-
}], initialSelectedDate: [{
|
|
588
|
-
type: Input
|
|
589
|
-
}], initialSelectedDates: [{
|
|
590
|
-
type: Input
|
|
591
|
-
}], submitTextButton: [{
|
|
592
|
-
type: Input
|
|
593
|
-
}], todaysDateText: [{
|
|
594
|
-
type: Input
|
|
595
|
-
}], ummAlQuraDateText: [{
|
|
596
|
-
type: Input
|
|
597
|
-
}], yearSelectLabel: [{
|
|
598
|
-
type: Input
|
|
599
|
-
}], monthSelectLabel: [{
|
|
600
|
-
type: Input
|
|
601
|
-
}], todaysDateSection: [{
|
|
602
|
-
type: Input
|
|
603
|
-
}], markToday: [{
|
|
604
|
-
type: Input
|
|
605
|
-
}], disableYearPicker: [{
|
|
606
|
-
type: Input
|
|
607
|
-
}], disableMonthPicker: [{
|
|
608
|
-
type: Input
|
|
609
|
-
}], disableDayPicker: [{
|
|
610
|
-
type: Input
|
|
611
|
-
}], styles: [{
|
|
612
|
-
type: Input
|
|
613
|
-
}], enableTime: [{
|
|
614
|
-
type: Input
|
|
615
|
-
}], timeFormat: [{
|
|
616
|
-
type: Input
|
|
617
|
-
}], minuteStep: [{
|
|
618
|
-
type: Input
|
|
619
|
-
}], enableSeconds: [{
|
|
620
|
-
type: Input
|
|
621
|
-
}], defaultTime: [{
|
|
622
|
-
type: Input
|
|
623
|
-
}], dateSelected: [{
|
|
624
|
-
type: Output
|
|
625
|
-
}], modeChanged: [{
|
|
626
|
-
type: Output
|
|
627
|
-
}] } });
|
|
628
|
-
|
|
629
|
-
/**
|
|
630
|
-
* Generated bundle index. Do not edit.
|
|
631
|
-
*/
|
|
632
|
-
|
|
633
|
-
export { GREGORIAN_MONTHS_AR, GREGORIAN_MONTHS_EN, HIJRI_MONTHS_AR, HIJRI_MONTHS_EN, HijriDatePickerComponent, WEEKDAY_NAMES_AR, WEEKDAY_NAMES_EN };
|
|
634
|
-
//# sourceMappingURL=hijri-date-time-picker.mjs.map
|