igniteui-angular 22.2.0-rc.0 → 22.2.0-rc.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.
@@ -6,7 +6,7 @@ import { NgControl, NG_VALUE_ACCESSOR, NG_VALIDATORS } from '@angular/forms';
6
6
  import * as i4 from 'igniteui-angular/calendar';
7
7
  import { IgxCalendarComponent, IgxCalendarHeaderTitleTemplateDirective, IgxCalendarHeaderTemplateDirective, IgxCalendarSubheaderTemplateDirective, CalendarSelection } from 'igniteui-angular/calendar';
8
8
  import * as i3 from 'igniteui-angular/input-group';
9
- import { IGX_INPUT_GROUP_TYPE, IgxInputGroupComponent, IgxPrefixDirective, IgxSuffixDirective, IgxHintDirective, IgxInputState, IgxInputDirective, IgxReadOnlyInputDirective, IgxLabelDirective, IgxInputGroupBase } from 'igniteui-angular/input-group';
9
+ import { IGX_INPUT_GROUP_TYPE, IgxInputGroupComponent, IgxPrefixDirective, IgxSuffixDirective, IgxHintDirective, toInputState, IgxInputState, IgxInputDirective, IgxReadOnlyInputDirective, IgxLabelDirective, IgxInputGroupBase } from 'igniteui-angular/input-group';
10
10
  import { Subject, merge, noop, fromEvent } from 'rxjs';
11
11
  import { takeUntil, filter } from 'rxjs/operators';
12
12
  import { IgxButtonDirective, IgxRippleDirective, IgxDividerComponent, IgxDateTimeEditorDirective, IgxTextSelectionDirective } from 'igniteui-angular/directives';
@@ -986,12 +986,8 @@ class IgxDatePickerComponent extends PickerBaseDirective {
986
986
  updateValidity() {
987
987
  // B.P. 18 May 2021: IgxDatePicker does not reset its state upon resetForm #9526
988
988
  if (this._control && !this.disabled && this._control.touchedOrDirty) {
989
- if (this._control.hasValidators && this.inputGroup.isFocused) {
990
- this.inputDirective.valid = this._control.valid ? IgxInputState.VALID : IgxInputState.INVALID;
991
- }
992
- else {
993
- this.inputDirective.valid = this._control.valid ? IgxInputState.INITIAL : IgxInputState.INVALID;
994
- }
989
+ const showSuccess = this._control.hasValidators && this.inputGroup.isFocused;
990
+ this.inputDirective.valid = toInputState(this._control.status, showSuccess ? 'allowed' : 'suppressed');
995
991
  }
996
992
  else {
997
993
  this.inputDirective.valid = IgxInputState.INITIAL;
@@ -2087,12 +2083,8 @@ class IgxDateRangePickerComponent extends PickerBaseDirective {
2087
2083
  }
2088
2084
  setValidityState(inputDirective, isFocused) {
2089
2085
  if (this._control && !this._control.disabled && this._control.touchedOrDirty) {
2090
- if (this._control.hasValidators && isFocused) {
2091
- inputDirective.valid = this._control.valid ? IgxInputState.VALID : IgxInputState.INVALID;
2092
- }
2093
- else {
2094
- inputDirective.valid = this._control.valid ? IgxInputState.INITIAL : IgxInputState.INVALID;
2095
- }
2086
+ const showSuccess = this._control.hasValidators && isFocused;
2087
+ inputDirective.valid = toInputState(this._control.status, showSuccess ? 'allowed' : 'suppressed');
2096
2088
  }
2097
2089
  else {
2098
2090
  inputDirective.valid = IgxInputState.INITIAL;
@@ -2181,25 +2173,16 @@ class IgxDateRangePickerComponent extends PickerBaseDirective {
2181
2173
  updateValidityOnBlur() {
2182
2174
  this._focusedInput = null;
2183
2175
  this.onTouchCallback();
2184
- if (this._ngControl) {
2185
- if (this.hasProjectedInputs) {
2186
- this.projectedInputs.forEach(i => {
2187
- if (!this._ngControl.valid) {
2188
- i.updateInputValidity(IgxInputState.INVALID);
2189
- }
2190
- else {
2191
- i.updateInputValidity(IgxInputState.INITIAL);
2192
- }
2193
- });
2194
- }
2195
- if (this.inputDirective) {
2196
- if (!this._ngControl.valid) {
2197
- this.inputDirective.valid = IgxInputState.INVALID;
2198
- }
2199
- else {
2200
- this.inputDirective.valid = IgxInputState.INITIAL;
2201
- }
2202
- }
2176
+ if (!this._control) {
2177
+ return;
2178
+ }
2179
+ // Blur never shows success, only the error.
2180
+ const state = toInputState(this._control.status, 'suppressed');
2181
+ if (this.hasProjectedInputs) {
2182
+ this.projectedInputs.forEach(i => i.updateInputValidity(state));
2183
+ }
2184
+ if (this.inputDirective) {
2185
+ this.inputDirective.valid = state;
2203
2186
  }
2204
2187
  }
2205
2188
  updateDisabledState() {