@skyux/datetime 5.5.0 → 5.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundles/skyux-datetime.umd.js +695 -695
- package/documentation.json +187 -187
- 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 +3 -3
- 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/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 +2 -2
- package/esm2015/lib/modules/datepicker/datepicker-input-fuzzy.directive.js.map +1 -1
- package/esm2015/lib/modules/datepicker/datepicker-input.directive.js +2 -2
- 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 +2 -2
- package/esm2015/lib/modules/timepicker/timepicker.component.js.map +1 -1
- package/esm2015/lib/modules/timepicker/timepicker.directive.js +3 -3
- 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 +438 -438
- package/fesm2015/skyux-datetime.js.map +1 -1
- package/lib/modules/date-range-picker/date-range-picker.component.d.ts +2 -2
- 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/datepicker/datepicker-calendar-change.d.ts +1 -1
- package/lib/modules/datepicker/datepicker-calendar-inner.component.d.ts +1 -1
- package/lib/modules/datepicker/datepicker-calendar.component.d.ts +1 -1
- package/lib/modules/datepicker/datepicker-input-fuzzy.directive.d.ts +1 -1
- package/lib/modules/datepicker/datepicker-input.directive.d.ts +1 -1
- package/lib/modules/datepicker/datepicker.component.d.ts +2 -2
- package/lib/modules/datepicker/daypicker.component.d.ts +1 -1
- package/package.json +6 -6
|
@@ -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,8 +32,8 @@
|
|
|
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 () {
|
|
@@ -932,38 +932,6 @@
|
|
|
932
932
|
SkyDateRangeCalculatorType[SkyDateRangeCalculatorType["Relative"] = 3] = "Relative";
|
|
933
933
|
})(exports.SkyDateRangeCalculatorType || (exports.SkyDateRangeCalculatorType = {}));
|
|
934
934
|
|
|
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
935
|
var SkyDateFormatter = /** @class */ (function () {
|
|
968
936
|
function SkyDateFormatter() {
|
|
969
937
|
}
|
|
@@ -1322,6 +1290,38 @@
|
|
|
1322
1290
|
type: i0.Output
|
|
1323
1291
|
}] } });
|
|
1324
1292
|
|
|
1293
|
+
/**
|
|
1294
|
+
* @internal
|
|
1295
|
+
*/
|
|
1296
|
+
var SkyDatepickerAdapterService = /** @class */ (function () {
|
|
1297
|
+
function SkyDatepickerAdapterService(renderer) {
|
|
1298
|
+
this.renderer = renderer;
|
|
1299
|
+
}
|
|
1300
|
+
SkyDatepickerAdapterService.prototype.init = function (elRef) {
|
|
1301
|
+
this.el = elRef.nativeElement;
|
|
1302
|
+
};
|
|
1303
|
+
SkyDatepickerAdapterService.prototype.elementIsFocused = function () {
|
|
1304
|
+
var focusedEl = document.activeElement;
|
|
1305
|
+
return this.el.contains(focusedEl);
|
|
1306
|
+
};
|
|
1307
|
+
SkyDatepickerAdapterService.prototype.elementIsVisible = function () {
|
|
1308
|
+
var styles = this.el && getComputedStyle(this.el);
|
|
1309
|
+
return styles && styles.visibility === 'visible';
|
|
1310
|
+
};
|
|
1311
|
+
SkyDatepickerAdapterService.prototype.getPlaceholder = function (elementRef) {
|
|
1312
|
+
return elementRef.nativeElement.getAttribute('placeholder');
|
|
1313
|
+
};
|
|
1314
|
+
SkyDatepickerAdapterService.prototype.setPlaceholder = function (elementRef, value) {
|
|
1315
|
+
this.renderer.setAttribute(elementRef.nativeElement, 'placeholder', value);
|
|
1316
|
+
};
|
|
1317
|
+
return SkyDatepickerAdapterService;
|
|
1318
|
+
}());
|
|
1319
|
+
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 });
|
|
1320
|
+
SkyDatepickerAdapterService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: SkyDatepickerAdapterService });
|
|
1321
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: SkyDatepickerAdapterService, decorators: [{
|
|
1322
|
+
type: i0.Injectable
|
|
1323
|
+
}], ctorParameters: function () { return [{ type: i0__namespace.Renderer2 }]; } });
|
|
1324
|
+
|
|
1325
1325
|
var SkyDatepickerConfigService = /** @class */ (function () {
|
|
1326
1326
|
function SkyDatepickerConfigService() {
|
|
1327
1327
|
/**
|
|
@@ -2342,53 +2342,54 @@
|
|
|
2342
2342
|
}] } });
|
|
2343
2343
|
|
|
2344
2344
|
// tslint:disable:no-forward-ref no-use-before-declare
|
|
2345
|
-
var
|
|
2345
|
+
var SKY_FUZZY_DATEPICKER_VALUE_ACCESSOR = {
|
|
2346
2346
|
provide: i2$2.NG_VALUE_ACCESSOR,
|
|
2347
|
-
useExisting: i0.forwardRef(function () { return
|
|
2347
|
+
useExisting: i0.forwardRef(function () { return SkyFuzzyDatepickerInputDirective; }),
|
|
2348
2348
|
multi: true,
|
|
2349
2349
|
};
|
|
2350
|
-
var
|
|
2350
|
+
var SKY_FUZZY_DATEPICKER_VALIDATOR = {
|
|
2351
2351
|
provide: i2$2.NG_VALIDATORS,
|
|
2352
|
-
useExisting: i0.forwardRef(function () { return
|
|
2352
|
+
useExisting: i0.forwardRef(function () { return SkyFuzzyDatepickerInputDirective; }),
|
|
2353
2353
|
multi: true,
|
|
2354
2354
|
};
|
|
2355
2355
|
// tslint:enable
|
|
2356
|
-
var
|
|
2357
|
-
function
|
|
2356
|
+
var SkyFuzzyDatepickerInputDirective = /** @class */ (function () {
|
|
2357
|
+
function SkyFuzzyDatepickerInputDirective(changeDetector, configService, elementRef, fuzzyDateService, localeProvider, renderer, resourcesService, datepickerComponent) {
|
|
2358
2358
|
var _this = this;
|
|
2359
|
-
this.adapter = adapter;
|
|
2360
2359
|
this.changeDetector = changeDetector;
|
|
2361
2360
|
this.configService = configService;
|
|
2362
2361
|
this.elementRef = elementRef;
|
|
2362
|
+
this.fuzzyDateService = fuzzyDateService;
|
|
2363
2363
|
this.localeProvider = localeProvider;
|
|
2364
2364
|
this.renderer = renderer;
|
|
2365
2365
|
this.resourcesService = resourcesService;
|
|
2366
2366
|
this.datepickerComponent = datepickerComponent;
|
|
2367
2367
|
/**
|
|
2368
|
-
* Indicates whether to disable date validation on the datepicker input.
|
|
2368
|
+
* Indicates whether to disable date validation on the fuzzy datepicker input.
|
|
2369
2369
|
* @default false
|
|
2370
2370
|
*/
|
|
2371
2371
|
this.skyDatepickerNoValidate = false;
|
|
2372
2372
|
this.dateFormatter = new SkyDateFormatter();
|
|
2373
2373
|
this.isFirstChange = true;
|
|
2374
2374
|
this.ngUnsubscribe = new rxjs.Subject();
|
|
2375
|
+
this._futureDisabled = false;
|
|
2376
|
+
this._disabled = false;
|
|
2377
|
+
this._yearRequired = false;
|
|
2375
2378
|
this.onChange = function (_) { };
|
|
2376
2379
|
/*istanbul ignore next */
|
|
2377
2380
|
this.onTouched = 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,72 @@
|
|
|
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
|
-
set: function (value) {
|
|
2479
|
-
if (value) {
|
|
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
|
-
}
|
|
2486
|
-
},
|
|
2491
|
+
set: function (value) { },
|
|
2487
2492
|
enumerable: false,
|
|
2488
2493
|
configurable: true
|
|
2489
2494
|
});
|
|
2490
|
-
Object.defineProperty(
|
|
2495
|
+
Object.defineProperty(SkyFuzzyDatepickerInputDirective.prototype, "startingDay", {
|
|
2491
2496
|
get: function () {
|
|
2492
2497
|
return this._startingDay || this.configService.startingDay;
|
|
2493
2498
|
},
|
|
@@ -2505,64 +2510,89 @@
|
|
|
2505
2510
|
enumerable: false,
|
|
2506
2511
|
configurable: true
|
|
2507
2512
|
});
|
|
2508
|
-
Object.defineProperty(
|
|
2513
|
+
Object.defineProperty(SkyFuzzyDatepickerInputDirective.prototype, "yearRequired", {
|
|
2509
2514
|
get: function () {
|
|
2510
|
-
return this.
|
|
2515
|
+
return this._yearRequired;
|
|
2511
2516
|
},
|
|
2512
2517
|
/**
|
|
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).
|
|
2518
|
+
* Indicates whether to require the year in fuzzy dates.
|
|
2518
2519
|
* @default false
|
|
2519
2520
|
*/
|
|
2520
2521
|
set: function (value) {
|
|
2521
|
-
this.
|
|
2522
|
+
this._yearRequired = value;
|
|
2523
|
+
this.onValidatorChange();
|
|
2522
2524
|
},
|
|
2523
2525
|
enumerable: false,
|
|
2524
2526
|
configurable: true
|
|
2525
2527
|
});
|
|
2526
|
-
Object.defineProperty(
|
|
2528
|
+
Object.defineProperty(SkyFuzzyDatepickerInputDirective.prototype, "value", {
|
|
2527
2529
|
get: function () {
|
|
2528
2530
|
return this._value;
|
|
2529
2531
|
},
|
|
2530
2532
|
set: function (value) {
|
|
2531
|
-
var
|
|
2532
|
-
var
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
this._value = value;
|
|
2540
|
-
this.notifyUpdatedValue();
|
|
2541
|
-
}
|
|
2542
|
-
else if (dateValue !== this._value || !areDatesEqual) {
|
|
2543
|
-
this._value = dateValue || value;
|
|
2544
|
-
this.notifyUpdatedValue();
|
|
2533
|
+
var fuzzyDate;
|
|
2534
|
+
var fuzzyMoment;
|
|
2535
|
+
var dateValue;
|
|
2536
|
+
var formattedDate;
|
|
2537
|
+
if (value instanceof Date) {
|
|
2538
|
+
dateValue = value;
|
|
2539
|
+
formattedDate = this.dateFormatter.format(value, this.dateFormat);
|
|
2540
|
+
fuzzyDate = this.fuzzyDateService.getFuzzyDateFromSelectedDate(value, this.dateFormat);
|
|
2545
2541
|
}
|
|
2546
|
-
if (
|
|
2547
|
-
|
|
2548
|
-
this.
|
|
2542
|
+
else if (typeof value === 'string') {
|
|
2543
|
+
fuzzyDate = this.fuzzyDateService.getFuzzyDateFromString(value, this.dateFormat);
|
|
2544
|
+
formattedDate = this.fuzzyDateService.format(fuzzyDate, this.dateFormat, this.locale);
|
|
2545
|
+
if (!formattedDate) {
|
|
2546
|
+
formattedDate = value;
|
|
2547
|
+
}
|
|
2548
|
+
fuzzyMoment = this.fuzzyDateService.getMomentFromFuzzyDate(fuzzyDate);
|
|
2549
|
+
if (fuzzyMoment) {
|
|
2550
|
+
dateValue = fuzzyMoment.toDate();
|
|
2551
|
+
}
|
|
2549
2552
|
}
|
|
2550
2553
|
else {
|
|
2551
|
-
|
|
2554
|
+
fuzzyDate = value;
|
|
2555
|
+
formattedDate = this.fuzzyDateService.format(fuzzyDate, this.dateFormat, this.locale);
|
|
2556
|
+
fuzzyMoment = this.fuzzyDateService.getMomentFromFuzzyDate(fuzzyDate);
|
|
2557
|
+
if (fuzzyMoment) {
|
|
2558
|
+
dateValue = fuzzyMoment.toDate();
|
|
2559
|
+
}
|
|
2552
2560
|
}
|
|
2561
|
+
var areFuzzyDatesEqual = this.fuzzyDatesEqual(this._value, fuzzyDate);
|
|
2562
|
+
var isNewValue = fuzzyDate !== this._value || !areFuzzyDatesEqual;
|
|
2563
|
+
this._value = fuzzyDate || value;
|
|
2564
|
+
if (isNewValue) {
|
|
2565
|
+
this.onChange(this._value);
|
|
2566
|
+
// Do not mark the field as "dirty"
|
|
2567
|
+
// if the field has been initialized with a value.
|
|
2568
|
+
if (this.isFirstChange && this.control) {
|
|
2569
|
+
this.control.markAsPristine();
|
|
2570
|
+
}
|
|
2571
|
+
if (this.isFirstChange && this._value) {
|
|
2572
|
+
this.isFirstChange = false;
|
|
2573
|
+
}
|
|
2574
|
+
this.datepickerComponent.selectedDate = dateValue;
|
|
2575
|
+
}
|
|
2576
|
+
this.setInputElementValue(formattedDate || '');
|
|
2553
2577
|
},
|
|
2554
2578
|
enumerable: false,
|
|
2555
2579
|
configurable: true
|
|
2556
2580
|
});
|
|
2557
|
-
|
|
2581
|
+
SkyFuzzyDatepickerInputDirective.prototype.ngOnInit = function () {
|
|
2558
2582
|
var _this = this;
|
|
2583
|
+
if (this.yearRequired) {
|
|
2584
|
+
if (this.dateFormat.toLowerCase().indexOf('y') === -1) {
|
|
2585
|
+
throw new Error('You have configured conflicting settings. Year is required and dateFormat does not include year.');
|
|
2586
|
+
}
|
|
2587
|
+
}
|
|
2559
2588
|
if (!this.datepickerComponent) {
|
|
2560
|
-
throw new Error('You must wrap the `
|
|
2589
|
+
throw new Error('You must wrap the `skyFuzzyDatepickerInput` directive within a ' +
|
|
2561
2590
|
'`<sky-datepicker>` component!');
|
|
2562
2591
|
}
|
|
2563
2592
|
var element = this.elementRef.nativeElement;
|
|
2564
2593
|
this.renderer.addClass(element, 'sky-form-control');
|
|
2565
2594
|
var hasAriaLabel = element.getAttribute('aria-label');
|
|
2595
|
+
/* istanbul ignore else */
|
|
2566
2596
|
if (!hasAriaLabel) {
|
|
2567
2597
|
this.resourcesService
|
|
2568
2598
|
.getString('skyux_date_field_default_label')
|
|
@@ -2572,18 +2602,17 @@
|
|
|
2572
2602
|
});
|
|
2573
2603
|
}
|
|
2574
2604
|
};
|
|
2575
|
-
|
|
2605
|
+
SkyFuzzyDatepickerInputDirective.prototype.ngAfterContentInit = function () {
|
|
2576
2606
|
var _this = this;
|
|
2577
2607
|
this.datepickerComponent.dateChange
|
|
2578
|
-
.pipe(operators.distinctUntilChanged())
|
|
2579
|
-
.pipe(operators.takeUntil(this.ngUnsubscribe))
|
|
2608
|
+
.pipe(operators.distinctUntilChanged(), operators.takeUntil(this.ngUnsubscribe))
|
|
2580
2609
|
.subscribe(function (value) {
|
|
2581
2610
|
_this.isFirstChange = false;
|
|
2582
2611
|
_this.value = value;
|
|
2583
2612
|
_this.onTouched();
|
|
2584
2613
|
});
|
|
2585
2614
|
};
|
|
2586
|
-
|
|
2615
|
+
SkyFuzzyDatepickerInputDirective.prototype.ngAfterViewInit = function () {
|
|
2587
2616
|
var _this = this;
|
|
2588
2617
|
// This is needed to address a bug in Angular 4.
|
|
2589
2618
|
// When a control value is set intially, its value is not represented on the view.
|
|
@@ -2599,90 +2628,110 @@
|
|
|
2599
2628
|
_this.changeDetector.markForCheck();
|
|
2600
2629
|
});
|
|
2601
2630
|
}
|
|
2602
|
-
this.adapter.init(this.elementRef);
|
|
2603
2631
|
};
|
|
2604
|
-
|
|
2632
|
+
SkyFuzzyDatepickerInputDirective.prototype.ngOnDestroy = function () {
|
|
2605
2633
|
this.ngUnsubscribe.next();
|
|
2606
2634
|
this.ngUnsubscribe.complete();
|
|
2607
2635
|
};
|
|
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
|
-
});
|
|
2636
|
+
SkyFuzzyDatepickerInputDirective.prototype.onInputChange = function (event) {
|
|
2637
|
+
this.onValueChange(event.target.value);
|
|
2626
2638
|
};
|
|
2627
|
-
|
|
2639
|
+
SkyFuzzyDatepickerInputDirective.prototype.onInputBlur = function () {
|
|
2628
2640
|
this.onTouched();
|
|
2641
|
+
var formattedDate = this.fuzzyDateService.format(this.value, this.dateFormat, this.locale);
|
|
2642
|
+
if (this.control.valid) {
|
|
2643
|
+
this.setInputElementValue(formattedDate);
|
|
2644
|
+
}
|
|
2629
2645
|
};
|
|
2630
|
-
|
|
2646
|
+
SkyFuzzyDatepickerInputDirective.prototype.onInputKeyup = function () {
|
|
2631
2647
|
this.control.markAsDirty();
|
|
2632
2648
|
};
|
|
2633
|
-
|
|
2649
|
+
SkyFuzzyDatepickerInputDirective.prototype.writeValue = function (value) {
|
|
2634
2650
|
this.value = value;
|
|
2635
2651
|
};
|
|
2636
|
-
|
|
2652
|
+
SkyFuzzyDatepickerInputDirective.prototype.validate = function (control) {
|
|
2637
2653
|
if (!this.control) {
|
|
2638
2654
|
this.control = control;
|
|
2639
2655
|
}
|
|
2640
2656
|
if (this.skyDatepickerNoValidate) {
|
|
2641
2657
|
return;
|
|
2642
2658
|
}
|
|
2643
|
-
|
|
2644
|
-
if (!value) {
|
|
2659
|
+
if (!this.control.value) {
|
|
2645
2660
|
return;
|
|
2646
2661
|
}
|
|
2647
|
-
var
|
|
2648
|
-
var
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
|
|
2662
|
+
var value = control.value;
|
|
2663
|
+
var fuzzyDate;
|
|
2664
|
+
var validationError;
|
|
2665
|
+
if (typeof value === 'string') {
|
|
2666
|
+
fuzzyDate = this.fuzzyDateService.getFuzzyDateFromString(value, this.dateFormat);
|
|
2667
|
+
}
|
|
2668
|
+
else {
|
|
2669
|
+
fuzzyDate = value;
|
|
2670
|
+
}
|
|
2671
|
+
if (!fuzzyDate) {
|
|
2672
|
+
validationError = {
|
|
2673
|
+
skyFuzzyDate: {
|
|
2655
2674
|
invalid: value,
|
|
2656
2675
|
},
|
|
2657
2676
|
};
|
|
2658
2677
|
}
|
|
2659
|
-
|
|
2660
|
-
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
minDate: minDate,
|
|
2678
|
+
if (!validationError && !fuzzyDate.year && this.yearRequired) {
|
|
2679
|
+
validationError = {
|
|
2680
|
+
skyFuzzyDate: {
|
|
2681
|
+
yearRequired: value,
|
|
2664
2682
|
},
|
|
2665
2683
|
};
|
|
2666
2684
|
}
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
|
|
2685
|
+
if (!validationError && fuzzyDate.year) {
|
|
2686
|
+
var fuzzyDateRange = void 0;
|
|
2687
|
+
if (this.maxDate) {
|
|
2688
|
+
fuzzyDateRange = this.fuzzyDateService.getFuzzyDateRange(fuzzyDate, this.maxDate);
|
|
2689
|
+
if (!fuzzyDateRange.valid) {
|
|
2690
|
+
validationError = {
|
|
2691
|
+
skyFuzzyDate: {
|
|
2692
|
+
maxDate: value,
|
|
2693
|
+
},
|
|
2694
|
+
};
|
|
2695
|
+
}
|
|
2696
|
+
}
|
|
2697
|
+
if (!validationError && this.minDate) {
|
|
2698
|
+
fuzzyDateRange = this.fuzzyDateService.getFuzzyDateRange(this.minDate, fuzzyDate);
|
|
2699
|
+
if (!fuzzyDateRange.valid) {
|
|
2700
|
+
validationError = {
|
|
2701
|
+
skyFuzzyDate: {
|
|
2702
|
+
minDate: value,
|
|
2703
|
+
},
|
|
2704
|
+
};
|
|
2705
|
+
}
|
|
2706
|
+
}
|
|
2707
|
+
if (!validationError && this.futureDisabled) {
|
|
2708
|
+
fuzzyDateRange = this.fuzzyDateService.getFuzzyDateRange(fuzzyDate, this.fuzzyDateService.getCurrentFuzzyDate());
|
|
2709
|
+
if (!fuzzyDateRange.valid) {
|
|
2710
|
+
validationError = {
|
|
2711
|
+
skyFuzzyDate: {
|
|
2712
|
+
futureDisabled: value,
|
|
2713
|
+
},
|
|
2714
|
+
};
|
|
2715
|
+
}
|
|
2716
|
+
}
|
|
2717
|
+
}
|
|
2718
|
+
if (validationError) {
|
|
2719
|
+
// Mark the invalid control as touched so that the input's invalid CSS styles appear.
|
|
2720
|
+
// (This is only required when the invalid value is set by the FormControl constructor.)
|
|
2721
|
+
this.control.markAsTouched();
|
|
2674
2722
|
}
|
|
2723
|
+
return validationError;
|
|
2675
2724
|
};
|
|
2676
|
-
|
|
2725
|
+
SkyFuzzyDatepickerInputDirective.prototype.registerOnChange = function (fn) {
|
|
2677
2726
|
this.onChange = fn;
|
|
2678
2727
|
};
|
|
2679
|
-
|
|
2728
|
+
SkyFuzzyDatepickerInputDirective.prototype.registerOnTouched = function (fn) {
|
|
2680
2729
|
this.onTouched = fn;
|
|
2681
2730
|
};
|
|
2682
|
-
|
|
2731
|
+
SkyFuzzyDatepickerInputDirective.prototype.registerOnValidatorChange = function (fn) {
|
|
2683
2732
|
this.onValidatorChange = fn;
|
|
2684
2733
|
};
|
|
2685
|
-
|
|
2734
|
+
SkyFuzzyDatepickerInputDirective.prototype.setDisabledState = function (disabled) {
|
|
2686
2735
|
this.disabled = disabled;
|
|
2687
2736
|
this.datepickerComponent.disabled = disabled;
|
|
2688
2737
|
};
|
|
@@ -2690,108 +2739,82 @@
|
|
|
2690
2739
|
* Detects changes to the underlying input element's value and updates the ngModel accordingly.
|
|
2691
2740
|
* This is useful if you need to update the ngModel value before the input element loses focus.
|
|
2692
2741
|
*/
|
|
2693
|
-
|
|
2742
|
+
SkyFuzzyDatepickerInputDirective.prototype.detectInputValueChange = function () {
|
|
2694
2743
|
this.onValueChange(this.elementRef.nativeElement.value);
|
|
2695
2744
|
};
|
|
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) {
|
|
2745
|
+
SkyFuzzyDatepickerInputDirective.prototype.onValueChange = function (newValue) {
|
|
2705
2746
|
this.isFirstChange = false;
|
|
2706
2747
|
this.value = newValue;
|
|
2707
2748
|
};
|
|
2708
|
-
|
|
2749
|
+
SkyFuzzyDatepickerInputDirective.prototype.setInputElementValue = function (value) {
|
|
2709
2750
|
this.renderer.setProperty(this.elementRef.nativeElement, 'value', value);
|
|
2710
2751
|
};
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
else if (typeof value === 'string') {
|
|
2717
|
-
var date = this.dateFormatter.getDateFromString(value, this.dateFormat, this.strict);
|
|
2718
|
-
if (this.dateFormatter.dateIsValid(date)) {
|
|
2719
|
-
dateValue = date;
|
|
2752
|
+
SkyFuzzyDatepickerInputDirective.prototype.getMaxDate = function () {
|
|
2753
|
+
if (this.maxDate) {
|
|
2754
|
+
var maxDate = this.fuzzyDateService.getMomentFromFuzzyDate(this.maxDate);
|
|
2755
|
+
if (maxDate.isValid()) {
|
|
2756
|
+
return maxDate.toDate();
|
|
2720
2757
|
}
|
|
2721
2758
|
}
|
|
2722
|
-
|
|
2723
|
-
|
|
2724
|
-
/**
|
|
2725
|
-
* Validates the input value to ensure it is formatted correctly.
|
|
2726
|
-
*/
|
|
2727
|
-
SkyDatepickerInputDirective.prototype.isDateStringValid = function (value) {
|
|
2728
|
-
if (!value || typeof value !== 'string') {
|
|
2729
|
-
return true;
|
|
2730
|
-
}
|
|
2731
|
-
// Does the value only include digits, dashes, or slashes?
|
|
2732
|
-
var regexp = /^[\d\/\-]+$/;
|
|
2733
|
-
var isValid = regexp.test(value);
|
|
2734
|
-
if (isValid) {
|
|
2735
|
-
return true;
|
|
2759
|
+
else if (this.futureDisabled) {
|
|
2760
|
+
return new Date();
|
|
2736
2761
|
}
|
|
2737
|
-
|
|
2738
|
-
var isValidIso = moment__default["default"](value, moment__default["default"].ISO_8601).isValid();
|
|
2739
|
-
return isValidIso;
|
|
2762
|
+
return this.configService.maxDate;
|
|
2740
2763
|
};
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
|
|
2744
|
-
|
|
2745
|
-
|
|
2746
|
-
|
|
2747
|
-
}
|
|
2748
|
-
if (this.isFirstChange && this._value) {
|
|
2749
|
-
this.isFirstChange = false;
|
|
2764
|
+
SkyFuzzyDatepickerInputDirective.prototype.getMinDate = function () {
|
|
2765
|
+
if (this.minDate) {
|
|
2766
|
+
var minDate = this.fuzzyDateService.getMomentFromFuzzyDate(this.minDate);
|
|
2767
|
+
if (minDate.isValid()) {
|
|
2768
|
+
return minDate.toDate();
|
|
2769
|
+
}
|
|
2750
2770
|
}
|
|
2751
|
-
this.
|
|
2771
|
+
return this.configService.minDate;
|
|
2752
2772
|
};
|
|
2753
|
-
|
|
2754
|
-
|
|
2755
|
-
|
|
2756
|
-
|
|
2773
|
+
/* istanbul ignore next */
|
|
2774
|
+
SkyFuzzyDatepickerInputDirective.prototype.fuzzyDatesEqual = function (dateA, dateB) {
|
|
2775
|
+
return (dateA &&
|
|
2776
|
+
dateB &&
|
|
2777
|
+
((!dateA.day && !dateB.day) || dateA.day === dateB.day) &&
|
|
2778
|
+
((!dateA.month && !dateB.month) || dateA.month === dateB.month) &&
|
|
2779
|
+
((!dateA.year && !dateB.year) || dateA.year === dateB.year));
|
|
2757
2780
|
};
|
|
2758
|
-
return
|
|
2781
|
+
return SkyFuzzyDatepickerInputDirective;
|
|
2759
2782
|
}());
|
|
2760
|
-
|
|
2761
|
-
|
|
2762
|
-
|
|
2763
|
-
|
|
2764
|
-
SkyDatepickerAdapterService,
|
|
2783
|
+
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 });
|
|
2784
|
+
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: [
|
|
2785
|
+
SKY_FUZZY_DATEPICKER_VALUE_ACCESSOR,
|
|
2786
|
+
SKY_FUZZY_DATEPICKER_VALIDATOR,
|
|
2765
2787
|
], ngImport: i0__namespace });
|
|
2766
|
-
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type:
|
|
2788
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: SkyFuzzyDatepickerInputDirective, decorators: [{
|
|
2767
2789
|
type: i0.Directive,
|
|
2768
2790
|
args: [{
|
|
2769
|
-
selector: '[
|
|
2791
|
+
selector: '[skyFuzzyDatepickerInput]',
|
|
2770
2792
|
providers: [
|
|
2771
|
-
|
|
2772
|
-
|
|
2773
|
-
SkyDatepickerAdapterService,
|
|
2793
|
+
SKY_FUZZY_DATEPICKER_VALUE_ACCESSOR,
|
|
2794
|
+
SKY_FUZZY_DATEPICKER_VALIDATOR,
|
|
2774
2795
|
],
|
|
2775
2796
|
}]
|
|
2776
2797
|
}], ctorParameters: function () {
|
|
2777
|
-
return [{ type:
|
|
2798
|
+
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
2799
|
type: i0.Optional
|
|
2779
2800
|
}] }];
|
|
2780
2801
|
}, propDecorators: { dateFormat: [{
|
|
2781
2802
|
type: i0.Input
|
|
2782
2803
|
}], disabled: [{
|
|
2783
2804
|
type: i0.Input
|
|
2805
|
+
}], futureDisabled: [{
|
|
2806
|
+
type: i0.Input
|
|
2784
2807
|
}], maxDate: [{
|
|
2785
2808
|
type: i0.Input
|
|
2786
2809
|
}], minDate: [{
|
|
2787
2810
|
type: i0.Input
|
|
2788
|
-
}], skyDatepickerInput: [{
|
|
2789
|
-
type: i0.Input
|
|
2790
2811
|
}], skyDatepickerNoValidate: [{
|
|
2791
2812
|
type: i0.Input
|
|
2813
|
+
}], skyFuzzyDatepickerInput: [{
|
|
2814
|
+
type: i0.Input
|
|
2792
2815
|
}], startingDay: [{
|
|
2793
2816
|
type: i0.Input
|
|
2794
|
-
}],
|
|
2817
|
+
}], yearRequired: [{
|
|
2795
2818
|
type: i0.Input
|
|
2796
2819
|
}], onInputChange: [{
|
|
2797
2820
|
type: i0.HostListener,
|
|
@@ -2805,54 +2828,53 @@
|
|
|
2805
2828
|
}] } });
|
|
2806
2829
|
|
|
2807
2830
|
// tslint:disable:no-forward-ref no-use-before-declare
|
|
2808
|
-
var
|
|
2831
|
+
var SKY_DATEPICKER_VALUE_ACCESSOR = {
|
|
2809
2832
|
provide: i2$2.NG_VALUE_ACCESSOR,
|
|
2810
|
-
useExisting: i0.forwardRef(function () { return
|
|
2833
|
+
useExisting: i0.forwardRef(function () { return SkyDatepickerInputDirective; }),
|
|
2811
2834
|
multi: true,
|
|
2812
2835
|
};
|
|
2813
|
-
var
|
|
2836
|
+
var SKY_DATEPICKER_VALIDATOR = {
|
|
2814
2837
|
provide: i2$2.NG_VALIDATORS,
|
|
2815
|
-
useExisting: i0.forwardRef(function () { return
|
|
2838
|
+
useExisting: i0.forwardRef(function () { return SkyDatepickerInputDirective; }),
|
|
2816
2839
|
multi: true,
|
|
2817
2840
|
};
|
|
2818
2841
|
// tslint:enable
|
|
2819
|
-
var
|
|
2820
|
-
function
|
|
2842
|
+
var SkyDatepickerInputDirective = /** @class */ (function () {
|
|
2843
|
+
function SkyDatepickerInputDirective(adapter, changeDetector, configService, elementRef, localeProvider, renderer, resourcesService, datepickerComponent) {
|
|
2821
2844
|
var _this = this;
|
|
2845
|
+
this.adapter = adapter;
|
|
2822
2846
|
this.changeDetector = changeDetector;
|
|
2823
2847
|
this.configService = configService;
|
|
2824
2848
|
this.elementRef = elementRef;
|
|
2825
|
-
this.fuzzyDateService = fuzzyDateService;
|
|
2826
2849
|
this.localeProvider = localeProvider;
|
|
2827
2850
|
this.renderer = renderer;
|
|
2828
2851
|
this.resourcesService = resourcesService;
|
|
2829
2852
|
this.datepickerComponent = datepickerComponent;
|
|
2830
2853
|
/**
|
|
2831
|
-
* Indicates whether to disable date validation on the
|
|
2854
|
+
* Indicates whether to disable date validation on the datepicker input.
|
|
2832
2855
|
* @default false
|
|
2833
2856
|
*/
|
|
2834
2857
|
this.skyDatepickerNoValidate = false;
|
|
2835
2858
|
this.dateFormatter = new SkyDateFormatter();
|
|
2836
2859
|
this.isFirstChange = true;
|
|
2837
2860
|
this.ngUnsubscribe = new rxjs.Subject();
|
|
2838
|
-
this._futureDisabled = false;
|
|
2839
|
-
this._disabled = false;
|
|
2840
|
-
this._yearRequired = false;
|
|
2841
2861
|
this.onChange = function (_) { };
|
|
2842
2862
|
/*istanbul ignore next */
|
|
2843
2863
|
this.onTouched = function () { };
|
|
2844
2864
|
this.onValidatorChange = function () { };
|
|
2865
|
+
this.initialPlaceholder = this.adapter.getPlaceholder(this.elementRef);
|
|
2866
|
+
this.updatePlaceholder();
|
|
2845
2867
|
this.localeProvider
|
|
2846
2868
|
.getLocaleInfo()
|
|
2847
2869
|
.pipe(operators.takeUntil(this.ngUnsubscribe))
|
|
2848
2870
|
.subscribe(function (localeInfo) {
|
|
2849
|
-
|
|
2850
|
-
SkyDateFormatter.setLocale(_this.locale);
|
|
2871
|
+
SkyDateFormatter.setLocale(localeInfo.locale);
|
|
2851
2872
|
_this.preferredShortDateFormat =
|
|
2852
2873
|
SkyDateFormatter.getPreferredShortDateFormat();
|
|
2874
|
+
_this.applyDateFormat();
|
|
2853
2875
|
});
|
|
2854
2876
|
}
|
|
2855
|
-
Object.defineProperty(
|
|
2877
|
+
Object.defineProperty(SkyDatepickerInputDirective.prototype, "dateFormat", {
|
|
2856
2878
|
get: function () {
|
|
2857
2879
|
return (this._dateFormat ||
|
|
2858
2880
|
this.configService.dateFormat ||
|
|
@@ -2860,23 +2882,22 @@
|
|
|
2860
2882
|
},
|
|
2861
2883
|
/**
|
|
2862
2884
|
* Specifies the date format for the input. Place this attribute on the `input` element
|
|
2863
|
-
* to override the default in `SkyDatepickerConfigService`.
|
|
2885
|
+
* to override the default in the `SkyDatepickerConfigService`.
|
|
2864
2886
|
* @default "MM/DD/YYYY"
|
|
2865
2887
|
*/
|
|
2866
2888
|
set: function (value) {
|
|
2867
|
-
|
|
2868
|
-
if (this.
|
|
2869
|
-
|
|
2870
|
-
this.
|
|
2871
|
-
this.changeDetector.markForCheck();
|
|
2889
|
+
/* istanbul ignore else */
|
|
2890
|
+
if (value !== this._dateFormat) {
|
|
2891
|
+
this._dateFormat = value;
|
|
2892
|
+
this.applyDateFormat();
|
|
2872
2893
|
}
|
|
2873
2894
|
},
|
|
2874
2895
|
enumerable: false,
|
|
2875
2896
|
configurable: true
|
|
2876
2897
|
});
|
|
2877
|
-
Object.defineProperty(
|
|
2898
|
+
Object.defineProperty(SkyDatepickerInputDirective.prototype, "disabled", {
|
|
2878
2899
|
get: function () {
|
|
2879
|
-
return this._disabled;
|
|
2900
|
+
return this._disabled || false;
|
|
2880
2901
|
},
|
|
2881
2902
|
/**
|
|
2882
2903
|
* Indicates whether to disable the datepicker.
|
|
@@ -2890,72 +2911,69 @@
|
|
|
2890
2911
|
enumerable: false,
|
|
2891
2912
|
configurable: true
|
|
2892
2913
|
});
|
|
2893
|
-
Object.defineProperty(
|
|
2894
|
-
get: function () {
|
|
2895
|
-
return this._futureDisabled;
|
|
2896
|
-
},
|
|
2914
|
+
Object.defineProperty(SkyDatepickerInputDirective.prototype, "inputIsFocused", {
|
|
2897
2915
|
/**
|
|
2898
|
-
*
|
|
2899
|
-
*
|
|
2900
|
-
* @default false
|
|
2916
|
+
* @internal
|
|
2917
|
+
* Indicates if the input element or any of its children have focus.
|
|
2901
2918
|
*/
|
|
2902
|
-
|
|
2903
|
-
this.
|
|
2904
|
-
this.onValidatorChange();
|
|
2919
|
+
get: function () {
|
|
2920
|
+
return this.adapter.elementIsFocused();
|
|
2905
2921
|
},
|
|
2906
2922
|
enumerable: false,
|
|
2907
2923
|
configurable: true
|
|
2908
2924
|
});
|
|
2909
|
-
Object.defineProperty(
|
|
2925
|
+
Object.defineProperty(SkyDatepickerInputDirective.prototype, "maxDate", {
|
|
2910
2926
|
get: function () {
|
|
2911
|
-
return this._maxDate;
|
|
2927
|
+
return this._maxDate || this.configService.maxDate;
|
|
2912
2928
|
},
|
|
2913
2929
|
/**
|
|
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 }`.
|
|
2930
|
+
* Specifies the latest date that is available in the calendar. Place this attribute on
|
|
2931
|
+
* the `input` element to override the default in `SkyDatepickerConfigService`.
|
|
2918
2932
|
*/
|
|
2919
2933
|
set: function (value) {
|
|
2920
2934
|
this._maxDate = value;
|
|
2921
|
-
this.datepickerComponent.maxDate = this.
|
|
2935
|
+
this.datepickerComponent.maxDate = this.maxDate;
|
|
2922
2936
|
this.onValidatorChange();
|
|
2923
2937
|
},
|
|
2924
2938
|
enumerable: false,
|
|
2925
2939
|
configurable: true
|
|
2926
2940
|
});
|
|
2927
|
-
Object.defineProperty(
|
|
2941
|
+
Object.defineProperty(SkyDatepickerInputDirective.prototype, "minDate", {
|
|
2928
2942
|
get: function () {
|
|
2929
|
-
return this._minDate;
|
|
2943
|
+
return this._minDate || this.configService.minDate;
|
|
2930
2944
|
},
|
|
2931
2945
|
/**
|
|
2932
|
-
* Specifies the earliest
|
|
2933
|
-
*
|
|
2934
|
-
* that includes numeric month, day, and year values.
|
|
2935
|
-
* For example: `{ month: 1, day: 1, year: 2007 }`.
|
|
2946
|
+
* Specifies the earliest date that is available in the calendar. Place this attribute on
|
|
2947
|
+
* the `input` element to override the default in `SkyDatepickerConfigService`.
|
|
2936
2948
|
*/
|
|
2937
2949
|
set: function (value) {
|
|
2938
2950
|
this._minDate = value;
|
|
2939
|
-
this.datepickerComponent.minDate = this.
|
|
2951
|
+
this.datepickerComponent.minDate = this.minDate;
|
|
2940
2952
|
this.onValidatorChange();
|
|
2941
2953
|
},
|
|
2942
2954
|
enumerable: false,
|
|
2943
2955
|
configurable: true
|
|
2944
2956
|
});
|
|
2945
|
-
Object.defineProperty(
|
|
2957
|
+
Object.defineProperty(SkyDatepickerInputDirective.prototype, "skyDatepickerInput", {
|
|
2946
2958
|
/**
|
|
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
|
|
2959
|
+
* Creates the datepicker input and calendar. Place this directive on an `input` element,
|
|
2960
|
+
* and wrap the input in a `sky-datepicker` component. The value that users select is driven
|
|
2951
2961
|
* through the `ngModel` attribute specified on the `input` element.
|
|
2952
2962
|
* @required
|
|
2953
2963
|
*/
|
|
2954
|
-
set: function (value) {
|
|
2964
|
+
set: function (value) {
|
|
2965
|
+
if (value) {
|
|
2966
|
+
console.warn('[Deprecation warning] You no longer need to provide a template reference variable ' +
|
|
2967
|
+
'to the `skyDatepickerInput` attribute (this will be a breaking change in the next ' +
|
|
2968
|
+
'major version release).\n' +
|
|
2969
|
+
'Do this instead:\n' +
|
|
2970
|
+
'<sky-datepicker>\n <input skyDatepickerInput />\n</sky-datepicker>');
|
|
2971
|
+
}
|
|
2972
|
+
},
|
|
2955
2973
|
enumerable: false,
|
|
2956
2974
|
configurable: true
|
|
2957
2975
|
});
|
|
2958
|
-
Object.defineProperty(
|
|
2976
|
+
Object.defineProperty(SkyDatepickerInputDirective.prototype, "startingDay", {
|
|
2959
2977
|
get: function () {
|
|
2960
2978
|
return this._startingDay || this.configService.startingDay;
|
|
2961
2979
|
},
|
|
@@ -2973,89 +2991,64 @@
|
|
|
2973
2991
|
enumerable: false,
|
|
2974
2992
|
configurable: true
|
|
2975
2993
|
});
|
|
2976
|
-
Object.defineProperty(
|
|
2994
|
+
Object.defineProperty(SkyDatepickerInputDirective.prototype, "strict", {
|
|
2977
2995
|
get: function () {
|
|
2978
|
-
return this.
|
|
2996
|
+
return this._strict || false;
|
|
2979
2997
|
},
|
|
2980
2998
|
/**
|
|
2981
|
-
* Indicates whether
|
|
2999
|
+
* Indicates whether the format of the date value must match the format from the `dateFormat` value.
|
|
3000
|
+
* If this property is `true` and the datepicker input directive cannot find an exact match, then
|
|
3001
|
+
* the input is marked as invalid.
|
|
3002
|
+
* If this property is `false` and the datepicker input directive cannot find an exact match, then
|
|
3003
|
+
* 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
3004
|
* @default false
|
|
2983
3005
|
*/
|
|
2984
3006
|
set: function (value) {
|
|
2985
|
-
this.
|
|
2986
|
-
this.onValidatorChange();
|
|
3007
|
+
this._strict = value;
|
|
2987
3008
|
},
|
|
2988
3009
|
enumerable: false,
|
|
2989
3010
|
configurable: true
|
|
2990
3011
|
});
|
|
2991
|
-
Object.defineProperty(
|
|
3012
|
+
Object.defineProperty(SkyDatepickerInputDirective.prototype, "value", {
|
|
2992
3013
|
get: function () {
|
|
2993
3014
|
return this._value;
|
|
2994
3015
|
},
|
|
2995
3016
|
set: function (value) {
|
|
2996
|
-
var
|
|
2997
|
-
var
|
|
2998
|
-
|
|
2999
|
-
|
|
3000
|
-
|
|
3001
|
-
|
|
3002
|
-
|
|
3003
|
-
|
|
3017
|
+
var dateValue = this.getDateValue(value);
|
|
3018
|
+
var areDatesEqual = this._value instanceof Date &&
|
|
3019
|
+
dateValue &&
|
|
3020
|
+
dateValue.getTime() === this._value.getTime();
|
|
3021
|
+
var isValidDateString = this.isDateStringValid(value);
|
|
3022
|
+
// If the string value supplied is malformed, do not set the value to its Date equivalent.
|
|
3023
|
+
// (JavaScript's Date parser will convert poorly formatted dates to Date objects, such as "abc 123", which isn't ideal.)
|
|
3024
|
+
if (!isValidDateString) {
|
|
3025
|
+
this._value = value;
|
|
3026
|
+
this.notifyUpdatedValue();
|
|
3004
3027
|
}
|
|
3005
|
-
else if (
|
|
3006
|
-
|
|
3007
|
-
|
|
3008
|
-
if (!formattedDate) {
|
|
3009
|
-
formattedDate = value;
|
|
3010
|
-
}
|
|
3011
|
-
fuzzyMoment = this.fuzzyDateService.getMomentFromFuzzyDate(fuzzyDate);
|
|
3012
|
-
if (fuzzyMoment) {
|
|
3013
|
-
dateValue = fuzzyMoment.toDate();
|
|
3014
|
-
}
|
|
3028
|
+
else if (dateValue !== this._value || !areDatesEqual) {
|
|
3029
|
+
this._value = dateValue || value;
|
|
3030
|
+
this.notifyUpdatedValue();
|
|
3015
3031
|
}
|
|
3016
|
-
|
|
3017
|
-
|
|
3018
|
-
|
|
3019
|
-
fuzzyMoment = this.fuzzyDateService.getMomentFromFuzzyDate(fuzzyDate);
|
|
3020
|
-
if (fuzzyMoment) {
|
|
3021
|
-
dateValue = fuzzyMoment.toDate();
|
|
3022
|
-
}
|
|
3032
|
+
if (dateValue && isValidDateString) {
|
|
3033
|
+
var formattedDate = this.dateFormatter.format(dateValue, this.dateFormat);
|
|
3034
|
+
this.setInputElementValue(formattedDate);
|
|
3023
3035
|
}
|
|
3024
|
-
|
|
3025
|
-
|
|
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;
|
|
3036
|
+
else {
|
|
3037
|
+
this.setInputElementValue(value || '');
|
|
3038
3038
|
}
|
|
3039
|
-
this.setInputElementValue(formattedDate || '');
|
|
3040
3039
|
},
|
|
3041
3040
|
enumerable: false,
|
|
3042
3041
|
configurable: true
|
|
3043
3042
|
});
|
|
3044
|
-
|
|
3043
|
+
SkyDatepickerInputDirective.prototype.ngOnInit = function () {
|
|
3045
3044
|
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
3045
|
if (!this.datepickerComponent) {
|
|
3052
|
-
throw new Error('You must wrap the `
|
|
3046
|
+
throw new Error('You must wrap the `skyDatepickerInput` directive within a ' +
|
|
3053
3047
|
'`<sky-datepicker>` component!');
|
|
3054
3048
|
}
|
|
3055
3049
|
var element = this.elementRef.nativeElement;
|
|
3056
3050
|
this.renderer.addClass(element, 'sky-form-control');
|
|
3057
3051
|
var hasAriaLabel = element.getAttribute('aria-label');
|
|
3058
|
-
/* istanbul ignore else */
|
|
3059
3052
|
if (!hasAriaLabel) {
|
|
3060
3053
|
this.resourcesService
|
|
3061
3054
|
.getString('skyux_date_field_default_label')
|
|
@@ -3065,17 +3058,18 @@
|
|
|
3065
3058
|
});
|
|
3066
3059
|
}
|
|
3067
3060
|
};
|
|
3068
|
-
|
|
3061
|
+
SkyDatepickerInputDirective.prototype.ngAfterContentInit = function () {
|
|
3069
3062
|
var _this = this;
|
|
3070
3063
|
this.datepickerComponent.dateChange
|
|
3071
|
-
.pipe(operators.distinctUntilChanged()
|
|
3064
|
+
.pipe(operators.distinctUntilChanged())
|
|
3065
|
+
.pipe(operators.takeUntil(this.ngUnsubscribe))
|
|
3072
3066
|
.subscribe(function (value) {
|
|
3073
3067
|
_this.isFirstChange = false;
|
|
3074
3068
|
_this.value = value;
|
|
3075
3069
|
_this.onTouched();
|
|
3076
3070
|
});
|
|
3077
3071
|
};
|
|
3078
|
-
|
|
3072
|
+
SkyDatepickerInputDirective.prototype.ngAfterViewInit = function () {
|
|
3079
3073
|
var _this = this;
|
|
3080
3074
|
// This is needed to address a bug in Angular 4.
|
|
3081
3075
|
// When a control value is set intially, its value is not represented on the view.
|
|
@@ -3091,110 +3085,90 @@
|
|
|
3091
3085
|
_this.changeDetector.markForCheck();
|
|
3092
3086
|
});
|
|
3093
3087
|
}
|
|
3088
|
+
this.adapter.init(this.elementRef);
|
|
3094
3089
|
};
|
|
3095
|
-
|
|
3090
|
+
SkyDatepickerInputDirective.prototype.ngOnDestroy = function () {
|
|
3096
3091
|
this.ngUnsubscribe.next();
|
|
3097
3092
|
this.ngUnsubscribe.complete();
|
|
3098
3093
|
};
|
|
3099
|
-
|
|
3100
|
-
|
|
3094
|
+
SkyDatepickerInputDirective.prototype.onInputChange = function (event) {
|
|
3095
|
+
var value = event.target.value;
|
|
3096
|
+
if (this.skyDatepickerNoValidate) {
|
|
3097
|
+
this.onValueChange(value);
|
|
3098
|
+
return;
|
|
3099
|
+
}
|
|
3100
|
+
// Don't try to parse the string value into a Date value if it is malformed.
|
|
3101
|
+
if (this.isDateStringValid(value)) {
|
|
3102
|
+
this.onValueChange(value);
|
|
3103
|
+
return;
|
|
3104
|
+
}
|
|
3105
|
+
this._value = value;
|
|
3106
|
+
this.onChange(value);
|
|
3107
|
+
this.control.setErrors({
|
|
3108
|
+
skyDate: {
|
|
3109
|
+
invalid: true,
|
|
3110
|
+
},
|
|
3111
|
+
});
|
|
3101
3112
|
};
|
|
3102
|
-
|
|
3113
|
+
SkyDatepickerInputDirective.prototype.onInputBlur = function () {
|
|
3103
3114
|
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
3115
|
};
|
|
3109
|
-
|
|
3116
|
+
SkyDatepickerInputDirective.prototype.onInputKeyup = function () {
|
|
3110
3117
|
this.control.markAsDirty();
|
|
3111
3118
|
};
|
|
3112
|
-
|
|
3119
|
+
SkyDatepickerInputDirective.prototype.writeValue = function (value) {
|
|
3113
3120
|
this.value = value;
|
|
3114
3121
|
};
|
|
3115
|
-
|
|
3122
|
+
SkyDatepickerInputDirective.prototype.validate = function (control) {
|
|
3116
3123
|
if (!this.control) {
|
|
3117
3124
|
this.control = control;
|
|
3118
3125
|
}
|
|
3119
3126
|
if (this.skyDatepickerNoValidate) {
|
|
3120
3127
|
return;
|
|
3121
3128
|
}
|
|
3122
|
-
if (!this.control.value) {
|
|
3123
|
-
return;
|
|
3124
|
-
}
|
|
3125
3129
|
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;
|
|
3130
|
+
if (!value) {
|
|
3131
|
+
return;
|
|
3133
3132
|
}
|
|
3134
|
-
|
|
3135
|
-
|
|
3136
|
-
|
|
3133
|
+
var dateValue = this.getDateValue(value);
|
|
3134
|
+
var isDateValid = dateValue && this.dateFormatter.dateIsValid(dateValue);
|
|
3135
|
+
if (!isDateValid || !this.isDateStringValid(value)) {
|
|
3136
|
+
// Mark the invalid control as touched so that the input's invalid CSS styles appear.
|
|
3137
|
+
// (This is only required when the invalid value is set by the FormControl constructor.)
|
|
3138
|
+
this.control.markAsTouched();
|
|
3139
|
+
return {
|
|
3140
|
+
skyDate: {
|
|
3137
3141
|
invalid: value,
|
|
3138
3142
|
},
|
|
3139
3143
|
};
|
|
3140
3144
|
}
|
|
3141
|
-
|
|
3142
|
-
|
|
3143
|
-
|
|
3144
|
-
|
|
3145
|
+
var minDate = this.minDate;
|
|
3146
|
+
if (minDate && this.dateFormatter.dateIsValid(minDate) && value < minDate) {
|
|
3147
|
+
return {
|
|
3148
|
+
skyDate: {
|
|
3149
|
+
minDate: minDate,
|
|
3145
3150
|
},
|
|
3146
3151
|
};
|
|
3147
3152
|
}
|
|
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();
|
|
3153
|
+
var maxDate = this.maxDate;
|
|
3154
|
+
if (maxDate && this.dateFormatter.dateIsValid(maxDate) && value > maxDate) {
|
|
3155
|
+
return {
|
|
3156
|
+
skyDate: {
|
|
3157
|
+
maxDate: maxDate,
|
|
3158
|
+
},
|
|
3159
|
+
};
|
|
3185
3160
|
}
|
|
3186
|
-
return validationError;
|
|
3187
3161
|
};
|
|
3188
|
-
|
|
3162
|
+
SkyDatepickerInputDirective.prototype.registerOnChange = function (fn) {
|
|
3189
3163
|
this.onChange = fn;
|
|
3190
3164
|
};
|
|
3191
|
-
|
|
3165
|
+
SkyDatepickerInputDirective.prototype.registerOnTouched = function (fn) {
|
|
3192
3166
|
this.onTouched = fn;
|
|
3193
3167
|
};
|
|
3194
|
-
|
|
3168
|
+
SkyDatepickerInputDirective.prototype.registerOnValidatorChange = function (fn) {
|
|
3195
3169
|
this.onValidatorChange = fn;
|
|
3196
3170
|
};
|
|
3197
|
-
|
|
3171
|
+
SkyDatepickerInputDirective.prototype.setDisabledState = function (disabled) {
|
|
3198
3172
|
this.disabled = disabled;
|
|
3199
3173
|
this.datepickerComponent.disabled = disabled;
|
|
3200
3174
|
};
|
|
@@ -3202,82 +3176,108 @@
|
|
|
3202
3176
|
* Detects changes to the underlying input element's value and updates the ngModel accordingly.
|
|
3203
3177
|
* This is useful if you need to update the ngModel value before the input element loses focus.
|
|
3204
3178
|
*/
|
|
3205
|
-
|
|
3179
|
+
SkyDatepickerInputDirective.prototype.detectInputValueChange = function () {
|
|
3206
3180
|
this.onValueChange(this.elementRef.nativeElement.value);
|
|
3207
3181
|
};
|
|
3208
|
-
|
|
3182
|
+
SkyDatepickerInputDirective.prototype.applyDateFormat = function () {
|
|
3183
|
+
this.updatePlaceholder();
|
|
3184
|
+
if (this.value) {
|
|
3185
|
+
var formattedDate = this.dateFormatter.format(this.value, this.dateFormat);
|
|
3186
|
+
this.setInputElementValue(formattedDate);
|
|
3187
|
+
this.changeDetector.markForCheck();
|
|
3188
|
+
}
|
|
3189
|
+
};
|
|
3190
|
+
SkyDatepickerInputDirective.prototype.onValueChange = function (newValue) {
|
|
3209
3191
|
this.isFirstChange = false;
|
|
3210
3192
|
this.value = newValue;
|
|
3211
3193
|
};
|
|
3212
|
-
|
|
3194
|
+
SkyDatepickerInputDirective.prototype.setInputElementValue = function (value) {
|
|
3213
3195
|
this.renderer.setProperty(this.elementRef.nativeElement, 'value', value);
|
|
3214
3196
|
};
|
|
3215
|
-
|
|
3216
|
-
|
|
3217
|
-
|
|
3218
|
-
|
|
3219
|
-
|
|
3197
|
+
SkyDatepickerInputDirective.prototype.getDateValue = function (value) {
|
|
3198
|
+
var dateValue;
|
|
3199
|
+
if (value instanceof Date) {
|
|
3200
|
+
dateValue = value;
|
|
3201
|
+
}
|
|
3202
|
+
else if (typeof value === 'string') {
|
|
3203
|
+
var date = this.dateFormatter.getDateFromString(value, this.dateFormat, this.strict);
|
|
3204
|
+
if (this.dateFormatter.dateIsValid(date)) {
|
|
3205
|
+
dateValue = date;
|
|
3220
3206
|
}
|
|
3221
3207
|
}
|
|
3222
|
-
|
|
3223
|
-
|
|
3208
|
+
return dateValue;
|
|
3209
|
+
};
|
|
3210
|
+
/**
|
|
3211
|
+
* Validates the input value to ensure it is formatted correctly.
|
|
3212
|
+
*/
|
|
3213
|
+
SkyDatepickerInputDirective.prototype.isDateStringValid = function (value) {
|
|
3214
|
+
if (!value || typeof value !== 'string') {
|
|
3215
|
+
return true;
|
|
3224
3216
|
}
|
|
3225
|
-
|
|
3217
|
+
// Does the value only include digits, dashes, or slashes?
|
|
3218
|
+
var regexp = /^[\d\/\-]+$/;
|
|
3219
|
+
var isValid = regexp.test(value);
|
|
3220
|
+
if (isValid) {
|
|
3221
|
+
return true;
|
|
3222
|
+
}
|
|
3223
|
+
// If not, does it conform to the standard ISO format?
|
|
3224
|
+
var isValidIso = moment__default["default"](value, moment__default["default"].ISO_8601).isValid();
|
|
3225
|
+
return isValidIso;
|
|
3226
3226
|
};
|
|
3227
|
-
|
|
3228
|
-
|
|
3229
|
-
|
|
3230
|
-
|
|
3231
|
-
|
|
3232
|
-
|
|
3227
|
+
SkyDatepickerInputDirective.prototype.notifyUpdatedValue = function () {
|
|
3228
|
+
this.onChange(this._value);
|
|
3229
|
+
// Do not mark the field as "dirty"
|
|
3230
|
+
// if the field has been initialized with a value.
|
|
3231
|
+
if (this.isFirstChange && this.control) {
|
|
3232
|
+
this.control.markAsPristine();
|
|
3233
3233
|
}
|
|
3234
|
-
|
|
3234
|
+
if (this.isFirstChange && this._value) {
|
|
3235
|
+
this.isFirstChange = false;
|
|
3236
|
+
}
|
|
3237
|
+
this.datepickerComponent.selectedDate = this._value;
|
|
3235
3238
|
};
|
|
3236
|
-
|
|
3237
|
-
|
|
3238
|
-
|
|
3239
|
-
|
|
3240
|
-
((!dateA.day && !dateB.day) || dateA.day === dateB.day) &&
|
|
3241
|
-
((!dateA.month && !dateB.month) || dateA.month === dateB.month) &&
|
|
3242
|
-
((!dateA.year && !dateB.year) || dateA.year === dateB.year));
|
|
3239
|
+
SkyDatepickerInputDirective.prototype.updatePlaceholder = function () {
|
|
3240
|
+
if (!this.initialPlaceholder) {
|
|
3241
|
+
this.adapter.setPlaceholder(this.elementRef, this.dateFormat);
|
|
3242
|
+
}
|
|
3243
3243
|
};
|
|
3244
|
-
return
|
|
3244
|
+
return SkyDatepickerInputDirective;
|
|
3245
3245
|
}());
|
|
3246
|
-
|
|
3247
|
-
|
|
3248
|
-
|
|
3249
|
-
|
|
3246
|
+
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 });
|
|
3247
|
+
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: [
|
|
3248
|
+
SKY_DATEPICKER_VALUE_ACCESSOR,
|
|
3249
|
+
SKY_DATEPICKER_VALIDATOR,
|
|
3250
|
+
SkyDatepickerAdapterService,
|
|
3250
3251
|
], ngImport: i0__namespace });
|
|
3251
|
-
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type:
|
|
3252
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: SkyDatepickerInputDirective, decorators: [{
|
|
3252
3253
|
type: i0.Directive,
|
|
3253
3254
|
args: [{
|
|
3254
|
-
selector: '[
|
|
3255
|
+
selector: '[skyDatepickerInput]',
|
|
3255
3256
|
providers: [
|
|
3256
|
-
|
|
3257
|
-
|
|
3257
|
+
SKY_DATEPICKER_VALUE_ACCESSOR,
|
|
3258
|
+
SKY_DATEPICKER_VALIDATOR,
|
|
3259
|
+
SkyDatepickerAdapterService,
|
|
3258
3260
|
],
|
|
3259
3261
|
}]
|
|
3260
3262
|
}], ctorParameters: function () {
|
|
3261
|
-
return [{ type:
|
|
3263
|
+
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
3264
|
type: i0.Optional
|
|
3263
3265
|
}] }];
|
|
3264
3266
|
}, propDecorators: { dateFormat: [{
|
|
3265
3267
|
type: i0.Input
|
|
3266
3268
|
}], disabled: [{
|
|
3267
3269
|
type: i0.Input
|
|
3268
|
-
}], futureDisabled: [{
|
|
3269
|
-
type: i0.Input
|
|
3270
3270
|
}], maxDate: [{
|
|
3271
3271
|
type: i0.Input
|
|
3272
3272
|
}], minDate: [{
|
|
3273
3273
|
type: i0.Input
|
|
3274
|
-
}],
|
|
3274
|
+
}], skyDatepickerInput: [{
|
|
3275
3275
|
type: i0.Input
|
|
3276
|
-
}],
|
|
3276
|
+
}], skyDatepickerNoValidate: [{
|
|
3277
3277
|
type: i0.Input
|
|
3278
3278
|
}], startingDay: [{
|
|
3279
3279
|
type: i0.Input
|
|
3280
|
-
}],
|
|
3280
|
+
}], strict: [{
|
|
3281
3281
|
type: i0.Input
|
|
3282
3282
|
}], onInputChange: [{
|
|
3283
3283
|
type: i0.HostListener,
|
|
@@ -4468,247 +4468,7 @@
|
|
|
4468
4468
|
exports: [SkyDateRangePickerComponent],
|
|
4469
4469
|
providers: [SkyDateRangeService],
|
|
4470
4470
|
}]
|
|
4471
|
-
}] });
|
|
4472
|
-
|
|
4473
|
-
// tslint:disable:no-forward-ref no-use-before-declare
|
|
4474
|
-
var SKY_TIMEPICKER_VALUE_ACCESSOR = {
|
|
4475
|
-
provide: i2$2.NG_VALUE_ACCESSOR,
|
|
4476
|
-
useExisting: i0.forwardRef(function () { return SkyTimepickerInputDirective; }),
|
|
4477
|
-
multi: true,
|
|
4478
|
-
};
|
|
4479
|
-
var SKY_TIMEPICKER_VALIDATOR = {
|
|
4480
|
-
provide: i2$2.NG_VALIDATORS,
|
|
4481
|
-
useExisting: i0.forwardRef(function () { return SkyTimepickerInputDirective; }),
|
|
4482
|
-
multi: true,
|
|
4483
|
-
};
|
|
4484
|
-
// tslint:enable
|
|
4485
|
-
var SkyTimepickerInputDirective = /** @class */ (function () {
|
|
4486
|
-
function SkyTimepickerInputDirective(renderer, elRef, resourcesService, changeDetector) {
|
|
4487
|
-
this.renderer = renderer;
|
|
4488
|
-
this.elRef = elRef;
|
|
4489
|
-
this.resourcesService = resourcesService;
|
|
4490
|
-
this.changeDetector = changeDetector;
|
|
4491
|
-
this._timeFormat = 'hh';
|
|
4492
|
-
/*istanbul ignore next */
|
|
4493
|
-
this._onChange = function (_) { };
|
|
4494
|
-
/*istanbul ignore next */
|
|
4495
|
-
this._onTouched = function () { };
|
|
4496
|
-
/* istanbul ignore next */
|
|
4497
|
-
this._validatorChange = function () { };
|
|
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
|
-
}
|
|
4644
|
-
}
|
|
4645
|
-
this.renderer.setProperty(this.elRef.nativeElement, 'value', formattedValue);
|
|
4646
|
-
};
|
|
4647
|
-
SkyTimepickerInputDirective.prototype.formatter = function (time) {
|
|
4648
|
-
if (time && typeof time !== 'string' && 'local' in time) {
|
|
4649
|
-
return time;
|
|
4650
|
-
}
|
|
4651
|
-
if (typeof time === 'string') {
|
|
4652
|
-
if (time.length === 0) {
|
|
4653
|
-
return '';
|
|
4654
|
-
}
|
|
4655
|
-
var currentFormat = void 0;
|
|
4656
|
-
var formatTime = void 0;
|
|
4657
|
-
if (this.timeFormat === 'hh') {
|
|
4658
|
-
currentFormat = 'h:mm A';
|
|
4659
|
-
}
|
|
4660
|
-
if (this.timeFormat === 'HH') {
|
|
4661
|
-
currentFormat = 'H:mm';
|
|
4662
|
-
}
|
|
4663
|
-
if (typeof this.returnFormat === 'undefined') {
|
|
4664
|
-
this.returnFormat = currentFormat;
|
|
4665
|
-
}
|
|
4666
|
-
formatTime = {
|
|
4667
|
-
hour: moment__default["default"](time, currentFormat).hour(),
|
|
4668
|
-
minute: moment__default["default"](time, currentFormat).minute(),
|
|
4669
|
-
meridie: moment__default["default"](time, currentFormat).format('A'),
|
|
4670
|
-
timezone: parseInt(moment__default["default"](time, currentFormat).format('Z'), 10),
|
|
4671
|
-
iso8601: moment__default["default"](time, currentFormat).toDate(),
|
|
4672
|
-
local: moment__default["default"](time, currentFormat).format(currentFormat),
|
|
4673
|
-
customFormat: this.returnFormat,
|
|
4674
|
-
};
|
|
4675
|
-
return formatTime;
|
|
4676
|
-
}
|
|
4677
|
-
};
|
|
4678
|
-
SkyTimepickerInputDirective.prototype.updateTimepickerInput = function () {
|
|
4679
|
-
if (this.skyTimepickerInput) {
|
|
4680
|
-
this.skyTimepickerInput.disabled = this.disabled;
|
|
4681
|
-
/* istanbul ignore else */
|
|
4682
|
-
if (this.skyTimepickerInput.selectedTime !== this.modelValue) {
|
|
4683
|
-
this.skyTimepickerInput.selectedTime = this.modelValue;
|
|
4684
|
-
}
|
|
4685
|
-
}
|
|
4686
|
-
};
|
|
4687
|
-
return SkyTimepickerInputDirective;
|
|
4688
|
-
}());
|
|
4689
|
-
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 });
|
|
4690
|
-
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 });
|
|
4691
|
-
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: SkyTimepickerInputDirective, decorators: [{
|
|
4692
|
-
type: i0.Directive,
|
|
4693
|
-
args: [{
|
|
4694
|
-
selector: '[skyTimepickerInput]',
|
|
4695
|
-
providers: [SKY_TIMEPICKER_VALUE_ACCESSOR, SKY_TIMEPICKER_VALIDATOR],
|
|
4696
|
-
}]
|
|
4697
|
-
}], ctorParameters: function () { return [{ type: i0__namespace.Renderer2 }, { type: i0__namespace.ElementRef }, { type: i3__namespace.SkyLibResourcesService }, { type: i0__namespace.ChangeDetectorRef }]; }, propDecorators: { skyTimepickerInput: [{
|
|
4698
|
-
type: i0.Input
|
|
4699
|
-
}], timeFormat: [{
|
|
4700
|
-
type: i0.Input
|
|
4701
|
-
}], returnFormat: [{
|
|
4702
|
-
type: i0.Input
|
|
4703
|
-
}], disabled: [{
|
|
4704
|
-
type: i0.Input
|
|
4705
|
-
}], onChange: [{
|
|
4706
|
-
type: i0.HostListener,
|
|
4707
|
-
args: ['change', ['$event']]
|
|
4708
|
-
}], onBlur: [{
|
|
4709
|
-
type: i0.HostListener,
|
|
4710
|
-
args: ['blur']
|
|
4711
|
-
}] } });
|
|
4471
|
+
}] });
|
|
4712
4472
|
|
|
4713
4473
|
var nextId = 0;
|
|
4714
4474
|
/**
|
|
@@ -5095,6 +4855,246 @@
|
|
|
5095
4855
|
}]
|
|
5096
4856
|
}] } });
|
|
5097
4857
|
|
|
4858
|
+
// tslint:disable:no-forward-ref no-use-before-declare
|
|
4859
|
+
var SKY_TIMEPICKER_VALUE_ACCESSOR = {
|
|
4860
|
+
provide: i2$2.NG_VALUE_ACCESSOR,
|
|
4861
|
+
useExisting: i0.forwardRef(function () { return SkyTimepickerInputDirective; }),
|
|
4862
|
+
multi: true,
|
|
4863
|
+
};
|
|
4864
|
+
var SKY_TIMEPICKER_VALIDATOR = {
|
|
4865
|
+
provide: i2$2.NG_VALIDATORS,
|
|
4866
|
+
useExisting: i0.forwardRef(function () { return SkyTimepickerInputDirective; }),
|
|
4867
|
+
multi: true,
|
|
4868
|
+
};
|
|
4869
|
+
// tslint:enable
|
|
4870
|
+
var SkyTimepickerInputDirective = /** @class */ (function () {
|
|
4871
|
+
function SkyTimepickerInputDirective(renderer, elRef, resourcesService, changeDetector) {
|
|
4872
|
+
this.renderer = renderer;
|
|
4873
|
+
this.elRef = elRef;
|
|
4874
|
+
this.resourcesService = resourcesService;
|
|
4875
|
+
this.changeDetector = changeDetector;
|
|
4876
|
+
this._timeFormat = 'hh';
|
|
4877
|
+
/*istanbul ignore next */
|
|
4878
|
+
this._onChange = function (_) { };
|
|
4879
|
+
/*istanbul ignore next */
|
|
4880
|
+
this._onTouched = function () { };
|
|
4881
|
+
/* istanbul ignore next */
|
|
4882
|
+
this._validatorChange = function () { };
|
|
4883
|
+
}
|
|
4884
|
+
Object.defineProperty(SkyTimepickerInputDirective.prototype, "skyTimepickerInput", {
|
|
4885
|
+
/**
|
|
4886
|
+
* Creates the timepicker input field and picker. Place this attribute on an `input` element,
|
|
4887
|
+
* and wrap the input in a `sky-timepicker` component.
|
|
4888
|
+
* This attribute must be set to the instance of the `sky-timepicker`.
|
|
4889
|
+
* @required
|
|
4890
|
+
*/
|
|
4891
|
+
get: function () {
|
|
4892
|
+
return this._skyTimepickerInput;
|
|
4893
|
+
},
|
|
4894
|
+
set: function (value) {
|
|
4895
|
+
this._skyTimepickerInput = value;
|
|
4896
|
+
this.updateTimepickerInput();
|
|
4897
|
+
},
|
|
4898
|
+
enumerable: false,
|
|
4899
|
+
configurable: true
|
|
4900
|
+
});
|
|
4901
|
+
Object.defineProperty(SkyTimepickerInputDirective.prototype, "timeFormat", {
|
|
4902
|
+
get: function () {
|
|
4903
|
+
return this._timeFormat || 'hh';
|
|
4904
|
+
},
|
|
4905
|
+
/**
|
|
4906
|
+
* Specifies the 12-hour `hh` or 24-hour `HH` time format for the input.
|
|
4907
|
+
* @default "hh"
|
|
4908
|
+
*/
|
|
4909
|
+
set: function (value) {
|
|
4910
|
+
this._timeFormat = value;
|
|
4911
|
+
},
|
|
4912
|
+
enumerable: false,
|
|
4913
|
+
configurable: true
|
|
4914
|
+
});
|
|
4915
|
+
Object.defineProperty(SkyTimepickerInputDirective.prototype, "disabled", {
|
|
4916
|
+
/**
|
|
4917
|
+
* Indicates whether to disable the timepicker.
|
|
4918
|
+
* @default false
|
|
4919
|
+
*/
|
|
4920
|
+
get: function () {
|
|
4921
|
+
return this._disabled || false;
|
|
4922
|
+
},
|
|
4923
|
+
set: function (value) {
|
|
4924
|
+
this._disabled = value;
|
|
4925
|
+
this.updateTimepickerInput();
|
|
4926
|
+
this.renderer.setProperty(this.elRef.nativeElement, 'disabled', value);
|
|
4927
|
+
},
|
|
4928
|
+
enumerable: false,
|
|
4929
|
+
configurable: true
|
|
4930
|
+
});
|
|
4931
|
+
Object.defineProperty(SkyTimepickerInputDirective.prototype, "modelValue", {
|
|
4932
|
+
get: function () {
|
|
4933
|
+
return this._modelValue;
|
|
4934
|
+
},
|
|
4935
|
+
set: function (value) {
|
|
4936
|
+
if (value !== this._modelValue) {
|
|
4937
|
+
this._modelValue = value;
|
|
4938
|
+
this.updateTimepickerInput();
|
|
4939
|
+
this.setInputValue(value);
|
|
4940
|
+
this._validatorChange();
|
|
4941
|
+
this._onChange(value);
|
|
4942
|
+
}
|
|
4943
|
+
},
|
|
4944
|
+
enumerable: false,
|
|
4945
|
+
configurable: true
|
|
4946
|
+
});
|
|
4947
|
+
SkyTimepickerInputDirective.prototype.ngOnInit = function () {
|
|
4948
|
+
var _this = this;
|
|
4949
|
+
this.renderer.addClass(this.elRef.nativeElement, 'sky-form-control');
|
|
4950
|
+
this.pickerChangedSubscription =
|
|
4951
|
+
this.skyTimepickerInput.selectedTimeChanged.subscribe(function (newTime) {
|
|
4952
|
+
_this.writeValue(newTime);
|
|
4953
|
+
_this._onTouched();
|
|
4954
|
+
});
|
|
4955
|
+
/* istanbul ignore else */
|
|
4956
|
+
if (!this.elRef.nativeElement.getAttribute('aria-label')) {
|
|
4957
|
+
this.resourcesService
|
|
4958
|
+
.getString('skyux_timepicker_input_default_label')
|
|
4959
|
+
.subscribe(function (value) {
|
|
4960
|
+
_this.renderer.setAttribute(_this.elRef.nativeElement, 'aria-label', value);
|
|
4961
|
+
});
|
|
4962
|
+
}
|
|
4963
|
+
};
|
|
4964
|
+
SkyTimepickerInputDirective.prototype.ngAfterContentInit = function () {
|
|
4965
|
+
// Watch for the control to be added and initialize the value immediately.
|
|
4966
|
+
/* istanbul ignore else */
|
|
4967
|
+
if (this.control && this.control.parent) {
|
|
4968
|
+
this.control.setValue(this.modelValue, {
|
|
4969
|
+
emitEvent: false,
|
|
4970
|
+
});
|
|
4971
|
+
this.changeDetector.markForCheck();
|
|
4972
|
+
}
|
|
4973
|
+
};
|
|
4974
|
+
SkyTimepickerInputDirective.prototype.ngOnDestroy = function () {
|
|
4975
|
+
this.pickerChangedSubscription.unsubscribe();
|
|
4976
|
+
};
|
|
4977
|
+
SkyTimepickerInputDirective.prototype.ngOnChanges = function () {
|
|
4978
|
+
this.skyTimepickerInput.setFormat(this.timeFormat);
|
|
4979
|
+
this.skyTimepickerInput.returnFormat = this.returnFormat;
|
|
4980
|
+
};
|
|
4981
|
+
SkyTimepickerInputDirective.prototype.onChange = function (event) {
|
|
4982
|
+
this.writeValue(event.target.value);
|
|
4983
|
+
};
|
|
4984
|
+
/* istanbul ignore next */
|
|
4985
|
+
SkyTimepickerInputDirective.prototype.onBlur = function () {
|
|
4986
|
+
this._onTouched();
|
|
4987
|
+
};
|
|
4988
|
+
SkyTimepickerInputDirective.prototype.registerOnChange = function (fn) {
|
|
4989
|
+
this._onChange = fn;
|
|
4990
|
+
};
|
|
4991
|
+
SkyTimepickerInputDirective.prototype.registerOnTouched = function (fn) {
|
|
4992
|
+
this._onTouched = fn;
|
|
4993
|
+
};
|
|
4994
|
+
SkyTimepickerInputDirective.prototype.registerOnValidatorChange = function (fn) {
|
|
4995
|
+
this._validatorChange = fn;
|
|
4996
|
+
};
|
|
4997
|
+
SkyTimepickerInputDirective.prototype.setDisabledState = function (isDisabled) {
|
|
4998
|
+
this.disabled = isDisabled;
|
|
4999
|
+
};
|
|
5000
|
+
SkyTimepickerInputDirective.prototype.writeValue = function (value) {
|
|
5001
|
+
this.modelValue = this.formatter(value);
|
|
5002
|
+
};
|
|
5003
|
+
SkyTimepickerInputDirective.prototype.validate = function (control) {
|
|
5004
|
+
if (!this.control) {
|
|
5005
|
+
this.control = control;
|
|
5006
|
+
}
|
|
5007
|
+
var value = control.value;
|
|
5008
|
+
if (!value) {
|
|
5009
|
+
return undefined;
|
|
5010
|
+
}
|
|
5011
|
+
/* istanbul ignore next */
|
|
5012
|
+
if (value.local === 'Invalid date') {
|
|
5013
|
+
return {
|
|
5014
|
+
skyTime: {
|
|
5015
|
+
invalid: control.value,
|
|
5016
|
+
},
|
|
5017
|
+
};
|
|
5018
|
+
}
|
|
5019
|
+
return undefined;
|
|
5020
|
+
};
|
|
5021
|
+
SkyTimepickerInputDirective.prototype.setInputValue = function (value) {
|
|
5022
|
+
var formattedValue = '';
|
|
5023
|
+
if (value) {
|
|
5024
|
+
var output = moment__default["default"](value).format(value.customFormat);
|
|
5025
|
+
/* istanbul ignore else */
|
|
5026
|
+
if (output !== 'Invalid date') {
|
|
5027
|
+
formattedValue = output;
|
|
5028
|
+
}
|
|
5029
|
+
}
|
|
5030
|
+
this.renderer.setProperty(this.elRef.nativeElement, 'value', formattedValue);
|
|
5031
|
+
};
|
|
5032
|
+
SkyTimepickerInputDirective.prototype.formatter = function (time) {
|
|
5033
|
+
if (time && typeof time !== 'string' && 'local' in time) {
|
|
5034
|
+
return time;
|
|
5035
|
+
}
|
|
5036
|
+
if (typeof time === 'string') {
|
|
5037
|
+
if (time.length === 0) {
|
|
5038
|
+
return '';
|
|
5039
|
+
}
|
|
5040
|
+
var currentFormat = void 0;
|
|
5041
|
+
var formatTime = void 0;
|
|
5042
|
+
if (this.timeFormat === 'hh') {
|
|
5043
|
+
currentFormat = 'h:mm A';
|
|
5044
|
+
}
|
|
5045
|
+
if (this.timeFormat === 'HH') {
|
|
5046
|
+
currentFormat = 'H:mm';
|
|
5047
|
+
}
|
|
5048
|
+
if (typeof this.returnFormat === 'undefined') {
|
|
5049
|
+
this.returnFormat = currentFormat;
|
|
5050
|
+
}
|
|
5051
|
+
formatTime = {
|
|
5052
|
+
hour: moment__default["default"](time, currentFormat).hour(),
|
|
5053
|
+
minute: moment__default["default"](time, currentFormat).minute(),
|
|
5054
|
+
meridie: moment__default["default"](time, currentFormat).format('A'),
|
|
5055
|
+
timezone: parseInt(moment__default["default"](time, currentFormat).format('Z'), 10),
|
|
5056
|
+
iso8601: moment__default["default"](time, currentFormat).toDate(),
|
|
5057
|
+
local: moment__default["default"](time, currentFormat).format(currentFormat),
|
|
5058
|
+
customFormat: this.returnFormat,
|
|
5059
|
+
};
|
|
5060
|
+
return formatTime;
|
|
5061
|
+
}
|
|
5062
|
+
};
|
|
5063
|
+
SkyTimepickerInputDirective.prototype.updateTimepickerInput = function () {
|
|
5064
|
+
if (this.skyTimepickerInput) {
|
|
5065
|
+
this.skyTimepickerInput.disabled = this.disabled;
|
|
5066
|
+
/* istanbul ignore else */
|
|
5067
|
+
if (this.skyTimepickerInput.selectedTime !== this.modelValue) {
|
|
5068
|
+
this.skyTimepickerInput.selectedTime = this.modelValue;
|
|
5069
|
+
}
|
|
5070
|
+
}
|
|
5071
|
+
};
|
|
5072
|
+
return SkyTimepickerInputDirective;
|
|
5073
|
+
}());
|
|
5074
|
+
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 });
|
|
5075
|
+
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 });
|
|
5076
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: SkyTimepickerInputDirective, decorators: [{
|
|
5077
|
+
type: i0.Directive,
|
|
5078
|
+
args: [{
|
|
5079
|
+
selector: '[skyTimepickerInput]',
|
|
5080
|
+
providers: [SKY_TIMEPICKER_VALUE_ACCESSOR, SKY_TIMEPICKER_VALIDATOR],
|
|
5081
|
+
}]
|
|
5082
|
+
}], ctorParameters: function () { return [{ type: i0__namespace.Renderer2 }, { type: i0__namespace.ElementRef }, { type: i3__namespace.SkyLibResourcesService }, { type: i0__namespace.ChangeDetectorRef }]; }, propDecorators: { skyTimepickerInput: [{
|
|
5083
|
+
type: i0.Input
|
|
5084
|
+
}], timeFormat: [{
|
|
5085
|
+
type: i0.Input
|
|
5086
|
+
}], returnFormat: [{
|
|
5087
|
+
type: i0.Input
|
|
5088
|
+
}], disabled: [{
|
|
5089
|
+
type: i0.Input
|
|
5090
|
+
}], onChange: [{
|
|
5091
|
+
type: i0.HostListener,
|
|
5092
|
+
args: ['change', ['$event']]
|
|
5093
|
+
}], onBlur: [{
|
|
5094
|
+
type: i0.HostListener,
|
|
5095
|
+
args: ['blur']
|
|
5096
|
+
}] } });
|
|
5097
|
+
|
|
5098
5098
|
var SkyTimepickerModule = /** @class */ (function () {
|
|
5099
5099
|
function SkyTimepickerModule() {
|
|
5100
5100
|
}
|