@verisoft/ui-govcz 21.0.9 → 21.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.
@@ -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, ViewEncapsulation, HostListener, NO_ERRORS_SCHEMA, output, ContentChild, ContentChildren, NgModule, Inject, effect, Directive, forwardRef, InjectionToken } from '@angular/core';
2
+ import { Component, Pipe, ChangeDetectionStrategy, CUSTOM_ELEMENTS_SCHEMA, EventEmitter, Output, Input, inject, Optional, Self, input, reflectComponentType, Injectable, ChangeDetectorRef, Injector, ViewContainerRef, ViewChild, ViewEncapsulation, HostListener, NO_ERRORS_SCHEMA, output, ContentChild, ContentChildren, NgModule, Inject, effect, Directive, forwardRef, InjectionToken } from '@angular/core';
3
3
  import * as i1 from '@angular/router';
4
4
  import { RouterModule, Router, RouterOutlet, RouterLink, RouterLinkActive, ActivatedRoute } from '@angular/router';
5
5
  import * as i2 from '@gov-design-system-ce/angular';
@@ -57,6 +57,12 @@ const Icons = {
57
57
  check: 'check-lg',
58
58
  envelope: 'envelope',
59
59
  loader: 'loader',
60
+ file: 'file',
61
+ map: 'map',
62
+ arrowCounterclockwise: 'arrow-counterclockwise',
63
+ folder: 'folder',
64
+ eye: 'eye',
65
+ box: 'box',
60
66
  };
61
67
 
62
68
  class BreadcrumbComponent extends BreadcrumbCoreComponent {
@@ -502,86 +508,76 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImpor
502
508
  type: Input
503
509
  }] } });
504
510
 
505
- /* eslint-disable @typescript-eslint/no-explicit-any */
506
511
  class DynamicComponentFactoryService {
507
- componentFactoryResolver;
508
- constructor(componentFactoryResolver) {
509
- this.componentFactoryResolver = componentFactoryResolver;
510
- }
511
- ngOnDestroy() {
512
- this.unsubscribeComponentEvents(this);
513
- }
514
- async createDynamicComponent(componentType, viewContainerRef, inputs, injector = undefined) {
515
- const componentFactory = this.componentFactoryResolver.resolveComponentFactory(componentType);
512
+ outputSubscriptions = new WeakMap();
513
+ createDynamicComponent(componentType, viewContainerRef, inputs, injector = undefined) {
516
514
  viewContainerRef.clear();
517
- const component = viewContainerRef.createComponent(componentFactory, undefined, injector);
518
- this.setComponentDataInt(componentFactory, component, inputs);
519
- this.fireComponentEvents(component.instance, inputs);
515
+ const component = viewContainerRef.createComponent(componentType, {
516
+ injector,
517
+ });
518
+ this.setComponentDataInt(componentType, component, inputs);
519
+ this.fireComponentEvents(componentType, component.instance, inputs);
520
520
  return component;
521
521
  }
522
+ cleanupComponent(instance) {
523
+ this.unsubscribeComponentEvents(instance);
524
+ }
522
525
  setComponentData(component, inputs) {
523
- const factory = this.componentFactoryResolver.resolveComponentFactory(component.componentType);
524
- this.setComponentDataInt(factory, component, inputs);
526
+ this.setComponentDataInt(component.componentType, component, inputs);
525
527
  }
526
528
  unsubscribeComponentEvents(instance) {
527
- const subscriptionStoreKey = '__outputSubscriptions__';
528
- const subscriptions = instance[subscriptionStoreKey];
529
+ const subscriptions = this.outputSubscriptions.get(instance);
529
530
  if (subscriptions) {
530
531
  subscriptions.forEach((sub) => sub.unsubscribe());
531
532
  subscriptions.clear();
533
+ this.outputSubscriptions.delete(instance);
532
534
  }
533
535
  }
534
- fireComponentEvents(instance, inputs) {
536
+ fireComponentEvents(componentType, instance, inputs) {
535
537
  if (!instance || typeof instance !== 'object')
536
538
  return;
537
- this.fireInputComponentEvents(instance, inputs);
538
- this.fireOutputComponentEvents(instance, inputs);
539
+ this.fireOutputComponentEvents(componentType, instance, inputs);
539
540
  }
540
- setComponentDataInt(factory, component, inputs) {
541
+ setComponentDataInt(componentType, component, inputs) {
541
542
  if (inputs) {
542
- const propertyNames = factory.inputs.map((x) => x.propName);
543
+ const propertyNames = this.getInputNames(componentType);
543
544
  const inputsHash = new Set(propertyNames);
544
545
  Object.keys(inputs)
545
546
  .filter((x) => inputsHash.has(x))
546
547
  .forEach((x) => {
547
- component.instance[x] = inputs[x];
548
+ component.setInput(x, inputs[x]);
548
549
  });
549
550
  }
550
551
  }
551
- fireInputComponentEvents(instance, inputs) {
552
- const onChangeComponent = instance;
553
- if (onChangeComponent.ngOnChanges && inputs) {
554
- const changeEventArgs = Object.keys(inputs).reduce((changes, key) => {
555
- const inputValue = inputs[key];
556
- changes[key] = new SimpleChange(undefined, inputValue, true);
557
- return changes;
558
- }, {});
559
- onChangeComponent.ngOnChanges(changeEventArgs);
560
- }
561
- }
562
- fireOutputComponentEvents(instance, inputs) {
563
- const outputs = Object.keys(inputs).filter((key) => {
564
- const emitter = instance[key];
565
- return emitter instanceof EventEmitter;
566
- });
567
- const subscriptionStoreKey = '__outputSubscriptions__';
568
- if (!(subscriptionStoreKey in instance)) {
569
- instance[subscriptionStoreKey] = new Map();
552
+ fireOutputComponentEvents(componentType, instance, inputs) {
553
+ const outputNames = new Set(this.getOutputNames(componentType));
554
+ const outputs = Object.keys(inputs ?? {}).filter((key) => outputNames.has(key));
555
+ let subscriptions = this.outputSubscriptions.get(instance);
556
+ if (!subscriptions) {
557
+ subscriptions = new Map();
558
+ this.outputSubscriptions.set(instance, subscriptions);
570
559
  }
571
- const subscriptions = instance[subscriptionStoreKey];
572
560
  for (const outputKey of outputs) {
573
- const eventEmitter = instance[outputKey];
561
+ const outputRef = instance[outputKey];
574
562
  const callback = inputs[outputKey];
575
- if (eventEmitter && typeof callback === 'function') {
563
+ if (outputRef &&
564
+ typeof outputRef.subscribe === 'function' &&
565
+ typeof callback === 'function') {
576
566
  if (subscriptions.has(outputKey)) {
577
567
  subscriptions.get(outputKey).unsubscribe();
578
568
  }
579
- const subscription = eventEmitter.subscribe((value) => callback(value));
569
+ const subscription = outputRef.subscribe((value) => callback(value));
580
570
  subscriptions.set(outputKey, subscription);
581
571
  }
582
572
  }
583
573
  }
584
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: DynamicComponentFactoryService, deps: [{ token: i0.ComponentFactoryResolver }], target: i0.ɵɵFactoryTarget.Injectable });
574
+ getInputNames(componentType) {
575
+ return (reflectComponentType(componentType)?.inputs.map((input) => input.propName) ?? []);
576
+ }
577
+ getOutputNames(componentType) {
578
+ return (reflectComponentType(componentType)?.outputs.map((output) => output.propName) ?? []);
579
+ }
580
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: DynamicComponentFactoryService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
585
581
  static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: DynamicComponentFactoryService, providedIn: 'root' });
586
582
  }
587
583
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: DynamicComponentFactoryService, decorators: [{
@@ -589,7 +585,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImpor
589
585
  args: [{
590
586
  providedIn: 'root',
591
587
  }]
592
- }], ctorParameters: () => [{ type: i0.ComponentFactoryResolver }] });
588
+ }] });
593
589
 
594
590
  class DynamicComponent {
595
591
  componentType;
@@ -598,6 +594,7 @@ class DynamicComponent {
598
594
  factoryServices = inject(DynamicComponentFactoryService);
599
595
  changeDetectorRef = inject(ChangeDetectorRef);
600
596
  injector = inject(Injector);
597
+ componentRef;
601
598
  ngOnChanges() {
602
599
  this.createComponent();
603
600
  }
@@ -605,9 +602,20 @@ class DynamicComponent {
605
602
  this.createComponent();
606
603
  this.changeDetectorRef.detectChanges();
607
604
  }
605
+ ngOnDestroy() {
606
+ this.destroyCurrentComponent();
607
+ }
608
608
  createComponent() {
609
609
  if (this.container) {
610
- this.factoryServices.createDynamicComponent(this.componentType, this.container, this.data, this.injector);
610
+ this.destroyCurrentComponent();
611
+ this.componentRef = this.factoryServices.createDynamicComponent(this.componentType, this.container, this.data, this.injector);
612
+ }
613
+ }
614
+ destroyCurrentComponent() {
615
+ if (this.componentRef) {
616
+ this.factoryServices.cleanupComponent(this.componentRef.instance);
617
+ this.componentRef.destroy();
618
+ this.componentRef = undefined;
611
619
  }
612
620
  }
613
621
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: DynamicComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
@@ -674,7 +682,7 @@ class ConfirmDialogComponent extends UnsubscribeComponent {
674
682
  provide: CONFIRM_DIALOG_COMPONENT_TOKEN,
675
683
  useExisting: ConfirmDialogComponent,
676
684
  },
677
- ], 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 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 [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>\n", 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" }] });
685
+ ], 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]=\"\n data.closable !== undefined ? !data.closable : false\n \"\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 color=\"primary\"\n size=\"m\"\n type=\"solid\"\n slot=\"footer\"\n [disabled]=\"data.confirmButtonDisabled\"\n (gov-click)=\"data.confirmButtonFn ? dialogClick(true) : (visible = false)\"\n >\n {{ data.confirmButtonText ?? 'Yes' }}\n </gov-button>\n\n <gov-button\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>\n", 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" }] });
678
686
  }
679
687
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: ConfirmDialogComponent, decorators: [{
680
688
  type: Component,
@@ -688,7 +696,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImpor
688
696
  provide: CONFIRM_DIALOG_COMPONENT_TOKEN,
689
697
  useExisting: ConfirmDialogComponent,
690
698
  },
691
- ], 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 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 [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>\n", styles: [":host ::ng-deep dialog{max-width:var(--dialog-max-width, 95%);max-height:var(--dialog-max-height, 95%)}\n"] }]
699
+ ], template: "<gov-dialog\n [open]=\"visible\"\n [attr.block-close]=\"data.closable !== undefined ? !data.closable : false\"\n [attr.block-backdrop-close]=\"\n data.closable !== undefined ? !data.closable : false\n \"\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 color=\"primary\"\n size=\"m\"\n type=\"solid\"\n slot=\"footer\"\n [disabled]=\"data.confirmButtonDisabled\"\n (gov-click)=\"data.confirmButtonFn ? dialogClick(true) : (visible = false)\"\n >\n {{ data.confirmButtonText ?? 'Yes' }}\n </gov-button>\n\n <gov-button\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>\n", styles: [":host ::ng-deep dialog{max-width:var(--dialog-max-width, 95%);max-height:var(--dialog-max-height, 95%)}\n"] }]
692
700
  }], ctorParameters: () => [{ type: i1$3.DialogService }, { type: i0.ChangeDetectorRef }] });
693
701
 
694
702
  class TooltipComponent {