@odx/angular 2.11.3 → 2.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/components/calendar/index.d.ts +5 -1
- package/components/calendar/lib/calendar.component.d.ts +11 -11
- package/components/calendar/lib/calendar.config.d.ts +42 -0
- package/components/calendar/lib/{services/calendar.service.d.ts → calendar.service.d.ts} +4 -14
- package/components/calendar/lib/components/calendar-header/calendar-header.component.d.ts +17 -27
- package/components/calendar/lib/components/calendar-month/calendar-month.component.d.ts +11 -12
- package/components/calendar/lib/components/calendar-year/calendar-year.component.d.ts +10 -10
- package/components/calendar/lib/components/calendar-years/calendar-years.component.d.ts +9 -9
- package/components/calendar/lib/directives/calendar-cell.directive.d.ts +20 -13
- package/components/calendar/lib/directives/calendar-view.directive.d.ts +23 -12
- package/components/calendar/lib/{enums/calendar-view.enum.d.ts → models/calendar-view.d.ts} +1 -1
- package/components/calendar/lib/models/index.d.ts +1 -0
- package/components/calendar/lib/pipes/date-label.pipe.d.ts +7 -0
- package/components/calendar/lib/services/calendar-month.service.d.ts +6 -8
- package/components/calendar/lib/services/calendar-year.service.d.ts +4 -6
- package/components/calendar/lib/services/calendar-years.service.d.ts +3 -4
- package/components/calendar/lib/services/index.d.ts +0 -1
- package/components/calendar/lib/utils/check-identical-date.d.ts +2 -2
- package/components/calendar/lib/utils/get-A11y-label.d.ts +2 -2
- package/components/calendar/lib/utils/index.d.ts +1 -0
- package/components/calendar/lib/utils/is-date-disabled.d.ts +2 -0
- package/components/calendar/lib/utils/validate-max-date.d.ts +2 -2
- package/components/calendar/lib/utils/validate-min-date.d.ts +2 -2
- package/components/calendar/lib/utils/validate-next-date-set.d.ts +2 -2
- package/components/calendar/lib/utils/validate-previous-date-set.d.ts +2 -2
- package/components/datepicker/lib/datepicker.component.d.ts +3 -1
- package/components/main-menu/index.d.ts +1 -0
- package/components/main-menu/lib/helpers/create-main-menu-links.d.ts +2 -0
- package/components/main-menu/lib/helpers/index.d.ts +1 -0
- package/components/main-menu/lib/main-menu.component.d.ts +3 -0
- package/components/main-menu/lib/main-menu.config.d.ts +8 -0
- package/components/main-menu/lib/main-menu.i18n.d.ts +3 -0
- package/components/main-menu/lib/models/index.d.ts +1 -0
- package/components/main-menu/lib/models/main-menu-link.d.ts +4 -0
- package/esm2020/components/calendar/index.mjs +6 -2
- package/esm2020/components/calendar/lib/calendar.component.mjs +12 -19
- package/esm2020/components/calendar/lib/calendar.config.mjs +8 -1
- package/esm2020/components/calendar/lib/calendar.service.mjs +36 -0
- package/esm2020/components/calendar/lib/components/calendar-header/calendar-header.component.mjs +33 -27
- package/esm2020/components/calendar/lib/components/calendar-month/calendar-month.component.mjs +6 -6
- package/esm2020/components/calendar/lib/components/calendar-year/calendar-year.component.mjs +7 -7
- package/esm2020/components/calendar/lib/components/calendar-years/calendar-years.component.mjs +9 -8
- package/esm2020/components/calendar/lib/directives/calendar-cell.directive.mjs +8 -11
- package/esm2020/components/calendar/lib/directives/calendar-view.directive.mjs +24 -14
- package/esm2020/components/calendar/lib/models/calendar-view.mjs +7 -0
- package/esm2020/components/calendar/lib/models/index.mjs +2 -1
- package/esm2020/components/calendar/lib/pipes/date-label.pipe.mjs +4 -4
- package/esm2020/components/calendar/lib/services/calendar-month.service.mjs +2 -2
- package/esm2020/components/calendar/lib/services/calendar-year.service.mjs +7 -5
- package/esm2020/components/calendar/lib/services/calendar-years.service.mjs +12 -9
- package/esm2020/components/calendar/lib/services/index.mjs +1 -2
- package/esm2020/components/calendar/lib/utils/check-identical-date.mjs +7 -7
- package/esm2020/components/calendar/lib/utils/get-A11y-label.mjs +7 -7
- package/esm2020/components/calendar/lib/utils/index.mjs +2 -1
- package/esm2020/components/calendar/lib/utils/is-date-disabled.mjs +10 -0
- package/esm2020/components/calendar/lib/utils/validate-max-date.mjs +7 -7
- package/esm2020/components/calendar/lib/utils/validate-min-date.mjs +7 -7
- package/esm2020/components/calendar/lib/utils/validate-next-date-set.mjs +7 -8
- package/esm2020/components/calendar/lib/utils/validate-previous-date-set.mjs +7 -8
- package/esm2020/components/datepicker/lib/datepicker.component.mjs +7 -4
- package/esm2020/components/main-menu/index.mjs +2 -1
- package/esm2020/components/main-menu/lib/helpers/create-main-menu-links.mjs +13 -0
- package/esm2020/components/main-menu/lib/helpers/index.mjs +2 -0
- package/esm2020/components/main-menu/lib/main-menu.component.mjs +11 -5
- package/esm2020/components/main-menu/lib/main-menu.config.mjs +6 -0
- package/esm2020/components/main-menu/lib/main-menu.i18n.mjs +17 -0
- package/esm2020/components/main-menu/lib/models/index.mjs +2 -0
- package/esm2020/components/main-menu/lib/models/main-menu-link.mjs +2 -0
- package/esm2020/index.mjs +2 -1
- package/esm2020/internal/translate/index.mjs +7 -0
- package/esm2020/internal/translate/lib/helpers/get-language-code.mjs +6 -0
- package/esm2020/internal/translate/lib/helpers/index.mjs +2 -0
- package/esm2020/internal/translate/lib/models/index.mjs +2 -0
- package/esm2020/internal/translate/lib/models/translation.mjs +2 -0
- package/esm2020/internal/translate/lib/pipes/index.mjs +2 -0
- package/esm2020/internal/translate/lib/pipes/translate.pipe.mjs +22 -0
- package/esm2020/internal/translate/lib/services/index.mjs +2 -0
- package/esm2020/internal/translate/lib/services/language.service.mjs +21 -0
- package/esm2020/internal/translate/lib/translate.config.mjs +15 -0
- package/esm2020/internal/translate/lib/translate.service.mjs +16 -0
- package/esm2020/internal/translate/odx-angular-internal-translate.mjs +5 -0
- package/esm2020/lib/services/window-ref.mjs +3 -2
- package/esm2020/utils/lib/helpers/build-website-url.mjs +6 -0
- package/esm2020/utils/lib/helpers/index.mjs +2 -1
- package/fesm2015/odx-angular-components-calendar.mjs +254 -270
- package/fesm2015/odx-angular-components-calendar.mjs.map +1 -1
- package/fesm2015/odx-angular-components-datepicker.mjs +5 -2
- package/fesm2015/odx-angular-components-datepicker.mjs.map +1 -1
- package/fesm2015/odx-angular-components-main-menu.mjs +43 -6
- package/fesm2015/odx-angular-components-main-menu.mjs.map +1 -1
- package/fesm2015/odx-angular-internal-translate.mjs +75 -0
- package/fesm2015/odx-angular-internal-translate.mjs.map +1 -0
- package/fesm2015/odx-angular-utils.mjs +6 -1
- package/fesm2015/odx-angular-utils.mjs.map +1 -1
- package/fesm2015/odx-angular.mjs +3 -1
- package/fesm2015/odx-angular.mjs.map +1 -1
- package/fesm2020/odx-angular-components-calendar.mjs +254 -269
- package/fesm2020/odx-angular-components-calendar.mjs.map +1 -1
- package/fesm2020/odx-angular-components-datepicker.mjs +5 -2
- package/fesm2020/odx-angular-components-datepicker.mjs.map +1 -1
- package/fesm2020/odx-angular-components-main-menu.mjs +43 -6
- package/fesm2020/odx-angular-components-main-menu.mjs.map +1 -1
- package/fesm2020/odx-angular-internal-translate.mjs +74 -0
- package/fesm2020/odx-angular-internal-translate.mjs.map +1 -0
- package/fesm2020/odx-angular-utils.mjs +6 -1
- package/fesm2020/odx-angular-utils.mjs.map +1 -1
- package/fesm2020/odx-angular.mjs +3 -1
- package/fesm2020/odx-angular.mjs.map +1 -1
- package/index.d.ts +1 -0
- package/internal/translate/README.md +3 -0
- package/internal/translate/index.d.ts +6 -0
- package/internal/translate/lib/helpers/get-language-code.d.ts +1 -0
- package/internal/translate/lib/helpers/index.d.ts +1 -0
- package/internal/translate/lib/models/index.d.ts +1 -0
- package/internal/translate/lib/models/translation.d.ts +2 -0
- package/internal/translate/lib/pipes/index.d.ts +1 -0
- package/internal/translate/lib/pipes/translate.pipe.d.ts +9 -0
- package/internal/translate/lib/services/index.d.ts +1 -0
- package/internal/translate/lib/services/language.service.d.ts +8 -0
- package/internal/translate/lib/translate.config.d.ts +9 -0
- package/internal/translate/lib/translate.service.d.ts +10 -0
- package/package.json +11 -3
- package/utils/lib/helpers/build-website-url.d.ts +2 -0
- package/utils/lib/helpers/index.d.ts +1 -0
- package/components/calendar/lib/enums/index.d.ts +0 -1
- package/esm2020/components/calendar/lib/enums/calendar-view.enum.mjs +0 -7
- package/esm2020/components/calendar/lib/enums/index.mjs +0 -2
- package/esm2020/components/calendar/lib/services/calendar.service.mjs +0 -73
|
@@ -1,56 +1,69 @@
|
|
|
1
1
|
import { __decorate, __metadata } from 'tslib';
|
|
2
2
|
import { A11yModule } from '@angular/cdk/a11y';
|
|
3
3
|
import * as i0 from '@angular/core';
|
|
4
|
-
import { Injectable,
|
|
4
|
+
import { Injectable, EventEmitter, Component, ChangeDetectionStrategy, ViewEncapsulation, Input, Output, Pipe, inject, Directive } from '@angular/core';
|
|
5
5
|
import * as i2 from '@odx/angular';
|
|
6
6
|
import { CoreModule, DisabledController } from '@odx/angular';
|
|
7
7
|
import { CSSComponent, CSSModifier } from '@odx/angular/internal';
|
|
8
|
-
import {
|
|
8
|
+
import { isString, isPresent, injectElement, hasChanged, createConfigTokens, deferFn, untilDestroyed, trackByIndex, isFunction } from '@odx/angular/utils';
|
|
9
|
+
import { isSameDay, isSameMonth, isSameYear, endOfDay, endOfMonth, endOfYear, startOfDay, startOfMonth, startOfYear, isValid, toDate, addMonths, subMonths, isEqual, format, startOfWeek, addDays, endOfWeek, eachMonthOfInterval, addYears, getYear, setYear, subDays, subWeeks, addWeeks, setMonth, getMonth } from 'date-fns';
|
|
10
|
+
import { BehaviorSubject, Subject, shareReplay, merge, filter, distinctUntilChanged, map, defer, of } from 'rxjs';
|
|
9
11
|
import { ActionGroupComponent } from '@odx/angular/components/action-group';
|
|
10
12
|
import { ButtonComponent } from '@odx/angular/components/button';
|
|
11
13
|
import { IconComponent } from '@odx/angular/components/icon';
|
|
12
|
-
import { BehaviorSubject, shareReplay, tap, map } from 'rxjs';
|
|
13
14
|
import { enGB } from 'date-fns/locale';
|
|
14
|
-
import { isSameDay, isSameMonth, isSameYear, isValid, toDate, endOfDay, endOfMonth, endOfYear, startOfDay, startOfMonth, startOfYear, addMonths, subMonths, startOfWeek, addDays, endOfWeek, eachMonthOfInterval, addYears, getYear, setYear, format, subDays, subWeeks, addWeeks, setMonth, getMonth } from 'date-fns';
|
|
15
15
|
import * as i1 from '@angular/common';
|
|
16
16
|
import { DOCUMENT } from '@angular/common';
|
|
17
|
+
import * as i2$1 from '@ngrx/component';
|
|
17
18
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
dayA11yLabel: 'MMMM dd, yyyy',
|
|
25
|
-
monthA11yLabel: 'MMMM, yyyy',
|
|
26
|
-
yearA11yLabel: 'yyyy',
|
|
27
|
-
displayAdjacentDays: true,
|
|
28
|
-
locale: new BehaviorSubject(enGB),
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
var CalendarViewEnum;
|
|
32
|
-
(function (CalendarViewEnum) {
|
|
33
|
-
CalendarViewEnum["Month"] = "month";
|
|
34
|
-
CalendarViewEnum["Year"] = "year";
|
|
35
|
-
CalendarViewEnum["Years"] = "years";
|
|
36
|
-
})(CalendarViewEnum || (CalendarViewEnum = {}));
|
|
19
|
+
var CalendarView;
|
|
20
|
+
(function (CalendarView) {
|
|
21
|
+
CalendarView["Month"] = "month";
|
|
22
|
+
CalendarView["Year"] = "year";
|
|
23
|
+
CalendarView["Years"] = "years";
|
|
24
|
+
})(CalendarView || (CalendarView = {}));
|
|
37
25
|
|
|
38
|
-
const
|
|
39
|
-
[
|
|
40
|
-
[
|
|
41
|
-
[
|
|
26
|
+
const dateValidators$4 = {
|
|
27
|
+
[CalendarView.Month]: (currentDate, date) => isSameDay(currentDate, date),
|
|
28
|
+
[CalendarView.Year]: (currentDate, date) => isSameMonth(currentDate, date),
|
|
29
|
+
[CalendarView.Years]: (currentDate, date) => isSameYear(currentDate, date),
|
|
42
30
|
};
|
|
43
31
|
function checkIdenticalDate(currentDate, date, calendarView) {
|
|
44
|
-
return
|
|
32
|
+
return dateValidators$4[calendarView](currentDate, date);
|
|
45
33
|
}
|
|
46
34
|
|
|
47
|
-
const
|
|
48
|
-
[
|
|
49
|
-
[
|
|
50
|
-
[
|
|
35
|
+
const labelResolvers = {
|
|
36
|
+
[CalendarView.Month]: (config) => config.dayA11yLabel,
|
|
37
|
+
[CalendarView.Year]: (config) => config.monthA11yLabel,
|
|
38
|
+
[CalendarView.Years]: (config) => config.yearA11yLabel,
|
|
51
39
|
};
|
|
52
40
|
function getA11yLabel(calendarView, config) {
|
|
53
|
-
return
|
|
41
|
+
return labelResolvers[calendarView](config);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const dateValidators$3 = {
|
|
45
|
+
[CalendarView.Month]: (maxDate, date) => endOfDay(maxDate) < endOfDay(date),
|
|
46
|
+
[CalendarView.Year]: (maxDate, date) => endOfMonth(maxDate) < endOfMonth(date),
|
|
47
|
+
[CalendarView.Years]: (maxDate, date) => endOfYear(maxDate) < endOfYear(date),
|
|
48
|
+
};
|
|
49
|
+
function validateMaxDate(maxDate, date, calendarView) {
|
|
50
|
+
return dateValidators$3[calendarView](maxDate, date);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const dateValidators$2 = {
|
|
54
|
+
[CalendarView.Month]: (minDate, date) => startOfDay(minDate) > startOfDay(date),
|
|
55
|
+
[CalendarView.Year]: (minDate, date) => startOfMonth(minDate) > startOfMonth(date),
|
|
56
|
+
[CalendarView.Years]: (minDate, date) => startOfYear(minDate) > startOfYear(date),
|
|
57
|
+
};
|
|
58
|
+
function validateMinDate(maxDate, date, calendarView) {
|
|
59
|
+
return dateValidators$2[calendarView](maxDate, date);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function isDateDisabled(date, calendarView, minDate, maxDate, filterFn) {
|
|
63
|
+
const minDateValidation = minDate && validateMinDate(minDate, date, calendarView);
|
|
64
|
+
const maxDateValidation = maxDate && validateMaxDate(maxDate, date, calendarView);
|
|
65
|
+
const isDateFiltered = calendarView === CalendarView.Month && !!filterFn?.(date);
|
|
66
|
+
return minDateValidation || maxDateValidation || isDateFiltered;
|
|
54
67
|
}
|
|
55
68
|
|
|
56
69
|
function parseDate(value) {
|
|
@@ -66,235 +79,98 @@ function parseDate(value) {
|
|
|
66
79
|
}
|
|
67
80
|
}
|
|
68
81
|
|
|
69
|
-
const
|
|
70
|
-
[
|
|
71
|
-
[
|
|
72
|
-
[
|
|
73
|
-
};
|
|
74
|
-
function validateMaxDate(maxDate, date, calendarView) {
|
|
75
|
-
return functionList$3[calendarView](maxDate, date);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
const functionList$2 = {
|
|
79
|
-
[CalendarViewEnum.Month]: (minDate, date) => startOfDay(minDate) > startOfDay(date),
|
|
80
|
-
[CalendarViewEnum.Year]: (minDate, date) => startOfMonth(minDate) > startOfMonth(date),
|
|
81
|
-
[CalendarViewEnum.Years]: (minDate, date) => startOfYear(minDate) > startOfYear(date),
|
|
82
|
-
};
|
|
83
|
-
function validateMinDate(maxDate, date, calendarView) {
|
|
84
|
-
return functionList$2[calendarView](maxDate, date);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
const functionList$1 = {
|
|
88
|
-
[CalendarViewEnum.Month]: (maxDate, date) => maxDate < startOfMonth(addMonths(date, 1)),
|
|
89
|
-
[CalendarViewEnum.Year]: (maxDate, date) => maxDate < startOfYear(addMonths(date, 12)),
|
|
90
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
91
|
-
[CalendarViewEnum.Years]: (maxDate, date) => false,
|
|
82
|
+
const dateValidators$1 = {
|
|
83
|
+
[CalendarView.Month]: (maxDate, date) => maxDate < startOfMonth(addMonths(date, 1)),
|
|
84
|
+
[CalendarView.Year]: (maxDate, date) => maxDate < startOfYear(addMonths(date, 12)),
|
|
85
|
+
[CalendarView.Years]: () => false,
|
|
92
86
|
};
|
|
93
87
|
function validateNextDateSet(maxDate, date, calendarView) {
|
|
94
|
-
return
|
|
88
|
+
return dateValidators$1[calendarView](maxDate, date);
|
|
95
89
|
}
|
|
96
90
|
|
|
97
|
-
const
|
|
98
|
-
[
|
|
99
|
-
[
|
|
100
|
-
|
|
101
|
-
[CalendarViewEnum.Years]: () => false,
|
|
91
|
+
const dateValidators = {
|
|
92
|
+
[CalendarView.Month]: (minDate, date) => minDate > endOfMonth(subMonths(date, 1)),
|
|
93
|
+
[CalendarView.Year]: (minDate, date) => minDate > endOfYear(subMonths(date, 12)),
|
|
94
|
+
[CalendarView.Years]: () => false,
|
|
102
95
|
};
|
|
103
96
|
function validatePreviousDateSet(minDate, date, calendarView) {
|
|
104
|
-
return
|
|
97
|
+
return dateValidators[calendarView](minDate, date);
|
|
105
98
|
}
|
|
106
99
|
|
|
107
100
|
class CalendarService {
|
|
108
101
|
constructor() {
|
|
109
|
-
this.calendarView$$ = new BehaviorSubject(
|
|
110
|
-
this.activeDate$$ = new
|
|
102
|
+
this.calendarView$$ = new BehaviorSubject(CalendarView.Month);
|
|
103
|
+
this.activeDate$$ = new Subject();
|
|
111
104
|
this.selectedDate$$ = new BehaviorSubject(null);
|
|
112
|
-
this.minDate = null;
|
|
113
|
-
this.maxDate = null;
|
|
114
|
-
this.filterFn = null;
|
|
115
105
|
this.calendarView$ = this.calendarView$$.pipe(shareReplay({ refCount: true }));
|
|
116
|
-
this.
|
|
117
|
-
this.
|
|
106
|
+
this.selectedDate$ = this.selectedDate$$.pipe(shareReplay({ refCount: true }));
|
|
107
|
+
this.activeDate$ = merge(this.activeDate$$, this.selectedDate$).pipe(filter(Boolean), distinctUntilChanged((prev, curr) => isEqual(prev, curr)), shareReplay({ refCount: true }));
|
|
118
108
|
}
|
|
119
109
|
setActiveDate(value) {
|
|
120
|
-
if (isPresent(value))
|
|
121
|
-
|
|
122
|
-
|
|
110
|
+
if (!isPresent(value))
|
|
111
|
+
return;
|
|
112
|
+
this.activeDate$$.next(parseDate(value));
|
|
123
113
|
}
|
|
124
114
|
selectDate(value) {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
else {
|
|
129
|
-
this.selectedDate$$.next(null);
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
get activeDate() {
|
|
133
|
-
return this.activeDate$$.getValue();
|
|
134
|
-
}
|
|
135
|
-
get selectedDate() {
|
|
136
|
-
return this.selectedDate$$.getValue();
|
|
115
|
+
const date = isPresent(value) ? startOfDay(parseDate(value)) : null;
|
|
116
|
+
this.selectedDate$$.next(date);
|
|
117
|
+
this.setActiveDate(date);
|
|
137
118
|
}
|
|
138
119
|
changeView(view) {
|
|
139
120
|
this.calendarView$$.next(view);
|
|
140
121
|
}
|
|
141
|
-
get calendarCurrentView() {
|
|
142
|
-
return this.calendarView$$.getValue();
|
|
143
|
-
}
|
|
144
|
-
isDateDisabled(date) {
|
|
145
|
-
const minDate = this.minDate && validateMinDate(this.minDate, date, this.calendarCurrentView);
|
|
146
|
-
const maxDate = this.maxDate && validateMaxDate(this.maxDate, date, this.calendarCurrentView);
|
|
147
|
-
let isDateFiltered = false;
|
|
148
|
-
if (this.calendarCurrentView === CalendarViewEnum.Month) {
|
|
149
|
-
isDateFiltered = this.filterFn?.(date) ?? false;
|
|
150
|
-
}
|
|
151
|
-
return minDate || maxDate || isDateFiltered;
|
|
152
|
-
}
|
|
153
|
-
isPreviousDateSetDisabled() {
|
|
154
|
-
return this.minDate ? validatePreviousDateSet(this.minDate, this.activeDate, this.calendarCurrentView) : false;
|
|
155
|
-
}
|
|
156
|
-
isNextDateSetDisabled() {
|
|
157
|
-
return this.maxDate ? validateNextDateSet(this.maxDate, this.activeDate, this.calendarCurrentView) : false;
|
|
158
|
-
}
|
|
159
122
|
}
|
|
160
123
|
CalendarService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: CalendarService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
161
124
|
CalendarService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: CalendarService });
|
|
162
|
-
__decorate([
|
|
163
|
-
Pure,
|
|
164
|
-
__metadata("design:type", Function),
|
|
165
|
-
__metadata("design:paramtypes", [Date]),
|
|
166
|
-
__metadata("design:returntype", Boolean)
|
|
167
|
-
], CalendarService.prototype, "isDateDisabled", null);
|
|
168
125
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: CalendarService, decorators: [{
|
|
169
126
|
type: Injectable
|
|
170
|
-
}], propDecorators: { isDateDisabled: [] } });
|
|
171
|
-
|
|
172
|
-
class CalendarMonthService {
|
|
173
|
-
constructor() {
|
|
174
|
-
this.calendar = inject(CalendarService);
|
|
175
|
-
this.weekDays$ = this.calendar.activeDate$.pipe(map((date) => this.generateWeekDays(date)));
|
|
176
|
-
this.weeks$ = this.calendar.activeDate$.pipe(map((date) => this.generateWeeks(date)));
|
|
177
|
-
}
|
|
178
|
-
generateWeekDays(date) {
|
|
179
|
-
const firstWeekDay = startOfWeek(date, { weekStartsOn: 1 });
|
|
180
|
-
return Array.from({ length: 7 }, (_, i) => addDays(firstWeekDay, i));
|
|
181
|
-
}
|
|
182
|
-
generateWeeks(date) {
|
|
183
|
-
const startOfTheSelectedMonth = startOfMonth(date);
|
|
184
|
-
const endOfTheSelectedMonth = endOfMonth(date);
|
|
185
|
-
const startDate = startOfWeek(startOfTheSelectedMonth, { weekStartsOn: 1 });
|
|
186
|
-
const endDate = endOfWeek(endOfTheSelectedMonth);
|
|
187
|
-
const allWeeks = [];
|
|
188
|
-
let currentDate = startDate;
|
|
189
|
-
while (currentDate <= endDate) {
|
|
190
|
-
allWeeks.push(this.generateDaysForWeek(currentDate, date));
|
|
191
|
-
currentDate = addDays(currentDate, 7);
|
|
192
|
-
}
|
|
193
|
-
return allWeeks;
|
|
194
|
-
}
|
|
195
|
-
generateDaysForWeek(date, currentDate) {
|
|
196
|
-
return Array.from({ length: 7 }).map((_, i) => addDays(date, i), currentDate);
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
CalendarMonthService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: CalendarMonthService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
200
|
-
CalendarMonthService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: CalendarMonthService });
|
|
201
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: CalendarMonthService, decorators: [{
|
|
202
|
-
type: Injectable
|
|
203
|
-
}] });
|
|
204
|
-
|
|
205
|
-
class CalendarYearService {
|
|
206
|
-
constructor() {
|
|
207
|
-
this.calendar = inject(CalendarService);
|
|
208
|
-
this.seasonSeparator = 3;
|
|
209
|
-
this.seasons$ = this.calendar.activeDate$.pipe(map((selectedDate) => this.generateSeasons(selectedDate)));
|
|
210
|
-
}
|
|
211
|
-
generateSeasons(date) {
|
|
212
|
-
const seasons = [];
|
|
213
|
-
const months = eachMonthOfInterval({
|
|
214
|
-
start: startOfYear(date),
|
|
215
|
-
end: endOfYear(date),
|
|
216
|
-
});
|
|
217
|
-
let index = 0;
|
|
218
|
-
while (index < months.length) {
|
|
219
|
-
seasons.push(months.slice(index, index + this.seasonSeparator));
|
|
220
|
-
index += this.seasonSeparator;
|
|
221
|
-
}
|
|
222
|
-
return seasons;
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
CalendarYearService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: CalendarYearService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
226
|
-
CalendarYearService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: CalendarYearService });
|
|
227
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: CalendarYearService, decorators: [{
|
|
228
|
-
type: Injectable
|
|
229
|
-
}] });
|
|
230
|
-
|
|
231
|
-
class CalendarYearsService {
|
|
232
|
-
constructor() {
|
|
233
|
-
this.yearsSeparator = 3;
|
|
234
|
-
this.yearsLimit = 100;
|
|
235
|
-
this.date = new Date();
|
|
236
|
-
}
|
|
237
|
-
get years() {
|
|
238
|
-
const startDate = startOfYear(addYears(this.date, -this.yearsLimit));
|
|
239
|
-
const startYear = getYear(startDate);
|
|
240
|
-
const endDate = startOfYear(addYears(this.date, this.yearsLimit));
|
|
241
|
-
const endYear = getYear(endDate);
|
|
242
|
-
const years = [];
|
|
243
|
-
const yearRows = [];
|
|
244
|
-
for (let i = startYear; i <= endYear; i++) {
|
|
245
|
-
years.push(setYear(startDate, i));
|
|
246
|
-
}
|
|
247
|
-
let index = 0;
|
|
248
|
-
while (index < years.length) {
|
|
249
|
-
yearRows.push(years.slice(index, index + this.yearsSeparator));
|
|
250
|
-
index += this.yearsSeparator;
|
|
251
|
-
}
|
|
252
|
-
return yearRows;
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
CalendarYearsService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: CalendarYearsService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
256
|
-
CalendarYearsService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: CalendarYearsService });
|
|
257
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: CalendarYearsService, decorators: [{
|
|
258
|
-
type: Injectable
|
|
259
127
|
}] });
|
|
260
128
|
|
|
261
129
|
let CalendarHeaderComponent = class CalendarHeaderComponent {
|
|
262
130
|
constructor() {
|
|
263
|
-
this.
|
|
131
|
+
this.isPreviousDisabled = false;
|
|
132
|
+
this.isNextDisabled = false;
|
|
264
133
|
this.element = injectElement();
|
|
134
|
+
this.minDate = null;
|
|
135
|
+
this.maxDate = null;
|
|
265
136
|
this.previous = new EventEmitter();
|
|
266
137
|
this.next = new EventEmitter();
|
|
267
138
|
this.changeView = new EventEmitter();
|
|
268
|
-
|
|
139
|
+
}
|
|
140
|
+
ngOnChanges(changes) {
|
|
141
|
+
if (hasChanged(changes, ['activeDate', 'calendarView', 'minDate', 'maxDate'], false)) {
|
|
142
|
+
this.isPreviousDisabled = this.minDate ? validatePreviousDateSet(this.minDate, this.activeDate, this.calendarView) : false;
|
|
143
|
+
this.isNextDisabled = this.maxDate ? validateNextDateSet(this.maxDate, this.activeDate, this.calendarView) : false;
|
|
144
|
+
}
|
|
269
145
|
}
|
|
270
146
|
previousClicked(event) {
|
|
271
|
-
|
|
147
|
+
if (this.isPreviousDisabled)
|
|
148
|
+
return;
|
|
149
|
+
this.previous.emit(event);
|
|
272
150
|
}
|
|
273
151
|
nextClicked(event) {
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
return this.calendar.activeDate$.pipe(map(() => this.isPreviousDisabled));
|
|
278
|
-
}
|
|
279
|
-
get handleIsNextDisabled$() {
|
|
280
|
-
return this.calendar.activeDate$.pipe(map(() => this.isNextDisabled));
|
|
281
|
-
}
|
|
282
|
-
get isPreviousDisabled() {
|
|
283
|
-
return this.calendar.isPreviousDateSetDisabled();
|
|
284
|
-
}
|
|
285
|
-
get isNextDisabled() {
|
|
286
|
-
return this.calendar.isNextDateSetDisabled();
|
|
152
|
+
if (this.isNextDisabled)
|
|
153
|
+
return;
|
|
154
|
+
this.next.emit(event);
|
|
287
155
|
}
|
|
288
156
|
};
|
|
289
157
|
CalendarHeaderComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: CalendarHeaderComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
290
|
-
CalendarHeaderComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.9", type: CalendarHeaderComponent, isStandalone: true, selector: "odx-calendar-header", outputs: { previous: "previous", next: "next", changeView: "changeView" }, ngImport: i0, template: "<odx-action-group>\n <button odxButton (click)=\"previousClicked($event)\"
|
|
158
|
+
CalendarHeaderComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.9", type: CalendarHeaderComponent, isStandalone: true, selector: "odx-calendar-header", inputs: { activeDate: "activeDate", calendarView: "calendarView", minDate: "minDate", maxDate: "maxDate" }, outputs: { previous: "previous", next: "next", changeView: "changeView" }, usesOnChanges: true, ngImport: i0, template: "<odx-action-group>\n <button odxButton [disabled]=\"isPreviousDisabled\" (click)=\"previousClicked($event)\">\n <odx-icon name=\"chevron-left\"></odx-icon>\n </button>\n\n <button odxButton class=\"odx-calendar-header__title\" (click)=\"changeView.emit()\">\n <ng-content></ng-content>\n </button>\n\n <button odxButton [disabled]=\"isNextDisabled\" (click)=\"nextClicked($event)\">\n <odx-icon name=\"chevron-right\"></odx-icon>\n </button>\n</odx-action-group>\n", dependencies: [{ kind: "ngmodule", type: CoreModule }, { kind: "directive", type: i2.DisabledController, selector: "[disabled]", inputs: ["disabled"] }, { kind: "component", type: ActionGroupComponent, selector: "odx-action-group", inputs: ["reverse"] }, { kind: "component", type: ButtonComponent, selector: "button[odxButton], a[odxButton]", inputs: ["variant", "size"] }, { kind: "component", type: IconComponent, selector: "odx-icon", inputs: ["inline", "size", "name", "iconSet"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
291
159
|
CalendarHeaderComponent = __decorate([
|
|
292
160
|
CSSComponent('calendar-header')
|
|
293
161
|
], CalendarHeaderComponent);
|
|
294
162
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: CalendarHeaderComponent, decorators: [{
|
|
295
163
|
type: Component,
|
|
296
|
-
args: [{ selector: 'odx-calendar-header', standalone: true, imports: [CoreModule, ActionGroupComponent, ButtonComponent, IconComponent], changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, template: "<odx-action-group>\n <button odxButton (click)=\"previousClicked($event)\"
|
|
297
|
-
}], propDecorators: {
|
|
164
|
+
args: [{ selector: 'odx-calendar-header', standalone: true, imports: [CoreModule, ActionGroupComponent, ButtonComponent, IconComponent], changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, template: "<odx-action-group>\n <button odxButton [disabled]=\"isPreviousDisabled\" (click)=\"previousClicked($event)\">\n <odx-icon name=\"chevron-left\"></odx-icon>\n </button>\n\n <button odxButton class=\"odx-calendar-header__title\" (click)=\"changeView.emit()\">\n <ng-content></ng-content>\n </button>\n\n <button odxButton [disabled]=\"isNextDisabled\" (click)=\"nextClicked($event)\">\n <odx-icon name=\"chevron-right\"></odx-icon>\n </button>\n</odx-action-group>\n" }]
|
|
165
|
+
}], propDecorators: { activeDate: [{
|
|
166
|
+
type: Input
|
|
167
|
+
}], calendarView: [{
|
|
168
|
+
type: Input
|
|
169
|
+
}], minDate: [{
|
|
170
|
+
type: Input
|
|
171
|
+
}], maxDate: [{
|
|
172
|
+
type: Input
|
|
173
|
+
}], previous: [{
|
|
298
174
|
type: Output
|
|
299
175
|
}], next: [{
|
|
300
176
|
type: Output
|
|
@@ -302,6 +178,26 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
|
|
|
302
178
|
type: Output
|
|
303
179
|
}] } });
|
|
304
180
|
|
|
181
|
+
const { CalendarConfig, CalendarDefaultConfig, injectCalendarConfig, provideCalendarConfig } = createConfigTokens('Calendar', '@odx/angular/components/calendar', {
|
|
182
|
+
monthYearLabel: 'LLLL yyyy',
|
|
183
|
+
monthLabel: 'LLL',
|
|
184
|
+
weekLabel: 'EEEEE',
|
|
185
|
+
dayLabel: 'd',
|
|
186
|
+
yearLabel: 'yyyy',
|
|
187
|
+
dayA11yLabel: 'MMMM dd, yyyy',
|
|
188
|
+
monthA11yLabel: 'MMMM, yyyy',
|
|
189
|
+
yearA11yLabel: 'yyyy',
|
|
190
|
+
displayAdjacentDays: true,
|
|
191
|
+
locale: new BehaviorSubject(enGB),
|
|
192
|
+
yearView: {
|
|
193
|
+
itemsPerRow: 3,
|
|
194
|
+
},
|
|
195
|
+
yearsView: {
|
|
196
|
+
itemsPerRow: 3,
|
|
197
|
+
padding: 100,
|
|
198
|
+
},
|
|
199
|
+
});
|
|
200
|
+
|
|
305
201
|
class DateLabelPipe {
|
|
306
202
|
constructor() {
|
|
307
203
|
this.config = injectCalendarConfig();
|
|
@@ -313,28 +209,28 @@ class DateLabelPipe {
|
|
|
313
209
|
}
|
|
314
210
|
}
|
|
315
211
|
DateLabelPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: DateLabelPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
316
|
-
DateLabelPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: DateLabelPipe, isStandalone: true, name: "odxDateLabel"
|
|
212
|
+
DateLabelPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: DateLabelPipe, isStandalone: true, name: "odxDateLabel" });
|
|
317
213
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: DateLabelPipe, decorators: [{
|
|
318
214
|
type: Pipe,
|
|
319
215
|
args: [{
|
|
320
|
-
pure: false,
|
|
321
|
-
name: 'odxDateLabel',
|
|
322
216
|
standalone: true,
|
|
217
|
+
name: 'odxDateLabel',
|
|
218
|
+
pure: true,
|
|
323
219
|
}]
|
|
324
220
|
}] });
|
|
325
221
|
|
|
326
222
|
let CalendarCellDirective = class CalendarCellDirective {
|
|
327
223
|
constructor() {
|
|
328
224
|
this.disabledController = DisabledController.inject();
|
|
225
|
+
this.config = injectCalendarConfig();
|
|
226
|
+
this.dateLabelPipe = inject(DateLabelPipe);
|
|
329
227
|
this.isActive = false;
|
|
330
228
|
this.isSelected = false;
|
|
331
229
|
this.isHidden = false;
|
|
230
|
+
this.ariaLabel = '';
|
|
332
231
|
this.isCurrent = false;
|
|
333
232
|
this.adjacent = false;
|
|
334
233
|
this.element = injectElement();
|
|
335
|
-
this.dateLabelPipe = inject(DateLabelPipe);
|
|
336
|
-
this.config = injectCalendarConfig();
|
|
337
|
-
this.calendarView = CalendarViewEnum.Month;
|
|
338
234
|
this.activeDate = null;
|
|
339
235
|
this.selectedDate = null;
|
|
340
236
|
}
|
|
@@ -342,12 +238,13 @@ let CalendarCellDirective = class CalendarCellDirective {
|
|
|
342
238
|
return !!this.disabledController?.disabled;
|
|
343
239
|
}
|
|
344
240
|
ngOnChanges(changes) {
|
|
345
|
-
if (hasChanged(changes, ['date'], false)) {
|
|
241
|
+
if (hasChanged(changes, ['date', 'calendarView'], false)) {
|
|
242
|
+
this.ariaLabel = this.dateLabelPipe.transform(this.date, getA11yLabel(this.calendarView, this.config));
|
|
346
243
|
this.isCurrent = checkIdenticalDate(this.date, new Date(), this.calendarView);
|
|
347
244
|
}
|
|
348
245
|
if (this.activeDate && hasChanged(changes, ['date', 'activeDate'], false)) {
|
|
349
246
|
this.isActive = checkIdenticalDate(this.date, this.activeDate, this.calendarView);
|
|
350
|
-
if (this.calendarView ===
|
|
247
|
+
if (this.calendarView === CalendarView.Month) {
|
|
351
248
|
this.adjacent = !isSameMonth(this.date, this.activeDate);
|
|
352
249
|
this.isHidden = this.adjacent && !this.config.displayAdjacentDays;
|
|
353
250
|
}
|
|
@@ -359,10 +256,6 @@ let CalendarCellDirective = class CalendarCellDirective {
|
|
|
359
256
|
deferFn(() => this.element.nativeElement.focus());
|
|
360
257
|
}
|
|
361
258
|
}
|
|
362
|
-
get ariaLabel() {
|
|
363
|
-
const dateFormat = getA11yLabel(this.calendarView, this.config);
|
|
364
|
-
return this.dateLabelPipe.transform(this.date, dateFormat);
|
|
365
|
-
}
|
|
366
259
|
};
|
|
367
260
|
CalendarCellDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: CalendarCellDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
368
261
|
CalendarCellDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.9", type: CalendarCellDirective, isStandalone: true, selector: "[odxCalendarCell]", inputs: { date: ["odxCalendarCell", "date"], calendarView: ["odxCalendarCellCalendarView", "calendarView"], activeDate: ["odxCalendarCellActiveDate", "activeDate"], selectedDate: ["odxCalendarCellSelectedDate", "selectedDate"] }, host: { properties: { "class.is-disabled": "isDisabled", "class.is-selected": "isSelected", "attr.hidden": "isHidden || null", "tabindex": "isActive ? 0 : -1", "attr.aria-label": "ariaLabel", "attr.aria-disabled": "isDisabled", "attr.type": "\"button\"" } }, providers: [DisabledController.connect(), DateLabelPipe], usesOnChanges: true, ngImport: i0 });
|
|
@@ -412,19 +305,18 @@ class CalendarViewDirective {
|
|
|
412
305
|
this.takeUntilDestroyed = untilDestroyed();
|
|
413
306
|
this.calendar = inject(CalendarService);
|
|
414
307
|
this.config = injectCalendarConfig();
|
|
308
|
+
this.trackByIndex = trackByIndex;
|
|
415
309
|
this.element = injectElement();
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
trackByIndex(index) {
|
|
421
|
-
return index;
|
|
310
|
+
this.selectedDate = null;
|
|
311
|
+
this.minDate = null;
|
|
312
|
+
this.maxDate = null;
|
|
313
|
+
this.filterFn = null;
|
|
422
314
|
}
|
|
423
315
|
isDateDisabled(value) {
|
|
424
|
-
return this.
|
|
316
|
+
return isDateDisabled(value, this.currentView, this.minDate, this.maxDate, this.filterFn);
|
|
425
317
|
}
|
|
426
318
|
changeView() {
|
|
427
|
-
this.calendar.changeView(this.
|
|
319
|
+
this.calendar.changeView(this.nextView);
|
|
428
320
|
}
|
|
429
321
|
updateActiveDate(event, date) {
|
|
430
322
|
event.preventDefault();
|
|
@@ -433,20 +325,121 @@ class CalendarViewDirective {
|
|
|
433
325
|
}
|
|
434
326
|
}
|
|
435
327
|
CalendarViewDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: CalendarViewDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
436
|
-
CalendarViewDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.9", type: CalendarViewDirective, isStandalone: true, ngImport: i0 });
|
|
328
|
+
CalendarViewDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.9", type: CalendarViewDirective, isStandalone: true, inputs: { activeDate: "activeDate", selectedDate: "selectedDate", minDate: "minDate", maxDate: "maxDate", filterFn: "filterFn" }, ngImport: i0 });
|
|
437
329
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: CalendarViewDirective, decorators: [{
|
|
438
330
|
type: Directive,
|
|
439
331
|
args: [{
|
|
440
332
|
standalone: true,
|
|
441
333
|
}]
|
|
334
|
+
}], propDecorators: { activeDate: [{
|
|
335
|
+
type: Input
|
|
336
|
+
}], selectedDate: [{
|
|
337
|
+
type: Input
|
|
338
|
+
}], minDate: [{
|
|
339
|
+
type: Input
|
|
340
|
+
}], maxDate: [{
|
|
341
|
+
type: Input
|
|
342
|
+
}], filterFn: [{
|
|
343
|
+
type: Input
|
|
344
|
+
}] } });
|
|
345
|
+
|
|
346
|
+
class CalendarMonthService {
|
|
347
|
+
constructor() {
|
|
348
|
+
this.calendar = inject(CalendarService);
|
|
349
|
+
this.weekDays$ = this.calendar.activeDate$.pipe(map((date) => this.generateWeekDays(date)));
|
|
350
|
+
this.weeks$ = this.calendar.activeDate$.pipe(map((date) => this.generateWeeks(date)));
|
|
351
|
+
}
|
|
352
|
+
generateWeekDays(date) {
|
|
353
|
+
const firstWeekDay = startOfWeek(date, { weekStartsOn: 1 });
|
|
354
|
+
return Array.from({ length: 7 }, (_, i) => addDays(firstWeekDay, i));
|
|
355
|
+
}
|
|
356
|
+
generateWeeks(date) {
|
|
357
|
+
const startOfTheSelectedMonth = startOfMonth(date);
|
|
358
|
+
const endOfTheSelectedMonth = endOfMonth(date);
|
|
359
|
+
const startDate = startOfWeek(startOfTheSelectedMonth, { weekStartsOn: 1 });
|
|
360
|
+
const endDate = endOfWeek(endOfTheSelectedMonth);
|
|
361
|
+
const allWeeks = [];
|
|
362
|
+
let currentDate = startDate;
|
|
363
|
+
while (currentDate <= endDate) {
|
|
364
|
+
allWeeks.push(this.generateDaysForWeek(currentDate, date));
|
|
365
|
+
currentDate = addDays(currentDate, 7);
|
|
366
|
+
}
|
|
367
|
+
return allWeeks;
|
|
368
|
+
}
|
|
369
|
+
generateDaysForWeek(date, currentDate) {
|
|
370
|
+
return Array.from({ length: 7 }).map((_, i) => addDays(date, i), currentDate);
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
CalendarMonthService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: CalendarMonthService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
374
|
+
CalendarMonthService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: CalendarMonthService });
|
|
375
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: CalendarMonthService, decorators: [{
|
|
376
|
+
type: Injectable
|
|
377
|
+
}] });
|
|
378
|
+
|
|
379
|
+
class CalendarYearService {
|
|
380
|
+
constructor() {
|
|
381
|
+
this.config = injectCalendarConfig();
|
|
382
|
+
this.calendar = inject(CalendarService);
|
|
383
|
+
this.seasons$ = this.calendar.activeDate$.pipe(map((selectedDate) => this.generateSeasons(selectedDate)));
|
|
384
|
+
}
|
|
385
|
+
generateSeasons(date) {
|
|
386
|
+
const { itemsPerRow } = this.config.yearView;
|
|
387
|
+
const seasons = [];
|
|
388
|
+
const months = eachMonthOfInterval({
|
|
389
|
+
start: startOfYear(date),
|
|
390
|
+
end: endOfYear(date),
|
|
391
|
+
});
|
|
392
|
+
let index = 0;
|
|
393
|
+
while (index < months.length) {
|
|
394
|
+
seasons.push(months.slice(index, index + itemsPerRow));
|
|
395
|
+
index += itemsPerRow;
|
|
396
|
+
}
|
|
397
|
+
return seasons;
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
CalendarYearService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: CalendarYearService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
401
|
+
CalendarYearService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: CalendarYearService });
|
|
402
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: CalendarYearService, decorators: [{
|
|
403
|
+
type: Injectable
|
|
404
|
+
}] });
|
|
405
|
+
|
|
406
|
+
class CalendarYearsService {
|
|
407
|
+
constructor() {
|
|
408
|
+
this.config = injectCalendarConfig();
|
|
409
|
+
this.years$ = defer(() => of(this.generateYears()));
|
|
410
|
+
}
|
|
411
|
+
generateYears() {
|
|
412
|
+
const { itemsPerRow, padding } = this.config.yearsView;
|
|
413
|
+
const now = Date.now();
|
|
414
|
+
const startDate = startOfYear(addYears(now, -padding));
|
|
415
|
+
const startYear = getYear(startDate);
|
|
416
|
+
const endDate = startOfYear(addYears(now, padding));
|
|
417
|
+
const endYear = getYear(endDate);
|
|
418
|
+
const years = [];
|
|
419
|
+
const yearRows = [];
|
|
420
|
+
for (let i = startYear; i <= endYear; i++) {
|
|
421
|
+
years.push(setYear(startDate, i));
|
|
422
|
+
}
|
|
423
|
+
let index = 0;
|
|
424
|
+
while (index < years.length) {
|
|
425
|
+
yearRows.push(years.slice(index, index + itemsPerRow));
|
|
426
|
+
index += itemsPerRow;
|
|
427
|
+
}
|
|
428
|
+
return yearRows;
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
CalendarYearsService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: CalendarYearsService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
432
|
+
CalendarYearsService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: CalendarYearsService });
|
|
433
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: CalendarYearsService, decorators: [{
|
|
434
|
+
type: Injectable
|
|
442
435
|
}] });
|
|
443
436
|
|
|
444
437
|
let CalendarMonthComponent = class CalendarMonthComponent extends CalendarViewDirective {
|
|
445
438
|
constructor() {
|
|
446
439
|
super(...arguments);
|
|
447
440
|
this.calendarMonth = inject(CalendarMonthService);
|
|
448
|
-
this.
|
|
449
|
-
this.
|
|
441
|
+
this.nextView = CalendarView.Years;
|
|
442
|
+
this.currentView = CalendarView.Month;
|
|
450
443
|
this.selectedChange = new EventEmitter();
|
|
451
444
|
}
|
|
452
445
|
previousDay(event) {
|
|
@@ -475,13 +468,13 @@ let CalendarMonthComponent = class CalendarMonthComponent extends CalendarViewDi
|
|
|
475
468
|
}
|
|
476
469
|
};
|
|
477
470
|
CalendarMonthComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: CalendarMonthComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
478
|
-
CalendarMonthComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.9", type: CalendarMonthComponent, isStandalone: true, selector: "odx-calendar-month", outputs: { selectedChange: "selectedChange" }, providers: [CalendarMonthService], usesInheritance: true, ngImport: i0, template: "<table class=\"odx-calendar__table\" role=\"grid\" aria-describedby=\"odx-calendar\">\n <thead>\n <tr>\n <th colspan=\"7\">\n <odx-calendar-header
|
|
471
|
+
CalendarMonthComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.9", type: CalendarMonthComponent, isStandalone: true, selector: "odx-calendar-month", outputs: { selectedChange: "selectedChange" }, providers: [CalendarMonthService], usesInheritance: true, ngImport: i0, template: "<table class=\"odx-calendar__table\" role=\"grid\" aria-describedby=\"odx-calendar\">\n <thead>\n <tr>\n <th colspan=\"7\">\n <odx-calendar-header\n [calendarView]=\"currentView\"\n [activeDate]=\"activeDate\"\n [minDate]=\"minDate\"\n [maxDate]=\"maxDate\"\n (previous)=\"previousMonth($event)\"\n (next)=\"nextMonth($event)\"\n (changeView)=\"changeView()\"\n >\n {{ activeDate | odxDateLabel: config.monthYearLabel }}\n </odx-calendar-header>\n </th>\n </tr>\n\n <tr class=\"odx-calendar__weekdays\">\n <td *ngFor=\"let day of calendarMonth.weekDays$ | async\">\n {{ day | odxDateLabel: config.weekLabel }}\n </td>\n </tr>\n </thead>\n\n <tbody\n class=\"odx-calendar__body\"\n (keydown.ArrowLeft)=\"previousDay($event)\"\n (keydown.ArrowRight)=\"nextDay($event)\"\n (keydown.ArrowUp)=\"previousWeek($event)\"\n (keydown.ArrowDown)=\"nextWeek($event)\"\n (keydown.PageUp)=\"previousMonth($event)\"\n (keydown.PageDown)=\"nextMonth($event)\"\n >\n <tr *ngFor=\"let week of calendarMonth.weeks$ | async; trackBy: trackByIndex\">\n <td role=\"gridcell\" *ngFor=\"let day of week; trackBy: trackByIndex\">\n <button\n [disabled]=\"isDateDisabled(day)\"\n [odxCalendarCell]=\"day\"\n [odxCalendarCellActiveDate]=\"activeDate\"\n [odxCalendarCellCalendarView]=\"currentView\"\n [odxCalendarCellSelectedDate]=\"selectedDate\"\n (click)=\"selectDate(day)\"\n >\n {{ day | odxDateLabel: config.dayLabel }}\n </button>\n </td>\n </tr>\n </tbody>\n</table>\n", dependencies: [{ kind: "ngmodule", type: CoreModule }, { kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "pipe", type: i1.AsyncPipe, name: "async" }, { kind: "directive", type: i2.DisabledController, selector: "[disabled]", inputs: ["disabled"] }, { kind: "directive", type: CalendarCellDirective, selector: "[odxCalendarCell]", inputs: ["odxCalendarCell", "odxCalendarCellCalendarView", "odxCalendarCellActiveDate", "odxCalendarCellSelectedDate"] }, { kind: "component", type: CalendarHeaderComponent, selector: "odx-calendar-header", inputs: ["activeDate", "calendarView", "minDate", "maxDate"], outputs: ["previous", "next", "changeView"] }, { kind: "pipe", type: DateLabelPipe, name: "odxDateLabel" }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
479
472
|
CalendarMonthComponent = __decorate([
|
|
480
473
|
CSSComponent('calendar-month')
|
|
481
474
|
], CalendarMonthComponent);
|
|
482
475
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: CalendarMonthComponent, decorators: [{
|
|
483
476
|
type: Component,
|
|
484
|
-
args: [{ selector: 'odx-calendar-month', standalone: true, imports: [CoreModule, CalendarCellDirective, CalendarHeaderComponent, DateLabelPipe], changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, providers: [CalendarMonthService], template: "<table class=\"odx-calendar__table\" role=\"grid\" aria-describedby=\"odx-calendar\">\n <thead>\n <tr>\n <th colspan=\"7\">\n <odx-calendar-header
|
|
477
|
+
args: [{ selector: 'odx-calendar-month', standalone: true, imports: [CoreModule, CalendarCellDirective, CalendarHeaderComponent, DateLabelPipe], changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, providers: [CalendarMonthService], template: "<table class=\"odx-calendar__table\" role=\"grid\" aria-describedby=\"odx-calendar\">\n <thead>\n <tr>\n <th colspan=\"7\">\n <odx-calendar-header\n [calendarView]=\"currentView\"\n [activeDate]=\"activeDate\"\n [minDate]=\"minDate\"\n [maxDate]=\"maxDate\"\n (previous)=\"previousMonth($event)\"\n (next)=\"nextMonth($event)\"\n (changeView)=\"changeView()\"\n >\n {{ activeDate | odxDateLabel: config.monthYearLabel }}\n </odx-calendar-header>\n </th>\n </tr>\n\n <tr class=\"odx-calendar__weekdays\">\n <td *ngFor=\"let day of calendarMonth.weekDays$ | async\">\n {{ day | odxDateLabel: config.weekLabel }}\n </td>\n </tr>\n </thead>\n\n <tbody\n class=\"odx-calendar__body\"\n (keydown.ArrowLeft)=\"previousDay($event)\"\n (keydown.ArrowRight)=\"nextDay($event)\"\n (keydown.ArrowUp)=\"previousWeek($event)\"\n (keydown.ArrowDown)=\"nextWeek($event)\"\n (keydown.PageUp)=\"previousMonth($event)\"\n (keydown.PageDown)=\"nextMonth($event)\"\n >\n <tr *ngFor=\"let week of calendarMonth.weeks$ | async; trackBy: trackByIndex\">\n <td role=\"gridcell\" *ngFor=\"let day of week; trackBy: trackByIndex\">\n <button\n [disabled]=\"isDateDisabled(day)\"\n [odxCalendarCell]=\"day\"\n [odxCalendarCellActiveDate]=\"activeDate\"\n [odxCalendarCellCalendarView]=\"currentView\"\n [odxCalendarCellSelectedDate]=\"selectedDate\"\n (click)=\"selectDate(day)\"\n >\n {{ day | odxDateLabel: config.dayLabel }}\n </button>\n </td>\n </tr>\n </tbody>\n</table>\n" }]
|
|
485
478
|
}], propDecorators: { selectedChange: [{
|
|
486
479
|
type: Output
|
|
487
480
|
}] } });
|
|
@@ -490,8 +483,8 @@ let CalendarYearComponent = class CalendarYearComponent extends CalendarViewDire
|
|
|
490
483
|
constructor() {
|
|
491
484
|
super(...arguments);
|
|
492
485
|
this.calendarYear = inject(CalendarYearService);
|
|
493
|
-
this.
|
|
494
|
-
this.
|
|
486
|
+
this.nextView = CalendarView.Month;
|
|
487
|
+
this.currentView = CalendarView.Year;
|
|
495
488
|
}
|
|
496
489
|
previousMonth(event) {
|
|
497
490
|
this.updateActiveDate(event, subMonths(this.activeDate, 1));
|
|
@@ -514,19 +507,19 @@ let CalendarYearComponent = class CalendarYearComponent extends CalendarViewDire
|
|
|
514
507
|
selectDate(value) {
|
|
515
508
|
if (this.isDateDisabled(value))
|
|
516
509
|
return;
|
|
517
|
-
const date = setMonth(this.
|
|
510
|
+
const date = setMonth(this.activeDate, getMonth(value));
|
|
518
511
|
this.calendar.selectDate(date);
|
|
519
512
|
this.changeView();
|
|
520
513
|
}
|
|
521
514
|
};
|
|
522
515
|
CalendarYearComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: CalendarYearComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
523
|
-
CalendarYearComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.9", type: CalendarYearComponent, isStandalone: true, selector: "odx-calendar-year", providers: [CalendarYearService], usesInheritance: true, ngImport: i0, template: "<table class=\"odx-calendar__table\" role=\"grid\" aria-describedby=\"odx-calendar\">\n <thead>\n <tr>\n <th colspan=\"3\">\n <odx-calendar-header
|
|
516
|
+
CalendarYearComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.9", type: CalendarYearComponent, isStandalone: true, selector: "odx-calendar-year", providers: [CalendarYearService], usesInheritance: true, ngImport: i0, template: "<table class=\"odx-calendar__table\" role=\"grid\" aria-describedby=\"odx-calendar\">\n <thead>\n <tr>\n <th colspan=\"3\">\n <odx-calendar-header\n (previous)=\"previousYear($event)\"\n [calendarView]=\"currentView\"\n [activeDate]=\"activeDate\"\n [minDate]=\"minDate\"\n [maxDate]=\"maxDate\"\n (next)=\"nextYear($event)\"\n (changeView)=\"changeView()\"\n >\n {{ activeDate | odxDateLabel: config.yearLabel }}\n </odx-calendar-header>\n </th>\n </tr>\n </thead>\n\n <tbody\n class=\"odx-calendar__body\"\n (keydown.ArrowLeft)=\"previousMonth($event)\"\n (keydown.ArrowRight)=\"nextMonth($event)\"\n (keydown.ArrowUp)=\"previousSeason($event)\"\n (keydown.ArrowDown)=\"nextSeason($event)\"\n (keydown.PageDown)=\"nextYear($event)\"\n (keydown.PageUp)=\"previousYear($event)\"\n >\n <tr class=\"odx-calendar__season\" *ngFor=\"let season of calendarYear.seasons$ | async; trackBy: trackByIndex\">\n <td role=\"gridcell\" *ngFor=\"let month of season; trackBy: trackByIndex\">\n <button\n [disabled]=\"isDateDisabled(month)\"\n [odxCalendarCell]=\"month\"\n [odxCalendarCellActiveDate]=\"activeDate\"\n [odxCalendarCellCalendarView]=\"currentView\"\n [odxCalendarCellSelectedDate]=\"selectedDate\"\n (click)=\"selectDate(month)\"\n >\n {{ month | odxDateLabel: config.monthLabel }}\n </button>\n </td>\n </tr>\n </tbody>\n</table>\n", dependencies: [{ kind: "ngmodule", type: CoreModule }, { kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "pipe", type: i1.AsyncPipe, name: "async" }, { kind: "directive", type: i2.DisabledController, selector: "[disabled]", inputs: ["disabled"] }, { kind: "directive", type: CalendarCellDirective, selector: "[odxCalendarCell]", inputs: ["odxCalendarCell", "odxCalendarCellCalendarView", "odxCalendarCellActiveDate", "odxCalendarCellSelectedDate"] }, { kind: "component", type: CalendarHeaderComponent, selector: "odx-calendar-header", inputs: ["activeDate", "calendarView", "minDate", "maxDate"], outputs: ["previous", "next", "changeView"] }, { kind: "pipe", type: DateLabelPipe, name: "odxDateLabel" }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
524
517
|
CalendarYearComponent = __decorate([
|
|
525
518
|
CSSComponent('calendar-year')
|
|
526
519
|
], CalendarYearComponent);
|
|
527
520
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: CalendarYearComponent, decorators: [{
|
|
528
521
|
type: Component,
|
|
529
|
-
args: [{ selector: 'odx-calendar-year', standalone: true, imports: [CoreModule, CalendarCellDirective, CalendarHeaderComponent, DateLabelPipe], changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, providers: [CalendarYearService], template: "<table class=\"odx-calendar__table\" role=\"grid\" aria-describedby=\"odx-calendar\">\n <thead>\n <tr>\n <th colspan=\"3\">\n <odx-calendar-header
|
|
522
|
+
args: [{ selector: 'odx-calendar-year', standalone: true, imports: [CoreModule, CalendarCellDirective, CalendarHeaderComponent, DateLabelPipe], changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, providers: [CalendarYearService], template: "<table class=\"odx-calendar__table\" role=\"grid\" aria-describedby=\"odx-calendar\">\n <thead>\n <tr>\n <th colspan=\"3\">\n <odx-calendar-header\n (previous)=\"previousYear($event)\"\n [calendarView]=\"currentView\"\n [activeDate]=\"activeDate\"\n [minDate]=\"minDate\"\n [maxDate]=\"maxDate\"\n (next)=\"nextYear($event)\"\n (changeView)=\"changeView()\"\n >\n {{ activeDate | odxDateLabel: config.yearLabel }}\n </odx-calendar-header>\n </th>\n </tr>\n </thead>\n\n <tbody\n class=\"odx-calendar__body\"\n (keydown.ArrowLeft)=\"previousMonth($event)\"\n (keydown.ArrowRight)=\"nextMonth($event)\"\n (keydown.ArrowUp)=\"previousSeason($event)\"\n (keydown.ArrowDown)=\"nextSeason($event)\"\n (keydown.PageDown)=\"nextYear($event)\"\n (keydown.PageUp)=\"previousYear($event)\"\n >\n <tr class=\"odx-calendar__season\" *ngFor=\"let season of calendarYear.seasons$ | async; trackBy: trackByIndex\">\n <td role=\"gridcell\" *ngFor=\"let month of season; trackBy: trackByIndex\">\n <button\n [disabled]=\"isDateDisabled(month)\"\n [odxCalendarCell]=\"month\"\n [odxCalendarCellActiveDate]=\"activeDate\"\n [odxCalendarCellCalendarView]=\"currentView\"\n [odxCalendarCellSelectedDate]=\"selectedDate\"\n (click)=\"selectDate(month)\"\n >\n {{ month | odxDateLabel: config.monthLabel }}\n </button>\n </td>\n </tr>\n </tbody>\n</table>\n" }]
|
|
530
523
|
}] });
|
|
531
524
|
|
|
532
525
|
let CalendarYearsComponent = class CalendarYearsComponent extends CalendarViewDirective {
|
|
@@ -534,8 +527,8 @@ let CalendarYearsComponent = class CalendarYearsComponent extends CalendarViewDi
|
|
|
534
527
|
super(...arguments);
|
|
535
528
|
this.document = inject(DOCUMENT);
|
|
536
529
|
this.calendarYears = inject(CalendarYearsService);
|
|
537
|
-
this.
|
|
538
|
-
this.
|
|
530
|
+
this.nextView = CalendarView.Year;
|
|
531
|
+
this.currentView = CalendarView.Years;
|
|
539
532
|
}
|
|
540
533
|
ngAfterViewInit() {
|
|
541
534
|
deferFn(() => this.scrollCurrentYearIntoView());
|
|
@@ -555,7 +548,7 @@ let CalendarYearsComponent = class CalendarYearsComponent extends CalendarViewDi
|
|
|
555
548
|
selectDate(value) {
|
|
556
549
|
if (this.isDateDisabled(value))
|
|
557
550
|
return;
|
|
558
|
-
const date = setYear(this.
|
|
551
|
+
const date = setYear(this.activeDate, getYear(value));
|
|
559
552
|
this.calendar.selectDate(date);
|
|
560
553
|
this.changeView();
|
|
561
554
|
}
|
|
@@ -569,48 +562,40 @@ let CalendarYearsComponent = class CalendarYearsComponent extends CalendarViewDi
|
|
|
569
562
|
}
|
|
570
563
|
};
|
|
571
564
|
CalendarYearsComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: CalendarYearsComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
572
|
-
CalendarYearsComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.9", type: CalendarYearsComponent, isStandalone: true, selector: "odx-calendar-years", providers: [CalendarYearsService], usesInheritance: true, ngImport: i0, template: "<table class=\"odx-calendar__table\" role=\"grid\" aria-describedby=\"odx-calendar\">\n <thead aria-hidden=\"true\">\n <th></th>\n </thead>\n\n <tbody\n
|
|
565
|
+
CalendarYearsComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.9", type: CalendarYearsComponent, isStandalone: true, selector: "odx-calendar-years", providers: [CalendarYearsService], usesInheritance: true, ngImport: i0, template: "<table class=\"odx-calendar__table\" role=\"grid\" aria-describedby=\"odx-calendar\" *ngrxLet=\"calendar.activeDate$ as activeDate\">\n <thead aria-hidden=\"true\">\n <th></th>\n </thead>\n\n <tbody\n class=\"odx-calendar__body\"\n (keydown.ArrowLeft)=\"previousYear($event)\"\n (keydown.ArrowRight)=\"nextYear($event)\"\n (keydown.ArrowUp)=\"previousRow($event)\"\n (keydown.ArrowDown)=\"nextRow($event)\"\n >\n <tr class=\"odx-calendar__year-row\" *ngFor=\"let yearRow of calendarYears.years$ | async; trackBy: trackByIndex\">\n <td role=\"gridcell\" *ngFor=\"let year of yearRow; trackBy: trackByIndex\">\n <button\n [disabled]=\"isDateDisabled(year)\"\n [odxCalendarCell]=\"year\"\n [odxCalendarCellActiveDate]=\"activeDate\"\n [odxCalendarCellCalendarView]=\"currentView\"\n [odxCalendarCellSelectedDate]=\"calendar.selectedDate$ | async\"\n (click)=\"selectDate(year)\"\n >\n {{ year | odxDateLabel: config.yearLabel }}\n </button>\n </td>\n </tr>\n </tbody>\n</table>\n", dependencies: [{ kind: "ngmodule", type: CoreModule }, { kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "pipe", type: i1.AsyncPipe, name: "async" }, { kind: "directive", type: i2$1.LetDirective, selector: "[ngrxLet]", inputs: ["ngrxLet", "ngrxLetSuspenseTpl"] }, { kind: "directive", type: i2.DisabledController, selector: "[disabled]", inputs: ["disabled"] }, { kind: "directive", type: CalendarCellDirective, selector: "[odxCalendarCell]", inputs: ["odxCalendarCell", "odxCalendarCellCalendarView", "odxCalendarCellActiveDate", "odxCalendarCellSelectedDate"] }, { kind: "pipe", type: DateLabelPipe, name: "odxDateLabel" }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
573
566
|
CalendarYearsComponent = __decorate([
|
|
574
567
|
CSSComponent('calendar-years')
|
|
575
568
|
], CalendarYearsComponent);
|
|
576
569
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: CalendarYearsComponent, decorators: [{
|
|
577
570
|
type: Component,
|
|
578
|
-
args: [{ selector: 'odx-calendar-years', standalone: true, imports: [CoreModule, CalendarCellDirective, CalendarHeaderComponent, DateLabelPipe], changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, providers: [CalendarYearsService], template: "<table class=\"odx-calendar__table\" role=\"grid\" aria-describedby=\"odx-calendar\">\n <thead aria-hidden=\"true\">\n <th></th>\n </thead>\n\n <tbody\n
|
|
571
|
+
args: [{ selector: 'odx-calendar-years', standalone: true, imports: [CoreModule, CalendarCellDirective, CalendarHeaderComponent, DateLabelPipe], changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, providers: [CalendarYearsService], template: "<table class=\"odx-calendar__table\" role=\"grid\" aria-describedby=\"odx-calendar\" *ngrxLet=\"calendar.activeDate$ as activeDate\">\n <thead aria-hidden=\"true\">\n <th></th>\n </thead>\n\n <tbody\n class=\"odx-calendar__body\"\n (keydown.ArrowLeft)=\"previousYear($event)\"\n (keydown.ArrowRight)=\"nextYear($event)\"\n (keydown.ArrowUp)=\"previousRow($event)\"\n (keydown.ArrowDown)=\"nextRow($event)\"\n >\n <tr class=\"odx-calendar__year-row\" *ngFor=\"let yearRow of calendarYears.years$ | async; trackBy: trackByIndex\">\n <td role=\"gridcell\" *ngFor=\"let year of yearRow; trackBy: trackByIndex\">\n <button\n [disabled]=\"isDateDisabled(year)\"\n [odxCalendarCell]=\"year\"\n [odxCalendarCellActiveDate]=\"activeDate\"\n [odxCalendarCellCalendarView]=\"currentView\"\n [odxCalendarCellSelectedDate]=\"calendar.selectedDate$ | async\"\n (click)=\"selectDate(year)\"\n >\n {{ year | odxDateLabel: config.yearLabel }}\n </button>\n </td>\n </tr>\n </tbody>\n</table>\n" }]
|
|
579
572
|
}] });
|
|
580
573
|
|
|
581
574
|
let CalendarComponent = class CalendarComponent {
|
|
582
575
|
constructor() {
|
|
576
|
+
this.CalendarView = CalendarView;
|
|
583
577
|
this.calendar = inject(CalendarService);
|
|
584
578
|
this.element = injectElement();
|
|
585
|
-
this.
|
|
579
|
+
this.selectedDate = null;
|
|
586
580
|
this.minDate = null;
|
|
587
581
|
this.maxDate = null;
|
|
588
582
|
this.filterFn = null;
|
|
589
|
-
this.
|
|
590
|
-
}
|
|
591
|
-
set selectedDate(value) {
|
|
592
|
-
this.calendar.selectDate(value);
|
|
583
|
+
this.selectedDateChange = new EventEmitter();
|
|
593
584
|
}
|
|
594
585
|
ngOnChanges(changes) {
|
|
595
|
-
if (hasChanged(changes, '
|
|
596
|
-
this.calendar.
|
|
597
|
-
}
|
|
598
|
-
if (hasChanged(changes, 'maxDate', false)) {
|
|
599
|
-
this.calendar.maxDate = this.maxDate;
|
|
600
|
-
}
|
|
601
|
-
if (hasChanged(changes, 'filterFn', false)) {
|
|
602
|
-
this.calendar.filterFn = this.filterFn;
|
|
586
|
+
if (hasChanged(changes, 'selectedDate', false)) {
|
|
587
|
+
this.calendar.selectDate(this.selectedDate);
|
|
603
588
|
}
|
|
604
589
|
}
|
|
605
590
|
};
|
|
606
591
|
CalendarComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: CalendarComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
607
|
-
CalendarComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.9", type: CalendarComponent, isStandalone: true, selector: "odx-calendar", inputs: { selectedDate: "selectedDate", minDate: "minDate", maxDate: "maxDate", filterFn: "filterFn" }, outputs: {
|
|
592
|
+
CalendarComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.9", type: CalendarComponent, isStandalone: true, selector: "odx-calendar", inputs: { selectedDate: "selectedDate", minDate: "minDate", maxDate: "maxDate", filterFn: "filterFn" }, outputs: { selectedDateChange: "selectedDateChange" }, providers: [CalendarService], usesOnChanges: true, ngImport: i0, template: "<ng-template [ngrxLet]=\"{ activeDate: calendar.activeDate$, calendarView: calendar.calendarView$, selectedDate: calendar.selectedDate$ }\" let-vm>\n <ng-container [ngSwitch]=\"vm.calendarView\">\n <odx-calendar-year\n [activeDate]=\"vm.activeDate\"\n [selectedDate]=\"vm.selectedDate\"\n [minDate]=\"minDate\"\n [maxDate]=\"maxDate\"\n [filterFn]=\"filterFn\"\n *ngSwitchCase=\"CalendarView.Year\"\n ></odx-calendar-year>\n <odx-calendar-years\n [activeDate]=\"vm.activeDate\"\n [selectedDate]=\"vm.selectedDate\"\n [minDate]=\"minDate\"\n [maxDate]=\"maxDate\"\n [filterFn]=\"filterFn\"\n *ngSwitchCase=\"CalendarView.Years\"\n ></odx-calendar-years>\n <odx-calendar-month\n [activeDate]=\"vm.activeDate\"\n [selectedDate]=\"vm.selectedDate\"\n [minDate]=\"minDate\"\n [maxDate]=\"maxDate\"\n [filterFn]=\"filterFn\"\n (selectedChange)=\"selectedDateChange.emit($event)\"\n *ngSwitchDefault\n ></odx-calendar-month>\n </ng-container>\n</ng-template>\n", dependencies: [{ kind: "ngmodule", type: CoreModule }, { kind: "directive", type: i1.NgSwitch, selector: "[ngSwitch]", inputs: ["ngSwitch"] }, { kind: "directive", type: i1.NgSwitchCase, selector: "[ngSwitchCase]", inputs: ["ngSwitchCase"] }, { kind: "directive", type: i1.NgSwitchDefault, selector: "[ngSwitchDefault]" }, { kind: "directive", type: i2$1.LetDirective, selector: "[ngrxLet]", inputs: ["ngrxLet", "ngrxLetSuspenseTpl"] }, { kind: "ngmodule", type: A11yModule }, { kind: "component", type: CalendarMonthComponent, selector: "odx-calendar-month", outputs: ["selectedChange"] }, { kind: "component", type: CalendarYearComponent, selector: "odx-calendar-year" }, { kind: "component", type: CalendarYearsComponent, selector: "odx-calendar-years" }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
608
593
|
CalendarComponent = __decorate([
|
|
609
594
|
CSSComponent('calendar')
|
|
610
595
|
], CalendarComponent);
|
|
611
596
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: CalendarComponent, decorators: [{
|
|
612
597
|
type: Component,
|
|
613
|
-
args: [{ selector: 'odx-calendar', standalone: true, imports: [CoreModule, A11yModule, CalendarMonthComponent, CalendarYearComponent, CalendarYearsComponent], changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, providers: [CalendarService], template: "<ng-
|
|
598
|
+
args: [{ selector: 'odx-calendar', standalone: true, imports: [CoreModule, A11yModule, CalendarMonthComponent, CalendarYearComponent, CalendarYearsComponent], changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, providers: [CalendarService], template: "<ng-template [ngrxLet]=\"{ activeDate: calendar.activeDate$, calendarView: calendar.calendarView$, selectedDate: calendar.selectedDate$ }\" let-vm>\n <ng-container [ngSwitch]=\"vm.calendarView\">\n <odx-calendar-year\n [activeDate]=\"vm.activeDate\"\n [selectedDate]=\"vm.selectedDate\"\n [minDate]=\"minDate\"\n [maxDate]=\"maxDate\"\n [filterFn]=\"filterFn\"\n *ngSwitchCase=\"CalendarView.Year\"\n ></odx-calendar-year>\n <odx-calendar-years\n [activeDate]=\"vm.activeDate\"\n [selectedDate]=\"vm.selectedDate\"\n [minDate]=\"minDate\"\n [maxDate]=\"maxDate\"\n [filterFn]=\"filterFn\"\n *ngSwitchCase=\"CalendarView.Years\"\n ></odx-calendar-years>\n <odx-calendar-month\n [activeDate]=\"vm.activeDate\"\n [selectedDate]=\"vm.selectedDate\"\n [minDate]=\"minDate\"\n [maxDate]=\"maxDate\"\n [filterFn]=\"filterFn\"\n (selectedChange)=\"selectedDateChange.emit($event)\"\n *ngSwitchDefault\n ></odx-calendar-month>\n </ng-container>\n</ng-template>\n" }]
|
|
614
599
|
}], propDecorators: { selectedDate: [{
|
|
615
600
|
type: Input
|
|
616
601
|
}], minDate: [{
|
|
@@ -619,7 +604,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
|
|
|
619
604
|
type: Input
|
|
620
605
|
}], filterFn: [{
|
|
621
606
|
type: Input
|
|
622
|
-
}],
|
|
607
|
+
}], selectedDateChange: [{
|
|
623
608
|
type: Output
|
|
624
609
|
}] } });
|
|
625
610
|
|
|
@@ -627,5 +612,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
|
|
|
627
612
|
* Generated bundle index. Do not edit.
|
|
628
613
|
*/
|
|
629
614
|
|
|
630
|
-
export { CalendarComponent, CalendarConfig, CalendarDefaultConfig,
|
|
615
|
+
export { CalendarCellDirective, CalendarComponent, CalendarConfig, CalendarDefaultConfig, CalendarHeaderComponent, CalendarMonthComponent, CalendarMonthService, CalendarService, CalendarView, CalendarViewDirective, CalendarYearComponent, CalendarYearService, CalendarYearsComponent, CalendarYearsService, DateLabelPipe, checkIdenticalDate, getA11yLabel, injectCalendarConfig, isDateDisabled, parseDate, provideCalendarConfig, validateMaxDate, validateMinDate, validateNextDateSet, validatePreviousDateSet };
|
|
631
616
|
//# sourceMappingURL=odx-angular-components-calendar.mjs.map
|