@verisoft/ui-govcz 21.0.6 → 21.0.8
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,5 +1,5 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { Component, Pipe, ChangeDetectionStrategy, CUSTOM_ELEMENTS_SCHEMA, EventEmitter, Output, Input, inject, Optional, Self, input, SimpleChange, Injectable, ChangeDetectorRef, Injector, ViewContainerRef, ViewChild, HostListener, ViewEncapsulation, NO_ERRORS_SCHEMA, output, ContentChild, ContentChildren, NgModule, Inject, signal, Directive, forwardRef, InjectionToken } from '@angular/core';
|
|
2
|
+
import { Component, Pipe, ChangeDetectionStrategy, CUSTOM_ELEMENTS_SCHEMA, EventEmitter, Output, Input, inject, Optional, Self, input, SimpleChange, Injectable, ChangeDetectorRef, Injector, ViewContainerRef, ViewChild, ElementRef, HostListener, ViewEncapsulation, NO_ERRORS_SCHEMA, output, ContentChild, ContentChildren, NgModule, Inject, signal, Directive, forwardRef, InjectionToken } from '@angular/core';
|
|
3
3
|
import * as i1 from '@angular/router';
|
|
4
4
|
import { RouterModule, Router, ActivatedRoute, NavigationEnd, RouterLink, RouterLinkActive, RouterOutlet } from '@angular/router';
|
|
5
5
|
import * as i2 from '@gov-design-system-ce/angular';
|
|
@@ -639,15 +639,31 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.6", ngImpor
|
|
|
639
639
|
class ConfirmDialogComponent extends UnsubscribeComponent {
|
|
640
640
|
dialogService = inject(DialogService);
|
|
641
641
|
cdr = inject(ChangeDetectorRef);
|
|
642
|
+
elementRef = inject(ElementRef);
|
|
643
|
+
confirmButton;
|
|
644
|
+
cancelButton;
|
|
642
645
|
visible = false;
|
|
643
646
|
closable = false;
|
|
644
647
|
data = { severity: 'primary', headerIcon: 'info-circle' };
|
|
648
|
+
confirmButtonDisabled = false;
|
|
645
649
|
ngOnInit() {
|
|
646
650
|
this.dialogService.showEvent
|
|
647
651
|
.pipe(takeUntil(this.destroyed$))
|
|
648
652
|
.subscribe((x) => {
|
|
649
653
|
this.data = x;
|
|
650
654
|
this.visible = true;
|
|
655
|
+
this.confirmButtonDisabled = false;
|
|
656
|
+
if (x.data && typeof x.data === 'object' && 'registerComponent' in x.data) {
|
|
657
|
+
setTimeout(() => {
|
|
658
|
+
const dialogComponent = x.data.componentInstance;
|
|
659
|
+
if (dialogComponent?.isValid$) {
|
|
660
|
+
dialogComponent.isValid$.pipe(takeUntil(this.destroyed$)).subscribe((valid) => {
|
|
661
|
+
this.confirmButtonDisabled = !valid;
|
|
662
|
+
this.cdr.detectChanges();
|
|
663
|
+
});
|
|
664
|
+
}
|
|
665
|
+
}, 100);
|
|
666
|
+
}
|
|
651
667
|
this.cdr.detectChanges();
|
|
652
668
|
});
|
|
653
669
|
this.dialogService.closeEvent
|
|
@@ -655,6 +671,7 @@ class ConfirmDialogComponent extends UnsubscribeComponent {
|
|
|
655
671
|
.subscribe(() => {
|
|
656
672
|
this.data = {};
|
|
657
673
|
this.visible = false;
|
|
674
|
+
this.confirmButtonDisabled = false;
|
|
658
675
|
this.cdr.detectChanges();
|
|
659
676
|
});
|
|
660
677
|
}
|
|
@@ -667,29 +684,79 @@ class ConfirmDialogComponent extends UnsubscribeComponent {
|
|
|
667
684
|
activeElement.tagName === 'SELECT' ||
|
|
668
685
|
activeElement.isContentEditable);
|
|
669
686
|
if (event.key === 'Enter') {
|
|
687
|
+
if (this.confirmButtonDisabled)
|
|
688
|
+
return;
|
|
670
689
|
event.preventDefault();
|
|
671
|
-
|
|
672
|
-
|
|
690
|
+
event.stopPropagation();
|
|
691
|
+
if (isInputField) {
|
|
692
|
+
this.focusConfirmButton();
|
|
693
|
+
setTimeout(() => {
|
|
694
|
+
this.dialogClick(true);
|
|
695
|
+
}, 50);
|
|
673
696
|
}
|
|
674
|
-
|
|
697
|
+
else {
|
|
675
698
|
this.dialogClick(true);
|
|
676
|
-
}
|
|
699
|
+
}
|
|
677
700
|
}
|
|
678
701
|
if (event.key === ' ' && !isInputField) {
|
|
702
|
+
if (this.confirmButtonDisabled)
|
|
703
|
+
return;
|
|
679
704
|
event.preventDefault();
|
|
680
705
|
this.dialogClick(true);
|
|
681
706
|
}
|
|
682
707
|
if (event.key === 'Escape') {
|
|
683
708
|
event.preventDefault();
|
|
684
|
-
|
|
685
|
-
|
|
709
|
+
event.stopPropagation();
|
|
710
|
+
if (isInputField) {
|
|
711
|
+
this.focusCancelButton();
|
|
712
|
+
setTimeout(() => {
|
|
713
|
+
this.dialogClick(false);
|
|
714
|
+
}, 50);
|
|
686
715
|
}
|
|
687
|
-
|
|
716
|
+
else {
|
|
688
717
|
this.dialogClick(false);
|
|
689
|
-
}
|
|
718
|
+
}
|
|
719
|
+
}
|
|
720
|
+
}
|
|
721
|
+
focusConfirmButton() {
|
|
722
|
+
if (this.confirmButton?.nativeElement) {
|
|
723
|
+
this.focusButton(this.confirmButton.nativeElement);
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
focusCancelButton() {
|
|
727
|
+
if (this.cancelButton?.nativeElement) {
|
|
728
|
+
this.focusButton(this.cancelButton.nativeElement);
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
focusButton(element) {
|
|
732
|
+
try {
|
|
733
|
+
if (element.tagName === 'BUTTON') {
|
|
734
|
+
element.focus();
|
|
735
|
+
return;
|
|
736
|
+
}
|
|
737
|
+
const button = element.querySelector('button');
|
|
738
|
+
if (button) {
|
|
739
|
+
button.focus();
|
|
740
|
+
return;
|
|
741
|
+
}
|
|
742
|
+
const shadowRoot = element.shadowRoot;
|
|
743
|
+
if (shadowRoot) {
|
|
744
|
+
const shadowButton = shadowRoot.querySelector('button');
|
|
745
|
+
if (shadowButton) {
|
|
746
|
+
shadowButton.focus();
|
|
747
|
+
return;
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
element.focus();
|
|
751
|
+
}
|
|
752
|
+
catch (error) {
|
|
753
|
+
console.warn('Failed to focus button:', error);
|
|
690
754
|
}
|
|
691
755
|
}
|
|
692
756
|
dialogClick(confirm) {
|
|
757
|
+
if (confirm && this.confirmButtonDisabled) {
|
|
758
|
+
return;
|
|
759
|
+
}
|
|
693
760
|
const { confirmButtonFn, cancelButtonFn } = this.data;
|
|
694
761
|
if (confirm && confirmButtonFn) {
|
|
695
762
|
confirmButtonFn();
|
|
@@ -703,7 +770,7 @@ class ConfirmDialogComponent extends UnsubscribeComponent {
|
|
|
703
770
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: ConfirmDialogComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
704
771
|
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.0.6", type: ConfirmDialogComponent, isStandalone: true, selector: "v-confirm-dialog", host: { listeners: { "document:keydown": "onKeyDown($event)" }, properties: { "attr.tabindex": "visible ? \"0\" : null" } }, providers: [
|
|
705
772
|
{ provide: CONFIRM_DIALOG_COMPONENT_TOKEN, useExisting: ConfirmDialogComponent },
|
|
706
|
-
], usesInheritance: true, ngImport: i0, template: "<gov-dialog\n [open]=\"visible\"\n [attr.block-close]=\"data.closable !== undefined ? !data.closable : false\"\n [attr.block-backdrop-close]=\"data.closable !== undefined ? !data.closable : false\" \n [style.--dialog-max-width]=\"data.width\"\n [style.--dialog-max-height]=\"data.height\"\n role=\"dialog\"\n accessible-close-label=\"Close dialog box with more information\"\n (gov-close)=\"data.cancelButtonFn ? dialogClick(false) : (visible = false)\"\n>\n <gov-icon\n type=\"components\"\n [name]=\"data.headerIcon\"\n slot=\"icon\"\n [color]=\"data.severity | govColor\"\n />\n \n <h2 slot=\"title\">{{ data.title ?? 'Title' }}</h2>\n\n @if (data && data.innerHTML) {\n <div [innerHTML]=\"data.innerHTML\"></div>\n } @else if (data.componentType) {\n <v-dynamic-component\n [componentType]=\"data.componentType\"\n [data]=\"$any(data.data)\"\n ></v-dynamic-component>\n }\n\n <gov-button\n #confirmButton\n color=\"primary\"\n size=\"m\"\n type=\"solid\"\n slot=\"footer\"\n (gov-click)=\"data.confirmButtonFn ? dialogClick(true) : (visible = false)\"\n >\n {{ data.confirmButtonText ?? 'Yes'}}\n </gov-button>\n \n <gov-button\n #cancelButton\n [ngClass]=\"!data.showCancelButton ? 'd-none' : ''\"\n color=\"primary\"\n size=\"m\"\n type=\"outlined\"\n slot=\"footer\"\n [disabled]=\"!data.showCancelButton\"\n (gov-click)=\"data.cancelButtonFn ? dialogClick(false) : (visible = false)\"\n >\n {{ data.cancelButtonText ?? 'No' }}\n </gov-button>\n</gov-dialog>", styles: [":host ::ng-deep dialog{max-width:var(--dialog-max-width, 95%);max-height:var(--dialog-max-height, 95%)}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1$1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "ngmodule", type: GovDesignSystemModule }, { kind: "component", type: i2.GovButton, selector: "gov-button", inputs: ["color", "disabled", "download", "expanded", "expandedMobile", "focusable", "href", "hreflang", "identifier", "loading", "name", "nativeType", "referrerpolicy", "rel", "size", "target", "type"] }, { kind: "component", type: i2.GovDialog, selector: "gov-dialog", inputs: ["accessibleCloseLabel", "accessibleCloseLabelledBy", "accessibleDescribedBy", "accessibleLabelledBy", "blockBackdropClose", "blockClose", "labelTag", "open", "role"] }, { kind: "component", type: i2.GovIcon, selector: "gov-icon", inputs: ["color", "name", "size", "type"] }, { kind: "component", type: DynamicComponent, selector: "v-dynamic-component", inputs: ["componentType", "data"] }, { kind: "pipe", type: GovColorPipe, name: "govColor" }] });
|
|
773
|
+
], viewQueries: [{ propertyName: "confirmButton", first: true, predicate: ["confirmButton"], descendants: true, read: ElementRef }, { propertyName: "cancelButton", first: true, predicate: ["cancelButton"], descendants: true, read: ElementRef }], usesInheritance: true, ngImport: i0, template: "<gov-dialog\n [open]=\"visible\"\n [attr.block-close]=\"data.closable !== undefined ? !data.closable : false\"\n [attr.block-backdrop-close]=\"data.closable !== undefined ? !data.closable : false\" \n [style.--dialog-max-width]=\"data.width\"\n [style.--dialog-max-height]=\"data.height\"\n role=\"dialog\"\n accessible-close-label=\"Close dialog box with more information\"\n (gov-close)=\"data.cancelButtonFn ? dialogClick(false) : (visible = false)\"\n>\n <gov-icon\n type=\"components\"\n [name]=\"data.headerIcon\"\n slot=\"icon\"\n [color]=\"data.severity | govColor\"\n />\n \n <h2 slot=\"title\">{{ data.title ?? 'Title' }}</h2>\n\n @if (data && data.innerHTML) {\n <div [innerHTML]=\"data.innerHTML\"></div>\n } @else if (data.componentType) {\n <v-dynamic-component\n [componentType]=\"data.componentType\"\n [data]=\"$any(data.data)\"\n ></v-dynamic-component>\n }\n\n <gov-button\n #confirmButton\n color=\"primary\"\n size=\"m\"\n type=\"solid\"\n slot=\"footer\"\n [disabled]=\"confirmButtonDisabled\"\n (gov-click)=\"data.confirmButtonFn ? dialogClick(true) : (visible = false)\"\n >\n {{ data.confirmButtonText ?? 'Yes'}}\n </gov-button>\n \n <gov-button\n #cancelButton\n [ngClass]=\"!data.showCancelButton ? 'd-none' : ''\"\n color=\"primary\"\n size=\"m\"\n type=\"outlined\"\n slot=\"footer\"\n [disabled]=\"!data.showCancelButton\"\n (gov-click)=\"data.cancelButtonFn ? dialogClick(false) : (visible = false)\"\n >\n {{ data.cancelButtonText ?? 'No' }}\n </gov-button>\n</gov-dialog>", styles: [":host ::ng-deep dialog{max-width:var(--dialog-max-width, 95%);max-height:var(--dialog-max-height, 95%)}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1$1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "ngmodule", type: GovDesignSystemModule }, { kind: "component", type: i2.GovButton, selector: "gov-button", inputs: ["color", "disabled", "download", "expanded", "expandedMobile", "focusable", "href", "hreflang", "identifier", "loading", "name", "nativeType", "referrerpolicy", "rel", "size", "target", "type"] }, { kind: "component", type: i2.GovDialog, selector: "gov-dialog", inputs: ["accessibleCloseLabel", "accessibleCloseLabelledBy", "accessibleDescribedBy", "accessibleLabelledBy", "blockBackdropClose", "blockClose", "labelTag", "open", "role"] }, { kind: "component", type: i2.GovIcon, selector: "gov-icon", inputs: ["color", "name", "size", "type"] }, { kind: "component", type: DynamicComponent, selector: "v-dynamic-component", inputs: ["componentType", "data"] }, { kind: "pipe", type: GovColorPipe, name: "govColor" }] });
|
|
707
774
|
}
|
|
708
775
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: ConfirmDialogComponent, decorators: [{
|
|
709
776
|
type: Component,
|
|
@@ -712,8 +779,14 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.6", ngImpor
|
|
|
712
779
|
], host: {
|
|
713
780
|
'(document:keydown)': 'onKeyDown($event)',
|
|
714
781
|
'[attr.tabindex]': 'visible ? "0" : null',
|
|
715
|
-
}, template: "<gov-dialog\n [open]=\"visible\"\n [attr.block-close]=\"data.closable !== undefined ? !data.closable : false\"\n [attr.block-backdrop-close]=\"data.closable !== undefined ? !data.closable : false\" \n [style.--dialog-max-width]=\"data.width\"\n [style.--dialog-max-height]=\"data.height\"\n role=\"dialog\"\n accessible-close-label=\"Close dialog box with more information\"\n (gov-close)=\"data.cancelButtonFn ? dialogClick(false) : (visible = false)\"\n>\n <gov-icon\n type=\"components\"\n [name]=\"data.headerIcon\"\n slot=\"icon\"\n [color]=\"data.severity | govColor\"\n />\n \n <h2 slot=\"title\">{{ data.title ?? 'Title' }}</h2>\n\n @if (data && data.innerHTML) {\n <div [innerHTML]=\"data.innerHTML\"></div>\n } @else if (data.componentType) {\n <v-dynamic-component\n [componentType]=\"data.componentType\"\n [data]=\"$any(data.data)\"\n ></v-dynamic-component>\n }\n\n <gov-button\n #confirmButton\n color=\"primary\"\n size=\"m\"\n type=\"solid\"\n slot=\"footer\"\n (gov-click)=\"data.confirmButtonFn ? dialogClick(true) : (visible = false)\"\n >\n {{ data.confirmButtonText ?? 'Yes'}}\n </gov-button>\n \n <gov-button\n #cancelButton\n [ngClass]=\"!data.showCancelButton ? 'd-none' : ''\"\n color=\"primary\"\n size=\"m\"\n type=\"outlined\"\n slot=\"footer\"\n [disabled]=\"!data.showCancelButton\"\n (gov-click)=\"data.cancelButtonFn ? dialogClick(false) : (visible = false)\"\n >\n {{ data.cancelButtonText ?? 'No' }}\n </gov-button>\n</gov-dialog>", styles: [":host ::ng-deep dialog{max-width:var(--dialog-max-width, 95%);max-height:var(--dialog-max-height, 95%)}\n"] }]
|
|
716
|
-
}], propDecorators: {
|
|
782
|
+
}, template: "<gov-dialog\n [open]=\"visible\"\n [attr.block-close]=\"data.closable !== undefined ? !data.closable : false\"\n [attr.block-backdrop-close]=\"data.closable !== undefined ? !data.closable : false\" \n [style.--dialog-max-width]=\"data.width\"\n [style.--dialog-max-height]=\"data.height\"\n role=\"dialog\"\n accessible-close-label=\"Close dialog box with more information\"\n (gov-close)=\"data.cancelButtonFn ? dialogClick(false) : (visible = false)\"\n>\n <gov-icon\n type=\"components\"\n [name]=\"data.headerIcon\"\n slot=\"icon\"\n [color]=\"data.severity | govColor\"\n />\n \n <h2 slot=\"title\">{{ data.title ?? 'Title' }}</h2>\n\n @if (data && data.innerHTML) {\n <div [innerHTML]=\"data.innerHTML\"></div>\n } @else if (data.componentType) {\n <v-dynamic-component\n [componentType]=\"data.componentType\"\n [data]=\"$any(data.data)\"\n ></v-dynamic-component>\n }\n\n <gov-button\n #confirmButton\n color=\"primary\"\n size=\"m\"\n type=\"solid\"\n slot=\"footer\"\n [disabled]=\"confirmButtonDisabled\"\n (gov-click)=\"data.confirmButtonFn ? dialogClick(true) : (visible = false)\"\n >\n {{ data.confirmButtonText ?? 'Yes'}}\n </gov-button>\n \n <gov-button\n #cancelButton\n [ngClass]=\"!data.showCancelButton ? 'd-none' : ''\"\n color=\"primary\"\n size=\"m\"\n type=\"outlined\"\n slot=\"footer\"\n [disabled]=\"!data.showCancelButton\"\n (gov-click)=\"data.cancelButtonFn ? dialogClick(false) : (visible = false)\"\n >\n {{ data.cancelButtonText ?? 'No' }}\n </gov-button>\n</gov-dialog>", styles: [":host ::ng-deep dialog{max-width:var(--dialog-max-width, 95%);max-height:var(--dialog-max-height, 95%)}\n"] }]
|
|
783
|
+
}], propDecorators: { confirmButton: [{
|
|
784
|
+
type: ViewChild,
|
|
785
|
+
args: ['confirmButton', { read: ElementRef }]
|
|
786
|
+
}], cancelButton: [{
|
|
787
|
+
type: ViewChild,
|
|
788
|
+
args: ['cancelButton', { read: ElementRef }]
|
|
789
|
+
}], onKeyDown: [{
|
|
717
790
|
type: HostListener,
|
|
718
791
|
args: ['document:keydown', ['$event']]
|
|
719
792
|
}] } });
|