@skyux/datetime 5.6.1 → 5.7.1
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 +162 -153
- package/documentation.json +674 -813
- 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-range-picker/date-range-picker.component.js +47 -58
- package/esm2015/lib/modules/date-range-picker/date-range-picker.component.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/datepicker-calendar-inner.component.js.map +1 -1
- package/esm2015/lib/modules/datepicker/datepicker-input-fuzzy.directive.js +60 -50
- package/esm2015/lib/modules/datepicker/datepicker-input-fuzzy.directive.js.map +1 -1
- package/esm2015/lib/modules/datepicker/datepicker-input.directive.js +50 -39
- package/esm2015/lib/modules/datepicker/datepicker-input.directive.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.directive.js +3 -3
- package/esm2015/lib/modules/timepicker/timepicker.directive.js.map +1 -1
- package/fesm2015/skyux-datetime.js +160 -155
- 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 +4 -3
- package/lib/modules/date-range-picker/types/date-range-relative-value.d.ts +0 -1
- package/lib/modules/datepicker/datepicker-calendar-inner.component.d.ts +16 -13
- package/lib/modules/datepicker/datepicker-input-fuzzy.directive.d.ts +6 -1
- package/lib/modules/datepicker/datepicker-input.directive.d.ts +6 -2
- package/lib/modules/shared/sky-datetime-resources.module.d.ts +1 -1
- package/package.json +8 -8
|
@@ -37,7 +37,6 @@
|
|
|
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) {
|
|
@@ -143,7 +142,7 @@
|
|
|
143
142
|
/**
|
|
144
143
|
* NOTICE: DO NOT MODIFY THIS FILE!
|
|
145
144
|
* The contents of this file were automatically generated by
|
|
146
|
-
* the 'ng generate @skyux/i18n:lib-resources-module modules/shared/sky-datetime' schematic.
|
|
145
|
+
* the 'ng generate @skyux/i18n:lib-resources-module lib/modules/shared/sky-datetime' schematic.
|
|
147
146
|
* To update this file, simply rerun the command.
|
|
148
147
|
*/
|
|
149
148
|
var RESOURCES = {
|
|
@@ -2370,14 +2369,15 @@
|
|
|
2370
2369
|
*/
|
|
2371
2370
|
this.skyDatepickerNoValidate = false;
|
|
2372
2371
|
this.dateFormatter = new SkyDateFormatter();
|
|
2373
|
-
this.isFirstChange = true;
|
|
2374
2372
|
this.ngUnsubscribe = new rxjs.Subject();
|
|
2375
2373
|
this._futureDisabled = false;
|
|
2376
2374
|
this._disabled = false;
|
|
2377
2375
|
this._yearRequired = false;
|
|
2376
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
2378
2377
|
this.onChange = function (_) { };
|
|
2379
|
-
|
|
2378
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
2380
2379
|
this.onTouched = function () { };
|
|
2380
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
2381
2381
|
this.onValidatorChange = function () { };
|
|
2382
2382
|
this.localeProvider
|
|
2383
2383
|
.getLocaleInfo()
|
|
@@ -2488,7 +2488,9 @@
|
|
|
2488
2488
|
* through the `ngModel` attribute specified on the `input` element.
|
|
2489
2489
|
* @required
|
|
2490
2490
|
*/
|
|
2491
|
-
set: function (value) {
|
|
2491
|
+
set: function (value) {
|
|
2492
|
+
// TODO: Remove this property in a future version of SKY UX.
|
|
2493
|
+
},
|
|
2492
2494
|
enumerable: false,
|
|
2493
2495
|
configurable: true
|
|
2494
2496
|
});
|
|
@@ -2530,50 +2532,7 @@
|
|
|
2530
2532
|
return this._value;
|
|
2531
2533
|
},
|
|
2532
2534
|
set: function (value) {
|
|
2533
|
-
|
|
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);
|
|
2541
|
-
}
|
|
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
|
-
}
|
|
2552
|
-
}
|
|
2553
|
-
else {
|
|
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
|
-
}
|
|
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 || '');
|
|
2535
|
+
this.updateValue(value);
|
|
2577
2536
|
},
|
|
2578
2537
|
enumerable: false,
|
|
2579
2538
|
configurable: true
|
|
@@ -2607,7 +2566,6 @@
|
|
|
2607
2566
|
this.datepickerComponent.dateChange
|
|
2608
2567
|
.pipe(operators.distinctUntilChanged(), operators.takeUntil(this.ngUnsubscribe))
|
|
2609
2568
|
.subscribe(function (value) {
|
|
2610
|
-
_this.isFirstChange = false;
|
|
2611
2569
|
_this.value = value;
|
|
2612
2570
|
_this.onTouched();
|
|
2613
2571
|
});
|
|
@@ -2647,7 +2605,7 @@
|
|
|
2647
2605
|
this.control.markAsDirty();
|
|
2648
2606
|
};
|
|
2649
2607
|
SkyFuzzyDatepickerInputDirective.prototype.writeValue = function (value) {
|
|
2650
|
-
this.value
|
|
2608
|
+
this.updateValue(value, false);
|
|
2651
2609
|
};
|
|
2652
2610
|
SkyFuzzyDatepickerInputDirective.prototype.validate = function (control) {
|
|
2653
2611
|
if (!this.control) {
|
|
@@ -2743,7 +2701,6 @@
|
|
|
2743
2701
|
this.onValueChange(this.elementRef.nativeElement.value);
|
|
2744
2702
|
};
|
|
2745
2703
|
SkyFuzzyDatepickerInputDirective.prototype.onValueChange = function (newValue) {
|
|
2746
|
-
this.isFirstChange = false;
|
|
2747
2704
|
this.value = newValue;
|
|
2748
2705
|
};
|
|
2749
2706
|
SkyFuzzyDatepickerInputDirective.prototype.setInputElementValue = function (value) {
|
|
@@ -2778,6 +2735,59 @@
|
|
|
2778
2735
|
((!dateA.month && !dateB.month) || dateA.month === dateB.month) &&
|
|
2779
2736
|
((!dateA.year && !dateB.year) || dateA.year === dateB.year));
|
|
2780
2737
|
};
|
|
2738
|
+
/**
|
|
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.
|
|
2742
|
+
*/
|
|
2743
|
+
SkyFuzzyDatepickerInputDirective.prototype.updateValue = function (value, emitEvent) {
|
|
2744
|
+
if (emitEvent === void 0) { emitEvent = true; }
|
|
2745
|
+
var _a;
|
|
2746
|
+
if (this._value === value) {
|
|
2747
|
+
return;
|
|
2748
|
+
}
|
|
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);
|
|
2757
|
+
}
|
|
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
|
+
}
|
|
2768
|
+
}
|
|
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
|
+
}
|
|
2776
|
+
}
|
|
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;
|
|
2788
|
+
}
|
|
2789
|
+
this.setInputElementValue(formattedDate || '');
|
|
2790
|
+
};
|
|
2781
2791
|
return SkyFuzzyDatepickerInputDirective;
|
|
2782
2792
|
}());
|
|
2783
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 });
|
|
@@ -2856,11 +2866,12 @@
|
|
|
2856
2866
|
*/
|
|
2857
2867
|
this.skyDatepickerNoValidate = false;
|
|
2858
2868
|
this.dateFormatter = new SkyDateFormatter();
|
|
2859
|
-
this.isFirstChange = true;
|
|
2860
2869
|
this.ngUnsubscribe = new rxjs.Subject();
|
|
2870
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
2861
2871
|
this.onChange = function (_) { };
|
|
2862
|
-
|
|
2872
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
2863
2873
|
this.onTouched = function () { };
|
|
2874
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
2864
2875
|
this.onValidatorChange = function () { };
|
|
2865
2876
|
this.initialPlaceholder = this.adapter.getPlaceholder(this.elementRef);
|
|
2866
2877
|
this.updatePlaceholder();
|
|
@@ -3014,28 +3025,7 @@
|
|
|
3014
3025
|
return this._value;
|
|
3015
3026
|
},
|
|
3016
3027
|
set: function (value) {
|
|
3017
|
-
|
|
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();
|
|
3027
|
-
}
|
|
3028
|
-
else if (dateValue !== this._value || !areDatesEqual) {
|
|
3029
|
-
this._value = dateValue || value;
|
|
3030
|
-
this.notifyUpdatedValue();
|
|
3031
|
-
}
|
|
3032
|
-
if (dateValue && isValidDateString) {
|
|
3033
|
-
var formattedDate = this.dateFormatter.format(dateValue, this.dateFormat);
|
|
3034
|
-
this.setInputElementValue(formattedDate);
|
|
3035
|
-
}
|
|
3036
|
-
else {
|
|
3037
|
-
this.setInputElementValue(value || '');
|
|
3038
|
-
}
|
|
3028
|
+
this.updateValue(value);
|
|
3039
3029
|
},
|
|
3040
3030
|
enumerable: false,
|
|
3041
3031
|
configurable: true
|
|
@@ -3064,7 +3054,6 @@
|
|
|
3064
3054
|
.pipe(operators.distinctUntilChanged())
|
|
3065
3055
|
.pipe(operators.takeUntil(this.ngUnsubscribe))
|
|
3066
3056
|
.subscribe(function (value) {
|
|
3067
|
-
_this.isFirstChange = false;
|
|
3068
3057
|
_this.value = value;
|
|
3069
3058
|
_this.onTouched();
|
|
3070
3059
|
});
|
|
@@ -3117,7 +3106,7 @@
|
|
|
3117
3106
|
this.control.markAsDirty();
|
|
3118
3107
|
};
|
|
3119
3108
|
SkyDatepickerInputDirective.prototype.writeValue = function (value) {
|
|
3120
|
-
this.value
|
|
3109
|
+
this.updateValue(value, false);
|
|
3121
3110
|
};
|
|
3122
3111
|
SkyDatepickerInputDirective.prototype.validate = function (control) {
|
|
3123
3112
|
if (!this.control) {
|
|
@@ -3188,7 +3177,6 @@
|
|
|
3188
3177
|
}
|
|
3189
3178
|
};
|
|
3190
3179
|
SkyDatepickerInputDirective.prototype.onValueChange = function (newValue) {
|
|
3191
|
-
this.isFirstChange = false;
|
|
3192
3180
|
this.value = newValue;
|
|
3193
3181
|
};
|
|
3194
3182
|
SkyDatepickerInputDirective.prototype.setInputElementValue = function (value) {
|
|
@@ -3224,23 +3212,57 @@
|
|
|
3224
3212
|
var isValidIso = moment__default["default"](value, moment__default["default"].ISO_8601).isValid();
|
|
3225
3213
|
return isValidIso;
|
|
3226
3214
|
};
|
|
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
|
-
}
|
|
3234
|
-
if (this.isFirstChange && this._value) {
|
|
3235
|
-
this.isFirstChange = false;
|
|
3236
|
-
}
|
|
3237
|
-
this.datepickerComponent.selectedDate = this._value;
|
|
3238
|
-
};
|
|
3239
3215
|
SkyDatepickerInputDirective.prototype.updatePlaceholder = function () {
|
|
3240
3216
|
if (!this.initialPlaceholder) {
|
|
3241
3217
|
this.adapter.setPlaceholder(this.elementRef, this.dateFormat);
|
|
3242
3218
|
}
|
|
3243
3219
|
};
|
|
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
|
+
}
|
|
3265
|
+
};
|
|
3244
3266
|
return SkyDatepickerInputDirective;
|
|
3245
3267
|
}());
|
|
3246
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 });
|
|
@@ -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: [{
|
|
@@ -5192,11 +5201,11 @@
|
|
|
5192
5201
|
this.resourcesService = resourcesService;
|
|
5193
5202
|
this.changeDetector = changeDetector;
|
|
5194
5203
|
this._timeFormat = 'hh';
|
|
5195
|
-
|
|
5204
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
5196
5205
|
this._onChange = function (_) { };
|
|
5197
|
-
|
|
5206
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
5198
5207
|
this._onTouched = function () { };
|
|
5199
|
-
|
|
5208
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
5200
5209
|
this._validatorChange = function () { };
|
|
5201
5210
|
}
|
|
5202
5211
|
Object.defineProperty(SkyTimepickerInputDirective.prototype, "skyTimepickerInput", {
|