@imihai/angular-datetime-picker 22.0.0 → 22.0.6
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/assets/style/picker.min.css +1 -0
- package/fesm2022/imihai-angular-datetime-picker.mjs +5843 -0
- package/fesm2022/imihai-angular-datetime-picker.mjs.map +1 -0
- package/imihai-angular-datetime-picker-22.0.6.tgz +0 -0
- package/package.json +34 -77
- package/types/imihai-angular-datetime-picker.d.ts +2193 -0
- package/.browserslistrc +0 -9
- package/.editorconfig +0 -13
- package/.eslintrc.js +0 -208
- package/.github/workflows/ci_test.yml +0 -35
- package/.prettierrc +0 -2
- package/.travis.yml +0 -16
- package/angular.json +0 -221
- package/e2e/protractor.conf.js +0 -28
- package/e2e/src/app.e2e-spec.ts +0 -14
- package/e2e/src/app.po.ts +0 -11
- package/e2e/tsconfig.e2e.json +0 -13
- package/projects/picker/karma.conf.js +0 -62
- package/projects/picker/ng-package.json +0 -7
- package/projects/picker/package.json +0 -23
- package/projects/picker/src/lib/date-time/adapter/date-time-adapter.class.ts +0 -313
- package/projects/picker/src/lib/date-time/adapter/date-time-format.class.ts +0 -18
- package/projects/picker/src/lib/date-time/adapter/luxon-date-time-adapter.class.ts +0 -307
- package/projects/picker/src/lib/date-time/adapter/luxon-date-time-format.class.ts +0 -11
- package/projects/picker/src/lib/date-time/adapter/luxon-date-time.module.ts +0 -31
- package/projects/picker/src/lib/date-time/adapter/unix-timestamp-adapter/unix-timestamp-date-time-adapter.class.ts +0 -356
- package/projects/picker/src/lib/date-time/adapter/unix-timestamp-adapter/unix-timestamp-date-time-format.class.ts +0 -14
- package/projects/picker/src/lib/date-time/adapter/unix-timestamp-adapter/unix-timestamp-date-time.module.ts +0 -26
- package/projects/picker/src/lib/date-time/calendar-body.component.html +0 -38
- package/projects/picker/src/lib/date-time/calendar-body.component.scss +0 -0
- package/projects/picker/src/lib/date-time/calendar-body.component.spec.ts +0 -120
- package/projects/picker/src/lib/date-time/calendar-body.component.ts +0 -190
- package/projects/picker/src/lib/date-time/calendar-month-view.component.html +0 -47
- package/projects/picker/src/lib/date-time/calendar-month-view.component.scss +0 -16
- package/projects/picker/src/lib/date-time/calendar-month-view.component.spec.ts +0 -394
- package/projects/picker/src/lib/date-time/calendar-month-view.component.ts +0 -705
- package/projects/picker/src/lib/date-time/calendar-multi-year-view.component.html +0 -44
- package/projects/picker/src/lib/date-time/calendar-multi-year-view.component.scss +0 -0
- package/projects/picker/src/lib/date-time/calendar-multi-year-view.component.spec.ts +0 -343
- package/projects/picker/src/lib/date-time/calendar-multi-year-view.component.ts +0 -465
- package/projects/picker/src/lib/date-time/calendar-year-view.component.html +0 -16
- package/projects/picker/src/lib/date-time/calendar-year-view.component.scss +0 -0
- package/projects/picker/src/lib/date-time/calendar-year-view.component.spec.ts +0 -381
- package/projects/picker/src/lib/date-time/calendar-year-view.component.ts +0 -549
- package/projects/picker/src/lib/date-time/calendar.component.html +0 -169
- package/projects/picker/src/lib/date-time/calendar.component.scss +0 -0
- package/projects/picker/src/lib/date-time/calendar.component.spec.ts +0 -592
- package/projects/picker/src/lib/date-time/calendar.component.ts +0 -496
- package/projects/picker/src/lib/date-time/date-time-inline.component.html +0 -1
- package/projects/picker/src/lib/date-time/date-time-inline.component.scss +0 -4
- package/projects/picker/src/lib/date-time/date-time-inline.component.ts +0 -365
- package/projects/picker/src/lib/date-time/date-time-picker-animation-event.ts +0 -4
- package/projects/picker/src/lib/date-time/date-time-picker-container.component.html +0 -126
- package/projects/picker/src/lib/date-time/date-time-picker-container.component.scss +0 -0
- package/projects/picker/src/lib/date-time/date-time-picker-container.component.ts +0 -631
- package/projects/picker/src/lib/date-time/date-time-picker-input.directive.ts +0 -851
- package/projects/picker/src/lib/date-time/date-time-picker-intl.service.ts +0 -76
- package/projects/picker/src/lib/date-time/date-time-picker-trigger.directive.ts +0 -88
- package/projects/picker/src/lib/date-time/date-time-picker.component.html +0 -0
- package/projects/picker/src/lib/date-time/date-time-picker.component.scss +0 -0
- package/projects/picker/src/lib/date-time/date-time-picker.component.spec.ts +0 -2648
- package/projects/picker/src/lib/date-time/date-time-picker.component.ts +0 -731
- package/projects/picker/src/lib/date-time/date-time.class.ts +0 -256
- package/projects/picker/src/lib/date-time/date-time.module.ts +0 -61
- package/projects/picker/src/lib/date-time/numberedFixLen.pipe.ts +0 -28
- package/projects/picker/src/lib/date-time/options-provider.ts +0 -44
- package/projects/picker/src/lib/date-time/timer-box.component.html +0 -79
- package/projects/picker/src/lib/date-time/timer-box.component.scss +0 -0
- package/projects/picker/src/lib/date-time/timer-box.component.ts +0 -175
- package/projects/picker/src/lib/date-time/timer.component.html +0 -58
- package/projects/picker/src/lib/date-time/timer.component.scss +0 -0
- package/projects/picker/src/lib/date-time/timer.component.spec.ts +0 -399
- package/projects/picker/src/lib/date-time/timer.component.ts +0 -371
- package/projects/picker/src/lib/dialog/dialog-config.class.ts +0 -220
- package/projects/picker/src/lib/dialog/dialog-container.component.html +0 -1
- package/projects/picker/src/lib/dialog/dialog-container.component.scss +0 -0
- package/projects/picker/src/lib/dialog/dialog-container.component.ts +0 -231
- package/projects/picker/src/lib/dialog/dialog-ref.class.ts +0 -178
- package/projects/picker/src/lib/dialog/dialog.module.ts +0 -25
- package/projects/picker/src/lib/dialog/dialog.service.ts +0 -353
- package/projects/picker/src/lib/utils/array.utils.ts +0 -12
- package/projects/picker/src/lib/utils/constants.ts +0 -59
- package/projects/picker/src/lib/utils/date.utils.ts +0 -97
- package/projects/picker/src/lib/utils/index.ts +0 -5
- package/projects/picker/src/lib/utils/object.utils.ts +0 -29
- package/projects/picker/src/public_api.ts +0 -56
- package/projects/picker/src/sass/picker.scss +0 -743
- package/projects/picker/src/test-helpers.ts +0 -125
- package/projects/picker/src/test.ts +0 -52
- package/projects/picker/tsconfig.lib.json +0 -19
- package/projects/picker/tsconfig.lib.prod.json +0 -7
- package/projects/picker/tsconfig.spec.json +0 -17
- package/projects/picker/tslint.json +0 -8
- package/src/app/app.component.html +0 -77
- package/src/app/app.component.scss +0 -32
- package/src/app/app.component.spec.ts +0 -16
- package/src/app/app.component.ts +0 -35
- package/src/assets/.gitkeep +0 -0
- package/src/environments/environment.prod.ts +0 -3
- package/src/environments/environment.ts +0 -16
- package/src/favicon.ico +0 -0
- package/src/index.html +0 -14
- package/src/karma.conf.js +0 -31
- package/src/main.ts +0 -16
- package/src/polyfills.ts +0 -53
- package/src/styles.scss +0 -7
- package/src/test.ts +0 -50
- package/src/tsconfig.app.json +0 -16
- package/src/tsconfig.spec.json +0 -18
- package/src/tslint.json +0 -17
- package/tsconfig.base.json +0 -31
- package/tsconfig.json +0 -30
- package/tslint.json +0 -130
|
@@ -1,465 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* calendar-multi-year-view.component
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
AfterContentInit,
|
|
7
|
-
ChangeDetectionStrategy, ChangeDetectorRef,
|
|
8
|
-
Component,
|
|
9
|
-
EventEmitter,
|
|
10
|
-
Inject,
|
|
11
|
-
Input,
|
|
12
|
-
OnInit,
|
|
13
|
-
Optional,
|
|
14
|
-
Output,
|
|
15
|
-
ViewChild
|
|
16
|
-
} from '@angular/core';
|
|
17
|
-
import { DateTimeAdapter } from './adapter/date-time-adapter.class';
|
|
18
|
-
import { CalendarCell, OwlCalendarBodyComponent } from './calendar-body.component';
|
|
19
|
-
import { SelectMode } from './date-time.class';
|
|
20
|
-
import {
|
|
21
|
-
DOWN_ARROW,
|
|
22
|
-
END,
|
|
23
|
-
ENTER,
|
|
24
|
-
HOME,
|
|
25
|
-
LEFT_ARROW,
|
|
26
|
-
PAGE_DOWN,
|
|
27
|
-
PAGE_UP,
|
|
28
|
-
RIGHT_ARROW,
|
|
29
|
-
UP_ARROW
|
|
30
|
-
} from '@angular/cdk/keycodes';
|
|
31
|
-
import { OwlDateTimeIntl } from './date-time-picker-intl.service';
|
|
32
|
-
import { OptionsTokens, Options } from './options-provider';
|
|
33
|
-
|
|
34
|
-
@Component({
|
|
35
|
-
selector: 'owl-date-time-multi-year-view',
|
|
36
|
-
templateUrl: './calendar-multi-year-view.component.html',
|
|
37
|
-
styleUrls: ['./calendar-multi-year-view.component.scss'],
|
|
38
|
-
host: {
|
|
39
|
-
'[class.owl-dt-calendar-view]': 'owlDTCalendarView',
|
|
40
|
-
'[class.owl-dt-calendar-multi-year-view]': 'owlDTCalendarMultiYearView'
|
|
41
|
-
},
|
|
42
|
-
standalone: false,
|
|
43
|
-
preserveWhitespaces: false,
|
|
44
|
-
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
45
|
-
})
|
|
46
|
-
|
|
47
|
-
export class OwlMultiYearViewComponent<T> implements OnInit, AfterContentInit {
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* The select mode of the picker;
|
|
51
|
-
* */
|
|
52
|
-
private _selectMode: SelectMode = 'single';
|
|
53
|
-
@Input()
|
|
54
|
-
get selectMode(): SelectMode {
|
|
55
|
-
return this._selectMode;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
set selectMode( val: SelectMode ) {
|
|
59
|
-
this._selectMode = val;
|
|
60
|
-
if (this.initiated) {
|
|
61
|
-
this.setSelectedYears();
|
|
62
|
-
this.cdRef.markForCheck();
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/** The currently selected date. */
|
|
67
|
-
private _selected: T | null;
|
|
68
|
-
@Input()
|
|
69
|
-
get selected(): T | null {
|
|
70
|
-
return this._selected;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
set selected( value: T | null ) {
|
|
74
|
-
const oldSelected = this._selected;
|
|
75
|
-
value = this.dateTimeAdapter.deserialize(value);
|
|
76
|
-
this._selected = this.getValidDate(value);
|
|
77
|
-
|
|
78
|
-
if (!this.dateTimeAdapter.isSameDay(oldSelected, this._selected)) {
|
|
79
|
-
this.setSelectedYears();
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
private _selecteds: T[] = [];
|
|
84
|
-
@Input()
|
|
85
|
-
get selecteds(): T[] {
|
|
86
|
-
return this._selecteds;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
set selecteds( values: T[] ) {
|
|
90
|
-
this._selecteds = values.map(( v ) => {
|
|
91
|
-
v = this.dateTimeAdapter.deserialize(v);
|
|
92
|
-
return this.getValidDate(v);
|
|
93
|
-
});
|
|
94
|
-
this.setSelectedYears();
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
private _pickerMoment: T | null;
|
|
98
|
-
@Input()
|
|
99
|
-
get pickerMoment() {
|
|
100
|
-
return this._pickerMoment;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
set pickerMoment( value: T ) {
|
|
104
|
-
const oldMoment = this._pickerMoment;
|
|
105
|
-
value = this.dateTimeAdapter.deserialize(value);
|
|
106
|
-
this._pickerMoment = this.getValidDate(value) || this.dateTimeAdapter.now();
|
|
107
|
-
|
|
108
|
-
if (oldMoment && this._pickerMoment &&
|
|
109
|
-
!this.isSameYearList(oldMoment, this._pickerMoment)) {
|
|
110
|
-
this.generateYearList();
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* A function used to filter which dates are selectable
|
|
116
|
-
* */
|
|
117
|
-
private _dateFilter: ( date: T ) => boolean;
|
|
118
|
-
@Input()
|
|
119
|
-
get dateFilter() {
|
|
120
|
-
return this._dateFilter;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
set dateFilter( filter: ( date: T ) => boolean ) {
|
|
124
|
-
this._dateFilter = filter;
|
|
125
|
-
if (this.initiated) {
|
|
126
|
-
this.generateYearList();
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
/** The minimum selectable date. */
|
|
131
|
-
private _minDate: T | null;
|
|
132
|
-
@Input()
|
|
133
|
-
get minDate(): T | null {
|
|
134
|
-
return this._minDate;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
set minDate( value: T | null ) {
|
|
138
|
-
value = this.dateTimeAdapter.deserialize(value);
|
|
139
|
-
this._minDate = this.getValidDate(value);
|
|
140
|
-
if (this.initiated) {
|
|
141
|
-
this.generateYearList();
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
/** The maximum selectable date. */
|
|
146
|
-
private _maxDate: T | null;
|
|
147
|
-
@Input()
|
|
148
|
-
get maxDate(): T | null {
|
|
149
|
-
return this._maxDate;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
set maxDate( value: T | null ) {
|
|
153
|
-
value = this.dateTimeAdapter.deserialize(value);
|
|
154
|
-
this._maxDate = this.getValidDate(value);
|
|
155
|
-
if (this.initiated) {
|
|
156
|
-
this.generateYearList();
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
private _todayYear: number;
|
|
161
|
-
get todayYear(): number {
|
|
162
|
-
return this._todayYear;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
private _years: CalendarCell[][];
|
|
166
|
-
get years() {
|
|
167
|
-
return this._years;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
private _selectedYears: number[];
|
|
171
|
-
get selectedYears(): number[] {
|
|
172
|
-
return this._selectedYears;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
private initiated = false;
|
|
176
|
-
|
|
177
|
-
get isInSingleMode(): boolean {
|
|
178
|
-
return this.selectMode === 'single';
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
get isInRangeMode(): boolean {
|
|
182
|
-
return this.selectMode === 'range' || this.selectMode === 'rangeFrom'
|
|
183
|
-
|| this.selectMode === 'rangeTo';
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
get activeCell(): number {
|
|
187
|
-
if (this._pickerMoment) {
|
|
188
|
-
return this.dateTimeAdapter.getYear(this._pickerMoment) % (this.options.yearsPerRow * this.options.yearRows);
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
get tableHeader(): string {
|
|
193
|
-
if (this._years && this._years.length > 0) {
|
|
194
|
-
return `${this._years[0][0].displayValue} - ${this._years[this.options.yearRows - 1][this.options.yearsPerRow - 1].displayValue}`;
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
get prevButtonLabel(): string {
|
|
199
|
-
return this.pickerIntl.prevMultiYearLabel;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
get nextButtonLabel(): string {
|
|
203
|
-
return this.pickerIntl.nextMultiYearLabel;
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
/**
|
|
207
|
-
* Callback to invoke when a new month is selected
|
|
208
|
-
* */
|
|
209
|
-
@Output() readonly change = new EventEmitter<T>();
|
|
210
|
-
|
|
211
|
-
/**
|
|
212
|
-
* Emits the selected year. This doesn't imply a change on the selected date
|
|
213
|
-
* */
|
|
214
|
-
@Output() readonly yearSelected = new EventEmitter<T>();
|
|
215
|
-
|
|
216
|
-
/** Emits when any date is activated. */
|
|
217
|
-
@Output() readonly pickerMomentChange: EventEmitter<T> = new EventEmitter<T>();
|
|
218
|
-
|
|
219
|
-
/** Emits when use keyboard enter to select a calendar cell */
|
|
220
|
-
@Output() readonly keyboardEnter: EventEmitter<any> = new EventEmitter<any>();
|
|
221
|
-
|
|
222
|
-
/** The body of calendar table */
|
|
223
|
-
@ViewChild(OwlCalendarBodyComponent, { static: true }) calendarBodyElm: OwlCalendarBodyComponent;
|
|
224
|
-
|
|
225
|
-
get owlDTCalendarView(): boolean {
|
|
226
|
-
return true;
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
get owlDTCalendarMultiYearView(): boolean {
|
|
230
|
-
return true;
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
constructor( private cdRef: ChangeDetectorRef,
|
|
234
|
-
private pickerIntl: OwlDateTimeIntl,
|
|
235
|
-
@Optional() private dateTimeAdapter: DateTimeAdapter<T>,
|
|
236
|
-
@Inject(OptionsTokens.multiYear) private options: any) {
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
public ngOnInit() {
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
public ngAfterContentInit(): void {
|
|
243
|
-
this._todayYear = this.dateTimeAdapter.getYear(this.dateTimeAdapter.now());
|
|
244
|
-
this.generateYearList();
|
|
245
|
-
this.initiated = true;
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
/**
|
|
249
|
-
* Handle a calendarCell selected
|
|
250
|
-
*/
|
|
251
|
-
public selectCalendarCell( cell: CalendarCell ): void {
|
|
252
|
-
this.selectYear(cell.value);
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
private selectYear( year: number ): void {
|
|
256
|
-
this.yearSelected.emit(this.dateTimeAdapter.createDate(year, this.dateTimeAdapter.firstMonthOfTheYear, 1));
|
|
257
|
-
const firstDateOfMonth = this.dateTimeAdapter.createDate(
|
|
258
|
-
year,
|
|
259
|
-
this.dateTimeAdapter.getMonth(this.pickerMoment),
|
|
260
|
-
1
|
|
261
|
-
);
|
|
262
|
-
const daysInMonth = this.dateTimeAdapter.getNumDaysInMonth(firstDateOfMonth);
|
|
263
|
-
const selected = this.dateTimeAdapter.createDate(
|
|
264
|
-
year,
|
|
265
|
-
this.dateTimeAdapter.getMonth(this.pickerMoment),
|
|
266
|
-
Math.min(daysInMonth, this.dateTimeAdapter.getDate(this.pickerMoment)),
|
|
267
|
-
this.dateTimeAdapter.getHours(this.pickerMoment),
|
|
268
|
-
this.dateTimeAdapter.getMinutes(this.pickerMoment),
|
|
269
|
-
this.dateTimeAdapter.getSeconds(this.pickerMoment),
|
|
270
|
-
);
|
|
271
|
-
|
|
272
|
-
this.change.emit(selected);
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
/**
|
|
276
|
-
* Generate the previous year list
|
|
277
|
-
* */
|
|
278
|
-
public prevYearList( event: any ): void {
|
|
279
|
-
this._pickerMoment = this.dateTimeAdapter.addCalendarYears(this.pickerMoment, -1 * this.options.yearsPerRow * this.options.yearRows);
|
|
280
|
-
this.generateYearList();
|
|
281
|
-
event.preventDefault();
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
/**
|
|
285
|
-
* Generate the next year list
|
|
286
|
-
* */
|
|
287
|
-
public nextYearList( event: any ): void {
|
|
288
|
-
this._pickerMoment = this.dateTimeAdapter.addCalendarYears(this.pickerMoment, this.options.yearsPerRow * this.options.yearRows);
|
|
289
|
-
this.generateYearList();
|
|
290
|
-
event.preventDefault();
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
public generateYearList(): void {
|
|
294
|
-
this._years = [];
|
|
295
|
-
|
|
296
|
-
const pickerMomentYear = this.dateTimeAdapter.getYear(this._pickerMoment);
|
|
297
|
-
const offset = pickerMomentYear % (this.options.yearsPerRow * this.options.yearRows);
|
|
298
|
-
|
|
299
|
-
for (let i = 0; i < this.options.yearRows; i++) {
|
|
300
|
-
const row = [];
|
|
301
|
-
|
|
302
|
-
for (let j = 0; j < this.options.yearsPerRow; j++) {
|
|
303
|
-
const year = pickerMomentYear - offset + (j + i * this.options.yearsPerRow);
|
|
304
|
-
const yearCell = this.createYearCell(year);
|
|
305
|
-
row.push(yearCell);
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
this._years.push(row);
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
return;
|
|
312
|
-
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
/** Whether the previous period button is enabled. */
|
|
316
|
-
public previousEnabled(): boolean {
|
|
317
|
-
if (!this.minDate) {
|
|
318
|
-
return true;
|
|
319
|
-
}
|
|
320
|
-
return !this.minDate || !this.isSameYearList(this._pickerMoment, this.minDate);
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
/** Whether the next period button is enabled. */
|
|
324
|
-
public nextEnabled(): boolean {
|
|
325
|
-
return !this.maxDate || !this.isSameYearList(this._pickerMoment, this.maxDate);
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
public handleCalendarKeydown( event: KeyboardEvent ): void {
|
|
329
|
-
let moment;
|
|
330
|
-
switch (event.keyCode) {
|
|
331
|
-
// minus 1 year
|
|
332
|
-
case LEFT_ARROW:
|
|
333
|
-
moment = this.dateTimeAdapter.addCalendarYears(this._pickerMoment, -1);
|
|
334
|
-
this.pickerMomentChange.emit(moment);
|
|
335
|
-
break;
|
|
336
|
-
|
|
337
|
-
// add 1 year
|
|
338
|
-
case RIGHT_ARROW:
|
|
339
|
-
moment = this.dateTimeAdapter.addCalendarYears(this._pickerMoment, 1);
|
|
340
|
-
this.pickerMomentChange.emit(moment);
|
|
341
|
-
break;
|
|
342
|
-
|
|
343
|
-
// minus 3 years
|
|
344
|
-
case UP_ARROW:
|
|
345
|
-
moment = this.dateTimeAdapter.addCalendarYears(this._pickerMoment, -1 * this.options.yearsPerRow);
|
|
346
|
-
this.pickerMomentChange.emit(moment);
|
|
347
|
-
break;
|
|
348
|
-
|
|
349
|
-
// add 3 years
|
|
350
|
-
case DOWN_ARROW:
|
|
351
|
-
moment = this.dateTimeAdapter.addCalendarYears(this._pickerMoment, this.options.yearsPerRow);
|
|
352
|
-
this.pickerMomentChange.emit(moment);
|
|
353
|
-
break;
|
|
354
|
-
|
|
355
|
-
// go to the first year of the year page
|
|
356
|
-
case HOME:
|
|
357
|
-
moment = this.dateTimeAdapter.addCalendarYears(this._pickerMoment,
|
|
358
|
-
-this.dateTimeAdapter.getYear(this._pickerMoment) % (this.options.yearsPerRow * this.options.yearRows));
|
|
359
|
-
this.pickerMomentChange.emit(moment);
|
|
360
|
-
break;
|
|
361
|
-
|
|
362
|
-
// go to the last year of the year page
|
|
363
|
-
case END:
|
|
364
|
-
moment = this.dateTimeAdapter.addCalendarYears(this._pickerMoment,
|
|
365
|
-
(this.options.yearsPerRow * this.options.yearRows) - this.dateTimeAdapter.getYear(this._pickerMoment) % (this.options.yearsPerRow * this.options.yearRows) - 1);
|
|
366
|
-
this.pickerMomentChange.emit(moment);
|
|
367
|
-
break;
|
|
368
|
-
|
|
369
|
-
// minus 1 year page (or 10 year pages)
|
|
370
|
-
case PAGE_UP:
|
|
371
|
-
moment = this.dateTimeAdapter.addCalendarYears(this.pickerMoment, event.altKey ? -10 * (this.options.yearsPerRow * this.options.yearRows) : -1 * (this.options.yearsPerRow * this.options.yearRows));
|
|
372
|
-
this.pickerMomentChange.emit(moment);
|
|
373
|
-
break;
|
|
374
|
-
|
|
375
|
-
// add 1 year page (or 10 year pages)
|
|
376
|
-
case PAGE_DOWN:
|
|
377
|
-
moment = this.dateTimeAdapter.addCalendarYears(this.pickerMoment, event.altKey ? 10 * (this.options.yearsPerRow * this.options.yearRows) : (this.options.yearsPerRow * this.options.yearRows));
|
|
378
|
-
this.pickerMomentChange.emit(moment);
|
|
379
|
-
break;
|
|
380
|
-
|
|
381
|
-
case ENTER:
|
|
382
|
-
this.selectYear(this.dateTimeAdapter.getYear(this._pickerMoment));
|
|
383
|
-
this.keyboardEnter.emit();
|
|
384
|
-
break;
|
|
385
|
-
|
|
386
|
-
default:
|
|
387
|
-
return;
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
this.focusActiveCell();
|
|
391
|
-
event.preventDefault();
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
/**
|
|
395
|
-
* Creates an CalendarCell for the given year.
|
|
396
|
-
*/
|
|
397
|
-
private createYearCell( year: number ): CalendarCell {
|
|
398
|
-
const startDateOfYear = this.dateTimeAdapter.createDate(year, this.dateTimeAdapter.firstMonthOfTheYear, 1);
|
|
399
|
-
const ariaLabel = this.dateTimeAdapter.getYearName(startDateOfYear);
|
|
400
|
-
const cellClass = 'owl-dt-year-' + year;
|
|
401
|
-
return new CalendarCell(year, year.toString(), ariaLabel, this.isYearEnabled(year), false, cellClass);
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
private setSelectedYears(): void {
|
|
405
|
-
|
|
406
|
-
this._selectedYears = [];
|
|
407
|
-
|
|
408
|
-
if (this.isInSingleMode && this.selected) {
|
|
409
|
-
this._selectedYears[0] = this.dateTimeAdapter.getYear(this.selected);
|
|
410
|
-
}
|
|
411
|
-
|
|
412
|
-
if (this.isInRangeMode && this.selecteds) {
|
|
413
|
-
this._selectedYears = this.selecteds.map(( selected ) => {
|
|
414
|
-
if (this.dateTimeAdapter.isValid(selected)) {
|
|
415
|
-
return this.dateTimeAdapter.getYear(selected);
|
|
416
|
-
} else {
|
|
417
|
-
return null;
|
|
418
|
-
}
|
|
419
|
-
});
|
|
420
|
-
}
|
|
421
|
-
}
|
|
422
|
-
|
|
423
|
-
/** Whether the given year is enabled. */
|
|
424
|
-
private isYearEnabled( year: number ) {
|
|
425
|
-
// disable if the year is greater than maxDate lower than minDate
|
|
426
|
-
if (year === undefined || year === null ||
|
|
427
|
-
(this.maxDate && year > this.dateTimeAdapter.getYear(this.maxDate)) ||
|
|
428
|
-
(this.minDate && year < this.dateTimeAdapter.getYear(this.minDate))) {
|
|
429
|
-
return false;
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
// enable if it reaches here and there's no filter defined
|
|
433
|
-
if (!this.dateFilter) {
|
|
434
|
-
return true;
|
|
435
|
-
}
|
|
436
|
-
|
|
437
|
-
const firstOfYear = this.dateTimeAdapter.createDate(year, this.dateTimeAdapter.firstMonthOfTheYear, 1);
|
|
438
|
-
|
|
439
|
-
// If any date in the year is enabled count the year as enabled.
|
|
440
|
-
for (let date = firstOfYear; this.dateTimeAdapter.getYear(date) === year;
|
|
441
|
-
date = this.dateTimeAdapter.addCalendarDays(date, 1)) {
|
|
442
|
-
if (this.dateFilter(date)) {
|
|
443
|
-
return true;
|
|
444
|
-
}
|
|
445
|
-
}
|
|
446
|
-
|
|
447
|
-
return false;
|
|
448
|
-
}
|
|
449
|
-
|
|
450
|
-
private isSameYearList( date1: T, date2: T ): boolean {
|
|
451
|
-
return Math.floor(this.dateTimeAdapter.getYear(date1) / (this.options.yearsPerRow * this.options.yearRows)) ===
|
|
452
|
-
Math.floor(this.dateTimeAdapter.getYear(date2) / (this.options.yearsPerRow * this.options.yearRows));
|
|
453
|
-
}
|
|
454
|
-
|
|
455
|
-
/**
|
|
456
|
-
* Get a valid date object
|
|
457
|
-
*/
|
|
458
|
-
private getValidDate( obj: any ): T | null {
|
|
459
|
-
return (this.dateTimeAdapter.isDateInstance(obj) && this.dateTimeAdapter.isValid(obj)) ? obj : null;
|
|
460
|
-
}
|
|
461
|
-
|
|
462
|
-
private focusActiveCell() {
|
|
463
|
-
this.calendarBodyElm.focusActiveCell();
|
|
464
|
-
}
|
|
465
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
<table class="owl-dt-calendar-table owl-dt-calendar-year-table">
|
|
2
|
-
<thead class="owl-dt-calendar-header">
|
|
3
|
-
<tr>
|
|
4
|
-
<th class="owl-dt-calendar-table-divider" aria-hidden="true" colspan="3"></th>
|
|
5
|
-
</tr>
|
|
6
|
-
</thead>
|
|
7
|
-
<tbody owl-date-time-calendar-body role="grid"
|
|
8
|
-
[rows]="months" [numCols]="3" [cellRatio]="3 / 7"
|
|
9
|
-
[activeCell]="activeCell"
|
|
10
|
-
[todayValue]="todayMonth"
|
|
11
|
-
[selectedValues]="selectedMonths"
|
|
12
|
-
[selectMode]="selectMode"
|
|
13
|
-
(keydown)="handleCalendarKeydown($event)"
|
|
14
|
-
(select)="selectCalendarCell($event)">
|
|
15
|
-
</tbody>
|
|
16
|
-
</table>
|
|
File without changes
|