adb-shared 3.0.9 → 3.0.11

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.
@@ -9,7 +9,7 @@ import * as i1 from '@angular/common/http';
9
9
  import { HttpClientModule } from '@angular/common/http';
10
10
  import * as i1$2 from '@angular/router';
11
11
  import { RouterModule } from '@angular/router';
12
- import { startOfDay, subYears, endOfDay, addYears, getMonth, subMonths, addMonths, isSameYear, startOfMonth, endOfMonth, eachWeekOfInterval, getISOWeek, addDays, eachDayOfInterval, getHours, getMinutes, isSameDay, isSameMonth, isWithinInterval, isValid, parseISO } from 'date-fns';
12
+ import { startOfDay, subYears, endOfDay, addYears, getMonth, subMonths, addMonths, isSameYear, startOfMonth, endOfMonth, eachWeekOfInterval, getISOWeek, addDays, eachDayOfInterval, getHours, getMinutes, isSameDay, isSameMonth, isWithinInterval, isValid, parseISO, parse } from 'date-fns';
13
13
  import { NG_VALUE_ACCESSOR, NG_VALIDATORS } from '@angular/forms';
14
14
  import { delay } from 'rxjs/operators';
15
15
 
@@ -718,7 +718,6 @@ class AdbDatePickerDirective {
718
718
  this.id = this.getId();
719
719
  viewRef.instance.id = this.id;
720
720
  viewRef.instance.selectDate.subscribe((date) => {
721
- this.elementRef.nativeElement.classList.remove('ng-invalid');
722
721
  this.renderer.setProperty(this.elementRef.nativeElement, 'value', formatDate(date, this.format, this.translate.currentLang));
723
722
  this.onChange(date);
724
723
  this.initialDate = date;
@@ -770,7 +769,7 @@ class AdbDatePickerDirective {
770
769
  return null;
771
770
  }
772
771
  if (typeof value === 'string' || value instanceof String) {
773
- const date = AdbDatePickerDirective.tryParse(value);
772
+ const date = AdbDatePickerDirective.tryParse(value, this.format);
774
773
  if (!date) {
775
774
  return { date: true };
776
775
  }
@@ -783,7 +782,7 @@ class AdbDatePickerDirective {
783
782
  writeValue(value) {
784
783
  if (value) {
785
784
  if (typeof value === 'string' || value instanceof String) {
786
- const date = AdbDatePickerDirective.tryParse(value);
785
+ const date = AdbDatePickerDirective.tryParse(value, this.format);
787
786
  if (!date) {
788
787
  this.renderer.setProperty(this.elementRef.nativeElement, 'value', value);
789
788
  return;
@@ -808,8 +807,8 @@ class AdbDatePickerDirective {
808
807
  setDisabledState(isDisabled) {
809
808
  this.viewContainerRef.clear();
810
809
  }
811
- static tryParse(dateString) {
812
- const parsed = parseISO(dateString);
810
+ static tryParse(dateString, format) {
811
+ const parsed = parse(dateString, format, new Date());
813
812
  return isValid(parsed) ? parsed : null;
814
813
  }
815
814
  getId() {