@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,190 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* calendar-body.component
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
ChangeDetectionStrategy,
|
|
7
|
-
Component,
|
|
8
|
-
ElementRef,
|
|
9
|
-
EventEmitter,
|
|
10
|
-
Input,
|
|
11
|
-
NgZone,
|
|
12
|
-
OnInit,
|
|
13
|
-
Output
|
|
14
|
-
} from '@angular/core';
|
|
15
|
-
import { SelectMode } from './date-time.class';
|
|
16
|
-
import { take } from 'rxjs/operators';
|
|
17
|
-
|
|
18
|
-
export class CalendarCell {
|
|
19
|
-
constructor(
|
|
20
|
-
public value: number,
|
|
21
|
-
public displayValue: string,
|
|
22
|
-
public ariaLabel: string,
|
|
23
|
-
public enabled: boolean,
|
|
24
|
-
public out: boolean = false,
|
|
25
|
-
public cellClass: string = ''
|
|
26
|
-
) {}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
@Component({
|
|
30
|
-
selector: '[owl-date-time-calendar-body]',
|
|
31
|
-
exportAs: 'owlDateTimeCalendarBody',
|
|
32
|
-
templateUrl: './calendar-body.component.html',
|
|
33
|
-
styleUrls: ['./calendar-body.component.scss'],
|
|
34
|
-
host: {
|
|
35
|
-
'[class.owl-dt-calendar-body]': 'owlDTCalendarBodyClass'
|
|
36
|
-
},
|
|
37
|
-
preserveWhitespaces: false,
|
|
38
|
-
standalone: false,
|
|
39
|
-
changeDetection: ChangeDetectionStrategy.OnPush
|
|
40
|
-
})
|
|
41
|
-
export class OwlCalendarBodyComponent implements OnInit {
|
|
42
|
-
/**
|
|
43
|
-
* The cell number of the active cell in the table.
|
|
44
|
-
*/
|
|
45
|
-
@Input()
|
|
46
|
-
activeCell = 0;
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* The cells to display in the table.
|
|
50
|
-
* */
|
|
51
|
-
@Input()
|
|
52
|
-
rows: CalendarCell[][];
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* The number of columns in the table.
|
|
56
|
-
* */
|
|
57
|
-
@Input()
|
|
58
|
-
numCols = 7;
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* The ratio (width / height) to use for the cells in the table.
|
|
62
|
-
*/
|
|
63
|
-
@Input()
|
|
64
|
-
cellRatio = 1;
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* The value in the table that corresponds to today.
|
|
68
|
-
* */
|
|
69
|
-
@Input()
|
|
70
|
-
todayValue: number;
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* The value in the table that is currently selected.
|
|
74
|
-
* */
|
|
75
|
-
@Input()
|
|
76
|
-
selectedValues: number[];
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Current picker select mode
|
|
80
|
-
*/
|
|
81
|
-
@Input()
|
|
82
|
-
selectMode: SelectMode;
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Emit when a calendar cell is selected
|
|
86
|
-
* */
|
|
87
|
-
@Output()
|
|
88
|
-
public readonly select = new EventEmitter<CalendarCell>();
|
|
89
|
-
|
|
90
|
-
get owlDTCalendarBodyClass(): boolean {
|
|
91
|
-
return true;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
get isInSingleMode(): boolean {
|
|
95
|
-
return this.selectMode === 'single';
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
get isInRangeMode(): boolean {
|
|
99
|
-
return (
|
|
100
|
-
this.selectMode === 'range' ||
|
|
101
|
-
this.selectMode === 'rangeFrom' ||
|
|
102
|
-
this.selectMode === 'rangeTo'
|
|
103
|
-
);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
constructor(private elmRef: ElementRef, private ngZone: NgZone) {}
|
|
107
|
-
|
|
108
|
-
public ngOnInit() {}
|
|
109
|
-
|
|
110
|
-
public selectCell(cell: CalendarCell): void {
|
|
111
|
-
this.select.emit(cell);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
public isActiveCell(rowIndex: number, colIndex: number): boolean {
|
|
115
|
-
const cellNumber = rowIndex * this.numCols + colIndex;
|
|
116
|
-
return cellNumber === this.activeCell;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* Check if the cell is selected
|
|
121
|
-
*/
|
|
122
|
-
public isSelected(value: number): boolean {
|
|
123
|
-
if (!this.selectedValues || this.selectedValues.length === 0) {
|
|
124
|
-
return false;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
if (this.isInSingleMode) {
|
|
128
|
-
return value === this.selectedValues[0];
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
if (this.isInRangeMode) {
|
|
132
|
-
const fromValue = this.selectedValues[0];
|
|
133
|
-
const toValue = this.selectedValues[1];
|
|
134
|
-
|
|
135
|
-
return value === fromValue || value === toValue;
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
/**
|
|
140
|
-
* Check if the cell in the range
|
|
141
|
-
* */
|
|
142
|
-
public isInRange(value: number): boolean {
|
|
143
|
-
if (this.isInRangeMode) {
|
|
144
|
-
const fromValue = this.selectedValues[0];
|
|
145
|
-
const toValue = this.selectedValues[1];
|
|
146
|
-
|
|
147
|
-
if (fromValue !== null && toValue !== null) {
|
|
148
|
-
return value >= fromValue && value <= toValue;
|
|
149
|
-
} else {
|
|
150
|
-
return value === fromValue || value === toValue;
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
/**
|
|
156
|
-
* Check if the cell is the range from
|
|
157
|
-
* */
|
|
158
|
-
public isRangeFrom(value: number): boolean {
|
|
159
|
-
if (this.isInRangeMode) {
|
|
160
|
-
const fromValue = this.selectedValues[0];
|
|
161
|
-
return fromValue !== null && value === fromValue;
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
/**
|
|
166
|
-
* Check if the cell is the range to
|
|
167
|
-
* */
|
|
168
|
-
public isRangeTo(value: number): boolean {
|
|
169
|
-
if (this.isInRangeMode) {
|
|
170
|
-
const toValue = this.selectedValues[1];
|
|
171
|
-
return toValue !== null && value === toValue;
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
/**
|
|
176
|
-
* Focus to a active cell
|
|
177
|
-
* */
|
|
178
|
-
public focusActiveCell(): void {
|
|
179
|
-
this.ngZone.runOutsideAngular(() => {
|
|
180
|
-
this.ngZone.onStable
|
|
181
|
-
.asObservable()
|
|
182
|
-
.pipe(take(1))
|
|
183
|
-
.subscribe(() => {
|
|
184
|
-
this.elmRef.nativeElement
|
|
185
|
-
.querySelector('.owl-dt-calendar-cell-active')
|
|
186
|
-
.focus();
|
|
187
|
-
});
|
|
188
|
-
});
|
|
189
|
-
}
|
|
190
|
-
}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
@if (showCalendarWeeks) {
|
|
2
|
-
<ul class="week-number">
|
|
3
|
-
@for (week of weekNumbers; track week) {
|
|
4
|
-
<li>
|
|
5
|
-
<span>{{ week }}</span>
|
|
6
|
-
</li>
|
|
7
|
-
}
|
|
8
|
-
</ul>
|
|
9
|
-
}
|
|
10
|
-
<table
|
|
11
|
-
class="owl-dt-calendar-table owl-dt-calendar-month-table"
|
|
12
|
-
[ngClass]="{ 'owl-calendar-weeks': showCalendarWeeks }"
|
|
13
|
-
[class.owl-dt-calendar-only-current-month]="hideOtherMonths"
|
|
14
|
-
>
|
|
15
|
-
<thead class="owl-dt-calendar-header">
|
|
16
|
-
<tr class="owl-dt-weekdays">
|
|
17
|
-
@for (weekday of weekdays; track weekday.short) {
|
|
18
|
-
<th
|
|
19
|
-
[attr.aria-label]="weekday.long"
|
|
20
|
-
class="owl-dt-weekday"
|
|
21
|
-
scope="col"
|
|
22
|
-
>
|
|
23
|
-
<span>{{ weekday.short }}</span>
|
|
24
|
-
</th>
|
|
25
|
-
}
|
|
26
|
-
</tr>
|
|
27
|
-
<tr>
|
|
28
|
-
<th
|
|
29
|
-
class="owl-dt-calendar-table-divider"
|
|
30
|
-
[ngClass]="{ 'owl-calendar-weeks': showCalendarWeeks }"
|
|
31
|
-
aria-hidden="true"
|
|
32
|
-
colspan="7"
|
|
33
|
-
></th>
|
|
34
|
-
</tr>
|
|
35
|
-
</thead>
|
|
36
|
-
<tbody
|
|
37
|
-
owl-date-time-calendar-body
|
|
38
|
-
role="grid"
|
|
39
|
-
[rows]="days"
|
|
40
|
-
[todayValue]="todayDate"
|
|
41
|
-
[selectedValues]="selectedDates"
|
|
42
|
-
[selectMode]="selectMode"
|
|
43
|
-
[activeCell]="activeCell"
|
|
44
|
-
(keydown)="handleCalendarKeydown($event)"
|
|
45
|
-
(select)="selectCalendarCell($event)"
|
|
46
|
-
></tbody>
|
|
47
|
-
</table>
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
.week-number {
|
|
2
|
-
display: flex;
|
|
3
|
-
flex-direction: column;
|
|
4
|
-
justify-content: space-between;
|
|
5
|
-
margin: 0;
|
|
6
|
-
padding: 0;
|
|
7
|
-
list-style: none;
|
|
8
|
-
margin-bottom: 14px;
|
|
9
|
-
margin-top: 46px;
|
|
10
|
-
border-right: 1px solid rgba(0, 0, 0, .12);
|
|
11
|
-
width: 8%;
|
|
12
|
-
font-weight: bold;
|
|
13
|
-
li {
|
|
14
|
-
font-size: .8em;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
@@ -1,394 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* calendar-month-view.component.spec
|
|
3
|
-
*/
|
|
4
|
-
import { registerLocaleData } from '@angular/common';
|
|
5
|
-
import localeDutch from '@angular/common/locales/nl';
|
|
6
|
-
import { DateTimeAdapter } from './adapter/date-time-adapter.class';
|
|
7
|
-
import { OwlMonthViewComponent } from './calendar-month-view.component';
|
|
8
|
-
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
9
|
-
import { OwlDateTimeIntl } from './date-time-picker-intl.service';
|
|
10
|
-
import { OwlNativeDateTimeModule } from './adapter/native-date-time.module';
|
|
11
|
-
import { OwlDateTimeModule } from './date-time.module';
|
|
12
|
-
import { Component, DebugElement } from '@angular/core';
|
|
13
|
-
import { By } from '@angular/platform-browser';
|
|
14
|
-
import { dispatchKeyboardEvent } from '../../test-helpers';
|
|
15
|
-
import {
|
|
16
|
-
DOWN_ARROW,
|
|
17
|
-
END,
|
|
18
|
-
ENTER,
|
|
19
|
-
HOME,
|
|
20
|
-
LEFT_ARROW,
|
|
21
|
-
PAGE_DOWN,
|
|
22
|
-
PAGE_UP,
|
|
23
|
-
RIGHT_ARROW,
|
|
24
|
-
UP_ARROW
|
|
25
|
-
} from '@angular/cdk/keycodes';
|
|
26
|
-
|
|
27
|
-
const JAN = 0,
|
|
28
|
-
FEB = 1,
|
|
29
|
-
MAR = 2,
|
|
30
|
-
APR = 3,
|
|
31
|
-
MAY = 4,
|
|
32
|
-
JUN = 5,
|
|
33
|
-
JUL = 6,
|
|
34
|
-
AUG = 7,
|
|
35
|
-
SEP = 8,
|
|
36
|
-
OCT = 9,
|
|
37
|
-
NOV = 10,
|
|
38
|
-
DEC = 11;
|
|
39
|
-
|
|
40
|
-
describe('OwlMonthViewComponent', () => {
|
|
41
|
-
beforeEach(() => {
|
|
42
|
-
TestBed.configureTestingModule({
|
|
43
|
-
imports: [OwlNativeDateTimeModule, OwlDateTimeModule],
|
|
44
|
-
declarations: [
|
|
45
|
-
StandardMonthViewComponent,
|
|
46
|
-
MonthViewWithDateFilterComponent
|
|
47
|
-
],
|
|
48
|
-
providers: [OwlDateTimeIntl]
|
|
49
|
-
}).compileComponents();
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
describe('standard month view', () => {
|
|
53
|
-
let fixture: ComponentFixture<StandardMonthViewComponent>;
|
|
54
|
-
let testComponent: StandardMonthViewComponent;
|
|
55
|
-
let monthViewDebugElement: DebugElement;
|
|
56
|
-
let monthViewElement: HTMLElement;
|
|
57
|
-
let monthViewInstance: OwlMonthViewComponent<Date>;
|
|
58
|
-
|
|
59
|
-
beforeEach(() => {
|
|
60
|
-
fixture = TestBed.createComponent(StandardMonthViewComponent);
|
|
61
|
-
fixture.detectChanges();
|
|
62
|
-
|
|
63
|
-
monthViewDebugElement = fixture.debugElement.query(
|
|
64
|
-
By.directive(OwlMonthViewComponent)
|
|
65
|
-
);
|
|
66
|
-
monthViewElement = monthViewDebugElement.nativeElement;
|
|
67
|
-
testComponent = fixture.componentInstance;
|
|
68
|
-
monthViewInstance = monthViewDebugElement.componentInstance;
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
it('should have 42 calendar day cells', () => {
|
|
72
|
-
const cellEls = monthViewElement.querySelectorAll(
|
|
73
|
-
'.owl-dt-calendar-cell'
|
|
74
|
-
);
|
|
75
|
-
expect(cellEls.length).toBe(42);
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
it('should show selected date if in same month', () => {
|
|
79
|
-
const selectedEl = monthViewElement.querySelector(
|
|
80
|
-
'.owl-dt-calendar-cell-selected'
|
|
81
|
-
);
|
|
82
|
-
expect(selectedEl.innerHTML.trim()).toBe('10');
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
it('should NOT show selected date if in different month', () => {
|
|
86
|
-
testComponent.selected = new Date(2018, MAR, 10);
|
|
87
|
-
fixture.detectChanges();
|
|
88
|
-
const selectedEl = monthViewElement.querySelector(
|
|
89
|
-
'.owl-dt-calendar-cell-selected'
|
|
90
|
-
);
|
|
91
|
-
expect(selectedEl).toBeNull();
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
it('should mark active date', () => {
|
|
95
|
-
const selectedElContent = monthViewElement.querySelector(
|
|
96
|
-
'.owl-dt-calendar-cell-active .owl-dt-calendar-cell-content'
|
|
97
|
-
);
|
|
98
|
-
expect(selectedElContent.innerHTML.trim()).toBe('5');
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
it('should set Sunday as first day of week by default', () => {
|
|
102
|
-
expect(monthViewInstance.firstDayOfWeek).toBe(0);
|
|
103
|
-
const weekdayCells = monthViewElement.querySelectorAll(
|
|
104
|
-
'.owl-dt-weekday'
|
|
105
|
-
);
|
|
106
|
-
expect(weekdayCells[0].getAttribute('aria-label')).toBe('Sunday');
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
it('should set Monday as first day of week if firstDayOfWeek set to 1', () => {
|
|
110
|
-
monthViewInstance.firstDayOfWeek = 1;
|
|
111
|
-
fixture.detectChanges();
|
|
112
|
-
const weekdayCells = monthViewElement.querySelectorAll(
|
|
113
|
-
'.owl-dt-weekday'
|
|
114
|
-
);
|
|
115
|
-
expect(weekdayCells[0].getAttribute('aria-label')).toBe('Monday');
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
it('should set Saturday as first day of week if firstDayOfWeek set to 6', () => {
|
|
119
|
-
monthViewInstance.firstDayOfWeek = 6;
|
|
120
|
-
fixture.detectChanges();
|
|
121
|
-
const weekdayCells = monthViewElement.querySelectorAll(
|
|
122
|
-
'.owl-dt-weekday'
|
|
123
|
-
);
|
|
124
|
-
expect(weekdayCells[0].getAttribute('aria-label')).toBe('Saturday');
|
|
125
|
-
});
|
|
126
|
-
|
|
127
|
-
it('should decrement date on left arrow press', () => {
|
|
128
|
-
const calendarBodyEl = monthViewElement.querySelector(
|
|
129
|
-
'.owl-dt-calendar-body'
|
|
130
|
-
);
|
|
131
|
-
dispatchKeyboardEvent(calendarBodyEl, 'keydown', LEFT_ARROW);
|
|
132
|
-
fixture.detectChanges();
|
|
133
|
-
expect(testComponent.pickerMoment).toEqual(new Date(2018, JAN, 4));
|
|
134
|
-
|
|
135
|
-
monthViewInstance.pickerMoment = new Date(2017, JAN, 1);
|
|
136
|
-
fixture.detectChanges();
|
|
137
|
-
|
|
138
|
-
dispatchKeyboardEvent(calendarBodyEl, 'keydown', LEFT_ARROW);
|
|
139
|
-
fixture.detectChanges();
|
|
140
|
-
|
|
141
|
-
expect(testComponent.pickerMoment).toEqual(new Date(2016, DEC, 31));
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
it('should increment date on right arrow press', () => {
|
|
145
|
-
const calendarBodyEl = monthViewElement.querySelector(
|
|
146
|
-
'.owl-dt-calendar-body'
|
|
147
|
-
);
|
|
148
|
-
dispatchKeyboardEvent(calendarBodyEl, 'keydown', RIGHT_ARROW);
|
|
149
|
-
fixture.detectChanges();
|
|
150
|
-
|
|
151
|
-
expect(testComponent.pickerMoment).toEqual(new Date(2018, JAN, 6));
|
|
152
|
-
|
|
153
|
-
dispatchKeyboardEvent(calendarBodyEl, 'keydown', RIGHT_ARROW);
|
|
154
|
-
fixture.detectChanges();
|
|
155
|
-
|
|
156
|
-
expect(testComponent.pickerMoment).toEqual(new Date(2018, JAN, 7));
|
|
157
|
-
});
|
|
158
|
-
|
|
159
|
-
it('should go up a row on up arrow press', () => {
|
|
160
|
-
const calendarBodyEl = monthViewElement.querySelector(
|
|
161
|
-
'.owl-dt-calendar-body'
|
|
162
|
-
);
|
|
163
|
-
dispatchKeyboardEvent(calendarBodyEl, 'keydown', UP_ARROW);
|
|
164
|
-
fixture.detectChanges();
|
|
165
|
-
|
|
166
|
-
expect(testComponent.pickerMoment).toEqual(new Date(2017, DEC, 29));
|
|
167
|
-
|
|
168
|
-
monthViewInstance.pickerMoment = new Date(2017, JAN, 7);
|
|
169
|
-
fixture.detectChanges();
|
|
170
|
-
|
|
171
|
-
dispatchKeyboardEvent(calendarBodyEl, 'keydown', UP_ARROW);
|
|
172
|
-
fixture.detectChanges();
|
|
173
|
-
|
|
174
|
-
expect(testComponent.pickerMoment).toEqual(new Date(2016, DEC, 31));
|
|
175
|
-
});
|
|
176
|
-
|
|
177
|
-
it('should go down a row on down arrow press', () => {
|
|
178
|
-
const calendarBodyEl = monthViewElement.querySelector(
|
|
179
|
-
'.owl-dt-calendar-body'
|
|
180
|
-
);
|
|
181
|
-
dispatchKeyboardEvent(calendarBodyEl, 'keydown', DOWN_ARROW);
|
|
182
|
-
fixture.detectChanges();
|
|
183
|
-
|
|
184
|
-
expect(testComponent.pickerMoment).toEqual(new Date(2018, JAN, 12));
|
|
185
|
-
|
|
186
|
-
dispatchKeyboardEvent(calendarBodyEl, 'keydown', DOWN_ARROW);
|
|
187
|
-
fixture.detectChanges();
|
|
188
|
-
|
|
189
|
-
expect(testComponent.pickerMoment).toEqual(new Date(2018, JAN, 19));
|
|
190
|
-
});
|
|
191
|
-
|
|
192
|
-
it('should go to beginning of the month on home press', () => {
|
|
193
|
-
monthViewInstance.pickerMoment = new Date(2018, JAN, 7);
|
|
194
|
-
fixture.detectChanges();
|
|
195
|
-
|
|
196
|
-
const calendarBodyEl = monthViewElement.querySelector(
|
|
197
|
-
'.owl-dt-calendar-body'
|
|
198
|
-
);
|
|
199
|
-
dispatchKeyboardEvent(calendarBodyEl, 'keydown', HOME);
|
|
200
|
-
fixture.detectChanges();
|
|
201
|
-
|
|
202
|
-
expect(testComponent.pickerMoment).toEqual(new Date(2018, JAN, 1));
|
|
203
|
-
|
|
204
|
-
dispatchKeyboardEvent(calendarBodyEl, 'keydown', HOME);
|
|
205
|
-
fixture.detectChanges();
|
|
206
|
-
|
|
207
|
-
expect(testComponent.pickerMoment).toEqual(new Date(2018, JAN, 1));
|
|
208
|
-
});
|
|
209
|
-
|
|
210
|
-
it('should go to end of the month on end press', () => {
|
|
211
|
-
monthViewInstance.pickerMoment = new Date(2018, JAN, 7);
|
|
212
|
-
fixture.detectChanges();
|
|
213
|
-
|
|
214
|
-
const calendarBodyEl = monthViewElement.querySelector(
|
|
215
|
-
'.owl-dt-calendar-body'
|
|
216
|
-
);
|
|
217
|
-
dispatchKeyboardEvent(calendarBodyEl, 'keydown', END);
|
|
218
|
-
fixture.detectChanges();
|
|
219
|
-
|
|
220
|
-
expect(testComponent.pickerMoment).toEqual(new Date(2018, JAN, 31));
|
|
221
|
-
|
|
222
|
-
dispatchKeyboardEvent(calendarBodyEl, 'keydown', END);
|
|
223
|
-
fixture.detectChanges();
|
|
224
|
-
|
|
225
|
-
expect(testComponent.pickerMoment).toEqual(new Date(2018, JAN, 31));
|
|
226
|
-
});
|
|
227
|
-
|
|
228
|
-
it('should go back one month on page up press', () => {
|
|
229
|
-
const calendarBodyEl = monthViewElement.querySelector(
|
|
230
|
-
'.owl-dt-calendar-body'
|
|
231
|
-
);
|
|
232
|
-
dispatchKeyboardEvent(calendarBodyEl, 'keydown', PAGE_UP);
|
|
233
|
-
fixture.detectChanges();
|
|
234
|
-
|
|
235
|
-
expect(testComponent.pickerMoment).toEqual(new Date(2017, DEC, 5));
|
|
236
|
-
|
|
237
|
-
dispatchKeyboardEvent(calendarBodyEl, 'keydown', PAGE_UP);
|
|
238
|
-
fixture.detectChanges();
|
|
239
|
-
|
|
240
|
-
expect(testComponent.pickerMoment).toEqual(new Date(2017, NOV, 5));
|
|
241
|
-
});
|
|
242
|
-
|
|
243
|
-
it('should go forward one month on page down press', () => {
|
|
244
|
-
const calendarBodyEl = monthViewElement.querySelector(
|
|
245
|
-
'.owl-dt-calendar-body'
|
|
246
|
-
);
|
|
247
|
-
dispatchKeyboardEvent(calendarBodyEl, 'keydown', PAGE_DOWN);
|
|
248
|
-
fixture.detectChanges();
|
|
249
|
-
|
|
250
|
-
expect(testComponent.pickerMoment).toEqual(new Date(2018, FEB, 5));
|
|
251
|
-
|
|
252
|
-
dispatchKeyboardEvent(calendarBodyEl, 'keydown', PAGE_DOWN);
|
|
253
|
-
fixture.detectChanges();
|
|
254
|
-
|
|
255
|
-
expect(testComponent.pickerMoment).toEqual(new Date(2018, MAR, 5));
|
|
256
|
-
});
|
|
257
|
-
|
|
258
|
-
it('should select active date on enter', () => {
|
|
259
|
-
const calendarBodyEl = monthViewElement.querySelector(
|
|
260
|
-
'.owl-dt-calendar-body'
|
|
261
|
-
);
|
|
262
|
-
dispatchKeyboardEvent(calendarBodyEl, 'keydown', LEFT_ARROW);
|
|
263
|
-
fixture.detectChanges();
|
|
264
|
-
|
|
265
|
-
expect(testComponent.selected).toEqual(new Date(2018, JAN, 10));
|
|
266
|
-
|
|
267
|
-
dispatchKeyboardEvent(calendarBodyEl, 'keydown', ENTER);
|
|
268
|
-
fixture.detectChanges();
|
|
269
|
-
|
|
270
|
-
expect(testComponent.selected).toEqual(new Date(2018, JAN, 4));
|
|
271
|
-
});
|
|
272
|
-
});
|
|
273
|
-
|
|
274
|
-
describe('month view with date filter', () => {
|
|
275
|
-
let fixture: ComponentFixture<MonthViewWithDateFilterComponent>;
|
|
276
|
-
let monthViewNativeElement: Element;
|
|
277
|
-
|
|
278
|
-
beforeEach(() => {
|
|
279
|
-
fixture = TestBed.createComponent(MonthViewWithDateFilterComponent);
|
|
280
|
-
fixture.detectChanges();
|
|
281
|
-
|
|
282
|
-
const monthViewDebugElement = fixture.debugElement.query(
|
|
283
|
-
By.directive(OwlMonthViewComponent)
|
|
284
|
-
);
|
|
285
|
-
monthViewNativeElement = monthViewDebugElement.nativeElement;
|
|
286
|
-
});
|
|
287
|
-
|
|
288
|
-
it('should disable filtered dates', () => {
|
|
289
|
-
const cellOne = monthViewNativeElement.querySelector(
|
|
290
|
-
'[aria-label="January 1, 2018"]'
|
|
291
|
-
);
|
|
292
|
-
const cellTwo = monthViewNativeElement.querySelector(
|
|
293
|
-
'[aria-label="January 2, 2018"]'
|
|
294
|
-
);
|
|
295
|
-
expect(cellOne.classList).toContain(
|
|
296
|
-
'owl-dt-calendar-cell-disabled'
|
|
297
|
-
);
|
|
298
|
-
expect(cellTwo.classList).not.toContain(
|
|
299
|
-
'owl-dt-calendar-cell-disabled'
|
|
300
|
-
);
|
|
301
|
-
});
|
|
302
|
-
});
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
describe('standard month view (locale tests)', () => {
|
|
306
|
-
let fixture: ComponentFixture<StandardMonthViewComponent>;
|
|
307
|
-
let adapter: DateTimeAdapter<unknown>;
|
|
308
|
-
let monthViewDebugElement: DebugElement;
|
|
309
|
-
let monthViewElement: HTMLElement;
|
|
310
|
-
let monthViewInstance: OwlMonthViewComponent<Date>;
|
|
311
|
-
|
|
312
|
-
beforeAll(() => {
|
|
313
|
-
registerLocaleData(localeDutch);
|
|
314
|
-
});
|
|
315
|
-
|
|
316
|
-
beforeEach(() => {
|
|
317
|
-
fixture = TestBed.createComponent(StandardMonthViewComponent);
|
|
318
|
-
|
|
319
|
-
adapter = TestBed.inject(DateTimeAdapter);
|
|
320
|
-
monthViewDebugElement = fixture.debugElement.query(
|
|
321
|
-
By.directive(OwlMonthViewComponent)
|
|
322
|
-
);
|
|
323
|
-
monthViewElement = monthViewDebugElement.nativeElement;
|
|
324
|
-
monthViewInstance = monthViewDebugElement.componentInstance;
|
|
325
|
-
});
|
|
326
|
-
|
|
327
|
-
it('should derive the first day of the week based on the active locale', () => {
|
|
328
|
-
adapter.setLocale('nl-NL');
|
|
329
|
-
|
|
330
|
-
fixture.detectChanges();
|
|
331
|
-
const weekdayCells = monthViewElement.querySelectorAll(
|
|
332
|
-
'.owl-dt-weekday'
|
|
333
|
-
);
|
|
334
|
-
expect(weekdayCells[0].getAttribute('aria-label')).toBe('maandag');
|
|
335
|
-
});
|
|
336
|
-
|
|
337
|
-
it('should fallback to Sunday as first day of the week when when locale data is missing', () => {
|
|
338
|
-
adapter.setLocale('unknown');
|
|
339
|
-
|
|
340
|
-
fixture.detectChanges();
|
|
341
|
-
const weekdayCells = monthViewElement.querySelectorAll(
|
|
342
|
-
'.owl-dt-weekday'
|
|
343
|
-
);
|
|
344
|
-
expect(weekdayCells[0].getAttribute('aria-label')).toBe('Sunday');
|
|
345
|
-
});
|
|
346
|
-
|
|
347
|
-
it('should update the default day of the week when locale changes', () => {
|
|
348
|
-
adapter.setLocale('nl-NL');
|
|
349
|
-
|
|
350
|
-
fixture.detectChanges();
|
|
351
|
-
const weekdayCellsNl = monthViewElement.querySelectorAll(
|
|
352
|
-
'.owl-dt-weekday'
|
|
353
|
-
);
|
|
354
|
-
expect(weekdayCellsNl[0].getAttribute('aria-label')).toBe('maandag');
|
|
355
|
-
|
|
356
|
-
adapter.setLocale('en-US');
|
|
357
|
-
|
|
358
|
-
fixture.detectChanges();
|
|
359
|
-
const weekdayCellsUs = monthViewElement.querySelectorAll(
|
|
360
|
-
'.owl-dt-weekday'
|
|
361
|
-
);
|
|
362
|
-
expect(weekdayCellsUs[0].getAttribute('aria-label')).toBe('Sunday');
|
|
363
|
-
});
|
|
364
|
-
});
|
|
365
|
-
});
|
|
366
|
-
|
|
367
|
-
@Component({
|
|
368
|
-
standalone: false,
|
|
369
|
-
template: `
|
|
370
|
-
<owl-date-time-month-view
|
|
371
|
-
[(selected)]="selected"
|
|
372
|
-
[(pickerMoment)]="pickerMoment"></owl-date-time-month-view>
|
|
373
|
-
`
|
|
374
|
-
})
|
|
375
|
-
class StandardMonthViewComponent {
|
|
376
|
-
selected = new Date(2018, JAN, 10);
|
|
377
|
-
pickerMoment = new Date(2018, JAN, 5);
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
@Component({
|
|
381
|
-
standalone: false,
|
|
382
|
-
template: `
|
|
383
|
-
<owl-date-time-month-view
|
|
384
|
-
[(pickerMoment)]="pickerMoment"
|
|
385
|
-
[dateFilter]="dateFilter"></owl-date-time-month-view>
|
|
386
|
-
`
|
|
387
|
-
})
|
|
388
|
-
class MonthViewWithDateFilterComponent {
|
|
389
|
-
pickerMoment = new Date(2018, JAN, 1);
|
|
390
|
-
dateFilter(date: Date) {
|
|
391
|
-
// tslint:disable-next-line:triple-equals
|
|
392
|
-
return date.getDate() % 2 === 0;
|
|
393
|
-
}
|
|
394
|
-
}
|