@haiilo/catalyst-angular 10.7.0 → 10.8.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.
@@ -300,10 +300,10 @@ let CatDateInline = class CatDateInline {
300
300
  }
301
301
  };
302
302
  CatDateInline.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: CatDateInline, deps: [{ token: i0.ChangeDetectorRef }, { token: i0.ElementRef }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Component });
303
- CatDateInline.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.3.0", type: CatDateInline, selector: "cat-date-inline", inputs: { max: "max", min: "min", noClear: "noClear", noHint: "noHint", noToday: "noToday", noWeeks: "noWeeks", range: "range", size: "size", value: "value" }, ngImport: i0, template: '<ng-content></ng-content>', isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
303
+ CatDateInline.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.3.0", type: CatDateInline, selector: "cat-date-inline", inputs: { hint: "hint", max: "max", min: "min", noClear: "noClear", noToday: "noToday", range: "range", value: "value", weeks: "weeks" }, ngImport: i0, template: '<ng-content></ng-content>', isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
304
304
  CatDateInline = __decorate([
305
305
  ProxyCmp({
306
- inputs: ['max', 'min', 'noClear', 'noHint', 'noToday', 'noWeeks', 'range', 'size', 'value'],
306
+ inputs: ['hint', 'max', 'min', 'noClear', 'noToday', 'range', 'value', 'weeks'],
307
307
  methods: ['select', 'clear', 'resetView']
308
308
  })
309
309
  ], CatDateInline);
@@ -314,7 +314,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImpor
314
314
  changeDetection: ChangeDetectionStrategy.OnPush,
315
315
  template: '<ng-content></ng-content>',
316
316
  // eslint-disable-next-line @angular-eslint/no-inputs-metadata-property
317
- inputs: ['max', 'min', 'noClear', 'noHint', 'noToday', 'noWeeks', 'range', 'size', 'value'],
317
+ inputs: ['hint', 'max', 'min', 'noClear', 'noToday', 'range', 'value', 'weeks'],
318
318
  }]
319
319
  }], ctorParameters: function () { return [{ type: i0.ChangeDetectorRef }, { type: i0.ElementRef }, { type: i0.NgZone }]; } });
320
320
  let CatDatepicker = class CatDatepicker {
@@ -959,17 +959,36 @@ class DateValueAccessor extends ValueAccessor {
959
959
  return this.el.nativeElement;
960
960
  }
961
961
  writeValue(value) {
962
- if (value && value instanceof Date) {
962
+ if (!this.el.nativeElement.range) {
963
+ return super.writeValue(this.toISO(value));
964
+ }
965
+ else if (value instanceof Array) {
966
+ const data = [this.toISO(value[0]), this.toISO(value[1])];
967
+ return super.writeValue(JSON.stringify(data));
968
+ }
969
+ return super.writeValue(undefined);
970
+ }
971
+ handleChangeEvent(value) {
972
+ if (!this.el.nativeElement.range) {
973
+ return super.handleChangeEvent(this.toDate(value));
974
+ }
975
+ else if (typeof value === 'string') {
976
+ return super.handleChangeEvent(JSON.parse(value).map(this.toDate));
977
+ }
978
+ super.handleChangeEvent(null);
979
+ }
980
+ toISO(value) {
981
+ if (value instanceof Date) {
963
982
  const year = value.getFullYear();
964
983
  const month = (value.getMonth() + 1).toString().padStart(2, '0');
965
984
  const day = value.getDate().toString().padStart(2, '0');
966
- return super.writeValue(`${year}-${month}-${day}`);
985
+ return `${year}-${month}-${day}`;
967
986
  }
968
- return super.writeValue(undefined);
987
+ return undefined;
969
988
  }
970
- handleChangeEvent(value) {
989
+ toDate(value) {
971
990
  const [match, year, month, day] = value?.match(/^(\d{4})-(\d{2})-(\d{2})/) ?? [];
972
- return super.handleChangeEvent(match ? new Date(Number(year), Number(month) - 1, Number(day)) : null);
991
+ return match ? new Date(Number(year), Number(month) - 1, Number(day)) : null;
973
992
  }
974
993
  }
975
994
  DateValueAccessor.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: DateValueAccessor, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });