@imihai/angular-datetime-picker 21.0.2 → 22.0.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/.browserslistrc +9 -0
- package/.editorconfig +13 -0
- package/.eslintrc.js +208 -0
- package/.github/workflows/ci_test.yml +35 -0
- package/.prettierrc +2 -0
- package/.travis.yml +16 -0
- package/angular.json +221 -0
- package/e2e/protractor.conf.js +28 -0
- package/e2e/src/app.e2e-spec.ts +14 -0
- package/e2e/src/app.po.ts +11 -0
- package/e2e/tsconfig.e2e.json +13 -0
- package/package.json +77 -33
- package/projects/picker/karma.conf.js +62 -0
- package/projects/picker/ng-package.json +7 -0
- package/projects/picker/package.json +23 -0
- package/projects/picker/src/lib/date-time/adapter/date-time-adapter.class.ts +313 -0
- package/projects/picker/src/lib/date-time/adapter/date-time-format.class.ts +18 -0
- package/projects/picker/src/lib/date-time/adapter/luxon-date-time-adapter.class.ts +307 -0
- package/projects/picker/src/lib/date-time/adapter/luxon-date-time-format.class.ts +11 -0
- package/projects/picker/src/lib/date-time/adapter/luxon-date-time.module.ts +31 -0
- package/projects/picker/src/lib/date-time/adapter/unix-timestamp-adapter/unix-timestamp-date-time-adapter.class.ts +356 -0
- package/projects/picker/src/lib/date-time/adapter/unix-timestamp-adapter/unix-timestamp-date-time-format.class.ts +14 -0
- package/projects/picker/src/lib/date-time/adapter/unix-timestamp-adapter/unix-timestamp-date-time.module.ts +26 -0
- package/projects/picker/src/lib/date-time/calendar-body.component.html +38 -0
- 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 +120 -0
- package/projects/picker/src/lib/date-time/calendar-body.component.ts +190 -0
- package/projects/picker/src/lib/date-time/calendar-month-view.component.html +47 -0
- package/projects/picker/src/lib/date-time/calendar-month-view.component.scss +16 -0
- package/projects/picker/src/lib/date-time/calendar-month-view.component.spec.ts +394 -0
- package/projects/picker/src/lib/date-time/calendar-month-view.component.ts +705 -0
- package/projects/picker/src/lib/date-time/calendar-multi-year-view.component.html +44 -0
- 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 +343 -0
- package/projects/picker/src/lib/date-time/calendar-multi-year-view.component.ts +465 -0
- package/projects/picker/src/lib/date-time/calendar-year-view.component.html +16 -0
- 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 +381 -0
- package/projects/picker/src/lib/date-time/calendar-year-view.component.ts +549 -0
- package/projects/picker/src/lib/date-time/calendar.component.html +169 -0
- package/projects/picker/src/lib/date-time/calendar.component.scss +0 -0
- package/projects/picker/src/lib/date-time/calendar.component.spec.ts +592 -0
- package/projects/picker/src/lib/date-time/calendar.component.ts +496 -0
- package/projects/picker/src/lib/date-time/date-time-inline.component.html +1 -0
- package/projects/picker/src/lib/date-time/date-time-inline.component.scss +4 -0
- package/projects/picker/src/lib/date-time/date-time-inline.component.ts +365 -0
- package/projects/picker/src/lib/date-time/date-time-picker-animation-event.ts +4 -0
- package/projects/picker/src/lib/date-time/date-time-picker-container.component.html +126 -0
- 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 +631 -0
- package/projects/picker/src/lib/date-time/date-time-picker-input.directive.ts +851 -0
- package/projects/picker/src/lib/date-time/date-time-picker-intl.service.ts +76 -0
- package/projects/picker/src/lib/date-time/date-time-picker-trigger.directive.ts +88 -0
- 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 +2648 -0
- package/projects/picker/src/lib/date-time/date-time-picker.component.ts +731 -0
- package/projects/picker/src/lib/date-time/date-time.class.ts +256 -0
- package/projects/picker/src/lib/date-time/date-time.module.ts +61 -0
- package/projects/picker/src/lib/date-time/numberedFixLen.pipe.ts +28 -0
- package/projects/picker/src/lib/date-time/options-provider.ts +44 -0
- package/projects/picker/src/lib/date-time/timer-box.component.html +79 -0
- package/projects/picker/src/lib/date-time/timer-box.component.scss +0 -0
- package/projects/picker/src/lib/date-time/timer-box.component.ts +175 -0
- package/projects/picker/src/lib/date-time/timer.component.html +58 -0
- package/projects/picker/src/lib/date-time/timer.component.scss +0 -0
- package/projects/picker/src/lib/date-time/timer.component.spec.ts +399 -0
- package/projects/picker/src/lib/date-time/timer.component.ts +371 -0
- package/projects/picker/src/lib/dialog/dialog-config.class.ts +220 -0
- package/projects/picker/src/lib/dialog/dialog-container.component.html +1 -0
- package/projects/picker/src/lib/dialog/dialog-container.component.scss +0 -0
- package/projects/picker/src/lib/dialog/dialog-container.component.ts +231 -0
- package/projects/picker/src/lib/dialog/dialog-ref.class.ts +178 -0
- package/projects/picker/src/lib/dialog/dialog.module.ts +25 -0
- package/projects/picker/src/lib/dialog/dialog.service.ts +353 -0
- package/projects/picker/src/lib/utils/array.utils.ts +12 -0
- package/projects/picker/src/lib/utils/constants.ts +59 -0
- package/projects/picker/src/lib/utils/date.utils.ts +97 -0
- package/projects/picker/src/lib/utils/index.ts +5 -0
- package/projects/picker/src/lib/utils/object.utils.ts +29 -0
- package/projects/picker/src/public_api.ts +56 -0
- package/projects/picker/src/sass/picker.scss +743 -0
- package/projects/picker/src/test-helpers.ts +125 -0
- package/projects/picker/src/test.ts +52 -0
- package/projects/picker/tsconfig.lib.json +19 -0
- package/projects/picker/tsconfig.lib.prod.json +7 -0
- package/projects/picker/tsconfig.spec.json +17 -0
- package/projects/picker/tslint.json +8 -0
- package/src/app/app.component.html +77 -0
- package/src/app/app.component.scss +32 -0
- package/src/app/app.component.spec.ts +16 -0
- package/src/app/app.component.ts +35 -0
- package/src/assets/.gitkeep +0 -0
- package/src/environments/environment.prod.ts +3 -0
- package/src/environments/environment.ts +16 -0
- package/src/favicon.ico +0 -0
- package/src/index.html +14 -0
- package/src/karma.conf.js +31 -0
- package/src/main.ts +16 -0
- package/src/polyfills.ts +53 -0
- package/src/styles.scss +7 -0
- package/src/test.ts +50 -0
- package/src/tsconfig.app.json +16 -0
- package/src/tsconfig.spec.json +18 -0
- package/src/tslint.json +17 -0
- package/tsconfig.base.json +31 -0
- package/tsconfig.json +30 -0
- package/tslint.json +130 -0
- package/assets/style/picker.min.css +0 -1
- package/fesm2022/imihai-angular-datetime-picker.mjs +0 -5845
- package/fesm2022/imihai-angular-datetime-picker.mjs.map +0 -1
- package/imihai-angular-datetime-picker-21.0.2.tgz +0 -0
- package/types/imihai-angular-datetime-picker.d.ts +0 -2193
|
@@ -0,0 +1,381 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* calendar-year-view.component.spec
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
6
|
+
import { OwlDateTimeIntl } from './date-time-picker-intl.service';
|
|
7
|
+
import { OwlNativeDateTimeModule } from './adapter/native-date-time.module';
|
|
8
|
+
import { OwlDateTimeModule } from './date-time.module';
|
|
9
|
+
import { Component, DebugElement } from '@angular/core';
|
|
10
|
+
import { OwlYearViewComponent } from './calendar-year-view.component';
|
|
11
|
+
import { By } from '@angular/platform-browser';
|
|
12
|
+
import { dispatchMouseEvent, dispatchKeyboardEvent } from '../../test-helpers';
|
|
13
|
+
import {
|
|
14
|
+
DOWN_ARROW,
|
|
15
|
+
END,
|
|
16
|
+
HOME,
|
|
17
|
+
LEFT_ARROW,
|
|
18
|
+
PAGE_DOWN,
|
|
19
|
+
PAGE_UP,
|
|
20
|
+
RIGHT_ARROW,
|
|
21
|
+
UP_ARROW
|
|
22
|
+
} from '@angular/cdk/keycodes';
|
|
23
|
+
|
|
24
|
+
const JAN = 0,
|
|
25
|
+
FEB = 1,
|
|
26
|
+
MAR = 2,
|
|
27
|
+
APR = 3,
|
|
28
|
+
MAY = 4,
|
|
29
|
+
JUN = 5,
|
|
30
|
+
JUL = 6,
|
|
31
|
+
AUG = 7,
|
|
32
|
+
SEP = 8,
|
|
33
|
+
OCT = 9,
|
|
34
|
+
NOV = 10,
|
|
35
|
+
DEC = 11;
|
|
36
|
+
|
|
37
|
+
describe('OwlYearViewComponent', () => {
|
|
38
|
+
beforeEach(() => {
|
|
39
|
+
TestBed.configureTestingModule({
|
|
40
|
+
imports: [OwlNativeDateTimeModule, OwlDateTimeModule],
|
|
41
|
+
declarations: [
|
|
42
|
+
StandardYearViewComponent,
|
|
43
|
+
YearViewWithDateFilterComponent
|
|
44
|
+
],
|
|
45
|
+
providers: [OwlDateTimeIntl]
|
|
46
|
+
}).compileComponents();
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
describe('standard year view', () => {
|
|
50
|
+
let fixture: ComponentFixture<StandardYearViewComponent>;
|
|
51
|
+
let testComponent: StandardYearViewComponent;
|
|
52
|
+
let yearViewDebugElement: DebugElement;
|
|
53
|
+
let yearViewElement: HTMLElement;
|
|
54
|
+
let yearViewInstance: OwlYearViewComponent<Date>;
|
|
55
|
+
|
|
56
|
+
beforeEach(() => {
|
|
57
|
+
fixture = TestBed.createComponent(StandardYearViewComponent);
|
|
58
|
+
fixture.detectChanges();
|
|
59
|
+
|
|
60
|
+
yearViewDebugElement = fixture.debugElement.query(
|
|
61
|
+
By.directive(OwlYearViewComponent)
|
|
62
|
+
);
|
|
63
|
+
yearViewElement = yearViewDebugElement.nativeElement;
|
|
64
|
+
testComponent = fixture.componentInstance;
|
|
65
|
+
yearViewInstance = yearViewDebugElement.componentInstance;
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it('should have 12 months', () => {
|
|
69
|
+
const cellEls = yearViewElement.querySelectorAll(
|
|
70
|
+
'.owl-dt-calendar-cell'
|
|
71
|
+
);
|
|
72
|
+
expect(cellEls.length).toBe(12);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it('should show selected month if in same year', () => {
|
|
76
|
+
const selectedElContent = yearViewElement.querySelector(
|
|
77
|
+
'.owl-dt-calendar-cell-selected.owl-dt-calendar-cell-content'
|
|
78
|
+
);
|
|
79
|
+
expect(selectedElContent.innerHTML.trim()).toBe('Jan');
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it('should NOT show selected month if in different year', () => {
|
|
83
|
+
testComponent.selected = new Date(2017, JAN, 10);
|
|
84
|
+
fixture.detectChanges();
|
|
85
|
+
|
|
86
|
+
const selectedElContent = yearViewElement.querySelector(
|
|
87
|
+
'.owl-calendar-body-selected.owl-dt-calendar-cell-content'
|
|
88
|
+
);
|
|
89
|
+
expect(selectedElContent).toBeNull();
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
it('should fire change event on cell clicked', () => {
|
|
93
|
+
const cellDecember = yearViewElement.querySelector(
|
|
94
|
+
'[aria-label="December 2018"]'
|
|
95
|
+
);
|
|
96
|
+
dispatchMouseEvent(cellDecember, 'click');
|
|
97
|
+
fixture.detectChanges();
|
|
98
|
+
|
|
99
|
+
const selectedElContent = yearViewElement.querySelector(
|
|
100
|
+
'.owl-dt-calendar-cell-active .owl-dt-calendar-cell-content'
|
|
101
|
+
);
|
|
102
|
+
expect(selectedElContent.innerHTML.trim()).toBe('Dec');
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
it('should mark active date', () => {
|
|
106
|
+
const cellDecember = yearViewElement.querySelector(
|
|
107
|
+
'[aria-label="January 2018"]'
|
|
108
|
+
);
|
|
109
|
+
expect((cellDecember as HTMLElement).innerText.trim()).toBe('Jan');
|
|
110
|
+
expect(cellDecember.classList).toContain(
|
|
111
|
+
'owl-dt-calendar-cell-active'
|
|
112
|
+
);
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
it('should allow selection of month with less days than current active date', () => {
|
|
116
|
+
testComponent.pickerMoment = new Date(2017, JUL, 31);
|
|
117
|
+
fixture.detectChanges();
|
|
118
|
+
|
|
119
|
+
const cellJune = yearViewElement.querySelector(
|
|
120
|
+
'[aria-label="June 2017"]'
|
|
121
|
+
);
|
|
122
|
+
dispatchMouseEvent(cellJune, 'click');
|
|
123
|
+
fixture.detectChanges();
|
|
124
|
+
|
|
125
|
+
expect(testComponent.pickerMoment).toEqual(new Date(2017, JUN, 30));
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
it('should decrement month on left arrow press', () => {
|
|
129
|
+
const calendarBodyEl = yearViewElement.querySelector(
|
|
130
|
+
'.owl-dt-calendar-body'
|
|
131
|
+
);
|
|
132
|
+
dispatchKeyboardEvent(calendarBodyEl, 'keydown', LEFT_ARROW);
|
|
133
|
+
fixture.detectChanges();
|
|
134
|
+
|
|
135
|
+
expect(yearViewInstance.pickerMoment).toEqual(
|
|
136
|
+
new Date(2017, DEC, 5)
|
|
137
|
+
);
|
|
138
|
+
|
|
139
|
+
dispatchKeyboardEvent(calendarBodyEl, 'keydown', LEFT_ARROW);
|
|
140
|
+
fixture.detectChanges();
|
|
141
|
+
|
|
142
|
+
expect(yearViewInstance.pickerMoment).toEqual(
|
|
143
|
+
new Date(2017, NOV, 5)
|
|
144
|
+
);
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
it('should increment month on right arrow press', () => {
|
|
148
|
+
const calendarBodyEl = yearViewElement.querySelector(
|
|
149
|
+
'.owl-dt-calendar-body'
|
|
150
|
+
);
|
|
151
|
+
dispatchKeyboardEvent(calendarBodyEl, 'keydown', RIGHT_ARROW);
|
|
152
|
+
fixture.detectChanges();
|
|
153
|
+
|
|
154
|
+
expect(yearViewInstance.pickerMoment).toEqual(
|
|
155
|
+
new Date(2018, FEB, 5)
|
|
156
|
+
);
|
|
157
|
+
|
|
158
|
+
dispatchKeyboardEvent(calendarBodyEl, 'keydown', RIGHT_ARROW);
|
|
159
|
+
fixture.detectChanges();
|
|
160
|
+
|
|
161
|
+
expect(yearViewInstance.pickerMoment).toEqual(
|
|
162
|
+
new Date(2018, MAR, 5)
|
|
163
|
+
);
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
it('should go up a row on up arrow press', () => {
|
|
167
|
+
const calendarBodyEl = yearViewElement.querySelector(
|
|
168
|
+
'.owl-dt-calendar-body'
|
|
169
|
+
);
|
|
170
|
+
dispatchKeyboardEvent(calendarBodyEl, 'keydown', UP_ARROW);
|
|
171
|
+
fixture.detectChanges();
|
|
172
|
+
|
|
173
|
+
expect(yearViewInstance.pickerMoment).toEqual(
|
|
174
|
+
new Date(2017, OCT, 5)
|
|
175
|
+
);
|
|
176
|
+
|
|
177
|
+
yearViewInstance.pickerMoment = new Date(2018, JUL, 1);
|
|
178
|
+
fixture.detectChanges();
|
|
179
|
+
|
|
180
|
+
dispatchKeyboardEvent(calendarBodyEl, 'keydown', UP_ARROW);
|
|
181
|
+
fixture.detectChanges();
|
|
182
|
+
|
|
183
|
+
expect(yearViewInstance.pickerMoment).toEqual(
|
|
184
|
+
new Date(2018, APR, 1)
|
|
185
|
+
);
|
|
186
|
+
|
|
187
|
+
yearViewInstance.pickerMoment = new Date(2018, DEC, 10);
|
|
188
|
+
fixture.detectChanges();
|
|
189
|
+
|
|
190
|
+
dispatchKeyboardEvent(calendarBodyEl, 'keydown', UP_ARROW);
|
|
191
|
+
fixture.detectChanges();
|
|
192
|
+
|
|
193
|
+
expect(yearViewInstance.pickerMoment).toEqual(
|
|
194
|
+
new Date(2018, SEP, 10)
|
|
195
|
+
);
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
it('should go down a row on down arrow press', () => {
|
|
199
|
+
const calendarBodyEl = yearViewElement.querySelector(
|
|
200
|
+
'.owl-dt-calendar-body'
|
|
201
|
+
);
|
|
202
|
+
dispatchKeyboardEvent(calendarBodyEl, 'keydown', DOWN_ARROW);
|
|
203
|
+
fixture.detectChanges();
|
|
204
|
+
|
|
205
|
+
expect(yearViewInstance.pickerMoment).toEqual(
|
|
206
|
+
new Date(2018, APR, 5)
|
|
207
|
+
);
|
|
208
|
+
|
|
209
|
+
yearViewInstance.pickerMoment = new Date(2018, JUN, 1);
|
|
210
|
+
fixture.detectChanges();
|
|
211
|
+
|
|
212
|
+
dispatchKeyboardEvent(calendarBodyEl, 'keydown', DOWN_ARROW);
|
|
213
|
+
fixture.detectChanges();
|
|
214
|
+
|
|
215
|
+
expect(yearViewInstance.pickerMoment).toEqual(
|
|
216
|
+
new Date(2018, SEP, 1)
|
|
217
|
+
);
|
|
218
|
+
|
|
219
|
+
yearViewInstance.pickerMoment = new Date(2018, SEP, 30);
|
|
220
|
+
fixture.detectChanges();
|
|
221
|
+
|
|
222
|
+
dispatchKeyboardEvent(calendarBodyEl, 'keydown', DOWN_ARROW);
|
|
223
|
+
fixture.detectChanges();
|
|
224
|
+
|
|
225
|
+
expect(yearViewInstance.pickerMoment).toEqual(
|
|
226
|
+
new Date(2018, DEC, 30)
|
|
227
|
+
);
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
it('should go to first month of the year on home press', () => {
|
|
231
|
+
yearViewInstance.pickerMoment = new Date(2018, SEP, 30);
|
|
232
|
+
fixture.detectChanges();
|
|
233
|
+
|
|
234
|
+
const calendarBodyEl = yearViewElement.querySelector(
|
|
235
|
+
'.owl-dt-calendar-body'
|
|
236
|
+
);
|
|
237
|
+
dispatchKeyboardEvent(calendarBodyEl, 'keydown', HOME);
|
|
238
|
+
fixture.detectChanges();
|
|
239
|
+
|
|
240
|
+
expect(yearViewInstance.pickerMoment).toEqual(
|
|
241
|
+
new Date(2018, JAN, 30)
|
|
242
|
+
);
|
|
243
|
+
|
|
244
|
+
dispatchKeyboardEvent(calendarBodyEl, 'keydown', HOME);
|
|
245
|
+
fixture.detectChanges();
|
|
246
|
+
|
|
247
|
+
expect(yearViewInstance.pickerMoment).toEqual(
|
|
248
|
+
new Date(2018, JAN, 30)
|
|
249
|
+
);
|
|
250
|
+
});
|
|
251
|
+
|
|
252
|
+
it('should go to last month of the year on end press', () => {
|
|
253
|
+
yearViewInstance.pickerMoment = new Date(2018, OCT, 31);
|
|
254
|
+
fixture.detectChanges();
|
|
255
|
+
|
|
256
|
+
const calendarBodyEl = yearViewElement.querySelector(
|
|
257
|
+
'.owl-dt-calendar-body'
|
|
258
|
+
);
|
|
259
|
+
dispatchKeyboardEvent(calendarBodyEl, 'keydown', END);
|
|
260
|
+
fixture.detectChanges();
|
|
261
|
+
|
|
262
|
+
expect(yearViewInstance.pickerMoment).toEqual(
|
|
263
|
+
new Date(2018, DEC, 31)
|
|
264
|
+
);
|
|
265
|
+
|
|
266
|
+
dispatchKeyboardEvent(calendarBodyEl, 'keydown', END);
|
|
267
|
+
fixture.detectChanges();
|
|
268
|
+
|
|
269
|
+
expect(yearViewInstance.pickerMoment).toEqual(
|
|
270
|
+
new Date(2018, DEC, 31)
|
|
271
|
+
);
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
it('should go back one year on page up press', () => {
|
|
275
|
+
yearViewInstance.pickerMoment = new Date(2016, FEB, 29);
|
|
276
|
+
fixture.detectChanges();
|
|
277
|
+
|
|
278
|
+
const calendarBodyEl = yearViewElement.querySelector(
|
|
279
|
+
'.owl-dt-calendar-body'
|
|
280
|
+
);
|
|
281
|
+
dispatchKeyboardEvent(calendarBodyEl, 'keydown', PAGE_UP);
|
|
282
|
+
fixture.detectChanges();
|
|
283
|
+
|
|
284
|
+
expect(yearViewInstance.pickerMoment).toEqual(
|
|
285
|
+
new Date(2015, FEB, 28)
|
|
286
|
+
);
|
|
287
|
+
|
|
288
|
+
dispatchKeyboardEvent(calendarBodyEl, 'keydown', PAGE_UP);
|
|
289
|
+
fixture.detectChanges();
|
|
290
|
+
|
|
291
|
+
expect(yearViewInstance.pickerMoment).toEqual(
|
|
292
|
+
new Date(2014, FEB, 28)
|
|
293
|
+
);
|
|
294
|
+
});
|
|
295
|
+
|
|
296
|
+
it('should go forward one year on page down press', () => {
|
|
297
|
+
yearViewInstance.pickerMoment = new Date(2016, FEB, 29);
|
|
298
|
+
fixture.detectChanges();
|
|
299
|
+
|
|
300
|
+
const calendarBodyEl = yearViewElement.querySelector(
|
|
301
|
+
'.owl-dt-calendar-body'
|
|
302
|
+
);
|
|
303
|
+
dispatchKeyboardEvent(calendarBodyEl, 'keydown', PAGE_DOWN);
|
|
304
|
+
fixture.detectChanges();
|
|
305
|
+
|
|
306
|
+
expect(yearViewInstance.pickerMoment).toEqual(
|
|
307
|
+
new Date(2017, FEB, 28)
|
|
308
|
+
);
|
|
309
|
+
|
|
310
|
+
dispatchKeyboardEvent(calendarBodyEl, 'keydown', PAGE_DOWN);
|
|
311
|
+
fixture.detectChanges();
|
|
312
|
+
|
|
313
|
+
expect(yearViewInstance.pickerMoment).toEqual(
|
|
314
|
+
new Date(2018, FEB, 28)
|
|
315
|
+
);
|
|
316
|
+
});
|
|
317
|
+
});
|
|
318
|
+
|
|
319
|
+
describe('year view with date filter', () => {
|
|
320
|
+
let fixture: ComponentFixture<YearViewWithDateFilterComponent>;
|
|
321
|
+
let yearViewNativeElement: Element;
|
|
322
|
+
|
|
323
|
+
beforeEach(() => {
|
|
324
|
+
fixture = TestBed.createComponent(YearViewWithDateFilterComponent);
|
|
325
|
+
fixture.detectChanges();
|
|
326
|
+
|
|
327
|
+
const yearViewDebugElement = fixture.debugElement.query(
|
|
328
|
+
By.directive(OwlYearViewComponent)
|
|
329
|
+
);
|
|
330
|
+
yearViewNativeElement = yearViewDebugElement.nativeElement;
|
|
331
|
+
});
|
|
332
|
+
|
|
333
|
+
it('should disable filtered months', () => {
|
|
334
|
+
const cellJan = yearViewNativeElement.querySelector(
|
|
335
|
+
'[aria-label="January 2018"]'
|
|
336
|
+
);
|
|
337
|
+
const cellFeb = yearViewNativeElement.querySelector(
|
|
338
|
+
'[aria-label="February 2018"]'
|
|
339
|
+
);
|
|
340
|
+
expect(cellJan.classList).not.toContain(
|
|
341
|
+
'owl-dt-calendar-cell-disabled'
|
|
342
|
+
);
|
|
343
|
+
expect(cellFeb.classList).toContain(
|
|
344
|
+
'owl-dt-calendar-cell-disabled'
|
|
345
|
+
);
|
|
346
|
+
});
|
|
347
|
+
});
|
|
348
|
+
});
|
|
349
|
+
|
|
350
|
+
@Component({
|
|
351
|
+
standalone: false,
|
|
352
|
+
template: `
|
|
353
|
+
<owl-date-time-year-view
|
|
354
|
+
[selected]="selected"
|
|
355
|
+
[(pickerMoment)]="pickerMoment"
|
|
356
|
+
(change)="handleChange($event)"></owl-date-time-year-view>
|
|
357
|
+
`
|
|
358
|
+
})
|
|
359
|
+
class StandardYearViewComponent {
|
|
360
|
+
selected = new Date(2018, JAN, 10);
|
|
361
|
+
pickerMoment = new Date(2018, JAN, 5);
|
|
362
|
+
|
|
363
|
+
handleChange(date: Date): void {
|
|
364
|
+
this.pickerMoment = new Date(date);
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
@Component({
|
|
369
|
+
standalone: false,
|
|
370
|
+
template: `
|
|
371
|
+
<owl-date-time-year-view
|
|
372
|
+
[(pickerMoment)]="pickerMoment"
|
|
373
|
+
[dateFilter]="dateFilter"></owl-date-time-year-view>
|
|
374
|
+
`
|
|
375
|
+
})
|
|
376
|
+
class YearViewWithDateFilterComponent {
|
|
377
|
+
pickerMoment = new Date(2018, JAN, 1);
|
|
378
|
+
dateFilter(date: Date) {
|
|
379
|
+
return date.getMonth() !== FEB;
|
|
380
|
+
}
|
|
381
|
+
}
|