@imihai/angular-datetime-picker 22.0.0 → 22.0.8

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.
Files changed (113) hide show
  1. package/assets/style/picker.min.css +1 -0
  2. package/fesm2022/imihai-angular-datetime-picker.mjs +5843 -0
  3. package/fesm2022/imihai-angular-datetime-picker.mjs.map +1 -0
  4. package/imihai-angular-datetime-picker-22.0.8.tgz +0 -0
  5. package/package.json +34 -77
  6. package/types/imihai-angular-datetime-picker.d.ts +2193 -0
  7. package/.browserslistrc +0 -9
  8. package/.editorconfig +0 -13
  9. package/.eslintrc.js +0 -208
  10. package/.github/workflows/ci_test.yml +0 -35
  11. package/.prettierrc +0 -2
  12. package/.travis.yml +0 -16
  13. package/angular.json +0 -221
  14. package/e2e/protractor.conf.js +0 -28
  15. package/e2e/src/app.e2e-spec.ts +0 -14
  16. package/e2e/src/app.po.ts +0 -11
  17. package/e2e/tsconfig.e2e.json +0 -13
  18. package/projects/picker/karma.conf.js +0 -62
  19. package/projects/picker/ng-package.json +0 -7
  20. package/projects/picker/package.json +0 -23
  21. package/projects/picker/src/lib/date-time/adapter/date-time-adapter.class.ts +0 -313
  22. package/projects/picker/src/lib/date-time/adapter/date-time-format.class.ts +0 -18
  23. package/projects/picker/src/lib/date-time/adapter/luxon-date-time-adapter.class.ts +0 -307
  24. package/projects/picker/src/lib/date-time/adapter/luxon-date-time-format.class.ts +0 -11
  25. package/projects/picker/src/lib/date-time/adapter/luxon-date-time.module.ts +0 -31
  26. package/projects/picker/src/lib/date-time/adapter/unix-timestamp-adapter/unix-timestamp-date-time-adapter.class.ts +0 -356
  27. package/projects/picker/src/lib/date-time/adapter/unix-timestamp-adapter/unix-timestamp-date-time-format.class.ts +0 -14
  28. package/projects/picker/src/lib/date-time/adapter/unix-timestamp-adapter/unix-timestamp-date-time.module.ts +0 -26
  29. package/projects/picker/src/lib/date-time/calendar-body.component.html +0 -38
  30. package/projects/picker/src/lib/date-time/calendar-body.component.scss +0 -0
  31. package/projects/picker/src/lib/date-time/calendar-body.component.spec.ts +0 -120
  32. package/projects/picker/src/lib/date-time/calendar-body.component.ts +0 -190
  33. package/projects/picker/src/lib/date-time/calendar-month-view.component.html +0 -47
  34. package/projects/picker/src/lib/date-time/calendar-month-view.component.scss +0 -16
  35. package/projects/picker/src/lib/date-time/calendar-month-view.component.spec.ts +0 -394
  36. package/projects/picker/src/lib/date-time/calendar-month-view.component.ts +0 -705
  37. package/projects/picker/src/lib/date-time/calendar-multi-year-view.component.html +0 -44
  38. package/projects/picker/src/lib/date-time/calendar-multi-year-view.component.scss +0 -0
  39. package/projects/picker/src/lib/date-time/calendar-multi-year-view.component.spec.ts +0 -343
  40. package/projects/picker/src/lib/date-time/calendar-multi-year-view.component.ts +0 -465
  41. package/projects/picker/src/lib/date-time/calendar-year-view.component.html +0 -16
  42. package/projects/picker/src/lib/date-time/calendar-year-view.component.scss +0 -0
  43. package/projects/picker/src/lib/date-time/calendar-year-view.component.spec.ts +0 -381
  44. package/projects/picker/src/lib/date-time/calendar-year-view.component.ts +0 -549
  45. package/projects/picker/src/lib/date-time/calendar.component.html +0 -169
  46. package/projects/picker/src/lib/date-time/calendar.component.scss +0 -0
  47. package/projects/picker/src/lib/date-time/calendar.component.spec.ts +0 -592
  48. package/projects/picker/src/lib/date-time/calendar.component.ts +0 -496
  49. package/projects/picker/src/lib/date-time/date-time-inline.component.html +0 -1
  50. package/projects/picker/src/lib/date-time/date-time-inline.component.scss +0 -4
  51. package/projects/picker/src/lib/date-time/date-time-inline.component.ts +0 -365
  52. package/projects/picker/src/lib/date-time/date-time-picker-animation-event.ts +0 -4
  53. package/projects/picker/src/lib/date-time/date-time-picker-container.component.html +0 -126
  54. package/projects/picker/src/lib/date-time/date-time-picker-container.component.scss +0 -0
  55. package/projects/picker/src/lib/date-time/date-time-picker-container.component.ts +0 -631
  56. package/projects/picker/src/lib/date-time/date-time-picker-input.directive.ts +0 -851
  57. package/projects/picker/src/lib/date-time/date-time-picker-intl.service.ts +0 -76
  58. package/projects/picker/src/lib/date-time/date-time-picker-trigger.directive.ts +0 -88
  59. package/projects/picker/src/lib/date-time/date-time-picker.component.html +0 -0
  60. package/projects/picker/src/lib/date-time/date-time-picker.component.scss +0 -0
  61. package/projects/picker/src/lib/date-time/date-time-picker.component.spec.ts +0 -2648
  62. package/projects/picker/src/lib/date-time/date-time-picker.component.ts +0 -731
  63. package/projects/picker/src/lib/date-time/date-time.class.ts +0 -256
  64. package/projects/picker/src/lib/date-time/date-time.module.ts +0 -61
  65. package/projects/picker/src/lib/date-time/numberedFixLen.pipe.ts +0 -28
  66. package/projects/picker/src/lib/date-time/options-provider.ts +0 -44
  67. package/projects/picker/src/lib/date-time/timer-box.component.html +0 -79
  68. package/projects/picker/src/lib/date-time/timer-box.component.scss +0 -0
  69. package/projects/picker/src/lib/date-time/timer-box.component.ts +0 -175
  70. package/projects/picker/src/lib/date-time/timer.component.html +0 -58
  71. package/projects/picker/src/lib/date-time/timer.component.scss +0 -0
  72. package/projects/picker/src/lib/date-time/timer.component.spec.ts +0 -399
  73. package/projects/picker/src/lib/date-time/timer.component.ts +0 -371
  74. package/projects/picker/src/lib/dialog/dialog-config.class.ts +0 -220
  75. package/projects/picker/src/lib/dialog/dialog-container.component.html +0 -1
  76. package/projects/picker/src/lib/dialog/dialog-container.component.scss +0 -0
  77. package/projects/picker/src/lib/dialog/dialog-container.component.ts +0 -231
  78. package/projects/picker/src/lib/dialog/dialog-ref.class.ts +0 -178
  79. package/projects/picker/src/lib/dialog/dialog.module.ts +0 -25
  80. package/projects/picker/src/lib/dialog/dialog.service.ts +0 -353
  81. package/projects/picker/src/lib/utils/array.utils.ts +0 -12
  82. package/projects/picker/src/lib/utils/constants.ts +0 -59
  83. package/projects/picker/src/lib/utils/date.utils.ts +0 -97
  84. package/projects/picker/src/lib/utils/index.ts +0 -5
  85. package/projects/picker/src/lib/utils/object.utils.ts +0 -29
  86. package/projects/picker/src/public_api.ts +0 -56
  87. package/projects/picker/src/sass/picker.scss +0 -743
  88. package/projects/picker/src/test-helpers.ts +0 -125
  89. package/projects/picker/src/test.ts +0 -52
  90. package/projects/picker/tsconfig.lib.json +0 -19
  91. package/projects/picker/tsconfig.lib.prod.json +0 -7
  92. package/projects/picker/tsconfig.spec.json +0 -17
  93. package/projects/picker/tslint.json +0 -8
  94. package/src/app/app.component.html +0 -77
  95. package/src/app/app.component.scss +0 -32
  96. package/src/app/app.component.spec.ts +0 -16
  97. package/src/app/app.component.ts +0 -35
  98. package/src/assets/.gitkeep +0 -0
  99. package/src/environments/environment.prod.ts +0 -3
  100. package/src/environments/environment.ts +0 -16
  101. package/src/favicon.ico +0 -0
  102. package/src/index.html +0 -14
  103. package/src/karma.conf.js +0 -31
  104. package/src/main.ts +0 -16
  105. package/src/polyfills.ts +0 -53
  106. package/src/styles.scss +0 -7
  107. package/src/test.ts +0 -50
  108. package/src/tsconfig.app.json +0 -16
  109. package/src/tsconfig.spec.json +0 -18
  110. package/src/tslint.json +0 -17
  111. package/tsconfig.base.json +0 -31
  112. package/tsconfig.json +0 -30
  113. package/tslint.json +0 -130
@@ -1,399 +0,0 @@
1
- /**
2
- * timer.component.spec
3
- */
4
-
5
- import { EventEmitter } from '@angular/core';
6
- import {
7
- ComponentFixture,
8
- fakeAsync,
9
- flush,
10
- TestBed
11
- } from '@angular/core/testing';
12
- import { OwlDateTimeIntl } from './date-time-picker-intl.service';
13
- import { Component, DebugElement, NgZone } from '@angular/core';
14
- import { discardPeriodicTasks } from '@angular/core/testing';
15
- import { OwlNativeDateTimeModule } from './adapter/native-date-time.module';
16
- import { OwlDateTimeModule } from './date-time.module';
17
- import { By } from '@angular/platform-browser';
18
- import { OwlTimerComponent } from './timer.component';
19
- import { dispatchFakeEvent } from '../../test-helpers';
20
-
21
- const JAN = 0,
22
- FEB = 1,
23
- MAR = 2,
24
- APR = 3,
25
- MAY = 4,
26
- JUN = 5,
27
- JUL = 6,
28
- AUG = 7,
29
- SEP = 8,
30
- OCT = 9,
31
- NOV = 10,
32
- DEC = 11;
33
-
34
- class MockNgZone extends NgZone {
35
- onStable: EventEmitter<any> = new EventEmitter(false);
36
- constructor() {
37
- super({ enableLongStackTrace: false });
38
- }
39
- run(fn: Function): any {
40
- return fn();
41
- }
42
- runOutsideAngular(fn: Function): any {
43
- return fn();
44
- }
45
- simulateZoneExit(): void {
46
- this.onStable.emit(null);
47
- }
48
- }
49
-
50
- describe('OwlTimerComponent', () => {
51
- let zone: MockNgZone;
52
-
53
- beforeEach(() => {
54
- TestBed.configureTestingModule({
55
- imports: [OwlNativeDateTimeModule, OwlDateTimeModule],
56
- declarations: [StandardTimerComponent],
57
- providers: [
58
- OwlDateTimeIntl,
59
- { provide: NgZone, useFactory: () => (zone = new MockNgZone()) }
60
- ]
61
- }).compileComponents();
62
- });
63
-
64
- describe('standard timer', () => {
65
- let fixture: ComponentFixture<StandardTimerComponent>;
66
- let testComponent: StandardTimerComponent;
67
- let timerDebugElement: DebugElement;
68
- let timerElement: HTMLElement;
69
- let timerInstance: OwlTimerComponent<Date>;
70
-
71
- beforeEach(() => {
72
- fixture = TestBed.createComponent(StandardTimerComponent);
73
- fixture.detectChanges();
74
-
75
- timerDebugElement = fixture.debugElement.query(
76
- By.directive(OwlTimerComponent)
77
- );
78
- timerElement = timerDebugElement.nativeElement;
79
- testComponent = fixture.componentInstance;
80
- timerInstance = timerDebugElement.componentInstance;
81
- });
82
-
83
- it('should have two timer boxes if showSecondsTimer set to false', () => {
84
- const timerBoxes = timerElement.querySelectorAll(
85
- 'owl-date-time-timer-box'
86
- );
87
- expect(timerInstance.showSecondsTimer).toBeFalsy();
88
- expect(timerBoxes.length).toBe(2);
89
- });
90
-
91
- it('should have three timer boxes if showSecondsTimer set to true', () => {
92
- testComponent.showSecondsTimer = true;
93
- fixture.detectChanges();
94
-
95
- const timerBoxes = timerElement.querySelectorAll(
96
- 'owl-date-time-timer-box'
97
- );
98
- expect(timerInstance.showSecondsTimer).toBeTruthy();
99
- expect(timerBoxes.length).toBe(3);
100
- });
101
-
102
- it('should NOT have the hour12 toggle button if hour12Timer set to false', () => {
103
- const toggleBtn = timerElement.querySelector(
104
- 'button.owl-dt-timer-hour12-box'
105
- );
106
- expect(timerInstance.hour12Timer).toBeFalsy();
107
- expect(toggleBtn).toBeFalsy();
108
- });
109
-
110
- it('should have the hour12 toggle button if hour12Timer set to true', () => {
111
- testComponent.hour12Timer = true;
112
- fixture.detectChanges();
113
-
114
- const toggleBtn = timerElement.querySelector(
115
- 'button.owl-dt-timer-hour12-box'
116
- );
117
- expect(timerInstance.hour12Timer).toBeTruthy();
118
- expect(toggleBtn).toBeTruthy();
119
- });
120
-
121
- it('should dispatch an event when a timer arrow button clicked', fakeAsync(() => {
122
- spyOn(testComponent, 'handleSelectedChange');
123
- expect(testComponent.handleSelectedChange).not.toHaveBeenCalled();
124
-
125
- testComponent.showSecondsTimer = true;
126
- fixture.detectChanges();
127
-
128
- const arrowBtns = timerElement.querySelectorAll<HTMLButtonElement>(
129
- 'button.owl-dt-control-arrow-button'
130
- );
131
- expect(arrowBtns.length).toBe(6);
132
-
133
- for (let i = 0; i < arrowBtns.length; i++) {
134
- arrowBtns[i].click();
135
- fixture.detectChanges();
136
- flush();
137
- }
138
-
139
- expect(testComponent.handleSelectedChange).toHaveBeenCalledTimes(6);
140
- }));
141
-
142
- it('should dispatch an event when hour12 toggle button clicked', fakeAsync(() => {
143
- spyOn(testComponent, 'handleSelectedChange');
144
- expect(testComponent.handleSelectedChange).not.toHaveBeenCalled();
145
-
146
- testComponent.hour12Timer = true;
147
- fixture.detectChanges();
148
-
149
- const toggleBtn = timerElement.querySelector<HTMLButtonElement>(
150
- 'button.owl-dt-timer-hour12-box'
151
- );
152
-
153
- toggleBtn.click();
154
- fixture.detectChanges();
155
- flush();
156
-
157
- expect(testComponent.handleSelectedChange).toHaveBeenCalledTimes(1);
158
- }));
159
-
160
- it('should add or minus stepHour hours when hour arrow button clicked', fakeAsync(() => {
161
- expect(timerInstance.stepHour).toBe(1);
162
-
163
- const arrowBtns = timerElement.querySelectorAll<HTMLButtonElement>(
164
- 'button.owl-dt-control-arrow-button'
165
- );
166
- expect(arrowBtns.length).toBe(4);
167
-
168
- arrowBtns[0].click();
169
- fixture.detectChanges();
170
- flush();
171
- expect(testComponent.pickerMoment).toEqual(
172
- new Date(2018, JAN, 31, 13, 30, 30)
173
- );
174
-
175
- arrowBtns[1].click();
176
- fixture.detectChanges();
177
- flush();
178
- expect(testComponent.pickerMoment).toEqual(
179
- new Date(2018, JAN, 31, 12, 30, 30)
180
- );
181
-
182
- testComponent.stepHour = 2;
183
- fixture.detectChanges();
184
- expect(timerInstance.stepHour).toBe(2);
185
-
186
- arrowBtns[0].click();
187
- fixture.detectChanges();
188
- flush();
189
- expect(testComponent.pickerMoment).toEqual(
190
- new Date(2018, JAN, 31, 14, 30, 30)
191
- );
192
-
193
- arrowBtns[1].click();
194
- fixture.detectChanges();
195
- flush();
196
- expect(testComponent.pickerMoment).toEqual(
197
- new Date(2018, JAN, 31, 12, 30, 30)
198
- );
199
- }));
200
-
201
- it('should add or minus stepMinute minutes when minute arrow button clicked', fakeAsync(() => {
202
- expect(timerInstance.stepMinute).toBe(1);
203
-
204
- const arrowBtns = timerElement.querySelectorAll<HTMLButtonElement>(
205
- 'button.owl-dt-control-arrow-button'
206
- );
207
- expect(arrowBtns.length).toBe(4);
208
-
209
- arrowBtns[2].click();
210
- fixture.detectChanges();
211
- flush();
212
- expect(testComponent.pickerMoment).toEqual(
213
- new Date(2018, JAN, 31, 12, 31, 30)
214
- );
215
-
216
- arrowBtns[3].click();
217
- fixture.detectChanges();
218
- flush();
219
- expect(testComponent.pickerMoment).toEqual(
220
- new Date(2018, JAN, 31, 12, 30, 30)
221
- );
222
-
223
- testComponent.stepMinute = 2;
224
- fixture.detectChanges();
225
- expect(timerInstance.stepMinute).toBe(2);
226
-
227
- arrowBtns[2].click();
228
- fixture.detectChanges();
229
- flush();
230
- expect(testComponent.pickerMoment).toEqual(
231
- new Date(2018, JAN, 31, 12, 32, 30)
232
- );
233
-
234
- arrowBtns[3].click();
235
- fixture.detectChanges();
236
- flush();
237
- expect(testComponent.pickerMoment).toEqual(
238
- new Date(2018, JAN, 31, 12, 30, 30)
239
- );
240
- }));
241
-
242
- it('should add or minus stepSecond seconds when second arrow button clicked', fakeAsync(() => {
243
- expect(timerInstance.stepSecond).toBe(1);
244
-
245
- testComponent.showSecondsTimer = true;
246
- fixture.detectChanges();
247
- const arrowBtns = timerElement.querySelectorAll<HTMLButtonElement>(
248
- 'button.owl-dt-control-arrow-button'
249
- );
250
- expect(arrowBtns.length).toBe(6);
251
-
252
- arrowBtns[4].click();
253
- fixture.detectChanges();
254
- flush();
255
- expect(testComponent.pickerMoment).toEqual(
256
- new Date(2018, JAN, 31, 12, 30, 31)
257
- );
258
-
259
- arrowBtns[5].click();
260
- fixture.detectChanges();
261
- flush();
262
- expect(testComponent.pickerMoment).toEqual(
263
- new Date(2018, JAN, 31, 12, 30, 30)
264
- );
265
-
266
- testComponent.stepSecond = 2;
267
- fixture.detectChanges();
268
- expect(timerInstance.stepSecond).toBe(2);
269
-
270
- arrowBtns[4].click();
271
- fixture.detectChanges();
272
- flush();
273
- expect(testComponent.pickerMoment).toEqual(
274
- new Date(2018, JAN, 31, 12, 30, 32)
275
- );
276
-
277
- arrowBtns[5].click();
278
- fixture.detectChanges();
279
- flush();
280
- expect(testComponent.pickerMoment).toEqual(
281
- new Date(2018, JAN, 31, 12, 30, 30)
282
- );
283
- }));
284
-
285
- it('should toggle between PM and AM when hour12 toggle button clicked', fakeAsync(() => {
286
- testComponent.hour12Timer = true;
287
- fixture.detectChanges();
288
-
289
- const toggleBtn = timerElement.querySelector<HTMLButtonElement>(
290
- 'button.owl-dt-timer-hour12-box'
291
- );
292
- expect(toggleBtn.innerHTML).toContain('PM');
293
-
294
- toggleBtn.click();
295
- fixture.detectChanges();
296
- flush();
297
-
298
- expect(toggleBtn.innerHTML).toContain('AM');
299
- expect(testComponent.pickerMoment).toEqual(
300
- new Date(2018, JAN, 31, 0, 30, 30)
301
- );
302
- }));
303
-
304
- it('should disable all down arrow button if pickerMoment equals to minDateTime', () => {
305
- testComponent.showSecondsTimer = true;
306
- fixture.detectChanges();
307
- const arrowBtns = timerElement.querySelectorAll<HTMLButtonElement>(
308
- 'button.owl-dt-control-arrow-button'
309
- );
310
- expect(arrowBtns.length).toBe(6);
311
-
312
- testComponent.pickerMoment = new Date(testComponent.minDateTime);
313
- fixture.detectChanges();
314
-
315
- // up arrow buttons
316
- expect(arrowBtns[0].hasAttribute('disabled')).toBe(false);
317
- expect(arrowBtns[2].hasAttribute('disabled')).toBe(false);
318
- expect(arrowBtns[4].hasAttribute('disabled')).toBe(false);
319
-
320
- // down arrow buttons
321
- expect(arrowBtns[1].hasAttribute('disabled')).toBe(true);
322
- expect(arrowBtns[3].hasAttribute('disabled')).toBe(true);
323
- expect(arrowBtns[5].hasAttribute('disabled')).toBe(true);
324
- });
325
-
326
- it('should disable all up arrow button if pickerMoment equals to maxDateTime', () => {
327
- testComponent.showSecondsTimer = true;
328
- fixture.detectChanges();
329
- const arrowBtns = timerElement.querySelectorAll<HTMLButtonElement>(
330
- 'button.owl-dt-control-arrow-button'
331
- );
332
- expect(arrowBtns.length).toBe(6);
333
-
334
- testComponent.pickerMoment = new Date(testComponent.maxDateTime);
335
- fixture.detectChanges();
336
-
337
- // up arrow buttons
338
- expect(arrowBtns[0].hasAttribute('disabled')).toBe(true);
339
- expect(arrowBtns[2].hasAttribute('disabled')).toBe(true);
340
- expect(arrowBtns[4].hasAttribute('disabled')).toBe(true);
341
-
342
- // down arrow buttons
343
- expect(arrowBtns[1].hasAttribute('disabled')).toBe(false);
344
- expect(arrowBtns[3].hasAttribute('disabled')).toBe(false);
345
- expect(arrowBtns[5].hasAttribute('disabled')).toBe(false);
346
- });
347
-
348
- it('should not reformat input text while field is focused', fakeAsync(() => {
349
- const timeCells = timerElement.querySelectorAll<HTMLInputElement>('.owl-dt-timer-input');
350
-
351
- dispatchFakeEvent(timeCells[0], 'focusin');
352
- timeCells[0].value = '5';
353
- dispatchFakeEvent(timeCells[0], 'input');
354
- setTimeout(() => { }, 1000);
355
-
356
- timeCells[1].value = '8';
357
- dispatchFakeEvent(timeCells[1], 'input');
358
- setTimeout(() => { }, 1000);
359
-
360
- fixture.detectChanges();
361
-
362
- expect(timeCells[0].value).toEqual('5');
363
- expect(timeCells[1].value).toEqual('8');
364
-
365
-
366
- flush();
367
- }));
368
- });
369
- });
370
-
371
- @Component({
372
- standalone: false,
373
- template: `
374
- <owl-date-time-timer
375
- [hour12Timer]="hour12Timer"
376
- [showSecondsTimer]="showSecondsTimer"
377
- [pickerMoment]="pickerMoment"
378
- [stepHour]="stepHour"
379
- [stepMinute]="stepMinute"
380
- [stepSecond]="stepSecond"
381
- [minDateTime]="minDateTime"
382
- [maxDateTime]="maxDateTime"
383
- (selectedChange)="handleSelectedChange($event)"></owl-date-time-timer>
384
- `
385
- })
386
- class StandardTimerComponent {
387
- stepHour = 1;
388
- stepMinute = 1;
389
- stepSecond = 1;
390
- hour12Timer = false;
391
- showSecondsTimer = false;
392
- pickerMoment = new Date(2018, JAN, 31, 12, 30, 30);
393
- minDateTime = new Date(2018, JAN, 29, 12, 30, 30);
394
- maxDateTime = new Date(2018, FEB, 1, 12, 30, 30);
395
-
396
- handleSelectedChange(val: Date) {
397
- this.pickerMoment = val;
398
- }
399
- }