@skyux/datetime 4.12.3 → 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 +4 -0
- package/bundles/skyux-datetime.umd.js +1294 -941
- 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/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.component.js +47 -4
- 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 +95 -3
- package/esm2015/public_api.js +1 -1
- package/esm2015/skyux-datetime.js +6 -3
- 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.component.js +48 -4
- 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 +99 -3
- package/esm5/public_api.js +1 -1
- package/esm5/skyux-datetime.js +6 -3
- package/fesm2015/skyux-datetime.js +1380 -1039
- package/fesm2015/skyux-datetime.js.map +1 -1
- package/fesm5/skyux-datetime.js +1289 -938
- 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.component.d.ts +13 -0
- 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/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/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_;
|
|
@@ -835,6 +836,7 @@ var SkyDatepickerCalendarInnerComponent = /** @class */ (function () {
|
|
|
835
836
|
39: 'right',
|
|
836
837
|
40: 'down'
|
|
837
838
|
};
|
|
839
|
+
this.ngUnsubscribe = new Subject();
|
|
838
840
|
}
|
|
839
841
|
Object.defineProperty(SkyDatepickerCalendarInnerComponent.prototype, "selectedDate", {
|
|
840
842
|
get: function () {
|
|
@@ -860,6 +862,10 @@ var SkyDatepickerCalendarInnerComponent = /** @class */ (function () {
|
|
|
860
862
|
SkyDatepickerCalendarInnerComponent.prototype.ngOnChanges = function (changes) {
|
|
861
863
|
this.refreshView();
|
|
862
864
|
};
|
|
865
|
+
SkyDatepickerCalendarInnerComponent.prototype.ngOnDestroy = function () {
|
|
866
|
+
this.ngUnsubscribe.next();
|
|
867
|
+
this.ngUnsubscribe.complete();
|
|
868
|
+
};
|
|
863
869
|
SkyDatepickerCalendarInnerComponent.prototype.setCompareHandler = function (handler, type) {
|
|
864
870
|
if (type === 'day') {
|
|
865
871
|
this.compareHandlerDay = handler;
|
|
@@ -963,6 +969,7 @@ var SkyDatepickerCalendarInnerComponent = /** @class */ (function () {
|
|
|
963
969
|
}
|
|
964
970
|
};
|
|
965
971
|
SkyDatepickerCalendarInnerComponent.prototype.createDateObject = function (date, format, isSecondary, id) {
|
|
972
|
+
var customDateMatch = this.getCustomDate(date);
|
|
966
973
|
var dateObject = {
|
|
967
974
|
date: new Date(date.getFullYear(), date.getMonth(), date.getDate()),
|
|
968
975
|
label: this.dateFilter(date, format),
|
|
@@ -970,7 +977,9 @@ var SkyDatepickerCalendarInnerComponent = /** @class */ (function () {
|
|
|
970
977
|
disabled: this.isDisabled(date),
|
|
971
978
|
current: this.compare(date, new Date()) === 0,
|
|
972
979
|
secondary: isSecondary,
|
|
973
|
-
uid: id
|
|
980
|
+
uid: id,
|
|
981
|
+
keyDate: customDateMatch ? customDateMatch.keyDate : undefined,
|
|
982
|
+
keyDateText: customDateMatch ? customDateMatch.keyDateText : []
|
|
974
983
|
};
|
|
975
984
|
return dateObject;
|
|
976
985
|
};
|
|
@@ -1057,10 +1066,27 @@ var SkyDatepickerCalendarInnerComponent = /** @class */ (function () {
|
|
|
1057
1066
|
this.refreshView();
|
|
1058
1067
|
}
|
|
1059
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
|
+
*/
|
|
1060
1074
|
SkyDatepickerCalendarInnerComponent.prototype.isDisabled = function (date) {
|
|
1061
|
-
|
|
1062
|
-
|
|
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
|
+
}
|
|
1063
1086
|
};
|
|
1087
|
+
__decorate([
|
|
1088
|
+
Input()
|
|
1089
|
+
], SkyDatepickerCalendarInnerComponent.prototype, "customDates", void 0);
|
|
1064
1090
|
__decorate([
|
|
1065
1091
|
Input()
|
|
1066
1092
|
], SkyDatepickerCalendarInnerComponent.prototype, "startingDay", void 0);
|
|
@@ -1114,6 +1140,7 @@ var SkyDatepickerCalendarComponent = /** @class */ (function () {
|
|
|
1114
1140
|
this.config = config;
|
|
1115
1141
|
this.elementRef = elementRef;
|
|
1116
1142
|
this.selectedDateChange = new EventEmitter(undefined);
|
|
1143
|
+
this.calendarDateRangeChange = new EventEmitter();
|
|
1117
1144
|
this.calendarModeChange = new EventEmitter();
|
|
1118
1145
|
this._now = new Date();
|
|
1119
1146
|
this.formatter = new SkyDateFormatter();
|
|
@@ -1147,6 +1174,9 @@ var SkyDatepickerCalendarComponent = /** @class */ (function () {
|
|
|
1147
1174
|
SkyDatepickerCalendarComponent.prototype.configureOptions = function () {
|
|
1148
1175
|
Object.assign(this, this.config);
|
|
1149
1176
|
};
|
|
1177
|
+
SkyDatepickerCalendarComponent.prototype.onCalendarDateRangeChange = function (event) {
|
|
1178
|
+
this.calendarDateRangeChange.next(event);
|
|
1179
|
+
};
|
|
1150
1180
|
SkyDatepickerCalendarComponent.prototype.onCalendarModeChange = function (event) {
|
|
1151
1181
|
this.calendarModeChange.emit(event);
|
|
1152
1182
|
};
|
|
@@ -1174,6 +1204,12 @@ var SkyDatepickerCalendarComponent = /** @class */ (function () {
|
|
|
1174
1204
|
{ type: SkyDatepickerConfigService },
|
|
1175
1205
|
{ type: ElementRef }
|
|
1176
1206
|
]; };
|
|
1207
|
+
__decorate([
|
|
1208
|
+
Input()
|
|
1209
|
+
], SkyDatepickerCalendarComponent.prototype, "customDates", void 0);
|
|
1210
|
+
__decorate([
|
|
1211
|
+
Input()
|
|
1212
|
+
], SkyDatepickerCalendarComponent.prototype, "isDaypickerWaiting", void 0);
|
|
1177
1213
|
__decorate([
|
|
1178
1214
|
Input()
|
|
1179
1215
|
], SkyDatepickerCalendarComponent.prototype, "minDate", void 0);
|
|
@@ -1189,6 +1225,9 @@ var SkyDatepickerCalendarComponent = /** @class */ (function () {
|
|
|
1189
1225
|
__decorate([
|
|
1190
1226
|
Output()
|
|
1191
1227
|
], SkyDatepickerCalendarComponent.prototype, "selectedDateChange", void 0);
|
|
1228
|
+
__decorate([
|
|
1229
|
+
Output()
|
|
1230
|
+
], SkyDatepickerCalendarComponent.prototype, "calendarDateRangeChange", void 0);
|
|
1192
1231
|
__decorate([
|
|
1193
1232
|
Output()
|
|
1194
1233
|
], SkyDatepickerCalendarComponent.prototype, "calendarModeChange", void 0);
|
|
@@ -1201,7 +1240,7 @@ var SkyDatepickerCalendarComponent = /** @class */ (function () {
|
|
|
1201
1240
|
SkyDatepickerCalendarComponent = __decorate([
|
|
1202
1241
|
Component({
|
|
1203
1242
|
selector: 'sky-datepicker-calendar',
|
|
1204
|
-
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",
|
|
1205
1244
|
providers: [SkyDatepickerAdapterService],
|
|
1206
1245
|
styles: [".sky-datepicker-calendar{display:block}"]
|
|
1207
1246
|
})
|
|
@@ -1209,796 +1248,557 @@ var SkyDatepickerCalendarComponent = /** @class */ (function () {
|
|
|
1209
1248
|
return SkyDatepickerCalendarComponent;
|
|
1210
1249
|
}());
|
|
1211
1250
|
|
|
1251
|
+
var nextId = 0;
|
|
1212
1252
|
/**
|
|
1213
|
-
*
|
|
1253
|
+
* Creates the datepicker button and calendar.
|
|
1254
|
+
* You must wrap this component around an input with the `skyDatepickerInput` directive.
|
|
1214
1255
|
*/
|
|
1215
|
-
var
|
|
1216
|
-
function
|
|
1217
|
-
this.labels = [];
|
|
1218
|
-
this.rows = [];
|
|
1219
|
-
this.weekNumbers = [];
|
|
1220
|
-
this.daysInMonth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
|
1221
|
-
this.datepicker = datepicker;
|
|
1222
|
-
}
|
|
1223
|
-
SkyDayPickerComponent.prototype.ngOnInit = function () {
|
|
1256
|
+
var SkyDatepickerComponent = /** @class */ (function () {
|
|
1257
|
+
function SkyDatepickerComponent(affixService, changeDetector, coreAdapter, overlayService, inputBoxHostService, themeSvc) {
|
|
1224
1258
|
var _this = this;
|
|
1225
|
-
this.
|
|
1226
|
-
this.
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
this.
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
this.
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
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
|
+
});
|
|
1245
1385
|
}
|
|
1246
|
-
return dates;
|
|
1247
1386
|
};
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
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();
|
|
1252
1394
|
};
|
|
1253
|
-
|
|
1254
|
-
var
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
// 42 is the number of days on a six-week calendar
|
|
1268
|
-
var days = this.getDates(firstDate, 42);
|
|
1269
|
-
var pickerDates = [];
|
|
1270
|
-
for (var i = 0; i < 42; i++) {
|
|
1271
|
-
var _dateObject = this.datepicker.createDateObject(days[i], this.datepicker.formatDay, days[i].getMonth() !== month, this.datepicker.datepickerId + '-' + i);
|
|
1272
|
-
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();
|
|
1273
1409
|
}
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
this.labels[j] = {};
|
|
1277
|
-
this.labels[j].abbr =
|
|
1278
|
-
this.datepicker.dateFilter(pickerDates[j].date, this.datepicker.formatDayHeader);
|
|
1279
|
-
this.labels[j].full = this.datepicker.dateFilter(pickerDates[j].date, 'EEEE');
|
|
1410
|
+
else {
|
|
1411
|
+
this.openPicker();
|
|
1280
1412
|
}
|
|
1281
|
-
this.title =
|
|
1282
|
-
this.datepicker.dateFilter(this.datepicker.activeDate, this.datepicker.formatDayTitle);
|
|
1283
|
-
this.rows = this.datepicker.createCalendarRows(pickerDates, 7);
|
|
1284
1413
|
};
|
|
1285
|
-
|
|
1286
|
-
var
|
|
1414
|
+
SkyDatepickerComponent.prototype.onCalendarDateRangeChange = function (event) {
|
|
1415
|
+
var _this = this;
|
|
1287
1416
|
/* istanbul ignore else */
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
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
|
+
}
|
|
1306
1440
|
}
|
|
1307
|
-
else if (key === 'home') {
|
|
1308
|
-
date = 1;
|
|
1309
|
-
}
|
|
1310
|
-
else if (key === 'end') {
|
|
1311
|
-
date = this.getDaysInMonth(this.datepicker.activeDate.getFullYear(), this.datepicker.activeDate.getMonth());
|
|
1312
|
-
}
|
|
1313
|
-
this.datepicker.activeDate.setDate(date);
|
|
1314
1441
|
};
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1442
|
+
SkyDatepickerComponent.prototype.closePicker = function () {
|
|
1443
|
+
this.destroyAffixer();
|
|
1444
|
+
this.destroyOverlay();
|
|
1445
|
+
this.removePickerEventListeners();
|
|
1446
|
+
this.triggerButtonRef.nativeElement.focus();
|
|
1447
|
+
this.isOpen = false;
|
|
1318
1448
|
};
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
}());
|
|
1331
|
-
|
|
1332
|
-
/**
|
|
1333
|
-
* @internal
|
|
1334
|
-
*/
|
|
1335
|
-
var SkyMonthPickerComponent = /** @class */ (function () {
|
|
1336
|
-
function SkyMonthPickerComponent(datepicker) {
|
|
1337
|
-
this.rows = [];
|
|
1338
|
-
this.datepicker = datepicker;
|
|
1339
|
-
}
|
|
1340
|
-
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 () {
|
|
1341
1460
|
var _this = this;
|
|
1342
|
-
this.
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
this.
|
|
1351
|
-
|
|
1352
|
-
|
|
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;
|
|
1353
1477
|
};
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1478
|
+
SkyDatepickerComponent.prototype.destroyAffixer = function () {
|
|
1479
|
+
/*istanbul ignore else*/
|
|
1480
|
+
if (this.affixer) {
|
|
1481
|
+
this.affixer.destroy();
|
|
1482
|
+
this.affixer = undefined;
|
|
1483
|
+
}
|
|
1358
1484
|
};
|
|
1359
|
-
|
|
1360
|
-
var
|
|
1361
|
-
var
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
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;
|
|
1368
1508
|
}
|
|
1369
|
-
this.title =
|
|
1370
|
-
this.datepicker.dateFilter(this.datepicker.activeDate, this.datepicker.formatMonthTitle);
|
|
1371
|
-
this.rows = this.datepicker.createCalendarRows(months, this.datepicker.monthColLimit);
|
|
1372
1509
|
};
|
|
1373
|
-
|
|
1374
|
-
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;
|
|
1375
1524
|
/* istanbul ignore else */
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
else if (key === 'up') {
|
|
1381
|
-
date = date - this.datepicker.monthColLimit;
|
|
1382
|
-
}
|
|
1383
|
-
else if (key === 'right') {
|
|
1384
|
-
date = date + 1;
|
|
1385
|
-
}
|
|
1386
|
-
else if (key === 'down') {
|
|
1387
|
-
date = date + this.datepicker.monthColLimit;
|
|
1388
|
-
}
|
|
1389
|
-
else if (key === 'pageup' || key === 'pagedown') {
|
|
1390
|
-
var year = this.datepicker.activeDate.getFullYear() + (key === 'pageup' ? -1 : 1);
|
|
1391
|
-
this.datepicker.activeDate.setFullYear(year);
|
|
1392
|
-
}
|
|
1393
|
-
else if (key === 'home') {
|
|
1394
|
-
date = 0;
|
|
1525
|
+
if (this.calendarUnsubscribe) {
|
|
1526
|
+
this.calendarUnsubscribe.next();
|
|
1527
|
+
this.calendarUnsubscribe.complete();
|
|
1528
|
+
this.calendarUnsubscribe = undefined;
|
|
1395
1529
|
}
|
|
1396
|
-
|
|
1397
|
-
|
|
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;
|
|
1398
1536
|
}
|
|
1399
|
-
this.datepicker.activeDate.setMonth(date);
|
|
1400
1537
|
};
|
|
1401
|
-
|
|
1402
|
-
{ 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 }] }
|
|
1403
1545
|
]; };
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
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
|
|
1409
1558
|
})
|
|
1410
|
-
],
|
|
1411
|
-
|
|
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;
|
|
1412
1593
|
}());
|
|
1413
1594
|
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
function
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
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) {
|
|
1423
1610
|
var _this = this;
|
|
1424
|
-
this.
|
|
1425
|
-
this.datepicker.setRefreshViewHandler(function () {
|
|
1426
|
-
_this.refreshYearView();
|
|
1427
|
-
}, 'year');
|
|
1428
|
-
this.datepicker.setCompareHandler(this.compareYears, 'year');
|
|
1429
|
-
this.datepicker.setKeydownHandler(function (key, event) {
|
|
1430
|
-
_this.keydownYears(key, event);
|
|
1431
|
-
}, 'year');
|
|
1432
|
-
this.datepicker.refreshView();
|
|
1433
|
-
};
|
|
1434
|
-
SkyYearPickerComponent.prototype.getStartingYear = function (year) {
|
|
1435
|
-
return Math.floor((year - 1) / this.datepicker.yearRange) * this.datepicker.yearRange + 1;
|
|
1436
|
-
};
|
|
1437
|
-
SkyYearPickerComponent.prototype.compareYears = function (date1, date2) {
|
|
1438
|
-
return date1.getFullYear() - date2.getFullYear();
|
|
1439
|
-
};
|
|
1440
|
-
SkyYearPickerComponent.prototype.refreshYearView = function () {
|
|
1441
|
-
var years = new Array(this.datepicker.yearRange);
|
|
1442
|
-
var date;
|
|
1443
|
-
var start = this.getStartingYear(this.datepicker.activeDate.getFullYear());
|
|
1444
|
-
for (var i = 0; i < this.datepicker.yearRange; i++) {
|
|
1445
|
-
date = new Date(this.datepicker.activeDate);
|
|
1446
|
-
date.setFullYear(start + i, 0, 1);
|
|
1447
|
-
years[i] =
|
|
1448
|
-
this.datepicker.createDateObject(date, this.datepicker.formatYear, false, this.datepicker.datepickerId + '-' + i);
|
|
1449
|
-
}
|
|
1450
|
-
this.title = [years[0].label,
|
|
1451
|
-
years[this.datepicker.yearRange - 1].label].join(' - ');
|
|
1452
|
-
this.rows = this.datepicker.createCalendarRows(years, this.datepicker.yearColLimit);
|
|
1453
|
-
};
|
|
1454
|
-
SkyYearPickerComponent.prototype.keydownYears = function (key, event) {
|
|
1455
|
-
var date = this.datepicker.activeDate.getFullYear();
|
|
1456
|
-
/* istanbul ignore else */
|
|
1457
|
-
/* sanity check */
|
|
1458
|
-
if (key === 'left') {
|
|
1459
|
-
date = date - 1;
|
|
1460
|
-
}
|
|
1461
|
-
else if (key === 'up') {
|
|
1462
|
-
date = date - this.datepicker.yearColLimit;
|
|
1463
|
-
}
|
|
1464
|
-
else if (key === 'right') {
|
|
1465
|
-
date = date + 1;
|
|
1466
|
-
}
|
|
1467
|
-
else if (key === 'down') {
|
|
1468
|
-
date = date + this.datepicker.yearColLimit;
|
|
1469
|
-
}
|
|
1470
|
-
else if (key === 'pageup' || key === 'pagedown') {
|
|
1471
|
-
date += (key === 'pageup' ? -1 : 1) * this.datepicker.yearRange;
|
|
1472
|
-
}
|
|
1473
|
-
else if (key === 'home') {
|
|
1474
|
-
date = this.getStartingYear(this.datepicker.activeDate.getFullYear());
|
|
1475
|
-
}
|
|
1476
|
-
else if (key === 'end') {
|
|
1477
|
-
date
|
|
1478
|
-
= this.getStartingYear(this.datepicker.activeDate.getFullYear()) + this.datepicker.yearRange - 1;
|
|
1479
|
-
}
|
|
1480
|
-
this.datepicker.activeDate.setFullYear(date);
|
|
1481
|
-
};
|
|
1482
|
-
SkyYearPickerComponent.ctorParameters = function () { return [
|
|
1483
|
-
{ type: SkyDatepickerCalendarInnerComponent }
|
|
1484
|
-
]; };
|
|
1485
|
-
SkyYearPickerComponent = __decorate([
|
|
1486
|
-
Component({
|
|
1487
|
-
selector: 'sky-yearpicker',
|
|
1488
|
-
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",
|
|
1489
|
-
styles: [":host-context(.sky-theme-modern) :host:focus{outline:0}.sky-theme-modern :host:focus{outline:0}"]
|
|
1490
|
-
})
|
|
1491
|
-
], SkyYearPickerComponent);
|
|
1492
|
-
return SkyYearPickerComponent;
|
|
1493
|
-
}());
|
|
1494
|
-
|
|
1495
|
-
var nextId = 0;
|
|
1496
|
-
/**
|
|
1497
|
-
* Creates the datepicker button and calendar.
|
|
1498
|
-
* You must wrap this component around an input with the `skyDatepickerInput` directive.
|
|
1499
|
-
*/
|
|
1500
|
-
var SkyDatepickerComponent = /** @class */ (function () {
|
|
1501
|
-
function SkyDatepickerComponent(affixService, changeDetector, coreAdapter, overlayService, inputBoxHostService, themeSvc) {
|
|
1502
|
-
var _this = this;
|
|
1503
|
-
this.affixService = affixService;
|
|
1611
|
+
this.adapter = adapter;
|
|
1504
1612
|
this.changeDetector = changeDetector;
|
|
1505
|
-
this.
|
|
1506
|
-
this.
|
|
1507
|
-
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;
|
|
1508
1619
|
/**
|
|
1509
|
-
*
|
|
1620
|
+
* Indicates whether to disable date validation on the datepicker input.
|
|
1621
|
+
* @default false
|
|
1510
1622
|
*/
|
|
1511
|
-
this.
|
|
1512
|
-
this.
|
|
1513
|
-
this.
|
|
1514
|
-
this.isVisible = false;
|
|
1623
|
+
this.skyDatepickerNoValidate = false;
|
|
1624
|
+
this.dateFormatter = new SkyDateFormatter();
|
|
1625
|
+
this.isFirstChange = true;
|
|
1515
1626
|
this.ngUnsubscribe = new Subject();
|
|
1516
|
-
this.
|
|
1517
|
-
|
|
1518
|
-
this.
|
|
1519
|
-
this.
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
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();
|
|
1523
1639
|
});
|
|
1524
1640
|
}
|
|
1525
|
-
Object.defineProperty(
|
|
1641
|
+
Object.defineProperty(SkyDatepickerInputDirective.prototype, "dateFormat", {
|
|
1642
|
+
get: function () {
|
|
1643
|
+
return this._dateFormat ||
|
|
1644
|
+
this.configService.dateFormat ||
|
|
1645
|
+
this.preferredShortDateFormat;
|
|
1646
|
+
},
|
|
1526
1647
|
/**
|
|
1527
|
-
*
|
|
1528
|
-
*
|
|
1529
|
-
* @
|
|
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
|
|
1530
1651
|
*/
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
return false;
|
|
1652
|
+
set: function (value) {
|
|
1653
|
+
if (value !== this._dateFormat) {
|
|
1654
|
+
this._dateFormat = value;
|
|
1655
|
+
this.applyDateFormat();
|
|
1536
1656
|
}
|
|
1537
|
-
var activeEl = document.activeElement;
|
|
1538
|
-
return this.triggerButtonRef.nativeElement === activeEl;
|
|
1539
1657
|
},
|
|
1540
1658
|
enumerable: true,
|
|
1541
1659
|
configurable: true
|
|
1542
1660
|
});
|
|
1543
|
-
Object.defineProperty(
|
|
1661
|
+
Object.defineProperty(SkyDatepickerInputDirective.prototype, "disabled", {
|
|
1662
|
+
get: function () {
|
|
1663
|
+
return this._disabled || false;
|
|
1664
|
+
},
|
|
1544
1665
|
/**
|
|
1545
|
-
*
|
|
1546
|
-
*
|
|
1547
|
-
* @deprecated This property will be removed in the next major version release.
|
|
1666
|
+
* Indicates whether to disable the datepicker.
|
|
1667
|
+
* @default false
|
|
1548
1668
|
*/
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
var focusedEl = document.activeElement;
|
|
1554
|
-
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);
|
|
1555
1673
|
},
|
|
1556
1674
|
enumerable: true,
|
|
1557
1675
|
configurable: true
|
|
1558
1676
|
});
|
|
1559
|
-
Object.defineProperty(
|
|
1677
|
+
Object.defineProperty(SkyDatepickerInputDirective.prototype, "inputIsFocused", {
|
|
1560
1678
|
/**
|
|
1561
1679
|
* @internal
|
|
1562
|
-
* Indicates if the
|
|
1563
|
-
* @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.
|
|
1564
1681
|
*/
|
|
1565
1682
|
get: function () {
|
|
1566
|
-
return this.
|
|
1683
|
+
return this.adapter.elementIsFocused();
|
|
1567
1684
|
},
|
|
1568
1685
|
enumerable: true,
|
|
1569
1686
|
configurable: true
|
|
1570
1687
|
});
|
|
1571
|
-
Object.defineProperty(
|
|
1688
|
+
Object.defineProperty(SkyDatepickerInputDirective.prototype, "maxDate", {
|
|
1572
1689
|
get: function () {
|
|
1573
|
-
return this.
|
|
1690
|
+
return this._maxDate || this.configService.maxDate;
|
|
1574
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
|
+
*/
|
|
1575
1696
|
set: function (value) {
|
|
1576
|
-
this.
|
|
1577
|
-
this.
|
|
1697
|
+
this._maxDate = value;
|
|
1698
|
+
this.datepickerComponent.maxDate = this.maxDate;
|
|
1699
|
+
this.onValidatorChange();
|
|
1578
1700
|
},
|
|
1579
1701
|
enumerable: true,
|
|
1580
1702
|
configurable: true
|
|
1581
1703
|
});
|
|
1582
|
-
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
|
+
*/
|
|
1583
1712
|
set: function (value) {
|
|
1584
|
-
this.
|
|
1585
|
-
|
|
1586
|
-
|
|
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>');
|
|
1587
1734
|
}
|
|
1588
1735
|
},
|
|
1589
1736
|
enumerable: true,
|
|
1590
1737
|
configurable: true
|
|
1591
1738
|
});
|
|
1592
|
-
Object.defineProperty(
|
|
1739
|
+
Object.defineProperty(SkyDatepickerInputDirective.prototype, "startingDay", {
|
|
1593
1740
|
get: function () {
|
|
1594
|
-
return this.
|
|
1741
|
+
return this._startingDay || this.configService.startingDay;
|
|
1595
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
|
+
*/
|
|
1596
1749
|
set: function (value) {
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
// Wait for the calendar component to render before gauging dimensions.
|
|
1601
|
-
setTimeout(function () {
|
|
1602
|
-
_this.calendar.writeValue(_this._selectedDate);
|
|
1603
|
-
_this.destroyAffixer();
|
|
1604
|
-
_this.createAffixer();
|
|
1605
|
-
setTimeout(function () {
|
|
1606
|
-
_this.coreAdapter.getFocusableChildrenAndApplyFocus(_this.calendarRef, '.sky-datepicker-calendar-inner', false);
|
|
1607
|
-
_this.isVisible = true;
|
|
1608
|
-
_this.changeDetector.markForCheck();
|
|
1609
|
-
});
|
|
1610
|
-
});
|
|
1611
|
-
}
|
|
1750
|
+
this._startingDay = value;
|
|
1751
|
+
this.datepickerComponent.startingDay = this.startingDay;
|
|
1752
|
+
this.onValidatorChange();
|
|
1612
1753
|
},
|
|
1613
1754
|
enumerable: true,
|
|
1614
1755
|
configurable: true
|
|
1615
1756
|
});
|
|
1616
|
-
|
|
1617
|
-
if (this.inputBoxHostService) {
|
|
1618
|
-
this.inputBoxHostService.populate({
|
|
1619
|
-
inputTemplate: this.inputTemplateRef,
|
|
1620
|
-
buttonsTemplate: this.triggerButtonTemplateRef
|
|
1621
|
-
});
|
|
1622
|
-
}
|
|
1623
|
-
};
|
|
1624
|
-
SkyDatepickerComponent.prototype.ngOnDestroy = function () {
|
|
1625
|
-
this.dateChange.complete();
|
|
1626
|
-
this.ngUnsubscribe.next();
|
|
1627
|
-
this.ngUnsubscribe.complete();
|
|
1628
|
-
this.removePickerEventListeners();
|
|
1629
|
-
this.destroyAffixer();
|
|
1630
|
-
this.destroyOverlay();
|
|
1631
|
-
};
|
|
1632
|
-
SkyDatepickerComponent.prototype.onCalendarModeChange = function () {
|
|
1633
|
-
var _this = this;
|
|
1634
|
-
// Let the calendar populate in the DOM before recalculating placement.
|
|
1635
|
-
setTimeout(function () {
|
|
1636
|
-
_this.affixer.reaffix();
|
|
1637
|
-
});
|
|
1638
|
-
};
|
|
1639
|
-
SkyDatepickerComponent.prototype.onSelectedDateChange = function (value) {
|
|
1640
|
-
this.dateChange.emit(value);
|
|
1641
|
-
this.closePicker();
|
|
1642
|
-
};
|
|
1643
|
-
SkyDatepickerComponent.prototype.onTriggerButtonClick = function () {
|
|
1644
|
-
if (this.isOpen) {
|
|
1645
|
-
this.closePicker();
|
|
1646
|
-
}
|
|
1647
|
-
else {
|
|
1648
|
-
this.openPicker();
|
|
1649
|
-
}
|
|
1650
|
-
};
|
|
1651
|
-
SkyDatepickerComponent.prototype.closePicker = function () {
|
|
1652
|
-
this.destroyAffixer();
|
|
1653
|
-
this.destroyOverlay();
|
|
1654
|
-
this.removePickerEventListeners();
|
|
1655
|
-
this.triggerButtonRef.nativeElement.focus();
|
|
1656
|
-
this.isOpen = false;
|
|
1657
|
-
};
|
|
1658
|
-
SkyDatepickerComponent.prototype.openPicker = function () {
|
|
1659
|
-
this.isVisible = false;
|
|
1660
|
-
this.changeDetector.markForCheck();
|
|
1661
|
-
this.removePickerEventListeners();
|
|
1662
|
-
this.calendarUnsubscribe = new Subject();
|
|
1663
|
-
this.destroyOverlay();
|
|
1664
|
-
this.createOverlay();
|
|
1665
|
-
this.isOpen = true;
|
|
1666
|
-
this.changeDetector.markForCheck();
|
|
1667
|
-
};
|
|
1668
|
-
SkyDatepickerComponent.prototype.createAffixer = function () {
|
|
1669
|
-
var _this = this;
|
|
1670
|
-
var affixer = this.affixService.createAffixer(this.calendarRef);
|
|
1671
|
-
// Hide calendar when trigger button is scrolled off screen.
|
|
1672
|
-
affixer.placementChange
|
|
1673
|
-
.pipe(takeUntil(this.calendarUnsubscribe))
|
|
1674
|
-
.subscribe(function (change) {
|
|
1675
|
-
_this.isVisible = (change.placement !== null);
|
|
1676
|
-
_this.changeDetector.markForCheck();
|
|
1677
|
-
});
|
|
1678
|
-
affixer.affixTo(this.triggerButtonRef.nativeElement, {
|
|
1679
|
-
autoFitContext: SkyAffixAutoFitContext.Viewport,
|
|
1680
|
-
enableAutoFit: true,
|
|
1681
|
-
horizontalAlignment: 'right',
|
|
1682
|
-
isSticky: true,
|
|
1683
|
-
placement: 'below'
|
|
1684
|
-
});
|
|
1685
|
-
this.affixer = affixer;
|
|
1686
|
-
};
|
|
1687
|
-
SkyDatepickerComponent.prototype.destroyAffixer = function () {
|
|
1688
|
-
/*istanbul ignore else*/
|
|
1689
|
-
if (this.affixer) {
|
|
1690
|
-
this.affixer.destroy();
|
|
1691
|
-
this.affixer = undefined;
|
|
1692
|
-
}
|
|
1693
|
-
};
|
|
1694
|
-
SkyDatepickerComponent.prototype.createOverlay = function () {
|
|
1695
|
-
var _this = this;
|
|
1696
|
-
var overlay = this.overlayService.create({
|
|
1697
|
-
wrapperClass: this.pickerClass,
|
|
1698
|
-
enableClose: false,
|
|
1699
|
-
enablePointerEvents: false
|
|
1700
|
-
});
|
|
1701
|
-
overlay.backdropClick
|
|
1702
|
-
.pipe(takeUntil(this.calendarUnsubscribe))
|
|
1703
|
-
.subscribe(function () {
|
|
1704
|
-
if (_this.isOpen) {
|
|
1705
|
-
_this.closePicker();
|
|
1706
|
-
}
|
|
1707
|
-
});
|
|
1708
|
-
this.addKeydownListner();
|
|
1709
|
-
overlay.attachTemplate(this.calendarTemplateRef);
|
|
1710
|
-
this.overlay = overlay;
|
|
1711
|
-
};
|
|
1712
|
-
SkyDatepickerComponent.prototype.destroyOverlay = function () {
|
|
1713
|
-
/*istanbul ignore else*/
|
|
1714
|
-
if (this.overlay) {
|
|
1715
|
-
this.overlayService.close(this.overlay);
|
|
1716
|
-
this.overlay = undefined;
|
|
1717
|
-
}
|
|
1718
|
-
};
|
|
1719
|
-
SkyDatepickerComponent.prototype.addKeydownListner = function () {
|
|
1720
|
-
var _this = this;
|
|
1721
|
-
this.overlayKeydownListner = fromEvent(window.document, 'keydown')
|
|
1722
|
-
.pipe(takeUntil(this.ngUnsubscribe))
|
|
1723
|
-
.subscribe(function (event) {
|
|
1724
|
-
var _a;
|
|
1725
|
-
var key = (_a = event.key) === null || _a === void 0 ? void 0 : _a.toLowerCase();
|
|
1726
|
-
if (key === 'escape' && _this.isOpen) {
|
|
1727
|
-
_this.closePicker();
|
|
1728
|
-
}
|
|
1729
|
-
});
|
|
1730
|
-
};
|
|
1731
|
-
SkyDatepickerComponent.prototype.removePickerEventListeners = function () {
|
|
1732
|
-
var _a;
|
|
1733
|
-
/* istanbul ignore else */
|
|
1734
|
-
if (this.calendarUnsubscribe) {
|
|
1735
|
-
this.calendarUnsubscribe.next();
|
|
1736
|
-
this.calendarUnsubscribe.complete();
|
|
1737
|
-
this.calendarUnsubscribe = undefined;
|
|
1738
|
-
}
|
|
1739
|
-
(_a = this.overlayKeydownListner) === null || _a === void 0 ? void 0 : _a.unsubscribe();
|
|
1740
|
-
};
|
|
1741
|
-
SkyDatepickerComponent.ctorParameters = function () { return [
|
|
1742
|
-
{ type: SkyAffixService },
|
|
1743
|
-
{ type: ChangeDetectorRef },
|
|
1744
|
-
{ type: SkyCoreAdapterService },
|
|
1745
|
-
{ type: SkyOverlayService },
|
|
1746
|
-
{ type: SkyInputBoxHostService, decorators: [{ type: Optional }] },
|
|
1747
|
-
{ type: SkyThemeService, decorators: [{ type: Optional }] }
|
|
1748
|
-
]; };
|
|
1749
|
-
__decorate([
|
|
1750
|
-
Input()
|
|
1751
|
-
], SkyDatepickerComponent.prototype, "pickerClass", void 0);
|
|
1752
|
-
__decorate([
|
|
1753
|
-
ViewChild(SkyDatepickerCalendarComponent)
|
|
1754
|
-
], SkyDatepickerComponent.prototype, "calendar", void 0);
|
|
1755
|
-
__decorate([
|
|
1756
|
-
ViewChild('calendarRef', {
|
|
1757
|
-
read: ElementRef
|
|
1758
|
-
})
|
|
1759
|
-
], SkyDatepickerComponent.prototype, "calendarRef", null);
|
|
1760
|
-
__decorate([
|
|
1761
|
-
ViewChild('calendarTemplateRef', {
|
|
1762
|
-
read: TemplateRef
|
|
1763
|
-
})
|
|
1764
|
-
], SkyDatepickerComponent.prototype, "calendarTemplateRef", void 0);
|
|
1765
|
-
__decorate([
|
|
1766
|
-
ViewChild('triggerButtonRef', {
|
|
1767
|
-
read: ElementRef
|
|
1768
|
-
})
|
|
1769
|
-
], SkyDatepickerComponent.prototype, "triggerButtonRef", void 0);
|
|
1770
|
-
__decorate([
|
|
1771
|
-
ViewChild('inputTemplateRef', {
|
|
1772
|
-
read: TemplateRef,
|
|
1773
|
-
static: true
|
|
1774
|
-
})
|
|
1775
|
-
], SkyDatepickerComponent.prototype, "inputTemplateRef", void 0);
|
|
1776
|
-
__decorate([
|
|
1777
|
-
ViewChild('triggerButtonTemplateRef', {
|
|
1778
|
-
read: TemplateRef,
|
|
1779
|
-
static: true
|
|
1780
|
-
})
|
|
1781
|
-
], SkyDatepickerComponent.prototype, "triggerButtonTemplateRef", void 0);
|
|
1782
|
-
SkyDatepickerComponent = __decorate([
|
|
1783
|
-
Component({
|
|
1784
|
-
selector: 'sky-datepicker',
|
|
1785
|
-
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",
|
|
1786
|
-
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
1787
|
-
styles: [".sky-datepicker-calendar-container{position:fixed;border-radius:5px}.sky-datepicker-hidden{visibility:hidden}"]
|
|
1788
|
-
}),
|
|
1789
|
-
__param(4, Optional()),
|
|
1790
|
-
__param(5, Optional())
|
|
1791
|
-
], SkyDatepickerComponent);
|
|
1792
|
-
return SkyDatepickerComponent;
|
|
1793
|
-
}());
|
|
1794
|
-
|
|
1795
|
-
var moment$3 = moment_;
|
|
1796
|
-
// tslint:disable:no-forward-ref no-use-before-declare
|
|
1797
|
-
var SKY_DATEPICKER_VALUE_ACCESSOR = {
|
|
1798
|
-
provide: NG_VALUE_ACCESSOR,
|
|
1799
|
-
useExisting: forwardRef(function () { return SkyDatepickerInputDirective; }),
|
|
1800
|
-
multi: true
|
|
1801
|
-
};
|
|
1802
|
-
var SKY_DATEPICKER_VALIDATOR = {
|
|
1803
|
-
provide: NG_VALIDATORS,
|
|
1804
|
-
useExisting: forwardRef(function () { return SkyDatepickerInputDirective; }),
|
|
1805
|
-
multi: true
|
|
1806
|
-
};
|
|
1807
|
-
// tslint:enable
|
|
1808
|
-
var SkyDatepickerInputDirective = /** @class */ (function () {
|
|
1809
|
-
function SkyDatepickerInputDirective(adapter, changeDetector, configService, elementRef, localeProvider, renderer, resourcesService, datepickerComponent) {
|
|
1810
|
-
var _this = this;
|
|
1811
|
-
this.adapter = adapter;
|
|
1812
|
-
this.changeDetector = changeDetector;
|
|
1813
|
-
this.configService = configService;
|
|
1814
|
-
this.elementRef = elementRef;
|
|
1815
|
-
this.localeProvider = localeProvider;
|
|
1816
|
-
this.renderer = renderer;
|
|
1817
|
-
this.resourcesService = resourcesService;
|
|
1818
|
-
this.datepickerComponent = datepickerComponent;
|
|
1819
|
-
/**
|
|
1820
|
-
* Indicates whether to disable date validation on the datepicker input.
|
|
1821
|
-
* @default false
|
|
1822
|
-
*/
|
|
1823
|
-
this.skyDatepickerNoValidate = false;
|
|
1824
|
-
this.dateFormatter = new SkyDateFormatter();
|
|
1825
|
-
this.isFirstChange = true;
|
|
1826
|
-
this.ngUnsubscribe = new Subject();
|
|
1827
|
-
this.onChange = function (_) { };
|
|
1828
|
-
/*istanbul ignore next */
|
|
1829
|
-
this.onTouched = function () { };
|
|
1830
|
-
this.onValidatorChange = function () { };
|
|
1831
|
-
this.initialPlaceholder = this.adapter.getPlaceholder(this.elementRef);
|
|
1832
|
-
this.updatePlaceholder();
|
|
1833
|
-
this.localeProvider.getLocaleInfo()
|
|
1834
|
-
.pipe(takeUntil(this.ngUnsubscribe))
|
|
1835
|
-
.subscribe(function (localeInfo) {
|
|
1836
|
-
SkyDateFormatter.setLocale(localeInfo.locale);
|
|
1837
|
-
_this.preferredShortDateFormat = SkyDateFormatter.getPreferredShortDateFormat();
|
|
1838
|
-
_this.applyDateFormat();
|
|
1839
|
-
});
|
|
1840
|
-
}
|
|
1841
|
-
Object.defineProperty(SkyDatepickerInputDirective.prototype, "dateFormat", {
|
|
1757
|
+
Object.defineProperty(SkyDatepickerInputDirective.prototype, "strict", {
|
|
1842
1758
|
get: function () {
|
|
1843
|
-
return this.
|
|
1844
|
-
this.configService.dateFormat ||
|
|
1845
|
-
this.preferredShortDateFormat;
|
|
1759
|
+
return this._strict || false;
|
|
1846
1760
|
},
|
|
1847
1761
|
/**
|
|
1848
|
-
*
|
|
1849
|
-
*
|
|
1850
|
-
*
|
|
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
|
|
1851
1768
|
*/
|
|
1852
1769
|
set: function (value) {
|
|
1853
|
-
|
|
1854
|
-
this._dateFormat = value;
|
|
1855
|
-
this.applyDateFormat();
|
|
1856
|
-
}
|
|
1770
|
+
this._strict = value;
|
|
1857
1771
|
},
|
|
1858
1772
|
enumerable: true,
|
|
1859
1773
|
configurable: true
|
|
1860
1774
|
});
|
|
1861
|
-
Object.defineProperty(SkyDatepickerInputDirective.prototype, "
|
|
1775
|
+
Object.defineProperty(SkyDatepickerInputDirective.prototype, "value", {
|
|
1862
1776
|
get: function () {
|
|
1863
|
-
return this.
|
|
1777
|
+
return this._value;
|
|
1864
1778
|
},
|
|
1865
|
-
/**
|
|
1866
|
-
* Indicates whether to disable the datepicker.
|
|
1867
|
-
* @default false
|
|
1868
|
-
*/
|
|
1869
1779
|
set: function (value) {
|
|
1870
|
-
|
|
1871
|
-
this.
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
/**
|
|
1893
|
-
* Specifies the latest date that is available in the calendar. Place this attribute on
|
|
1894
|
-
* the `input` element to override the default in `SkyDatepickerConfigService`.
|
|
1895
|
-
*/
|
|
1896
|
-
set: function (value) {
|
|
1897
|
-
this._maxDate = value;
|
|
1898
|
-
this.datepickerComponent.maxDate = this.maxDate;
|
|
1899
|
-
this.onValidatorChange();
|
|
1900
|
-
},
|
|
1901
|
-
enumerable: true,
|
|
1902
|
-
configurable: true
|
|
1903
|
-
});
|
|
1904
|
-
Object.defineProperty(SkyDatepickerInputDirective.prototype, "minDate", {
|
|
1905
|
-
get: function () {
|
|
1906
|
-
return this._minDate || this.configService.minDate;
|
|
1907
|
-
},
|
|
1908
|
-
/**
|
|
1909
|
-
* Specifies the earliest date that is available in the calendar. Place this attribute on
|
|
1910
|
-
* the `input` element to override the default in `SkyDatepickerConfigService`.
|
|
1911
|
-
*/
|
|
1912
|
-
set: function (value) {
|
|
1913
|
-
this._minDate = value;
|
|
1914
|
-
this.datepickerComponent.minDate = this.minDate;
|
|
1915
|
-
this.onValidatorChange();
|
|
1916
|
-
},
|
|
1917
|
-
enumerable: true,
|
|
1918
|
-
configurable: true
|
|
1919
|
-
});
|
|
1920
|
-
Object.defineProperty(SkyDatepickerInputDirective.prototype, "skyDatepickerInput", {
|
|
1921
|
-
/**
|
|
1922
|
-
* Creates the datepicker input and calendar. Place this directive on an `input` element,
|
|
1923
|
-
* and wrap the input in a `sky-datepicker` component. The value that users select is driven
|
|
1924
|
-
* through the `ngModel` attribute specified on the `input` element.
|
|
1925
|
-
* @required
|
|
1926
|
-
*/
|
|
1927
|
-
set: function (value) {
|
|
1928
|
-
if (value) {
|
|
1929
|
-
console.warn('[Deprecation warning] You no longer need to provide a template reference variable ' +
|
|
1930
|
-
'to the `skyDatepickerInput` attribute (this will be a breaking change in the next ' +
|
|
1931
|
-
'major version release).\n' +
|
|
1932
|
-
'Do this instead:\n' +
|
|
1933
|
-
'<sky-datepicker>\n <input skyDatepickerInput />\n</sky-datepicker>');
|
|
1934
|
-
}
|
|
1935
|
-
},
|
|
1936
|
-
enumerable: true,
|
|
1937
|
-
configurable: true
|
|
1938
|
-
});
|
|
1939
|
-
Object.defineProperty(SkyDatepickerInputDirective.prototype, "startingDay", {
|
|
1940
|
-
get: function () {
|
|
1941
|
-
return this._startingDay || this.configService.startingDay;
|
|
1942
|
-
},
|
|
1943
|
-
/**
|
|
1944
|
-
* Specifies the starting day of the week in the calendar, where `0` sets the starting day
|
|
1945
|
-
* to Sunday. Place this attribute on the `input` element to override the default
|
|
1946
|
-
* in `SkyDatepickerConfigService`.
|
|
1947
|
-
* @default 0
|
|
1948
|
-
*/
|
|
1949
|
-
set: function (value) {
|
|
1950
|
-
this._startingDay = value;
|
|
1951
|
-
this.datepickerComponent.startingDay = this.startingDay;
|
|
1952
|
-
this.onValidatorChange();
|
|
1953
|
-
},
|
|
1954
|
-
enumerable: true,
|
|
1955
|
-
configurable: true
|
|
1956
|
-
});
|
|
1957
|
-
Object.defineProperty(SkyDatepickerInputDirective.prototype, "strict", {
|
|
1958
|
-
get: function () {
|
|
1959
|
-
return this._strict || false;
|
|
1960
|
-
},
|
|
1961
|
-
/**
|
|
1962
|
-
* Indicates whether the format of the date value must match the format from the `dateFormat` value.
|
|
1963
|
-
* If this property is `true` and the datepicker input directive cannot find an exact match, then
|
|
1964
|
-
* the input is marked as invalid.
|
|
1965
|
-
* If this property is `false` and the datepicker input directive cannot find an exact match, then
|
|
1966
|
-
* it attempts to format the string based on the [ISO 8601 standard format](https://www.iso.org/iso-8601-date-and-time-format.html).
|
|
1967
|
-
* @default false
|
|
1968
|
-
*/
|
|
1969
|
-
set: function (value) {
|
|
1970
|
-
this._strict = value;
|
|
1971
|
-
},
|
|
1972
|
-
enumerable: true,
|
|
1973
|
-
configurable: true
|
|
1974
|
-
});
|
|
1975
|
-
Object.defineProperty(SkyDatepickerInputDirective.prototype, "value", {
|
|
1976
|
-
get: function () {
|
|
1977
|
-
return this._value;
|
|
1978
|
-
},
|
|
1979
|
-
set: function (value) {
|
|
1980
|
-
var dateValue = this.getDateValue(value);
|
|
1981
|
-
var areDatesEqual = (this._value instanceof Date &&
|
|
1982
|
-
dateValue &&
|
|
1983
|
-
dateValue.getTime() === this._value.getTime());
|
|
1984
|
-
var isValidDateString = this.isDateStringValid(value);
|
|
1985
|
-
// If the string value supplied is malformed, do not set the value to its Date equivalent.
|
|
1986
|
-
// (JavaScript's Date parser will convert poorly formatted dates to Date objects, such as "abc 123", which isn't ideal.)
|
|
1987
|
-
if (!isValidDateString) {
|
|
1988
|
-
this._value = value;
|
|
1989
|
-
this.notifyUpdatedValue();
|
|
1990
|
-
}
|
|
1991
|
-
else if (dateValue !== this._value || !areDatesEqual) {
|
|
1992
|
-
this._value = (dateValue || value);
|
|
1993
|
-
this.notifyUpdatedValue();
|
|
1994
|
-
}
|
|
1995
|
-
if (dateValue && isValidDateString) {
|
|
1996
|
-
var formattedDate = this.dateFormatter.format(dateValue, this.dateFormat);
|
|
1997
|
-
this.setInputElementValue(formattedDate);
|
|
1998
|
-
}
|
|
1999
|
-
else {
|
|
2000
|
-
this.setInputElementValue(value || '');
|
|
2001
|
-
}
|
|
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
|
+
}
|
|
2002
1802
|
},
|
|
2003
1803
|
enumerable: true,
|
|
2004
1804
|
configurable: true
|
|
@@ -2495,267 +2295,811 @@ var SkyFuzzyDatepickerInputDirective = /** @class */ (function () {
|
|
|
2495
2295
|
}
|
|
2496
2296
|
this.datepickerComponent.selectedDate = dateValue;
|
|
2497
2297
|
}
|
|
2498
|
-
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
|
+
}
|
|
2499
2748
|
},
|
|
2500
2749
|
enumerable: true,
|
|
2501
2750
|
configurable: true
|
|
2502
2751
|
});
|
|
2503
|
-
|
|
2752
|
+
SkyDayPickerComponent.prototype.ngOnInit = function () {
|
|
2504
2753
|
var _this = this;
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
|
|
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);
|
|
2509
2779
|
}
|
|
2510
|
-
|
|
2511
|
-
|
|
2512
|
-
|
|
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;
|
|
2513
2798
|
}
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
|
|
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
|
|
2522
2827
|
});
|
|
2523
2828
|
}
|
|
2524
2829
|
};
|
|
2525
|
-
|
|
2526
|
-
var
|
|
2527
|
-
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
|
|
2533
|
-
|
|
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);
|
|
2534
2859
|
};
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
|
|
2540
|
-
|
|
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;
|
|
2541
2871
|
/* istanbul ignore else */
|
|
2542
|
-
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
|
|
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
|
+
}
|
|
2547
2897
|
});
|
|
2548
|
-
_this.changeDetector.markForCheck();
|
|
2549
2898
|
});
|
|
2550
2899
|
}
|
|
2551
2900
|
};
|
|
2552
|
-
|
|
2553
|
-
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
|
|
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;
|
|
2558
2911
|
};
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
|
|
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
|
+
};
|
|
2564
2918
|
}
|
|
2565
2919
|
};
|
|
2566
|
-
|
|
2567
|
-
|
|
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');
|
|
2568
2963
|
};
|
|
2569
|
-
|
|
2570
|
-
|
|
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();
|
|
2571
2968
|
};
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
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);
|
|
2581
2978
|
}
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
|
|
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;
|
|
2587
2989
|
}
|
|
2588
|
-
else {
|
|
2589
|
-
|
|
2990
|
+
else if (key === 'up') {
|
|
2991
|
+
date = date - this.datepicker.monthColLimit;
|
|
2590
2992
|
}
|
|
2591
|
-
if (
|
|
2592
|
-
|
|
2593
|
-
'skyFuzzyDate': {
|
|
2594
|
-
invalid: value
|
|
2595
|
-
}
|
|
2596
|
-
};
|
|
2993
|
+
else if (key === 'right') {
|
|
2994
|
+
date = date + 1;
|
|
2597
2995
|
}
|
|
2598
|
-
if (
|
|
2599
|
-
|
|
2600
|
-
'skyFuzzyDate': {
|
|
2601
|
-
yearRequired: value
|
|
2602
|
-
}
|
|
2603
|
-
};
|
|
2996
|
+
else if (key === 'down') {
|
|
2997
|
+
date = date + this.datepicker.monthColLimit;
|
|
2604
2998
|
}
|
|
2605
|
-
if (
|
|
2606
|
-
var
|
|
2607
|
-
|
|
2608
|
-
fuzzyDateRange = this.fuzzyDateService.getFuzzyDateRange(fuzzyDate, this.maxDate);
|
|
2609
|
-
if (!fuzzyDateRange.valid) {
|
|
2610
|
-
validationError = {
|
|
2611
|
-
'skyFuzzyDate': {
|
|
2612
|
-
maxDate: value
|
|
2613
|
-
}
|
|
2614
|
-
};
|
|
2615
|
-
}
|
|
2616
|
-
}
|
|
2617
|
-
if (!validationError && this.minDate) {
|
|
2618
|
-
fuzzyDateRange = this.fuzzyDateService.getFuzzyDateRange(this.minDate, fuzzyDate);
|
|
2619
|
-
if (!fuzzyDateRange.valid) {
|
|
2620
|
-
validationError = {
|
|
2621
|
-
'skyFuzzyDate': {
|
|
2622
|
-
minDate: value
|
|
2623
|
-
}
|
|
2624
|
-
};
|
|
2625
|
-
}
|
|
2626
|
-
}
|
|
2627
|
-
if (!validationError && this.futureDisabled) {
|
|
2628
|
-
fuzzyDateRange = this.fuzzyDateService.getFuzzyDateRange(fuzzyDate, this.fuzzyDateService.getCurrentFuzzyDate());
|
|
2629
|
-
if (!fuzzyDateRange.valid) {
|
|
2630
|
-
validationError = {
|
|
2631
|
-
'skyFuzzyDate': {
|
|
2632
|
-
futureDisabled: value
|
|
2633
|
-
}
|
|
2634
|
-
};
|
|
2635
|
-
}
|
|
2636
|
-
}
|
|
2999
|
+
else if (key === 'pageup' || key === 'pagedown') {
|
|
3000
|
+
var year = this.datepicker.activeDate.getFullYear() + (key === 'pageup' ? -1 : 1);
|
|
3001
|
+
this.datepicker.activeDate.setFullYear(year);
|
|
2637
3002
|
}
|
|
2638
|
-
if (
|
|
2639
|
-
|
|
2640
|
-
// (This is only required when the invalid value is set by the FormControl constructor.)
|
|
2641
|
-
this.control.markAsTouched();
|
|
3003
|
+
else if (key === 'home') {
|
|
3004
|
+
date = 0;
|
|
2642
3005
|
}
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
this.
|
|
2647
|
-
};
|
|
2648
|
-
SkyFuzzyDatepickerInputDirective.prototype.registerOnTouched = function (fn) {
|
|
2649
|
-
this.onTouched = fn;
|
|
2650
|
-
};
|
|
2651
|
-
SkyFuzzyDatepickerInputDirective.prototype.registerOnValidatorChange = function (fn) {
|
|
2652
|
-
this.onValidatorChange = fn;
|
|
3006
|
+
else if (key === 'end') {
|
|
3007
|
+
date = 11;
|
|
3008
|
+
}
|
|
3009
|
+
this.datepicker.activeDate.setMonth(date);
|
|
2653
3010
|
};
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
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();
|
|
2657
3043
|
};
|
|
2658
|
-
|
|
2659
|
-
|
|
2660
|
-
* This is useful if you need to update the ngModel value before the input element loses focus.
|
|
2661
|
-
*/
|
|
2662
|
-
SkyFuzzyDatepickerInputDirective.prototype.detectInputValueChange = function () {
|
|
2663
|
-
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;
|
|
2664
3046
|
};
|
|
2665
|
-
|
|
2666
|
-
|
|
2667
|
-
this.value = newValue;
|
|
3047
|
+
SkyYearPickerComponent.prototype.compareYears = function (date1, date2) {
|
|
3048
|
+
return date1.getFullYear() - date2.getFullYear();
|
|
2668
3049
|
};
|
|
2669
|
-
|
|
2670
|
-
|
|
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);
|
|
2671
3063
|
};
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
|
|
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;
|
|
2678
3070
|
}
|
|
2679
|
-
else if (
|
|
2680
|
-
|
|
3071
|
+
else if (key === 'up') {
|
|
3072
|
+
date = date - this.datepicker.yearColLimit;
|
|
2681
3073
|
}
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
SkyFuzzyDatepickerInputDirective.prototype.getMinDate = function () {
|
|
2685
|
-
if (this.minDate) {
|
|
2686
|
-
var minDate = this.fuzzyDateService.getMomentFromFuzzyDate(this.minDate);
|
|
2687
|
-
if (minDate.isValid()) {
|
|
2688
|
-
return minDate.toDate();
|
|
2689
|
-
}
|
|
3074
|
+
else if (key === 'right') {
|
|
3075
|
+
date = date + 1;
|
|
2690
3076
|
}
|
|
2691
|
-
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
|
|
2697
|
-
|
|
2698
|
-
|
|
2699
|
-
|
|
2700
|
-
|
|
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);
|
|
2701
3091
|
};
|
|
2702
|
-
|
|
2703
|
-
{ type:
|
|
2704
|
-
{ type: SkyDatepickerConfigService },
|
|
2705
|
-
{ type: ElementRef },
|
|
2706
|
-
{ type: SkyFuzzyDateService },
|
|
2707
|
-
{ type: SkyAppLocaleProvider },
|
|
2708
|
-
{ type: Renderer2 },
|
|
2709
|
-
{ type: SkyLibResourcesService },
|
|
2710
|
-
{ type: SkyDatepickerComponent, decorators: [{ type: Optional }] }
|
|
3092
|
+
SkyYearPickerComponent.ctorParameters = function () { return [
|
|
3093
|
+
{ type: SkyDatepickerCalendarInnerComponent }
|
|
2711
3094
|
]; };
|
|
2712
|
-
__decorate([
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
|
|
2720
|
-
], SkyFuzzyDatepickerInputDirective.prototype, "futureDisabled", null);
|
|
2721
|
-
__decorate([
|
|
2722
|
-
Input()
|
|
2723
|
-
], SkyFuzzyDatepickerInputDirective.prototype, "maxDate", null);
|
|
2724
|
-
__decorate([
|
|
2725
|
-
Input()
|
|
2726
|
-
], SkyFuzzyDatepickerInputDirective.prototype, "minDate", null);
|
|
2727
|
-
__decorate([
|
|
2728
|
-
Input()
|
|
2729
|
-
], SkyFuzzyDatepickerInputDirective.prototype, "skyDatepickerNoValidate", void 0);
|
|
2730
|
-
__decorate([
|
|
2731
|
-
Input()
|
|
2732
|
-
], SkyFuzzyDatepickerInputDirective.prototype, "skyFuzzyDatepickerInput", null);
|
|
2733
|
-
__decorate([
|
|
2734
|
-
Input()
|
|
2735
|
-
], SkyFuzzyDatepickerInputDirective.prototype, "startingDay", null);
|
|
2736
|
-
__decorate([
|
|
2737
|
-
Input()
|
|
2738
|
-
], SkyFuzzyDatepickerInputDirective.prototype, "yearRequired", null);
|
|
2739
|
-
__decorate([
|
|
2740
|
-
HostListener('change', ['$event'])
|
|
2741
|
-
], SkyFuzzyDatepickerInputDirective.prototype, "onInputChange", null);
|
|
2742
|
-
__decorate([
|
|
2743
|
-
HostListener('blur')
|
|
2744
|
-
], SkyFuzzyDatepickerInputDirective.prototype, "onInputBlur", null);
|
|
2745
|
-
__decorate([
|
|
2746
|
-
HostListener('keyup')
|
|
2747
|
-
], SkyFuzzyDatepickerInputDirective.prototype, "onInputKeyup", null);
|
|
2748
|
-
SkyFuzzyDatepickerInputDirective = __decorate([
|
|
2749
|
-
Directive({
|
|
2750
|
-
selector: '[skyFuzzyDatepickerInput]',
|
|
2751
|
-
providers: [
|
|
2752
|
-
SKY_FUZZY_DATEPICKER_VALUE_ACCESSOR,
|
|
2753
|
-
SKY_FUZZY_DATEPICKER_VALIDATOR
|
|
2754
|
-
]
|
|
2755
|
-
}),
|
|
2756
|
-
__param(7, Optional())
|
|
2757
|
-
], SkyFuzzyDatepickerInputDirective);
|
|
2758
|
-
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;
|
|
2759
3103
|
}());
|
|
2760
3104
|
|
|
2761
3105
|
var SkyDatepickerModule = /** @class */ (function () {
|
|
@@ -2771,7 +3115,9 @@ var SkyDatepickerModule = /** @class */ (function () {
|
|
|
2771
3115
|
SkyYearPickerComponent,
|
|
2772
3116
|
SkyDatepickerComponent,
|
|
2773
3117
|
SkyDatepickerInputDirective,
|
|
2774
|
-
SkyFuzzyDatepickerInputDirective
|
|
3118
|
+
SkyFuzzyDatepickerInputDirective,
|
|
3119
|
+
SkyDayPickerCellComponent,
|
|
3120
|
+
SkyDayPickerButtonComponent
|
|
2775
3121
|
],
|
|
2776
3122
|
imports: [
|
|
2777
3123
|
CommonModule,
|
|
@@ -2781,7 +3127,9 @@ var SkyDatepickerModule = /** @class */ (function () {
|
|
|
2781
3127
|
SkyDateTimeResourcesModule,
|
|
2782
3128
|
SkyAffixModule,
|
|
2783
3129
|
SkyOverlayModule,
|
|
2784
|
-
SkyThemeModule
|
|
3130
|
+
SkyThemeModule,
|
|
3131
|
+
SkyPopoverModule,
|
|
3132
|
+
SkyWaitModule
|
|
2785
3133
|
],
|
|
2786
3134
|
exports: [
|
|
2787
3135
|
SkyDatepickerCalendarComponent,
|
|
@@ -2791,14 +3139,17 @@ var SkyDatepickerModule = /** @class */ (function () {
|
|
|
2791
3139
|
SkyYearPickerComponent,
|
|
2792
3140
|
SkyDatepickerComponent,
|
|
2793
3141
|
SkyDatepickerInputDirective,
|
|
2794
|
-
SkyFuzzyDatepickerInputDirective
|
|
3142
|
+
SkyFuzzyDatepickerInputDirective,
|
|
3143
|
+
SkyDayPickerCellComponent,
|
|
3144
|
+
SkyDayPickerButtonComponent
|
|
2795
3145
|
],
|
|
2796
3146
|
providers: [
|
|
2797
3147
|
SkyAppWindowRef,
|
|
2798
3148
|
SkyDatepickerConfigService,
|
|
2799
3149
|
SkyFuzzyDateService,
|
|
2800
3150
|
SkyCoreAdapterService,
|
|
2801
|
-
SkyThemeService
|
|
3151
|
+
SkyThemeService,
|
|
3152
|
+
SkyDatepickerService
|
|
2802
3153
|
]
|
|
2803
3154
|
})
|
|
2804
3155
|
], SkyDatepickerModule);
|
|
@@ -4626,5 +4977,5 @@ var SkyTimepickerModule = /** @class */ (function () {
|
|
|
4626
4977
|
* Generated bundle index. Do not edit.
|
|
4627
4978
|
*/
|
|
4628
4979
|
|
|
4629
|
-
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 };
|
|
4630
4981
|
//# sourceMappingURL=skyux-datetime.js.map
|