@klippa/ngx-enhancy-forms 14.22.10 → 14.22.12
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/esm2020/lib/form/form-element/form-element.component.mjs +36 -7
- package/fesm2015/klippa-ngx-enhancy-forms.mjs +35 -6
- package/fesm2015/klippa-ngx-enhancy-forms.mjs.map +1 -1
- package/fesm2020/klippa-ngx-enhancy-forms.mjs +35 -6
- package/fesm2020/klippa-ngx-enhancy-forms.mjs.map +1 -1
- package/lib/form/form-element/form-element.component.d.ts +5 -2
- package/package.json +1 -1
|
@@ -574,6 +574,7 @@ class FormElementComponent {
|
|
|
574
574
|
this.errorMessages = DEFAULT_ERROR_MESSAGES;
|
|
575
575
|
this.customErrorHandlers = [];
|
|
576
576
|
this.popupState = 'onHover';
|
|
577
|
+
this.subscriptions = [];
|
|
577
578
|
this.setErrorMessageIsTruncated = (isTruncated) => {
|
|
578
579
|
this.errorFullyVisible = !isTruncated;
|
|
579
580
|
};
|
|
@@ -590,10 +591,12 @@ class FormElementComponent {
|
|
|
590
591
|
async ngAfterViewInit() {
|
|
591
592
|
await awaitableForNextCycle();
|
|
592
593
|
this.fieldInput?.setTailTpl(this.tailTpl);
|
|
593
|
-
this.fieldInput?.onTouch.asObservable().subscribe((
|
|
594
|
+
const subscription = this.fieldInput?.onTouch.asObservable().subscribe(() => {
|
|
594
595
|
this.determinePopupState();
|
|
595
596
|
});
|
|
596
|
-
|
|
597
|
+
if (isValueSet(subscription)) {
|
|
598
|
+
this.subscriptions.push(subscription);
|
|
599
|
+
}
|
|
597
600
|
}
|
|
598
601
|
shouldShowErrorMessages() {
|
|
599
602
|
return this.parent?.showErrorMessages !== false;
|
|
@@ -607,21 +610,40 @@ class FormElementComponent {
|
|
|
607
610
|
this.attachedControl = formControl;
|
|
608
611
|
this.parent.registerControl(formControl, this);
|
|
609
612
|
this.input = input;
|
|
610
|
-
this.attachedControl.statusChanges.subscribe((
|
|
613
|
+
const subscription = this.attachedControl.statusChanges.subscribe(() => {
|
|
611
614
|
this.determinePopupState();
|
|
612
615
|
});
|
|
616
|
+
this.subscriptions.push(subscription);
|
|
613
617
|
this.determinePopupState();
|
|
614
618
|
}
|
|
615
619
|
determinePopupState() {
|
|
620
|
+
const prevState = this.popupState;
|
|
616
621
|
if (stringIsSetAndFilled(this.getErrorToShow())) {
|
|
617
622
|
this.popupState = 'onHover';
|
|
618
|
-
return;
|
|
619
623
|
}
|
|
620
|
-
if (isValueSet(this.getWarningToShow())) {
|
|
624
|
+
else if (isValueSet(this.getWarningToShow())) {
|
|
621
625
|
this.popupState = 'lockedOpen';
|
|
626
|
+
}
|
|
627
|
+
else {
|
|
628
|
+
this.popupState = 'onHover';
|
|
629
|
+
}
|
|
630
|
+
this.setUpErrorTooltipListeners(prevState, this.popupState);
|
|
631
|
+
}
|
|
632
|
+
setUpErrorTooltipListeners(prev, current) {
|
|
633
|
+
if (prev === current) {
|
|
622
634
|
return;
|
|
623
635
|
}
|
|
624
|
-
this.
|
|
636
|
+
const containers = [...getAllLimitingContainers(this.elRef.nativeElement), window];
|
|
637
|
+
if (current === 'lockedOpen') {
|
|
638
|
+
containers.forEach(e => {
|
|
639
|
+
e.addEventListener('scroll', this.setErrorTooltipOffset);
|
|
640
|
+
});
|
|
641
|
+
}
|
|
642
|
+
else {
|
|
643
|
+
containers.forEach(e => {
|
|
644
|
+
e.removeEventListener('scroll', this.setErrorTooltipOffset);
|
|
645
|
+
});
|
|
646
|
+
}
|
|
625
647
|
}
|
|
626
648
|
unregisterControl(formControl) {
|
|
627
649
|
this.attachedControl = null;
|
|
@@ -736,7 +758,9 @@ class FormElementComponent {
|
|
|
736
758
|
return isValueSet(this.getWarningToShow());
|
|
737
759
|
}
|
|
738
760
|
closePopup() {
|
|
761
|
+
const prevState = this.popupState;
|
|
739
762
|
this.popupState = 'onHover';
|
|
763
|
+
this.setUpErrorTooltipListeners(prevState, this.popupState);
|
|
740
764
|
}
|
|
741
765
|
togglePopup() {
|
|
742
766
|
if (!this.errorMessageAsTooltip && !this.hasRightOfCaptionError()) {
|
|
@@ -745,12 +769,17 @@ class FormElementComponent {
|
|
|
745
769
|
if (this.errorFullyVisible) {
|
|
746
770
|
return;
|
|
747
771
|
}
|
|
772
|
+
const prevState = this.popupState;
|
|
748
773
|
if (this.popupState === 'lockedOpen') {
|
|
749
774
|
this.popupState = 'onHover';
|
|
750
775
|
}
|
|
751
776
|
else {
|
|
752
777
|
this.popupState = 'lockedOpen';
|
|
753
778
|
}
|
|
779
|
+
this.setUpErrorTooltipListeners(prevState, this.popupState);
|
|
780
|
+
}
|
|
781
|
+
ngOnDestroy() {
|
|
782
|
+
this.subscriptions.forEach(e => e.unsubscribe());
|
|
754
783
|
}
|
|
755
784
|
}
|
|
756
785
|
FormElementComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.8", ngImport: i0, type: FormElementComponent, deps: [{ token: FormComponent, optional: true }, { token: FORM_ERROR_MESSAGES, optional: true }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component });
|