ngx-animating-datepicker 1.2.0 → 2.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.
Files changed (56) hide show
  1. package/README.md +33 -1
  2. package/fesm2022/ngx-animating-datepicker.mjs +1534 -0
  3. package/fesm2022/ngx-animating-datepicker.mjs.map +1 -0
  4. package/package.json +32 -17
  5. package/types/ngx-animating-datepicker.d.ts +551 -0
  6. package/bundles/ngx-animating-datepicker.umd.js +0 -2594
  7. package/bundles/ngx-animating-datepicker.umd.js.map +0 -1
  8. package/bundles/ngx-animating-datepicker.umd.min.js +0 -2
  9. package/bundles/ngx-animating-datepicker.umd.min.js.map +0 -1
  10. package/esm2015/lib/components/animatepicker/animatepicker.component.js +0 -468
  11. package/esm2015/lib/components/datepicker/datepicker.component.js +0 -703
  12. package/esm2015/lib/components/datepicker/datepicker.directive.js +0 -408
  13. package/esm2015/lib/components/datepicker/datepicker.options.js +0 -41
  14. package/esm2015/lib/components/navigation/navigation.component.js +0 -233
  15. package/esm2015/lib/components/sub-navigation/sub-navigation.component.js +0 -48
  16. package/esm2015/lib/models/datepicker-options.model.js +0 -35
  17. package/esm2015/lib/models/datepicker.model.js +0 -75
  18. package/esm2015/lib/models/directive-options.model.js +0 -19
  19. package/esm2015/lib/ngx-animating-datepicker.module.js +0 -35
  20. package/esm2015/lib/services/datepicker.service.js +0 -161
  21. package/esm2015/lib/services/utilities.service.js +0 -56
  22. package/esm2015/ngx-animating-datepicker.js +0 -13
  23. package/esm2015/public_api.js +0 -8
  24. package/esm5/lib/components/animatepicker/animatepicker.component.js +0 -574
  25. package/esm5/lib/components/datepicker/datepicker.component.js +0 -928
  26. package/esm5/lib/components/datepicker/datepicker.directive.js +0 -499
  27. package/esm5/lib/components/datepicker/datepicker.options.js +0 -41
  28. package/esm5/lib/components/navigation/navigation.component.js +0 -298
  29. package/esm5/lib/components/sub-navigation/sub-navigation.component.js +0 -48
  30. package/esm5/lib/models/datepicker-options.model.js +0 -35
  31. package/esm5/lib/models/datepicker.model.js +0 -75
  32. package/esm5/lib/models/directive-options.model.js +0 -19
  33. package/esm5/lib/ngx-animating-datepicker.module.js +0 -39
  34. package/esm5/lib/services/datepicker.service.js +0 -307
  35. package/esm5/lib/services/utilities.service.js +0 -73
  36. package/esm5/ngx-animating-datepicker.js +0 -13
  37. package/esm5/public_api.js +0 -8
  38. package/fesm2015/ngx-animating-datepicker.js +0 -1886
  39. package/fesm2015/ngx-animating-datepicker.js.map +0 -1
  40. package/fesm5/ngx-animating-datepicker.js +0 -2529
  41. package/fesm5/ngx-animating-datepicker.js.map +0 -1
  42. package/lib/components/animatepicker/animatepicker.component.d.ts +0 -112
  43. package/lib/components/datepicker/datepicker.component.d.ts +0 -191
  44. package/lib/components/datepicker/datepicker.directive.d.ts +0 -92
  45. package/lib/components/datepicker/datepicker.options.d.ts +0 -20
  46. package/lib/components/navigation/navigation.component.d.ts +0 -52
  47. package/lib/components/sub-navigation/sub-navigation.component.d.ts +0 -8
  48. package/lib/models/datepicker-options.model.d.ts +0 -14
  49. package/lib/models/datepicker.model.d.ts +0 -29
  50. package/lib/models/directive-options.model.d.ts +0 -6
  51. package/lib/ngx-animating-datepicker.module.d.ts +0 -2
  52. package/lib/services/datepicker.service.d.ts +0 -77
  53. package/lib/services/utilities.service.d.ts +0 -12
  54. package/ngx-animating-datepicker.d.ts +0 -8
  55. package/ngx-animating-datepicker.metadata.json +0 -1
  56. package/public_api.d.ts +0 -5
@@ -0,0 +1,1534 @@
1
+ import * as i2 from '@angular/common';
2
+ import { CommonModule } from '@angular/common';
3
+ import * as i0 from '@angular/core';
4
+ import { Injectable, EventEmitter, HostBinding, Input, Output, Component, ViewChild, createComponent, HostListener, Optional, Directive, NgModule } from '@angular/core';
5
+ import * as i1 from '@angular/forms';
6
+
7
+ class DatepickerService {
8
+ /**
9
+ * Get the formatted weekdays
10
+ *
11
+ * @param language
12
+ * @param format
13
+ * @param start
14
+ */
15
+ static getWeekDays(language, format, start) {
16
+ const days = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday'];
17
+ const index = days.indexOf(start.toLowerCase());
18
+ if (index < 0) {
19
+ throw new Error('Invalid week day start: ' + start);
20
+ }
21
+ const weekdays = [];
22
+ for (let day = 5; day <= 11; day++) {
23
+ weekdays.push(new Date(1970, 1 - 1, day + index).toLocaleString(language, {
24
+ weekday: format
25
+ }));
26
+ }
27
+ return weekdays;
28
+ }
29
+ /**
30
+ * Checks if is a value iso code
31
+ *
32
+ * @param isoCode
33
+ */
34
+ static isValidIsoCode(isoCode) {
35
+ const pattern = new RegExp(/([a-z]{2})-([A-Z]{2})/);
36
+ return pattern.test(isoCode);
37
+ }
38
+ /**
39
+ * Create a week array from the merged day arrays
40
+ *
41
+ * @param dayArray
42
+ */
43
+ static createWeekArray(dayArray) {
44
+ const size = 7;
45
+ const weeks = [];
46
+ while (dayArray.length) {
47
+ weeks.push({
48
+ days: dayArray.splice(0, size)
49
+ });
50
+ }
51
+ return weeks;
52
+ }
53
+ static getDaysInMonth(year, month) {
54
+ return [31, DatepickerService.isLeapYear(year) ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month];
55
+ }
56
+ static isValidDate(value) {
57
+ let validDate = true;
58
+ for (let i = 0; i < value.length; i++) {
59
+ if (!DatepickerService.isDate(value[i]) && validDate) {
60
+ validDate = false;
61
+ }
62
+ }
63
+ return validDate;
64
+ }
65
+ /**
66
+ * Check if year is a leap year
67
+ *
68
+ * @param year
69
+ */
70
+ static isLeapYear(year) {
71
+ return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;
72
+ }
73
+ /**
74
+ * Checks to see if value is a valid date
75
+ *
76
+ * @param value
77
+ */
78
+ static isDate(value) {
79
+ return value instanceof Date;
80
+ }
81
+ /**
82
+ * Get the year of the next month
83
+ *
84
+ * @param year
85
+ * @param month
86
+ */
87
+ static getYearOfNextMonth(year, month) {
88
+ return month === 11 ? year + 1 : year;
89
+ }
90
+ /**
91
+ * Get the next month
92
+ *
93
+ * @param month
94
+ */
95
+ static getNextMonth(month) {
96
+ return month === 11 ? 0 : month + 1;
97
+ }
98
+ /**
99
+ * Get the year of the previous month
100
+ *
101
+ * @param year
102
+ * @param month
103
+ */
104
+ static getYearOfPreviousMonth(year, month) {
105
+ return month === 0 ? year - 1 : year;
106
+ }
107
+ /**
108
+ * Get previous motnh
109
+ *
110
+ * @param month
111
+ */
112
+ static getPreviousMonth(month) {
113
+ return month === 0 ? 11 : month - 1;
114
+ }
115
+ /**
116
+ * Check if a date is later
117
+ *
118
+ * @param date
119
+ * @param compareDate
120
+ */
121
+ static isLater(date, compareDate) {
122
+ return date > compareDate;
123
+ }
124
+ /**
125
+ * Check if a date is ealrier
126
+ *
127
+ * @param date
128
+ * @param compareDate
129
+ */
130
+ static isEarlier(date, compareDate) {
131
+ return date < compareDate;
132
+ }
133
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.15", ngImport: i0, type: DatepickerService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
134
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.15", ngImport: i0, type: DatepickerService, providedIn: 'root' });
135
+ }
136
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.15", ngImport: i0, type: DatepickerService, decorators: [{
137
+ type: Injectable,
138
+ args: [{ providedIn: 'root' }]
139
+ }] });
140
+
141
+ const DefaultOptions = {
142
+ selectMultiple: false, // Select multiple dates
143
+ closeOnSelect: false, // Close datepicker when date(s) selected
144
+ animationSpeed: 400, // Animation speed in ms
145
+ easing: 'ease-in', // Easing type string
146
+ hideRestDays: false, // Hide the rest days
147
+ disableRestDays: true, // Disable the click on rest days
148
+ hideNavigation: false, // Hide the navigation
149
+ range: false, // Use range functionality
150
+ currentDate: new Date(), // Tne current displayed date (month, year)
151
+ timeoutBeforeClosing: 300, // The timeout / delay before closing
152
+ weekdayFormat: 'short', // "narrow", "short", "long"
153
+ weekStart: 'monday' // Set the week start day
154
+ };
155
+ const DefaultDirectiveOptions = {
156
+ appendToBody: true, // Append Datepicker to body
157
+ openDirection: 'bottom', // The direction it should open to
158
+ closeOnBlur: true, // Close the datepicker onBlur
159
+ useAnimatePicker: true // Use the animatepickerComponent
160
+ };
161
+
162
+ class UtilitiesService {
163
+ static getScrollOffset() {
164
+ const x = window.pageXOffset || document.documentElement.scrollLeft;
165
+ const y = window.pageYOffset || document.documentElement.scrollTop;
166
+ return { x: x, y: y };
167
+ }
168
+ static getPageOffset(el) {
169
+ const scrollOffset = UtilitiesService.getScrollOffset();
170
+ const width = el.offsetWidth;
171
+ const height = el.offsetHeight;
172
+ if (el.getBoundingClientRect) {
173
+ const props = el.getBoundingClientRect();
174
+ const position = {
175
+ top: props.top + scrollOffset.y,
176
+ left: props.left + scrollOffset.x,
177
+ right: props.left + scrollOffset.x + width,
178
+ bottom: props.top + scrollOffset.y + height,
179
+ forRight: window.innerWidth - props.left,
180
+ forBottom: window.innerHeight - (props.top + scrollOffset.y)
181
+ };
182
+ return position;
183
+ }
184
+ return {
185
+ top: 0,
186
+ left: 0,
187
+ right: width,
188
+ bottom: height,
189
+ forRight: window.innerWidth,
190
+ forBottom: window.innerHeight
191
+ };
192
+ }
193
+ createArray(start, end) {
194
+ return new Array(end - start + 1).fill(1).map((_, idx) => start + idx);
195
+ }
196
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.15", ngImport: i0, type: UtilitiesService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
197
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.15", ngImport: i0, type: UtilitiesService, providedIn: 'root' });
198
+ }
199
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.15", ngImport: i0, type: UtilitiesService, decorators: [{
200
+ type: Injectable,
201
+ args: [{ providedIn: 'root' }]
202
+ }] });
203
+
204
+ class NavigationComponent {
205
+ previousClick = new EventEmitter();
206
+ nextClick = new EventEmitter();
207
+ subNavigationClick = new EventEmitter();
208
+ monthFormat = 'long'; // "narrow", "short", "long";
209
+ set language(language) {
210
+ this.formatMonth = new Intl.DateTimeFormat(language, {
211
+ month: this.monthFormat
212
+ });
213
+ this._language = language;
214
+ if (this.initialised) {
215
+ this.titles = this.createNavigationItems(this._totalYearMonth);
216
+ }
217
+ }
218
+ get language() {
219
+ return this._language;
220
+ }
221
+ _totalYearMonth;
222
+ set totalYearMonth(totalYearMonth) {
223
+ this._totalYearMonth = totalYearMonth;
224
+ this.titles = this.createNavigationItems(totalYearMonth);
225
+ }
226
+ transition;
227
+ translateX;
228
+ leftPosition;
229
+ hideNavigation;
230
+ animate = false;
231
+ _language;
232
+ initialised = false;
233
+ formatMonth;
234
+ subNavigationOpen = false;
235
+ navigationItems;
236
+ titles;
237
+ ngOnInit() {
238
+ this.initialised = true;
239
+ }
240
+ onMonthClick(title) {
241
+ const monthArray = this.createMonthArray(title);
242
+ const formatMonth = new Intl.DateTimeFormat(this.language, { month: 'short' });
243
+ this.navigationItems = this.createNavigationItems(monthArray, true, formatMonth);
244
+ this.toggleSubNavigation();
245
+ }
246
+ onYearClick(title) {
247
+ this.navigationItems = this.createYearArray(title);
248
+ this.toggleSubNavigation();
249
+ }
250
+ toggleSubNavigation() {
251
+ this.subNavigationOpen = !this.subNavigationOpen;
252
+ }
253
+ /**
254
+ * Sets the title
255
+ *
256
+ * @param totalMonthYear
257
+ * @param monthType
258
+ * @param formatMonth
259
+ * @returns NavigationItem[]
260
+ */
261
+ createNavigationItems(totalMonthYear, monthType = true, formatMonth = null) {
262
+ const _formatMonth = formatMonth || this.formatMonth;
263
+ // TODO: copy the object / remove the reference
264
+ return totalMonthYear.map(s => {
265
+ const date = new Date(s.year, s.month);
266
+ s.navigationTitle = monthType ? _formatMonth.format(date) : s.year;
267
+ return s;
268
+ });
269
+ }
270
+ createMonthArray(navigationItem) {
271
+ const months = [], currentYear = navigationItem.year;
272
+ for (let i = 0; i < 11; i++) {
273
+ months.push({ month: i, year: currentYear });
274
+ }
275
+ return months;
276
+ }
277
+ /**
278
+ * Create an array of navigation items with year as label
279
+ *
280
+ * @param navigationItem
281
+ * @returns NavigationItem[]
282
+ */
283
+ createYearArray(navigationItem) {
284
+ const currentYear = navigationItem.year, years = [{ ...navigationItem, navigationTitle: currentYear }];
285
+ for (let i = 0; i < 5; i++) {
286
+ years.unshift({ ...navigationItem, navigationTitle: currentYear - (i + 1) });
287
+ years.push({ ...navigationItem, navigationTitle: currentYear + (i + 1) });
288
+ }
289
+ return years;
290
+ }
291
+ onSubNavigationClick(date) {
292
+ this.subNavigationClick.emit(date);
293
+ }
294
+ /**
295
+ * Emits previous click event
296
+ */
297
+ previous() {
298
+ this.previousClick.emit();
299
+ }
300
+ /**
301
+ * Emits next click event
302
+ */
303
+ next() {
304
+ this.nextClick.emit();
305
+ }
306
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.15", ngImport: i0, type: NavigationComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
307
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "21.2.15", type: NavigationComponent, isStandalone: false, selector: "aa-navigation", inputs: { monthFormat: "monthFormat", language: "language", totalYearMonth: "totalYearMonth", transition: "transition", translateX: "translateX", leftPosition: "leftPosition", hideNavigation: "hideNavigation", animate: "animate" }, outputs: { previousClick: "previousClick", nextClick: "nextClick", subNavigationClick: "subNavigationClick" }, host: { properties: { "class.is-animate": "this.animate" } }, ngImport: i0, template: "<button *ngIf=\"!hideNavigation\" class=\"navigation__button is-previous\" (click)=\"previous()\"></button>\n<div class=\"navigation__title-wrapper\" [ngStyle]=\"{\n 'transform': 'translateX(' + translateX + '%)',\n 'transition': transition,\n 'left.%': leftPosition\n}\">\n <div *ngFor=\"let title of titles\"\n class=\"navigation__title\"\n [ngStyle]=\"{\n 'width.%': (100 / titles.length)\n }\"\n ><span (click)=\"onMonthClick(title)\">{{title.navigationTitle}}</span>&nbsp;<span (click)=\"onYearClick(title)\">{{title.year}}</span></div>\n</div>\n<button *ngIf=\"!hideNavigation\" class=\"navigation__button is-next\" (click)=\"next()\"></button>", styles: [":host:before,:host:after{content:\" \";display:table}:host:after{clear:both}:host{display:block;padding:10px;height:52px}:host .navigation__title-wrapper{position:absolute;left:0;width:100%}:host .navigation__title{width:100%;font-weight:700;text-align:center;float:left;line-height:2.2rem}:host .navigation__button{padding:0;background-color:transparent;border:none;outline:none;font-style:inherit;cursor:pointer;position:relative;z-index:1;background-color:#fff;border:1px solid rgb(192.1130434783,191.5565217391,189.8869565217);text-align:center;width:32px;height:32px;border-radius:4px}:host .navigation__button:hover{border-color:#8e8d8a}:host .navigation__button.is-previous{float:left}:host .navigation__button.is-previous:after{content:\"<\"}:host .navigation__button.is-next:before{content:\">\"}:host .navigation__button.is-next{float:right}:host.is-animate .navigation__title-wrapper{width:200%}\n"], dependencies: [{ kind: "directive", type: i2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i2.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }] });
308
+ }
309
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.15", ngImport: i0, type: NavigationComponent, decorators: [{
310
+ type: Component,
311
+ args: [{ selector: 'aa-navigation', standalone: false, template: "<button *ngIf=\"!hideNavigation\" class=\"navigation__button is-previous\" (click)=\"previous()\"></button>\n<div class=\"navigation__title-wrapper\" [ngStyle]=\"{\n 'transform': 'translateX(' + translateX + '%)',\n 'transition': transition,\n 'left.%': leftPosition\n}\">\n <div *ngFor=\"let title of titles\"\n class=\"navigation__title\"\n [ngStyle]=\"{\n 'width.%': (100 / titles.length)\n }\"\n ><span (click)=\"onMonthClick(title)\">{{title.navigationTitle}}</span>&nbsp;<span (click)=\"onYearClick(title)\">{{title.year}}</span></div>\n</div>\n<button *ngIf=\"!hideNavigation\" class=\"navigation__button is-next\" (click)=\"next()\"></button>", styles: [":host:before,:host:after{content:\" \";display:table}:host:after{clear:both}:host{display:block;padding:10px;height:52px}:host .navigation__title-wrapper{position:absolute;left:0;width:100%}:host .navigation__title{width:100%;font-weight:700;text-align:center;float:left;line-height:2.2rem}:host .navigation__button{padding:0;background-color:transparent;border:none;outline:none;font-style:inherit;cursor:pointer;position:relative;z-index:1;background-color:#fff;border:1px solid rgb(192.1130434783,191.5565217391,189.8869565217);text-align:center;width:32px;height:32px;border-radius:4px}:host .navigation__button:hover{border-color:#8e8d8a}:host .navigation__button.is-previous{float:left}:host .navigation__button.is-previous:after{content:\"<\"}:host .navigation__button.is-next:before{content:\">\"}:host .navigation__button.is-next{float:right}:host.is-animate .navigation__title-wrapper{width:200%}\n"] }]
312
+ }], propDecorators: { previousClick: [{
313
+ type: Output
314
+ }], nextClick: [{
315
+ type: Output
316
+ }], subNavigationClick: [{
317
+ type: Output
318
+ }], monthFormat: [{
319
+ type: Input
320
+ }], language: [{
321
+ type: Input
322
+ }], totalYearMonth: [{
323
+ type: Input
324
+ }], transition: [{
325
+ type: Input
326
+ }], translateX: [{
327
+ type: Input
328
+ }], leftPosition: [{
329
+ type: Input
330
+ }], hideNavigation: [{
331
+ type: Input
332
+ }], animate: [{
333
+ type: HostBinding,
334
+ args: ['class.is-animate']
335
+ }, {
336
+ type: Input
337
+ }] } });
338
+
339
+ class DatepickerComponent {
340
+ utils;
341
+ element;
342
+ /* ==============================================
343
+ * Internal Properties
344
+ * ============================================== */
345
+ date = new Date();
346
+ year = null;
347
+ month = null;
348
+ today = this.date;
349
+ months = null;
350
+ weekdays = ['M', 'T', 'W', 'T', 'F', 'S', 'S'];
351
+ totalYearMonth;
352
+ selectedRange = 'startDate';
353
+ startDate = null;
354
+ endDate = null;
355
+ initialised = false;
356
+ weekStartArray = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday'];
357
+ /* ==============================================
358
+ * Initial Options
359
+ * ============================================== */
360
+ _options = DefaultOptions;
361
+ set options(options) {
362
+ if (options === undefined || !options) {
363
+ return;
364
+ }
365
+ this._options = { ...this._options, ...options };
366
+ if (options.currentDate !== undefined) {
367
+ this.date = this.options.currentDate;
368
+ }
369
+ if (this.initialised) {
370
+ this.goToDate();
371
+ }
372
+ }
373
+ get options() {
374
+ return this._options;
375
+ }
376
+ /* ==============================================
377
+ * External Properties
378
+ * ============================================== */
379
+ /**
380
+ * Set the the language manualy. A string with a BCP 47 language tag
381
+ * @example nl-NL
382
+ */
383
+ _language = navigator.language;
384
+ set language(value) {
385
+ if (!value || value === undefined || !DatepickerService.isValidIsoCode(value)) {
386
+ return;
387
+ }
388
+ this._language = value;
389
+ this.renderWeekdays();
390
+ }
391
+ get language() {
392
+ return this._language;
393
+ }
394
+ /**
395
+ * Minimal Date: If set the dates before it will be disabled
396
+ */
397
+ _minDate = null;
398
+ set minDate(value) {
399
+ if (value === undefined || value === this._minDate) {
400
+ return;
401
+ }
402
+ this._minDate = new Date(value);
403
+ this.goToDate();
404
+ }
405
+ get minDate() {
406
+ return this._minDate;
407
+ }
408
+ /**
409
+ * Maximal Date: If set the dates after it will be disabled
410
+ */
411
+ _maxDate = null;
412
+ set maxDate(value) {
413
+ if (value === undefined || value === this._minDate) {
414
+ return;
415
+ }
416
+ this._maxDate = new Date(value);
417
+ this.goToDate();
418
+ }
419
+ get maxDate() {
420
+ return this._maxDate;
421
+ }
422
+ /**
423
+ * Selected Dates: handles the selected dates array. Can be set both internally and externally
424
+ */
425
+ _selectedDates = [];
426
+ selectedDatesChange = new EventEmitter();
427
+ set selectedDates(value) {
428
+ const _value = Array.isArray(value) ? value : [value];
429
+ if (!DatepickerService.isValidDate(_value)) {
430
+ return;
431
+ }
432
+ this._selectedDates = _value;
433
+ if (this.options.range) {
434
+ this.resetRange();
435
+ }
436
+ this.goToDate();
437
+ this.selectedDatesChange.emit(this._selectedDates);
438
+ }
439
+ get selectedDates() {
440
+ return this._selectedDates;
441
+ }
442
+ /* ==============================================
443
+ * Bindings and Children
444
+ * ============================================== */
445
+ calendarContainer;
446
+ calendarTopContainer;
447
+ theme = '';
448
+ isOpen = true;
449
+ asDirective = false;
450
+ animate = false;
451
+ topPosition = null;
452
+ leftPosition = null;
453
+ bottomPosition = null;
454
+ rightPosition = null;
455
+ constructor(utils, element) {
456
+ this.utils = utils;
457
+ this.element = element;
458
+ }
459
+ ngOnInit() {
460
+ this.initialised = true;
461
+ if (!this.month && !this.year) {
462
+ this.goToDate(this.options.currentDate);
463
+ }
464
+ }
465
+ /**
466
+ * Creates a day array
467
+ *
468
+ * @param year
469
+ * @param month
470
+ * @param isRestDays
471
+ */
472
+ createDayArray(year, month, isRestDays) {
473
+ const days = [];
474
+ const daysInMonth = DatepickerService.getDaysInMonth(year, month);
475
+ for (let index = 0; index < daysInMonth; index++) {
476
+ const dayNumber = index + 1;
477
+ const date = new Date(year, month, dayNumber);
478
+ const day = {
479
+ date,
480
+ dayNumber,
481
+ isFirst: dayNumber === 1,
482
+ isLast: dayNumber === daysInMonth,
483
+ isToday: this.isToday(date),
484
+ isSelected: this.isSelected(date),
485
+ isRest: isRestDays,
486
+ isHidden: isRestDays && this.options.hideRestDays,
487
+ isDisabled: ((this.minDate || this.maxDate) && this.isDisabled(date)) ||
488
+ (isRestDays && this.options.disableRestDays),
489
+ isInRange: this.isInRange(date) ||
490
+ ((this.isStartDate(date) || this.isEndDate(date)) && this.startDate && this.endDate),
491
+ isStartDate: this.isStartDate(date),
492
+ isEndDate: this.isEndDate(date)
493
+ };
494
+ days.push(day);
495
+ }
496
+ return days;
497
+ }
498
+ /**
499
+ * Get the days from the next month
500
+ *
501
+ * @param year
502
+ * @param month
503
+ */
504
+ getNextRestDays(year, month) {
505
+ const monthLength = DatepickerService.getDaysInMonth(year, month);
506
+ const weekStartIndex = this.weekStartArray.indexOf(this.options.weekStart);
507
+ const endOfTheMonth = new Date(year, month, monthLength).getDay() - weekStartIndex;
508
+ const _endOfTheMonth = endOfTheMonth < 0 ? 7 - Math.abs(endOfTheMonth) : endOfTheMonth;
509
+ const nextDays = this.createDayArray(DatepickerService.getYearOfNextMonth(year, month), DatepickerService.getNextMonth(month), true).slice(0, 7 - _endOfTheMonth);
510
+ return nextDays.length > 6 ? [] : nextDays;
511
+ }
512
+ /**
513
+ * Get the days of the previous month
514
+ *
515
+ * @param year
516
+ * @param month
517
+ */
518
+ getPreviousRestDays(year, month) {
519
+ const startOfTheMonth = new Date(year, month, 0).getDay();
520
+ const previousDays = this.createDayArray(DatepickerService.getYearOfPreviousMonth(year, month), DatepickerService.getPreviousMonth(month), true);
521
+ const weekStartIndex = this.weekStartArray.indexOf(this.options.weekStart);
522
+ const _weekStartIndex = weekStartIndex === 0 ? 0 : (7 - weekStartIndex);
523
+ let sliceIndex = previousDays.length - startOfTheMonth - _weekStartIndex;
524
+ sliceIndex = previousDays.length - sliceIndex >= 7 ? sliceIndex + 7 : sliceIndex;
525
+ return previousDays.slice(sliceIndex, previousDays.length);
526
+ }
527
+ /**
528
+ * Merge all the day arrays together
529
+ *
530
+ * @param year
531
+ * @param month
532
+ */
533
+ getMergedDayArrays(year, month) {
534
+ return [
535
+ ...this.getPreviousRestDays(year, month),
536
+ ...this.createDayArray(year, month),
537
+ ...this.getNextRestDays(year, month)
538
+ ];
539
+ }
540
+ /**
541
+ * Create the calendar array from the week arrays
542
+ *
543
+ * @param year
544
+ * @param month
545
+ */
546
+ createCalendarArray(year, month) {
547
+ const dayArray = this.getMergedDayArrays(year, month);
548
+ const weeks = DatepickerService.createWeekArray(dayArray);
549
+ return [{ weeks: weeks }];
550
+ }
551
+ /**
552
+ * Update value is being triggered
553
+ *
554
+ * @param date
555
+ */
556
+ updateValue(date) {
557
+ if (this.options.range) {
558
+ this.selectRange(date);
559
+ }
560
+ else if (!this.isSelected(date)) {
561
+ if (this.options.selectMultiple) {
562
+ this.selectDate(date);
563
+ }
564
+ else {
565
+ this.toggleDate(date);
566
+ }
567
+ if (this.options.closeOnSelect) {
568
+ this.close(true);
569
+ }
570
+ }
571
+ else {
572
+ this.deselectDate(date);
573
+ if (this.options.closeOnSelect) {
574
+ this.close(true);
575
+ }
576
+ }
577
+ this.months = this.createCalendarArray(this.year, this.month);
578
+ }
579
+ /**
580
+ * Select range method - contains the logic to select the start- and endrange
581
+ *
582
+ * @param date
583
+ */
584
+ selectRange(date) {
585
+ if (this.isSelected(date)) {
586
+ this.deselectDate(date);
587
+ }
588
+ else if (DatepickerService.isEarlier(date, this.startDate)) {
589
+ if (this.startDate) {
590
+ this.toggleDate(date, this.startDate, true);
591
+ }
592
+ else {
593
+ this.selectDate(date);
594
+ }
595
+ this.startDate = date;
596
+ this.selectEndDate();
597
+ }
598
+ else if (this.endDate && DatepickerService.isLater(date, this.endDate)) {
599
+ this.toggleDate(date, this.endDate);
600
+ this.endDate = date;
601
+ this.selectStartDate();
602
+ }
603
+ else if (this.selectedRange === 'startDate') {
604
+ if (this.startDate) {
605
+ this.toggleDate(date, this.startDate, true);
606
+ }
607
+ else {
608
+ this.selectDate(date);
609
+ }
610
+ this.startDate = date;
611
+ this.selectEndDate();
612
+ }
613
+ else if (this.selectedRange === 'endDate') {
614
+ if (this.endDate) {
615
+ this.toggleDate(date, this.endDate);
616
+ }
617
+ else {
618
+ this.selectDate(date);
619
+ }
620
+ this.endDate = date;
621
+ this.selectStartDate();
622
+ if (this.options.closeOnSelect) {
623
+ this.close(true);
624
+ }
625
+ }
626
+ }
627
+ /**
628
+ * Reset the range if the selected dates change externally
629
+ */
630
+ resetRange() {
631
+ if (this._selectedDates.length === 1) {
632
+ this.startDate = this._selectedDates[0];
633
+ this.endDate = null;
634
+ }
635
+ else if (this._selectedDates.length === 0) {
636
+ this.startDate = null;
637
+ this.endDate = null;
638
+ }
639
+ }
640
+ /**
641
+ * Toggle a date. One in, on out.
642
+ *
643
+ * @param date - Date to be toggled on
644
+ * @param toggleDate - Optional set specific date to toggle off
645
+ * @param unshift - Optional set to unshift in the selectedDates array. is passed to selectDate method
646
+ */
647
+ toggleDate(date, toggleDate, unshift) {
648
+ if (!toggleDate) {
649
+ this.selectedDates = [date];
650
+ }
651
+ else if (unshift) {
652
+ this._selectedDates.unshift(date);
653
+ this.selectedDates = this._selectedDates.filter(selectedDate => {
654
+ return selectedDate.toDateString() !== toggleDate.toDateString();
655
+ });
656
+ }
657
+ else {
658
+ this._selectedDates.push(date);
659
+ this.selectedDates = this._selectedDates.filter(selectedDate => {
660
+ return selectedDate.toDateString() !== toggleDate.toDateString();
661
+ });
662
+ }
663
+ }
664
+ /**
665
+ * Select a date
666
+ *
667
+ * @param date
668
+ * @param unshift - Optional set to unshift instead of push the date in the selectedDates array
669
+ */
670
+ selectDate(date, unshift) {
671
+ const selectedDates = [...this.selectedDates];
672
+ if (unshift) {
673
+ selectedDates.unshift(date);
674
+ }
675
+ else {
676
+ selectedDates.push(date);
677
+ }
678
+ this.selectedDates = selectedDates;
679
+ }
680
+ /**
681
+ * Deselect a date
682
+ *
683
+ * @param date
684
+ */
685
+ deselectDate(date) {
686
+ this.selectedDates = this._selectedDates.filter(selectedDate => {
687
+ return selectedDate.toDateString() !== date.toDateString();
688
+ });
689
+ }
690
+ /**
691
+ * Go to the next month
692
+ */
693
+ goToNextMonth() {
694
+ this.year = DatepickerService.getYearOfNextMonth(this.year, this.month);
695
+ this.month = DatepickerService.getNextMonth(this.month);
696
+ this.totalYearMonth = [{ month: this.month, year: this.year }];
697
+ this.months = this.createCalendarArray(this.year, this.month);
698
+ }
699
+ /**
700
+ * Go to the previous month
701
+ */
702
+ goToPreviousMonth() {
703
+ this.year = DatepickerService.getYearOfPreviousMonth(this.year, this.month);
704
+ this.month = DatepickerService.getPreviousMonth(this.month);
705
+ this.totalYearMonth = [{ month: this.month, year: this.year }];
706
+ this.months = this.createCalendarArray(this.year, this.month);
707
+ }
708
+ /**
709
+ * Go to a specific month. Is also used to rerender the datepicker
710
+ *
711
+ * @param date - default is the current date.
712
+ */
713
+ goToDate(date = this.date) {
714
+ this.month = date.getMonth();
715
+ this.year = date.getFullYear();
716
+ this.totalYearMonth = [{ month: this.month, year: this.year }];
717
+ this.months = this.createCalendarArray(this.year, this.month);
718
+ }
719
+ /**
720
+ * Render weekdays when options or language changes
721
+ */
722
+ renderWeekdays() {
723
+ this.weekdays = DatepickerService.getWeekDays(this._language, this.options.weekdayFormat, this.options.weekStart);
724
+ }
725
+ /**
726
+ * Set the open state to true
727
+ */
728
+ open() {
729
+ if (this.isOpen) {
730
+ return;
731
+ }
732
+ this.isOpen = true;
733
+ }
734
+ /**
735
+ * Close the datepicker
736
+ *
737
+ * @param useTimeout - optional timeout
738
+ */
739
+ close(useTimeout) {
740
+ if (!this.isOpen) {
741
+ return;
742
+ }
743
+ const timeout = useTimeout ? this.options.timeoutBeforeClosing : 0;
744
+ setTimeout(() => {
745
+ this.isOpen = false;
746
+ }, timeout);
747
+ }
748
+ /**
749
+ * Select the start date - used for range functionality
750
+ */
751
+ selectStartDate() {
752
+ this.selectedRange = 'startDate';
753
+ }
754
+ /**
755
+ * Select the end date - used for range functionality
756
+ */
757
+ selectEndDate() {
758
+ this.selectedRange = 'endDate';
759
+ }
760
+ // TODO: maybe output the startDate and Endate or just of internal use
761
+ /**
762
+ * Check if date is the start date
763
+ */
764
+ isStartDate(date) {
765
+ return this.startDate && date.toDateString() === this.startDate.toDateString();
766
+ }
767
+ /**
768
+ * Check if date is the end date
769
+ */
770
+ isEndDate(date) {
771
+ return this.endDate && date.toDateString() === this.endDate.toDateString();
772
+ }
773
+ /**
774
+ * Check if date is today
775
+ */
776
+ isToday(date) {
777
+ return date.toDateString() === this.today.toDateString();
778
+ }
779
+ /**
780
+ * Check if date is selected
781
+ */
782
+ isSelected(dateToCheck) {
783
+ return this._selectedDates.map(date => date.toDateString()).indexOf(dateToCheck.toDateString()) !== -1;
784
+ }
785
+ /**
786
+ * Check if date is disabled
787
+ */
788
+ isDisabled(date) {
789
+ if (!this.minDate) {
790
+ return !(date < this.maxDate);
791
+ }
792
+ if (!this.maxDate) {
793
+ return !(date > this.minDate);
794
+ }
795
+ return !(date < this.maxDate && date > this.minDate);
796
+ }
797
+ /**
798
+ * Check if date is in range
799
+ */
800
+ isInRange(date) {
801
+ return this.startDate && this.endDate && this.startDate < date && date < this.endDate;
802
+ }
803
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.15", ngImport: i0, type: DatepickerComponent, deps: [{ token: UtilitiesService }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component });
804
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "21.2.15", type: DatepickerComponent, isStandalone: false, selector: "aa-datepicker", inputs: { options: "options", language: "language", minDate: "minDate", maxDate: "maxDate", selectedDates: "selectedDates", theme: "theme", isOpen: "isOpen" }, outputs: { selectedDatesChange: "selectedDatesChange" }, host: { properties: { "class": "this.theme", "class.is-open": "this.isOpen", "class.is-directive": "this.asDirective", "class.is-animate": "this.animate", "style.top.px": "this.topPosition", "style.left.px": "this.leftPosition", "style.bottom.px": "this.bottomPosition", "style.right.px": "this.rightPosition" } }, viewQueries: [{ propertyName: "calendarContainer", first: true, predicate: ["calendarContainer"], descendants: true, static: true }, { propertyName: "calendarTopContainer", first: true, predicate: ["calendarTopContainer"], descendants: true, static: true }], ngImport: i0, template: "<div class=\"datepicker__wrapper\">\n\t<div>\n\t\t<aa-navigation\n\t\t\t\t[hideNavigation]=\"options.hideNavigation\"\n (previousClick)=\"goToPreviousMonth()\"\n\t\t\t\t(nextClick)=\"goToNextMonth()\"\n\t\t\t\t[language]=\"language\"\n\t\t\t\t[totalYearMonth]=\"totalYearMonth\"></aa-navigation>\n\t\t<div class=\"datepicker__weekdays-wrapper\">\n\t\t\t<div class=\"datepicker__weekdays-container\">\n\t\t\t\t<table class=\"datepicker__weekdays\">\n\t\t\t\t\t<thead>\n\t\t\t\t\t<td class=\"datepicker__weekday\" *ngFor=\"let weekday of weekdays; index as i\">{{weekday}}</td>\n\t\t\t\t\t</thead>\n\t\t\t\t</table>\n\t\t\t</div>\n\t\t</div>\n\t</div>\n\t<div class=\"datepicker__calendar-wrapper\">\n\t\t<div *ngFor=\"let month of months;\" class=\"datepicker__calendar-container\">\n\t\t\t<table class=\"datepicker__calendar\">\n\t\t\t\t<tbody>\n\t\t\t\t<tr *ngFor=\"let week of month.weeks; index as i\">\n\t\t\t\t\t<td class=\"datepicker__day\" *ngFor=\"let day of week.days; index as i\" [ngClass]=\"{\n\t\t\t'is-first': day.isFirst,\n\t\t\t'is-last': day.isLast,\n\t\t\t'is-hidden': day.isHidden,\n\t\t\t'is-disabled': day.isDisabled,\n\t\t\t'is-today': day.isToday,\n\t\t\t'is-selected': day.isSelected,\n\t\t\t'is-in-range': day.isInRange,\n\t\t\t'is-start-date': day.isStartDate,\n\t\t\t'is-end-date': day.isEndDate,\n\t\t\t'is-rest': day.isRest\n\t\t\t}\">\n\t\t\t\t\t\t<button class=\"datepicker__button\" [disabled]=\"day.isDisabled || day.isHidden\"\n\t\t\t\t\t\t\t\t(click)=\"updateValue(day.date)\">{{day.dayNumber}}\n\t\t\t\t\t\t</button>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n\t\t\t\t</tbody>\n\t\t\t</table>\n\t\t</div>\n\t</div>\n\t<ng-content></ng-content>\n</div>", styles: [":host{font-family:Arial,Helvetica,sans-serif;border:1px solid rgb(217.1695652174,216.8347826087,215.8304347826);width:300px;position:relative;display:inline-block;z-index:2;border-radius:4px;box-shadow:0 1px 5px #00000026;overflow:hidden;background-color:#fff;box-sizing:border-box;visibility:hidden}:host *{box-sizing:border-box}:host .datepicker__calendar-container{padding:0 10px 10px}:host .datepicker__footer{position:relative;z-index:1}:host table{width:100%;table-layout:fixed;border-spacing:0;border-collapse:collapse}:host td{padding:0}:host .datepicker__weekdays-wrapper:before,:host .datepicker__weekdays-wrapper:after{content:\" \";display:table}:host .datepicker__weekdays-wrapper:after{clear:both}:host .datepicker__weekdays-container{padding:10px 10px 0;float:left}:host .datepicker__weekdays{table-layout:fixed;width:100%}:host .datepicker__weekday{color:gray;font-size:12px;height:20px;text-align:center}:host .datepicker__day{position:relative;text-align:center;height:40px;width:auto;border:1px solid rgb(217.1695652174,216.8347826087,215.8304347826)}:host .datepicker__day.is-rest{border:none}:host .datepicker__button{padding:0;background-color:transparent;border:none;outline:none;font-style:inherit;cursor:pointer;color:#8e8d8a;width:100%;height:100%}:host .datepicker__button:hover{border:1px solid transparent;background-color:#f2f2f2;color:#8e8d8a}:host .is-hidden{opacity:0;display:table-cell}:host .is-rest{border:none}:host .is-rest .datepicker__button{color:#c0c0be}:host .is-today .datepicker__button{background-color:#eae7dc}:host .is-in-range .datepicker__button{background-color:#e98074;color:#fff}:host .is-in-range .datepicker__button:hover{background-color:#e66c5e}:host .is-selected .datepicker__button{background-color:#e85a4f;color:#fff;font-weight:700}:host .is-selected .datepicker__button:hover{background-color:#e23022}:host .is-start-date .datepicker__button{background-color:#e85a4f;color:#fff}:host .is-end-date .datepicker__button{background-color:#e85a4f;color:#fff}:host .is-disabled .datepicker__button{color:#d9d9d8;cursor:default}:host .is-disabled .datepicker__button:hover{background-color:transparent}:host.is-directive{visibility:hidden;position:absolute}:host.is-open{visibility:visible}:host.is-animate{transition:height .2s ease-in;width:300px}:host.is-animate .datepicker__main{transition:height .2s ease-in}:host.is-animate .datepicker__calendar-wrapper{position:absolute;width:200%;left:0}:host.is-animate .datepicker__calendar{float:left;width:100%}:host.is-animate .datepicker__calendar-container{float:left}\n"], dependencies: [{ kind: "directive", type: i2.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "component", type: NavigationComponent, selector: "aa-navigation", inputs: ["monthFormat", "language", "totalYearMonth", "transition", "translateX", "leftPosition", "hideNavigation", "animate"], outputs: ["previousClick", "nextClick", "subNavigationClick"] }] });
805
+ }
806
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.15", ngImport: i0, type: DatepickerComponent, decorators: [{
807
+ type: Component,
808
+ args: [{ selector: 'aa-datepicker', standalone: false, template: "<div class=\"datepicker__wrapper\">\n\t<div>\n\t\t<aa-navigation\n\t\t\t\t[hideNavigation]=\"options.hideNavigation\"\n (previousClick)=\"goToPreviousMonth()\"\n\t\t\t\t(nextClick)=\"goToNextMonth()\"\n\t\t\t\t[language]=\"language\"\n\t\t\t\t[totalYearMonth]=\"totalYearMonth\"></aa-navigation>\n\t\t<div class=\"datepicker__weekdays-wrapper\">\n\t\t\t<div class=\"datepicker__weekdays-container\">\n\t\t\t\t<table class=\"datepicker__weekdays\">\n\t\t\t\t\t<thead>\n\t\t\t\t\t<td class=\"datepicker__weekday\" *ngFor=\"let weekday of weekdays; index as i\">{{weekday}}</td>\n\t\t\t\t\t</thead>\n\t\t\t\t</table>\n\t\t\t</div>\n\t\t</div>\n\t</div>\n\t<div class=\"datepicker__calendar-wrapper\">\n\t\t<div *ngFor=\"let month of months;\" class=\"datepicker__calendar-container\">\n\t\t\t<table class=\"datepicker__calendar\">\n\t\t\t\t<tbody>\n\t\t\t\t<tr *ngFor=\"let week of month.weeks; index as i\">\n\t\t\t\t\t<td class=\"datepicker__day\" *ngFor=\"let day of week.days; index as i\" [ngClass]=\"{\n\t\t\t'is-first': day.isFirst,\n\t\t\t'is-last': day.isLast,\n\t\t\t'is-hidden': day.isHidden,\n\t\t\t'is-disabled': day.isDisabled,\n\t\t\t'is-today': day.isToday,\n\t\t\t'is-selected': day.isSelected,\n\t\t\t'is-in-range': day.isInRange,\n\t\t\t'is-start-date': day.isStartDate,\n\t\t\t'is-end-date': day.isEndDate,\n\t\t\t'is-rest': day.isRest\n\t\t\t}\">\n\t\t\t\t\t\t<button class=\"datepicker__button\" [disabled]=\"day.isDisabled || day.isHidden\"\n\t\t\t\t\t\t\t\t(click)=\"updateValue(day.date)\">{{day.dayNumber}}\n\t\t\t\t\t\t</button>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n\t\t\t\t</tbody>\n\t\t\t</table>\n\t\t</div>\n\t</div>\n\t<ng-content></ng-content>\n</div>", styles: [":host{font-family:Arial,Helvetica,sans-serif;border:1px solid rgb(217.1695652174,216.8347826087,215.8304347826);width:300px;position:relative;display:inline-block;z-index:2;border-radius:4px;box-shadow:0 1px 5px #00000026;overflow:hidden;background-color:#fff;box-sizing:border-box;visibility:hidden}:host *{box-sizing:border-box}:host .datepicker__calendar-container{padding:0 10px 10px}:host .datepicker__footer{position:relative;z-index:1}:host table{width:100%;table-layout:fixed;border-spacing:0;border-collapse:collapse}:host td{padding:0}:host .datepicker__weekdays-wrapper:before,:host .datepicker__weekdays-wrapper:after{content:\" \";display:table}:host .datepicker__weekdays-wrapper:after{clear:both}:host .datepicker__weekdays-container{padding:10px 10px 0;float:left}:host .datepicker__weekdays{table-layout:fixed;width:100%}:host .datepicker__weekday{color:gray;font-size:12px;height:20px;text-align:center}:host .datepicker__day{position:relative;text-align:center;height:40px;width:auto;border:1px solid rgb(217.1695652174,216.8347826087,215.8304347826)}:host .datepicker__day.is-rest{border:none}:host .datepicker__button{padding:0;background-color:transparent;border:none;outline:none;font-style:inherit;cursor:pointer;color:#8e8d8a;width:100%;height:100%}:host .datepicker__button:hover{border:1px solid transparent;background-color:#f2f2f2;color:#8e8d8a}:host .is-hidden{opacity:0;display:table-cell}:host .is-rest{border:none}:host .is-rest .datepicker__button{color:#c0c0be}:host .is-today .datepicker__button{background-color:#eae7dc}:host .is-in-range .datepicker__button{background-color:#e98074;color:#fff}:host .is-in-range .datepicker__button:hover{background-color:#e66c5e}:host .is-selected .datepicker__button{background-color:#e85a4f;color:#fff;font-weight:700}:host .is-selected .datepicker__button:hover{background-color:#e23022}:host .is-start-date .datepicker__button{background-color:#e85a4f;color:#fff}:host .is-end-date .datepicker__button{background-color:#e85a4f;color:#fff}:host .is-disabled .datepicker__button{color:#d9d9d8;cursor:default}:host .is-disabled .datepicker__button:hover{background-color:transparent}:host.is-directive{visibility:hidden;position:absolute}:host.is-open{visibility:visible}:host.is-animate{transition:height .2s ease-in;width:300px}:host.is-animate .datepicker__main{transition:height .2s ease-in}:host.is-animate .datepicker__calendar-wrapper{position:absolute;width:200%;left:0}:host.is-animate .datepicker__calendar{float:left;width:100%}:host.is-animate .datepicker__calendar-container{float:left}\n"] }]
809
+ }], ctorParameters: () => [{ type: UtilitiesService }, { type: i0.ElementRef }], propDecorators: { options: [{
810
+ type: Input,
811
+ args: ['options']
812
+ }], language: [{
813
+ type: Input
814
+ }], minDate: [{
815
+ type: Input
816
+ }], maxDate: [{
817
+ type: Input
818
+ }], selectedDatesChange: [{
819
+ type: Output
820
+ }], selectedDates: [{
821
+ type: Input
822
+ }], calendarContainer: [{
823
+ type: ViewChild,
824
+ args: ['calendarContainer', { static: true }]
825
+ }], calendarTopContainer: [{
826
+ type: ViewChild,
827
+ args: ['calendarTopContainer', { static: true }]
828
+ }], theme: [{
829
+ type: HostBinding,
830
+ args: ['class']
831
+ }, {
832
+ type: Input
833
+ }], isOpen: [{
834
+ type: HostBinding,
835
+ args: ['class.is-open']
836
+ }, {
837
+ type: Input
838
+ }], asDirective: [{
839
+ type: HostBinding,
840
+ args: ['class.is-directive']
841
+ }], animate: [{
842
+ type: HostBinding,
843
+ args: ['class.is-animate']
844
+ }], topPosition: [{
845
+ type: HostBinding,
846
+ args: ['style.top.px']
847
+ }], leftPosition: [{
848
+ type: HostBinding,
849
+ args: ['style.left.px']
850
+ }], bottomPosition: [{
851
+ type: HostBinding,
852
+ args: ['style.bottom.px']
853
+ }], rightPosition: [{
854
+ type: HostBinding,
855
+ args: ['style.right.px']
856
+ }] } });
857
+
858
+ class AnimatepickerComponent extends DatepickerComponent {
859
+ elementRef;
860
+ utilities;
861
+ /* ==============================================
862
+ * Internal Properties
863
+ * ============================================== */
864
+ animate = true;
865
+ initialWidth;
866
+ calendarWidth;
867
+ isAnimating = false;
868
+ leftInnerPosition = 0;
869
+ transition;
870
+ translateX;
871
+ datepickerPosition;
872
+ initialised = false;
873
+ calendarHeight;
874
+ _currentYearMonth = null;
875
+ set currentYearMonth(yearMonths) {
876
+ this._currentYearMonth = yearMonths;
877
+ this.navigate.emit(yearMonths);
878
+ }
879
+ get currentYearMonth() {
880
+ return this._currentYearMonth;
881
+ }
882
+ /* ==============================================
883
+ * External Properties
884
+ * ============================================== */
885
+ /**
886
+ * Number of months: the number of months displayed
887
+ */
888
+ _numberOfMonths = new Array(1);
889
+ set numberOfMonths(value) {
890
+ if (value === undefined || value === this._numberOfMonths.length) {
891
+ return;
892
+ }
893
+ this._numberOfMonths = new Array(value);
894
+ this.setDatePickerDimension();
895
+ this.goToDate(this.date);
896
+ }
897
+ get numberOfMonths() {
898
+ return this._numberOfMonths;
899
+ }
900
+ /* ==============================================
901
+ * Outputs
902
+ * ============================================== */
903
+ navigate = new EventEmitter();
904
+ /* ==============================================
905
+ * Bindings and Children
906
+ * ============================================== */
907
+ calendarContainer;
908
+ calendarTopContainer;
909
+ footer;
910
+ datepickerWidth;
911
+ datepickerHeight;
912
+ constructor(elementRef, utilities) {
913
+ super(utilities, elementRef);
914
+ this.elementRef = elementRef;
915
+ this.utilities = utilities;
916
+ }
917
+ ngOnInit() {
918
+ // Get the computed width from the calendar. Set the initial width
919
+ const computedWidth = window
920
+ .getComputedStyle(this.elementRef.nativeElement, null)
921
+ .getPropertyValue('width');
922
+ this.initialWidth = parseInt(computedWidth, 10);
923
+ this.initialised = true;
924
+ // Set the current year and month object
925
+ if (!this.month && !this.year) {
926
+ this.goToDate(this.options.currentDate);
927
+ }
928
+ }
929
+ ngAfterViewInit() {
930
+ setTimeout(() => {
931
+ this.setDatePickerDimension();
932
+ this.setDatepickerHeight(true);
933
+ });
934
+ }
935
+ /**
936
+ * Set the height and the width properties
937
+ */
938
+ setDatePickerDimension() {
939
+ this.datepickerHeight =
940
+ this.calendarContainer.nativeElement.offsetHeight +
941
+ this.calendarTopContainer.nativeElement.offsetHeight +
942
+ this.footer.nativeElement.offsetHeight;
943
+ this.calendarHeight = this.calendarContainer.nativeElement.offsetHeight;
944
+ this.datepickerWidth = this.initialWidth * this._numberOfMonths.length;
945
+ }
946
+ /**
947
+ * Go to a specific month
948
+ *
949
+ * @param date - optional
950
+ */
951
+ goToDate(date) {
952
+ if (date) {
953
+ this.currentYearMonth = this.getNextYearMonthArray(date.getFullYear(), date.getMonth());
954
+ }
955
+ this.calendarWidth = 50 / this._numberOfMonths.length;
956
+ this.months = this.getNextMonthArray(this.currentYearMonth, true);
957
+ this.resetStyle();
958
+ }
959
+ /**
960
+ * Create an array of the next year and months
961
+ *
962
+ * @param year
963
+ * @param month
964
+ */
965
+ getNextYearMonthArray(year, month) {
966
+ const array = [];
967
+ for (let index = 0; index < this._numberOfMonths.length; index++) {
968
+ array.push({ year: year, month: month });
969
+ year = DatepickerService.getYearOfNextMonth(year, month);
970
+ month = DatepickerService.getNextMonth(month);
971
+ }
972
+ return array;
973
+ }
974
+ /**
975
+ * Create an array of the previous year and months
976
+ *
977
+ * @param year
978
+ * @param month
979
+ */
980
+ getPreviousYearMonthArray(year, month) {
981
+ const array = [];
982
+ for (let index = 0; index < this._numberOfMonths.length; index++) {
983
+ array.unshift({ year: year, month: month });
984
+ year = DatepickerService.getYearOfPreviousMonth(year, month);
985
+ month = DatepickerService.getPreviousMonth(month);
986
+ }
987
+ return array;
988
+ }
989
+ /**
990
+ * Set the datepicker height, used when animating
991
+ *
992
+ * @param directionRight - Set optional when sliding to the right
993
+ */
994
+ setDatepickerHeight(directionRight) {
995
+ let indexArray;
996
+ // TODO: Seperate this logic for readability purpose
997
+ if (this._numberOfMonths.length > 1) {
998
+ const start = directionRight ? 0 : this._numberOfMonths.length;
999
+ const end = directionRight
1000
+ ? this._numberOfMonths.length - 1
1001
+ : this._numberOfMonths.length + this._numberOfMonths.length - 1;
1002
+ indexArray = this.utilities.createArray(start, end);
1003
+ }
1004
+ else {
1005
+ indexArray = directionRight ? [0] : [1];
1006
+ }
1007
+ const that = this;
1008
+ setTimeout(() => {
1009
+ const calendarArray = that.elementRef.nativeElement.querySelectorAll('.datepicker__calendar-container');
1010
+ let offsetHeight = 0;
1011
+ indexArray.forEach(el => {
1012
+ if (calendarArray[el].offsetHeight > offsetHeight) {
1013
+ offsetHeight = calendarArray[el].offsetHeight;
1014
+ }
1015
+ });
1016
+ // TODO: Merge with setHeight function.
1017
+ that.datepickerHeight =
1018
+ offsetHeight + that.calendarTopContainer.nativeElement.offsetHeight + that.footer.nativeElement.offsetHeight;
1019
+ that.calendarHeight = offsetHeight;
1020
+ });
1021
+ }
1022
+ /**
1023
+ * Get next month array, gets multiple months.
1024
+ * Used when the options animate is set or multiple months are visable
1025
+ *
1026
+ * @return Month[]
1027
+ */
1028
+ getNextMonthArray(currentYearMonth, keepDate = false, nextMonthsYearMonthArray) {
1029
+ // Get the last index, used for selecting the right year month object
1030
+ const lastIndex = this._numberOfMonths.length - 1;
1031
+ // Get next year and month in an Object
1032
+ const nextMonths = nextMonthsYearMonthArray ||
1033
+ this.getNextYearMonthArray(DatepickerService.getYearOfNextMonth(currentYearMonth[lastIndex].year, currentYearMonth[lastIndex].month), DatepickerService.getNextMonth(currentYearMonth[lastIndex].month));
1034
+ // Concatenates the two objects to create a total year and month object
1035
+ this.totalYearMonth = currentYearMonth.concat(nextMonths);
1036
+ // Create the calendar array using the total year and month Object
1037
+ const monthArray = [];
1038
+ this.totalYearMonth.forEach(e => monthArray.push(this.createCalendarArray(e.year, e.month)));
1039
+ // Set the new current year and month object.
1040
+ if (!keepDate) {
1041
+ this.currentYearMonth = nextMonths;
1042
+ }
1043
+ return [].concat.apply([], monthArray);
1044
+ }
1045
+ /**
1046
+ * Gets an array of previous months.
1047
+ * Used for animation and when more months are displayed
1048
+ *
1049
+ * @param currentYearMonth
1050
+ * @param keepDate
1051
+ */
1052
+ getPreviousMonthArray(currentYearMonth, keepDate = false) {
1053
+ // Get previous year and month in an Object
1054
+ const previousMonths = this.getPreviousYearMonthArray(DatepickerService.getYearOfPreviousMonth(currentYearMonth[0].year, currentYearMonth[0].month), DatepickerService.getPreviousMonth(currentYearMonth[0].month));
1055
+ // Concatenates the two objects to create a total year and month object
1056
+ this.totalYearMonth = previousMonths.concat(currentYearMonth);
1057
+ // Create the calendar array using the total year and month Object
1058
+ const monthArray = [];
1059
+ this.totalYearMonth.forEach(e => {
1060
+ monthArray.push(this.createCalendarArray(e['year'], e['month']));
1061
+ });
1062
+ // Set the new current year and month object.
1063
+ if (!keepDate) {
1064
+ this.currentYearMonth = previousMonths;
1065
+ }
1066
+ return [].concat.apply([], monthArray);
1067
+ }
1068
+ /**
1069
+ * Update value is being triggered
1070
+ *
1071
+ * @param date
1072
+ */
1073
+ updateValue(date) {
1074
+ if (this.options.range) {
1075
+ this.selectRange(date);
1076
+ }
1077
+ else if (!this.isSelected(date)) {
1078
+ if (this.options.selectMultiple) {
1079
+ this.selectDate(date);
1080
+ }
1081
+ else {
1082
+ this.toggleDate(date);
1083
+ }
1084
+ if (this.options.closeOnSelect) {
1085
+ this.close(true);
1086
+ }
1087
+ }
1088
+ else {
1089
+ this.deselectDate(date);
1090
+ if (this.options.closeOnSelect) {
1091
+ this.close(true);
1092
+ }
1093
+ }
1094
+ this.months = this.getNextMonthArray(this.currentYearMonth, true);
1095
+ this.resetStyle();
1096
+ }
1097
+ /**
1098
+ * Go to the next month
1099
+ */
1100
+ goToNextMonth() {
1101
+ if (this.isAnimating) {
1102
+ return;
1103
+ }
1104
+ this.months = this.getNextMonthArray(this.currentYearMonth);
1105
+ this.resetStyle();
1106
+ this.setDatepickerHeight();
1107
+ this.slideLeft();
1108
+ }
1109
+ /**
1110
+ * Go to the previous month
1111
+ */
1112
+ goToPreviousMonth() {
1113
+ if (this.isAnimating) {
1114
+ return;
1115
+ }
1116
+ this.months = this.getPreviousMonthArray(this.currentYearMonth);
1117
+ this.resetStyle(true);
1118
+ this.setDatepickerHeight(true);
1119
+ this.slideRight();
1120
+ }
1121
+ /**
1122
+ * Go to a specific month
1123
+ * TODO: WIP Check if date is in current range, or if it is later or earlier
1124
+ */
1125
+ goToMonth(date) {
1126
+ const nextMonths = this.getNextYearMonthArray(date.getFullYear(), date.getMonth());
1127
+ this.months = this.getNextMonthArray(this.totalYearMonth, false, nextMonths);
1128
+ this.resetStyle();
1129
+ this.setDatepickerHeight();
1130
+ this.slideRight();
1131
+ }
1132
+ /**
1133
+ * Slide to the right
1134
+ */
1135
+ slideRight() {
1136
+ this.setIsAnimating();
1137
+ setTimeout(() => {
1138
+ this.transition =
1139
+ 'transform ' + this.options.animationSpeed + 'ms ' + this.options.easing;
1140
+ this.translateX = 50;
1141
+ });
1142
+ }
1143
+ /**
1144
+ * Slide to the left (criss cross)
1145
+ */
1146
+ slideLeft() {
1147
+ this.setIsAnimating();
1148
+ setTimeout(() => {
1149
+ this.transition =
1150
+ 'transform ' + this.options.animationSpeed + 'ms ' + this.options.easing;
1151
+ this.translateX = -50;
1152
+ });
1153
+ }
1154
+ /**
1155
+ * Set animating state
1156
+ */
1157
+ setIsAnimating() {
1158
+ this.isAnimating = true;
1159
+ setTimeout(() => {
1160
+ this.isAnimating = false;
1161
+ }, this.options.animationSpeed);
1162
+ }
1163
+ /**
1164
+ * Reset Style
1165
+ *
1166
+ * @param resetForPrevious - Optional
1167
+ */
1168
+ resetStyle(resetForPrevious) {
1169
+ this.transition = 'transform 0ms ease-in';
1170
+ this.translateX = 0;
1171
+ this.leftInnerPosition = resetForPrevious ? -100 : 0;
1172
+ }
1173
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.15", ngImport: i0, type: AnimatepickerComponent, deps: [{ token: i0.ElementRef }, { token: UtilitiesService }], target: i0.ɵɵFactoryTarget.Component });
1174
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "21.2.15", type: AnimatepickerComponent, isStandalone: false, selector: "aa-animatepicker", inputs: { numberOfMonths: "numberOfMonths" }, outputs: { navigate: "navigate" }, host: { properties: { "style.width.px": "this.datepickerWidth", "style.height.px": "this.datepickerHeight" } }, viewQueries: [{ propertyName: "calendarContainer", first: true, predicate: ["calendarContainer"], descendants: true, static: true }, { propertyName: "calendarTopContainer", first: true, predicate: ["calendarTopContainer"], descendants: true, static: true }, { propertyName: "footer", first: true, predicate: ["footer"], descendants: true, static: true }], usesInheritance: true, ngImport: i0, template: "<div class=\"datepicker__wrapper\" [ngStyle]=\"datepickerPosition\">\n\t<div #calendarTopContainer>\n\t\t<div class=\"datepicker__header\" #header>\n\t\t\t<ng-content select=\"header\"></ng-content>\n\t\t</div>\n\t\t<aa-navigation\n\t\t\t\t(previousClick)=\"goToPreviousMonth()\"\n\t\t\t\t(nextClick)=\"goToNextMonth()\"\n\t\t\t\t(subNavigationClick)=\"goToDate($event)\"\n\t\t\t\t[language]=\"language\"\n\t\t\t\t[animate]=\"animate\"\n\t\t\t\t[translateX]=\"translateX\"\n\t\t\t\t[transition]=\"transition\"\n\t\t\t\t[leftPosition]=\"leftInnerPosition\"\n\t\t\t\t[hideNavigation]=\"options.hideNavigation\"\n\t\t\t\t[totalYearMonth]=\"totalYearMonth\"\n\t\t></aa-navigation>\n\n\t\t<div class=\"datepicker__weekdays-wrapper\">\n\t\t\t<div \t*ngFor=\"let month of numberOfMonths\"\n\t\t\t\t\t[ngStyle]=\"{\n\t\t\t\t'width.%': (100 / numberOfMonths.length)\n\t\t\t\t}\"\n\t\t\t\t\tclass=\"datepicker__weekdays-container\">\n\t\t\t\t<table class=\"datepicker__weekdays\">\n\t\t\t\t\t<thead>\n\t\t\t\t\t<td class=\"datepicker__weekday\" *ngFor=\"let weekday of weekdays; index as i\">{{weekday}}</td>\n\t\t\t\t\t</thead>\n\t\t\t\t</table>\n\t\t\t</div>\n\t\t</div>\n\t</div>\n\t<div class=\"datepicker__main\" [ngStyle]=\"{\n\t\t'height.px': calendarHeight}\">\n\t\t<div class=\"datepicker__calendar-wrapper\" #calendarContainer [ngStyle]=\"{\n\t\t\t\t\t'transform': 'translateX(' + translateX + '%)',\n\t\t\t\t\t'transition': transition,\n\t\t\t\t\t'left.%': leftInnerPosition\n\t\t\t\t\t}\"\n\t\t>\n\t\t\t<div\n\t\t\t\t\t*ngFor=\"let month of months;\"\n\t\t\t\t\tclass=\"datepicker__calendar-container\"\n\t\t\t\t\t[ngStyle]=\"{'width.%': calendarWidth}\"\n\t\t\t>\n\t\t\t\t<table class=\"datepicker__calendar\">\n\t\t\t\t\t<tbody>\n\t\t\t\t\t<tr *ngFor=\"let week of month.weeks; index as i\" class=\"datepicker__week\">\n\t\t\t\t\t\t<td class=\"datepicker__day\" *ngFor=\"let day of week.days; index as i\"\n\t\t\t\t\t\t\t[ngClass]=\"{\n\t\t\t\t\t\t'is-first': day.isFirst,\n\t\t\t\t\t\t'is-last': day.isLast,\n\t\t\t\t\t\t'is-hidden': day.isHidden,\n\t\t\t\t\t\t'is-disabled': day.isDisabled,\n\t\t\t\t\t\t'is-today': day.isToday,\n\t\t\t\t\t\t'is-selected': day.isSelected,\n\t\t\t\t\t\t'is-in-range': day.isInRange,\n\t\t\t\t\t\t'is-start-date': day.isStartDate,\n\t\t\t\t\t\t'is-end-date': day.isEndDate,\n\t\t\t\t\t\t'is-rest': day.isRest\n\t\t\t\t\t\t}\">\n\t\t\t\t\t\t\t<button class=\"datepicker__button\" [disabled]=\"day.isDisabled || day.isHidden\"\n\t\t\t\t\t\t\t\t\t(click)=\"updateValue(day.date)\">{{day.dayNumber}}\n\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t</td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t</tbody>\n\t\t\t\t</table>\n\t\t\t</div>\n\t\t</div>\n\t</div>\n\t<div class=\"datepicker__footer\" #footer>\n\t\t<ng-content select=\"footer\"></ng-content>\n\t</div>\n</div>\n\t\t", styles: [":host{font-family:Arial,Helvetica,sans-serif;border:1px solid rgb(217.1695652174,216.8347826087,215.8304347826);width:300px;position:relative;display:inline-block;z-index:2;border-radius:4px;box-shadow:0 1px 5px #00000026;overflow:hidden;background-color:#fff;box-sizing:border-box;visibility:hidden}:host *{box-sizing:border-box}:host .datepicker__calendar-container{padding:0 10px 10px}:host .datepicker__footer{position:relative;z-index:1}:host table{width:100%;table-layout:fixed;border-spacing:0;border-collapse:collapse}:host td{padding:0}:host .datepicker__weekdays-wrapper:before,:host .datepicker__weekdays-wrapper:after{content:\" \";display:table}:host .datepicker__weekdays-wrapper:after{clear:both}:host .datepicker__weekdays-container{padding:10px 10px 0;float:left}:host .datepicker__weekdays{table-layout:fixed;width:100%}:host .datepicker__weekday{color:gray;font-size:12px;height:20px;text-align:center}:host .datepicker__day{position:relative;text-align:center;height:40px;width:auto;border:1px solid rgb(217.1695652174,216.8347826087,215.8304347826)}:host .datepicker__day.is-rest{border:none}:host .datepicker__button{padding:0;background-color:transparent;border:none;outline:none;font-style:inherit;cursor:pointer;color:#8e8d8a;width:100%;height:100%}:host .datepicker__button:hover{border:1px solid transparent;background-color:#f2f2f2;color:#8e8d8a}:host .is-hidden{opacity:0;display:table-cell}:host .is-rest{border:none}:host .is-rest .datepicker__button{color:#c0c0be}:host .is-today .datepicker__button{background-color:#eae7dc}:host .is-in-range .datepicker__button{background-color:#e98074;color:#fff}:host .is-in-range .datepicker__button:hover{background-color:#e66c5e}:host .is-selected .datepicker__button{background-color:#e85a4f;color:#fff;font-weight:700}:host .is-selected .datepicker__button:hover{background-color:#e23022}:host .is-start-date .datepicker__button{background-color:#e85a4f;color:#fff}:host .is-end-date .datepicker__button{background-color:#e85a4f;color:#fff}:host .is-disabled .datepicker__button{color:#d9d9d8;cursor:default}:host .is-disabled .datepicker__button:hover{background-color:transparent}:host.is-directive{visibility:hidden;position:absolute}:host.is-open{visibility:visible}:host.is-animate{transition:height .2s ease-in;width:300px}:host.is-animate .datepicker__main{transition:height .2s ease-in}:host.is-animate .datepicker__calendar-wrapper{position:absolute;width:200%;left:0}:host.is-animate .datepicker__calendar{float:left;width:100%}:host.is-animate .datepicker__calendar-container{float:left}\n"], dependencies: [{ kind: "directive", type: i2.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i2.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { kind: "component", type: NavigationComponent, selector: "aa-navigation", inputs: ["monthFormat", "language", "totalYearMonth", "transition", "translateX", "leftPosition", "hideNavigation", "animate"], outputs: ["previousClick", "nextClick", "subNavigationClick"] }] });
1175
+ }
1176
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.15", ngImport: i0, type: AnimatepickerComponent, decorators: [{
1177
+ type: Component,
1178
+ args: [{ selector: 'aa-animatepicker', standalone: false, template: "<div class=\"datepicker__wrapper\" [ngStyle]=\"datepickerPosition\">\n\t<div #calendarTopContainer>\n\t\t<div class=\"datepicker__header\" #header>\n\t\t\t<ng-content select=\"header\"></ng-content>\n\t\t</div>\n\t\t<aa-navigation\n\t\t\t\t(previousClick)=\"goToPreviousMonth()\"\n\t\t\t\t(nextClick)=\"goToNextMonth()\"\n\t\t\t\t(subNavigationClick)=\"goToDate($event)\"\n\t\t\t\t[language]=\"language\"\n\t\t\t\t[animate]=\"animate\"\n\t\t\t\t[translateX]=\"translateX\"\n\t\t\t\t[transition]=\"transition\"\n\t\t\t\t[leftPosition]=\"leftInnerPosition\"\n\t\t\t\t[hideNavigation]=\"options.hideNavigation\"\n\t\t\t\t[totalYearMonth]=\"totalYearMonth\"\n\t\t></aa-navigation>\n\n\t\t<div class=\"datepicker__weekdays-wrapper\">\n\t\t\t<div \t*ngFor=\"let month of numberOfMonths\"\n\t\t\t\t\t[ngStyle]=\"{\n\t\t\t\t'width.%': (100 / numberOfMonths.length)\n\t\t\t\t}\"\n\t\t\t\t\tclass=\"datepicker__weekdays-container\">\n\t\t\t\t<table class=\"datepicker__weekdays\">\n\t\t\t\t\t<thead>\n\t\t\t\t\t<td class=\"datepicker__weekday\" *ngFor=\"let weekday of weekdays; index as i\">{{weekday}}</td>\n\t\t\t\t\t</thead>\n\t\t\t\t</table>\n\t\t\t</div>\n\t\t</div>\n\t</div>\n\t<div class=\"datepicker__main\" [ngStyle]=\"{\n\t\t'height.px': calendarHeight}\">\n\t\t<div class=\"datepicker__calendar-wrapper\" #calendarContainer [ngStyle]=\"{\n\t\t\t\t\t'transform': 'translateX(' + translateX + '%)',\n\t\t\t\t\t'transition': transition,\n\t\t\t\t\t'left.%': leftInnerPosition\n\t\t\t\t\t}\"\n\t\t>\n\t\t\t<div\n\t\t\t\t\t*ngFor=\"let month of months;\"\n\t\t\t\t\tclass=\"datepicker__calendar-container\"\n\t\t\t\t\t[ngStyle]=\"{'width.%': calendarWidth}\"\n\t\t\t>\n\t\t\t\t<table class=\"datepicker__calendar\">\n\t\t\t\t\t<tbody>\n\t\t\t\t\t<tr *ngFor=\"let week of month.weeks; index as i\" class=\"datepicker__week\">\n\t\t\t\t\t\t<td class=\"datepicker__day\" *ngFor=\"let day of week.days; index as i\"\n\t\t\t\t\t\t\t[ngClass]=\"{\n\t\t\t\t\t\t'is-first': day.isFirst,\n\t\t\t\t\t\t'is-last': day.isLast,\n\t\t\t\t\t\t'is-hidden': day.isHidden,\n\t\t\t\t\t\t'is-disabled': day.isDisabled,\n\t\t\t\t\t\t'is-today': day.isToday,\n\t\t\t\t\t\t'is-selected': day.isSelected,\n\t\t\t\t\t\t'is-in-range': day.isInRange,\n\t\t\t\t\t\t'is-start-date': day.isStartDate,\n\t\t\t\t\t\t'is-end-date': day.isEndDate,\n\t\t\t\t\t\t'is-rest': day.isRest\n\t\t\t\t\t\t}\">\n\t\t\t\t\t\t\t<button class=\"datepicker__button\" [disabled]=\"day.isDisabled || day.isHidden\"\n\t\t\t\t\t\t\t\t\t(click)=\"updateValue(day.date)\">{{day.dayNumber}}\n\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t</td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t</tbody>\n\t\t\t\t</table>\n\t\t\t</div>\n\t\t</div>\n\t</div>\n\t<div class=\"datepicker__footer\" #footer>\n\t\t<ng-content select=\"footer\"></ng-content>\n\t</div>\n</div>\n\t\t", styles: [":host{font-family:Arial,Helvetica,sans-serif;border:1px solid rgb(217.1695652174,216.8347826087,215.8304347826);width:300px;position:relative;display:inline-block;z-index:2;border-radius:4px;box-shadow:0 1px 5px #00000026;overflow:hidden;background-color:#fff;box-sizing:border-box;visibility:hidden}:host *{box-sizing:border-box}:host .datepicker__calendar-container{padding:0 10px 10px}:host .datepicker__footer{position:relative;z-index:1}:host table{width:100%;table-layout:fixed;border-spacing:0;border-collapse:collapse}:host td{padding:0}:host .datepicker__weekdays-wrapper:before,:host .datepicker__weekdays-wrapper:after{content:\" \";display:table}:host .datepicker__weekdays-wrapper:after{clear:both}:host .datepicker__weekdays-container{padding:10px 10px 0;float:left}:host .datepicker__weekdays{table-layout:fixed;width:100%}:host .datepicker__weekday{color:gray;font-size:12px;height:20px;text-align:center}:host .datepicker__day{position:relative;text-align:center;height:40px;width:auto;border:1px solid rgb(217.1695652174,216.8347826087,215.8304347826)}:host .datepicker__day.is-rest{border:none}:host .datepicker__button{padding:0;background-color:transparent;border:none;outline:none;font-style:inherit;cursor:pointer;color:#8e8d8a;width:100%;height:100%}:host .datepicker__button:hover{border:1px solid transparent;background-color:#f2f2f2;color:#8e8d8a}:host .is-hidden{opacity:0;display:table-cell}:host .is-rest{border:none}:host .is-rest .datepicker__button{color:#c0c0be}:host .is-today .datepicker__button{background-color:#eae7dc}:host .is-in-range .datepicker__button{background-color:#e98074;color:#fff}:host .is-in-range .datepicker__button:hover{background-color:#e66c5e}:host .is-selected .datepicker__button{background-color:#e85a4f;color:#fff;font-weight:700}:host .is-selected .datepicker__button:hover{background-color:#e23022}:host .is-start-date .datepicker__button{background-color:#e85a4f;color:#fff}:host .is-end-date .datepicker__button{background-color:#e85a4f;color:#fff}:host .is-disabled .datepicker__button{color:#d9d9d8;cursor:default}:host .is-disabled .datepicker__button:hover{background-color:transparent}:host.is-directive{visibility:hidden;position:absolute}:host.is-open{visibility:visible}:host.is-animate{transition:height .2s ease-in;width:300px}:host.is-animate .datepicker__main{transition:height .2s ease-in}:host.is-animate .datepicker__calendar-wrapper{position:absolute;width:200%;left:0}:host.is-animate .datepicker__calendar{float:left;width:100%}:host.is-animate .datepicker__calendar-container{float:left}\n"] }]
1179
+ }], ctorParameters: () => [{ type: i0.ElementRef }, { type: UtilitiesService }], propDecorators: { numberOfMonths: [{
1180
+ type: Input
1181
+ }], navigate: [{
1182
+ type: Output
1183
+ }], calendarContainer: [{
1184
+ type: ViewChild,
1185
+ args: ['calendarContainer', { static: true }]
1186
+ }], calendarTopContainer: [{
1187
+ type: ViewChild,
1188
+ args: ['calendarTopContainer', { static: true }]
1189
+ }], footer: [{
1190
+ type: ViewChild,
1191
+ args: ['footer', { static: true }]
1192
+ }], datepickerWidth: [{
1193
+ type: HostBinding,
1194
+ args: ['style.width.px']
1195
+ }], datepickerHeight: [{
1196
+ type: HostBinding,
1197
+ args: ['style.height.px']
1198
+ }] } });
1199
+
1200
+ class DatepickerDirective {
1201
+ viewContainerRef;
1202
+ appRef;
1203
+ injector;
1204
+ renderer;
1205
+ formControl;
1206
+ datepicker = null; // TODO: fix types: DatepickerComponent | AnimatepickerComponent
1207
+ datepickerRef = null;
1208
+ clickListener;
1209
+ _options = DefaultDirectiveOptions;
1210
+ set options(options) {
1211
+ if (options === undefined || !options) {
1212
+ return;
1213
+ }
1214
+ // TODO: could be improved
1215
+ this._options = { ...this._options, ...options };
1216
+ }
1217
+ get options() {
1218
+ return this._options;
1219
+ }
1220
+ _datepickerOptions;
1221
+ set datepickerOptions(options) {
1222
+ this._datepickerOptions = options;
1223
+ if (this.datepicker) {
1224
+ this.datepicker.options = options;
1225
+ }
1226
+ }
1227
+ get datepickerOptions() {
1228
+ return this._datepickerOptions;
1229
+ }
1230
+ /**
1231
+ * Set the the language manualy. A string with a BCP 47 language tag
1232
+ * @example nl-NL
1233
+ */
1234
+ _language;
1235
+ set language(value) {
1236
+ this._language = value;
1237
+ if (this.datepicker) {
1238
+ this.datepicker.language = value;
1239
+ }
1240
+ }
1241
+ get language() {
1242
+ return this._language;
1243
+ }
1244
+ /**
1245
+ * Minimal Date: If set the dates before it will be disabled
1246
+ */
1247
+ _minDate;
1248
+ set minDate(value) {
1249
+ this._minDate = value;
1250
+ if (this.datepicker) {
1251
+ this.datepicker.minDate = value;
1252
+ }
1253
+ }
1254
+ get minDate() {
1255
+ return this._minDate;
1256
+ }
1257
+ /**
1258
+ * Maximal Date: If set the dates after it will be disabled
1259
+ */
1260
+ _maxDate;
1261
+ set maxDate(value) {
1262
+ this._maxDate = value;
1263
+ if (this.datepicker) {
1264
+ this.datepicker.maxDate = value;
1265
+ }
1266
+ }
1267
+ get maxDate() {
1268
+ return this._maxDate;
1269
+ }
1270
+ /**
1271
+ * Number of months: the number of months displayed
1272
+ */
1273
+ _numberOfMonths;
1274
+ set numberOfMonths(value) {
1275
+ this._numberOfMonths = value;
1276
+ if (this.datepicker) {
1277
+ this.datepicker.numberOfMonths = value;
1278
+ }
1279
+ }
1280
+ get numberOfMonths() {
1281
+ return this._numberOfMonths;
1282
+ }
1283
+ /**
1284
+ * Theme string is added to the host
1285
+ */
1286
+ _theme;
1287
+ set theme(value) {
1288
+ if (this.datepicker) {
1289
+ this.datepicker.theme = value;
1290
+ }
1291
+ }
1292
+ get theme() {
1293
+ return this._theme;
1294
+ }
1295
+ /**
1296
+ * The open state
1297
+ */
1298
+ _isOpen;
1299
+ set isOpen(value) {
1300
+ this._isOpen = value;
1301
+ if (this.datepicker) {
1302
+ this.datepicker.isOpen = value;
1303
+ }
1304
+ }
1305
+ get isOpen() {
1306
+ return this._isOpen;
1307
+ }
1308
+ /**
1309
+ * Selected Dates: handles the selected dates array. Can be set both internally and externally
1310
+ */
1311
+ _selectedDates = [];
1312
+ selectedDatesChange = new EventEmitter();
1313
+ set selectedDates(value) {
1314
+ if (value === undefined || this._selectedDates === value) {
1315
+ return;
1316
+ }
1317
+ this._selectedDates = value;
1318
+ this.selectedDatesChange.emit(this._selectedDates);
1319
+ }
1320
+ get selectedDates() {
1321
+ return this._selectedDates;
1322
+ }
1323
+ onClick() {
1324
+ if (!this.datepicker) {
1325
+ this.datepicker = this.createDatepicker();
1326
+ this.setDatepickerOptionsAndInputs();
1327
+ this.subscribeToSelectedChanges();
1328
+ }
1329
+ if (!this.datepicker.isOpen) {
1330
+ if (this.options.appendToBody) {
1331
+ this.setPosition();
1332
+ }
1333
+ this.datepicker.open();
1334
+ if (this.options.closeOnBlur) {
1335
+ setTimeout(() => (this.clickListener = this.renderer.listen('document', 'click', this.onBlurHandler.bind(this))));
1336
+ }
1337
+ }
1338
+ }
1339
+ constructor(viewContainerRef, appRef, injector, renderer, formControl) {
1340
+ this.viewContainerRef = viewContainerRef;
1341
+ this.appRef = appRef;
1342
+ this.injector = injector;
1343
+ this.renderer = renderer;
1344
+ this.formControl = formControl;
1345
+ }
1346
+ /**
1347
+ * Add selected changes
1348
+ */
1349
+ subscribeToSelectedChanges() {
1350
+ this.datepicker.selectedDatesChange.subscribe(date => {
1351
+ if (this.formControl) {
1352
+ this.formControl.control.setValue(date);
1353
+ }
1354
+ else {
1355
+ this.selectedDates = date;
1356
+ }
1357
+ });
1358
+ }
1359
+ /**
1360
+ * Set all the options and inputs of the datepicker
1361
+ */
1362
+ setDatepickerOptionsAndInputs() {
1363
+ this.datepicker.options = this.datepickerOptions;
1364
+ this.datepicker.isOpen = this.isOpen || false;
1365
+ this.datepicker.asDirective = true;
1366
+ this.datepicker.numberOfMonths = this.numberOfMonths;
1367
+ this.datepicker.theme = this.theme;
1368
+ this.datepicker._selectedDates = this.selectedDates;
1369
+ this.datepicker.language = this.language;
1370
+ this.datepicker.minDate = this.minDate;
1371
+ this.datepicker.maxDate = this.maxDate;
1372
+ }
1373
+ /**
1374
+ * Handles the (faked) blur event
1375
+ *
1376
+ * @param event
1377
+ */
1378
+ onBlurHandler(event) {
1379
+ if (event.target !== this.datepicker.element.nativeElement &&
1380
+ !this.datepicker.element.nativeElement.contains(event.target)) {
1381
+ // check click origin
1382
+ this.clickListener();
1383
+ this.datepicker.close(true);
1384
+ }
1385
+ }
1386
+ /**
1387
+ * Returns a create DatepickerComponent method
1388
+ */
1389
+ createDatepicker() {
1390
+ return this.options.appendToBody ? this.appendToBody() : this.appendToContainer();
1391
+ }
1392
+ /**
1393
+ * Sets the position of the datepicker
1394
+ */
1395
+ setPosition() {
1396
+ const position = UtilitiesService.getPageOffset(this.viewContainerRef.element.nativeElement);
1397
+ if (this.options.openDirection === 'bottom') {
1398
+ this.datepicker.topPosition = position.bottom;
1399
+ this.datepicker.leftPosition = position.left;
1400
+ }
1401
+ if (this.options.openDirection === 'left') {
1402
+ this.datepicker.topPosition = position.top;
1403
+ this.datepicker.rightPosition = position.forRight;
1404
+ }
1405
+ if (this.options.openDirection === 'right') {
1406
+ this.datepicker.topPosition = position.top;
1407
+ this.datepicker.leftPosition = position.right;
1408
+ }
1409
+ if (this.options.openDirection === 'top') {
1410
+ this.datepicker.bottomPosition = position.forBottom;
1411
+ this.datepicker.leftPosition = position.left;
1412
+ }
1413
+ }
1414
+ /**
1415
+ * Appends the DatepickerComponent to the body and returns the instance
1416
+ */
1417
+ appendToBody() {
1418
+ const datepickerComponent = this.options.useAnimatePicker ? AnimatepickerComponent : DatepickerComponent;
1419
+ this.datepickerRef = createComponent(datepickerComponent, {
1420
+ environmentInjector: this.appRef.injector,
1421
+ elementInjector: this.injector
1422
+ });
1423
+ this.appRef.attachView(this.datepickerRef.hostView);
1424
+ const domElem = this.datepickerRef.hostView.rootNodes[0];
1425
+ document.body.appendChild(domElem);
1426
+ return this.datepickerRef.instance;
1427
+ }
1428
+ /**
1429
+ * Appends the DatepickerComponent to the container and returns the instance
1430
+ */
1431
+ appendToContainer() {
1432
+ const datepickerComponent = this.options.useAnimatePicker ? AnimatepickerComponent : DatepickerComponent;
1433
+ this.datepickerRef = this.viewContainerRef.createComponent(datepickerComponent);
1434
+ return this.datepickerRef.instance;
1435
+ }
1436
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.15", ngImport: i0, type: DatepickerDirective, deps: [{ token: i0.ViewContainerRef }, { token: i0.ApplicationRef }, { token: i0.Injector }, { token: i0.Renderer2 }, { token: i1.NgControl, optional: true }], target: i0.ɵɵFactoryTarget.Directive });
1437
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.15", type: DatepickerDirective, isStandalone: false, selector: "[aaDatepicker]", inputs: { options: ["aaDatepicker", "options"], datepickerOptions: ["options", "datepickerOptions"], language: "language", minDate: "minDate", maxDate: "maxDate", numberOfMonths: "numberOfMonths", theme: "theme", isOpen: "isOpen", selectedDates: "selectedDates" }, outputs: { selectedDatesChange: "selectedDatesChange" }, host: { listeners: { "click": "onClick()" } }, ngImport: i0 });
1438
+ }
1439
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.15", ngImport: i0, type: DatepickerDirective, decorators: [{
1440
+ type: Directive,
1441
+ args: [{
1442
+ selector: '[aaDatepicker]',
1443
+ standalone: false
1444
+ }]
1445
+ }], ctorParameters: () => [{ type: i0.ViewContainerRef }, { type: i0.ApplicationRef }, { type: i0.Injector }, { type: i0.Renderer2 }, { type: i1.NgControl, decorators: [{
1446
+ type: Optional
1447
+ }] }], propDecorators: { options: [{
1448
+ type: Input,
1449
+ args: ['aaDatepicker']
1450
+ }], datepickerOptions: [{
1451
+ type: Input,
1452
+ args: ['options']
1453
+ }], language: [{
1454
+ type: Input
1455
+ }], minDate: [{
1456
+ type: Input
1457
+ }], maxDate: [{
1458
+ type: Input
1459
+ }], numberOfMonths: [{
1460
+ type: Input
1461
+ }], theme: [{
1462
+ type: Input
1463
+ }], isOpen: [{
1464
+ type: Input
1465
+ }], selectedDatesChange: [{
1466
+ type: Output
1467
+ }], selectedDates: [{
1468
+ type: Input
1469
+ }], onClick: [{
1470
+ type: HostListener,
1471
+ args: ['click']
1472
+ }] } });
1473
+
1474
+ class SubNavigationComponent {
1475
+ close = new EventEmitter();
1476
+ subNavigationClick = new EventEmitter();
1477
+ navigationItems;
1478
+ onItemCLick(navigationItem) {
1479
+ const date = new Date(navigationItem.year, navigationItem.month);
1480
+ this.close.emit();
1481
+ this.subNavigationClick.emit(date);
1482
+ }
1483
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.15", ngImport: i0, type: SubNavigationComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
1484
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "21.2.15", type: SubNavigationComponent, isStandalone: false, selector: "aa-sub-navigation", inputs: { navigationItems: "navigationItems" }, outputs: { close: "close", subNavigationClick: "subNavigationClick" }, ngImport: i0, template: "<span (click)=\"close.emit()\">Close</span>\n<div class=\"sub-navigation__items-container\">\n <div class=\"sub-navigation__item\" *ngFor=\"let item of navigationItems;\" (click)=\"onItemCLick(item)\">\n <span class=\"sub-navigation__label\">{{item.navigationTitle}}</span>\n </div>\n</div>\n", styles: [":host{position:absolute;z-index:4;top:0;left:0;width:100%;height:100%;display:block;background-color:#fff}:host .sub-navigation__items-container{display:flex;align-items:center;flex-wrap:wrap}:host .sub-navigation__item{border:1px solid #8e8d8a;width:auto;height:40px;width:40px}\n"], dependencies: [{ kind: "directive", type: i2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }] });
1485
+ }
1486
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.15", ngImport: i0, type: SubNavigationComponent, decorators: [{
1487
+ type: Component,
1488
+ args: [{ selector: 'aa-sub-navigation', standalone: false, template: "<span (click)=\"close.emit()\">Close</span>\n<div class=\"sub-navigation__items-container\">\n <div class=\"sub-navigation__item\" *ngFor=\"let item of navigationItems;\" (click)=\"onItemCLick(item)\">\n <span class=\"sub-navigation__label\">{{item.navigationTitle}}</span>\n </div>\n</div>\n", styles: [":host{position:absolute;z-index:4;top:0;left:0;width:100%;height:100%;display:block;background-color:#fff}:host .sub-navigation__items-container{display:flex;align-items:center;flex-wrap:wrap}:host .sub-navigation__item{border:1px solid #8e8d8a;width:auto;height:40px;width:40px}\n"] }]
1489
+ }], propDecorators: { close: [{
1490
+ type: Output
1491
+ }], subNavigationClick: [{
1492
+ type: Output
1493
+ }], navigationItems: [{
1494
+ type: Input
1495
+ }] } });
1496
+
1497
+ class AaDatepickerModule {
1498
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.15", ngImport: i0, type: AaDatepickerModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1499
+ static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "21.2.15", ngImport: i0, type: AaDatepickerModule, declarations: [DatepickerComponent,
1500
+ NavigationComponent,
1501
+ AnimatepickerComponent,
1502
+ DatepickerDirective,
1503
+ SubNavigationComponent], imports: [CommonModule], exports: [DatepickerComponent,
1504
+ NavigationComponent,
1505
+ AnimatepickerComponent,
1506
+ DatepickerDirective] });
1507
+ static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "21.2.15", ngImport: i0, type: AaDatepickerModule, imports: [CommonModule] });
1508
+ }
1509
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.15", ngImport: i0, type: AaDatepickerModule, decorators: [{
1510
+ type: NgModule,
1511
+ args: [{
1512
+ declarations: [
1513
+ DatepickerComponent,
1514
+ NavigationComponent,
1515
+ AnimatepickerComponent,
1516
+ DatepickerDirective,
1517
+ SubNavigationComponent
1518
+ ],
1519
+ imports: [CommonModule],
1520
+ exports: [
1521
+ DatepickerComponent,
1522
+ NavigationComponent,
1523
+ AnimatepickerComponent,
1524
+ DatepickerDirective
1525
+ ]
1526
+ }]
1527
+ }] });
1528
+
1529
+ /**
1530
+ * Generated bundle index. Do not edit.
1531
+ */
1532
+
1533
+ export { AaDatepickerModule, AnimatepickerComponent, DatepickerComponent, DatepickerDirective, NavigationComponent };
1534
+ //# sourceMappingURL=ngx-animating-datepicker.mjs.map