@skyux/datetime 4.12.0 → 4.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/bundles/skyux-datetime.umd.js +1321 -948
- package/bundles/skyux-datetime.umd.js.map +1 -1
- package/bundles/skyux-datetime.umd.min.js +2 -2
- package/bundles/skyux-datetime.umd.min.js.map +1 -1
- package/esm2015/modules/date-range-picker/date-range-picker.component.js +1 -1
- package/esm2015/modules/datepicker/datepicker-calendar-change.js +1 -0
- package/esm2015/modules/datepicker/datepicker-calendar-inner.component.js +30 -4
- package/esm2015/modules/datepicker/datepicker-calendar.component.js +15 -2
- package/esm2015/modules/datepicker/datepicker-custom-date.js +1 -0
- package/esm2015/modules/datepicker/datepicker-date.js +1 -1
- package/esm2015/modules/datepicker/datepicker-input-fuzzy.directive.js +10 -6
- package/esm2015/modules/datepicker/datepicker-input.directive.js +1 -1
- package/esm2015/modules/datepicker/datepicker.component.js +52 -7
- package/esm2015/modules/datepicker/datepicker.module.js +20 -9
- package/esm2015/modules/datepicker/datepicker.service.js +20 -0
- package/esm2015/modules/datepicker/daypicker-button.component.js +26 -0
- package/esm2015/modules/datepicker/daypicker-cell.component.js +131 -0
- package/esm2015/modules/datepicker/daypicker.component.js +96 -4
- package/esm2015/modules/datepicker/fuzzy-date.service.js +11 -1
- package/esm2015/modules/datepicker/monthpicker.component.js +1 -1
- package/esm2015/modules/datepicker/yearpicker.component.js +1 -1
- package/esm2015/modules/timepicker/timepicker.component.js +7 -4
- package/esm2015/modules/timepicker/timepicker.directive.js +3 -2
- package/esm2015/public_api.js +1 -1
- package/esm2015/skyux-datetime.js +6 -3
- package/esm5/modules/date-range-picker/date-range-picker.component.js +1 -1
- package/esm5/modules/datepicker/datepicker-calendar-change.js +1 -0
- package/esm5/modules/datepicker/datepicker-calendar-inner.component.js +30 -4
- package/esm5/modules/datepicker/datepicker-calendar.component.js +15 -2
- package/esm5/modules/datepicker/datepicker-custom-date.js +1 -0
- package/esm5/modules/datepicker/datepicker-date.js +1 -1
- package/esm5/modules/datepicker/datepicker-input-fuzzy.directive.js +10 -6
- package/esm5/modules/datepicker/datepicker-input.directive.js +1 -1
- package/esm5/modules/datepicker/datepicker.component.js +53 -7
- package/esm5/modules/datepicker/datepicker.module.js +20 -9
- package/esm5/modules/datepicker/datepicker.service.js +21 -0
- package/esm5/modules/datepicker/daypicker-button.component.js +27 -0
- package/esm5/modules/datepicker/daypicker-cell.component.js +134 -0
- package/esm5/modules/datepicker/daypicker.component.js +100 -4
- package/esm5/modules/datepicker/fuzzy-date.service.js +11 -1
- package/esm5/modules/datepicker/monthpicker.component.js +1 -1
- package/esm5/modules/datepicker/yearpicker.component.js +1 -1
- package/esm5/modules/timepicker/timepicker.component.js +7 -4
- package/esm5/modules/timepicker/timepicker.directive.js +3 -2
- package/esm5/public_api.js +1 -1
- package/esm5/skyux-datetime.js +6 -3
- package/fesm2015/skyux-datetime.js +1397 -1036
- package/fesm2015/skyux-datetime.js.map +1 -1
- package/fesm5/skyux-datetime.js +1316 -945
- package/fesm5/skyux-datetime.js.map +1 -1
- package/modules/datepicker/datepicker-calendar-change.d.ts +24 -0
- package/modules/datepicker/datepicker-calendar-inner.component.d.ts +12 -2
- package/modules/datepicker/datepicker-calendar.component.d.ts +6 -0
- package/modules/datepicker/datepicker-custom-date.d.ts +21 -0
- package/modules/datepicker/datepicker-date.d.ts +2 -0
- package/modules/datepicker/datepicker-input-fuzzy.directive.d.ts +1 -0
- package/modules/datepicker/datepicker-input.directive.d.ts +1 -1
- package/modules/datepicker/datepicker.component.d.ts +15 -1
- package/modules/datepicker/datepicker.service.d.ts +12 -0
- package/modules/datepicker/daypicker-button.component.d.ts +13 -0
- package/modules/datepicker/daypicker-cell.component.d.ts +37 -0
- package/modules/datepicker/daypicker.component.d.ts +17 -2
- package/modules/datepicker/fuzzy-date.service.d.ts +5 -1
- package/modules/timepicker/timepicker.component.d.ts +2 -1
- package/package.json +3 -2
- package/public_api.d.ts +2 -0
- package/skyux-datetime.d.ts +5 -2
- package/skyux-datetime.metadata.json +1 -1
- package/src/assets/img/guidelines/date-range-picker/content-error.png +0 -0
package/fesm5/skyux-datetime.js
CHANGED
|
@@ -2,14 +2,15 @@ import { __decorate, __param } from 'tslib';
|
|
|
2
2
|
import { Pipe, Injectable, NgModule, Renderer2, EventEmitter, Input, Output, Component, ViewEncapsulation, ElementRef, ViewChild, ChangeDetectorRef, Optional, TemplateRef, ChangeDetectionStrategy, forwardRef, HostListener, Directive } from '@angular/core';
|
|
3
3
|
import { SkyIntlDateFormatter, SkyAppLocaleProvider, getStringForLocale, SKY_LIB_RESOURCES_PROVIDERS, SkyLibResourcesService, SkyI18nModule } from '@skyux/i18n';
|
|
4
4
|
import { Subject, fromEvent, BehaviorSubject, forkJoin, combineLatest } from 'rxjs';
|
|
5
|
-
import { takeUntil, distinctUntilChanged, first, map } from 'rxjs/operators';
|
|
5
|
+
import { takeUntil, debounceTime, distinctUntilChanged, first, map } from 'rxjs/operators';
|
|
6
6
|
import * as moment_ from 'moment';
|
|
7
7
|
import { CommonModule } from '@angular/common';
|
|
8
8
|
import { NG_VALUE_ACCESSOR, NG_VALIDATORS, FormsModule, FormControl, FormBuilder, ReactiveFormsModule } from '@angular/forms';
|
|
9
9
|
import { SkyAffixAutoFitContext, SkyAffixService, SkyCoreAdapterService, SkyOverlayService, SkyAffixModule, SkyOverlayModule, SkyAppWindowRef } from '@skyux/core';
|
|
10
10
|
import { SkyInputBoxHostService, SkyInputBoxModule } from '@skyux/forms';
|
|
11
|
-
import { SkyIconModule } from '@skyux/indicators';
|
|
11
|
+
import { SkyIconModule, SkyWaitModule } from '@skyux/indicators';
|
|
12
12
|
import { SkyThemeService, SkyThemeModule } from '@skyux/theme';
|
|
13
|
+
import { SkyPopoverMessageType, SkyPopoverModule } from '@skyux/popovers';
|
|
13
14
|
|
|
14
15
|
// This class is mostly ported from the Angular 4.x DatePipe in order to maintain the old
|
|
15
16
|
var moment = moment_;
|
|
@@ -182,6 +183,9 @@ var SkyFuzzyDateService = /** @class */ (function () {
|
|
|
182
183
|
* If not provided, the locale will be taken from the browser's default locale.
|
|
183
184
|
*/
|
|
184
185
|
SkyFuzzyDateService.prototype.format = function (fuzzyDate, format, locale) {
|
|
186
|
+
if (!locale) {
|
|
187
|
+
locale = this.currentLocale;
|
|
188
|
+
}
|
|
185
189
|
if (!this.isFuzzyDateValid(fuzzyDate)) {
|
|
186
190
|
return '';
|
|
187
191
|
}
|
|
@@ -231,6 +235,10 @@ var SkyFuzzyDateService = /** @class */ (function () {
|
|
|
231
235
|
var day = fuzzyDate.day || 1;
|
|
232
236
|
return moment$1([year, month, day]);
|
|
233
237
|
};
|
|
238
|
+
/**
|
|
239
|
+
* Gets a string instance of a fuzzy date.
|
|
240
|
+
* @deprecated Deprecated in favor of the `format` function.
|
|
241
|
+
*/
|
|
234
242
|
SkyFuzzyDateService.prototype.getStringFromFuzzyDate = function (fuzzyDate, dateFormat) {
|
|
235
243
|
if (!fuzzyDate || !dateFormat) {
|
|
236
244
|
return;
|
|
@@ -482,6 +490,9 @@ var SkyFuzzyDateService = /** @class */ (function () {
|
|
|
482
490
|
* year only
|
|
483
491
|
*/
|
|
484
492
|
SkyFuzzyDateService.prototype.isFuzzyDateValid = function (fuzzyDate) {
|
|
493
|
+
if (!fuzzyDate) {
|
|
494
|
+
return false;
|
|
495
|
+
}
|
|
485
496
|
// If none of the dates part are specified, return false.
|
|
486
497
|
if (!fuzzyDate.day && !fuzzyDate.month && !fuzzyDate.year) {
|
|
487
498
|
return false;
|
|
@@ -825,6 +836,7 @@ var SkyDatepickerCalendarInnerComponent = /** @class */ (function () {
|
|
|
825
836
|
39: 'right',
|
|
826
837
|
40: 'down'
|
|
827
838
|
};
|
|
839
|
+
this.ngUnsubscribe = new Subject();
|
|
828
840
|
}
|
|
829
841
|
Object.defineProperty(SkyDatepickerCalendarInnerComponent.prototype, "selectedDate", {
|
|
830
842
|
get: function () {
|
|
@@ -850,6 +862,10 @@ var SkyDatepickerCalendarInnerComponent = /** @class */ (function () {
|
|
|
850
862
|
SkyDatepickerCalendarInnerComponent.prototype.ngOnChanges = function (changes) {
|
|
851
863
|
this.refreshView();
|
|
852
864
|
};
|
|
865
|
+
SkyDatepickerCalendarInnerComponent.prototype.ngOnDestroy = function () {
|
|
866
|
+
this.ngUnsubscribe.next();
|
|
867
|
+
this.ngUnsubscribe.complete();
|
|
868
|
+
};
|
|
853
869
|
SkyDatepickerCalendarInnerComponent.prototype.setCompareHandler = function (handler, type) {
|
|
854
870
|
if (type === 'day') {
|
|
855
871
|
this.compareHandlerDay = handler;
|
|
@@ -953,6 +969,7 @@ var SkyDatepickerCalendarInnerComponent = /** @class */ (function () {
|
|
|
953
969
|
}
|
|
954
970
|
};
|
|
955
971
|
SkyDatepickerCalendarInnerComponent.prototype.createDateObject = function (date, format, isSecondary, id) {
|
|
972
|
+
var customDateMatch = this.getCustomDate(date);
|
|
956
973
|
var dateObject = {
|
|
957
974
|
date: new Date(date.getFullYear(), date.getMonth(), date.getDate()),
|
|
958
975
|
label: this.dateFilter(date, format),
|
|
@@ -960,7 +977,9 @@ var SkyDatepickerCalendarInnerComponent = /** @class */ (function () {
|
|
|
960
977
|
disabled: this.isDisabled(date),
|
|
961
978
|
current: this.compare(date, new Date()) === 0,
|
|
962
979
|
secondary: isSecondary,
|
|
963
|
-
uid: id
|
|
980
|
+
uid: id,
|
|
981
|
+
keyDate: customDateMatch ? customDateMatch.keyDate : undefined,
|
|
982
|
+
keyDateText: customDateMatch ? customDateMatch.keyDateText : []
|
|
964
983
|
};
|
|
965
984
|
return dateObject;
|
|
966
985
|
};
|
|
@@ -1047,10 +1066,27 @@ var SkyDatepickerCalendarInnerComponent = /** @class */ (function () {
|
|
|
1047
1066
|
this.refreshView();
|
|
1048
1067
|
}
|
|
1049
1068
|
};
|
|
1069
|
+
/**
|
|
1070
|
+
* Date is disabled if it meets any of these criteria:
|
|
1071
|
+
* 1. Date falls outside the min or max dates set by the SkyDatepickerConfigService.
|
|
1072
|
+
* 2. Date is marked as disabled in the customDates array.
|
|
1073
|
+
*/
|
|
1050
1074
|
SkyDatepickerCalendarInnerComponent.prototype.isDisabled = function (date) {
|
|
1051
|
-
|
|
1052
|
-
|
|
1075
|
+
var customDate = this.getCustomDate(date);
|
|
1076
|
+
return ((this.minDate && this.compare(date, this.minDate) < 0) ||
|
|
1077
|
+
(this.maxDate && this.compare(date, this.maxDate) > 0)) ||
|
|
1078
|
+
(customDate && customDate.disabled);
|
|
1079
|
+
};
|
|
1080
|
+
SkyDatepickerCalendarInnerComponent.prototype.getCustomDate = function (date) {
|
|
1081
|
+
if (this.customDates) {
|
|
1082
|
+
return this.customDates.find(function (customDate) {
|
|
1083
|
+
return customDate.date.getTime() === date.getTime();
|
|
1084
|
+
});
|
|
1085
|
+
}
|
|
1053
1086
|
};
|
|
1087
|
+
__decorate([
|
|
1088
|
+
Input()
|
|
1089
|
+
], SkyDatepickerCalendarInnerComponent.prototype, "customDates", void 0);
|
|
1054
1090
|
__decorate([
|
|
1055
1091
|
Input()
|
|
1056
1092
|
], SkyDatepickerCalendarInnerComponent.prototype, "startingDay", void 0);
|
|
@@ -1104,6 +1140,7 @@ var SkyDatepickerCalendarComponent = /** @class */ (function () {
|
|
|
1104
1140
|
this.config = config;
|
|
1105
1141
|
this.elementRef = elementRef;
|
|
1106
1142
|
this.selectedDateChange = new EventEmitter(undefined);
|
|
1143
|
+
this.calendarDateRangeChange = new EventEmitter();
|
|
1107
1144
|
this.calendarModeChange = new EventEmitter();
|
|
1108
1145
|
this._now = new Date();
|
|
1109
1146
|
this.formatter = new SkyDateFormatter();
|
|
@@ -1137,6 +1174,9 @@ var SkyDatepickerCalendarComponent = /** @class */ (function () {
|
|
|
1137
1174
|
SkyDatepickerCalendarComponent.prototype.configureOptions = function () {
|
|
1138
1175
|
Object.assign(this, this.config);
|
|
1139
1176
|
};
|
|
1177
|
+
SkyDatepickerCalendarComponent.prototype.onCalendarDateRangeChange = function (event) {
|
|
1178
|
+
this.calendarDateRangeChange.next(event);
|
|
1179
|
+
};
|
|
1140
1180
|
SkyDatepickerCalendarComponent.prototype.onCalendarModeChange = function (event) {
|
|
1141
1181
|
this.calendarModeChange.emit(event);
|
|
1142
1182
|
};
|
|
@@ -1164,6 +1204,12 @@ var SkyDatepickerCalendarComponent = /** @class */ (function () {
|
|
|
1164
1204
|
{ type: SkyDatepickerConfigService },
|
|
1165
1205
|
{ type: ElementRef }
|
|
1166
1206
|
]; };
|
|
1207
|
+
__decorate([
|
|
1208
|
+
Input()
|
|
1209
|
+
], SkyDatepickerCalendarComponent.prototype, "customDates", void 0);
|
|
1210
|
+
__decorate([
|
|
1211
|
+
Input()
|
|
1212
|
+
], SkyDatepickerCalendarComponent.prototype, "isDaypickerWaiting", void 0);
|
|
1167
1213
|
__decorate([
|
|
1168
1214
|
Input()
|
|
1169
1215
|
], SkyDatepickerCalendarComponent.prototype, "minDate", void 0);
|
|
@@ -1179,6 +1225,9 @@ var SkyDatepickerCalendarComponent = /** @class */ (function () {
|
|
|
1179
1225
|
__decorate([
|
|
1180
1226
|
Output()
|
|
1181
1227
|
], SkyDatepickerCalendarComponent.prototype, "selectedDateChange", void 0);
|
|
1228
|
+
__decorate([
|
|
1229
|
+
Output()
|
|
1230
|
+
], SkyDatepickerCalendarComponent.prototype, "calendarDateRangeChange", void 0);
|
|
1182
1231
|
__decorate([
|
|
1183
1232
|
Output()
|
|
1184
1233
|
], SkyDatepickerCalendarComponent.prototype, "calendarModeChange", void 0);
|
|
@@ -1191,7 +1240,7 @@ var SkyDatepickerCalendarComponent = /** @class */ (function () {
|
|
|
1191
1240
|
SkyDatepickerCalendarComponent = __decorate([
|
|
1192
1241
|
Component({
|
|
1193
1242
|
selector: 'sky-datepicker-calendar',
|
|
1194
|
-
template: "<div class=\"sky-datepicker-calendar\">\n <sky-datepicker-inner\n
|
|
1243
|
+
template: "<div class=\"sky-datepicker-calendar\">\n <sky-datepicker-inner\n [customDates]=\"customDates\"\n [selectedDate]=\"selectedDate\"\n [minDate]=\"minDate\"\n [maxDate]=\"maxDate\"\n [startingDay]=\"startingDay\"\n (selectedDateChange)=\"onSelectedDateChange($event)\"\n (calendarModeChange)=\"onCalendarModeChange($event)\"\n >\n <sky-daypicker\n tabindex=\"0\"\n [customDates]=\"customDates\"\n [isWaiting]=\"isDaypickerWaiting\"\n (calendarDateRangeChange)=\"onCalendarDateRangeChange($event)\"\n ></sky-daypicker>\n <sky-monthpicker tabindex=\"0\"></sky-monthpicker>\n <sky-yearpicker tabindex=\"0\"></sky-yearpicker>\n </sky-datepicker-inner>\n</div>\n",
|
|
1195
1244
|
providers: [SkyDatepickerAdapterService],
|
|
1196
1245
|
styles: [".sky-datepicker-calendar{display:block}"]
|
|
1197
1246
|
})
|
|
@@ -1199,794 +1248,557 @@ var SkyDatepickerCalendarComponent = /** @class */ (function () {
|
|
|
1199
1248
|
return SkyDatepickerCalendarComponent;
|
|
1200
1249
|
}());
|
|
1201
1250
|
|
|
1251
|
+
var nextId = 0;
|
|
1202
1252
|
/**
|
|
1203
|
-
*
|
|
1253
|
+
* Creates the datepicker button and calendar.
|
|
1254
|
+
* You must wrap this component around an input with the `skyDatepickerInput` directive.
|
|
1204
1255
|
*/
|
|
1205
|
-
var
|
|
1206
|
-
function
|
|
1207
|
-
this.labels = [];
|
|
1208
|
-
this.rows = [];
|
|
1209
|
-
this.weekNumbers = [];
|
|
1210
|
-
this.daysInMonth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
|
1211
|
-
this.datepicker = datepicker;
|
|
1212
|
-
}
|
|
1213
|
-
SkyDayPickerComponent.prototype.ngOnInit = function () {
|
|
1256
|
+
var SkyDatepickerComponent = /** @class */ (function () {
|
|
1257
|
+
function SkyDatepickerComponent(affixService, changeDetector, coreAdapter, overlayService, inputBoxHostService, themeSvc) {
|
|
1214
1258
|
var _this = this;
|
|
1215
|
-
this.
|
|
1216
|
-
this.
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
this.
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
this.
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1259
|
+
this.affixService = affixService;
|
|
1260
|
+
this.changeDetector = changeDetector;
|
|
1261
|
+
this.coreAdapter = coreAdapter;
|
|
1262
|
+
this.overlayService = overlayService;
|
|
1263
|
+
this.inputBoxHostService = inputBoxHostService;
|
|
1264
|
+
/**
|
|
1265
|
+
* Adds a class to the datepicker.
|
|
1266
|
+
*/
|
|
1267
|
+
this.pickerClass = '';
|
|
1268
|
+
/**
|
|
1269
|
+
* Fires when the range of displayed dates in the calendar changes. Provides the
|
|
1270
|
+
* current range of displayed dates and a mutable `customDate` property consumers can use
|
|
1271
|
+
* to modify individual dates on the calendar.
|
|
1272
|
+
*/
|
|
1273
|
+
this.calendarDateRangeChange = new EventEmitter();
|
|
1274
|
+
this.dateChange = new EventEmitter();
|
|
1275
|
+
this.isDaypickerWaiting = false;
|
|
1276
|
+
this.isOpen = false;
|
|
1277
|
+
this.isVisible = false;
|
|
1278
|
+
this.ngUnsubscribe = new Subject();
|
|
1279
|
+
this._disabled = false;
|
|
1280
|
+
var uniqueId = nextId++;
|
|
1281
|
+
this.calendarId = "sky-datepicker-calendar-" + uniqueId;
|
|
1282
|
+
this.triggerButtonId = "sky-datepicker-button-" + uniqueId;
|
|
1283
|
+
// Update icons when theme changes.
|
|
1284
|
+
themeSvc === null || themeSvc === void 0 ? void 0 : themeSvc.settingsChange.pipe(takeUntil(this.ngUnsubscribe)).subscribe(function () {
|
|
1285
|
+
_this.changeDetector.markForCheck();
|
|
1286
|
+
});
|
|
1287
|
+
}
|
|
1288
|
+
Object.defineProperty(SkyDatepickerComponent.prototype, "buttonIsFocused", {
|
|
1289
|
+
/**
|
|
1290
|
+
* @internal
|
|
1291
|
+
* Indicates if the calendar button element or any of its children have focus.
|
|
1292
|
+
* @deprecated This property will be removed in the next major version release.
|
|
1293
|
+
*/
|
|
1294
|
+
get: function () {
|
|
1295
|
+
/* sanity check */
|
|
1296
|
+
/* istanbul ignore if */
|
|
1297
|
+
if (!this.triggerButtonRef) {
|
|
1298
|
+
return false;
|
|
1299
|
+
}
|
|
1300
|
+
var activeEl = document.activeElement;
|
|
1301
|
+
return this.triggerButtonRef.nativeElement === activeEl;
|
|
1302
|
+
},
|
|
1303
|
+
enumerable: true,
|
|
1304
|
+
configurable: true
|
|
1305
|
+
});
|
|
1306
|
+
Object.defineProperty(SkyDatepickerComponent.prototype, "calendarIsFocused", {
|
|
1307
|
+
/**
|
|
1308
|
+
* @internal
|
|
1309
|
+
* Indicates if the calendar element or any of its children have focus.
|
|
1310
|
+
* @deprecated This property will be removed in the next major version release.
|
|
1311
|
+
*/
|
|
1312
|
+
get: function () {
|
|
1313
|
+
if (!this.calendarRef) {
|
|
1314
|
+
return false;
|
|
1315
|
+
}
|
|
1316
|
+
var focusedEl = document.activeElement;
|
|
1317
|
+
return this.calendarRef.nativeElement.contains(focusedEl);
|
|
1318
|
+
},
|
|
1319
|
+
enumerable: true,
|
|
1320
|
+
configurable: true
|
|
1321
|
+
});
|
|
1322
|
+
Object.defineProperty(SkyDatepickerComponent.prototype, "calendarIsVisible", {
|
|
1323
|
+
/**
|
|
1324
|
+
* @internal
|
|
1325
|
+
* Indicates if the calendar element's visiblity property is 'visible'.
|
|
1326
|
+
* @deprecated This property will be removed in the next major version release.
|
|
1327
|
+
*/
|
|
1328
|
+
get: function () {
|
|
1329
|
+
return this.calendar ? this.calendar.isVisible : false;
|
|
1330
|
+
},
|
|
1331
|
+
enumerable: true,
|
|
1332
|
+
configurable: true
|
|
1333
|
+
});
|
|
1334
|
+
Object.defineProperty(SkyDatepickerComponent.prototype, "disabled", {
|
|
1335
|
+
get: function () {
|
|
1336
|
+
return this._disabled;
|
|
1337
|
+
},
|
|
1338
|
+
set: function (value) {
|
|
1339
|
+
this._disabled = value;
|
|
1340
|
+
this.changeDetector.markForCheck();
|
|
1341
|
+
},
|
|
1342
|
+
enumerable: true,
|
|
1343
|
+
configurable: true
|
|
1344
|
+
});
|
|
1345
|
+
Object.defineProperty(SkyDatepickerComponent.prototype, "selectedDate", {
|
|
1346
|
+
set: function (value) {
|
|
1347
|
+
this._selectedDate = value;
|
|
1348
|
+
if (this.calendar) {
|
|
1349
|
+
this.calendar.writeValue(this._selectedDate);
|
|
1350
|
+
}
|
|
1351
|
+
},
|
|
1352
|
+
enumerable: true,
|
|
1353
|
+
configurable: true
|
|
1354
|
+
});
|
|
1355
|
+
Object.defineProperty(SkyDatepickerComponent.prototype, "calendarRef", {
|
|
1356
|
+
get: function () {
|
|
1357
|
+
return this._calendarRef;
|
|
1358
|
+
},
|
|
1359
|
+
set: function (value) {
|
|
1360
|
+
var _this = this;
|
|
1361
|
+
if (value) {
|
|
1362
|
+
this._calendarRef = value;
|
|
1363
|
+
// Wait for the calendar component to render before gauging dimensions.
|
|
1364
|
+
setTimeout(function () {
|
|
1365
|
+
_this.calendar.writeValue(_this._selectedDate);
|
|
1366
|
+
_this.destroyAffixer();
|
|
1367
|
+
_this.createAffixer();
|
|
1368
|
+
setTimeout(function () {
|
|
1369
|
+
_this.coreAdapter.getFocusableChildrenAndApplyFocus(_this.calendarRef, '.sky-datepicker-calendar-inner', false);
|
|
1370
|
+
_this.isVisible = true;
|
|
1371
|
+
_this.changeDetector.markForCheck();
|
|
1372
|
+
});
|
|
1373
|
+
});
|
|
1374
|
+
}
|
|
1375
|
+
},
|
|
1376
|
+
enumerable: true,
|
|
1377
|
+
configurable: true
|
|
1378
|
+
});
|
|
1379
|
+
SkyDatepickerComponent.prototype.ngOnInit = function () {
|
|
1380
|
+
if (this.inputBoxHostService) {
|
|
1381
|
+
this.inputBoxHostService.populate({
|
|
1382
|
+
inputTemplate: this.inputTemplateRef,
|
|
1383
|
+
buttonsTemplate: this.triggerButtonTemplateRef
|
|
1384
|
+
});
|
|
1235
1385
|
}
|
|
1236
|
-
return dates;
|
|
1237
1386
|
};
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1387
|
+
SkyDatepickerComponent.prototype.ngOnDestroy = function () {
|
|
1388
|
+
this.dateChange.complete();
|
|
1389
|
+
this.ngUnsubscribe.next();
|
|
1390
|
+
this.ngUnsubscribe.complete();
|
|
1391
|
+
this.removePickerEventListeners();
|
|
1392
|
+
this.destroyAffixer();
|
|
1393
|
+
this.destroyOverlay();
|
|
1242
1394
|
};
|
|
1243
|
-
|
|
1244
|
-
var
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
// 42 is the number of days on a six-week calendar
|
|
1258
|
-
var days = this.getDates(firstDate, 42);
|
|
1259
|
-
var pickerDates = [];
|
|
1260
|
-
for (var i = 0; i < 42; i++) {
|
|
1261
|
-
var _dateObject = this.datepicker.createDateObject(days[i], this.datepicker.formatDay, days[i].getMonth() !== month, this.datepicker.datepickerId + '-' + i);
|
|
1262
|
-
pickerDates[i] = _dateObject;
|
|
1395
|
+
SkyDatepickerComponent.prototype.onCalendarModeChange = function () {
|
|
1396
|
+
var _this = this;
|
|
1397
|
+
// Let the calendar populate in the DOM before recalculating placement.
|
|
1398
|
+
setTimeout(function () {
|
|
1399
|
+
_this.affixer.reaffix();
|
|
1400
|
+
});
|
|
1401
|
+
};
|
|
1402
|
+
SkyDatepickerComponent.prototype.onSelectedDateChange = function (value) {
|
|
1403
|
+
this.dateChange.emit(value);
|
|
1404
|
+
this.closePicker();
|
|
1405
|
+
};
|
|
1406
|
+
SkyDatepickerComponent.prototype.onTriggerButtonClick = function () {
|
|
1407
|
+
if (this.isOpen) {
|
|
1408
|
+
this.closePicker();
|
|
1263
1409
|
}
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
this.labels[j] = {};
|
|
1267
|
-
this.labels[j].abbr =
|
|
1268
|
-
this.datepicker.dateFilter(pickerDates[j].date, this.datepicker.formatDayHeader);
|
|
1269
|
-
this.labels[j].full = this.datepicker.dateFilter(pickerDates[j].date, 'EEEE');
|
|
1410
|
+
else {
|
|
1411
|
+
this.openPicker();
|
|
1270
1412
|
}
|
|
1271
|
-
this.title =
|
|
1272
|
-
this.datepicker.dateFilter(this.datepicker.activeDate, this.datepicker.formatDayTitle);
|
|
1273
|
-
this.rows = this.datepicker.createCalendarRows(pickerDates, 7);
|
|
1274
1413
|
};
|
|
1275
|
-
|
|
1276
|
-
var
|
|
1414
|
+
SkyDatepickerComponent.prototype.onCalendarDateRangeChange = function (event) {
|
|
1415
|
+
var _this = this;
|
|
1277
1416
|
/* istanbul ignore else */
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1417
|
+
if (event) {
|
|
1418
|
+
this.cancelCustomDatesSubscription();
|
|
1419
|
+
var args = {
|
|
1420
|
+
startDate: event.startDate,
|
|
1421
|
+
endDate: event.endDate,
|
|
1422
|
+
customDates: undefined
|
|
1423
|
+
};
|
|
1424
|
+
this.calendarDateRangeChange.emit(args);
|
|
1425
|
+
// If consumer has added an observable to the args, watch for incoming custom dates.
|
|
1426
|
+
/* istanbul ignore else */
|
|
1427
|
+
if (args.customDates) {
|
|
1428
|
+
this.isDaypickerWaiting = true;
|
|
1429
|
+
// Avoid an ExpressionChangedAfterItHasBeenCheckedError.
|
|
1430
|
+
this.changeDetector.detectChanges();
|
|
1431
|
+
this.customDatesSubscription = args.customDates
|
|
1432
|
+
.pipe(debounceTime(250))
|
|
1433
|
+
.subscribe(function (result) {
|
|
1434
|
+
_this.customDates = result;
|
|
1435
|
+
_this.isDaypickerWaiting = false;
|
|
1436
|
+
// Trigger change detection in child components to show changes in the calendar.
|
|
1437
|
+
_this.changeDetector.markForCheck();
|
|
1438
|
+
});
|
|
1439
|
+
}
|
|
1290
1440
|
}
|
|
1291
|
-
else if (key === 'pageup' || key === 'pagedown') {
|
|
1292
|
-
var month = this.datepicker.activeDate.getMonth() + (key === 'pageup' ? -1 : 1);
|
|
1293
|
-
this.datepicker.activeDate.setMonth(month, 1);
|
|
1294
|
-
date =
|
|
1295
|
-
Math.min(this.getDaysInMonth(this.datepicker.activeDate.getFullYear(), this.datepicker.activeDate.getMonth()), date);
|
|
1296
|
-
}
|
|
1297
|
-
else if (key === 'home') {
|
|
1298
|
-
date = 1;
|
|
1299
|
-
}
|
|
1300
|
-
else if (key === 'end') {
|
|
1301
|
-
date = this.getDaysInMonth(this.datepicker.activeDate.getFullYear(), this.datepicker.activeDate.getMonth());
|
|
1302
|
-
}
|
|
1303
|
-
this.datepicker.activeDate.setDate(date);
|
|
1304
1441
|
};
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1442
|
+
SkyDatepickerComponent.prototype.closePicker = function () {
|
|
1443
|
+
this.destroyAffixer();
|
|
1444
|
+
this.destroyOverlay();
|
|
1445
|
+
this.removePickerEventListeners();
|
|
1446
|
+
this.triggerButtonRef.nativeElement.focus();
|
|
1447
|
+
this.isOpen = false;
|
|
1308
1448
|
};
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
}());
|
|
1321
|
-
|
|
1322
|
-
/**
|
|
1323
|
-
* @internal
|
|
1324
|
-
*/
|
|
1325
|
-
var SkyMonthPickerComponent = /** @class */ (function () {
|
|
1326
|
-
function SkyMonthPickerComponent(datepicker) {
|
|
1327
|
-
this.rows = [];
|
|
1328
|
-
this.datepicker = datepicker;
|
|
1329
|
-
}
|
|
1330
|
-
SkyMonthPickerComponent.prototype.ngOnInit = function () {
|
|
1449
|
+
SkyDatepickerComponent.prototype.openPicker = function () {
|
|
1450
|
+
this.isVisible = false;
|
|
1451
|
+
this.changeDetector.markForCheck();
|
|
1452
|
+
this.removePickerEventListeners();
|
|
1453
|
+
this.calendarUnsubscribe = new Subject();
|
|
1454
|
+
this.destroyOverlay();
|
|
1455
|
+
this.createOverlay();
|
|
1456
|
+
this.isOpen = true;
|
|
1457
|
+
this.changeDetector.markForCheck();
|
|
1458
|
+
};
|
|
1459
|
+
SkyDatepickerComponent.prototype.createAffixer = function () {
|
|
1331
1460
|
var _this = this;
|
|
1332
|
-
this.
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
this.
|
|
1341
|
-
|
|
1342
|
-
|
|
1461
|
+
var affixer = this.affixService.createAffixer(this.calendarRef);
|
|
1462
|
+
// Hide calendar when trigger button is scrolled off screen.
|
|
1463
|
+
affixer.placementChange
|
|
1464
|
+
.pipe(takeUntil(this.calendarUnsubscribe))
|
|
1465
|
+
.subscribe(function (change) {
|
|
1466
|
+
_this.isVisible = (change.placement !== null);
|
|
1467
|
+
_this.changeDetector.markForCheck();
|
|
1468
|
+
});
|
|
1469
|
+
affixer.affixTo(this.triggerButtonRef.nativeElement, {
|
|
1470
|
+
autoFitContext: SkyAffixAutoFitContext.Viewport,
|
|
1471
|
+
enableAutoFit: true,
|
|
1472
|
+
horizontalAlignment: 'right',
|
|
1473
|
+
isSticky: true,
|
|
1474
|
+
placement: 'below'
|
|
1475
|
+
});
|
|
1476
|
+
this.affixer = affixer;
|
|
1343
1477
|
};
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1478
|
+
SkyDatepickerComponent.prototype.destroyAffixer = function () {
|
|
1479
|
+
/*istanbul ignore else*/
|
|
1480
|
+
if (this.affixer) {
|
|
1481
|
+
this.affixer.destroy();
|
|
1482
|
+
this.affixer = undefined;
|
|
1483
|
+
}
|
|
1348
1484
|
};
|
|
1349
|
-
|
|
1350
|
-
var
|
|
1351
|
-
var
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1485
|
+
SkyDatepickerComponent.prototype.createOverlay = function () {
|
|
1486
|
+
var _this = this;
|
|
1487
|
+
var overlay = this.overlayService.create({
|
|
1488
|
+
wrapperClass: this.pickerClass,
|
|
1489
|
+
enableClose: false,
|
|
1490
|
+
enablePointerEvents: false
|
|
1491
|
+
});
|
|
1492
|
+
overlay.backdropClick
|
|
1493
|
+
.pipe(takeUntil(this.calendarUnsubscribe))
|
|
1494
|
+
.subscribe(function () {
|
|
1495
|
+
if (_this.isOpen) {
|
|
1496
|
+
_this.closePicker();
|
|
1497
|
+
}
|
|
1498
|
+
});
|
|
1499
|
+
this.addKeydownListner();
|
|
1500
|
+
overlay.attachTemplate(this.calendarTemplateRef);
|
|
1501
|
+
this.overlay = overlay;
|
|
1502
|
+
};
|
|
1503
|
+
SkyDatepickerComponent.prototype.destroyOverlay = function () {
|
|
1504
|
+
/*istanbul ignore else*/
|
|
1505
|
+
if (this.overlay) {
|
|
1506
|
+
this.overlayService.close(this.overlay);
|
|
1507
|
+
this.overlay = undefined;
|
|
1358
1508
|
}
|
|
1359
|
-
this.title =
|
|
1360
|
-
this.datepicker.dateFilter(this.datepicker.activeDate, this.datepicker.formatMonthTitle);
|
|
1361
|
-
this.rows = this.datepicker.createCalendarRows(months, this.datepicker.monthColLimit);
|
|
1362
1509
|
};
|
|
1363
|
-
|
|
1364
|
-
var
|
|
1510
|
+
SkyDatepickerComponent.prototype.addKeydownListner = function () {
|
|
1511
|
+
var _this = this;
|
|
1512
|
+
this.overlayKeydownListner = fromEvent(window.document, 'keydown')
|
|
1513
|
+
.pipe(takeUntil(this.ngUnsubscribe))
|
|
1514
|
+
.subscribe(function (event) {
|
|
1515
|
+
var _a;
|
|
1516
|
+
var key = (_a = event.key) === null || _a === void 0 ? void 0 : _a.toLowerCase();
|
|
1517
|
+
if (key === 'escape' && _this.isOpen) {
|
|
1518
|
+
_this.closePicker();
|
|
1519
|
+
}
|
|
1520
|
+
});
|
|
1521
|
+
};
|
|
1522
|
+
SkyDatepickerComponent.prototype.removePickerEventListeners = function () {
|
|
1523
|
+
var _a;
|
|
1365
1524
|
/* istanbul ignore else */
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
else if (key === 'up') {
|
|
1371
|
-
date = date - this.datepicker.monthColLimit;
|
|
1372
|
-
}
|
|
1373
|
-
else if (key === 'right') {
|
|
1374
|
-
date = date + 1;
|
|
1375
|
-
}
|
|
1376
|
-
else if (key === 'down') {
|
|
1377
|
-
date = date + this.datepicker.monthColLimit;
|
|
1378
|
-
}
|
|
1379
|
-
else if (key === 'pageup' || key === 'pagedown') {
|
|
1380
|
-
var year = this.datepicker.activeDate.getFullYear() + (key === 'pageup' ? -1 : 1);
|
|
1381
|
-
this.datepicker.activeDate.setFullYear(year);
|
|
1382
|
-
}
|
|
1383
|
-
else if (key === 'home') {
|
|
1384
|
-
date = 0;
|
|
1525
|
+
if (this.calendarUnsubscribe) {
|
|
1526
|
+
this.calendarUnsubscribe.next();
|
|
1527
|
+
this.calendarUnsubscribe.complete();
|
|
1528
|
+
this.calendarUnsubscribe = undefined;
|
|
1385
1529
|
}
|
|
1386
|
-
|
|
1387
|
-
|
|
1530
|
+
(_a = this.overlayKeydownListner) === null || _a === void 0 ? void 0 : _a.unsubscribe();
|
|
1531
|
+
};
|
|
1532
|
+
SkyDatepickerComponent.prototype.cancelCustomDatesSubscription = function () {
|
|
1533
|
+
if (this.customDatesSubscription) {
|
|
1534
|
+
this.customDatesSubscription.unsubscribe();
|
|
1535
|
+
this.customDatesSubscription = undefined;
|
|
1388
1536
|
}
|
|
1389
|
-
this.datepicker.activeDate.setMonth(date);
|
|
1390
1537
|
};
|
|
1391
|
-
|
|
1392
|
-
{ type:
|
|
1538
|
+
SkyDatepickerComponent.ctorParameters = function () { return [
|
|
1539
|
+
{ type: SkyAffixService },
|
|
1540
|
+
{ type: ChangeDetectorRef },
|
|
1541
|
+
{ type: SkyCoreAdapterService },
|
|
1542
|
+
{ type: SkyOverlayService },
|
|
1543
|
+
{ type: SkyInputBoxHostService, decorators: [{ type: Optional }] },
|
|
1544
|
+
{ type: SkyThemeService, decorators: [{ type: Optional }] }
|
|
1393
1545
|
]; };
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1546
|
+
__decorate([
|
|
1547
|
+
Input()
|
|
1548
|
+
], SkyDatepickerComponent.prototype, "pickerClass", void 0);
|
|
1549
|
+
__decorate([
|
|
1550
|
+
Output()
|
|
1551
|
+
], SkyDatepickerComponent.prototype, "calendarDateRangeChange", void 0);
|
|
1552
|
+
__decorate([
|
|
1553
|
+
ViewChild(SkyDatepickerCalendarComponent)
|
|
1554
|
+
], SkyDatepickerComponent.prototype, "calendar", void 0);
|
|
1555
|
+
__decorate([
|
|
1556
|
+
ViewChild('calendarRef', {
|
|
1557
|
+
read: ElementRef
|
|
1399
1558
|
})
|
|
1400
|
-
],
|
|
1401
|
-
|
|
1559
|
+
], SkyDatepickerComponent.prototype, "calendarRef", null);
|
|
1560
|
+
__decorate([
|
|
1561
|
+
ViewChild('calendarTemplateRef', {
|
|
1562
|
+
read: TemplateRef
|
|
1563
|
+
})
|
|
1564
|
+
], SkyDatepickerComponent.prototype, "calendarTemplateRef", void 0);
|
|
1565
|
+
__decorate([
|
|
1566
|
+
ViewChild('triggerButtonRef', {
|
|
1567
|
+
read: ElementRef
|
|
1568
|
+
})
|
|
1569
|
+
], SkyDatepickerComponent.prototype, "triggerButtonRef", void 0);
|
|
1570
|
+
__decorate([
|
|
1571
|
+
ViewChild('inputTemplateRef', {
|
|
1572
|
+
read: TemplateRef,
|
|
1573
|
+
static: true
|
|
1574
|
+
})
|
|
1575
|
+
], SkyDatepickerComponent.prototype, "inputTemplateRef", void 0);
|
|
1576
|
+
__decorate([
|
|
1577
|
+
ViewChild('triggerButtonTemplateRef', {
|
|
1578
|
+
read: TemplateRef,
|
|
1579
|
+
static: true
|
|
1580
|
+
})
|
|
1581
|
+
], SkyDatepickerComponent.prototype, "triggerButtonTemplateRef", void 0);
|
|
1582
|
+
SkyDatepickerComponent = __decorate([
|
|
1583
|
+
Component({
|
|
1584
|
+
selector: 'sky-datepicker',
|
|
1585
|
+
template: "<div\n class=\"sky-datepicker\"\n>\n <ng-container *ngIf=\"!inputBoxHostService\">\n <div\n class=\"sky-input-group\"\n >\n <ng-container *ngTemplateOutlet=\"inputTemplateRef\"></ng-container>\n <ng-container *ngTemplateOutlet=\"triggerButtonTemplateRef\"></ng-container>\n </div>\n </ng-container>\n</div>\n\n<ng-template #inputTemplateRef>\n <ng-content></ng-content>\n</ng-template>\n\n<ng-template #triggerButtonTemplateRef>\n <div\n class=\"sky-input-group-btn\"\n >\n <button\n aria-haspopup=\"dialog\"\n class=\"sky-btn sky-btn-default sky-input-group-datepicker-btn\"\n type=\"button\"\n [attr.aria-controls]=\"isOpen ? calendarId : null\"\n [attr.aria-expanded]=\"isOpen\"\n [attr.aria-label]=\"'skyux_datepicker_trigger_button_label' | skyLibResources\"\n [attr.id]=\"triggerButtonId\"\n [attr.title]=\"'skyux_datepicker_trigger_button_label' | skyLibResources\"\n [disabled]=\"disabled\"\n (click)=\"onTriggerButtonClick()\"\n #triggerButtonRef\n >\n <sky-icon *skyThemeIf=\"'default'\"\n icon=\"calendar\"\n size=\"lg\"\n ></sky-icon>\n <sky-icon *skyThemeIf=\"'modern'\"\n icon=\"calendar\"\n size=\"lg\"\n iconType=\"skyux\"\n ></sky-icon>\n </button>\n </div>\n</ng-template>\n\n<ng-template #calendarTemplateRef>\n <div\n class=\"sky-datepicker-calendar-container sky-shadow sky-elevation-4\"\n role=\"dialog\"\n [attr.aria-labelledby]=\"triggerButtonId\"\n [attr.id]=\"calendarId\"\n [class.sky-datepicker-hidden]=\"!isVisible\"\n #calendarRef\n >\n <sky-datepicker-calendar\n [customDates]=\"customDates\"\n [isDaypickerWaiting]=\"isDaypickerWaiting\"\n [maxDate]=\"maxDate\"\n [minDate]=\"minDate\"\n [startingDay]=\"startingDay\"\n (calendarDateRangeChange)=\"onCalendarDateRangeChange($event)\"\n (calendarModeChange)=\"onCalendarModeChange()\"\n (selectedDateChange)=\"onSelectedDateChange($event)\"\n >\n </sky-datepicker-calendar>\n </div>\n</ng-template>\n",
|
|
1586
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
1587
|
+
styles: [".sky-datepicker-calendar-container{position:fixed;border-radius:5px}.sky-datepicker-hidden{visibility:hidden}"]
|
|
1588
|
+
}),
|
|
1589
|
+
__param(4, Optional()),
|
|
1590
|
+
__param(5, Optional())
|
|
1591
|
+
], SkyDatepickerComponent);
|
|
1592
|
+
return SkyDatepickerComponent;
|
|
1402
1593
|
}());
|
|
1403
1594
|
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
function
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1595
|
+
var moment$3 = moment_;
|
|
1596
|
+
// tslint:disable:no-forward-ref no-use-before-declare
|
|
1597
|
+
var SKY_DATEPICKER_VALUE_ACCESSOR = {
|
|
1598
|
+
provide: NG_VALUE_ACCESSOR,
|
|
1599
|
+
useExisting: forwardRef(function () { return SkyDatepickerInputDirective; }),
|
|
1600
|
+
multi: true
|
|
1601
|
+
};
|
|
1602
|
+
var SKY_DATEPICKER_VALIDATOR = {
|
|
1603
|
+
provide: NG_VALIDATORS,
|
|
1604
|
+
useExisting: forwardRef(function () { return SkyDatepickerInputDirective; }),
|
|
1605
|
+
multi: true
|
|
1606
|
+
};
|
|
1607
|
+
// tslint:enable
|
|
1608
|
+
var SkyDatepickerInputDirective = /** @class */ (function () {
|
|
1609
|
+
function SkyDatepickerInputDirective(adapter, changeDetector, configService, elementRef, localeProvider, renderer, resourcesService, datepickerComponent) {
|
|
1413
1610
|
var _this = this;
|
|
1414
|
-
this.
|
|
1415
|
-
this.datepicker.setRefreshViewHandler(function () {
|
|
1416
|
-
_this.refreshYearView();
|
|
1417
|
-
}, 'year');
|
|
1418
|
-
this.datepicker.setCompareHandler(this.compareYears, 'year');
|
|
1419
|
-
this.datepicker.setKeydownHandler(function (key, event) {
|
|
1420
|
-
_this.keydownYears(key, event);
|
|
1421
|
-
}, 'year');
|
|
1422
|
-
this.datepicker.refreshView();
|
|
1423
|
-
};
|
|
1424
|
-
SkyYearPickerComponent.prototype.getStartingYear = function (year) {
|
|
1425
|
-
return Math.floor((year - 1) / this.datepicker.yearRange) * this.datepicker.yearRange + 1;
|
|
1426
|
-
};
|
|
1427
|
-
SkyYearPickerComponent.prototype.compareYears = function (date1, date2) {
|
|
1428
|
-
return date1.getFullYear() - date2.getFullYear();
|
|
1429
|
-
};
|
|
1430
|
-
SkyYearPickerComponent.prototype.refreshYearView = function () {
|
|
1431
|
-
var years = new Array(this.datepicker.yearRange);
|
|
1432
|
-
var date;
|
|
1433
|
-
var start = this.getStartingYear(this.datepicker.activeDate.getFullYear());
|
|
1434
|
-
for (var i = 0; i < this.datepicker.yearRange; i++) {
|
|
1435
|
-
date = new Date(this.datepicker.activeDate);
|
|
1436
|
-
date.setFullYear(start + i, 0, 1);
|
|
1437
|
-
years[i] =
|
|
1438
|
-
this.datepicker.createDateObject(date, this.datepicker.formatYear, false, this.datepicker.datepickerId + '-' + i);
|
|
1439
|
-
}
|
|
1440
|
-
this.title = [years[0].label,
|
|
1441
|
-
years[this.datepicker.yearRange - 1].label].join(' - ');
|
|
1442
|
-
this.rows = this.datepicker.createCalendarRows(years, this.datepicker.yearColLimit);
|
|
1443
|
-
};
|
|
1444
|
-
SkyYearPickerComponent.prototype.keydownYears = function (key, event) {
|
|
1445
|
-
var date = this.datepicker.activeDate.getFullYear();
|
|
1446
|
-
/* istanbul ignore else */
|
|
1447
|
-
/* sanity check */
|
|
1448
|
-
if (key === 'left') {
|
|
1449
|
-
date = date - 1;
|
|
1450
|
-
}
|
|
1451
|
-
else if (key === 'up') {
|
|
1452
|
-
date = date - this.datepicker.yearColLimit;
|
|
1453
|
-
}
|
|
1454
|
-
else if (key === 'right') {
|
|
1455
|
-
date = date + 1;
|
|
1456
|
-
}
|
|
1457
|
-
else if (key === 'down') {
|
|
1458
|
-
date = date + this.datepicker.yearColLimit;
|
|
1459
|
-
}
|
|
1460
|
-
else if (key === 'pageup' || key === 'pagedown') {
|
|
1461
|
-
date += (key === 'pageup' ? -1 : 1) * this.datepicker.yearRange;
|
|
1462
|
-
}
|
|
1463
|
-
else if (key === 'home') {
|
|
1464
|
-
date = this.getStartingYear(this.datepicker.activeDate.getFullYear());
|
|
1465
|
-
}
|
|
1466
|
-
else if (key === 'end') {
|
|
1467
|
-
date
|
|
1468
|
-
= this.getStartingYear(this.datepicker.activeDate.getFullYear()) + this.datepicker.yearRange - 1;
|
|
1469
|
-
}
|
|
1470
|
-
this.datepicker.activeDate.setFullYear(date);
|
|
1471
|
-
};
|
|
1472
|
-
SkyYearPickerComponent.ctorParameters = function () { return [
|
|
1473
|
-
{ type: SkyDatepickerCalendarInnerComponent }
|
|
1474
|
-
]; };
|
|
1475
|
-
SkyYearPickerComponent = __decorate([
|
|
1476
|
-
Component({
|
|
1477
|
-
selector: 'sky-yearpicker',
|
|
1478
|
-
template: "<table *ngIf=\"datepicker.datepickerMode==='year'\" role=\"grid\">\n <thead>\n <tr>\n <th\n class=\"sky-datepicker-header-left\"\n >\n <button\n type=\"button\"\n class=\"sky-btn sky-btn-default sky-btn-sm sky-datepicker-btn-previous\"\n (click)=\"datepicker.moveCalendar($event, -1)\"\n tabindex=\"-1\"\n >\n <sky-icon\n class=\"sky-datepicker-chevron-default\"\n icon=\"chevron-left\"\n ></sky-icon>\n <sky-icon\n class=\"sky-datepicker-chevron-modern\"\n icon=\"chevron-left\"\n iconType=\"skyux\"\n ></sky-icon>\n </button>\n </th>\n <th [attr.colspan]=\"((datepicker.yearColLimit - 2) <= 0) ? 1 : datepicker.yearColLimit - 2\">\n <button\n [id]=\"datepicker.datepickerId + '-title'\"\n role=\"heading\"\n type=\"button\"\n class=\"sky-btn sky-btn-default sky-btn-sm sky-datepicker-calendar-title\"\n (click)=\"datepicker.toggleModeCalendar($event)\"\n [disabled]=\"datepicker.datepickerMode === datepicker.maxMode\"\n [ngClass]=\"{'sky-btn-disabled': datepicker.datepickerMode === datepicker.maxMode}\"\n tabindex=\"-1\"\n >\n <strong>{{title}}</strong>\n </button>\n </th>\n <th\n class=\"sky-datepicker-header-right\"\n >\n <button\n type=\"button\"\n class=\"sky-btn sky-btn-default sky-btn-sm sky-datepicker-btn-next\"\n (click)=\"datepicker.moveCalendar($event, 1)\"\n tabindex=\"-1\"\n >\n <sky-icon\n class=\"sky-datepicker-chevron-default\"\n icon=\"chevron-right\"\n ></sky-icon>\n <sky-icon\n class=\"sky-datepicker-chevron-modern\"\n icon=\"chevron-right\"\n iconType=\"skyux\"\n ></sky-icon>\n </button>\n </th>\n </tr>\n </thead>\n <tbody>\n <tr *ngFor=\"let row of rows\">\n <td\n *ngFor=\"let date of row\"\n class=\"sky-datepicker-row\"\n role=\"gridcell\"\n >\n <button\n type=\"button\"\n class=\"sky-btn sky-btn-default sky-datepicker-btn-date\"\n [ngClass]=\"{'sky-datepicker-btn-selected': date.selected, 'sky-btn-disabled': date.disabled, 'sky-btn-active': datepicker.isActive(date)}\"\n [disabled]=\"date.disabled\"\n (click)=\"datepicker.selectCalendar($event, date.date)\"\n tabindex=\"-1\"\n >\n <span\n [ngClass]=\"{'sky-datepicker-current': date.current }\">{{date.label}}</span>\n </button>\n </td>\n </tr>\n </tbody>\n</table>\n",
|
|
1479
|
-
styles: [".sky-theme-modern :host:focus,:host-context(.sky-theme-modern) :host:focus{outline:0}"]
|
|
1480
|
-
})
|
|
1481
|
-
], SkyYearPickerComponent);
|
|
1482
|
-
return SkyYearPickerComponent;
|
|
1483
|
-
}());
|
|
1484
|
-
|
|
1485
|
-
var nextId = 0;
|
|
1486
|
-
/**
|
|
1487
|
-
* Creates the datepicker button and calendar.
|
|
1488
|
-
* You must wrap this component around an input with the `skyDatepickerInput` directive.
|
|
1489
|
-
*/
|
|
1490
|
-
var SkyDatepickerComponent = /** @class */ (function () {
|
|
1491
|
-
function SkyDatepickerComponent(affixService, changeDetector, coreAdapter, overlayService, inputBoxHostService, themeSvc) {
|
|
1492
|
-
var _this = this;
|
|
1493
|
-
this.affixService = affixService;
|
|
1611
|
+
this.adapter = adapter;
|
|
1494
1612
|
this.changeDetector = changeDetector;
|
|
1495
|
-
this.
|
|
1496
|
-
this.
|
|
1497
|
-
this.
|
|
1613
|
+
this.configService = configService;
|
|
1614
|
+
this.elementRef = elementRef;
|
|
1615
|
+
this.localeProvider = localeProvider;
|
|
1616
|
+
this.renderer = renderer;
|
|
1617
|
+
this.resourcesService = resourcesService;
|
|
1618
|
+
this.datepickerComponent = datepickerComponent;
|
|
1498
1619
|
/**
|
|
1499
|
-
*
|
|
1620
|
+
* Indicates whether to disable date validation on the datepicker input.
|
|
1621
|
+
* @default false
|
|
1500
1622
|
*/
|
|
1501
|
-
this.
|
|
1502
|
-
this.
|
|
1503
|
-
this.
|
|
1504
|
-
this.isVisible = false;
|
|
1623
|
+
this.skyDatepickerNoValidate = false;
|
|
1624
|
+
this.dateFormatter = new SkyDateFormatter();
|
|
1625
|
+
this.isFirstChange = true;
|
|
1505
1626
|
this.ngUnsubscribe = new Subject();
|
|
1506
|
-
this.
|
|
1507
|
-
|
|
1508
|
-
this.
|
|
1509
|
-
this.
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1627
|
+
this.onChange = function (_) { };
|
|
1628
|
+
/*istanbul ignore next */
|
|
1629
|
+
this.onTouched = function () { };
|
|
1630
|
+
this.onValidatorChange = function () { };
|
|
1631
|
+
this.initialPlaceholder = this.adapter.getPlaceholder(this.elementRef);
|
|
1632
|
+
this.updatePlaceholder();
|
|
1633
|
+
this.localeProvider.getLocaleInfo()
|
|
1634
|
+
.pipe(takeUntil(this.ngUnsubscribe))
|
|
1635
|
+
.subscribe(function (localeInfo) {
|
|
1636
|
+
SkyDateFormatter.setLocale(localeInfo.locale);
|
|
1637
|
+
_this.preferredShortDateFormat = SkyDateFormatter.getPreferredShortDateFormat();
|
|
1638
|
+
_this.applyDateFormat();
|
|
1513
1639
|
});
|
|
1514
1640
|
}
|
|
1515
|
-
Object.defineProperty(
|
|
1641
|
+
Object.defineProperty(SkyDatepickerInputDirective.prototype, "dateFormat", {
|
|
1642
|
+
get: function () {
|
|
1643
|
+
return this._dateFormat ||
|
|
1644
|
+
this.configService.dateFormat ||
|
|
1645
|
+
this.preferredShortDateFormat;
|
|
1646
|
+
},
|
|
1516
1647
|
/**
|
|
1517
|
-
*
|
|
1518
|
-
*
|
|
1519
|
-
* @
|
|
1648
|
+
* Specifies the date format for the input. Place this attribute on the `input` element
|
|
1649
|
+
* to override the default in the `SkyDatepickerConfigService`.
|
|
1650
|
+
* @default MM/DD/YYYY
|
|
1520
1651
|
*/
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
return false;
|
|
1652
|
+
set: function (value) {
|
|
1653
|
+
if (value !== this._dateFormat) {
|
|
1654
|
+
this._dateFormat = value;
|
|
1655
|
+
this.applyDateFormat();
|
|
1526
1656
|
}
|
|
1527
|
-
var activeEl = document.activeElement;
|
|
1528
|
-
return this.triggerButtonRef.nativeElement === activeEl;
|
|
1529
1657
|
},
|
|
1530
1658
|
enumerable: true,
|
|
1531
1659
|
configurable: true
|
|
1532
1660
|
});
|
|
1533
|
-
Object.defineProperty(
|
|
1661
|
+
Object.defineProperty(SkyDatepickerInputDirective.prototype, "disabled", {
|
|
1662
|
+
get: function () {
|
|
1663
|
+
return this._disabled || false;
|
|
1664
|
+
},
|
|
1534
1665
|
/**
|
|
1535
|
-
*
|
|
1536
|
-
*
|
|
1537
|
-
* @deprecated This property will be removed in the next major version release.
|
|
1666
|
+
* Indicates whether to disable the datepicker.
|
|
1667
|
+
* @default false
|
|
1538
1668
|
*/
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
var focusedEl = document.activeElement;
|
|
1544
|
-
return this.calendarRef.nativeElement.contains(focusedEl);
|
|
1669
|
+
set: function (value) {
|
|
1670
|
+
this._disabled = value;
|
|
1671
|
+
this.datepickerComponent.disabled = value;
|
|
1672
|
+
this.renderer.setProperty(this.elementRef.nativeElement, 'disabled', value);
|
|
1545
1673
|
},
|
|
1546
1674
|
enumerable: true,
|
|
1547
1675
|
configurable: true
|
|
1548
1676
|
});
|
|
1549
|
-
Object.defineProperty(
|
|
1677
|
+
Object.defineProperty(SkyDatepickerInputDirective.prototype, "inputIsFocused", {
|
|
1550
1678
|
/**
|
|
1551
1679
|
* @internal
|
|
1552
|
-
* Indicates if the
|
|
1553
|
-
* @deprecated This property will be removed in the next major version release.
|
|
1680
|
+
* Indicates if the input element or any of its children have focus.
|
|
1554
1681
|
*/
|
|
1555
1682
|
get: function () {
|
|
1556
|
-
return this.
|
|
1683
|
+
return this.adapter.elementIsFocused();
|
|
1557
1684
|
},
|
|
1558
1685
|
enumerable: true,
|
|
1559
1686
|
configurable: true
|
|
1560
1687
|
});
|
|
1561
|
-
Object.defineProperty(
|
|
1688
|
+
Object.defineProperty(SkyDatepickerInputDirective.prototype, "maxDate", {
|
|
1562
1689
|
get: function () {
|
|
1563
|
-
return this.
|
|
1690
|
+
return this._maxDate || this.configService.maxDate;
|
|
1564
1691
|
},
|
|
1692
|
+
/**
|
|
1693
|
+
* Specifies the latest date that is available in the calendar. Place this attribute on
|
|
1694
|
+
* the `input` element to override the default in `SkyDatepickerConfigService`.
|
|
1695
|
+
*/
|
|
1565
1696
|
set: function (value) {
|
|
1566
|
-
this.
|
|
1567
|
-
this.
|
|
1697
|
+
this._maxDate = value;
|
|
1698
|
+
this.datepickerComponent.maxDate = this.maxDate;
|
|
1699
|
+
this.onValidatorChange();
|
|
1568
1700
|
},
|
|
1569
1701
|
enumerable: true,
|
|
1570
1702
|
configurable: true
|
|
1571
1703
|
});
|
|
1572
|
-
Object.defineProperty(
|
|
1704
|
+
Object.defineProperty(SkyDatepickerInputDirective.prototype, "minDate", {
|
|
1705
|
+
get: function () {
|
|
1706
|
+
return this._minDate || this.configService.minDate;
|
|
1707
|
+
},
|
|
1708
|
+
/**
|
|
1709
|
+
* Specifies the earliest date that is available in the calendar. Place this attribute on
|
|
1710
|
+
* the `input` element to override the default in `SkyDatepickerConfigService`.
|
|
1711
|
+
*/
|
|
1573
1712
|
set: function (value) {
|
|
1574
|
-
this.
|
|
1575
|
-
|
|
1576
|
-
|
|
1713
|
+
this._minDate = value;
|
|
1714
|
+
this.datepickerComponent.minDate = this.minDate;
|
|
1715
|
+
this.onValidatorChange();
|
|
1716
|
+
},
|
|
1717
|
+
enumerable: true,
|
|
1718
|
+
configurable: true
|
|
1719
|
+
});
|
|
1720
|
+
Object.defineProperty(SkyDatepickerInputDirective.prototype, "skyDatepickerInput", {
|
|
1721
|
+
/**
|
|
1722
|
+
* Creates the datepicker input and calendar. Place this directive on an `input` element,
|
|
1723
|
+
* and wrap the input in a `sky-datepicker` component. The value that users select is driven
|
|
1724
|
+
* through the `ngModel` attribute specified on the `input` element.
|
|
1725
|
+
* @required
|
|
1726
|
+
*/
|
|
1727
|
+
set: function (value) {
|
|
1728
|
+
if (value) {
|
|
1729
|
+
console.warn('[Deprecation warning] You no longer need to provide a template reference variable ' +
|
|
1730
|
+
'to the `skyDatepickerInput` attribute (this will be a breaking change in the next ' +
|
|
1731
|
+
'major version release).\n' +
|
|
1732
|
+
'Do this instead:\n' +
|
|
1733
|
+
'<sky-datepicker>\n <input skyDatepickerInput />\n</sky-datepicker>');
|
|
1577
1734
|
}
|
|
1578
1735
|
},
|
|
1579
1736
|
enumerable: true,
|
|
1580
1737
|
configurable: true
|
|
1581
1738
|
});
|
|
1582
|
-
Object.defineProperty(
|
|
1739
|
+
Object.defineProperty(SkyDatepickerInputDirective.prototype, "startingDay", {
|
|
1583
1740
|
get: function () {
|
|
1584
|
-
return this.
|
|
1741
|
+
return this._startingDay || this.configService.startingDay;
|
|
1585
1742
|
},
|
|
1743
|
+
/**
|
|
1744
|
+
* Specifies the starting day of the week in the calendar, where `0` sets the starting day
|
|
1745
|
+
* to Sunday. Place this attribute on the `input` element to override the default
|
|
1746
|
+
* in `SkyDatepickerConfigService`.
|
|
1747
|
+
* @default 0
|
|
1748
|
+
*/
|
|
1586
1749
|
set: function (value) {
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
// Wait for the calendar component to render before gauging dimensions.
|
|
1591
|
-
setTimeout(function () {
|
|
1592
|
-
_this.calendar.writeValue(_this._selectedDate);
|
|
1593
|
-
_this.destroyAffixer();
|
|
1594
|
-
_this.createAffixer();
|
|
1595
|
-
setTimeout(function () {
|
|
1596
|
-
_this.coreAdapter.getFocusableChildrenAndApplyFocus(_this.calendarRef, '.sky-datepicker-calendar-inner', false);
|
|
1597
|
-
_this.isVisible = true;
|
|
1598
|
-
_this.changeDetector.markForCheck();
|
|
1599
|
-
});
|
|
1600
|
-
});
|
|
1601
|
-
}
|
|
1750
|
+
this._startingDay = value;
|
|
1751
|
+
this.datepickerComponent.startingDay = this.startingDay;
|
|
1752
|
+
this.onValidatorChange();
|
|
1602
1753
|
},
|
|
1603
1754
|
enumerable: true,
|
|
1604
1755
|
configurable: true
|
|
1605
1756
|
});
|
|
1606
|
-
|
|
1607
|
-
this.addTriggerButtonEventListeners();
|
|
1608
|
-
if (this.inputBoxHostService) {
|
|
1609
|
-
this.inputBoxHostService.populate({
|
|
1610
|
-
inputTemplate: this.inputTemplateRef,
|
|
1611
|
-
buttonsTemplate: this.triggerButtonTemplateRef
|
|
1612
|
-
});
|
|
1613
|
-
}
|
|
1614
|
-
};
|
|
1615
|
-
SkyDatepickerComponent.prototype.ngOnDestroy = function () {
|
|
1616
|
-
this.dateChange.complete();
|
|
1617
|
-
this.ngUnsubscribe.next();
|
|
1618
|
-
this.ngUnsubscribe.complete();
|
|
1619
|
-
this.removePickerEventListeners();
|
|
1620
|
-
this.destroyAffixer();
|
|
1621
|
-
this.destroyOverlay();
|
|
1622
|
-
};
|
|
1623
|
-
SkyDatepickerComponent.prototype.onCalendarModeChange = function () {
|
|
1624
|
-
var _this = this;
|
|
1625
|
-
// Let the calendar populate in the DOM before recalculating placement.
|
|
1626
|
-
setTimeout(function () {
|
|
1627
|
-
_this.affixer.reaffix();
|
|
1628
|
-
});
|
|
1629
|
-
};
|
|
1630
|
-
SkyDatepickerComponent.prototype.onSelectedDateChange = function (value) {
|
|
1631
|
-
this.dateChange.emit(value);
|
|
1632
|
-
this.closePicker();
|
|
1633
|
-
};
|
|
1634
|
-
SkyDatepickerComponent.prototype.onTriggerButtonClick = function () {
|
|
1635
|
-
if (this.isOpen) {
|
|
1636
|
-
this.closePicker();
|
|
1637
|
-
}
|
|
1638
|
-
else {
|
|
1639
|
-
this.openPicker();
|
|
1640
|
-
}
|
|
1641
|
-
};
|
|
1642
|
-
SkyDatepickerComponent.prototype.closePicker = function () {
|
|
1643
|
-
this.destroyAffixer();
|
|
1644
|
-
this.destroyOverlay();
|
|
1645
|
-
this.removePickerEventListeners();
|
|
1646
|
-
this.triggerButtonRef.nativeElement.focus();
|
|
1647
|
-
this.isOpen = false;
|
|
1648
|
-
};
|
|
1649
|
-
SkyDatepickerComponent.prototype.openPicker = function () {
|
|
1650
|
-
this.isVisible = false;
|
|
1651
|
-
this.changeDetector.markForCheck();
|
|
1652
|
-
this.removePickerEventListeners();
|
|
1653
|
-
this.calendarUnsubscribe = new Subject();
|
|
1654
|
-
this.destroyOverlay();
|
|
1655
|
-
this.createOverlay();
|
|
1656
|
-
this.isOpen = true;
|
|
1657
|
-
this.changeDetector.markForCheck();
|
|
1658
|
-
};
|
|
1659
|
-
SkyDatepickerComponent.prototype.createAffixer = function () {
|
|
1660
|
-
var _this = this;
|
|
1661
|
-
var affixer = this.affixService.createAffixer(this.calendarRef);
|
|
1662
|
-
// Hide calendar when trigger button is scrolled off screen.
|
|
1663
|
-
affixer.placementChange
|
|
1664
|
-
.pipe(takeUntil(this.calendarUnsubscribe))
|
|
1665
|
-
.subscribe(function (change) {
|
|
1666
|
-
_this.isVisible = (change.placement !== null);
|
|
1667
|
-
_this.changeDetector.markForCheck();
|
|
1668
|
-
});
|
|
1669
|
-
affixer.affixTo(this.triggerButtonRef.nativeElement, {
|
|
1670
|
-
autoFitContext: SkyAffixAutoFitContext.Viewport,
|
|
1671
|
-
enableAutoFit: true,
|
|
1672
|
-
horizontalAlignment: 'right',
|
|
1673
|
-
isSticky: true,
|
|
1674
|
-
placement: 'below'
|
|
1675
|
-
});
|
|
1676
|
-
this.affixer = affixer;
|
|
1677
|
-
};
|
|
1678
|
-
SkyDatepickerComponent.prototype.destroyAffixer = function () {
|
|
1679
|
-
/*istanbul ignore else*/
|
|
1680
|
-
if (this.affixer) {
|
|
1681
|
-
this.affixer.destroy();
|
|
1682
|
-
this.affixer = undefined;
|
|
1683
|
-
}
|
|
1684
|
-
};
|
|
1685
|
-
SkyDatepickerComponent.prototype.createOverlay = function () {
|
|
1686
|
-
var _this = this;
|
|
1687
|
-
var overlay = this.overlayService.create({
|
|
1688
|
-
wrapperClass: this.pickerClass,
|
|
1689
|
-
enableClose: false,
|
|
1690
|
-
enablePointerEvents: false
|
|
1691
|
-
});
|
|
1692
|
-
overlay.backdropClick
|
|
1693
|
-
.pipe(takeUntil(this.calendarUnsubscribe))
|
|
1694
|
-
.subscribe(function () {
|
|
1695
|
-
if (_this.isOpen) {
|
|
1696
|
-
_this.closePicker();
|
|
1697
|
-
}
|
|
1698
|
-
});
|
|
1699
|
-
overlay.attachTemplate(this.calendarTemplateRef);
|
|
1700
|
-
this.overlay = overlay;
|
|
1701
|
-
};
|
|
1702
|
-
SkyDatepickerComponent.prototype.destroyOverlay = function () {
|
|
1703
|
-
/*istanbul ignore else*/
|
|
1704
|
-
if (this.overlay) {
|
|
1705
|
-
this.overlayService.close(this.overlay);
|
|
1706
|
-
this.overlay = undefined;
|
|
1707
|
-
}
|
|
1708
|
-
};
|
|
1709
|
-
SkyDatepickerComponent.prototype.addTriggerButtonEventListeners = function () {
|
|
1710
|
-
var _this = this;
|
|
1711
|
-
fromEvent(window.document, 'keydown')
|
|
1712
|
-
.pipe(takeUntil(this.ngUnsubscribe))
|
|
1713
|
-
.subscribe(function (event) {
|
|
1714
|
-
var _a;
|
|
1715
|
-
var key = (_a = event.key) === null || _a === void 0 ? void 0 : _a.toLowerCase();
|
|
1716
|
-
if (key === 'escape' && _this.isOpen) {
|
|
1717
|
-
_this.closePicker();
|
|
1718
|
-
}
|
|
1719
|
-
});
|
|
1720
|
-
};
|
|
1721
|
-
SkyDatepickerComponent.prototype.removePickerEventListeners = function () {
|
|
1722
|
-
/* istanbul ignore else */
|
|
1723
|
-
if (this.calendarUnsubscribe) {
|
|
1724
|
-
this.calendarUnsubscribe.next();
|
|
1725
|
-
this.calendarUnsubscribe.complete();
|
|
1726
|
-
this.calendarUnsubscribe = undefined;
|
|
1727
|
-
}
|
|
1728
|
-
};
|
|
1729
|
-
SkyDatepickerComponent.ctorParameters = function () { return [
|
|
1730
|
-
{ type: SkyAffixService },
|
|
1731
|
-
{ type: ChangeDetectorRef },
|
|
1732
|
-
{ type: SkyCoreAdapterService },
|
|
1733
|
-
{ type: SkyOverlayService },
|
|
1734
|
-
{ type: SkyInputBoxHostService, decorators: [{ type: Optional }] },
|
|
1735
|
-
{ type: SkyThemeService, decorators: [{ type: Optional }] }
|
|
1736
|
-
]; };
|
|
1737
|
-
__decorate([
|
|
1738
|
-
Input()
|
|
1739
|
-
], SkyDatepickerComponent.prototype, "pickerClass", void 0);
|
|
1740
|
-
__decorate([
|
|
1741
|
-
ViewChild(SkyDatepickerCalendarComponent)
|
|
1742
|
-
], SkyDatepickerComponent.prototype, "calendar", void 0);
|
|
1743
|
-
__decorate([
|
|
1744
|
-
ViewChild('calendarRef', {
|
|
1745
|
-
read: ElementRef
|
|
1746
|
-
})
|
|
1747
|
-
], SkyDatepickerComponent.prototype, "calendarRef", null);
|
|
1748
|
-
__decorate([
|
|
1749
|
-
ViewChild('calendarTemplateRef', {
|
|
1750
|
-
read: TemplateRef
|
|
1751
|
-
})
|
|
1752
|
-
], SkyDatepickerComponent.prototype, "calendarTemplateRef", void 0);
|
|
1753
|
-
__decorate([
|
|
1754
|
-
ViewChild('triggerButtonRef', {
|
|
1755
|
-
read: ElementRef
|
|
1756
|
-
})
|
|
1757
|
-
], SkyDatepickerComponent.prototype, "triggerButtonRef", void 0);
|
|
1758
|
-
__decorate([
|
|
1759
|
-
ViewChild('inputTemplateRef', {
|
|
1760
|
-
read: TemplateRef,
|
|
1761
|
-
static: true
|
|
1762
|
-
})
|
|
1763
|
-
], SkyDatepickerComponent.prototype, "inputTemplateRef", void 0);
|
|
1764
|
-
__decorate([
|
|
1765
|
-
ViewChild('triggerButtonTemplateRef', {
|
|
1766
|
-
read: TemplateRef,
|
|
1767
|
-
static: true
|
|
1768
|
-
})
|
|
1769
|
-
], SkyDatepickerComponent.prototype, "triggerButtonTemplateRef", void 0);
|
|
1770
|
-
SkyDatepickerComponent = __decorate([
|
|
1771
|
-
Component({
|
|
1772
|
-
selector: 'sky-datepicker',
|
|
1773
|
-
template: "<div\n class=\"sky-datepicker\"\n>\n <ng-container *ngIf=\"!inputBoxHostService\">\n <div\n class=\"sky-input-group\"\n >\n <ng-container *ngTemplateOutlet=\"inputTemplateRef\"></ng-container>\n <ng-container *ngTemplateOutlet=\"triggerButtonTemplateRef\"></ng-container>\n </div>\n </ng-container>\n</div>\n\n<ng-template #inputTemplateRef>\n <ng-content></ng-content>\n</ng-template>\n\n<ng-template #triggerButtonTemplateRef>\n <div\n class=\"sky-input-group-btn\"\n >\n <button\n aria-haspopup=\"dialog\"\n class=\"sky-btn sky-btn-default sky-input-group-datepicker-btn\"\n type=\"button\"\n [attr.aria-controls]=\"isOpen ? calendarId : null\"\n [attr.aria-expanded]=\"isOpen\"\n [attr.aria-label]=\"'skyux_datepicker_trigger_button_label' | skyLibResources\"\n [attr.id]=\"triggerButtonId\"\n [attr.title]=\"'skyux_datepicker_trigger_button_label' | skyLibResources\"\n [disabled]=\"disabled\"\n (click)=\"onTriggerButtonClick()\"\n #triggerButtonRef\n >\n <sky-icon *skyThemeIf=\"'default'\"\n icon=\"calendar\"\n size=\"lg\"\n ></sky-icon>\n <sky-icon *skyThemeIf=\"'modern'\"\n icon=\"calendar\"\n size=\"lg\"\n iconType=\"skyux\"\n ></sky-icon>\n </button>\n </div>\n</ng-template>\n\n<ng-template #calendarTemplateRef>\n <div\n class=\"sky-datepicker-calendar-container sky-shadow sky-elevation-4\"\n role=\"dialog\"\n [attr.aria-labelledby]=\"triggerButtonId\"\n [attr.id]=\"calendarId\"\n [class.sky-datepicker-hidden]=\"!isVisible\"\n #calendarRef\n >\n <sky-datepicker-calendar\n [maxDate]=\"maxDate\"\n [minDate]=\"minDate\"\n [startingDay]=\"startingDay\"\n (calendarModeChange)=\"onCalendarModeChange()\"\n (selectedDateChange)=\"onSelectedDateChange($event)\"\n >\n </sky-datepicker-calendar>\n </div>\n</ng-template>\n",
|
|
1774
|
-
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
1775
|
-
styles: [".sky-datepicker-calendar-container{position:fixed;border-radius:5px}.sky-datepicker-hidden{visibility:hidden}"]
|
|
1776
|
-
}),
|
|
1777
|
-
__param(4, Optional()),
|
|
1778
|
-
__param(5, Optional())
|
|
1779
|
-
], SkyDatepickerComponent);
|
|
1780
|
-
return SkyDatepickerComponent;
|
|
1781
|
-
}());
|
|
1782
|
-
|
|
1783
|
-
var moment$3 = moment_;
|
|
1784
|
-
// tslint:disable:no-forward-ref no-use-before-declare
|
|
1785
|
-
var SKY_DATEPICKER_VALUE_ACCESSOR = {
|
|
1786
|
-
provide: NG_VALUE_ACCESSOR,
|
|
1787
|
-
useExisting: forwardRef(function () { return SkyDatepickerInputDirective; }),
|
|
1788
|
-
multi: true
|
|
1789
|
-
};
|
|
1790
|
-
var SKY_DATEPICKER_VALIDATOR = {
|
|
1791
|
-
provide: NG_VALIDATORS,
|
|
1792
|
-
useExisting: forwardRef(function () { return SkyDatepickerInputDirective; }),
|
|
1793
|
-
multi: true
|
|
1794
|
-
};
|
|
1795
|
-
// tslint:enable
|
|
1796
|
-
var SkyDatepickerInputDirective = /** @class */ (function () {
|
|
1797
|
-
function SkyDatepickerInputDirective(adapter, changeDetector, configService, elementRef, localeProvider, renderer, resourcesService, datepickerComponent) {
|
|
1798
|
-
var _this = this;
|
|
1799
|
-
this.adapter = adapter;
|
|
1800
|
-
this.changeDetector = changeDetector;
|
|
1801
|
-
this.configService = configService;
|
|
1802
|
-
this.elementRef = elementRef;
|
|
1803
|
-
this.localeProvider = localeProvider;
|
|
1804
|
-
this.renderer = renderer;
|
|
1805
|
-
this.resourcesService = resourcesService;
|
|
1806
|
-
this.datepickerComponent = datepickerComponent;
|
|
1807
|
-
/**
|
|
1808
|
-
* Indicates whether to disable date validation on the datepicker input.
|
|
1809
|
-
* @default false
|
|
1810
|
-
*/
|
|
1811
|
-
this.skyDatepickerNoValidate = false;
|
|
1812
|
-
this.dateFormatter = new SkyDateFormatter();
|
|
1813
|
-
this.isFirstChange = true;
|
|
1814
|
-
this.ngUnsubscribe = new Subject();
|
|
1815
|
-
this.onChange = function (_) { };
|
|
1816
|
-
/*istanbul ignore next */
|
|
1817
|
-
this.onTouched = function () { };
|
|
1818
|
-
this.onValidatorChange = function () { };
|
|
1819
|
-
this.initialPlaceholder = this.adapter.getPlaceholder(this.elementRef);
|
|
1820
|
-
this.updatePlaceholder();
|
|
1821
|
-
this.localeProvider.getLocaleInfo()
|
|
1822
|
-
.pipe(takeUntil(this.ngUnsubscribe))
|
|
1823
|
-
.subscribe(function (localeInfo) {
|
|
1824
|
-
SkyDateFormatter.setLocale(localeInfo.locale);
|
|
1825
|
-
_this.preferredShortDateFormat = SkyDateFormatter.getPreferredShortDateFormat();
|
|
1826
|
-
_this.applyDateFormat();
|
|
1827
|
-
});
|
|
1828
|
-
}
|
|
1829
|
-
Object.defineProperty(SkyDatepickerInputDirective.prototype, "dateFormat", {
|
|
1757
|
+
Object.defineProperty(SkyDatepickerInputDirective.prototype, "strict", {
|
|
1830
1758
|
get: function () {
|
|
1831
|
-
return this.
|
|
1832
|
-
this.configService.dateFormat ||
|
|
1833
|
-
this.preferredShortDateFormat;
|
|
1759
|
+
return this._strict || false;
|
|
1834
1760
|
},
|
|
1835
1761
|
/**
|
|
1836
|
-
*
|
|
1837
|
-
*
|
|
1838
|
-
*
|
|
1762
|
+
* Indicates whether the format of the date value must match the format from the `dateFormat` value.
|
|
1763
|
+
* If this property is `true` and the datepicker input directive cannot find an exact match, then
|
|
1764
|
+
* the input is marked as invalid.
|
|
1765
|
+
* If this property is `false` and the datepicker input directive cannot find an exact match, then
|
|
1766
|
+
* it attempts to format the string based on the [ISO 8601 standard format](https://www.iso.org/iso-8601-date-and-time-format.html).
|
|
1767
|
+
* @default false
|
|
1839
1768
|
*/
|
|
1840
1769
|
set: function (value) {
|
|
1841
|
-
|
|
1842
|
-
this._dateFormat = value;
|
|
1843
|
-
this.applyDateFormat();
|
|
1844
|
-
}
|
|
1770
|
+
this._strict = value;
|
|
1845
1771
|
},
|
|
1846
1772
|
enumerable: true,
|
|
1847
1773
|
configurable: true
|
|
1848
1774
|
});
|
|
1849
|
-
Object.defineProperty(SkyDatepickerInputDirective.prototype, "
|
|
1775
|
+
Object.defineProperty(SkyDatepickerInputDirective.prototype, "value", {
|
|
1850
1776
|
get: function () {
|
|
1851
|
-
return this.
|
|
1777
|
+
return this._value;
|
|
1852
1778
|
},
|
|
1853
|
-
/**
|
|
1854
|
-
* Indicates whether to disable the datepicker.
|
|
1855
|
-
* @default false
|
|
1856
|
-
*/
|
|
1857
1779
|
set: function (value) {
|
|
1858
|
-
|
|
1859
|
-
this.
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
/**
|
|
1881
|
-
* Specifies the latest date that is available in the calendar. Place this attribute on
|
|
1882
|
-
* the `input` element to override the default in `SkyDatepickerConfigService`.
|
|
1883
|
-
*/
|
|
1884
|
-
set: function (value) {
|
|
1885
|
-
this._maxDate = value;
|
|
1886
|
-
this.datepickerComponent.maxDate = this.maxDate;
|
|
1887
|
-
this.onValidatorChange();
|
|
1888
|
-
},
|
|
1889
|
-
enumerable: true,
|
|
1890
|
-
configurable: true
|
|
1891
|
-
});
|
|
1892
|
-
Object.defineProperty(SkyDatepickerInputDirective.prototype, "minDate", {
|
|
1893
|
-
get: function () {
|
|
1894
|
-
return this._minDate || this.configService.minDate;
|
|
1895
|
-
},
|
|
1896
|
-
/**
|
|
1897
|
-
* Specifies the earliest date that is available in the calendar. Place this attribute on
|
|
1898
|
-
* the `input` element to override the default in `SkyDatepickerConfigService`.
|
|
1899
|
-
*/
|
|
1900
|
-
set: function (value) {
|
|
1901
|
-
this._minDate = value;
|
|
1902
|
-
this.datepickerComponent.minDate = this.minDate;
|
|
1903
|
-
this.onValidatorChange();
|
|
1904
|
-
},
|
|
1905
|
-
enumerable: true,
|
|
1906
|
-
configurable: true
|
|
1907
|
-
});
|
|
1908
|
-
Object.defineProperty(SkyDatepickerInputDirective.prototype, "skyDatepickerInput", {
|
|
1909
|
-
/**
|
|
1910
|
-
* Creates the datepicker input and calendar. Place this directive on an `input` element,
|
|
1911
|
-
* and wrap the input in a `sky-datepicker` component. The value that users select is driven
|
|
1912
|
-
* through the `ngModel` attribute specified on the `input` element.
|
|
1913
|
-
* @required
|
|
1914
|
-
*/
|
|
1915
|
-
set: function (value) {
|
|
1916
|
-
if (value) {
|
|
1917
|
-
console.warn('[Deprecation warning] You no longer need to provide a template reference variable ' +
|
|
1918
|
-
'to the `skyDatepickerInput` attribute (this will be a breaking change in the next ' +
|
|
1919
|
-
'major version release).\n' +
|
|
1920
|
-
'Do this instead:\n' +
|
|
1921
|
-
'<sky-datepicker>\n <input skyDatepickerInput />\n</sky-datepicker>');
|
|
1922
|
-
}
|
|
1923
|
-
},
|
|
1924
|
-
enumerable: true,
|
|
1925
|
-
configurable: true
|
|
1926
|
-
});
|
|
1927
|
-
Object.defineProperty(SkyDatepickerInputDirective.prototype, "startingDay", {
|
|
1928
|
-
get: function () {
|
|
1929
|
-
return this._startingDay || this.configService.startingDay;
|
|
1930
|
-
},
|
|
1931
|
-
/**
|
|
1932
|
-
* Specifies the starting day of the week in the calendar, where `0` sets the starting day
|
|
1933
|
-
* to Sunday. Place this attribute on the `input` element to override the default
|
|
1934
|
-
* in `SkyDatepickerConfigService`.
|
|
1935
|
-
* @default 0
|
|
1936
|
-
*/
|
|
1937
|
-
set: function (value) {
|
|
1938
|
-
this._startingDay = value;
|
|
1939
|
-
this.datepickerComponent.startingDay = this.startingDay;
|
|
1940
|
-
this.onValidatorChange();
|
|
1941
|
-
},
|
|
1942
|
-
enumerable: true,
|
|
1943
|
-
configurable: true
|
|
1944
|
-
});
|
|
1945
|
-
Object.defineProperty(SkyDatepickerInputDirective.prototype, "strict", {
|
|
1946
|
-
get: function () {
|
|
1947
|
-
return this._strict || false;
|
|
1948
|
-
},
|
|
1949
|
-
/**
|
|
1950
|
-
* Indicates whether the format of the date value must match the format from the `dateFormat` value.
|
|
1951
|
-
* If this property is `true` and the datepicker input directive cannot find an exact match, then
|
|
1952
|
-
* the input is marked as invalid.
|
|
1953
|
-
* If this property is `false` and the datepicker input directive cannot find an exact match, then
|
|
1954
|
-
* it attempts to format the string based on the [ISO 8601 standard format](https://www.iso.org/iso-8601-date-and-time-format.html).
|
|
1955
|
-
* @default false
|
|
1956
|
-
*/
|
|
1957
|
-
set: function (value) {
|
|
1958
|
-
this._strict = value;
|
|
1959
|
-
},
|
|
1960
|
-
enumerable: true,
|
|
1961
|
-
configurable: true
|
|
1962
|
-
});
|
|
1963
|
-
Object.defineProperty(SkyDatepickerInputDirective.prototype, "value", {
|
|
1964
|
-
get: function () {
|
|
1965
|
-
return this._value;
|
|
1966
|
-
},
|
|
1967
|
-
set: function (value) {
|
|
1968
|
-
var dateValue = this.getDateValue(value);
|
|
1969
|
-
var areDatesEqual = (this._value instanceof Date &&
|
|
1970
|
-
dateValue &&
|
|
1971
|
-
dateValue.getTime() === this._value.getTime());
|
|
1972
|
-
var isValidDateString = this.isDateStringValid(value);
|
|
1973
|
-
// If the string value supplied is malformed, do not set the value to its Date equivalent.
|
|
1974
|
-
// (JavaScript's Date parser will convert poorly formatted dates to Date objects, such as "abc 123", which isn't ideal.)
|
|
1975
|
-
if (!isValidDateString) {
|
|
1976
|
-
this._value = value;
|
|
1977
|
-
this.notifyUpdatedValue();
|
|
1978
|
-
}
|
|
1979
|
-
else if (dateValue !== this._value || !areDatesEqual) {
|
|
1980
|
-
this._value = (dateValue || value);
|
|
1981
|
-
this.notifyUpdatedValue();
|
|
1982
|
-
}
|
|
1983
|
-
if (dateValue && isValidDateString) {
|
|
1984
|
-
var formattedDate = this.dateFormatter.format(dateValue, this.dateFormat);
|
|
1985
|
-
this.setInputElementValue(formattedDate);
|
|
1986
|
-
}
|
|
1987
|
-
else {
|
|
1988
|
-
this.setInputElementValue(value || '');
|
|
1989
|
-
}
|
|
1780
|
+
var dateValue = this.getDateValue(value);
|
|
1781
|
+
var areDatesEqual = (this._value instanceof Date &&
|
|
1782
|
+
dateValue &&
|
|
1783
|
+
dateValue.getTime() === this._value.getTime());
|
|
1784
|
+
var isValidDateString = this.isDateStringValid(value);
|
|
1785
|
+
// If the string value supplied is malformed, do not set the value to its Date equivalent.
|
|
1786
|
+
// (JavaScript's Date parser will convert poorly formatted dates to Date objects, such as "abc 123", which isn't ideal.)
|
|
1787
|
+
if (!isValidDateString) {
|
|
1788
|
+
this._value = value;
|
|
1789
|
+
this.notifyUpdatedValue();
|
|
1790
|
+
}
|
|
1791
|
+
else if (dateValue !== this._value || !areDatesEqual) {
|
|
1792
|
+
this._value = (dateValue || value);
|
|
1793
|
+
this.notifyUpdatedValue();
|
|
1794
|
+
}
|
|
1795
|
+
if (dateValue && isValidDateString) {
|
|
1796
|
+
var formattedDate = this.dateFormatter.format(dateValue, this.dateFormat);
|
|
1797
|
+
this.setInputElementValue(formattedDate);
|
|
1798
|
+
}
|
|
1799
|
+
else {
|
|
1800
|
+
this.setInputElementValue(value || '');
|
|
1801
|
+
}
|
|
1990
1802
|
},
|
|
1991
1803
|
enumerable: true,
|
|
1992
1804
|
configurable: true
|
|
@@ -2293,7 +2105,8 @@ var SkyFuzzyDatepickerInputDirective = /** @class */ (function () {
|
|
|
2293
2105
|
this.localeProvider.getLocaleInfo()
|
|
2294
2106
|
.pipe(takeUntil(this.ngUnsubscribe))
|
|
2295
2107
|
.subscribe(function (localeInfo) {
|
|
2296
|
-
|
|
2108
|
+
_this.locale = localeInfo.locale;
|
|
2109
|
+
SkyDateFormatter.setLocale(_this.locale);
|
|
2297
2110
|
_this.preferredShortDateFormat = SkyDateFormatter.getPreferredShortDateFormat();
|
|
2298
2111
|
});
|
|
2299
2112
|
}
|
|
@@ -2311,7 +2124,7 @@ var SkyFuzzyDatepickerInputDirective = /** @class */ (function () {
|
|
|
2311
2124
|
set: function (value) {
|
|
2312
2125
|
this._dateFormat = value;
|
|
2313
2126
|
if (this.value) {
|
|
2314
|
-
var formattedDate = this.fuzzyDateService.
|
|
2127
|
+
var formattedDate = this.fuzzyDateService.format(this.value, this.dateFormat, this.locale);
|
|
2315
2128
|
this.setInputElementValue(formattedDate);
|
|
2316
2129
|
this.changeDetector.markForCheck();
|
|
2317
2130
|
}
|
|
@@ -2448,8 +2261,11 @@ var SkyFuzzyDatepickerInputDirective = /** @class */ (function () {
|
|
|
2448
2261
|
fuzzyDate = this.fuzzyDateService.getFuzzyDateFromSelectedDate(value, this.dateFormat);
|
|
2449
2262
|
}
|
|
2450
2263
|
else if (typeof value === 'string') {
|
|
2451
|
-
formattedDate = value;
|
|
2452
2264
|
fuzzyDate = this.fuzzyDateService.getFuzzyDateFromString(value, this.dateFormat);
|
|
2265
|
+
formattedDate = this.fuzzyDateService.format(fuzzyDate, this.dateFormat, this.locale);
|
|
2266
|
+
if (!formattedDate) {
|
|
2267
|
+
formattedDate = value;
|
|
2268
|
+
}
|
|
2453
2269
|
fuzzyMoment = this.fuzzyDateService.getMomentFromFuzzyDate(fuzzyDate);
|
|
2454
2270
|
if (fuzzyMoment) {
|
|
2455
2271
|
dateValue = fuzzyMoment.toDate();
|
|
@@ -2457,7 +2273,7 @@ var SkyFuzzyDatepickerInputDirective = /** @class */ (function () {
|
|
|
2457
2273
|
}
|
|
2458
2274
|
else {
|
|
2459
2275
|
fuzzyDate = value;
|
|
2460
|
-
formattedDate = this.fuzzyDateService.
|
|
2276
|
+
formattedDate = this.fuzzyDateService.format(fuzzyDate, this.dateFormat, this.locale);
|
|
2461
2277
|
fuzzyMoment = this.fuzzyDateService.getMomentFromFuzzyDate(fuzzyDate);
|
|
2462
2278
|
if (fuzzyMoment) {
|
|
2463
2279
|
dateValue = fuzzyMoment.toDate();
|
|
@@ -2479,267 +2295,811 @@ var SkyFuzzyDatepickerInputDirective = /** @class */ (function () {
|
|
|
2479
2295
|
}
|
|
2480
2296
|
this.datepickerComponent.selectedDate = dateValue;
|
|
2481
2297
|
}
|
|
2482
|
-
this.setInputElementValue(formattedDate || '');
|
|
2298
|
+
this.setInputElementValue(formattedDate || '');
|
|
2299
|
+
},
|
|
2300
|
+
enumerable: true,
|
|
2301
|
+
configurable: true
|
|
2302
|
+
});
|
|
2303
|
+
SkyFuzzyDatepickerInputDirective.prototype.ngOnInit = function () {
|
|
2304
|
+
var _this = this;
|
|
2305
|
+
if (this.yearRequired) {
|
|
2306
|
+
if (this.dateFormat.toLowerCase().indexOf('y') === -1) {
|
|
2307
|
+
throw new Error('You have configured conflicting settings. Year is required and dateFormat does not include year.');
|
|
2308
|
+
}
|
|
2309
|
+
}
|
|
2310
|
+
if (!this.datepickerComponent) {
|
|
2311
|
+
throw new Error('You must wrap the `skyFuzzyDatepickerInput` directive within a ' +
|
|
2312
|
+
'`<sky-datepicker>` component!');
|
|
2313
|
+
}
|
|
2314
|
+
var element = this.elementRef.nativeElement;
|
|
2315
|
+
this.renderer.addClass(element, 'sky-form-control');
|
|
2316
|
+
var hasAriaLabel = element.getAttribute('aria-label');
|
|
2317
|
+
if (!hasAriaLabel) {
|
|
2318
|
+
this.resourcesService.getString('skyux_date_field_default_label')
|
|
2319
|
+
.pipe(takeUntil(this.ngUnsubscribe))
|
|
2320
|
+
.subscribe(function (value) {
|
|
2321
|
+
_this.renderer.setAttribute(element, 'aria-label', value);
|
|
2322
|
+
});
|
|
2323
|
+
}
|
|
2324
|
+
};
|
|
2325
|
+
SkyFuzzyDatepickerInputDirective.prototype.ngAfterContentInit = function () {
|
|
2326
|
+
var _this = this;
|
|
2327
|
+
this.datepickerComponent.dateChange
|
|
2328
|
+
.pipe(distinctUntilChanged(), takeUntil(this.ngUnsubscribe))
|
|
2329
|
+
.subscribe(function (value) {
|
|
2330
|
+
_this.isFirstChange = false;
|
|
2331
|
+
_this.value = value;
|
|
2332
|
+
_this.onTouched();
|
|
2333
|
+
});
|
|
2334
|
+
};
|
|
2335
|
+
SkyFuzzyDatepickerInputDirective.prototype.ngAfterViewInit = function () {
|
|
2336
|
+
// This is needed to address a bug in Angular 4.
|
|
2337
|
+
// When a control value is set intially, its value is not represented on the view.
|
|
2338
|
+
// See: https://github.com/angular/angular/issues/13792
|
|
2339
|
+
// Of note is the parent check which allows us to determine if the form is reactive.
|
|
2340
|
+
// Without this check there is a changed before checked error
|
|
2341
|
+
/* istanbul ignore else */
|
|
2342
|
+
var _this = this;
|
|
2343
|
+
if (this.control && this.control.parent) {
|
|
2344
|
+
setTimeout(function () {
|
|
2345
|
+
_this.control.setValue(_this.value, {
|
|
2346
|
+
emitEvent: false
|
|
2347
|
+
});
|
|
2348
|
+
_this.changeDetector.markForCheck();
|
|
2349
|
+
});
|
|
2350
|
+
}
|
|
2351
|
+
};
|
|
2352
|
+
SkyFuzzyDatepickerInputDirective.prototype.ngOnDestroy = function () {
|
|
2353
|
+
this.ngUnsubscribe.next();
|
|
2354
|
+
this.ngUnsubscribe.complete();
|
|
2355
|
+
};
|
|
2356
|
+
SkyFuzzyDatepickerInputDirective.prototype.onInputChange = function (event) {
|
|
2357
|
+
this.onValueChange(event.target.value);
|
|
2358
|
+
};
|
|
2359
|
+
SkyFuzzyDatepickerInputDirective.prototype.onInputBlur = function () {
|
|
2360
|
+
this.onTouched();
|
|
2361
|
+
var formattedDate = this.fuzzyDateService.format(this.value, this.dateFormat, this.locale);
|
|
2362
|
+
if (this.control.valid) {
|
|
2363
|
+
this.setInputElementValue(formattedDate || '');
|
|
2364
|
+
}
|
|
2365
|
+
};
|
|
2366
|
+
SkyFuzzyDatepickerInputDirective.prototype.onInputKeyup = function () {
|
|
2367
|
+
this.control.markAsDirty();
|
|
2368
|
+
};
|
|
2369
|
+
SkyFuzzyDatepickerInputDirective.prototype.writeValue = function (value) {
|
|
2370
|
+
this.value = value;
|
|
2371
|
+
};
|
|
2372
|
+
SkyFuzzyDatepickerInputDirective.prototype.validate = function (control) {
|
|
2373
|
+
if (!this.control) {
|
|
2374
|
+
this.control = control;
|
|
2375
|
+
}
|
|
2376
|
+
if (this.skyDatepickerNoValidate) {
|
|
2377
|
+
return;
|
|
2378
|
+
}
|
|
2379
|
+
if (!this.control.value) {
|
|
2380
|
+
return;
|
|
2381
|
+
}
|
|
2382
|
+
var value = control.value;
|
|
2383
|
+
var fuzzyDate;
|
|
2384
|
+
var validationError;
|
|
2385
|
+
if (typeof value === 'string') {
|
|
2386
|
+
fuzzyDate = this.fuzzyDateService.getFuzzyDateFromString(value, this.dateFormat);
|
|
2387
|
+
}
|
|
2388
|
+
else {
|
|
2389
|
+
fuzzyDate = value;
|
|
2390
|
+
}
|
|
2391
|
+
if (!fuzzyDate) {
|
|
2392
|
+
validationError = {
|
|
2393
|
+
'skyFuzzyDate': {
|
|
2394
|
+
invalid: value
|
|
2395
|
+
}
|
|
2396
|
+
};
|
|
2397
|
+
}
|
|
2398
|
+
if (!validationError && !fuzzyDate.year && this.yearRequired) {
|
|
2399
|
+
validationError = {
|
|
2400
|
+
'skyFuzzyDate': {
|
|
2401
|
+
yearRequired: value
|
|
2402
|
+
}
|
|
2403
|
+
};
|
|
2404
|
+
}
|
|
2405
|
+
if (!validationError && fuzzyDate.year) {
|
|
2406
|
+
var fuzzyDateRange = void 0;
|
|
2407
|
+
if (this.maxDate) {
|
|
2408
|
+
fuzzyDateRange = this.fuzzyDateService.getFuzzyDateRange(fuzzyDate, this.maxDate);
|
|
2409
|
+
if (!fuzzyDateRange.valid) {
|
|
2410
|
+
validationError = {
|
|
2411
|
+
'skyFuzzyDate': {
|
|
2412
|
+
maxDate: value
|
|
2413
|
+
}
|
|
2414
|
+
};
|
|
2415
|
+
}
|
|
2416
|
+
}
|
|
2417
|
+
if (!validationError && this.minDate) {
|
|
2418
|
+
fuzzyDateRange = this.fuzzyDateService.getFuzzyDateRange(this.minDate, fuzzyDate);
|
|
2419
|
+
if (!fuzzyDateRange.valid) {
|
|
2420
|
+
validationError = {
|
|
2421
|
+
'skyFuzzyDate': {
|
|
2422
|
+
minDate: value
|
|
2423
|
+
}
|
|
2424
|
+
};
|
|
2425
|
+
}
|
|
2426
|
+
}
|
|
2427
|
+
if (!validationError && this.futureDisabled) {
|
|
2428
|
+
fuzzyDateRange = this.fuzzyDateService.getFuzzyDateRange(fuzzyDate, this.fuzzyDateService.getCurrentFuzzyDate());
|
|
2429
|
+
if (!fuzzyDateRange.valid) {
|
|
2430
|
+
validationError = {
|
|
2431
|
+
'skyFuzzyDate': {
|
|
2432
|
+
futureDisabled: value
|
|
2433
|
+
}
|
|
2434
|
+
};
|
|
2435
|
+
}
|
|
2436
|
+
}
|
|
2437
|
+
}
|
|
2438
|
+
if (validationError) {
|
|
2439
|
+
// Mark the invalid control as touched so that the input's invalid CSS styles appear.
|
|
2440
|
+
// (This is only required when the invalid value is set by the FormControl constructor.)
|
|
2441
|
+
this.control.markAsTouched();
|
|
2442
|
+
}
|
|
2443
|
+
return validationError;
|
|
2444
|
+
};
|
|
2445
|
+
SkyFuzzyDatepickerInputDirective.prototype.registerOnChange = function (fn) {
|
|
2446
|
+
this.onChange = fn;
|
|
2447
|
+
};
|
|
2448
|
+
SkyFuzzyDatepickerInputDirective.prototype.registerOnTouched = function (fn) {
|
|
2449
|
+
this.onTouched = fn;
|
|
2450
|
+
};
|
|
2451
|
+
SkyFuzzyDatepickerInputDirective.prototype.registerOnValidatorChange = function (fn) {
|
|
2452
|
+
this.onValidatorChange = fn;
|
|
2453
|
+
};
|
|
2454
|
+
SkyFuzzyDatepickerInputDirective.prototype.setDisabledState = function (disabled) {
|
|
2455
|
+
this.disabled = disabled;
|
|
2456
|
+
this.datepickerComponent.disabled = disabled;
|
|
2457
|
+
};
|
|
2458
|
+
/**
|
|
2459
|
+
* Detects changes to the underlying input element's value and updates the ngModel accordingly.
|
|
2460
|
+
* This is useful if you need to update the ngModel value before the input element loses focus.
|
|
2461
|
+
*/
|
|
2462
|
+
SkyFuzzyDatepickerInputDirective.prototype.detectInputValueChange = function () {
|
|
2463
|
+
this.onValueChange(this.elementRef.nativeElement.value);
|
|
2464
|
+
};
|
|
2465
|
+
SkyFuzzyDatepickerInputDirective.prototype.onValueChange = function (newValue) {
|
|
2466
|
+
this.isFirstChange = false;
|
|
2467
|
+
this.value = newValue;
|
|
2468
|
+
};
|
|
2469
|
+
SkyFuzzyDatepickerInputDirective.prototype.setInputElementValue = function (value) {
|
|
2470
|
+
this.renderer.setProperty(this.elementRef.nativeElement, 'value', value);
|
|
2471
|
+
};
|
|
2472
|
+
SkyFuzzyDatepickerInputDirective.prototype.getMaxDate = function () {
|
|
2473
|
+
if (this.maxDate) {
|
|
2474
|
+
var maxDate = this.fuzzyDateService.getMomentFromFuzzyDate(this.maxDate);
|
|
2475
|
+
if (maxDate.isValid()) {
|
|
2476
|
+
return maxDate.toDate();
|
|
2477
|
+
}
|
|
2478
|
+
}
|
|
2479
|
+
else if (this.futureDisabled) {
|
|
2480
|
+
return new Date();
|
|
2481
|
+
}
|
|
2482
|
+
return this.configService.maxDate;
|
|
2483
|
+
};
|
|
2484
|
+
SkyFuzzyDatepickerInputDirective.prototype.getMinDate = function () {
|
|
2485
|
+
if (this.minDate) {
|
|
2486
|
+
var minDate = this.fuzzyDateService.getMomentFromFuzzyDate(this.minDate);
|
|
2487
|
+
if (minDate.isValid()) {
|
|
2488
|
+
return minDate.toDate();
|
|
2489
|
+
}
|
|
2490
|
+
}
|
|
2491
|
+
return this.configService.minDate;
|
|
2492
|
+
};
|
|
2493
|
+
SkyFuzzyDatepickerInputDirective.prototype.fuzzyDatesEqual = function (dateA, dateB) {
|
|
2494
|
+
return dateA && dateB
|
|
2495
|
+
&& ((!dateA.day && !dateB.day)
|
|
2496
|
+
|| dateA.day === dateB.day)
|
|
2497
|
+
&& ((!dateA.month && !dateB.month)
|
|
2498
|
+
|| dateA.month === dateB.month)
|
|
2499
|
+
&& ((!dateA.year && !dateB.year)
|
|
2500
|
+
|| dateA.year === dateB.year);
|
|
2501
|
+
};
|
|
2502
|
+
SkyFuzzyDatepickerInputDirective.ctorParameters = function () { return [
|
|
2503
|
+
{ type: ChangeDetectorRef },
|
|
2504
|
+
{ type: SkyDatepickerConfigService },
|
|
2505
|
+
{ type: ElementRef },
|
|
2506
|
+
{ type: SkyFuzzyDateService },
|
|
2507
|
+
{ type: SkyAppLocaleProvider },
|
|
2508
|
+
{ type: Renderer2 },
|
|
2509
|
+
{ type: SkyLibResourcesService },
|
|
2510
|
+
{ type: SkyDatepickerComponent, decorators: [{ type: Optional }] }
|
|
2511
|
+
]; };
|
|
2512
|
+
__decorate([
|
|
2513
|
+
Input()
|
|
2514
|
+
], SkyFuzzyDatepickerInputDirective.prototype, "dateFormat", null);
|
|
2515
|
+
__decorate([
|
|
2516
|
+
Input()
|
|
2517
|
+
], SkyFuzzyDatepickerInputDirective.prototype, "disabled", null);
|
|
2518
|
+
__decorate([
|
|
2519
|
+
Input()
|
|
2520
|
+
], SkyFuzzyDatepickerInputDirective.prototype, "futureDisabled", null);
|
|
2521
|
+
__decorate([
|
|
2522
|
+
Input()
|
|
2523
|
+
], SkyFuzzyDatepickerInputDirective.prototype, "maxDate", null);
|
|
2524
|
+
__decorate([
|
|
2525
|
+
Input()
|
|
2526
|
+
], SkyFuzzyDatepickerInputDirective.prototype, "minDate", null);
|
|
2527
|
+
__decorate([
|
|
2528
|
+
Input()
|
|
2529
|
+
], SkyFuzzyDatepickerInputDirective.prototype, "skyDatepickerNoValidate", void 0);
|
|
2530
|
+
__decorate([
|
|
2531
|
+
Input()
|
|
2532
|
+
], SkyFuzzyDatepickerInputDirective.prototype, "skyFuzzyDatepickerInput", null);
|
|
2533
|
+
__decorate([
|
|
2534
|
+
Input()
|
|
2535
|
+
], SkyFuzzyDatepickerInputDirective.prototype, "startingDay", null);
|
|
2536
|
+
__decorate([
|
|
2537
|
+
Input()
|
|
2538
|
+
], SkyFuzzyDatepickerInputDirective.prototype, "yearRequired", null);
|
|
2539
|
+
__decorate([
|
|
2540
|
+
HostListener('change', ['$event'])
|
|
2541
|
+
], SkyFuzzyDatepickerInputDirective.prototype, "onInputChange", null);
|
|
2542
|
+
__decorate([
|
|
2543
|
+
HostListener('blur')
|
|
2544
|
+
], SkyFuzzyDatepickerInputDirective.prototype, "onInputBlur", null);
|
|
2545
|
+
__decorate([
|
|
2546
|
+
HostListener('keyup')
|
|
2547
|
+
], SkyFuzzyDatepickerInputDirective.prototype, "onInputKeyup", null);
|
|
2548
|
+
SkyFuzzyDatepickerInputDirective = __decorate([
|
|
2549
|
+
Directive({
|
|
2550
|
+
selector: '[skyFuzzyDatepickerInput]',
|
|
2551
|
+
providers: [
|
|
2552
|
+
SKY_FUZZY_DATEPICKER_VALUE_ACCESSOR,
|
|
2553
|
+
SKY_FUZZY_DATEPICKER_VALIDATOR
|
|
2554
|
+
]
|
|
2555
|
+
}),
|
|
2556
|
+
__param(7, Optional())
|
|
2557
|
+
], SkyFuzzyDatepickerInputDirective);
|
|
2558
|
+
return SkyFuzzyDatepickerInputDirective;
|
|
2559
|
+
}());
|
|
2560
|
+
|
|
2561
|
+
/**
|
|
2562
|
+
* @internal
|
|
2563
|
+
*/
|
|
2564
|
+
var SkyDatepickerService = /** @class */ (function () {
|
|
2565
|
+
function SkyDatepickerService() {
|
|
2566
|
+
/**
|
|
2567
|
+
* Specifies if a key date popover is currently displayed.
|
|
2568
|
+
* Useful for communicating across all daypicker siblings when a popover is displayed.
|
|
2569
|
+
*/
|
|
2570
|
+
this.keyDatePopoverStream = new Subject();
|
|
2571
|
+
}
|
|
2572
|
+
SkyDatepickerService = __decorate([
|
|
2573
|
+
Injectable()
|
|
2574
|
+
], SkyDatepickerService);
|
|
2575
|
+
return SkyDatepickerService;
|
|
2576
|
+
}());
|
|
2577
|
+
|
|
2578
|
+
/**
|
|
2579
|
+
* @internal
|
|
2580
|
+
*/
|
|
2581
|
+
var SkyDayPickerButtonComponent = /** @class */ (function () {
|
|
2582
|
+
function SkyDayPickerButtonComponent(datepicker) {
|
|
2583
|
+
this.datepicker = datepicker;
|
|
2584
|
+
}
|
|
2585
|
+
SkyDayPickerButtonComponent.ctorParameters = function () { return [
|
|
2586
|
+
{ type: SkyDatepickerCalendarInnerComponent }
|
|
2587
|
+
]; };
|
|
2588
|
+
__decorate([
|
|
2589
|
+
Input()
|
|
2590
|
+
], SkyDayPickerButtonComponent.prototype, "date", void 0);
|
|
2591
|
+
SkyDayPickerButtonComponent = __decorate([
|
|
2592
|
+
Component({
|
|
2593
|
+
selector: 'sky-daypicker-button',
|
|
2594
|
+
template: "<button\n class=\"sky-btn sky-btn-sm sky-btn-default sky-datepicker-btn-date\"\n tabindex=\"-1\"\n type=\"button\"\n [disabled]=\"date.disabled\"\n [ngClass]=\"{\n 'sky-datepicker-btn-selected': date.selected,\n 'sky-btn-disabled': date.disabled,\n 'sky-btn-active': datepicker.isActive(date),\n 'sky-datepicker-btn-disabled': date.disabled,\n 'sky-datepicker-btn-key-date': date.keyDate\n }\"\n (click)=\"datepicker.selectCalendar($event, date.date, true)\"\n>\n <span\n [ngClass]=\"{ 'sky-datepicker-secondary': date.secondary }\"\n >\n {{date.label}}\n </span>\n</button>\n",
|
|
2595
|
+
styles: [".sky-datepicker-btn-disabled{font-style:italic}.sky-datepicker-btn-key-date{position:relative}.sky-datepicker-btn-key-date::before{position:absolute;content:\"\";height:5px;width:5px;background-color:#d93a3d;border-radius:50%;left:15px;top:22px}:host-context(.sky-theme-modern) .sky-datepicker-btn-key-date::before{left:12px}.sky-theme-modern .sky-datepicker-btn-key-date::before{left:12px}"]
|
|
2596
|
+
})
|
|
2597
|
+
], SkyDayPickerButtonComponent);
|
|
2598
|
+
return SkyDayPickerButtonComponent;
|
|
2599
|
+
}());
|
|
2600
|
+
|
|
2601
|
+
/**
|
|
2602
|
+
* @internal
|
|
2603
|
+
*/
|
|
2604
|
+
var SkyDayPickerCellComponent = /** @class */ (function () {
|
|
2605
|
+
function SkyDayPickerCellComponent(datepicker, datepickerService) {
|
|
2606
|
+
this.datepicker = datepicker;
|
|
2607
|
+
this.datepickerService = datepickerService;
|
|
2608
|
+
this.hasTooltip = false;
|
|
2609
|
+
this.popoverController = new Subject();
|
|
2610
|
+
this.activeUid = '';
|
|
2611
|
+
this.cancelPopover = false;
|
|
2612
|
+
this.popoverOpen = false;
|
|
2613
|
+
this.ngUnsubscribe = new Subject();
|
|
2614
|
+
}
|
|
2615
|
+
SkyDayPickerCellComponent.prototype.ngOnInit = function () {
|
|
2616
|
+
var _this = this;
|
|
2617
|
+
this.hasTooltip =
|
|
2618
|
+
this.date.keyDate &&
|
|
2619
|
+
this.date.keyDateText &&
|
|
2620
|
+
this.date.keyDateText.length > 0 &&
|
|
2621
|
+
this.date.keyDateText[0].length > 0;
|
|
2622
|
+
// show the tooltip if this is the active date and is not the
|
|
2623
|
+
// initial active date (activeDateHasChanged)
|
|
2624
|
+
if (this.datepicker.isActive(this.date) &&
|
|
2625
|
+
this.activeDateHasChanged &&
|
|
2626
|
+
this.hasTooltip) {
|
|
2627
|
+
this.activeUid = this.date.uid;
|
|
2628
|
+
this.showTooltip();
|
|
2629
|
+
}
|
|
2630
|
+
if (this.hasTooltip) {
|
|
2631
|
+
this.datepickerService.keyDatePopoverStream
|
|
2632
|
+
.pipe(takeUntil(this.ngUnsubscribe))
|
|
2633
|
+
.subscribe(function (date) {
|
|
2634
|
+
if (date) {
|
|
2635
|
+
_this.activeUid = date.uid;
|
|
2636
|
+
}
|
|
2637
|
+
else {
|
|
2638
|
+
_this.activeUid = '';
|
|
2639
|
+
}
|
|
2640
|
+
// If this day has an open popover and they have moved off of the day close the popover.
|
|
2641
|
+
if (_this.date.uid !== _this.activeUid) {
|
|
2642
|
+
_this.hideTooltip();
|
|
2643
|
+
}
|
|
2644
|
+
});
|
|
2645
|
+
}
|
|
2646
|
+
};
|
|
2647
|
+
SkyDayPickerCellComponent.prototype.ngOnDestroy = function () {
|
|
2648
|
+
this.ngUnsubscribe.next();
|
|
2649
|
+
this.ngUnsubscribe.complete();
|
|
2650
|
+
};
|
|
2651
|
+
SkyDayPickerCellComponent.prototype.onDayMouseenter = function () {
|
|
2652
|
+
this.cancelPopover = false;
|
|
2653
|
+
if (this.hasTooltip) {
|
|
2654
|
+
this.showTooltip();
|
|
2655
|
+
this.datepickerService.keyDatePopoverStream.next(this.date);
|
|
2656
|
+
}
|
|
2657
|
+
};
|
|
2658
|
+
SkyDayPickerCellComponent.prototype.onDayMouseleave = function () {
|
|
2659
|
+
this.cancelPopover = true;
|
|
2660
|
+
if (this.hasTooltip) {
|
|
2661
|
+
this.hideTooltip();
|
|
2662
|
+
}
|
|
2663
|
+
this.datepickerService.keyDatePopoverStream.next(undefined);
|
|
2664
|
+
};
|
|
2665
|
+
SkyDayPickerCellComponent.prototype.onPopoverClosed = function () {
|
|
2666
|
+
this.popoverOpen = false;
|
|
2667
|
+
};
|
|
2668
|
+
SkyDayPickerCellComponent.prototype.onPopoverOpened = function () {
|
|
2669
|
+
this.popoverOpen = true;
|
|
2670
|
+
/* istanbul ignore else */
|
|
2671
|
+
if (this.cancelPopover) {
|
|
2672
|
+
// If the popover gets opened just as a mouseout event happens, close it.
|
|
2673
|
+
this.hideTooltip();
|
|
2674
|
+
this.cancelPopover = false;
|
|
2675
|
+
}
|
|
2676
|
+
};
|
|
2677
|
+
SkyDayPickerCellComponent.prototype.getKeyDateLabel = function () {
|
|
2678
|
+
if (this.hasTooltip) {
|
|
2679
|
+
return this.date.keyDateText.join(', ');
|
|
2680
|
+
}
|
|
2681
|
+
else {
|
|
2682
|
+
return '';
|
|
2683
|
+
}
|
|
2684
|
+
};
|
|
2685
|
+
SkyDayPickerCellComponent.prototype.hideTooltip = function () {
|
|
2686
|
+
/* istanbul ignore else */
|
|
2687
|
+
if (this.popoverOpen) {
|
|
2688
|
+
this.popoverController.next({ type: SkyPopoverMessageType.Close });
|
|
2689
|
+
}
|
|
2690
|
+
};
|
|
2691
|
+
SkyDayPickerCellComponent.prototype.showTooltip = function () {
|
|
2692
|
+
var _this = this;
|
|
2693
|
+
/* istanbul ignore else */
|
|
2694
|
+
if (this.hasTooltip &&
|
|
2695
|
+
!this.popoverOpen) {
|
|
2696
|
+
/**
|
|
2697
|
+
* Delay 1/2 second before opening the popover as long as mouse hasn't moved off the date.
|
|
2698
|
+
*/
|
|
2699
|
+
setTimeout(function () {
|
|
2700
|
+
if (!_this.cancelPopover &&
|
|
2701
|
+
_this.activeUid === _this.date.uid) {
|
|
2702
|
+
_this.popoverController.next({ type: SkyPopoverMessageType.Open });
|
|
2703
|
+
}
|
|
2704
|
+
}, 500);
|
|
2705
|
+
}
|
|
2706
|
+
};
|
|
2707
|
+
SkyDayPickerCellComponent.ctorParameters = function () { return [
|
|
2708
|
+
{ type: SkyDatepickerCalendarInnerComponent },
|
|
2709
|
+
{ type: SkyDatepickerService }
|
|
2710
|
+
]; };
|
|
2711
|
+
__decorate([
|
|
2712
|
+
Input()
|
|
2713
|
+
], SkyDayPickerCellComponent.prototype, "activeDateHasChanged", void 0);
|
|
2714
|
+
__decorate([
|
|
2715
|
+
Input()
|
|
2716
|
+
], SkyDayPickerCellComponent.prototype, "date", void 0);
|
|
2717
|
+
SkyDayPickerCellComponent = __decorate([
|
|
2718
|
+
Component({
|
|
2719
|
+
selector: 'sky-daypicker-cell',
|
|
2720
|
+
template: "<div *ngIf=\"hasTooltip\"\n class=\"sky-daypicker-cell\"\n [attr.aria-label]=\"getKeyDateLabel()\"\n [skyPopover]=\"dayInfoPopover\"\n skyPopoverPlacement=\"left\"\n [skyPopoverMessageStream]=\"popoverController\"\n (mouseenter)=\"onDayMouseenter()\"\n (mouseleave)=\"onDayMouseleave()\"\n>\n <ng-container *ngTemplateOutlet=\"daypickerButtonTemplateRef\"></ng-container>\n <sky-popover\n (popoverClosed)=\"onPopoverClosed()\"\n (popoverOpened)=\"onPopoverOpened()\"\n #dayInfoPopover\n >\n <div *ngFor=\"let text of date.keyDateText\">\n {{text}}\n </div>\n </sky-popover>\n</div>\n<div *ngIf=\"!hasTooltip\"\n class=\"sky-daypicker-cell\"\n (mouseenter)=\"onDayMouseenter()\"\n (mouseleave)=\"onDayMouseleave()\"\n>\n <ng-container *ngTemplateOutlet=\"daypickerButtonTemplateRef\"></ng-container>\n</div>\n\n<ng-template #daypickerButtonTemplateRef>\n <sky-daypicker-button\n [date]=\"date\"\n >\n </sky-daypicker-button>\n</ng-template>\n",
|
|
2721
|
+
changeDetection: ChangeDetectionStrategy.OnPush
|
|
2722
|
+
})
|
|
2723
|
+
], SkyDayPickerCellComponent);
|
|
2724
|
+
return SkyDayPickerCellComponent;
|
|
2725
|
+
}());
|
|
2726
|
+
|
|
2727
|
+
/**
|
|
2728
|
+
* @internal
|
|
2729
|
+
*/
|
|
2730
|
+
var SkyDayPickerComponent = /** @class */ (function () {
|
|
2731
|
+
function SkyDayPickerComponent(datepicker) {
|
|
2732
|
+
this.calendarDateRangeChange = new EventEmitter();
|
|
2733
|
+
this.isWaiting = false;
|
|
2734
|
+
this.labels = [];
|
|
2735
|
+
this.rows = [];
|
|
2736
|
+
this.weekNumbers = [];
|
|
2737
|
+
this.activeDateHasChanged = false;
|
|
2738
|
+
this.daysInMonth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
|
2739
|
+
this.ngUnsubscribe = new Subject();
|
|
2740
|
+
this.datepicker = datepicker;
|
|
2741
|
+
}
|
|
2742
|
+
Object.defineProperty(SkyDayPickerComponent.prototype, "customDates", {
|
|
2743
|
+
set: function (value) {
|
|
2744
|
+
/* istanbul ignore else */
|
|
2745
|
+
if (value) {
|
|
2746
|
+
this.applyCustomDates(value, this.rows);
|
|
2747
|
+
}
|
|
2483
2748
|
},
|
|
2484
2749
|
enumerable: true,
|
|
2485
2750
|
configurable: true
|
|
2486
2751
|
});
|
|
2487
|
-
|
|
2752
|
+
SkyDayPickerComponent.prototype.ngOnInit = function () {
|
|
2488
2753
|
var _this = this;
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2754
|
+
this.datepicker.stepDay = { months: 1 };
|
|
2755
|
+
this.initialDate = this.datepicker.activeDate.getDate();
|
|
2756
|
+
this.datepicker.setRefreshViewHandler(function () {
|
|
2757
|
+
_this.refreshDayView();
|
|
2758
|
+
}, 'day');
|
|
2759
|
+
this.datepicker.setCompareHandler(this.compareDays, 'day');
|
|
2760
|
+
this.datepicker.setKeydownHandler(function (key, event) {
|
|
2761
|
+
_this.keydownDays(key, event);
|
|
2762
|
+
}, 'day');
|
|
2763
|
+
this.datepicker.refreshView();
|
|
2764
|
+
};
|
|
2765
|
+
SkyDayPickerComponent.prototype.ngOnDestroy = function () {
|
|
2766
|
+
this.ngUnsubscribe.next();
|
|
2767
|
+
this.ngUnsubscribe.complete();
|
|
2768
|
+
};
|
|
2769
|
+
SkyDayPickerComponent.prototype.getDates = function (startDate, n) {
|
|
2770
|
+
var dates = new Array(n);
|
|
2771
|
+
var current = new Date(startDate.getTime());
|
|
2772
|
+
var i = 0;
|
|
2773
|
+
var date;
|
|
2774
|
+
while (i < n) {
|
|
2775
|
+
date = new Date(current.getTime());
|
|
2776
|
+
date = this.datepicker.fixTimeZone(date);
|
|
2777
|
+
dates[i++] = date;
|
|
2778
|
+
current = new Date(current.getFullYear(), current.getMonth(), current.getDate() + 1);
|
|
2493
2779
|
}
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
|
|
2780
|
+
return dates;
|
|
2781
|
+
};
|
|
2782
|
+
SkyDayPickerComponent.prototype.compareDays = function (date1, date2) {
|
|
2783
|
+
var d1 = new Date(date1.getFullYear(), date1.getMonth(), date1.getDate());
|
|
2784
|
+
var d2 = new Date(date2.getFullYear(), date2.getMonth(), date2.getDate());
|
|
2785
|
+
return d1.getTime() - d2.getTime();
|
|
2786
|
+
};
|
|
2787
|
+
SkyDayPickerComponent.prototype.refreshDayView = function () {
|
|
2788
|
+
var year = this.datepicker.activeDate.getFullYear();
|
|
2789
|
+
var month = this.datepicker.activeDate.getMonth();
|
|
2790
|
+
var firstDayOfMonth = new Date(year, month, 1);
|
|
2791
|
+
var difference = this.datepicker.startingDay - firstDayOfMonth.getDay();
|
|
2792
|
+
var numDisplayedFromPreviousMonth = (difference > 0)
|
|
2793
|
+
? 7 - difference
|
|
2794
|
+
: -difference;
|
|
2795
|
+
var firstDate = new Date(firstDayOfMonth.getTime());
|
|
2796
|
+
if (this.datepicker.activeDate.getDate() !== this.initialDate) {
|
|
2797
|
+
this.activeDateHasChanged = true;
|
|
2497
2798
|
}
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
|
|
2799
|
+
/* istanbul ignore else */
|
|
2800
|
+
/* sanity check */
|
|
2801
|
+
if (numDisplayedFromPreviousMonth > 0) {
|
|
2802
|
+
firstDate.setDate(-numDisplayedFromPreviousMonth + 1);
|
|
2803
|
+
}
|
|
2804
|
+
// 42 is the number of days on a six-week calendar
|
|
2805
|
+
var days = this.getDates(firstDate, 42);
|
|
2806
|
+
var pickerDates = [];
|
|
2807
|
+
for (var i = 0; i < 42; i++) {
|
|
2808
|
+
var _dateObject = this.datepicker.createDateObject(days[i], this.datepicker.formatDay, days[i].getMonth() !== month, this.datepicker.datepickerId + '-' + i);
|
|
2809
|
+
pickerDates[i] = _dateObject;
|
|
2810
|
+
}
|
|
2811
|
+
this.labels = [];
|
|
2812
|
+
for (var j = 0; j < 7; j++) {
|
|
2813
|
+
this.labels[j] = {};
|
|
2814
|
+
this.labels[j].abbr =
|
|
2815
|
+
this.datepicker.dateFilter(pickerDates[j].date, this.datepicker.formatDayHeader);
|
|
2816
|
+
this.labels[j].full = this.datepicker.dateFilter(pickerDates[j].date, 'EEEE');
|
|
2817
|
+
}
|
|
2818
|
+
this.title =
|
|
2819
|
+
this.datepicker.dateFilter(this.datepicker.activeDate, this.datepicker.formatDayTitle);
|
|
2820
|
+
var oldDateRange = this.getDateRange(this.rows);
|
|
2821
|
+
this.rows = this.datepicker.createCalendarRows(pickerDates, 7);
|
|
2822
|
+
var newDateRange = this.getDateRange(this.rows);
|
|
2823
|
+
if (!this.dateRangeRowsAreEqual(oldDateRange, newDateRange)) {
|
|
2824
|
+
this.calendarDateRangeChange.next({
|
|
2825
|
+
startDate: newDateRange.startDate,
|
|
2826
|
+
endDate: newDateRange.endDate
|
|
2506
2827
|
});
|
|
2507
2828
|
}
|
|
2508
2829
|
};
|
|
2509
|
-
|
|
2510
|
-
var
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
|
|
2830
|
+
SkyDayPickerComponent.prototype.keydownDays = function (key, event) {
|
|
2831
|
+
var date = this.datepicker.activeDate.getDate();
|
|
2832
|
+
/* istanbul ignore else */
|
|
2833
|
+
/* sanity check */
|
|
2834
|
+
if (key === 'left') {
|
|
2835
|
+
date = date - 1;
|
|
2836
|
+
}
|
|
2837
|
+
else if (key === 'up') {
|
|
2838
|
+
date = date - 7;
|
|
2839
|
+
}
|
|
2840
|
+
else if (key === 'right') {
|
|
2841
|
+
date = date + 1;
|
|
2842
|
+
}
|
|
2843
|
+
else if (key === 'down') {
|
|
2844
|
+
date = date + 7;
|
|
2845
|
+
}
|
|
2846
|
+
else if (key === 'pageup' || key === 'pagedown') {
|
|
2847
|
+
var month = this.datepicker.activeDate.getMonth() + (key === 'pageup' ? -1 : 1);
|
|
2848
|
+
this.datepicker.activeDate.setMonth(month, 1);
|
|
2849
|
+
date =
|
|
2850
|
+
Math.min(this.getDaysInMonth(this.datepicker.activeDate.getFullYear(), this.datepicker.activeDate.getMonth()), date);
|
|
2851
|
+
}
|
|
2852
|
+
else if (key === 'home') {
|
|
2853
|
+
date = 1;
|
|
2854
|
+
}
|
|
2855
|
+
else if (key === 'end') {
|
|
2856
|
+
date = this.getDaysInMonth(this.datepicker.activeDate.getFullYear(), this.datepicker.activeDate.getMonth());
|
|
2857
|
+
}
|
|
2858
|
+
this.datepicker.activeDate.setDate(date);
|
|
2518
2859
|
};
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2860
|
+
SkyDayPickerComponent.prototype.getDaysInMonth = function (year, month) {
|
|
2861
|
+
return month === 1 && year % 4 === 0 &&
|
|
2862
|
+
(year % 400 === 0 || year % 100 !== 0) ? 29 : this.daysInMonth[month];
|
|
2863
|
+
};
|
|
2864
|
+
/**
|
|
2865
|
+
* Applies custom date properties to the existing dates displayed in the calendar.
|
|
2866
|
+
*/
|
|
2867
|
+
SkyDayPickerComponent.prototype.applyCustomDates = function (customDates, dateRows) {
|
|
2868
|
+
var date;
|
|
2869
|
+
var newDate;
|
|
2870
|
+
var dateIndex;
|
|
2525
2871
|
/* istanbul ignore else */
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
|
|
2872
|
+
if (customDates && dateRows) {
|
|
2873
|
+
customDates.forEach(function (customDate) {
|
|
2874
|
+
dateIndex = -1;
|
|
2875
|
+
dateRows.forEach(function (row) {
|
|
2876
|
+
if (dateIndex === -1) {
|
|
2877
|
+
dateIndex = row.findIndex(function (d) {
|
|
2878
|
+
return d.date.getTime() === customDate.date.getTime();
|
|
2879
|
+
});
|
|
2880
|
+
if (dateIndex > -1) {
|
|
2881
|
+
date = row[dateIndex];
|
|
2882
|
+
// Replace the date with a new instance so the display gets updated.
|
|
2883
|
+
newDate = {
|
|
2884
|
+
current: date.current,
|
|
2885
|
+
date: date.date,
|
|
2886
|
+
disabled: !!date.disabled || !!customDate.disabled,
|
|
2887
|
+
keyDate: !!customDate.keyDate || !!date.keyDate,
|
|
2888
|
+
keyDateText: customDate.keyDateText || date.keyDateText,
|
|
2889
|
+
label: date.label,
|
|
2890
|
+
secondary: date.secondary,
|
|
2891
|
+
selected: date.selected,
|
|
2892
|
+
uid: date.uid
|
|
2893
|
+
};
|
|
2894
|
+
row[dateIndex] = newDate;
|
|
2895
|
+
}
|
|
2896
|
+
}
|
|
2531
2897
|
});
|
|
2532
|
-
_this.changeDetector.markForCheck();
|
|
2533
2898
|
});
|
|
2534
2899
|
}
|
|
2535
2900
|
};
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
|
|
2540
|
-
|
|
2541
|
-
|
|
2901
|
+
SkyDayPickerComponent.prototype.dateRangeRowsAreEqual = function (rangeA, rangeB) {
|
|
2902
|
+
/* istanbul ignore if */
|
|
2903
|
+
if (!rangeA && !rangeB) {
|
|
2904
|
+
return true;
|
|
2905
|
+
}
|
|
2906
|
+
else if ((rangeA && !rangeB) || (!rangeA && rangeB)) {
|
|
2907
|
+
return false;
|
|
2908
|
+
}
|
|
2909
|
+
return this.compareDays(rangeA.startDate, rangeB.startDate) === 0 &&
|
|
2910
|
+
this.compareDays(rangeA.endDate, rangeB.endDate) === 0;
|
|
2542
2911
|
};
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
|
|
2547
|
-
|
|
2912
|
+
SkyDayPickerComponent.prototype.getDateRange = function (rows) {
|
|
2913
|
+
if (rows && rows.length > 0) {
|
|
2914
|
+
return {
|
|
2915
|
+
startDate: rows[0][0].date,
|
|
2916
|
+
endDate: rows[rows.length - 1][rows[rows.length - 1].length - 1].date
|
|
2917
|
+
};
|
|
2548
2918
|
}
|
|
2549
2919
|
};
|
|
2550
|
-
|
|
2551
|
-
|
|
2920
|
+
SkyDayPickerComponent.ctorParameters = function () { return [
|
|
2921
|
+
{ type: SkyDatepickerCalendarInnerComponent }
|
|
2922
|
+
]; };
|
|
2923
|
+
__decorate([
|
|
2924
|
+
Input()
|
|
2925
|
+
], SkyDayPickerComponent.prototype, "customDates", null);
|
|
2926
|
+
__decorate([
|
|
2927
|
+
Output()
|
|
2928
|
+
], SkyDayPickerComponent.prototype, "calendarDateRangeChange", void 0);
|
|
2929
|
+
__decorate([
|
|
2930
|
+
Input()
|
|
2931
|
+
], SkyDayPickerComponent.prototype, "isWaiting", void 0);
|
|
2932
|
+
SkyDayPickerComponent = __decorate([
|
|
2933
|
+
Component({
|
|
2934
|
+
selector: 'sky-daypicker',
|
|
2935
|
+
template: "<div *ngIf=\"datepicker.datepickerMode === 'day'\"\n class=\"sky-daypicker-wrapper\"\n>\n <table\n class=\"sky-daypicker-table\"\n role=\"grid\"\n [attr.aria-labelledby]=\"datepicker.datepickerId+'-title'\"\n [attr.aria-activedescendant]=\"datepicker.activeDateId\"\n >\n <thead>\n <tr>\n <th\n class=\"sky-datepicker-header-left\"\n scope=\"col\"\n >\n <button\n type=\"button\"\n class=\"sky-btn sky-btn-default sky-btn-sm sky-datepicker-btn-previous\"\n (click)=\"datepicker.moveCalendar($event, -1)\"\n tabindex=\"-1\"\n aria-hidden=\"true\"\n >\n <sky-icon\n class=\"sky-datepicker-chevron-default\"\n icon=\"chevron-left\"\n ></sky-icon>\n <sky-icon\n class=\"sky-datepicker-chevron-modern\"\n icon=\"chevron-left\"\n iconType=\"skyux\"\n ></sky-icon>\n </button>\n </th>\n <th\n scope=\"col\"\n [attr.colspan]=\"5\"\n >\n <button\n [id]=\"datepicker.datepickerId + '-title'\"\n type=\"button\"\n class=\"sky-btn sky-btn-default sky-btn-sm sky-datepicker-calendar-title\"\n (click)=\"datepicker.toggleModeCalendar($event)\"\n [disabled]=\"datepicker.datepickerMode === datepicker.maxMode\"\n [ngClass]=\"{'sky-btn-disabled': datepicker.datepickerMode === datepicker.maxMode}\"\n tabindex=\"-1\"\n aria-hidden=\"true\"\n >\n <strong>{{title}}</strong>\n </button>\n </th>\n <th\n class=\"sky-datepicker-header-right\"\n scope=\"col\"\n >\n <button\n type=\"button\"\n class=\"sky-btn sky-btn-default sky-btn-sm sky-datepicker-btn-next\"\n (click)=\"datepicker.moveCalendar($event, 1)\"\n tabindex=\"-1\"\n aria-hidden=\"true\"\n >\n <sky-icon\n class=\"sky-datepicker-chevron-default\"\n icon=\"chevron-right\"\n ></sky-icon>\n <sky-icon\n class=\"sky-datepicker-chevron-modern\"\n icon=\"chevron-right\"\n iconType=\"skyux\"\n ></sky-icon>\n </button>\n </th>\n </tr>\n <tr>\n <th\n scope=\"col\"\n *ngFor=\"let label of labels\"\n class=\"sky-datepicker-center sky-datepicker-weekdays\">\n <small [attr.aria-label]=\"label.full\">\n <b>{{label.abbr}}</b>\n </small>\n </th>\n </tr>\n </thead>\n <tbody>\n <!-- Wait indicator for async custom date stream -->\n <sky-wait\n [isWaiting]=\"isWaiting\"\n >\n </sky-wait>\n <ng-template\n ngFor\n [ngForOf]=\"rows\"\n let-row=\"$implicit\"\n let-index=\"index\"\n >\n <tr role=\"row\">\n <td *ngFor=\"let date of row\"\n class=\"sky-datepicker-center\"\n role=\"gridcell\"\n [id]=\"date.uid\"\n >\n <sky-daypicker-cell\n [activeDateHasChanged]=\"activeDateHasChanged\"\n [date]=\"date\"\n >\n </sky-daypicker-cell>\n </td>\n </tr>\n </ng-template>\n </tbody>\n </table>\n</div>\n",
|
|
2936
|
+
styles: [":host-context(.sky-theme-modern) :host:focus{outline:0}.sky-theme-modern :host:focus{outline:0}"]
|
|
2937
|
+
})
|
|
2938
|
+
], SkyDayPickerComponent);
|
|
2939
|
+
return SkyDayPickerComponent;
|
|
2940
|
+
}());
|
|
2941
|
+
|
|
2942
|
+
/**
|
|
2943
|
+
* @internal
|
|
2944
|
+
*/
|
|
2945
|
+
var SkyMonthPickerComponent = /** @class */ (function () {
|
|
2946
|
+
function SkyMonthPickerComponent(datepicker) {
|
|
2947
|
+
this.rows = [];
|
|
2948
|
+
this.datepicker = datepicker;
|
|
2949
|
+
}
|
|
2950
|
+
SkyMonthPickerComponent.prototype.ngOnInit = function () {
|
|
2951
|
+
var _this = this;
|
|
2952
|
+
this.datepicker.stepMonth = {
|
|
2953
|
+
years: 1
|
|
2954
|
+
};
|
|
2955
|
+
this.datepicker.setRefreshViewHandler(function () {
|
|
2956
|
+
_this.refreshMonthView();
|
|
2957
|
+
}, 'month');
|
|
2958
|
+
this.datepicker.setCompareHandler(this.compareMonth, 'month');
|
|
2959
|
+
this.datepicker.refreshView();
|
|
2960
|
+
this.datepicker.setKeydownHandler(function (key, event) {
|
|
2961
|
+
_this.keydownMonths(key, event);
|
|
2962
|
+
}, 'month');
|
|
2552
2963
|
};
|
|
2553
|
-
|
|
2554
|
-
|
|
2964
|
+
SkyMonthPickerComponent.prototype.compareMonth = function (date1, date2) {
|
|
2965
|
+
var d1 = new Date(date1.getFullYear(), date1.getMonth());
|
|
2966
|
+
var d2 = new Date(date2.getFullYear(), date2.getMonth());
|
|
2967
|
+
return d1.getTime() - d2.getTime();
|
|
2555
2968
|
};
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2969
|
+
SkyMonthPickerComponent.prototype.refreshMonthView = function () {
|
|
2970
|
+
var months = new Array(12);
|
|
2971
|
+
var year = this.datepicker.activeDate.getFullYear();
|
|
2972
|
+
var date;
|
|
2973
|
+
for (var i = 0; i < 12; i++) {
|
|
2974
|
+
date = new Date(year, i, 1);
|
|
2975
|
+
date = this.datepicker.fixTimeZone(date);
|
|
2976
|
+
months[i] =
|
|
2977
|
+
this.datepicker.createDateObject(date, this.datepicker.formatMonth, false, this.datepicker.datepickerId + '-' + i);
|
|
2565
2978
|
}
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
|
|
2570
|
-
|
|
2979
|
+
this.title =
|
|
2980
|
+
this.datepicker.dateFilter(this.datepicker.activeDate, this.datepicker.formatMonthTitle);
|
|
2981
|
+
this.rows = this.datepicker.createCalendarRows(months, this.datepicker.monthColLimit);
|
|
2982
|
+
};
|
|
2983
|
+
SkyMonthPickerComponent.prototype.keydownMonths = function (key, event) {
|
|
2984
|
+
var date = this.datepicker.activeDate.getMonth();
|
|
2985
|
+
/* istanbul ignore else */
|
|
2986
|
+
/* sanity check */
|
|
2987
|
+
if (key === 'left') {
|
|
2988
|
+
date = date - 1;
|
|
2571
2989
|
}
|
|
2572
|
-
else {
|
|
2573
|
-
|
|
2990
|
+
else if (key === 'up') {
|
|
2991
|
+
date = date - this.datepicker.monthColLimit;
|
|
2574
2992
|
}
|
|
2575
|
-
if (
|
|
2576
|
-
|
|
2577
|
-
'skyFuzzyDate': {
|
|
2578
|
-
invalid: value
|
|
2579
|
-
}
|
|
2580
|
-
};
|
|
2993
|
+
else if (key === 'right') {
|
|
2994
|
+
date = date + 1;
|
|
2581
2995
|
}
|
|
2582
|
-
if (
|
|
2583
|
-
|
|
2584
|
-
'skyFuzzyDate': {
|
|
2585
|
-
yearRequired: value
|
|
2586
|
-
}
|
|
2587
|
-
};
|
|
2996
|
+
else if (key === 'down') {
|
|
2997
|
+
date = date + this.datepicker.monthColLimit;
|
|
2588
2998
|
}
|
|
2589
|
-
if (
|
|
2590
|
-
var
|
|
2591
|
-
|
|
2592
|
-
fuzzyDateRange = this.fuzzyDateService.getFuzzyDateRange(fuzzyDate, this.maxDate);
|
|
2593
|
-
if (!fuzzyDateRange.valid) {
|
|
2594
|
-
validationError = {
|
|
2595
|
-
'skyFuzzyDate': {
|
|
2596
|
-
maxDate: value
|
|
2597
|
-
}
|
|
2598
|
-
};
|
|
2599
|
-
}
|
|
2600
|
-
}
|
|
2601
|
-
if (!validationError && this.minDate) {
|
|
2602
|
-
fuzzyDateRange = this.fuzzyDateService.getFuzzyDateRange(this.minDate, fuzzyDate);
|
|
2603
|
-
if (!fuzzyDateRange.valid) {
|
|
2604
|
-
validationError = {
|
|
2605
|
-
'skyFuzzyDate': {
|
|
2606
|
-
minDate: value
|
|
2607
|
-
}
|
|
2608
|
-
};
|
|
2609
|
-
}
|
|
2610
|
-
}
|
|
2611
|
-
if (!validationError && this.futureDisabled) {
|
|
2612
|
-
fuzzyDateRange = this.fuzzyDateService.getFuzzyDateRange(fuzzyDate, this.fuzzyDateService.getCurrentFuzzyDate());
|
|
2613
|
-
if (!fuzzyDateRange.valid) {
|
|
2614
|
-
validationError = {
|
|
2615
|
-
'skyFuzzyDate': {
|
|
2616
|
-
futureDisabled: value
|
|
2617
|
-
}
|
|
2618
|
-
};
|
|
2619
|
-
}
|
|
2620
|
-
}
|
|
2999
|
+
else if (key === 'pageup' || key === 'pagedown') {
|
|
3000
|
+
var year = this.datepicker.activeDate.getFullYear() + (key === 'pageup' ? -1 : 1);
|
|
3001
|
+
this.datepicker.activeDate.setFullYear(year);
|
|
2621
3002
|
}
|
|
2622
|
-
if (
|
|
2623
|
-
|
|
2624
|
-
// (This is only required when the invalid value is set by the FormControl constructor.)
|
|
2625
|
-
this.control.markAsTouched();
|
|
3003
|
+
else if (key === 'home') {
|
|
3004
|
+
date = 0;
|
|
2626
3005
|
}
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
this.
|
|
2631
|
-
};
|
|
2632
|
-
SkyFuzzyDatepickerInputDirective.prototype.registerOnTouched = function (fn) {
|
|
2633
|
-
this.onTouched = fn;
|
|
2634
|
-
};
|
|
2635
|
-
SkyFuzzyDatepickerInputDirective.prototype.registerOnValidatorChange = function (fn) {
|
|
2636
|
-
this.onValidatorChange = fn;
|
|
3006
|
+
else if (key === 'end') {
|
|
3007
|
+
date = 11;
|
|
3008
|
+
}
|
|
3009
|
+
this.datepicker.activeDate.setMonth(date);
|
|
2637
3010
|
};
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
3011
|
+
SkyMonthPickerComponent.ctorParameters = function () { return [
|
|
3012
|
+
{ type: SkyDatepickerCalendarInnerComponent }
|
|
3013
|
+
]; };
|
|
3014
|
+
SkyMonthPickerComponent = __decorate([
|
|
3015
|
+
Component({
|
|
3016
|
+
selector: 'sky-monthpicker',
|
|
3017
|
+
template: "<table *ngIf=\"datepicker.datepickerMode==='month'\" role=\"grid\">\n <thead>\n <tr>\n <th\n class=\"sky-datepicker-header-left\"\n >\n <button\n type=\"button\"\n class=\"sky-btn sky-btn-default sky-btn-sm sky-datepicker-btn-previous\"\n (click)=\"datepicker.moveCalendar($event, -1)\"\n tabindex=\"-1\"\n >\n <sky-icon\n class=\"sky-datepicker-chevron-default\"\n icon=\"chevron-left\"\n ></sky-icon>\n <sky-icon\n class=\"sky-datepicker-chevron-modern\"\n icon=\"chevron-left\"\n iconType=\"skyux\"\n ></sky-icon>\n </button></th>\n <th [attr.colspan]=\"((datepicker.monthColLimit - 2) <= 0) ? 1 : datepicker.monthColLimit - 2\">\n <button\n [id]=\"datepicker.datepickerId + '-title'\"\n type=\"button\"\n class=\"sky-btn sky-btn-default sky-btn-sm sky-datepicker-calendar-title\"\n (click)=\"datepicker.toggleModeCalendar($event)\"\n [disabled]=\"datepicker.datepickerMode === maxMode\"\n [ngClass]=\"{'sky-btn-disabled': datepicker.datepickerMode === maxMode}\"\n tabindex=\"-1\"\n >\n <strong>{{title}}</strong>\n </button>\n </th>\n <th\n class=\"sky-datepicker-header-right\"\n >\n <button\n type=\"button\"\n class=\"sky-btn sky-btn-default sky-btn-sm sky-datepicker-btn-next\"\n (click)=\"datepicker.moveCalendar($event, 1)\"\n tabindex=\"-1\"\n >\n <sky-icon\n class=\"sky-datepicker-chevron-default\"\n icon=\"chevron-right\"\n ></sky-icon>\n <sky-icon\n class=\"sky-datepicker-chevron-modern\"\n icon=\"chevron-right\"\n iconType=\"skyux\"\n ></sky-icon>\n </button>\n </th>\n </tr>\n </thead>\n <tbody>\n <tr *ngFor=\"let row of rows\">\n <td\n *ngFor=\"let date of row\"\n class=\"text-center\"\n role=\"gridcell\"\n id=\"{{date.uid}}\">\n <button\n type=\"button\"\n class=\"sky-btn sky-btn-default sky-datepicker-btn-date\"\n [ngClass]=\"{'sky-datepicker-btn-selected': date.selected, 'sky-btn-disabled': date.disabled, 'sky-btn-active': datepicker.isActive(date)}\"\n [disabled]=\"date.disabled\"\n (click)=\"datepicker.selectCalendar($event, date.date)\"\n tabindex=\"-1\"\n >\n <span [ngClass]=\"{'sky-datepicker-current': date.current}\">{{date.label}}</span>\n </button>\n </td>\n </tr>\n </tbody>\n</table>\n",
|
|
3018
|
+
styles: [":host-context(.sky-theme-modern) :host:focus{outline:0}.sky-theme-modern :host:focus{outline:0}"]
|
|
3019
|
+
})
|
|
3020
|
+
], SkyMonthPickerComponent);
|
|
3021
|
+
return SkyMonthPickerComponent;
|
|
3022
|
+
}());
|
|
3023
|
+
|
|
3024
|
+
/**
|
|
3025
|
+
* @internal
|
|
3026
|
+
*/
|
|
3027
|
+
var SkyYearPickerComponent = /** @class */ (function () {
|
|
3028
|
+
function SkyYearPickerComponent(datepicker) {
|
|
3029
|
+
this.rows = [];
|
|
3030
|
+
this.datepicker = datepicker;
|
|
3031
|
+
}
|
|
3032
|
+
SkyYearPickerComponent.prototype.ngOnInit = function () {
|
|
3033
|
+
var _this = this;
|
|
3034
|
+
this.datepicker.stepYear = { years: this.datepicker.yearRange };
|
|
3035
|
+
this.datepicker.setRefreshViewHandler(function () {
|
|
3036
|
+
_this.refreshYearView();
|
|
3037
|
+
}, 'year');
|
|
3038
|
+
this.datepicker.setCompareHandler(this.compareYears, 'year');
|
|
3039
|
+
this.datepicker.setKeydownHandler(function (key, event) {
|
|
3040
|
+
_this.keydownYears(key, event);
|
|
3041
|
+
}, 'year');
|
|
3042
|
+
this.datepicker.refreshView();
|
|
2641
3043
|
};
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
* This is useful if you need to update the ngModel value before the input element loses focus.
|
|
2645
|
-
*/
|
|
2646
|
-
SkyFuzzyDatepickerInputDirective.prototype.detectInputValueChange = function () {
|
|
2647
|
-
this.onValueChange(this.elementRef.nativeElement.value);
|
|
3044
|
+
SkyYearPickerComponent.prototype.getStartingYear = function (year) {
|
|
3045
|
+
return Math.floor((year - 1) / this.datepicker.yearRange) * this.datepicker.yearRange + 1;
|
|
2648
3046
|
};
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
this.value = newValue;
|
|
3047
|
+
SkyYearPickerComponent.prototype.compareYears = function (date1, date2) {
|
|
3048
|
+
return date1.getFullYear() - date2.getFullYear();
|
|
2652
3049
|
};
|
|
2653
|
-
|
|
2654
|
-
|
|
3050
|
+
SkyYearPickerComponent.prototype.refreshYearView = function () {
|
|
3051
|
+
var years = new Array(this.datepicker.yearRange);
|
|
3052
|
+
var date;
|
|
3053
|
+
var start = this.getStartingYear(this.datepicker.activeDate.getFullYear());
|
|
3054
|
+
for (var i = 0; i < this.datepicker.yearRange; i++) {
|
|
3055
|
+
date = new Date(this.datepicker.activeDate);
|
|
3056
|
+
date.setFullYear(start + i, 0, 1);
|
|
3057
|
+
years[i] =
|
|
3058
|
+
this.datepicker.createDateObject(date, this.datepicker.formatYear, false, this.datepicker.datepickerId + '-' + i);
|
|
3059
|
+
}
|
|
3060
|
+
this.title = [years[0].label,
|
|
3061
|
+
years[this.datepicker.yearRange - 1].label].join(' - ');
|
|
3062
|
+
this.rows = this.datepicker.createCalendarRows(years, this.datepicker.yearColLimit);
|
|
2655
3063
|
};
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
|
|
2660
|
-
|
|
2661
|
-
|
|
3064
|
+
SkyYearPickerComponent.prototype.keydownYears = function (key, event) {
|
|
3065
|
+
var date = this.datepicker.activeDate.getFullYear();
|
|
3066
|
+
/* istanbul ignore else */
|
|
3067
|
+
/* sanity check */
|
|
3068
|
+
if (key === 'left') {
|
|
3069
|
+
date = date - 1;
|
|
2662
3070
|
}
|
|
2663
|
-
else if (
|
|
2664
|
-
|
|
3071
|
+
else if (key === 'up') {
|
|
3072
|
+
date = date - this.datepicker.yearColLimit;
|
|
2665
3073
|
}
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
SkyFuzzyDatepickerInputDirective.prototype.getMinDate = function () {
|
|
2669
|
-
if (this.minDate) {
|
|
2670
|
-
var minDate = this.fuzzyDateService.getMomentFromFuzzyDate(this.minDate);
|
|
2671
|
-
if (minDate.isValid()) {
|
|
2672
|
-
return minDate.toDate();
|
|
2673
|
-
}
|
|
3074
|
+
else if (key === 'right') {
|
|
3075
|
+
date = date + 1;
|
|
2674
3076
|
}
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
|
|
3077
|
+
else if (key === 'down') {
|
|
3078
|
+
date = date + this.datepicker.yearColLimit;
|
|
3079
|
+
}
|
|
3080
|
+
else if (key === 'pageup' || key === 'pagedown') {
|
|
3081
|
+
date += (key === 'pageup' ? -1 : 1) * this.datepicker.yearRange;
|
|
3082
|
+
}
|
|
3083
|
+
else if (key === 'home') {
|
|
3084
|
+
date = this.getStartingYear(this.datepicker.activeDate.getFullYear());
|
|
3085
|
+
}
|
|
3086
|
+
else if (key === 'end') {
|
|
3087
|
+
date
|
|
3088
|
+
= this.getStartingYear(this.datepicker.activeDate.getFullYear()) + this.datepicker.yearRange - 1;
|
|
3089
|
+
}
|
|
3090
|
+
this.datepicker.activeDate.setFullYear(date);
|
|
2685
3091
|
};
|
|
2686
|
-
|
|
2687
|
-
{ type:
|
|
2688
|
-
{ type: SkyDatepickerConfigService },
|
|
2689
|
-
{ type: ElementRef },
|
|
2690
|
-
{ type: SkyFuzzyDateService },
|
|
2691
|
-
{ type: SkyAppLocaleProvider },
|
|
2692
|
-
{ type: Renderer2 },
|
|
2693
|
-
{ type: SkyLibResourcesService },
|
|
2694
|
-
{ type: SkyDatepickerComponent, decorators: [{ type: Optional }] }
|
|
3092
|
+
SkyYearPickerComponent.ctorParameters = function () { return [
|
|
3093
|
+
{ type: SkyDatepickerCalendarInnerComponent }
|
|
2695
3094
|
]; };
|
|
2696
|
-
__decorate([
|
|
2697
|
-
|
|
2698
|
-
|
|
2699
|
-
|
|
2700
|
-
|
|
2701
|
-
|
|
2702
|
-
|
|
2703
|
-
|
|
2704
|
-
], SkyFuzzyDatepickerInputDirective.prototype, "futureDisabled", null);
|
|
2705
|
-
__decorate([
|
|
2706
|
-
Input()
|
|
2707
|
-
], SkyFuzzyDatepickerInputDirective.prototype, "maxDate", null);
|
|
2708
|
-
__decorate([
|
|
2709
|
-
Input()
|
|
2710
|
-
], SkyFuzzyDatepickerInputDirective.prototype, "minDate", null);
|
|
2711
|
-
__decorate([
|
|
2712
|
-
Input()
|
|
2713
|
-
], SkyFuzzyDatepickerInputDirective.prototype, "skyDatepickerNoValidate", void 0);
|
|
2714
|
-
__decorate([
|
|
2715
|
-
Input()
|
|
2716
|
-
], SkyFuzzyDatepickerInputDirective.prototype, "skyFuzzyDatepickerInput", null);
|
|
2717
|
-
__decorate([
|
|
2718
|
-
Input()
|
|
2719
|
-
], SkyFuzzyDatepickerInputDirective.prototype, "startingDay", null);
|
|
2720
|
-
__decorate([
|
|
2721
|
-
Input()
|
|
2722
|
-
], SkyFuzzyDatepickerInputDirective.prototype, "yearRequired", null);
|
|
2723
|
-
__decorate([
|
|
2724
|
-
HostListener('change', ['$event'])
|
|
2725
|
-
], SkyFuzzyDatepickerInputDirective.prototype, "onInputChange", null);
|
|
2726
|
-
__decorate([
|
|
2727
|
-
HostListener('blur')
|
|
2728
|
-
], SkyFuzzyDatepickerInputDirective.prototype, "onInputBlur", null);
|
|
2729
|
-
__decorate([
|
|
2730
|
-
HostListener('keyup')
|
|
2731
|
-
], SkyFuzzyDatepickerInputDirective.prototype, "onInputKeyup", null);
|
|
2732
|
-
SkyFuzzyDatepickerInputDirective = __decorate([
|
|
2733
|
-
Directive({
|
|
2734
|
-
selector: '[skyFuzzyDatepickerInput]',
|
|
2735
|
-
providers: [
|
|
2736
|
-
SKY_FUZZY_DATEPICKER_VALUE_ACCESSOR,
|
|
2737
|
-
SKY_FUZZY_DATEPICKER_VALIDATOR
|
|
2738
|
-
]
|
|
2739
|
-
}),
|
|
2740
|
-
__param(7, Optional())
|
|
2741
|
-
], SkyFuzzyDatepickerInputDirective);
|
|
2742
|
-
return SkyFuzzyDatepickerInputDirective;
|
|
3095
|
+
SkyYearPickerComponent = __decorate([
|
|
3096
|
+
Component({
|
|
3097
|
+
selector: 'sky-yearpicker',
|
|
3098
|
+
template: "<table *ngIf=\"datepicker.datepickerMode==='year'\" role=\"grid\">\n <thead>\n <tr>\n <th\n class=\"sky-datepicker-header-left\"\n >\n <button\n type=\"button\"\n class=\"sky-btn sky-btn-default sky-btn-sm sky-datepicker-btn-previous\"\n (click)=\"datepicker.moveCalendar($event, -1)\"\n tabindex=\"-1\"\n >\n <sky-icon\n class=\"sky-datepicker-chevron-default\"\n icon=\"chevron-left\"\n ></sky-icon>\n <sky-icon\n class=\"sky-datepicker-chevron-modern\"\n icon=\"chevron-left\"\n iconType=\"skyux\"\n ></sky-icon>\n </button>\n </th>\n <th [attr.colspan]=\"((datepicker.yearColLimit - 2) <= 0) ? 1 : datepicker.yearColLimit - 2\">\n <button\n [id]=\"datepicker.datepickerId + '-title'\"\n role=\"heading\"\n type=\"button\"\n class=\"sky-btn sky-btn-default sky-btn-sm sky-datepicker-calendar-title\"\n (click)=\"datepicker.toggleModeCalendar($event)\"\n [disabled]=\"datepicker.datepickerMode === datepicker.maxMode\"\n [ngClass]=\"{'sky-btn-disabled': datepicker.datepickerMode === datepicker.maxMode}\"\n tabindex=\"-1\"\n >\n <strong>{{title}}</strong>\n </button>\n </th>\n <th\n class=\"sky-datepicker-header-right\"\n >\n <button\n type=\"button\"\n class=\"sky-btn sky-btn-default sky-btn-sm sky-datepicker-btn-next\"\n (click)=\"datepicker.moveCalendar($event, 1)\"\n tabindex=\"-1\"\n >\n <sky-icon\n class=\"sky-datepicker-chevron-default\"\n icon=\"chevron-right\"\n ></sky-icon>\n <sky-icon\n class=\"sky-datepicker-chevron-modern\"\n icon=\"chevron-right\"\n iconType=\"skyux\"\n ></sky-icon>\n </button>\n </th>\n </tr>\n </thead>\n <tbody>\n <tr *ngFor=\"let row of rows\">\n <td\n *ngFor=\"let date of row\"\n class=\"sky-datepicker-row\"\n role=\"gridcell\"\n >\n <button\n type=\"button\"\n class=\"sky-btn sky-btn-default sky-datepicker-btn-date\"\n [ngClass]=\"{'sky-datepicker-btn-selected': date.selected, 'sky-btn-disabled': date.disabled, 'sky-btn-active': datepicker.isActive(date)}\"\n [disabled]=\"date.disabled\"\n (click)=\"datepicker.selectCalendar($event, date.date)\"\n tabindex=\"-1\"\n >\n <span\n [ngClass]=\"{'sky-datepicker-current': date.current }\">{{date.label}}</span>\n </button>\n </td>\n </tr>\n </tbody>\n</table>\n",
|
|
3099
|
+
styles: [":host-context(.sky-theme-modern) :host:focus{outline:0}.sky-theme-modern :host:focus{outline:0}"]
|
|
3100
|
+
})
|
|
3101
|
+
], SkyYearPickerComponent);
|
|
3102
|
+
return SkyYearPickerComponent;
|
|
2743
3103
|
}());
|
|
2744
3104
|
|
|
2745
3105
|
var SkyDatepickerModule = /** @class */ (function () {
|
|
@@ -2755,7 +3115,9 @@ var SkyDatepickerModule = /** @class */ (function () {
|
|
|
2755
3115
|
SkyYearPickerComponent,
|
|
2756
3116
|
SkyDatepickerComponent,
|
|
2757
3117
|
SkyDatepickerInputDirective,
|
|
2758
|
-
SkyFuzzyDatepickerInputDirective
|
|
3118
|
+
SkyFuzzyDatepickerInputDirective,
|
|
3119
|
+
SkyDayPickerCellComponent,
|
|
3120
|
+
SkyDayPickerButtonComponent
|
|
2759
3121
|
],
|
|
2760
3122
|
imports: [
|
|
2761
3123
|
CommonModule,
|
|
@@ -2765,7 +3127,9 @@ var SkyDatepickerModule = /** @class */ (function () {
|
|
|
2765
3127
|
SkyDateTimeResourcesModule,
|
|
2766
3128
|
SkyAffixModule,
|
|
2767
3129
|
SkyOverlayModule,
|
|
2768
|
-
SkyThemeModule
|
|
3130
|
+
SkyThemeModule,
|
|
3131
|
+
SkyPopoverModule,
|
|
3132
|
+
SkyWaitModule
|
|
2769
3133
|
],
|
|
2770
3134
|
exports: [
|
|
2771
3135
|
SkyDatepickerCalendarComponent,
|
|
@@ -2775,14 +3139,17 @@ var SkyDatepickerModule = /** @class */ (function () {
|
|
|
2775
3139
|
SkyYearPickerComponent,
|
|
2776
3140
|
SkyDatepickerComponent,
|
|
2777
3141
|
SkyDatepickerInputDirective,
|
|
2778
|
-
SkyFuzzyDatepickerInputDirective
|
|
3142
|
+
SkyFuzzyDatepickerInputDirective,
|
|
3143
|
+
SkyDayPickerCellComponent,
|
|
3144
|
+
SkyDayPickerButtonComponent
|
|
2779
3145
|
],
|
|
2780
3146
|
providers: [
|
|
2781
3147
|
SkyAppWindowRef,
|
|
2782
3148
|
SkyDatepickerConfigService,
|
|
2783
3149
|
SkyFuzzyDateService,
|
|
2784
3150
|
SkyCoreAdapterService,
|
|
2785
|
-
SkyThemeService
|
|
3151
|
+
SkyThemeService,
|
|
3152
|
+
SkyDatepickerService
|
|
2786
3153
|
]
|
|
2787
3154
|
})
|
|
2788
3155
|
], SkyDatepickerModule);
|
|
@@ -3911,7 +4278,7 @@ var SkyDateRangePickerComponent = /** @class */ (function () {
|
|
|
3911
4278
|
SKY_DATE_RANGE_PICKER_VALIDATOR
|
|
3912
4279
|
],
|
|
3913
4280
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
3914
|
-
styles: [".sky-date-range-picker{display:flex;margin-left:-5px;margin-right:-5px}.sky-date-range-picker-form-group{padding-left:5px;padding-right:5px}.sky-date-range-picker-form-group:last-child{margin-bottom:0}:host .sky-date-range-picker{flex-direction:column}:host .sky-date-range-picker-form-group{flex-basis:100%}:host-context(.sky-responsive-container-lg) .sky-date-range-picker,:host-context(.sky-responsive-container-md) .sky-date-range-picker,:host-context(.sky-responsive-container-sm) .sky-date-range-picker,:host-context(.sky-responsive-container-xs) .sky-date-range-picker{flex-direction:column}:host-context(.sky-responsive-container-lg) .sky-date-range-picker-form-group,:host-context(.sky-responsive-container-md) .sky-date-range-picker-form-group,:host-context(.sky-responsive-container-sm) .sky-date-range-picker-form-group,:host-context(.sky-responsive-container-xs) .sky-date-range-picker-form-group{flex-basis:100%}@media (min-width:768px){:host .sky-date-range-picker{flex-direction:initial}:host .sky-date-range-picker-form-group{flex-basis:calc(100% / 3);margin-bottom:0}}:host-context(.sky-responsive-container-lg) .sky-date-range-picker,:host-context(.sky-responsive-container-md) .sky-date-range-picker,:host-context(.sky-responsive-container-sm) .sky-date-range-picker{flex-direction:initial}:host-context(.sky-responsive-container-lg) .sky-date-range-picker-form-group,:host-context(.sky-responsive-container-md) .sky-date-range-picker-form-group,:host-context(.sky-responsive-container-sm) .sky-date-range-picker-form-group{flex-basis:calc(100% / 3);margin-bottom:0}.sky-theme-modern .sky-date-range-picker-form-group
|
|
4281
|
+
styles: [".sky-date-range-picker{display:flex;margin-left:-5px;margin-right:-5px}.sky-date-range-picker-form-group{padding-left:5px;padding-right:5px}.sky-date-range-picker-form-group:last-child{margin-bottom:0}:host .sky-date-range-picker{flex-direction:column}:host .sky-date-range-picker-form-group{flex-basis:100%}:host-context(.sky-responsive-container-lg) .sky-date-range-picker,:host-context(.sky-responsive-container-md) .sky-date-range-picker,:host-context(.sky-responsive-container-sm) .sky-date-range-picker,:host-context(.sky-responsive-container-xs) .sky-date-range-picker{flex-direction:column}:host-context(.sky-responsive-container-lg) .sky-date-range-picker-form-group,:host-context(.sky-responsive-container-md) .sky-date-range-picker-form-group,:host-context(.sky-responsive-container-sm) .sky-date-range-picker-form-group,:host-context(.sky-responsive-container-xs) .sky-date-range-picker-form-group{flex-basis:100%}@media (min-width:768px){:host .sky-date-range-picker{flex-direction:initial}:host .sky-date-range-picker-form-group{flex-basis:calc(100% / 3);margin-bottom:0}}:host-context(.sky-responsive-container-lg) .sky-date-range-picker,:host-context(.sky-responsive-container-md) .sky-date-range-picker,:host-context(.sky-responsive-container-sm) .sky-date-range-picker{flex-direction:initial}:host-context(.sky-responsive-container-lg) .sky-date-range-picker-form-group,:host-context(.sky-responsive-container-md) .sky-date-range-picker-form-group,:host-context(.sky-responsive-container-sm) .sky-date-range-picker-form-group{flex-basis:calc(100% / 3);margin-bottom:0}:host-context(.sky-theme-modern) .sky-date-range-picker-form-group{padding:0;margin:0 0 20px}.sky-theme-modern .sky-date-range-picker-form-group{padding:0;margin:0 0 20px}@media (min-width:768px){:host-context(.sky-theme-modern) .sky-date-range-picker-form-group{margin:0 20px 0 0}.sky-theme-modern .sky-date-range-picker-form-group{margin:0 20px 0 0}}:host-context(.sky-theme-modern.sky-responsive-container-xs) .sky-date-range-picker-form-group{margin:0 0 20px}:host-context(.sky-theme-modern.sky-responsive-container-lg) .sky-date-range-picker-form-group,:host-context(.sky-theme-modern.sky-responsive-container-md) .sky-date-range-picker-form-group,:host-context(.sky-theme-modern.sky-responsive-container-sm) .sky-date-range-picker-form-group{margin:0 20px 0 0}"]
|
|
3915
4282
|
}),
|
|
3916
4283
|
__param(5, Optional())
|
|
3917
4284
|
], SkyDateRangePickerComponent);
|
|
@@ -4071,7 +4438,8 @@ var SkyTimepickerInputDirective = /** @class */ (function () {
|
|
|
4071
4438
|
SkyTimepickerInputDirective.prototype.onChange = function (event) {
|
|
4072
4439
|
this.writeValue(event.target.value);
|
|
4073
4440
|
};
|
|
4074
|
-
SkyTimepickerInputDirective.prototype.onBlur
|
|
4441
|
+
SkyTimepickerInputDirective.prototype.onBlur = function () {
|
|
4442
|
+
/* istanbul ignore next */
|
|
4075
4443
|
this._onTouched();
|
|
4076
4444
|
};
|
|
4077
4445
|
SkyTimepickerInputDirective.prototype.registerOnChange = function (fn) { this._onChange = fn; };
|
|
@@ -4347,7 +4715,7 @@ var SkyTimepickerComponent = /** @class */ (function () {
|
|
|
4347
4715
|
});
|
|
4348
4716
|
SkyTimepickerComponent.prototype.ngOnInit = function () {
|
|
4349
4717
|
this.setFormat(this.timeFormat);
|
|
4350
|
-
this.
|
|
4718
|
+
this.addKeydownListner();
|
|
4351
4719
|
if (this.inputBoxHostService) {
|
|
4352
4720
|
this.inputBoxHostService.populate({
|
|
4353
4721
|
inputTemplate: this.inputTemplateRef,
|
|
@@ -4488,6 +4856,7 @@ var SkyTimepickerComponent = /** @class */ (function () {
|
|
|
4488
4856
|
_this.closePicker();
|
|
4489
4857
|
}
|
|
4490
4858
|
});
|
|
4859
|
+
this.addKeydownListner();
|
|
4491
4860
|
overlay.attachTemplate(this.timepickerTemplateRef);
|
|
4492
4861
|
this.overlay = overlay;
|
|
4493
4862
|
};
|
|
@@ -4498,9 +4867,9 @@ var SkyTimepickerComponent = /** @class */ (function () {
|
|
|
4498
4867
|
this.overlay = undefined;
|
|
4499
4868
|
}
|
|
4500
4869
|
};
|
|
4501
|
-
SkyTimepickerComponent.prototype.
|
|
4870
|
+
SkyTimepickerComponent.prototype.addKeydownListner = function () {
|
|
4502
4871
|
var _this = this;
|
|
4503
|
-
fromEvent(window.document, 'keydown')
|
|
4872
|
+
this.overlayKeydownListner = fromEvent(window.document, 'keydown')
|
|
4504
4873
|
.pipe(takeUntil(this.ngUnsubscribe))
|
|
4505
4874
|
.subscribe(function (event) {
|
|
4506
4875
|
var _a;
|
|
@@ -4512,12 +4881,14 @@ var SkyTimepickerComponent = /** @class */ (function () {
|
|
|
4512
4881
|
});
|
|
4513
4882
|
};
|
|
4514
4883
|
SkyTimepickerComponent.prototype.removePickerEventListeners = function () {
|
|
4884
|
+
var _a;
|
|
4515
4885
|
/* istanbul ignore else */
|
|
4516
4886
|
if (this.timepickerUnsubscribe) {
|
|
4517
4887
|
this.timepickerUnsubscribe.next();
|
|
4518
4888
|
this.timepickerUnsubscribe.complete();
|
|
4519
4889
|
this.timepickerUnsubscribe = undefined;
|
|
4520
4890
|
}
|
|
4891
|
+
(_a = this.overlayKeydownListner) === null || _a === void 0 ? void 0 : _a.unsubscribe();
|
|
4521
4892
|
};
|
|
4522
4893
|
SkyTimepickerComponent.ctorParameters = function () { return [
|
|
4523
4894
|
{ type: SkyAffixService },
|
|
@@ -4606,5 +4977,5 @@ var SkyTimepickerModule = /** @class */ (function () {
|
|
|
4606
4977
|
* Generated bundle index. Do not edit.
|
|
4607
4978
|
*/
|
|
4608
4979
|
|
|
4609
|
-
export { SkyDatePipe, SkyDatePipeModule, SkyDateRangeCalculatorId, SkyDateRangeCalculatorType, SkyDateRangePickerModule, SkyDateRangeService, SkyDatepickerConfigService, SkyDatepickerModule, SkyFuzzyDatePipe, SkyFuzzyDateService, SkyTimepickerModule, SkyDateTimeResourcesModule as ɵa, SkyDateTimeResourcesProvider as ɵb, SkyDateRangePickerComponent as ɵc, SkyDatepickerCalendarComponent as ɵd, SkyDatepickerAdapterService as ɵe, SkyDatepickerCalendarInnerComponent as ɵf, SkyDayPickerComponent as ɵg, SkyMonthPickerComponent as ɵh, SkyYearPickerComponent as ɵi, SkyDatepickerComponent as ɵj, SkyDatepickerInputDirective as ɵk, SkyFuzzyDatepickerInputDirective as ɵl,
|
|
4980
|
+
export { SkyDatePipe, SkyDatePipeModule, SkyDateRangeCalculatorId, SkyDateRangeCalculatorType, SkyDateRangePickerModule, SkyDateRangeService, SkyDatepickerConfigService, SkyDatepickerModule, SkyFuzzyDatePipe, SkyFuzzyDateService, SkyTimepickerModule, SkyDateTimeResourcesModule as ɵa, SkyDateTimeResourcesProvider as ɵb, SkyDateRangePickerComponent as ɵc, SkyDatepickerCalendarComponent as ɵd, SkyDatepickerAdapterService as ɵe, SkyDatepickerCalendarInnerComponent as ɵf, SkyDayPickerComponent as ɵg, SkyMonthPickerComponent as ɵh, SkyYearPickerComponent as ɵi, SkyDatepickerComponent as ɵj, SkyDatepickerInputDirective as ɵk, SkyFuzzyDatepickerInputDirective as ɵl, SkyDayPickerCellComponent as ɵm, SkyDatepickerService as ɵn, SkyDayPickerButtonComponent as ɵo, SkyTimepickerInputDirective as ɵp, SkyTimepickerComponent as ɵq };
|
|
4610
4981
|
//# sourceMappingURL=skyux-datetime.js.map
|