@skyux/datetime 5.5.0 → 5.6.2
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/bundles/skyux-datetime.umd.js +1090 -764
- package/documentation.json +793 -932
- package/esm2015/lib/modules/date-pipe/date-format-utility.js +0 -2
- package/esm2015/lib/modules/date-pipe/date-format-utility.js.map +1 -1
- package/esm2015/lib/modules/date-pipe/date-pipe.module.js.map +1 -1
- package/esm2015/lib/modules/date-pipe/date.pipe.js.map +1 -1
- package/esm2015/lib/modules/date-pipe/fuzzy-date.pipe.js.map +1 -1
- package/esm2015/lib/modules/date-range-picker/date-range-picker.component.js +49 -60
- package/esm2015/lib/modules/date-range-picker/date-range-picker.component.js.map +1 -1
- package/esm2015/lib/modules/date-range-picker/date-range-picker.module.js.map +1 -1
- package/esm2015/lib/modules/date-range-picker/date-range.service.js.map +1 -1
- package/esm2015/lib/modules/date-range-picker/types/date-range-calculation.js.map +1 -1
- package/esm2015/lib/modules/date-range-picker/types/date-range-calculator-config.js.map +1 -1
- package/esm2015/lib/modules/date-range-picker/types/date-range-calculator.js.map +1 -1
- package/esm2015/lib/modules/date-range-picker/types/date-range-default-calculator-config.js.map +1 -1
- package/esm2015/lib/modules/date-range-picker/types/date-range-default-calculator-configs.js.map +1 -1
- package/esm2015/lib/modules/date-range-picker/types/date-range-relative-value.js +0 -3
- package/esm2015/lib/modules/date-range-picker/types/date-range-relative-value.js.map +1 -1
- package/esm2015/lib/modules/datepicker/date-formatter.js.map +1 -1
- package/esm2015/lib/modules/datepicker/datepicker-calendar-change.js.map +1 -1
- package/esm2015/lib/modules/datepicker/datepicker-calendar-inner.component.js +6 -6
- package/esm2015/lib/modules/datepicker/datepicker-calendar-inner.component.js.map +1 -1
- package/esm2015/lib/modules/datepicker/datepicker-calendar.component.js +1 -1
- package/esm2015/lib/modules/datepicker/datepicker-calendar.component.js.map +1 -1
- package/esm2015/lib/modules/datepicker/datepicker-input-fuzzy.directive.js +62 -52
- package/esm2015/lib/modules/datepicker/datepicker-input-fuzzy.directive.js.map +1 -1
- package/esm2015/lib/modules/datepicker/datepicker-input.directive.js +53 -42
- package/esm2015/lib/modules/datepicker/datepicker-input.directive.js.map +1 -1
- package/esm2015/lib/modules/datepicker/datepicker.component.js +2 -2
- package/esm2015/lib/modules/datepicker/datepicker.component.js.map +1 -1
- package/esm2015/lib/modules/datepicker/datepicker.module.js +10 -10
- package/esm2015/lib/modules/datepicker/datepicker.module.js.map +1 -1
- package/esm2015/lib/modules/datepicker/daypicker-button.component.js.map +1 -1
- package/esm2015/lib/modules/datepicker/daypicker-cell.component.js +1 -1
- package/esm2015/lib/modules/datepicker/daypicker-cell.component.js.map +1 -1
- package/esm2015/lib/modules/datepicker/daypicker.component.js +13 -13
- package/esm2015/lib/modules/datepicker/daypicker.component.js.map +1 -1
- package/esm2015/lib/modules/datepicker/fuzzy-date.service.js +10 -10
- package/esm2015/lib/modules/datepicker/fuzzy-date.service.js.map +1 -1
- package/esm2015/lib/modules/datepicker/monthpicker.component.js +5 -5
- package/esm2015/lib/modules/datepicker/monthpicker.component.js.map +1 -1
- package/esm2015/lib/modules/datepicker/yearpicker.component.js +2 -2
- package/esm2015/lib/modules/datepicker/yearpicker.component.js.map +1 -1
- package/esm2015/lib/modules/shared/sky-datetime-resources.module.js +1 -1
- package/esm2015/lib/modules/shared/sky-datetime-resources.module.js.map +1 -1
- package/esm2015/lib/modules/timepicker/timepicker.component.js +8 -8
- package/esm2015/lib/modules/timepicker/timepicker.component.js.map +1 -1
- package/esm2015/lib/modules/timepicker/timepicker.directive.js +7 -8
- package/esm2015/lib/modules/timepicker/timepicker.directive.js.map +1 -1
- package/esm2015/lib/modules/timepicker/timepicker.module.js +3 -3
- package/esm2015/lib/modules/timepicker/timepicker.module.js.map +1 -1
- package/esm2015/testing/datepicker-fixture.js.map +1 -1
- package/esm2015/testing/timepicker-fixture.js.map +1 -1
- package/fesm2015/skyux-datetime-testing.js.map +1 -1
- package/fesm2015/skyux-datetime.js +528 -524
- package/fesm2015/skyux-datetime.js.map +1 -1
- package/lib/modules/date-pipe/date-format-utility.d.ts +0 -1
- package/lib/modules/date-range-picker/date-range-picker.component.d.ts +6 -5
- package/lib/modules/date-range-picker/date-range.service.d.ts +1 -1
- package/lib/modules/date-range-picker/types/date-range-calculation.d.ts +1 -1
- package/lib/modules/date-range-picker/types/date-range-calculator.d.ts +1 -1
- package/lib/modules/date-range-picker/types/date-range-relative-value.d.ts +0 -1
- package/lib/modules/datepicker/datepicker-calendar-change.d.ts +1 -1
- package/lib/modules/datepicker/datepicker-calendar-inner.component.d.ts +17 -14
- package/lib/modules/datepicker/datepicker-calendar.component.d.ts +1 -1
- package/lib/modules/datepicker/datepicker-input-fuzzy.directive.d.ts +7 -2
- package/lib/modules/datepicker/datepicker-input.directive.d.ts +7 -3
- package/lib/modules/datepicker/datepicker.component.d.ts +2 -2
- package/lib/modules/datepicker/daypicker.component.d.ts +1 -1
- package/package.json +18 -16
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('rxjs'), require('rxjs/operators'), require('@skyux/i18n'), require('moment'), require('@angular/common'), require('@angular/forms'), require('@skyux/forms'), require('@skyux/core'), require('@skyux/indicators'), require('@skyux/
|
|
3
|
-
typeof define === 'function' && define.amd ? define('@skyux/datetime', ['exports', '@angular/core', 'rxjs', 'rxjs/operators', '@skyux/i18n', 'moment', '@angular/common', '@angular/forms', '@skyux/forms', '@skyux/core', '@skyux/indicators', '@skyux/
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.skyux = global.skyux || {}, global.skyux.datetime = {}), global.ng.core, global.rxjs, global.rxjs.operators, global.i3, global.moment, global.ng.common, global.ng.forms, global.i2$1, global.i1, global.i2, global.i3$
|
|
5
|
-
})(this, (function (exports, i0, rxjs, operators, i3, moment, i5, i2$2, i2$1, i1, i2, i3$
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('rxjs'), require('rxjs/operators'), require('@skyux/i18n'), require('moment'), require('@angular/common'), require('@angular/forms'), require('@skyux/forms'), require('@skyux/core'), require('@skyux/indicators'), require('@skyux/popovers'), require('@skyux/theme')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define('@skyux/datetime', ['exports', '@angular/core', 'rxjs', 'rxjs/operators', '@skyux/i18n', 'moment', '@angular/common', '@angular/forms', '@skyux/forms', '@skyux/core', '@skyux/indicators', '@skyux/popovers', '@skyux/theme'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.skyux = global.skyux || {}, global.skyux.datetime = {}), global.ng.core, global.rxjs, global.rxjs.operators, global.i3, global.moment, global.ng.common, global.ng.forms, global.i2$1, global.i1, global.i2, global.i3$1, global.i3$2));
|
|
5
|
+
})(this, (function (exports, i0, rxjs, operators, i3, moment, i5, i2$2, i2$1, i1, i2, i3$1, i3$2) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
8
|
|
|
@@ -32,12 +32,11 @@
|
|
|
32
32
|
var i2__namespace$1 = /*#__PURE__*/_interopNamespace(i2$1);
|
|
33
33
|
var i1__namespace = /*#__PURE__*/_interopNamespace(i1);
|
|
34
34
|
var i2__namespace = /*#__PURE__*/_interopNamespace(i2);
|
|
35
|
-
var i3__namespace$2 = /*#__PURE__*/_interopNamespace(i3$2);
|
|
36
35
|
var i3__namespace$1 = /*#__PURE__*/_interopNamespace(i3$1);
|
|
36
|
+
var i3__namespace$2 = /*#__PURE__*/_interopNamespace(i3$2);
|
|
37
37
|
|
|
38
38
|
// This class is mostly ported from the Angular 4.x DatePipe in order to maintain the old
|
|
39
39
|
var SkyDateFormatUtility = /** @class */ (function () {
|
|
40
|
-
/* istanbul ignore next */
|
|
41
40
|
function SkyDateFormatUtility() {
|
|
42
41
|
}
|
|
43
42
|
SkyDateFormatUtility.format = function (locale, value, pattern) {
|
|
@@ -932,38 +931,6 @@
|
|
|
932
931
|
SkyDateRangeCalculatorType[SkyDateRangeCalculatorType["Relative"] = 3] = "Relative";
|
|
933
932
|
})(exports.SkyDateRangeCalculatorType || (exports.SkyDateRangeCalculatorType = {}));
|
|
934
933
|
|
|
935
|
-
/**
|
|
936
|
-
* @internal
|
|
937
|
-
*/
|
|
938
|
-
var SkyDatepickerAdapterService = /** @class */ (function () {
|
|
939
|
-
function SkyDatepickerAdapterService(renderer) {
|
|
940
|
-
this.renderer = renderer;
|
|
941
|
-
}
|
|
942
|
-
SkyDatepickerAdapterService.prototype.init = function (elRef) {
|
|
943
|
-
this.el = elRef.nativeElement;
|
|
944
|
-
};
|
|
945
|
-
SkyDatepickerAdapterService.prototype.elementIsFocused = function () {
|
|
946
|
-
var focusedEl = document.activeElement;
|
|
947
|
-
return this.el.contains(focusedEl);
|
|
948
|
-
};
|
|
949
|
-
SkyDatepickerAdapterService.prototype.elementIsVisible = function () {
|
|
950
|
-
var styles = this.el && getComputedStyle(this.el);
|
|
951
|
-
return styles && styles.visibility === 'visible';
|
|
952
|
-
};
|
|
953
|
-
SkyDatepickerAdapterService.prototype.getPlaceholder = function (elementRef) {
|
|
954
|
-
return elementRef.nativeElement.getAttribute('placeholder');
|
|
955
|
-
};
|
|
956
|
-
SkyDatepickerAdapterService.prototype.setPlaceholder = function (elementRef, value) {
|
|
957
|
-
this.renderer.setAttribute(elementRef.nativeElement, 'placeholder', value);
|
|
958
|
-
};
|
|
959
|
-
return SkyDatepickerAdapterService;
|
|
960
|
-
}());
|
|
961
|
-
SkyDatepickerAdapterService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: SkyDatepickerAdapterService, deps: [{ token: i0__namespace.Renderer2 }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
|
|
962
|
-
SkyDatepickerAdapterService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: SkyDatepickerAdapterService });
|
|
963
|
-
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: SkyDatepickerAdapterService, decorators: [{
|
|
964
|
-
type: i0.Injectable
|
|
965
|
-
}], ctorParameters: function () { return [{ type: i0__namespace.Renderer2 }]; } });
|
|
966
|
-
|
|
967
934
|
var SkyDateFormatter = /** @class */ (function () {
|
|
968
935
|
function SkyDateFormatter() {
|
|
969
936
|
}
|
|
@@ -1322,6 +1289,38 @@
|
|
|
1322
1289
|
type: i0.Output
|
|
1323
1290
|
}] } });
|
|
1324
1291
|
|
|
1292
|
+
/**
|
|
1293
|
+
* @internal
|
|
1294
|
+
*/
|
|
1295
|
+
var SkyDatepickerAdapterService = /** @class */ (function () {
|
|
1296
|
+
function SkyDatepickerAdapterService(renderer) {
|
|
1297
|
+
this.renderer = renderer;
|
|
1298
|
+
}
|
|
1299
|
+
SkyDatepickerAdapterService.prototype.init = function (elRef) {
|
|
1300
|
+
this.el = elRef.nativeElement;
|
|
1301
|
+
};
|
|
1302
|
+
SkyDatepickerAdapterService.prototype.elementIsFocused = function () {
|
|
1303
|
+
var focusedEl = document.activeElement;
|
|
1304
|
+
return this.el.contains(focusedEl);
|
|
1305
|
+
};
|
|
1306
|
+
SkyDatepickerAdapterService.prototype.elementIsVisible = function () {
|
|
1307
|
+
var styles = this.el && getComputedStyle(this.el);
|
|
1308
|
+
return styles && styles.visibility === 'visible';
|
|
1309
|
+
};
|
|
1310
|
+
SkyDatepickerAdapterService.prototype.getPlaceholder = function (elementRef) {
|
|
1311
|
+
return elementRef.nativeElement.getAttribute('placeholder');
|
|
1312
|
+
};
|
|
1313
|
+
SkyDatepickerAdapterService.prototype.setPlaceholder = function (elementRef, value) {
|
|
1314
|
+
this.renderer.setAttribute(elementRef.nativeElement, 'placeholder', value);
|
|
1315
|
+
};
|
|
1316
|
+
return SkyDatepickerAdapterService;
|
|
1317
|
+
}());
|
|
1318
|
+
SkyDatepickerAdapterService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: SkyDatepickerAdapterService, deps: [{ token: i0__namespace.Renderer2 }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
|
|
1319
|
+
SkyDatepickerAdapterService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: SkyDatepickerAdapterService });
|
|
1320
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: SkyDatepickerAdapterService, decorators: [{
|
|
1321
|
+
type: i0.Injectable
|
|
1322
|
+
}], ctorParameters: function () { return [{ type: i0__namespace.Renderer2 }]; } });
|
|
1323
|
+
|
|
1325
1324
|
var SkyDatepickerConfigService = /** @class */ (function () {
|
|
1326
1325
|
function SkyDatepickerConfigService() {
|
|
1327
1326
|
/**
|
|
@@ -2342,53 +2341,55 @@
|
|
|
2342
2341
|
}] } });
|
|
2343
2342
|
|
|
2344
2343
|
// tslint:disable:no-forward-ref no-use-before-declare
|
|
2345
|
-
var
|
|
2344
|
+
var SKY_FUZZY_DATEPICKER_VALUE_ACCESSOR = {
|
|
2346
2345
|
provide: i2$2.NG_VALUE_ACCESSOR,
|
|
2347
|
-
useExisting: i0.forwardRef(function () { return
|
|
2346
|
+
useExisting: i0.forwardRef(function () { return SkyFuzzyDatepickerInputDirective; }),
|
|
2348
2347
|
multi: true,
|
|
2349
2348
|
};
|
|
2350
|
-
var
|
|
2349
|
+
var SKY_FUZZY_DATEPICKER_VALIDATOR = {
|
|
2351
2350
|
provide: i2$2.NG_VALIDATORS,
|
|
2352
|
-
useExisting: i0.forwardRef(function () { return
|
|
2351
|
+
useExisting: i0.forwardRef(function () { return SkyFuzzyDatepickerInputDirective; }),
|
|
2353
2352
|
multi: true,
|
|
2354
2353
|
};
|
|
2355
2354
|
// tslint:enable
|
|
2356
|
-
var
|
|
2357
|
-
function
|
|
2355
|
+
var SkyFuzzyDatepickerInputDirective = /** @class */ (function () {
|
|
2356
|
+
function SkyFuzzyDatepickerInputDirective(changeDetector, configService, elementRef, fuzzyDateService, localeProvider, renderer, resourcesService, datepickerComponent) {
|
|
2358
2357
|
var _this = this;
|
|
2359
|
-
this.adapter = adapter;
|
|
2360
2358
|
this.changeDetector = changeDetector;
|
|
2361
2359
|
this.configService = configService;
|
|
2362
2360
|
this.elementRef = elementRef;
|
|
2361
|
+
this.fuzzyDateService = fuzzyDateService;
|
|
2363
2362
|
this.localeProvider = localeProvider;
|
|
2364
2363
|
this.renderer = renderer;
|
|
2365
2364
|
this.resourcesService = resourcesService;
|
|
2366
2365
|
this.datepickerComponent = datepickerComponent;
|
|
2367
2366
|
/**
|
|
2368
|
-
* Indicates whether to disable date validation on the datepicker input.
|
|
2367
|
+
* Indicates whether to disable date validation on the fuzzy datepicker input.
|
|
2369
2368
|
* @default false
|
|
2370
2369
|
*/
|
|
2371
2370
|
this.skyDatepickerNoValidate = false;
|
|
2372
2371
|
this.dateFormatter = new SkyDateFormatter();
|
|
2373
|
-
this.isFirstChange = true;
|
|
2374
2372
|
this.ngUnsubscribe = new rxjs.Subject();
|
|
2373
|
+
this._futureDisabled = false;
|
|
2374
|
+
this._disabled = false;
|
|
2375
|
+
this._yearRequired = false;
|
|
2376
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
2375
2377
|
this.onChange = function (_) { };
|
|
2376
|
-
|
|
2378
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
2377
2379
|
this.onTouched = function () { };
|
|
2380
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
2378
2381
|
this.onValidatorChange = function () { };
|
|
2379
|
-
this.initialPlaceholder = this.adapter.getPlaceholder(this.elementRef);
|
|
2380
|
-
this.updatePlaceholder();
|
|
2381
2382
|
this.localeProvider
|
|
2382
2383
|
.getLocaleInfo()
|
|
2383
2384
|
.pipe(operators.takeUntil(this.ngUnsubscribe))
|
|
2384
2385
|
.subscribe(function (localeInfo) {
|
|
2385
|
-
|
|
2386
|
+
_this.locale = localeInfo.locale;
|
|
2387
|
+
SkyDateFormatter.setLocale(_this.locale);
|
|
2386
2388
|
_this.preferredShortDateFormat =
|
|
2387
2389
|
SkyDateFormatter.getPreferredShortDateFormat();
|
|
2388
|
-
_this.applyDateFormat();
|
|
2389
2390
|
});
|
|
2390
2391
|
}
|
|
2391
|
-
Object.defineProperty(
|
|
2392
|
+
Object.defineProperty(SkyFuzzyDatepickerInputDirective.prototype, "dateFormat", {
|
|
2392
2393
|
get: function () {
|
|
2393
2394
|
return (this._dateFormat ||
|
|
2394
2395
|
this.configService.dateFormat ||
|
|
@@ -2396,22 +2397,23 @@
|
|
|
2396
2397
|
},
|
|
2397
2398
|
/**
|
|
2398
2399
|
* Specifies the date format for the input. Place this attribute on the `input` element
|
|
2399
|
-
* to override the default in
|
|
2400
|
+
* to override the default in `SkyDatepickerConfigService`.
|
|
2400
2401
|
* @default "MM/DD/YYYY"
|
|
2401
2402
|
*/
|
|
2402
2403
|
set: function (value) {
|
|
2403
|
-
|
|
2404
|
-
if (
|
|
2405
|
-
this.
|
|
2406
|
-
this.
|
|
2404
|
+
this._dateFormat = value;
|
|
2405
|
+
if (this.value) {
|
|
2406
|
+
var formattedDate = this.fuzzyDateService.format(this.value, this.dateFormat, this.locale);
|
|
2407
|
+
this.setInputElementValue(formattedDate);
|
|
2408
|
+
this.changeDetector.markForCheck();
|
|
2407
2409
|
}
|
|
2408
2410
|
},
|
|
2409
2411
|
enumerable: false,
|
|
2410
2412
|
configurable: true
|
|
2411
2413
|
});
|
|
2412
|
-
Object.defineProperty(
|
|
2414
|
+
Object.defineProperty(SkyFuzzyDatepickerInputDirective.prototype, "disabled", {
|
|
2413
2415
|
get: function () {
|
|
2414
|
-
return this._disabled
|
|
2416
|
+
return this._disabled;
|
|
2415
2417
|
},
|
|
2416
2418
|
/**
|
|
2417
2419
|
* Indicates whether to disable the datepicker.
|
|
@@ -2425,69 +2427,74 @@
|
|
|
2425
2427
|
enumerable: false,
|
|
2426
2428
|
configurable: true
|
|
2427
2429
|
});
|
|
2428
|
-
Object.defineProperty(
|
|
2430
|
+
Object.defineProperty(SkyFuzzyDatepickerInputDirective.prototype, "futureDisabled", {
|
|
2431
|
+
get: function () {
|
|
2432
|
+
return this._futureDisabled;
|
|
2433
|
+
},
|
|
2429
2434
|
/**
|
|
2430
|
-
*
|
|
2431
|
-
*
|
|
2435
|
+
* Indicates whether to prevent users from specifying dates that are in the future.
|
|
2436
|
+
* Place this attribute on the `input` element.
|
|
2437
|
+
* @default false
|
|
2432
2438
|
*/
|
|
2433
|
-
|
|
2434
|
-
|
|
2439
|
+
set: function (value) {
|
|
2440
|
+
this._futureDisabled = value;
|
|
2441
|
+
this.onValidatorChange();
|
|
2435
2442
|
},
|
|
2436
2443
|
enumerable: false,
|
|
2437
2444
|
configurable: true
|
|
2438
2445
|
});
|
|
2439
|
-
Object.defineProperty(
|
|
2446
|
+
Object.defineProperty(SkyFuzzyDatepickerInputDirective.prototype, "maxDate", {
|
|
2440
2447
|
get: function () {
|
|
2441
|
-
return this._maxDate
|
|
2448
|
+
return this._maxDate;
|
|
2442
2449
|
},
|
|
2443
2450
|
/**
|
|
2444
|
-
* Specifies the latest date
|
|
2445
|
-
*
|
|
2451
|
+
* Specifies the latest fuzzy date allowed. Place this attribute on the `input` element
|
|
2452
|
+
* to prevent fuzzy dates after a specified date. This property accepts
|
|
2453
|
+
* a `SkyFuzzyDate` value that includes numeric month, day, and year values.
|
|
2454
|
+
* For example: `{ month: 1, day: 1, year: 2027 }`.
|
|
2446
2455
|
*/
|
|
2447
2456
|
set: function (value) {
|
|
2448
2457
|
this._maxDate = value;
|
|
2449
|
-
this.datepickerComponent.maxDate = this.
|
|
2458
|
+
this.datepickerComponent.maxDate = this.getMaxDate();
|
|
2450
2459
|
this.onValidatorChange();
|
|
2451
2460
|
},
|
|
2452
2461
|
enumerable: false,
|
|
2453
2462
|
configurable: true
|
|
2454
2463
|
});
|
|
2455
|
-
Object.defineProperty(
|
|
2464
|
+
Object.defineProperty(SkyFuzzyDatepickerInputDirective.prototype, "minDate", {
|
|
2456
2465
|
get: function () {
|
|
2457
|
-
return this._minDate
|
|
2466
|
+
return this._minDate;
|
|
2458
2467
|
},
|
|
2459
2468
|
/**
|
|
2460
|
-
* Specifies the earliest date
|
|
2461
|
-
*
|
|
2469
|
+
* Specifies the earliest fuzzy date allowed. Place this attribute on the `input` element
|
|
2470
|
+
* to prevent fuzzy dates before a specified date. This property accepts a `SkyFuzzyDate` value
|
|
2471
|
+
* that includes numeric month, day, and year values.
|
|
2472
|
+
* For example: `{ month: 1, day: 1, year: 2007 }`.
|
|
2462
2473
|
*/
|
|
2463
2474
|
set: function (value) {
|
|
2464
2475
|
this._minDate = value;
|
|
2465
|
-
this.datepickerComponent.minDate = this.
|
|
2476
|
+
this.datepickerComponent.minDate = this.getMinDate();
|
|
2466
2477
|
this.onValidatorChange();
|
|
2467
2478
|
},
|
|
2468
2479
|
enumerable: false,
|
|
2469
2480
|
configurable: true
|
|
2470
2481
|
});
|
|
2471
|
-
Object.defineProperty(
|
|
2482
|
+
Object.defineProperty(SkyFuzzyDatepickerInputDirective.prototype, "skyFuzzyDatepickerInput", {
|
|
2472
2483
|
/**
|
|
2473
|
-
* Creates the datepicker input and calendar
|
|
2474
|
-
*
|
|
2484
|
+
* Creates the fuzzy datepicker input and calendar to let users specify dates that are
|
|
2485
|
+
* not complete. For example, if users know the year but not the month or day, they can
|
|
2486
|
+
* enter just the year. Place this directive on an `input` element, and wrap the `input`
|
|
2487
|
+
* in a `sky-datepicker` component. The value that users select is driven
|
|
2475
2488
|
* through the `ngModel` attribute specified on the `input` element.
|
|
2476
2489
|
* @required
|
|
2477
2490
|
*/
|
|
2478
2491
|
set: function (value) {
|
|
2479
|
-
|
|
2480
|
-
console.warn('[Deprecation warning] You no longer need to provide a template reference variable ' +
|
|
2481
|
-
'to the `skyDatepickerInput` attribute (this will be a breaking change in the next ' +
|
|
2482
|
-
'major version release).\n' +
|
|
2483
|
-
'Do this instead:\n' +
|
|
2484
|
-
'<sky-datepicker>\n <input skyDatepickerInput />\n</sky-datepicker>');
|
|
2485
|
-
}
|
|
2492
|
+
// TODO: Remove this property in a future version of SKY UX.
|
|
2486
2493
|
},
|
|
2487
2494
|
enumerable: false,
|
|
2488
2495
|
configurable: true
|
|
2489
2496
|
});
|
|
2490
|
-
Object.defineProperty(
|
|
2497
|
+
Object.defineProperty(SkyFuzzyDatepickerInputDirective.prototype, "startingDay", {
|
|
2491
2498
|
get: function () {
|
|
2492
2499
|
return this._startingDay || this.configService.startingDay;
|
|
2493
2500
|
},
|
|
@@ -2505,64 +2512,46 @@
|
|
|
2505
2512
|
enumerable: false,
|
|
2506
2513
|
configurable: true
|
|
2507
2514
|
});
|
|
2508
|
-
Object.defineProperty(
|
|
2515
|
+
Object.defineProperty(SkyFuzzyDatepickerInputDirective.prototype, "yearRequired", {
|
|
2509
2516
|
get: function () {
|
|
2510
|
-
return this.
|
|
2517
|
+
return this._yearRequired;
|
|
2511
2518
|
},
|
|
2512
2519
|
/**
|
|
2513
|
-
* Indicates whether
|
|
2514
|
-
* If this property is `true` and the datepicker input directive cannot find an exact match, then
|
|
2515
|
-
* the input is marked as invalid.
|
|
2516
|
-
* If this property is `false` and the datepicker input directive cannot find an exact match, then
|
|
2517
|
-
* it attempts to format the string based on the [ISO 8601 standard format](https://www.iso.org/iso-8601-date-and-time-format.html).
|
|
2520
|
+
* Indicates whether to require the year in fuzzy dates.
|
|
2518
2521
|
* @default false
|
|
2519
2522
|
*/
|
|
2520
2523
|
set: function (value) {
|
|
2521
|
-
this.
|
|
2524
|
+
this._yearRequired = value;
|
|
2525
|
+
this.onValidatorChange();
|
|
2522
2526
|
},
|
|
2523
2527
|
enumerable: false,
|
|
2524
2528
|
configurable: true
|
|
2525
2529
|
});
|
|
2526
|
-
Object.defineProperty(
|
|
2530
|
+
Object.defineProperty(SkyFuzzyDatepickerInputDirective.prototype, "value", {
|
|
2527
2531
|
get: function () {
|
|
2528
2532
|
return this._value;
|
|
2529
2533
|
},
|
|
2530
2534
|
set: function (value) {
|
|
2531
|
-
|
|
2532
|
-
var areDatesEqual = this._value instanceof Date &&
|
|
2533
|
-
dateValue &&
|
|
2534
|
-
dateValue.getTime() === this._value.getTime();
|
|
2535
|
-
var isValidDateString = this.isDateStringValid(value);
|
|
2536
|
-
// If the string value supplied is malformed, do not set the value to its Date equivalent.
|
|
2537
|
-
// (JavaScript's Date parser will convert poorly formatted dates to Date objects, such as "abc 123", which isn't ideal.)
|
|
2538
|
-
if (!isValidDateString) {
|
|
2539
|
-
this._value = value;
|
|
2540
|
-
this.notifyUpdatedValue();
|
|
2541
|
-
}
|
|
2542
|
-
else if (dateValue !== this._value || !areDatesEqual) {
|
|
2543
|
-
this._value = dateValue || value;
|
|
2544
|
-
this.notifyUpdatedValue();
|
|
2545
|
-
}
|
|
2546
|
-
if (dateValue && isValidDateString) {
|
|
2547
|
-
var formattedDate = this.dateFormatter.format(dateValue, this.dateFormat);
|
|
2548
|
-
this.setInputElementValue(formattedDate);
|
|
2549
|
-
}
|
|
2550
|
-
else {
|
|
2551
|
-
this.setInputElementValue(value || '');
|
|
2552
|
-
}
|
|
2535
|
+
this.updateValue(value);
|
|
2553
2536
|
},
|
|
2554
2537
|
enumerable: false,
|
|
2555
2538
|
configurable: true
|
|
2556
2539
|
});
|
|
2557
|
-
|
|
2540
|
+
SkyFuzzyDatepickerInputDirective.prototype.ngOnInit = function () {
|
|
2558
2541
|
var _this = this;
|
|
2542
|
+
if (this.yearRequired) {
|
|
2543
|
+
if (this.dateFormat.toLowerCase().indexOf('y') === -1) {
|
|
2544
|
+
throw new Error('You have configured conflicting settings. Year is required and dateFormat does not include year.');
|
|
2545
|
+
}
|
|
2546
|
+
}
|
|
2559
2547
|
if (!this.datepickerComponent) {
|
|
2560
|
-
throw new Error('You must wrap the `
|
|
2548
|
+
throw new Error('You must wrap the `skyFuzzyDatepickerInput` directive within a ' +
|
|
2561
2549
|
'`<sky-datepicker>` component!');
|
|
2562
2550
|
}
|
|
2563
2551
|
var element = this.elementRef.nativeElement;
|
|
2564
2552
|
this.renderer.addClass(element, 'sky-form-control');
|
|
2565
2553
|
var hasAriaLabel = element.getAttribute('aria-label');
|
|
2554
|
+
/* istanbul ignore else */
|
|
2566
2555
|
if (!hasAriaLabel) {
|
|
2567
2556
|
this.resourcesService
|
|
2568
2557
|
.getString('skyux_date_field_default_label')
|
|
@@ -2572,18 +2561,16 @@
|
|
|
2572
2561
|
});
|
|
2573
2562
|
}
|
|
2574
2563
|
};
|
|
2575
|
-
|
|
2564
|
+
SkyFuzzyDatepickerInputDirective.prototype.ngAfterContentInit = function () {
|
|
2576
2565
|
var _this = this;
|
|
2577
2566
|
this.datepickerComponent.dateChange
|
|
2578
|
-
.pipe(operators.distinctUntilChanged())
|
|
2579
|
-
.pipe(operators.takeUntil(this.ngUnsubscribe))
|
|
2567
|
+
.pipe(operators.distinctUntilChanged(), operators.takeUntil(this.ngUnsubscribe))
|
|
2580
2568
|
.subscribe(function (value) {
|
|
2581
|
-
_this.isFirstChange = false;
|
|
2582
2569
|
_this.value = value;
|
|
2583
2570
|
_this.onTouched();
|
|
2584
2571
|
});
|
|
2585
2572
|
};
|
|
2586
|
-
|
|
2573
|
+
SkyFuzzyDatepickerInputDirective.prototype.ngAfterViewInit = function () {
|
|
2587
2574
|
var _this = this;
|
|
2588
2575
|
// This is needed to address a bug in Angular 4.
|
|
2589
2576
|
// When a control value is set intially, its value is not represented on the view.
|
|
@@ -2599,90 +2586,110 @@
|
|
|
2599
2586
|
_this.changeDetector.markForCheck();
|
|
2600
2587
|
});
|
|
2601
2588
|
}
|
|
2602
|
-
this.adapter.init(this.elementRef);
|
|
2603
2589
|
};
|
|
2604
|
-
|
|
2590
|
+
SkyFuzzyDatepickerInputDirective.prototype.ngOnDestroy = function () {
|
|
2605
2591
|
this.ngUnsubscribe.next();
|
|
2606
2592
|
this.ngUnsubscribe.complete();
|
|
2607
2593
|
};
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
if (this.skyDatepickerNoValidate) {
|
|
2611
|
-
this.onValueChange(value);
|
|
2612
|
-
return;
|
|
2613
|
-
}
|
|
2614
|
-
// Don't try to parse the string value into a Date value if it is malformed.
|
|
2615
|
-
if (this.isDateStringValid(value)) {
|
|
2616
|
-
this.onValueChange(value);
|
|
2617
|
-
return;
|
|
2618
|
-
}
|
|
2619
|
-
this._value = value;
|
|
2620
|
-
this.onChange(value);
|
|
2621
|
-
this.control.setErrors({
|
|
2622
|
-
skyDate: {
|
|
2623
|
-
invalid: true,
|
|
2624
|
-
},
|
|
2625
|
-
});
|
|
2594
|
+
SkyFuzzyDatepickerInputDirective.prototype.onInputChange = function (event) {
|
|
2595
|
+
this.onValueChange(event.target.value);
|
|
2626
2596
|
};
|
|
2627
|
-
|
|
2597
|
+
SkyFuzzyDatepickerInputDirective.prototype.onInputBlur = function () {
|
|
2628
2598
|
this.onTouched();
|
|
2599
|
+
var formattedDate = this.fuzzyDateService.format(this.value, this.dateFormat, this.locale);
|
|
2600
|
+
if (this.control.valid) {
|
|
2601
|
+
this.setInputElementValue(formattedDate);
|
|
2602
|
+
}
|
|
2629
2603
|
};
|
|
2630
|
-
|
|
2604
|
+
SkyFuzzyDatepickerInputDirective.prototype.onInputKeyup = function () {
|
|
2631
2605
|
this.control.markAsDirty();
|
|
2632
2606
|
};
|
|
2633
|
-
|
|
2634
|
-
this.value
|
|
2607
|
+
SkyFuzzyDatepickerInputDirective.prototype.writeValue = function (value) {
|
|
2608
|
+
this.updateValue(value, false);
|
|
2635
2609
|
};
|
|
2636
|
-
|
|
2610
|
+
SkyFuzzyDatepickerInputDirective.prototype.validate = function (control) {
|
|
2637
2611
|
if (!this.control) {
|
|
2638
2612
|
this.control = control;
|
|
2639
2613
|
}
|
|
2640
2614
|
if (this.skyDatepickerNoValidate) {
|
|
2641
2615
|
return;
|
|
2642
2616
|
}
|
|
2643
|
-
|
|
2644
|
-
if (!value) {
|
|
2617
|
+
if (!this.control.value) {
|
|
2645
2618
|
return;
|
|
2646
2619
|
}
|
|
2647
|
-
var
|
|
2648
|
-
var
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
|
|
2660
|
-
if (minDate && this.dateFormatter.dateIsValid(minDate) && value < minDate) {
|
|
2661
|
-
return {
|
|
2662
|
-
skyDate: {
|
|
2663
|
-
minDate: minDate,
|
|
2620
|
+
var value = control.value;
|
|
2621
|
+
var fuzzyDate;
|
|
2622
|
+
var validationError;
|
|
2623
|
+
if (typeof value === 'string') {
|
|
2624
|
+
fuzzyDate = this.fuzzyDateService.getFuzzyDateFromString(value, this.dateFormat);
|
|
2625
|
+
}
|
|
2626
|
+
else {
|
|
2627
|
+
fuzzyDate = value;
|
|
2628
|
+
}
|
|
2629
|
+
if (!fuzzyDate) {
|
|
2630
|
+
validationError = {
|
|
2631
|
+
skyFuzzyDate: {
|
|
2632
|
+
invalid: value,
|
|
2664
2633
|
},
|
|
2665
2634
|
};
|
|
2666
2635
|
}
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
maxDate: maxDate,
|
|
2636
|
+
if (!validationError && !fuzzyDate.year && this.yearRequired) {
|
|
2637
|
+
validationError = {
|
|
2638
|
+
skyFuzzyDate: {
|
|
2639
|
+
yearRequired: value,
|
|
2672
2640
|
},
|
|
2673
2641
|
};
|
|
2674
2642
|
}
|
|
2643
|
+
if (!validationError && fuzzyDate.year) {
|
|
2644
|
+
var fuzzyDateRange = void 0;
|
|
2645
|
+
if (this.maxDate) {
|
|
2646
|
+
fuzzyDateRange = this.fuzzyDateService.getFuzzyDateRange(fuzzyDate, this.maxDate);
|
|
2647
|
+
if (!fuzzyDateRange.valid) {
|
|
2648
|
+
validationError = {
|
|
2649
|
+
skyFuzzyDate: {
|
|
2650
|
+
maxDate: value,
|
|
2651
|
+
},
|
|
2652
|
+
};
|
|
2653
|
+
}
|
|
2654
|
+
}
|
|
2655
|
+
if (!validationError && this.minDate) {
|
|
2656
|
+
fuzzyDateRange = this.fuzzyDateService.getFuzzyDateRange(this.minDate, fuzzyDate);
|
|
2657
|
+
if (!fuzzyDateRange.valid) {
|
|
2658
|
+
validationError = {
|
|
2659
|
+
skyFuzzyDate: {
|
|
2660
|
+
minDate: value,
|
|
2661
|
+
},
|
|
2662
|
+
};
|
|
2663
|
+
}
|
|
2664
|
+
}
|
|
2665
|
+
if (!validationError && this.futureDisabled) {
|
|
2666
|
+
fuzzyDateRange = this.fuzzyDateService.getFuzzyDateRange(fuzzyDate, this.fuzzyDateService.getCurrentFuzzyDate());
|
|
2667
|
+
if (!fuzzyDateRange.valid) {
|
|
2668
|
+
validationError = {
|
|
2669
|
+
skyFuzzyDate: {
|
|
2670
|
+
futureDisabled: value,
|
|
2671
|
+
},
|
|
2672
|
+
};
|
|
2673
|
+
}
|
|
2674
|
+
}
|
|
2675
|
+
}
|
|
2676
|
+
if (validationError) {
|
|
2677
|
+
// Mark the invalid control as touched so that the input's invalid CSS styles appear.
|
|
2678
|
+
// (This is only required when the invalid value is set by the FormControl constructor.)
|
|
2679
|
+
this.control.markAsTouched();
|
|
2680
|
+
}
|
|
2681
|
+
return validationError;
|
|
2675
2682
|
};
|
|
2676
|
-
|
|
2683
|
+
SkyFuzzyDatepickerInputDirective.prototype.registerOnChange = function (fn) {
|
|
2677
2684
|
this.onChange = fn;
|
|
2678
2685
|
};
|
|
2679
|
-
|
|
2686
|
+
SkyFuzzyDatepickerInputDirective.prototype.registerOnTouched = function (fn) {
|
|
2680
2687
|
this.onTouched = fn;
|
|
2681
2688
|
};
|
|
2682
|
-
|
|
2689
|
+
SkyFuzzyDatepickerInputDirective.prototype.registerOnValidatorChange = function (fn) {
|
|
2683
2690
|
this.onValidatorChange = fn;
|
|
2684
2691
|
};
|
|
2685
|
-
|
|
2692
|
+
SkyFuzzyDatepickerInputDirective.prototype.setDisabledState = function (disabled) {
|
|
2686
2693
|
this.disabled = disabled;
|
|
2687
2694
|
this.datepickerComponent.disabled = disabled;
|
|
2688
2695
|
};
|
|
@@ -2690,108 +2697,134 @@
|
|
|
2690
2697
|
* Detects changes to the underlying input element's value and updates the ngModel accordingly.
|
|
2691
2698
|
* This is useful if you need to update the ngModel value before the input element loses focus.
|
|
2692
2699
|
*/
|
|
2693
|
-
|
|
2700
|
+
SkyFuzzyDatepickerInputDirective.prototype.detectInputValueChange = function () {
|
|
2694
2701
|
this.onValueChange(this.elementRef.nativeElement.value);
|
|
2695
2702
|
};
|
|
2696
|
-
|
|
2697
|
-
this.updatePlaceholder();
|
|
2698
|
-
if (this.value) {
|
|
2699
|
-
var formattedDate = this.dateFormatter.format(this.value, this.dateFormat);
|
|
2700
|
-
this.setInputElementValue(formattedDate);
|
|
2701
|
-
this.changeDetector.markForCheck();
|
|
2702
|
-
}
|
|
2703
|
-
};
|
|
2704
|
-
SkyDatepickerInputDirective.prototype.onValueChange = function (newValue) {
|
|
2705
|
-
this.isFirstChange = false;
|
|
2703
|
+
SkyFuzzyDatepickerInputDirective.prototype.onValueChange = function (newValue) {
|
|
2706
2704
|
this.value = newValue;
|
|
2707
2705
|
};
|
|
2708
|
-
|
|
2706
|
+
SkyFuzzyDatepickerInputDirective.prototype.setInputElementValue = function (value) {
|
|
2709
2707
|
this.renderer.setProperty(this.elementRef.nativeElement, 'value', value);
|
|
2710
2708
|
};
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
2709
|
+
SkyFuzzyDatepickerInputDirective.prototype.getMaxDate = function () {
|
|
2710
|
+
if (this.maxDate) {
|
|
2711
|
+
var maxDate = this.fuzzyDateService.getMomentFromFuzzyDate(this.maxDate);
|
|
2712
|
+
if (maxDate.isValid()) {
|
|
2713
|
+
return maxDate.toDate();
|
|
2714
|
+
}
|
|
2715
2715
|
}
|
|
2716
|
-
else if (
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
|
|
2716
|
+
else if (this.futureDisabled) {
|
|
2717
|
+
return new Date();
|
|
2718
|
+
}
|
|
2719
|
+
return this.configService.maxDate;
|
|
2720
|
+
};
|
|
2721
|
+
SkyFuzzyDatepickerInputDirective.prototype.getMinDate = function () {
|
|
2722
|
+
if (this.minDate) {
|
|
2723
|
+
var minDate = this.fuzzyDateService.getMomentFromFuzzyDate(this.minDate);
|
|
2724
|
+
if (minDate.isValid()) {
|
|
2725
|
+
return minDate.toDate();
|
|
2720
2726
|
}
|
|
2721
2727
|
}
|
|
2722
|
-
return
|
|
2728
|
+
return this.configService.minDate;
|
|
2729
|
+
};
|
|
2730
|
+
/* istanbul ignore next */
|
|
2731
|
+
SkyFuzzyDatepickerInputDirective.prototype.fuzzyDatesEqual = function (dateA, dateB) {
|
|
2732
|
+
return (dateA &&
|
|
2733
|
+
dateB &&
|
|
2734
|
+
((!dateA.day && !dateB.day) || dateA.day === dateB.day) &&
|
|
2735
|
+
((!dateA.month && !dateB.month) || dateA.month === dateB.month) &&
|
|
2736
|
+
((!dateA.year && !dateB.year) || dateA.year === dateB.year));
|
|
2723
2737
|
};
|
|
2724
2738
|
/**
|
|
2725
|
-
*
|
|
2739
|
+
* Update the value of the form control and input element
|
|
2740
|
+
* @param emitEvent Denotes if we emit an event to the consumer's form control. We do not want to do this if the value is being updated via a `setValue` call or a `patchValue` call as this is already handled by Angular.
|
|
2741
|
+
* In these cases we do not want to fire `onChange` as it will cause extra `valueChange` and `statusChange` events and the status of the form should not be affected by these changes.
|
|
2726
2742
|
*/
|
|
2727
|
-
|
|
2728
|
-
if (
|
|
2729
|
-
|
|
2743
|
+
SkyFuzzyDatepickerInputDirective.prototype.updateValue = function (value, emitEvent) {
|
|
2744
|
+
if (emitEvent === void 0) { emitEvent = true; }
|
|
2745
|
+
var _a;
|
|
2746
|
+
if (this._value === value) {
|
|
2747
|
+
return;
|
|
2730
2748
|
}
|
|
2731
|
-
|
|
2732
|
-
var
|
|
2733
|
-
var
|
|
2734
|
-
|
|
2735
|
-
|
|
2749
|
+
var fuzzyDate;
|
|
2750
|
+
var fuzzyMoment;
|
|
2751
|
+
var dateValue;
|
|
2752
|
+
var formattedDate;
|
|
2753
|
+
if (value instanceof Date) {
|
|
2754
|
+
dateValue = value;
|
|
2755
|
+
formattedDate = this.dateFormatter.format(value, this.dateFormat);
|
|
2756
|
+
fuzzyDate = this.fuzzyDateService.getFuzzyDateFromSelectedDate(value, this.dateFormat);
|
|
2736
2757
|
}
|
|
2737
|
-
|
|
2738
|
-
|
|
2739
|
-
|
|
2740
|
-
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
|
|
2744
|
-
|
|
2745
|
-
|
|
2746
|
-
|
|
2758
|
+
else if (typeof value === 'string') {
|
|
2759
|
+
fuzzyDate = this.fuzzyDateService.getFuzzyDateFromString(value, this.dateFormat);
|
|
2760
|
+
formattedDate = this.fuzzyDateService.format(fuzzyDate, this.dateFormat, this.locale);
|
|
2761
|
+
if (!formattedDate) {
|
|
2762
|
+
formattedDate = value;
|
|
2763
|
+
}
|
|
2764
|
+
fuzzyMoment = this.fuzzyDateService.getMomentFromFuzzyDate(fuzzyDate);
|
|
2765
|
+
if (fuzzyMoment) {
|
|
2766
|
+
dateValue = fuzzyMoment.toDate();
|
|
2767
|
+
}
|
|
2747
2768
|
}
|
|
2748
|
-
|
|
2749
|
-
|
|
2769
|
+
else {
|
|
2770
|
+
fuzzyDate = value;
|
|
2771
|
+
formattedDate = this.fuzzyDateService.format(fuzzyDate, this.dateFormat, this.locale);
|
|
2772
|
+
fuzzyMoment = this.fuzzyDateService.getMomentFromFuzzyDate(fuzzyDate);
|
|
2773
|
+
if (fuzzyMoment) {
|
|
2774
|
+
dateValue = fuzzyMoment.toDate();
|
|
2775
|
+
}
|
|
2750
2776
|
}
|
|
2751
|
-
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
-
if (
|
|
2755
|
-
|
|
2777
|
+
var areFuzzyDatesEqual = this.fuzzyDatesEqual(this._value, fuzzyDate);
|
|
2778
|
+
var isNewValue = fuzzyDate !== this._value || !areFuzzyDatesEqual;
|
|
2779
|
+
this._value = fuzzyDate || value;
|
|
2780
|
+
if (isNewValue) {
|
|
2781
|
+
if (emitEvent) {
|
|
2782
|
+
this.onChange(this._value);
|
|
2783
|
+
}
|
|
2784
|
+
else {
|
|
2785
|
+
(_a = this.control) === null || _a === void 0 ? void 0 : _a.setValue(this._value, { emitEvent: false });
|
|
2786
|
+
}
|
|
2787
|
+
this.datepickerComponent.selectedDate = dateValue;
|
|
2756
2788
|
}
|
|
2789
|
+
this.setInputElementValue(formattedDate || '');
|
|
2757
2790
|
};
|
|
2758
|
-
return
|
|
2791
|
+
return SkyFuzzyDatepickerInputDirective;
|
|
2759
2792
|
}());
|
|
2760
|
-
|
|
2761
|
-
|
|
2762
|
-
|
|
2763
|
-
|
|
2764
|
-
SkyDatepickerAdapterService,
|
|
2793
|
+
SkyFuzzyDatepickerInputDirective.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: SkyFuzzyDatepickerInputDirective, deps: [{ token: i0__namespace.ChangeDetectorRef }, { token: SkyDatepickerConfigService }, { token: i0__namespace.ElementRef }, { token: SkyFuzzyDateService }, { token: i3__namespace.SkyAppLocaleProvider }, { token: i0__namespace.Renderer2 }, { token: i3__namespace.SkyLibResourcesService }, { token: SkyDatepickerComponent, optional: true }], target: i0__namespace.ɵɵFactoryTarget.Directive });
|
|
2794
|
+
SkyFuzzyDatepickerInputDirective.ɵdir = i0__namespace.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: SkyFuzzyDatepickerInputDirective, selector: "[skyFuzzyDatepickerInput]", inputs: { dateFormat: "dateFormat", disabled: "disabled", futureDisabled: "futureDisabled", maxDate: "maxDate", minDate: "minDate", skyDatepickerNoValidate: "skyDatepickerNoValidate", skyFuzzyDatepickerInput: "skyFuzzyDatepickerInput", startingDay: "startingDay", yearRequired: "yearRequired" }, host: { listeners: { "change": "onInputChange($event)", "blur": "onInputBlur()", "keyup": "onInputKeyup()" } }, providers: [
|
|
2795
|
+
SKY_FUZZY_DATEPICKER_VALUE_ACCESSOR,
|
|
2796
|
+
SKY_FUZZY_DATEPICKER_VALIDATOR,
|
|
2765
2797
|
], ngImport: i0__namespace });
|
|
2766
|
-
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type:
|
|
2798
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: SkyFuzzyDatepickerInputDirective, decorators: [{
|
|
2767
2799
|
type: i0.Directive,
|
|
2768
2800
|
args: [{
|
|
2769
|
-
selector: '[
|
|
2801
|
+
selector: '[skyFuzzyDatepickerInput]',
|
|
2770
2802
|
providers: [
|
|
2771
|
-
|
|
2772
|
-
|
|
2773
|
-
SkyDatepickerAdapterService,
|
|
2803
|
+
SKY_FUZZY_DATEPICKER_VALUE_ACCESSOR,
|
|
2804
|
+
SKY_FUZZY_DATEPICKER_VALIDATOR,
|
|
2774
2805
|
],
|
|
2775
2806
|
}]
|
|
2776
2807
|
}], ctorParameters: function () {
|
|
2777
|
-
return [{ type:
|
|
2808
|
+
return [{ type: i0__namespace.ChangeDetectorRef }, { type: SkyDatepickerConfigService }, { type: i0__namespace.ElementRef }, { type: SkyFuzzyDateService }, { type: i3__namespace.SkyAppLocaleProvider }, { type: i0__namespace.Renderer2 }, { type: i3__namespace.SkyLibResourcesService }, { type: SkyDatepickerComponent, decorators: [{
|
|
2778
2809
|
type: i0.Optional
|
|
2779
2810
|
}] }];
|
|
2780
2811
|
}, propDecorators: { dateFormat: [{
|
|
2781
2812
|
type: i0.Input
|
|
2782
2813
|
}], disabled: [{
|
|
2783
2814
|
type: i0.Input
|
|
2815
|
+
}], futureDisabled: [{
|
|
2816
|
+
type: i0.Input
|
|
2784
2817
|
}], maxDate: [{
|
|
2785
2818
|
type: i0.Input
|
|
2786
2819
|
}], minDate: [{
|
|
2787
2820
|
type: i0.Input
|
|
2788
|
-
}], skyDatepickerInput: [{
|
|
2789
|
-
type: i0.Input
|
|
2790
2821
|
}], skyDatepickerNoValidate: [{
|
|
2791
2822
|
type: i0.Input
|
|
2823
|
+
}], skyFuzzyDatepickerInput: [{
|
|
2824
|
+
type: i0.Input
|
|
2792
2825
|
}], startingDay: [{
|
|
2793
2826
|
type: i0.Input
|
|
2794
|
-
}],
|
|
2827
|
+
}], yearRequired: [{
|
|
2795
2828
|
type: i0.Input
|
|
2796
2829
|
}], onInputChange: [{
|
|
2797
2830
|
type: i0.HostListener,
|
|
@@ -2805,54 +2838,54 @@
|
|
|
2805
2838
|
}] } });
|
|
2806
2839
|
|
|
2807
2840
|
// tslint:disable:no-forward-ref no-use-before-declare
|
|
2808
|
-
var
|
|
2841
|
+
var SKY_DATEPICKER_VALUE_ACCESSOR = {
|
|
2809
2842
|
provide: i2$2.NG_VALUE_ACCESSOR,
|
|
2810
|
-
useExisting: i0.forwardRef(function () { return
|
|
2843
|
+
useExisting: i0.forwardRef(function () { return SkyDatepickerInputDirective; }),
|
|
2811
2844
|
multi: true,
|
|
2812
2845
|
};
|
|
2813
|
-
var
|
|
2846
|
+
var SKY_DATEPICKER_VALIDATOR = {
|
|
2814
2847
|
provide: i2$2.NG_VALIDATORS,
|
|
2815
|
-
useExisting: i0.forwardRef(function () { return
|
|
2848
|
+
useExisting: i0.forwardRef(function () { return SkyDatepickerInputDirective; }),
|
|
2816
2849
|
multi: true,
|
|
2817
2850
|
};
|
|
2818
2851
|
// tslint:enable
|
|
2819
|
-
var
|
|
2820
|
-
function
|
|
2852
|
+
var SkyDatepickerInputDirective = /** @class */ (function () {
|
|
2853
|
+
function SkyDatepickerInputDirective(adapter, changeDetector, configService, elementRef, localeProvider, renderer, resourcesService, datepickerComponent) {
|
|
2821
2854
|
var _this = this;
|
|
2855
|
+
this.adapter = adapter;
|
|
2822
2856
|
this.changeDetector = changeDetector;
|
|
2823
2857
|
this.configService = configService;
|
|
2824
2858
|
this.elementRef = elementRef;
|
|
2825
|
-
this.fuzzyDateService = fuzzyDateService;
|
|
2826
2859
|
this.localeProvider = localeProvider;
|
|
2827
2860
|
this.renderer = renderer;
|
|
2828
2861
|
this.resourcesService = resourcesService;
|
|
2829
2862
|
this.datepickerComponent = datepickerComponent;
|
|
2830
2863
|
/**
|
|
2831
|
-
* Indicates whether to disable date validation on the
|
|
2864
|
+
* Indicates whether to disable date validation on the datepicker input.
|
|
2832
2865
|
* @default false
|
|
2833
2866
|
*/
|
|
2834
2867
|
this.skyDatepickerNoValidate = false;
|
|
2835
2868
|
this.dateFormatter = new SkyDateFormatter();
|
|
2836
|
-
this.isFirstChange = true;
|
|
2837
2869
|
this.ngUnsubscribe = new rxjs.Subject();
|
|
2838
|
-
|
|
2839
|
-
this._disabled = false;
|
|
2840
|
-
this._yearRequired = false;
|
|
2870
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
2841
2871
|
this.onChange = function (_) { };
|
|
2842
|
-
|
|
2872
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
2843
2873
|
this.onTouched = function () { };
|
|
2874
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
2844
2875
|
this.onValidatorChange = function () { };
|
|
2876
|
+
this.initialPlaceholder = this.adapter.getPlaceholder(this.elementRef);
|
|
2877
|
+
this.updatePlaceholder();
|
|
2845
2878
|
this.localeProvider
|
|
2846
2879
|
.getLocaleInfo()
|
|
2847
2880
|
.pipe(operators.takeUntil(this.ngUnsubscribe))
|
|
2848
2881
|
.subscribe(function (localeInfo) {
|
|
2849
|
-
|
|
2850
|
-
SkyDateFormatter.setLocale(_this.locale);
|
|
2882
|
+
SkyDateFormatter.setLocale(localeInfo.locale);
|
|
2851
2883
|
_this.preferredShortDateFormat =
|
|
2852
2884
|
SkyDateFormatter.getPreferredShortDateFormat();
|
|
2885
|
+
_this.applyDateFormat();
|
|
2853
2886
|
});
|
|
2854
2887
|
}
|
|
2855
|
-
Object.defineProperty(
|
|
2888
|
+
Object.defineProperty(SkyDatepickerInputDirective.prototype, "dateFormat", {
|
|
2856
2889
|
get: function () {
|
|
2857
2890
|
return (this._dateFormat ||
|
|
2858
2891
|
this.configService.dateFormat ||
|
|
@@ -2860,23 +2893,22 @@
|
|
|
2860
2893
|
},
|
|
2861
2894
|
/**
|
|
2862
2895
|
* Specifies the date format for the input. Place this attribute on the `input` element
|
|
2863
|
-
* to override the default in `SkyDatepickerConfigService`.
|
|
2896
|
+
* to override the default in the `SkyDatepickerConfigService`.
|
|
2864
2897
|
* @default "MM/DD/YYYY"
|
|
2865
2898
|
*/
|
|
2866
2899
|
set: function (value) {
|
|
2867
|
-
|
|
2868
|
-
if (this.
|
|
2869
|
-
|
|
2870
|
-
this.
|
|
2871
|
-
this.changeDetector.markForCheck();
|
|
2900
|
+
/* istanbul ignore else */
|
|
2901
|
+
if (value !== this._dateFormat) {
|
|
2902
|
+
this._dateFormat = value;
|
|
2903
|
+
this.applyDateFormat();
|
|
2872
2904
|
}
|
|
2873
2905
|
},
|
|
2874
2906
|
enumerable: false,
|
|
2875
2907
|
configurable: true
|
|
2876
2908
|
});
|
|
2877
|
-
Object.defineProperty(
|
|
2909
|
+
Object.defineProperty(SkyDatepickerInputDirective.prototype, "disabled", {
|
|
2878
2910
|
get: function () {
|
|
2879
|
-
return this._disabled;
|
|
2911
|
+
return this._disabled || false;
|
|
2880
2912
|
},
|
|
2881
2913
|
/**
|
|
2882
2914
|
* Indicates whether to disable the datepicker.
|
|
@@ -2890,72 +2922,69 @@
|
|
|
2890
2922
|
enumerable: false,
|
|
2891
2923
|
configurable: true
|
|
2892
2924
|
});
|
|
2893
|
-
Object.defineProperty(
|
|
2894
|
-
get: function () {
|
|
2895
|
-
return this._futureDisabled;
|
|
2896
|
-
},
|
|
2925
|
+
Object.defineProperty(SkyDatepickerInputDirective.prototype, "inputIsFocused", {
|
|
2897
2926
|
/**
|
|
2898
|
-
*
|
|
2899
|
-
*
|
|
2900
|
-
* @default false
|
|
2927
|
+
* @internal
|
|
2928
|
+
* Indicates if the input element or any of its children have focus.
|
|
2901
2929
|
*/
|
|
2902
|
-
|
|
2903
|
-
this.
|
|
2904
|
-
this.onValidatorChange();
|
|
2930
|
+
get: function () {
|
|
2931
|
+
return this.adapter.elementIsFocused();
|
|
2905
2932
|
},
|
|
2906
2933
|
enumerable: false,
|
|
2907
2934
|
configurable: true
|
|
2908
2935
|
});
|
|
2909
|
-
Object.defineProperty(
|
|
2936
|
+
Object.defineProperty(SkyDatepickerInputDirective.prototype, "maxDate", {
|
|
2910
2937
|
get: function () {
|
|
2911
|
-
return this._maxDate;
|
|
2938
|
+
return this._maxDate || this.configService.maxDate;
|
|
2912
2939
|
},
|
|
2913
2940
|
/**
|
|
2914
|
-
* Specifies the latest
|
|
2915
|
-
*
|
|
2916
|
-
* a `SkyFuzzyDate` value that includes numeric month, day, and year values.
|
|
2917
|
-
* For example: `{ month: 1, day: 1, year: 2027 }`.
|
|
2941
|
+
* Specifies the latest date that is available in the calendar. Place this attribute on
|
|
2942
|
+
* the `input` element to override the default in `SkyDatepickerConfigService`.
|
|
2918
2943
|
*/
|
|
2919
2944
|
set: function (value) {
|
|
2920
2945
|
this._maxDate = value;
|
|
2921
|
-
this.datepickerComponent.maxDate = this.
|
|
2946
|
+
this.datepickerComponent.maxDate = this.maxDate;
|
|
2922
2947
|
this.onValidatorChange();
|
|
2923
2948
|
},
|
|
2924
2949
|
enumerable: false,
|
|
2925
2950
|
configurable: true
|
|
2926
2951
|
});
|
|
2927
|
-
Object.defineProperty(
|
|
2952
|
+
Object.defineProperty(SkyDatepickerInputDirective.prototype, "minDate", {
|
|
2928
2953
|
get: function () {
|
|
2929
|
-
return this._minDate;
|
|
2954
|
+
return this._minDate || this.configService.minDate;
|
|
2930
2955
|
},
|
|
2931
2956
|
/**
|
|
2932
|
-
* Specifies the earliest
|
|
2933
|
-
*
|
|
2934
|
-
* that includes numeric month, day, and year values.
|
|
2935
|
-
* For example: `{ month: 1, day: 1, year: 2007 }`.
|
|
2957
|
+
* Specifies the earliest date that is available in the calendar. Place this attribute on
|
|
2958
|
+
* the `input` element to override the default in `SkyDatepickerConfigService`.
|
|
2936
2959
|
*/
|
|
2937
2960
|
set: function (value) {
|
|
2938
2961
|
this._minDate = value;
|
|
2939
|
-
this.datepickerComponent.minDate = this.
|
|
2962
|
+
this.datepickerComponent.minDate = this.minDate;
|
|
2940
2963
|
this.onValidatorChange();
|
|
2941
2964
|
},
|
|
2942
2965
|
enumerable: false,
|
|
2943
2966
|
configurable: true
|
|
2944
2967
|
});
|
|
2945
|
-
Object.defineProperty(
|
|
2968
|
+
Object.defineProperty(SkyDatepickerInputDirective.prototype, "skyDatepickerInput", {
|
|
2946
2969
|
/**
|
|
2947
|
-
* Creates the
|
|
2948
|
-
*
|
|
2949
|
-
* enter just the year. Place this directive on an `input` element, and wrap the `input`
|
|
2950
|
-
* in a `sky-datepicker` component. The value that users select is driven
|
|
2970
|
+
* Creates the datepicker input and calendar. Place this directive on an `input` element,
|
|
2971
|
+
* and wrap the input in a `sky-datepicker` component. The value that users select is driven
|
|
2951
2972
|
* through the `ngModel` attribute specified on the `input` element.
|
|
2952
2973
|
* @required
|
|
2953
2974
|
*/
|
|
2954
|
-
set: function (value) {
|
|
2975
|
+
set: function (value) {
|
|
2976
|
+
if (value) {
|
|
2977
|
+
console.warn('[Deprecation warning] You no longer need to provide a template reference variable ' +
|
|
2978
|
+
'to the `skyDatepickerInput` attribute (this will be a breaking change in the next ' +
|
|
2979
|
+
'major version release).\n' +
|
|
2980
|
+
'Do this instead:\n' +
|
|
2981
|
+
'<sky-datepicker>\n <input skyDatepickerInput />\n</sky-datepicker>');
|
|
2982
|
+
}
|
|
2983
|
+
},
|
|
2955
2984
|
enumerable: false,
|
|
2956
2985
|
configurable: true
|
|
2957
2986
|
});
|
|
2958
|
-
Object.defineProperty(
|
|
2987
|
+
Object.defineProperty(SkyDatepickerInputDirective.prototype, "startingDay", {
|
|
2959
2988
|
get: function () {
|
|
2960
2989
|
return this._startingDay || this.configService.startingDay;
|
|
2961
2990
|
},
|
|
@@ -2973,89 +3002,43 @@
|
|
|
2973
3002
|
enumerable: false,
|
|
2974
3003
|
configurable: true
|
|
2975
3004
|
});
|
|
2976
|
-
Object.defineProperty(
|
|
3005
|
+
Object.defineProperty(SkyDatepickerInputDirective.prototype, "strict", {
|
|
2977
3006
|
get: function () {
|
|
2978
|
-
return this.
|
|
3007
|
+
return this._strict || false;
|
|
2979
3008
|
},
|
|
2980
3009
|
/**
|
|
2981
|
-
* Indicates whether
|
|
3010
|
+
* Indicates whether the format of the date value must match the format from the `dateFormat` value.
|
|
3011
|
+
* If this property is `true` and the datepicker input directive cannot find an exact match, then
|
|
3012
|
+
* the input is marked as invalid.
|
|
3013
|
+
* If this property is `false` and the datepicker input directive cannot find an exact match, then
|
|
3014
|
+
* it attempts to format the string based on the [ISO 8601 standard format](https://www.iso.org/iso-8601-date-and-time-format.html).
|
|
2982
3015
|
* @default false
|
|
2983
3016
|
*/
|
|
2984
3017
|
set: function (value) {
|
|
2985
|
-
this.
|
|
2986
|
-
this.onValidatorChange();
|
|
3018
|
+
this._strict = value;
|
|
2987
3019
|
},
|
|
2988
3020
|
enumerable: false,
|
|
2989
3021
|
configurable: true
|
|
2990
3022
|
});
|
|
2991
|
-
Object.defineProperty(
|
|
3023
|
+
Object.defineProperty(SkyDatepickerInputDirective.prototype, "value", {
|
|
2992
3024
|
get: function () {
|
|
2993
3025
|
return this._value;
|
|
2994
3026
|
},
|
|
2995
3027
|
set: function (value) {
|
|
2996
|
-
|
|
2997
|
-
var fuzzyMoment;
|
|
2998
|
-
var dateValue;
|
|
2999
|
-
var formattedDate;
|
|
3000
|
-
if (value instanceof Date) {
|
|
3001
|
-
dateValue = value;
|
|
3002
|
-
formattedDate = this.dateFormatter.format(value, this.dateFormat);
|
|
3003
|
-
fuzzyDate = this.fuzzyDateService.getFuzzyDateFromSelectedDate(value, this.dateFormat);
|
|
3004
|
-
}
|
|
3005
|
-
else if (typeof value === 'string') {
|
|
3006
|
-
fuzzyDate = this.fuzzyDateService.getFuzzyDateFromString(value, this.dateFormat);
|
|
3007
|
-
formattedDate = this.fuzzyDateService.format(fuzzyDate, this.dateFormat, this.locale);
|
|
3008
|
-
if (!formattedDate) {
|
|
3009
|
-
formattedDate = value;
|
|
3010
|
-
}
|
|
3011
|
-
fuzzyMoment = this.fuzzyDateService.getMomentFromFuzzyDate(fuzzyDate);
|
|
3012
|
-
if (fuzzyMoment) {
|
|
3013
|
-
dateValue = fuzzyMoment.toDate();
|
|
3014
|
-
}
|
|
3015
|
-
}
|
|
3016
|
-
else {
|
|
3017
|
-
fuzzyDate = value;
|
|
3018
|
-
formattedDate = this.fuzzyDateService.format(fuzzyDate, this.dateFormat, this.locale);
|
|
3019
|
-
fuzzyMoment = this.fuzzyDateService.getMomentFromFuzzyDate(fuzzyDate);
|
|
3020
|
-
if (fuzzyMoment) {
|
|
3021
|
-
dateValue = fuzzyMoment.toDate();
|
|
3022
|
-
}
|
|
3023
|
-
}
|
|
3024
|
-
var areFuzzyDatesEqual = this.fuzzyDatesEqual(this._value, fuzzyDate);
|
|
3025
|
-
var isNewValue = fuzzyDate !== this._value || !areFuzzyDatesEqual;
|
|
3026
|
-
this._value = fuzzyDate || value;
|
|
3027
|
-
if (isNewValue) {
|
|
3028
|
-
this.onChange(this._value);
|
|
3029
|
-
// Do not mark the field as "dirty"
|
|
3030
|
-
// if the field has been initialized with a value.
|
|
3031
|
-
if (this.isFirstChange && this.control) {
|
|
3032
|
-
this.control.markAsPristine();
|
|
3033
|
-
}
|
|
3034
|
-
if (this.isFirstChange && this._value) {
|
|
3035
|
-
this.isFirstChange = false;
|
|
3036
|
-
}
|
|
3037
|
-
this.datepickerComponent.selectedDate = dateValue;
|
|
3038
|
-
}
|
|
3039
|
-
this.setInputElementValue(formattedDate || '');
|
|
3028
|
+
this.updateValue(value);
|
|
3040
3029
|
},
|
|
3041
3030
|
enumerable: false,
|
|
3042
3031
|
configurable: true
|
|
3043
3032
|
});
|
|
3044
|
-
|
|
3033
|
+
SkyDatepickerInputDirective.prototype.ngOnInit = function () {
|
|
3045
3034
|
var _this = this;
|
|
3046
|
-
if (this.yearRequired) {
|
|
3047
|
-
if (this.dateFormat.toLowerCase().indexOf('y') === -1) {
|
|
3048
|
-
throw new Error('You have configured conflicting settings. Year is required and dateFormat does not include year.');
|
|
3049
|
-
}
|
|
3050
|
-
}
|
|
3051
3035
|
if (!this.datepickerComponent) {
|
|
3052
|
-
throw new Error('You must wrap the `
|
|
3036
|
+
throw new Error('You must wrap the `skyDatepickerInput` directive within a ' +
|
|
3053
3037
|
'`<sky-datepicker>` component!');
|
|
3054
3038
|
}
|
|
3055
3039
|
var element = this.elementRef.nativeElement;
|
|
3056
3040
|
this.renderer.addClass(element, 'sky-form-control');
|
|
3057
3041
|
var hasAriaLabel = element.getAttribute('aria-label');
|
|
3058
|
-
/* istanbul ignore else */
|
|
3059
3042
|
if (!hasAriaLabel) {
|
|
3060
3043
|
this.resourcesService
|
|
3061
3044
|
.getString('skyux_date_field_default_label')
|
|
@@ -3065,17 +3048,17 @@
|
|
|
3065
3048
|
});
|
|
3066
3049
|
}
|
|
3067
3050
|
};
|
|
3068
|
-
|
|
3051
|
+
SkyDatepickerInputDirective.prototype.ngAfterContentInit = function () {
|
|
3069
3052
|
var _this = this;
|
|
3070
3053
|
this.datepickerComponent.dateChange
|
|
3071
|
-
.pipe(operators.distinctUntilChanged()
|
|
3054
|
+
.pipe(operators.distinctUntilChanged())
|
|
3055
|
+
.pipe(operators.takeUntil(this.ngUnsubscribe))
|
|
3072
3056
|
.subscribe(function (value) {
|
|
3073
|
-
_this.isFirstChange = false;
|
|
3074
3057
|
_this.value = value;
|
|
3075
3058
|
_this.onTouched();
|
|
3076
3059
|
});
|
|
3077
3060
|
};
|
|
3078
|
-
|
|
3061
|
+
SkyDatepickerInputDirective.prototype.ngAfterViewInit = function () {
|
|
3079
3062
|
var _this = this;
|
|
3080
3063
|
// This is needed to address a bug in Angular 4.
|
|
3081
3064
|
// When a control value is set intially, its value is not represented on the view.
|
|
@@ -3091,110 +3074,90 @@
|
|
|
3091
3074
|
_this.changeDetector.markForCheck();
|
|
3092
3075
|
});
|
|
3093
3076
|
}
|
|
3077
|
+
this.adapter.init(this.elementRef);
|
|
3094
3078
|
};
|
|
3095
|
-
|
|
3079
|
+
SkyDatepickerInputDirective.prototype.ngOnDestroy = function () {
|
|
3096
3080
|
this.ngUnsubscribe.next();
|
|
3097
3081
|
this.ngUnsubscribe.complete();
|
|
3098
3082
|
};
|
|
3099
|
-
|
|
3100
|
-
|
|
3083
|
+
SkyDatepickerInputDirective.prototype.onInputChange = function (event) {
|
|
3084
|
+
var value = event.target.value;
|
|
3085
|
+
if (this.skyDatepickerNoValidate) {
|
|
3086
|
+
this.onValueChange(value);
|
|
3087
|
+
return;
|
|
3088
|
+
}
|
|
3089
|
+
// Don't try to parse the string value into a Date value if it is malformed.
|
|
3090
|
+
if (this.isDateStringValid(value)) {
|
|
3091
|
+
this.onValueChange(value);
|
|
3092
|
+
return;
|
|
3093
|
+
}
|
|
3094
|
+
this._value = value;
|
|
3095
|
+
this.onChange(value);
|
|
3096
|
+
this.control.setErrors({
|
|
3097
|
+
skyDate: {
|
|
3098
|
+
invalid: true,
|
|
3099
|
+
},
|
|
3100
|
+
});
|
|
3101
3101
|
};
|
|
3102
|
-
|
|
3102
|
+
SkyDatepickerInputDirective.prototype.onInputBlur = function () {
|
|
3103
3103
|
this.onTouched();
|
|
3104
|
-
var formattedDate = this.fuzzyDateService.format(this.value, this.dateFormat, this.locale);
|
|
3105
|
-
if (this.control.valid) {
|
|
3106
|
-
this.setInputElementValue(formattedDate);
|
|
3107
|
-
}
|
|
3108
3104
|
};
|
|
3109
|
-
|
|
3105
|
+
SkyDatepickerInputDirective.prototype.onInputKeyup = function () {
|
|
3110
3106
|
this.control.markAsDirty();
|
|
3111
3107
|
};
|
|
3112
|
-
|
|
3113
|
-
this.value
|
|
3108
|
+
SkyDatepickerInputDirective.prototype.writeValue = function (value) {
|
|
3109
|
+
this.updateValue(value, false);
|
|
3114
3110
|
};
|
|
3115
|
-
|
|
3111
|
+
SkyDatepickerInputDirective.prototype.validate = function (control) {
|
|
3116
3112
|
if (!this.control) {
|
|
3117
3113
|
this.control = control;
|
|
3118
3114
|
}
|
|
3119
3115
|
if (this.skyDatepickerNoValidate) {
|
|
3120
3116
|
return;
|
|
3121
3117
|
}
|
|
3122
|
-
if (!this.control.value) {
|
|
3123
|
-
return;
|
|
3124
|
-
}
|
|
3125
3118
|
var value = control.value;
|
|
3126
|
-
|
|
3127
|
-
|
|
3128
|
-
if (typeof value === 'string') {
|
|
3129
|
-
fuzzyDate = this.fuzzyDateService.getFuzzyDateFromString(value, this.dateFormat);
|
|
3130
|
-
}
|
|
3131
|
-
else {
|
|
3132
|
-
fuzzyDate = value;
|
|
3119
|
+
if (!value) {
|
|
3120
|
+
return;
|
|
3133
3121
|
}
|
|
3134
|
-
|
|
3135
|
-
|
|
3136
|
-
|
|
3122
|
+
var dateValue = this.getDateValue(value);
|
|
3123
|
+
var isDateValid = dateValue && this.dateFormatter.dateIsValid(dateValue);
|
|
3124
|
+
if (!isDateValid || !this.isDateStringValid(value)) {
|
|
3125
|
+
// Mark the invalid control as touched so that the input's invalid CSS styles appear.
|
|
3126
|
+
// (This is only required when the invalid value is set by the FormControl constructor.)
|
|
3127
|
+
this.control.markAsTouched();
|
|
3128
|
+
return {
|
|
3129
|
+
skyDate: {
|
|
3137
3130
|
invalid: value,
|
|
3138
3131
|
},
|
|
3139
3132
|
};
|
|
3140
3133
|
}
|
|
3141
|
-
|
|
3142
|
-
|
|
3143
|
-
|
|
3144
|
-
|
|
3134
|
+
var minDate = this.minDate;
|
|
3135
|
+
if (minDate && this.dateFormatter.dateIsValid(minDate) && value < minDate) {
|
|
3136
|
+
return {
|
|
3137
|
+
skyDate: {
|
|
3138
|
+
minDate: minDate,
|
|
3145
3139
|
},
|
|
3146
3140
|
};
|
|
3147
3141
|
}
|
|
3148
|
-
|
|
3149
|
-
|
|
3150
|
-
|
|
3151
|
-
|
|
3152
|
-
|
|
3153
|
-
|
|
3154
|
-
|
|
3155
|
-
maxDate: value,
|
|
3156
|
-
},
|
|
3157
|
-
};
|
|
3158
|
-
}
|
|
3159
|
-
}
|
|
3160
|
-
if (!validationError && this.minDate) {
|
|
3161
|
-
fuzzyDateRange = this.fuzzyDateService.getFuzzyDateRange(this.minDate, fuzzyDate);
|
|
3162
|
-
if (!fuzzyDateRange.valid) {
|
|
3163
|
-
validationError = {
|
|
3164
|
-
skyFuzzyDate: {
|
|
3165
|
-
minDate: value,
|
|
3166
|
-
},
|
|
3167
|
-
};
|
|
3168
|
-
}
|
|
3169
|
-
}
|
|
3170
|
-
if (!validationError && this.futureDisabled) {
|
|
3171
|
-
fuzzyDateRange = this.fuzzyDateService.getFuzzyDateRange(fuzzyDate, this.fuzzyDateService.getCurrentFuzzyDate());
|
|
3172
|
-
if (!fuzzyDateRange.valid) {
|
|
3173
|
-
validationError = {
|
|
3174
|
-
skyFuzzyDate: {
|
|
3175
|
-
futureDisabled: value,
|
|
3176
|
-
},
|
|
3177
|
-
};
|
|
3178
|
-
}
|
|
3179
|
-
}
|
|
3180
|
-
}
|
|
3181
|
-
if (validationError) {
|
|
3182
|
-
// Mark the invalid control as touched so that the input's invalid CSS styles appear.
|
|
3183
|
-
// (This is only required when the invalid value is set by the FormControl constructor.)
|
|
3184
|
-
this.control.markAsTouched();
|
|
3142
|
+
var maxDate = this.maxDate;
|
|
3143
|
+
if (maxDate && this.dateFormatter.dateIsValid(maxDate) && value > maxDate) {
|
|
3144
|
+
return {
|
|
3145
|
+
skyDate: {
|
|
3146
|
+
maxDate: maxDate,
|
|
3147
|
+
},
|
|
3148
|
+
};
|
|
3185
3149
|
}
|
|
3186
|
-
return validationError;
|
|
3187
3150
|
};
|
|
3188
|
-
|
|
3151
|
+
SkyDatepickerInputDirective.prototype.registerOnChange = function (fn) {
|
|
3189
3152
|
this.onChange = fn;
|
|
3190
3153
|
};
|
|
3191
|
-
|
|
3154
|
+
SkyDatepickerInputDirective.prototype.registerOnTouched = function (fn) {
|
|
3192
3155
|
this.onTouched = fn;
|
|
3193
3156
|
};
|
|
3194
|
-
|
|
3157
|
+
SkyDatepickerInputDirective.prototype.registerOnValidatorChange = function (fn) {
|
|
3195
3158
|
this.onValidatorChange = fn;
|
|
3196
3159
|
};
|
|
3197
|
-
|
|
3160
|
+
SkyDatepickerInputDirective.prototype.setDisabledState = function (disabled) {
|
|
3198
3161
|
this.disabled = disabled;
|
|
3199
3162
|
this.datepickerComponent.disabled = disabled;
|
|
3200
3163
|
};
|
|
@@ -3202,82 +3165,141 @@
|
|
|
3202
3165
|
* Detects changes to the underlying input element's value and updates the ngModel accordingly.
|
|
3203
3166
|
* This is useful if you need to update the ngModel value before the input element loses focus.
|
|
3204
3167
|
*/
|
|
3205
|
-
|
|
3168
|
+
SkyDatepickerInputDirective.prototype.detectInputValueChange = function () {
|
|
3206
3169
|
this.onValueChange(this.elementRef.nativeElement.value);
|
|
3207
3170
|
};
|
|
3208
|
-
|
|
3209
|
-
this.
|
|
3171
|
+
SkyDatepickerInputDirective.prototype.applyDateFormat = function () {
|
|
3172
|
+
this.updatePlaceholder();
|
|
3173
|
+
if (this.value) {
|
|
3174
|
+
var formattedDate = this.dateFormatter.format(this.value, this.dateFormat);
|
|
3175
|
+
this.setInputElementValue(formattedDate);
|
|
3176
|
+
this.changeDetector.markForCheck();
|
|
3177
|
+
}
|
|
3178
|
+
};
|
|
3179
|
+
SkyDatepickerInputDirective.prototype.onValueChange = function (newValue) {
|
|
3210
3180
|
this.value = newValue;
|
|
3211
3181
|
};
|
|
3212
|
-
|
|
3182
|
+
SkyDatepickerInputDirective.prototype.setInputElementValue = function (value) {
|
|
3213
3183
|
this.renderer.setProperty(this.elementRef.nativeElement, 'value', value);
|
|
3214
3184
|
};
|
|
3215
|
-
|
|
3216
|
-
|
|
3217
|
-
|
|
3218
|
-
|
|
3219
|
-
|
|
3185
|
+
SkyDatepickerInputDirective.prototype.getDateValue = function (value) {
|
|
3186
|
+
var dateValue;
|
|
3187
|
+
if (value instanceof Date) {
|
|
3188
|
+
dateValue = value;
|
|
3189
|
+
}
|
|
3190
|
+
else if (typeof value === 'string') {
|
|
3191
|
+
var date = this.dateFormatter.getDateFromString(value, this.dateFormat, this.strict);
|
|
3192
|
+
if (this.dateFormatter.dateIsValid(date)) {
|
|
3193
|
+
dateValue = date;
|
|
3220
3194
|
}
|
|
3221
3195
|
}
|
|
3222
|
-
|
|
3223
|
-
|
|
3196
|
+
return dateValue;
|
|
3197
|
+
};
|
|
3198
|
+
/**
|
|
3199
|
+
* Validates the input value to ensure it is formatted correctly.
|
|
3200
|
+
*/
|
|
3201
|
+
SkyDatepickerInputDirective.prototype.isDateStringValid = function (value) {
|
|
3202
|
+
if (!value || typeof value !== 'string') {
|
|
3203
|
+
return true;
|
|
3224
3204
|
}
|
|
3225
|
-
|
|
3205
|
+
// Does the value only include digits, dashes, or slashes?
|
|
3206
|
+
var regexp = /^[\d/-]+$/;
|
|
3207
|
+
var isValid = regexp.test(value);
|
|
3208
|
+
if (isValid) {
|
|
3209
|
+
return true;
|
|
3210
|
+
}
|
|
3211
|
+
// If not, does it conform to the standard ISO format?
|
|
3212
|
+
var isValidIso = moment__default["default"](value, moment__default["default"].ISO_8601).isValid();
|
|
3213
|
+
return isValidIso;
|
|
3226
3214
|
};
|
|
3227
|
-
|
|
3228
|
-
if (this.
|
|
3229
|
-
|
|
3230
|
-
if (minDate.isValid()) {
|
|
3231
|
-
return minDate.toDate();
|
|
3232
|
-
}
|
|
3215
|
+
SkyDatepickerInputDirective.prototype.updatePlaceholder = function () {
|
|
3216
|
+
if (!this.initialPlaceholder) {
|
|
3217
|
+
this.adapter.setPlaceholder(this.elementRef, this.dateFormat);
|
|
3233
3218
|
}
|
|
3234
|
-
return this.configService.minDate;
|
|
3235
3219
|
};
|
|
3236
|
-
|
|
3237
|
-
|
|
3238
|
-
|
|
3239
|
-
|
|
3240
|
-
|
|
3241
|
-
|
|
3242
|
-
|
|
3220
|
+
/**
|
|
3221
|
+
* Update the value of the form control and input element
|
|
3222
|
+
* @param emitEvent Denotes if we emit an event to the consumer's form control. We do not want to do this if the value is being updated via a `setValue` call or a `patchValue` call as this is already handled by Angular.
|
|
3223
|
+
* In these cases we do not want to fire `onChange` as it will cause extra `valueChange` and `statusChange` events and the status of the form should not be affected by these changes.
|
|
3224
|
+
*/
|
|
3225
|
+
SkyDatepickerInputDirective.prototype.updateValue = function (value, emitEvent) {
|
|
3226
|
+
if (emitEvent === void 0) { emitEvent = true; }
|
|
3227
|
+
var _a, _b;
|
|
3228
|
+
if (this._value === value) {
|
|
3229
|
+
return;
|
|
3230
|
+
}
|
|
3231
|
+
var dateValue = this.getDateValue(value);
|
|
3232
|
+
var areDatesEqual = this._value instanceof Date &&
|
|
3233
|
+
dateValue &&
|
|
3234
|
+
dateValue.getTime() === this._value.getTime();
|
|
3235
|
+
var isValidDateString = this.isDateStringValid(value);
|
|
3236
|
+
// If the string value supplied is malformed, do not set the value to its Date equivalent.
|
|
3237
|
+
// (JavaScript's Date parser will convert poorly formatted dates to Date objects, such as "abc 123", which isn't ideal.)
|
|
3238
|
+
if (!isValidDateString) {
|
|
3239
|
+
this._value = value;
|
|
3240
|
+
if (emitEvent) {
|
|
3241
|
+
this.onChange(this._value);
|
|
3242
|
+
}
|
|
3243
|
+
else {
|
|
3244
|
+
(_a = this.control) === null || _a === void 0 ? void 0 : _a.setValue(this._value, { emitEvent: false });
|
|
3245
|
+
}
|
|
3246
|
+
this.datepickerComponent.selectedDate = this._value;
|
|
3247
|
+
}
|
|
3248
|
+
else if (dateValue !== this._value || !areDatesEqual) {
|
|
3249
|
+
this._value = dateValue || value;
|
|
3250
|
+
if (emitEvent) {
|
|
3251
|
+
this.onChange(this._value);
|
|
3252
|
+
}
|
|
3253
|
+
else {
|
|
3254
|
+
(_b = this.control) === null || _b === void 0 ? void 0 : _b.setValue(this._value, { emitEvent: false });
|
|
3255
|
+
}
|
|
3256
|
+
this.datepickerComponent.selectedDate = this._value;
|
|
3257
|
+
}
|
|
3258
|
+
if (dateValue && isValidDateString) {
|
|
3259
|
+
var formattedDate = this.dateFormatter.format(dateValue, this.dateFormat);
|
|
3260
|
+
this.setInputElementValue(formattedDate);
|
|
3261
|
+
}
|
|
3262
|
+
else {
|
|
3263
|
+
this.setInputElementValue(value || '');
|
|
3264
|
+
}
|
|
3243
3265
|
};
|
|
3244
|
-
return
|
|
3266
|
+
return SkyDatepickerInputDirective;
|
|
3245
3267
|
}());
|
|
3246
|
-
|
|
3247
|
-
|
|
3248
|
-
|
|
3249
|
-
|
|
3268
|
+
SkyDatepickerInputDirective.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: SkyDatepickerInputDirective, deps: [{ token: SkyDatepickerAdapterService }, { token: i0__namespace.ChangeDetectorRef }, { token: SkyDatepickerConfigService }, { token: i0__namespace.ElementRef }, { token: i3__namespace.SkyAppLocaleProvider }, { token: i0__namespace.Renderer2 }, { token: i3__namespace.SkyLibResourcesService }, { token: SkyDatepickerComponent, optional: true }], target: i0__namespace.ɵɵFactoryTarget.Directive });
|
|
3269
|
+
SkyDatepickerInputDirective.ɵdir = i0__namespace.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: SkyDatepickerInputDirective, selector: "[skyDatepickerInput]", inputs: { dateFormat: "dateFormat", disabled: "disabled", maxDate: "maxDate", minDate: "minDate", skyDatepickerInput: "skyDatepickerInput", skyDatepickerNoValidate: "skyDatepickerNoValidate", startingDay: "startingDay", strict: "strict" }, host: { listeners: { "change": "onInputChange($event)", "blur": "onInputBlur()", "keyup": "onInputKeyup()" } }, providers: [
|
|
3270
|
+
SKY_DATEPICKER_VALUE_ACCESSOR,
|
|
3271
|
+
SKY_DATEPICKER_VALIDATOR,
|
|
3272
|
+
SkyDatepickerAdapterService,
|
|
3250
3273
|
], ngImport: i0__namespace });
|
|
3251
|
-
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type:
|
|
3274
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: SkyDatepickerInputDirective, decorators: [{
|
|
3252
3275
|
type: i0.Directive,
|
|
3253
3276
|
args: [{
|
|
3254
|
-
selector: '[
|
|
3277
|
+
selector: '[skyDatepickerInput]',
|
|
3255
3278
|
providers: [
|
|
3256
|
-
|
|
3257
|
-
|
|
3279
|
+
SKY_DATEPICKER_VALUE_ACCESSOR,
|
|
3280
|
+
SKY_DATEPICKER_VALIDATOR,
|
|
3281
|
+
SkyDatepickerAdapterService,
|
|
3258
3282
|
],
|
|
3259
3283
|
}]
|
|
3260
3284
|
}], ctorParameters: function () {
|
|
3261
|
-
return [{ type:
|
|
3285
|
+
return [{ type: SkyDatepickerAdapterService }, { type: i0__namespace.ChangeDetectorRef }, { type: SkyDatepickerConfigService }, { type: i0__namespace.ElementRef }, { type: i3__namespace.SkyAppLocaleProvider }, { type: i0__namespace.Renderer2 }, { type: i3__namespace.SkyLibResourcesService }, { type: SkyDatepickerComponent, decorators: [{
|
|
3262
3286
|
type: i0.Optional
|
|
3263
3287
|
}] }];
|
|
3264
3288
|
}, propDecorators: { dateFormat: [{
|
|
3265
3289
|
type: i0.Input
|
|
3266
3290
|
}], disabled: [{
|
|
3267
3291
|
type: i0.Input
|
|
3268
|
-
}], futureDisabled: [{
|
|
3269
|
-
type: i0.Input
|
|
3270
3292
|
}], maxDate: [{
|
|
3271
3293
|
type: i0.Input
|
|
3272
3294
|
}], minDate: [{
|
|
3273
3295
|
type: i0.Input
|
|
3274
|
-
}],
|
|
3296
|
+
}], skyDatepickerInput: [{
|
|
3275
3297
|
type: i0.Input
|
|
3276
|
-
}],
|
|
3298
|
+
}], skyDatepickerNoValidate: [{
|
|
3277
3299
|
type: i0.Input
|
|
3278
3300
|
}], startingDay: [{
|
|
3279
3301
|
type: i0.Input
|
|
3280
|
-
}],
|
|
3302
|
+
}], strict: [{
|
|
3281
3303
|
type: i0.Input
|
|
3282
3304
|
}], onInputChange: [{
|
|
3283
3305
|
type: i0.HostListener,
|
|
@@ -3374,8 +3396,6 @@
|
|
|
3374
3396
|
* @dynamic
|
|
3375
3397
|
*/
|
|
3376
3398
|
var SkyDateRangeRelativeValue = /** @class */ (function () {
|
|
3377
|
-
// Abstract classes are not covered properly.
|
|
3378
|
-
/* istanbul ignore next */
|
|
3379
3399
|
function SkyDateRangeRelativeValue() {
|
|
3380
3400
|
}
|
|
3381
3401
|
Object.defineProperty(SkyDateRangeRelativeValue, "today", {
|
|
@@ -3954,13 +3974,14 @@
|
|
|
3954
3974
|
* ```
|
|
3955
3975
|
*/
|
|
3956
3976
|
var SkyDateRangePickerComponent = /** @class */ (function () {
|
|
3957
|
-
function SkyDateRangePickerComponent(changeDetector, dateRangeService, formBuilder, localeProvider, windowRef, themeSvc) {
|
|
3977
|
+
function SkyDateRangePickerComponent(changeDetector, dateRangeService, formBuilder, localeProvider, windowRef, ngZone, themeSvc) {
|
|
3958
3978
|
var _this = this;
|
|
3959
3979
|
this.changeDetector = changeDetector;
|
|
3960
3980
|
this.dateRangeService = dateRangeService;
|
|
3961
3981
|
this.formBuilder = formBuilder;
|
|
3962
3982
|
this.localeProvider = localeProvider;
|
|
3963
3983
|
this.windowRef = windowRef;
|
|
3984
|
+
this.ngZone = ngZone;
|
|
3964
3985
|
/**
|
|
3965
3986
|
* Indicates whether to require users to specify a start date.
|
|
3966
3987
|
* @default false
|
|
@@ -3977,11 +3998,11 @@
|
|
|
3977
3998
|
this.showStartDatePicker = false;
|
|
3978
3999
|
this.ngUnsubscribe = new rxjs.Subject();
|
|
3979
4000
|
this._disabled = false;
|
|
3980
|
-
|
|
4001
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
3981
4002
|
this.onChange = function (_) { };
|
|
3982
|
-
|
|
4003
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
3983
4004
|
this.onTouched = function () { };
|
|
3984
|
-
|
|
4005
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
3985
4006
|
this.onValidatorChange = function () { };
|
|
3986
4007
|
this.localeProvider
|
|
3987
4008
|
.getLocaleInfo()
|
|
@@ -4153,24 +4174,27 @@
|
|
|
4153
4174
|
this.updateCalculators().then(function () {
|
|
4154
4175
|
_this.addEventListeners();
|
|
4155
4176
|
_this.isReady = true;
|
|
4156
|
-
_this.resetFormGroupValue();
|
|
4157
4177
|
_this.showRelevantFormFields();
|
|
4158
|
-
//
|
|
4159
|
-
|
|
4160
|
-
|
|
4161
|
-
|
|
4162
|
-
|
|
4163
|
-
|
|
4164
|
-
|
|
4165
|
-
|
|
4166
|
-
|
|
4167
|
-
|
|
4168
|
-
|
|
4169
|
-
|
|
4170
|
-
|
|
4171
|
-
|
|
4172
|
-
|
|
4173
|
-
|
|
4178
|
+
// We need to let Angular be stable and have rendered the components prior to setting the values and form controls. This ensures all initial validation will be ran correctly.
|
|
4179
|
+
_this.ngZone.onStable.pipe(operators.first()).subscribe(function () {
|
|
4180
|
+
// Fill in any unprovided values after the calculators have been initialized.
|
|
4181
|
+
// For example, if the control is initialized with only the `calculatorId`,
|
|
4182
|
+
// allow the calculator to fill in the missing start and end dates.
|
|
4183
|
+
var _b = _this.value, startDate = _b.startDate, endDate = _b.endDate;
|
|
4184
|
+
var defaultValue = _this.selectedCalculator.getValue(startDate, endDate);
|
|
4185
|
+
var newValue = Object.assign({}, defaultValue, _this.value);
|
|
4186
|
+
_this.setValue(newValue, false);
|
|
4187
|
+
_this.resetFormGroupValue();
|
|
4188
|
+
// This is needed to address a bug in Angular 4.
|
|
4189
|
+
// When a control value is set intially, its value is not represented on the view.
|
|
4190
|
+
// See: https://github.com/angular/angular/issues/13792
|
|
4191
|
+
/* istanbul ignore else */
|
|
4192
|
+
if (_this.control) {
|
|
4193
|
+
_this.control.setValue(_this.value, {
|
|
4194
|
+
emitEvent: false,
|
|
4195
|
+
});
|
|
4196
|
+
}
|
|
4197
|
+
});
|
|
4174
4198
|
});
|
|
4175
4199
|
};
|
|
4176
4200
|
SkyDateRangePickerComponent.prototype.ngOnChanges = function (changes) {
|
|
@@ -4311,47 +4335,27 @@
|
|
|
4311
4335
|
this.changeDetector.markForCheck();
|
|
4312
4336
|
};
|
|
4313
4337
|
SkyDateRangePickerComponent.prototype.resetFormGroupValue = function (value) {
|
|
4314
|
-
|
|
4315
|
-
// because we're already watching for changes that are triggered by the end user.
|
|
4316
|
-
// For example, if we change the value of the form group internally, we don't want the event
|
|
4317
|
-
// listeners to be triggered, as those are reserved for user interactions.
|
|
4318
|
-
// (See the event listeners listed below.)
|
|
4319
|
-
this.formGroup.reset(value || this.value, {
|
|
4320
|
-
emitEvent: false,
|
|
4321
|
-
});
|
|
4338
|
+
this.formGroup.reset(value || this.value);
|
|
4322
4339
|
};
|
|
4323
4340
|
SkyDateRangePickerComponent.prototype.addEventListeners = function () {
|
|
4324
4341
|
var _this = this;
|
|
4325
|
-
// Detect errors from the date pickers
|
|
4326
|
-
// when control is initialized with a value.
|
|
4327
|
-
rxjs.combineLatest([
|
|
4328
|
-
this.startDateControl.statusChanges,
|
|
4329
|
-
this.endDateControl.statusChanges,
|
|
4330
|
-
])
|
|
4331
|
-
.pipe(operators.first())
|
|
4332
|
-
.subscribe(function (status) {
|
|
4333
|
-
if (status.indexOf('INVALID') > -1) {
|
|
4334
|
-
// Wait for initial validation to complete.
|
|
4335
|
-
_this.windowRef.nativeWindow.setTimeout(function () {
|
|
4336
|
-
_this.onValidatorChange();
|
|
4337
|
-
});
|
|
4338
|
-
}
|
|
4339
|
-
});
|
|
4340
4342
|
// Watch for selected calculator change.
|
|
4341
4343
|
this.calculatorIdControl.valueChanges
|
|
4342
4344
|
.pipe(operators.takeUntil(this.ngUnsubscribe))
|
|
4343
4345
|
.subscribe(function (value) {
|
|
4344
|
-
|
|
4345
|
-
|
|
4346
|
-
|
|
4347
|
-
|
|
4348
|
-
|
|
4349
|
-
|
|
4350
|
-
|
|
4351
|
-
|
|
4352
|
-
|
|
4353
|
-
|
|
4354
|
-
|
|
4346
|
+
if (value !== _this.value.calculatorId) {
|
|
4347
|
+
var id = parseInt(value, 10);
|
|
4348
|
+
// if the component is disabled during form creation, null is passed
|
|
4349
|
+
// as the value of the calculator id control
|
|
4350
|
+
// only handle the value changes if the calculator id is a number
|
|
4351
|
+
/* istanbul ignore else */
|
|
4352
|
+
if (!isNaN(id)) {
|
|
4353
|
+
var calculator = _this.getCalculatorById(id);
|
|
4354
|
+
var newValue = calculator.getValue();
|
|
4355
|
+
_this.setValue(newValue);
|
|
4356
|
+
_this.resetFormGroupValue(newValue);
|
|
4357
|
+
_this.showRelevantFormFields();
|
|
4358
|
+
}
|
|
4355
4359
|
}
|
|
4356
4360
|
});
|
|
4357
4361
|
// Watch for start date value changes.
|
|
@@ -4374,6 +4378,11 @@
|
|
|
4374
4378
|
.pipe(operators.takeUntil(this.ngUnsubscribe))
|
|
4375
4379
|
.subscribe(function () {
|
|
4376
4380
|
_this.changeDetector.markForCheck();
|
|
4381
|
+
// Wait for initial validation to complete.
|
|
4382
|
+
_this.ngZone.onStable.pipe(operators.first()).subscribe(function () {
|
|
4383
|
+
var _a;
|
|
4384
|
+
(_a = _this.control) === null || _a === void 0 ? void 0 : _a.updateValueAndValidity({ emitEvent: false });
|
|
4385
|
+
});
|
|
4377
4386
|
});
|
|
4378
4387
|
};
|
|
4379
4388
|
SkyDateRangePickerComponent.prototype.updateCalculators = function () {
|
|
@@ -4395,7 +4404,7 @@
|
|
|
4395
4404
|
};
|
|
4396
4405
|
return SkyDateRangePickerComponent;
|
|
4397
4406
|
}());
|
|
4398
|
-
SkyDateRangePickerComponent.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: SkyDateRangePickerComponent, deps: [{ token: i0__namespace.ChangeDetectorRef }, { token: SkyDateRangeService }, { token: i2__namespace$2.FormBuilder }, { token: i3__namespace.SkyAppLocaleProvider }, { token: i1__namespace.SkyAppWindowRef }, { token: i3__namespace$2.SkyThemeService, optional: true }], target: i0__namespace.ɵɵFactoryTarget.Component });
|
|
4407
|
+
SkyDateRangePickerComponent.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: SkyDateRangePickerComponent, deps: [{ token: i0__namespace.ChangeDetectorRef }, { token: SkyDateRangeService }, { token: i2__namespace$2.FormBuilder }, { token: i3__namespace.SkyAppLocaleProvider }, { token: i1__namespace.SkyAppWindowRef }, { token: i0__namespace.NgZone }, { token: i3__namespace$2.SkyThemeService, optional: true }], target: i0__namespace.ɵɵFactoryTarget.Component });
|
|
4399
4408
|
SkyDateRangePickerComponent.ɵcmp = i0__namespace.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.16", type: SkyDateRangePickerComponent, selector: "sky-date-range-picker", inputs: { calculatorIds: "calculatorIds", dateFormat: "dateFormat", disabled: "disabled", label: "label", startDateRequired: "startDateRequired", endDateRequired: "endDateRequired" }, providers: [
|
|
4400
4409
|
SKY_DATE_RANGE_PICKER_VALUE_ACCESSOR,
|
|
4401
4410
|
SKY_DATE_RANGE_PICKER_VALIDATOR,
|
|
@@ -4413,7 +4422,7 @@
|
|
|
4413
4422
|
changeDetection: i0.ChangeDetectionStrategy.OnPush,
|
|
4414
4423
|
}]
|
|
4415
4424
|
}], ctorParameters: function () {
|
|
4416
|
-
return [{ type: i0__namespace.ChangeDetectorRef }, { type: SkyDateRangeService }, { type: i2__namespace$2.FormBuilder }, { type: i3__namespace.SkyAppLocaleProvider }, { type: i1__namespace.SkyAppWindowRef }, { type: i3__namespace$2.SkyThemeService, decorators: [{
|
|
4425
|
+
return [{ type: i0__namespace.ChangeDetectorRef }, { type: SkyDateRangeService }, { type: i2__namespace$2.FormBuilder }, { type: i3__namespace.SkyAppLocaleProvider }, { type: i1__namespace.SkyAppWindowRef }, { type: i0__namespace.NgZone }, { type: i3__namespace$2.SkyThemeService, decorators: [{
|
|
4417
4426
|
type: i0.Optional
|
|
4418
4427
|
}] }];
|
|
4419
4428
|
}, propDecorators: { calculatorIds: [{
|
|
@@ -4470,245 +4479,323 @@
|
|
|
4470
4479
|
}]
|
|
4471
4480
|
}] });
|
|
4472
4481
|
|
|
4473
|
-
|
|
4474
|
-
|
|
4475
|
-
|
|
4476
|
-
|
|
4477
|
-
|
|
4478
|
-
|
|
4479
|
-
|
|
4480
|
-
|
|
4481
|
-
|
|
4482
|
-
|
|
4482
|
+
/*! *****************************************************************************
|
|
4483
|
+
Copyright (c) Microsoft Corporation.
|
|
4484
|
+
|
|
4485
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
4486
|
+
purpose with or without fee is hereby granted.
|
|
4487
|
+
|
|
4488
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
4489
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
4490
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
4491
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
4492
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
4493
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
4494
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
4495
|
+
***************************************************************************** */
|
|
4496
|
+
/* global Reflect, Promise */
|
|
4497
|
+
var extendStatics = function (d, b) {
|
|
4498
|
+
extendStatics = Object.setPrototypeOf ||
|
|
4499
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
4500
|
+
function (d, b) { for (var p in b)
|
|
4501
|
+
if (Object.prototype.hasOwnProperty.call(b, p))
|
|
4502
|
+
d[p] = b[p]; };
|
|
4503
|
+
return extendStatics(d, b);
|
|
4483
4504
|
};
|
|
4484
|
-
|
|
4485
|
-
|
|
4486
|
-
|
|
4487
|
-
|
|
4488
|
-
|
|
4489
|
-
|
|
4490
|
-
|
|
4491
|
-
|
|
4492
|
-
|
|
4493
|
-
|
|
4494
|
-
|
|
4495
|
-
|
|
4496
|
-
|
|
4497
|
-
|
|
4498
|
-
}
|
|
4499
|
-
Object.defineProperty(SkyTimepickerInputDirective.prototype, "skyTimepickerInput", {
|
|
4500
|
-
/**
|
|
4501
|
-
* Creates the timepicker input field and picker. Place this attribute on an `input` element,
|
|
4502
|
-
* and wrap the input in a `sky-timepicker` component.
|
|
4503
|
-
* This attribute must be set to the instance of the `sky-timepicker`.
|
|
4504
|
-
* @required
|
|
4505
|
-
*/
|
|
4506
|
-
get: function () {
|
|
4507
|
-
return this._skyTimepickerInput;
|
|
4508
|
-
},
|
|
4509
|
-
set: function (value) {
|
|
4510
|
-
this._skyTimepickerInput = value;
|
|
4511
|
-
this.updateTimepickerInput();
|
|
4512
|
-
},
|
|
4513
|
-
enumerable: false,
|
|
4514
|
-
configurable: true
|
|
4515
|
-
});
|
|
4516
|
-
Object.defineProperty(SkyTimepickerInputDirective.prototype, "timeFormat", {
|
|
4517
|
-
get: function () {
|
|
4518
|
-
return this._timeFormat || 'hh';
|
|
4519
|
-
},
|
|
4520
|
-
/**
|
|
4521
|
-
* Specifies the 12-hour `hh` or 24-hour `HH` time format for the input.
|
|
4522
|
-
* @default "hh"
|
|
4523
|
-
*/
|
|
4524
|
-
set: function (value) {
|
|
4525
|
-
this._timeFormat = value;
|
|
4526
|
-
},
|
|
4527
|
-
enumerable: false,
|
|
4528
|
-
configurable: true
|
|
4529
|
-
});
|
|
4530
|
-
Object.defineProperty(SkyTimepickerInputDirective.prototype, "disabled", {
|
|
4531
|
-
/**
|
|
4532
|
-
* Indicates whether to disable the timepicker.
|
|
4533
|
-
* @default false
|
|
4534
|
-
*/
|
|
4535
|
-
get: function () {
|
|
4536
|
-
return this._disabled || false;
|
|
4537
|
-
},
|
|
4538
|
-
set: function (value) {
|
|
4539
|
-
this._disabled = value;
|
|
4540
|
-
this.updateTimepickerInput();
|
|
4541
|
-
this.renderer.setProperty(this.elRef.nativeElement, 'disabled', value);
|
|
4542
|
-
},
|
|
4543
|
-
enumerable: false,
|
|
4544
|
-
configurable: true
|
|
4545
|
-
});
|
|
4546
|
-
Object.defineProperty(SkyTimepickerInputDirective.prototype, "modelValue", {
|
|
4547
|
-
get: function () {
|
|
4548
|
-
return this._modelValue;
|
|
4549
|
-
},
|
|
4550
|
-
set: function (value) {
|
|
4551
|
-
if (value !== this._modelValue) {
|
|
4552
|
-
this._modelValue = value;
|
|
4553
|
-
this.updateTimepickerInput();
|
|
4554
|
-
this.setInputValue(value);
|
|
4555
|
-
this._validatorChange();
|
|
4556
|
-
this._onChange(value);
|
|
4557
|
-
}
|
|
4558
|
-
},
|
|
4559
|
-
enumerable: false,
|
|
4560
|
-
configurable: true
|
|
4561
|
-
});
|
|
4562
|
-
SkyTimepickerInputDirective.prototype.ngOnInit = function () {
|
|
4563
|
-
var _this = this;
|
|
4564
|
-
this.renderer.addClass(this.elRef.nativeElement, 'sky-form-control');
|
|
4565
|
-
this.pickerChangedSubscription =
|
|
4566
|
-
this.skyTimepickerInput.selectedTimeChanged.subscribe(function (newTime) {
|
|
4567
|
-
_this.writeValue(newTime);
|
|
4568
|
-
_this._onTouched();
|
|
4569
|
-
});
|
|
4570
|
-
/* istanbul ignore else */
|
|
4571
|
-
if (!this.elRef.nativeElement.getAttribute('aria-label')) {
|
|
4572
|
-
this.resourcesService
|
|
4573
|
-
.getString('skyux_timepicker_input_default_label')
|
|
4574
|
-
.subscribe(function (value) {
|
|
4575
|
-
_this.renderer.setAttribute(_this.elRef.nativeElement, 'aria-label', value);
|
|
4576
|
-
});
|
|
4577
|
-
}
|
|
4578
|
-
};
|
|
4579
|
-
SkyTimepickerInputDirective.prototype.ngAfterContentInit = function () {
|
|
4580
|
-
// Watch for the control to be added and initialize the value immediately.
|
|
4581
|
-
/* istanbul ignore else */
|
|
4582
|
-
if (this.control && this.control.parent) {
|
|
4583
|
-
this.control.setValue(this.modelValue, {
|
|
4584
|
-
emitEvent: false,
|
|
4585
|
-
});
|
|
4586
|
-
this.changeDetector.markForCheck();
|
|
4587
|
-
}
|
|
4588
|
-
};
|
|
4589
|
-
SkyTimepickerInputDirective.prototype.ngOnDestroy = function () {
|
|
4590
|
-
this.pickerChangedSubscription.unsubscribe();
|
|
4591
|
-
};
|
|
4592
|
-
SkyTimepickerInputDirective.prototype.ngOnChanges = function () {
|
|
4593
|
-
this.skyTimepickerInput.setFormat(this.timeFormat);
|
|
4594
|
-
this.skyTimepickerInput.returnFormat = this.returnFormat;
|
|
4595
|
-
};
|
|
4596
|
-
SkyTimepickerInputDirective.prototype.onChange = function (event) {
|
|
4597
|
-
this.writeValue(event.target.value);
|
|
4598
|
-
};
|
|
4599
|
-
/* istanbul ignore next */
|
|
4600
|
-
SkyTimepickerInputDirective.prototype.onBlur = function () {
|
|
4601
|
-
this._onTouched();
|
|
4602
|
-
};
|
|
4603
|
-
SkyTimepickerInputDirective.prototype.registerOnChange = function (fn) {
|
|
4604
|
-
this._onChange = fn;
|
|
4605
|
-
};
|
|
4606
|
-
SkyTimepickerInputDirective.prototype.registerOnTouched = function (fn) {
|
|
4607
|
-
this._onTouched = fn;
|
|
4608
|
-
};
|
|
4609
|
-
SkyTimepickerInputDirective.prototype.registerOnValidatorChange = function (fn) {
|
|
4610
|
-
this._validatorChange = fn;
|
|
4611
|
-
};
|
|
4612
|
-
SkyTimepickerInputDirective.prototype.setDisabledState = function (isDisabled) {
|
|
4613
|
-
this.disabled = isDisabled;
|
|
4614
|
-
};
|
|
4615
|
-
SkyTimepickerInputDirective.prototype.writeValue = function (value) {
|
|
4616
|
-
this.modelValue = this.formatter(value);
|
|
4617
|
-
};
|
|
4618
|
-
SkyTimepickerInputDirective.prototype.validate = function (control) {
|
|
4619
|
-
if (!this.control) {
|
|
4620
|
-
this.control = control;
|
|
4621
|
-
}
|
|
4622
|
-
var value = control.value;
|
|
4623
|
-
if (!value) {
|
|
4624
|
-
return undefined;
|
|
4625
|
-
}
|
|
4626
|
-
/* istanbul ignore next */
|
|
4627
|
-
if (value.local === 'Invalid date') {
|
|
4628
|
-
return {
|
|
4629
|
-
skyTime: {
|
|
4630
|
-
invalid: control.value,
|
|
4631
|
-
},
|
|
4632
|
-
};
|
|
4633
|
-
}
|
|
4634
|
-
return undefined;
|
|
4635
|
-
};
|
|
4636
|
-
SkyTimepickerInputDirective.prototype.setInputValue = function (value) {
|
|
4637
|
-
var formattedValue = '';
|
|
4638
|
-
if (value) {
|
|
4639
|
-
var output = moment__default["default"](value).format(value.customFormat);
|
|
4640
|
-
/* istanbul ignore else */
|
|
4641
|
-
if (output !== 'Invalid date') {
|
|
4642
|
-
formattedValue = output;
|
|
4643
|
-
}
|
|
4505
|
+
function __extends(d, b) {
|
|
4506
|
+
if (typeof b !== "function" && b !== null)
|
|
4507
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
4508
|
+
extendStatics(d, b);
|
|
4509
|
+
function __() { this.constructor = d; }
|
|
4510
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
4511
|
+
}
|
|
4512
|
+
var __assign = function () {
|
|
4513
|
+
__assign = Object.assign || function __assign(t) {
|
|
4514
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4515
|
+
s = arguments[i];
|
|
4516
|
+
for (var p in s)
|
|
4517
|
+
if (Object.prototype.hasOwnProperty.call(s, p))
|
|
4518
|
+
t[p] = s[p];
|
|
4644
4519
|
}
|
|
4645
|
-
|
|
4520
|
+
return t;
|
|
4646
4521
|
};
|
|
4647
|
-
|
|
4648
|
-
|
|
4649
|
-
|
|
4650
|
-
|
|
4651
|
-
|
|
4652
|
-
|
|
4653
|
-
|
|
4654
|
-
|
|
4655
|
-
|
|
4656
|
-
|
|
4657
|
-
|
|
4658
|
-
|
|
4522
|
+
return __assign.apply(this, arguments);
|
|
4523
|
+
};
|
|
4524
|
+
function __rest(s, e) {
|
|
4525
|
+
var t = {};
|
|
4526
|
+
for (var p in s)
|
|
4527
|
+
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4528
|
+
t[p] = s[p];
|
|
4529
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
4530
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
4531
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
4532
|
+
t[p[i]] = s[p[i]];
|
|
4533
|
+
}
|
|
4534
|
+
return t;
|
|
4535
|
+
}
|
|
4536
|
+
function __decorate(decorators, target, key, desc) {
|
|
4537
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4538
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
4539
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
4540
|
+
else
|
|
4541
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
4542
|
+
if (d = decorators[i])
|
|
4543
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
4544
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4545
|
+
}
|
|
4546
|
+
function __param(paramIndex, decorator) {
|
|
4547
|
+
return function (target, key) { decorator(target, key, paramIndex); };
|
|
4548
|
+
}
|
|
4549
|
+
function __metadata(metadataKey, metadataValue) {
|
|
4550
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
4551
|
+
return Reflect.metadata(metadataKey, metadataValue);
|
|
4552
|
+
}
|
|
4553
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
4554
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4555
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4556
|
+
function fulfilled(value) { try {
|
|
4557
|
+
step(generator.next(value));
|
|
4558
|
+
}
|
|
4559
|
+
catch (e) {
|
|
4560
|
+
reject(e);
|
|
4561
|
+
} }
|
|
4562
|
+
function rejected(value) { try {
|
|
4563
|
+
step(generator["throw"](value));
|
|
4564
|
+
}
|
|
4565
|
+
catch (e) {
|
|
4566
|
+
reject(e);
|
|
4567
|
+
} }
|
|
4568
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
4569
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
4570
|
+
});
|
|
4571
|
+
}
|
|
4572
|
+
function __generator(thisArg, body) {
|
|
4573
|
+
var _ = { label: 0, sent: function () { if (t[0] & 1)
|
|
4574
|
+
throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
4575
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g;
|
|
4576
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
4577
|
+
function step(op) {
|
|
4578
|
+
if (f)
|
|
4579
|
+
throw new TypeError("Generator is already executing.");
|
|
4580
|
+
while (_)
|
|
4581
|
+
try {
|
|
4582
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
|
|
4583
|
+
return t;
|
|
4584
|
+
if (y = 0, t)
|
|
4585
|
+
op = [op[0] & 2, t.value];
|
|
4586
|
+
switch (op[0]) {
|
|
4587
|
+
case 0:
|
|
4588
|
+
case 1:
|
|
4589
|
+
t = op;
|
|
4590
|
+
break;
|
|
4591
|
+
case 4:
|
|
4592
|
+
_.label++;
|
|
4593
|
+
return { value: op[1], done: false };
|
|
4594
|
+
case 5:
|
|
4595
|
+
_.label++;
|
|
4596
|
+
y = op[1];
|
|
4597
|
+
op = [0];
|
|
4598
|
+
continue;
|
|
4599
|
+
case 7:
|
|
4600
|
+
op = _.ops.pop();
|
|
4601
|
+
_.trys.pop();
|
|
4602
|
+
continue;
|
|
4603
|
+
default:
|
|
4604
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
4605
|
+
_ = 0;
|
|
4606
|
+
continue;
|
|
4607
|
+
}
|
|
4608
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
|
|
4609
|
+
_.label = op[1];
|
|
4610
|
+
break;
|
|
4611
|
+
}
|
|
4612
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
4613
|
+
_.label = t[1];
|
|
4614
|
+
t = op;
|
|
4615
|
+
break;
|
|
4616
|
+
}
|
|
4617
|
+
if (t && _.label < t[2]) {
|
|
4618
|
+
_.label = t[2];
|
|
4619
|
+
_.ops.push(op);
|
|
4620
|
+
break;
|
|
4621
|
+
}
|
|
4622
|
+
if (t[2])
|
|
4623
|
+
_.ops.pop();
|
|
4624
|
+
_.trys.pop();
|
|
4625
|
+
continue;
|
|
4626
|
+
}
|
|
4627
|
+
op = body.call(thisArg, _);
|
|
4659
4628
|
}
|
|
4660
|
-
|
|
4661
|
-
|
|
4629
|
+
catch (e) {
|
|
4630
|
+
op = [6, e];
|
|
4631
|
+
y = 0;
|
|
4662
4632
|
}
|
|
4663
|
-
|
|
4664
|
-
|
|
4633
|
+
finally {
|
|
4634
|
+
f = t = 0;
|
|
4665
4635
|
}
|
|
4666
|
-
|
|
4667
|
-
|
|
4668
|
-
|
|
4669
|
-
|
|
4670
|
-
|
|
4671
|
-
|
|
4672
|
-
|
|
4673
|
-
|
|
4674
|
-
|
|
4675
|
-
|
|
4676
|
-
|
|
4677
|
-
|
|
4678
|
-
|
|
4679
|
-
|
|
4680
|
-
|
|
4681
|
-
|
|
4682
|
-
|
|
4683
|
-
|
|
4636
|
+
if (op[0] & 5)
|
|
4637
|
+
throw op[1];
|
|
4638
|
+
return { value: op[0] ? op[1] : void 0, done: true };
|
|
4639
|
+
}
|
|
4640
|
+
}
|
|
4641
|
+
var __createBinding = Object.create ? (function (o, m, k, k2) {
|
|
4642
|
+
if (k2 === undefined)
|
|
4643
|
+
k2 = k;
|
|
4644
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function () { return m[k]; } });
|
|
4645
|
+
}) : (function (o, m, k, k2) {
|
|
4646
|
+
if (k2 === undefined)
|
|
4647
|
+
k2 = k;
|
|
4648
|
+
o[k2] = m[k];
|
|
4649
|
+
});
|
|
4650
|
+
function __exportStar(m, o) {
|
|
4651
|
+
for (var p in m)
|
|
4652
|
+
if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p))
|
|
4653
|
+
__createBinding(o, m, p);
|
|
4654
|
+
}
|
|
4655
|
+
function __values(o) {
|
|
4656
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
4657
|
+
if (m)
|
|
4658
|
+
return m.call(o);
|
|
4659
|
+
if (o && typeof o.length === "number")
|
|
4660
|
+
return {
|
|
4661
|
+
next: function () {
|
|
4662
|
+
if (o && i >= o.length)
|
|
4663
|
+
o = void 0;
|
|
4664
|
+
return { value: o && o[i++], done: !o };
|
|
4684
4665
|
}
|
|
4666
|
+
};
|
|
4667
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
4668
|
+
}
|
|
4669
|
+
function __read(o, n) {
|
|
4670
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
4671
|
+
if (!m)
|
|
4672
|
+
return o;
|
|
4673
|
+
var i = m.call(o), r, ar = [], e;
|
|
4674
|
+
try {
|
|
4675
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
|
|
4676
|
+
ar.push(r.value);
|
|
4677
|
+
}
|
|
4678
|
+
catch (error) {
|
|
4679
|
+
e = { error: error };
|
|
4680
|
+
}
|
|
4681
|
+
finally {
|
|
4682
|
+
try {
|
|
4683
|
+
if (r && !r.done && (m = i["return"]))
|
|
4684
|
+
m.call(i);
|
|
4685
4685
|
}
|
|
4686
|
-
|
|
4687
|
-
|
|
4688
|
-
|
|
4689
|
-
|
|
4690
|
-
|
|
4691
|
-
|
|
4692
|
-
|
|
4693
|
-
|
|
4694
|
-
|
|
4695
|
-
|
|
4696
|
-
|
|
4697
|
-
|
|
4698
|
-
|
|
4699
|
-
|
|
4700
|
-
|
|
4701
|
-
|
|
4702
|
-
|
|
4703
|
-
|
|
4704
|
-
|
|
4705
|
-
|
|
4706
|
-
|
|
4707
|
-
|
|
4708
|
-
|
|
4709
|
-
|
|
4710
|
-
|
|
4711
|
-
|
|
4686
|
+
finally {
|
|
4687
|
+
if (e)
|
|
4688
|
+
throw e.error;
|
|
4689
|
+
}
|
|
4690
|
+
}
|
|
4691
|
+
return ar;
|
|
4692
|
+
}
|
|
4693
|
+
/** @deprecated */
|
|
4694
|
+
function __spread() {
|
|
4695
|
+
for (var ar = [], i = 0; i < arguments.length; i++)
|
|
4696
|
+
ar = ar.concat(__read(arguments[i]));
|
|
4697
|
+
return ar;
|
|
4698
|
+
}
|
|
4699
|
+
/** @deprecated */
|
|
4700
|
+
function __spreadArrays() {
|
|
4701
|
+
for (var s = 0, i = 0, il = arguments.length; i < il; i++)
|
|
4702
|
+
s += arguments[i].length;
|
|
4703
|
+
for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
|
4704
|
+
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
|
4705
|
+
r[k] = a[j];
|
|
4706
|
+
return r;
|
|
4707
|
+
}
|
|
4708
|
+
function __spreadArray(to, from, pack) {
|
|
4709
|
+
if (pack || arguments.length === 2)
|
|
4710
|
+
for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
4711
|
+
if (ar || !(i in from)) {
|
|
4712
|
+
if (!ar)
|
|
4713
|
+
ar = Array.prototype.slice.call(from, 0, i);
|
|
4714
|
+
ar[i] = from[i];
|
|
4715
|
+
}
|
|
4716
|
+
}
|
|
4717
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
4718
|
+
}
|
|
4719
|
+
function __await(v) {
|
|
4720
|
+
return this instanceof __await ? (this.v = v, this) : new __await(v);
|
|
4721
|
+
}
|
|
4722
|
+
function __asyncGenerator(thisArg, _arguments, generator) {
|
|
4723
|
+
if (!Symbol.asyncIterator)
|
|
4724
|
+
throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
4725
|
+
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
|
4726
|
+
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
|
|
4727
|
+
function verb(n) { if (g[n])
|
|
4728
|
+
i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
|
|
4729
|
+
function resume(n, v) { try {
|
|
4730
|
+
step(g[n](v));
|
|
4731
|
+
}
|
|
4732
|
+
catch (e) {
|
|
4733
|
+
settle(q[0][3], e);
|
|
4734
|
+
} }
|
|
4735
|
+
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
|
4736
|
+
function fulfill(value) { resume("next", value); }
|
|
4737
|
+
function reject(value) { resume("throw", value); }
|
|
4738
|
+
function settle(f, v) { if (f(v), q.shift(), q.length)
|
|
4739
|
+
resume(q[0][0], q[0][1]); }
|
|
4740
|
+
}
|
|
4741
|
+
function __asyncDelegator(o) {
|
|
4742
|
+
var i, p;
|
|
4743
|
+
return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
|
|
4744
|
+
function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
|
|
4745
|
+
}
|
|
4746
|
+
function __asyncValues(o) {
|
|
4747
|
+
if (!Symbol.asyncIterator)
|
|
4748
|
+
throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
4749
|
+
var m = o[Symbol.asyncIterator], i;
|
|
4750
|
+
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
|
4751
|
+
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
|
4752
|
+
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function (v) { resolve({ value: v, done: d }); }, reject); }
|
|
4753
|
+
}
|
|
4754
|
+
function __makeTemplateObject(cooked, raw) {
|
|
4755
|
+
if (Object.defineProperty) {
|
|
4756
|
+
Object.defineProperty(cooked, "raw", { value: raw });
|
|
4757
|
+
}
|
|
4758
|
+
else {
|
|
4759
|
+
cooked.raw = raw;
|
|
4760
|
+
}
|
|
4761
|
+
return cooked;
|
|
4762
|
+
}
|
|
4763
|
+
;
|
|
4764
|
+
var __setModuleDefault = Object.create ? (function (o, v) {
|
|
4765
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
4766
|
+
}) : function (o, v) {
|
|
4767
|
+
o["default"] = v;
|
|
4768
|
+
};
|
|
4769
|
+
function __importStar(mod) {
|
|
4770
|
+
if (mod && mod.__esModule)
|
|
4771
|
+
return mod;
|
|
4772
|
+
var result = {};
|
|
4773
|
+
if (mod != null)
|
|
4774
|
+
for (var k in mod)
|
|
4775
|
+
if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
|
|
4776
|
+
__createBinding(result, mod, k);
|
|
4777
|
+
__setModuleDefault(result, mod);
|
|
4778
|
+
return result;
|
|
4779
|
+
}
|
|
4780
|
+
function __importDefault(mod) {
|
|
4781
|
+
return (mod && mod.__esModule) ? mod : { default: mod };
|
|
4782
|
+
}
|
|
4783
|
+
function __classPrivateFieldGet(receiver, state, kind, f) {
|
|
4784
|
+
if (kind === "a" && !f)
|
|
4785
|
+
throw new TypeError("Private accessor was defined without a getter");
|
|
4786
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
|
4787
|
+
throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
4788
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
4789
|
+
}
|
|
4790
|
+
function __classPrivateFieldSet(receiver, state, value, kind, f) {
|
|
4791
|
+
if (kind === "m")
|
|
4792
|
+
throw new TypeError("Private method is not writable");
|
|
4793
|
+
if (kind === "a" && !f)
|
|
4794
|
+
throw new TypeError("Private accessor was defined without a setter");
|
|
4795
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
|
4796
|
+
throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
4797
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
4798
|
+
}
|
|
4712
4799
|
|
|
4713
4800
|
var nextId = 0;
|
|
4714
4801
|
/**
|
|
@@ -4763,7 +4850,6 @@
|
|
|
4763
4850
|
}
|
|
4764
4851
|
},
|
|
4765
4852
|
set: function (setHour) {
|
|
4766
|
-
var hour;
|
|
4767
4853
|
var hourOffset = 0;
|
|
4768
4854
|
if (this.selectedMeridies === 'AM' && setHour === 12) {
|
|
4769
4855
|
hourOffset = -12;
|
|
@@ -4774,7 +4860,7 @@
|
|
|
4774
4860
|
if (this.is8601) {
|
|
4775
4861
|
hourOffset = 0;
|
|
4776
4862
|
}
|
|
4777
|
-
hour = moment__default["default"]({ hour: setHour }).add(hourOffset, 'hours').hour();
|
|
4863
|
+
var hour = moment__default["default"]({ hour: setHour }).add(hourOffset, 'hours').hour();
|
|
4778
4864
|
this.activeTime = moment__default["default"]({
|
|
4779
4865
|
hour: hour,
|
|
4780
4866
|
minute: moment__default["default"](this.activeTime).get('minute') + 0,
|
|
@@ -4904,9 +4990,9 @@
|
|
|
4904
4990
|
localeFormat = 'HH:mm';
|
|
4905
4991
|
this.is8601 = true;
|
|
4906
4992
|
}
|
|
4907
|
-
var data
|
|
4908
|
-
|
|
4909
|
-
hours: Array.apply(
|
|
4993
|
+
var data = {
|
|
4994
|
+
// Create a sparse array with a length equal to the hour.
|
|
4995
|
+
hours: Array.apply(void 0, __spreadArray([], __read(Array(h)))).map(function (_, i) {
|
|
4910
4996
|
if (format === 'hh') {
|
|
4911
4997
|
return ++i;
|
|
4912
4998
|
}
|
|
@@ -4918,7 +5004,8 @@
|
|
|
4918
5004
|
/* sanity check */
|
|
4919
5005
|
return 0;
|
|
4920
5006
|
}),
|
|
4921
|
-
|
|
5007
|
+
// Create a sparse array with a length equal to the minute.
|
|
5008
|
+
minutes: Array.apply(void 0, __spreadArray([], __read(Array(m)))).map(function (_, i) {
|
|
4922
5009
|
return i * minuteMultiplier;
|
|
4923
5010
|
}),
|
|
4924
5011
|
localeFormat: localeFormat,
|
|
@@ -5095,6 +5182,245 @@
|
|
|
5095
5182
|
}]
|
|
5096
5183
|
}] } });
|
|
5097
5184
|
|
|
5185
|
+
// tslint:disable:no-forward-ref no-use-before-declare
|
|
5186
|
+
var SKY_TIMEPICKER_VALUE_ACCESSOR = {
|
|
5187
|
+
provide: i2$2.NG_VALUE_ACCESSOR,
|
|
5188
|
+
useExisting: i0.forwardRef(function () { return SkyTimepickerInputDirective; }),
|
|
5189
|
+
multi: true,
|
|
5190
|
+
};
|
|
5191
|
+
var SKY_TIMEPICKER_VALIDATOR = {
|
|
5192
|
+
provide: i2$2.NG_VALIDATORS,
|
|
5193
|
+
useExisting: i0.forwardRef(function () { return SkyTimepickerInputDirective; }),
|
|
5194
|
+
multi: true,
|
|
5195
|
+
};
|
|
5196
|
+
// tslint:enable
|
|
5197
|
+
var SkyTimepickerInputDirective = /** @class */ (function () {
|
|
5198
|
+
function SkyTimepickerInputDirective(renderer, elRef, resourcesService, changeDetector) {
|
|
5199
|
+
this.renderer = renderer;
|
|
5200
|
+
this.elRef = elRef;
|
|
5201
|
+
this.resourcesService = resourcesService;
|
|
5202
|
+
this.changeDetector = changeDetector;
|
|
5203
|
+
this._timeFormat = 'hh';
|
|
5204
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
5205
|
+
this._onChange = function (_) { };
|
|
5206
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
5207
|
+
this._onTouched = function () { };
|
|
5208
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
5209
|
+
this._validatorChange = function () { };
|
|
5210
|
+
}
|
|
5211
|
+
Object.defineProperty(SkyTimepickerInputDirective.prototype, "skyTimepickerInput", {
|
|
5212
|
+
/**
|
|
5213
|
+
* Creates the timepicker input field and picker. Place this attribute on an `input` element,
|
|
5214
|
+
* and wrap the input in a `sky-timepicker` component.
|
|
5215
|
+
* This attribute must be set to the instance of the `sky-timepicker`.
|
|
5216
|
+
* @required
|
|
5217
|
+
*/
|
|
5218
|
+
get: function () {
|
|
5219
|
+
return this._skyTimepickerInput;
|
|
5220
|
+
},
|
|
5221
|
+
set: function (value) {
|
|
5222
|
+
this._skyTimepickerInput = value;
|
|
5223
|
+
this.updateTimepickerInput();
|
|
5224
|
+
},
|
|
5225
|
+
enumerable: false,
|
|
5226
|
+
configurable: true
|
|
5227
|
+
});
|
|
5228
|
+
Object.defineProperty(SkyTimepickerInputDirective.prototype, "timeFormat", {
|
|
5229
|
+
get: function () {
|
|
5230
|
+
return this._timeFormat || 'hh';
|
|
5231
|
+
},
|
|
5232
|
+
/**
|
|
5233
|
+
* Specifies the 12-hour `hh` or 24-hour `HH` time format for the input.
|
|
5234
|
+
* @default "hh"
|
|
5235
|
+
*/
|
|
5236
|
+
set: function (value) {
|
|
5237
|
+
this._timeFormat = value;
|
|
5238
|
+
},
|
|
5239
|
+
enumerable: false,
|
|
5240
|
+
configurable: true
|
|
5241
|
+
});
|
|
5242
|
+
Object.defineProperty(SkyTimepickerInputDirective.prototype, "disabled", {
|
|
5243
|
+
/**
|
|
5244
|
+
* Indicates whether to disable the timepicker.
|
|
5245
|
+
* @default false
|
|
5246
|
+
*/
|
|
5247
|
+
get: function () {
|
|
5248
|
+
return this._disabled || false;
|
|
5249
|
+
},
|
|
5250
|
+
set: function (value) {
|
|
5251
|
+
this._disabled = value;
|
|
5252
|
+
this.updateTimepickerInput();
|
|
5253
|
+
this.renderer.setProperty(this.elRef.nativeElement, 'disabled', value);
|
|
5254
|
+
},
|
|
5255
|
+
enumerable: false,
|
|
5256
|
+
configurable: true
|
|
5257
|
+
});
|
|
5258
|
+
Object.defineProperty(SkyTimepickerInputDirective.prototype, "modelValue", {
|
|
5259
|
+
get: function () {
|
|
5260
|
+
return this._modelValue;
|
|
5261
|
+
},
|
|
5262
|
+
set: function (value) {
|
|
5263
|
+
if (value !== this._modelValue) {
|
|
5264
|
+
this._modelValue = value;
|
|
5265
|
+
this.updateTimepickerInput();
|
|
5266
|
+
this.setInputValue(value);
|
|
5267
|
+
this._validatorChange();
|
|
5268
|
+
this._onChange(value);
|
|
5269
|
+
}
|
|
5270
|
+
},
|
|
5271
|
+
enumerable: false,
|
|
5272
|
+
configurable: true
|
|
5273
|
+
});
|
|
5274
|
+
SkyTimepickerInputDirective.prototype.ngOnInit = function () {
|
|
5275
|
+
var _this = this;
|
|
5276
|
+
this.renderer.addClass(this.elRef.nativeElement, 'sky-form-control');
|
|
5277
|
+
this.pickerChangedSubscription =
|
|
5278
|
+
this.skyTimepickerInput.selectedTimeChanged.subscribe(function (newTime) {
|
|
5279
|
+
_this.writeValue(newTime);
|
|
5280
|
+
_this._onTouched();
|
|
5281
|
+
});
|
|
5282
|
+
/* istanbul ignore else */
|
|
5283
|
+
if (!this.elRef.nativeElement.getAttribute('aria-label')) {
|
|
5284
|
+
this.resourcesService
|
|
5285
|
+
.getString('skyux_timepicker_input_default_label')
|
|
5286
|
+
.subscribe(function (value) {
|
|
5287
|
+
_this.renderer.setAttribute(_this.elRef.nativeElement, 'aria-label', value);
|
|
5288
|
+
});
|
|
5289
|
+
}
|
|
5290
|
+
};
|
|
5291
|
+
SkyTimepickerInputDirective.prototype.ngAfterContentInit = function () {
|
|
5292
|
+
// Watch for the control to be added and initialize the value immediately.
|
|
5293
|
+
/* istanbul ignore else */
|
|
5294
|
+
if (this.control && this.control.parent) {
|
|
5295
|
+
this.control.setValue(this.modelValue, {
|
|
5296
|
+
emitEvent: false,
|
|
5297
|
+
});
|
|
5298
|
+
this.changeDetector.markForCheck();
|
|
5299
|
+
}
|
|
5300
|
+
};
|
|
5301
|
+
SkyTimepickerInputDirective.prototype.ngOnDestroy = function () {
|
|
5302
|
+
this.pickerChangedSubscription.unsubscribe();
|
|
5303
|
+
};
|
|
5304
|
+
SkyTimepickerInputDirective.prototype.ngOnChanges = function () {
|
|
5305
|
+
this.skyTimepickerInput.setFormat(this.timeFormat);
|
|
5306
|
+
this.skyTimepickerInput.returnFormat = this.returnFormat;
|
|
5307
|
+
};
|
|
5308
|
+
SkyTimepickerInputDirective.prototype.onChange = function (event) {
|
|
5309
|
+
this.writeValue(event.target.value);
|
|
5310
|
+
};
|
|
5311
|
+
/* istanbul ignore next */
|
|
5312
|
+
SkyTimepickerInputDirective.prototype.onBlur = function () {
|
|
5313
|
+
this._onTouched();
|
|
5314
|
+
};
|
|
5315
|
+
SkyTimepickerInputDirective.prototype.registerOnChange = function (fn) {
|
|
5316
|
+
this._onChange = fn;
|
|
5317
|
+
};
|
|
5318
|
+
SkyTimepickerInputDirective.prototype.registerOnTouched = function (fn) {
|
|
5319
|
+
this._onTouched = fn;
|
|
5320
|
+
};
|
|
5321
|
+
SkyTimepickerInputDirective.prototype.registerOnValidatorChange = function (fn) {
|
|
5322
|
+
this._validatorChange = fn;
|
|
5323
|
+
};
|
|
5324
|
+
SkyTimepickerInputDirective.prototype.setDisabledState = function (isDisabled) {
|
|
5325
|
+
this.disabled = isDisabled;
|
|
5326
|
+
};
|
|
5327
|
+
SkyTimepickerInputDirective.prototype.writeValue = function (value) {
|
|
5328
|
+
this.modelValue = this.formatter(value);
|
|
5329
|
+
};
|
|
5330
|
+
SkyTimepickerInputDirective.prototype.validate = function (control) {
|
|
5331
|
+
if (!this.control) {
|
|
5332
|
+
this.control = control;
|
|
5333
|
+
}
|
|
5334
|
+
var value = control.value;
|
|
5335
|
+
if (!value) {
|
|
5336
|
+
return undefined;
|
|
5337
|
+
}
|
|
5338
|
+
/* istanbul ignore next */
|
|
5339
|
+
if (value.local === 'Invalid date') {
|
|
5340
|
+
return {
|
|
5341
|
+
skyTime: {
|
|
5342
|
+
invalid: control.value,
|
|
5343
|
+
},
|
|
5344
|
+
};
|
|
5345
|
+
}
|
|
5346
|
+
return undefined;
|
|
5347
|
+
};
|
|
5348
|
+
SkyTimepickerInputDirective.prototype.setInputValue = function (value) {
|
|
5349
|
+
var formattedValue = '';
|
|
5350
|
+
if (value) {
|
|
5351
|
+
var output = moment__default["default"](value).format(value.customFormat);
|
|
5352
|
+
/* istanbul ignore else */
|
|
5353
|
+
if (output !== 'Invalid date') {
|
|
5354
|
+
formattedValue = output;
|
|
5355
|
+
}
|
|
5356
|
+
}
|
|
5357
|
+
this.renderer.setProperty(this.elRef.nativeElement, 'value', formattedValue);
|
|
5358
|
+
};
|
|
5359
|
+
SkyTimepickerInputDirective.prototype.formatter = function (time) {
|
|
5360
|
+
if (time && typeof time !== 'string' && 'local' in time) {
|
|
5361
|
+
return time;
|
|
5362
|
+
}
|
|
5363
|
+
if (typeof time === 'string') {
|
|
5364
|
+
if (time.length === 0) {
|
|
5365
|
+
return '';
|
|
5366
|
+
}
|
|
5367
|
+
var currentFormat = void 0;
|
|
5368
|
+
if (this.timeFormat === 'hh') {
|
|
5369
|
+
currentFormat = 'h:mm A';
|
|
5370
|
+
}
|
|
5371
|
+
if (this.timeFormat === 'HH') {
|
|
5372
|
+
currentFormat = 'H:mm';
|
|
5373
|
+
}
|
|
5374
|
+
if (typeof this.returnFormat === 'undefined') {
|
|
5375
|
+
this.returnFormat = currentFormat;
|
|
5376
|
+
}
|
|
5377
|
+
var formatTime = {
|
|
5378
|
+
hour: moment__default["default"](time, currentFormat).hour(),
|
|
5379
|
+
minute: moment__default["default"](time, currentFormat).minute(),
|
|
5380
|
+
meridie: moment__default["default"](time, currentFormat).format('A'),
|
|
5381
|
+
timezone: parseInt(moment__default["default"](time, currentFormat).format('Z'), 10),
|
|
5382
|
+
iso8601: moment__default["default"](time, currentFormat).toDate(),
|
|
5383
|
+
local: moment__default["default"](time, currentFormat).format(currentFormat),
|
|
5384
|
+
customFormat: this.returnFormat,
|
|
5385
|
+
};
|
|
5386
|
+
return formatTime;
|
|
5387
|
+
}
|
|
5388
|
+
};
|
|
5389
|
+
SkyTimepickerInputDirective.prototype.updateTimepickerInput = function () {
|
|
5390
|
+
if (this.skyTimepickerInput) {
|
|
5391
|
+
this.skyTimepickerInput.disabled = this.disabled;
|
|
5392
|
+
/* istanbul ignore else */
|
|
5393
|
+
if (this.skyTimepickerInput.selectedTime !== this.modelValue) {
|
|
5394
|
+
this.skyTimepickerInput.selectedTime = this.modelValue;
|
|
5395
|
+
}
|
|
5396
|
+
}
|
|
5397
|
+
};
|
|
5398
|
+
return SkyTimepickerInputDirective;
|
|
5399
|
+
}());
|
|
5400
|
+
SkyTimepickerInputDirective.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: SkyTimepickerInputDirective, deps: [{ token: i0__namespace.Renderer2 }, { token: i0__namespace.ElementRef }, { token: i3__namespace.SkyLibResourcesService }, { token: i0__namespace.ChangeDetectorRef }], target: i0__namespace.ɵɵFactoryTarget.Directive });
|
|
5401
|
+
SkyTimepickerInputDirective.ɵdir = i0__namespace.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: SkyTimepickerInputDirective, selector: "[skyTimepickerInput]", inputs: { skyTimepickerInput: "skyTimepickerInput", timeFormat: "timeFormat", returnFormat: "returnFormat", disabled: "disabled" }, host: { listeners: { "change": "onChange($event)", "blur": "onBlur()" } }, providers: [SKY_TIMEPICKER_VALUE_ACCESSOR, SKY_TIMEPICKER_VALIDATOR], usesOnChanges: true, ngImport: i0__namespace });
|
|
5402
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: SkyTimepickerInputDirective, decorators: [{
|
|
5403
|
+
type: i0.Directive,
|
|
5404
|
+
args: [{
|
|
5405
|
+
selector: '[skyTimepickerInput]',
|
|
5406
|
+
providers: [SKY_TIMEPICKER_VALUE_ACCESSOR, SKY_TIMEPICKER_VALIDATOR],
|
|
5407
|
+
}]
|
|
5408
|
+
}], ctorParameters: function () { return [{ type: i0__namespace.Renderer2 }, { type: i0__namespace.ElementRef }, { type: i3__namespace.SkyLibResourcesService }, { type: i0__namespace.ChangeDetectorRef }]; }, propDecorators: { skyTimepickerInput: [{
|
|
5409
|
+
type: i0.Input
|
|
5410
|
+
}], timeFormat: [{
|
|
5411
|
+
type: i0.Input
|
|
5412
|
+
}], returnFormat: [{
|
|
5413
|
+
type: i0.Input
|
|
5414
|
+
}], disabled: [{
|
|
5415
|
+
type: i0.Input
|
|
5416
|
+
}], onChange: [{
|
|
5417
|
+
type: i0.HostListener,
|
|
5418
|
+
args: ['change', ['$event']]
|
|
5419
|
+
}], onBlur: [{
|
|
5420
|
+
type: i0.HostListener,
|
|
5421
|
+
args: ['blur']
|
|
5422
|
+
}] } });
|
|
5423
|
+
|
|
5098
5424
|
var SkyTimepickerModule = /** @class */ (function () {
|
|
5099
5425
|
function SkyTimepickerModule() {
|
|
5100
5426
|
}
|