@aaamb/ngx-design-system 1.5.2 → 1.5.3

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.
@@ -1,9 +1,9 @@
1
1
  import * as i0 from '@angular/core';
2
- import { input, output, computed, Component, signal, effect, forwardRef, ViewChild, HostListener, ElementRef, CUSTOM_ELEMENTS_SCHEMA, EventEmitter, Input, Output, Attribute } from '@angular/core';
2
+ import { input, output, computed, Component, signal, effect, forwardRef, ViewChild, inject, DestroyRef, HostListener, ElementRef, CUSTOM_ELEMENTS_SCHEMA, EventEmitter, Input, Output, Attribute } from '@angular/core';
3
3
  import * as i1$1 from '@angular/forms';
4
4
  import { NG_VALUE_ACCESSOR, FormsModule, ReactiveFormsModule, FormBuilder, Validators } from '@angular/forms';
5
5
  import * as i2 from '@angular/common';
6
- import { CommonModule, NgClass, NgStyle } from '@angular/common';
6
+ import { CommonModule, NgClass, DOCUMENT, NgStyle } from '@angular/common';
7
7
  import { NgxMaskDirective, provideNgxMask } from 'ngx-mask';
8
8
  import * as i1 from 'ng-zorro-antd/date-picker';
9
9
  import { NzDatePickerModule } from 'ng-zorro-antd/date-picker';
@@ -896,6 +896,7 @@ class InputDatepickerComponent {
896
896
  const formatted = this.formatDate(date);
897
897
  this.selectedDate.set(formatted);
898
898
  this.onChange(formatted);
899
+ this.isDatePickerOpen = false;
899
900
  }
900
901
  onInputTextChange(text) {
901
902
  const rawText = text ?? '';
@@ -1024,7 +1025,8 @@ class InputDatepickerComponent {
1024
1025
  this.isDatePickerOpen = !this.isDatePickerOpen;
1025
1026
  }
1026
1027
  onOpenChange(isOpen) {
1027
- this.isDatePickerOpen = isOpen;
1028
+ if (isOpen)
1029
+ this.isDatePickerOpen = true;
1028
1030
  }
1029
1031
  onInputBlur() {
1030
1032
  this.onTouched();
@@ -1068,15 +1070,13 @@ class InputDatepickerComponent {
1068
1070
  this.cvaDisabled = isDisabled;
1069
1071
  }
1070
1072
  onDocumentClick(event) {
1071
- if (!this.isDatePickerOpen) {
1073
+ if (!this.isDatePickerOpen)
1072
1074
  return;
1073
- }
1074
1075
  const target = event.target;
1075
- const containerElement = this.elementRef?.nativeElement;
1076
- if (target instanceof Element && containerElement?.contains(target)) {
1076
+ if (this.elementRef.nativeElement.contains(target))
1077
1077
  return;
1078
- }
1079
- if (target instanceof Element && target.closest('.cdk-overlay-pane')) {
1078
+ if ([target, ...event.composedPath()].some((node) => node instanceof Element &&
1079
+ node.matches('.cdk-overlay-pane, [class*="ant-picker"]'))) {
1080
1080
  return;
1081
1081
  }
1082
1082
  this.isDatePickerOpen = false;
@@ -1095,6 +1095,16 @@ class InputDatepickerComponent {
1095
1095
  }
1096
1096
  constructor(elementRef) {
1097
1097
  this.elementRef = elementRef;
1098
+ const documentRef = inject(DOCUMENT);
1099
+ const closeOnEscape = (event) => {
1100
+ if (event.key === 'Escape') {
1101
+ event.preventDefault();
1102
+ event.stopImmediatePropagation();
1103
+ this.isDatePickerOpen = false;
1104
+ }
1105
+ };
1106
+ documentRef.addEventListener('keydown', closeOnEscape, true);
1107
+ inject(DestroyRef).onDestroy(() => documentRef.removeEventListener('keydown', closeOnEscape, true));
1098
1108
  }
1099
1109
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.11", ngImport: i0, type: InputDatepickerComponent, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component });
1100
1110
  static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.11", type: InputDatepickerComponent, isStandalone: true, selector: "ads-input-datepicker", inputs: { isPickerDisabled: { classPropertyName: "isPickerDisabled", publicName: "isPickerDisabled", isSignal: true, isRequired: false, transformFunction: null }, datePickerPlaceholder: { classPropertyName: "datePickerPlaceholder", publicName: "datePickerPlaceholder", isSignal: true, isRequired: false, transformFunction: null }, hasError: { classPropertyName: "hasError", publicName: "hasError", isSignal: true, isRequired: false, transformFunction: null }, errorMessage: { classPropertyName: "errorMessage", publicName: "errorMessage", isSignal: true, isRequired: false, transformFunction: null }, futureDatesAllowed: { classPropertyName: "futureDatesAllowed", publicName: "futureDatesAllowed", isSignal: true, isRequired: false, transformFunction: null }, label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, monthlyPicker: { classPropertyName: "monthlyPicker", publicName: "monthlyPicker", isSignal: true, isRequired: false, transformFunction: null } }, host: { listeners: { "document:click": "onDocumentClick($event)" } }, providers: [