@jm-7c3/common-lib 22.0.0 → 22.1.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.
@@ -1,5 +1,5 @@
1
1
  import * as i0 from '@angular/core';
2
- import { input, signal, effect, ChangeDetectionStrategy, Component, Injectable, inject, Inject, ChangeDetectorRef, viewChild, ViewContainerRef, output, InjectionToken, Directive, contentChild, computed, ViewEncapsulation, NgModule } from '@angular/core';
2
+ import { input, signal, effect, ChangeDetectionStrategy, Component, Injectable, inject, Inject, ChangeDetectorRef, viewChild, ViewContainerRef, Service, Directive, output, InjectionToken, contentChild, computed, ViewEncapsulation, NgModule } from '@angular/core';
3
3
  import * as i1 from 'primeng/button';
4
4
  import { ButtonModule } from 'primeng/button';
5
5
  import * as i2 from 'primeng/api';
@@ -8,20 +8,26 @@ import * as i1$1 from 'primeng/confirmdialog';
8
8
  import { ConfirmDialogModule } from 'primeng/confirmdialog';
9
9
  import { toObservable } from '@angular/core/rxjs-interop';
10
10
  import { signalState, patchState } from '@ngrx/signals';
11
- import { filter, map, Subscription, concatWith, toArray } from 'rxjs';
11
+ import { filter, map, Subject, takeUntil, Subscription, concatWith, toArray } from 'rxjs';
12
12
  import * as i1$2 from '@angular/common';
13
13
  import { CommonModule } from '@angular/common';
14
14
  import { DynamicDialogConfig, DynamicDialogRef, DialogService, DynamicDialogModule } from 'primeng/dynamicdialog';
15
15
  import * as i2$2 from '@angular/forms';
16
16
  import { FormsModule, ReactiveFormsModule, NG_VALUE_ACCESSOR, FormControl, Validators, FormArray, NG_VALIDATORS, FormControlName } from '@angular/forms';
17
- import * as i1$3 from 'primeng/dialog';
17
+ import * as i1$3 from '@angular/material/dialog';
18
+ import { MAT_DIALOG_DATA, MatDialogModule, MatDialog, MatDialogRef } from '@angular/material/dialog';
19
+ import * as i1$4 from '@angular/material/button';
20
+ import { MatButtonModule } from '@angular/material/button';
21
+ import * as i1$5 from 'primeng/dialog';
18
22
  import { DialogModule } from 'primeng/dialog';
19
23
  import * as i2$1 from 'primeng/progressbar';
20
24
  import { ProgressBarModule } from 'primeng/progressbar';
21
- import * as i1$4 from 'primeng/toast';
25
+ import * as i1$6 from 'primeng/toast';
22
26
  import { ToastModule } from 'primeng/toast';
23
27
  import { cloneDeep } from 'lodash-es';
24
28
  import { v4 } from 'uuid';
29
+ import * as i2$3 from '@angular/material/icon';
30
+ import { MatIconModule } from '@angular/material/icon';
25
31
 
26
32
  class ButtonComponent {
27
33
  color = input('primary', /* @ts-ignore */
@@ -431,6 +437,137 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.5", ngImpor
431
437
  ], changeDetection: ChangeDetectionStrategy.OnPush, template: "<button [class]=\"class()\" [disabled]=\"disabled()\" [icon]=\"icon()\" [loading]=\"loading()\" pButton [type]=\"type()\">\n</button>\n", styles: ["button{border-radius:25px}\n"] }]
432
438
  }], ctorParameters: () => [], propDecorators: { disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], icon: [{ type: i0.Input, args: [{ isSignal: true, alias: "icon", required: true }] }], loading: [{ type: i0.Input, args: [{ isSignal: true, alias: "loading", required: false }] }], severity: [{ type: i0.Input, args: [{ isSignal: true, alias: "severity", required: false }] }], type: [{ type: i0.Input, args: [{ isSignal: true, alias: "type", required: false }] }] } });
433
439
 
440
+ class MatConfirmationComponent {
441
+ data = inject(MAT_DIALOG_DATA);
442
+ contentHost = viewChild.required('contentHost', { read: ViewContainerRef });
443
+ title = signal('', /* @ts-ignore */
444
+ ...(ngDevMode ? [{ debugName: "title" }] : /* istanbul ignore next */ []));
445
+ message = signal(undefined, /* @ts-ignore */
446
+ ...(ngDevMode ? [{ debugName: "message" }] : /* istanbul ignore next */ []));
447
+ acceptButtonLabel = signal('Accept', /* @ts-ignore */
448
+ ...(ngDevMode ? [{ debugName: "acceptButtonLabel" }] : /* istanbul ignore next */ []));
449
+ cancelButtonLabel = signal('Cancel', /* @ts-ignore */
450
+ ...(ngDevMode ? [{ debugName: "cancelButtonLabel" }] : /* istanbul ignore next */ []));
451
+ ngAfterViewInit() {
452
+ const { acceptButtonLabel, cancelButtonLabel, component, message, title } = this.data;
453
+ this.acceptButtonLabel.set(acceptButtonLabel || 'Accept');
454
+ this.cancelButtonLabel.set(cancelButtonLabel || 'Cancel');
455
+ this.title.set(title ?? '');
456
+ if (component) {
457
+ this.contentHost().clear();
458
+ const componentRef = this.contentHost().createComponent(component);
459
+ Object.assign(componentRef.instance ?? {}, this.data.componentData);
460
+ }
461
+ else if (message) {
462
+ this.message.set(message);
463
+ }
464
+ }
465
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: MatConfirmationComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
466
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.5", type: MatConfirmationComponent, isStandalone: true, selector: "cl-mat-confirmation", viewQueries: [{ propertyName: "contentHost", first: true, predicate: ["contentHost"], descendants: true, read: ViewContainerRef, isSignal: true }], ngImport: i0, template: "<h2 mat-dialog-title>{{ title() }}</h2>\n\n<mat-dialog-content>\n @if (message()) {\n <p>{{ message() }}</p>\n }\n <ng-template #contentHost />\n</mat-dialog-content>\n\n<mat-dialog-actions align=\"end\">\n <button mat-button [mat-dialog-close]=\"false\">\n {{ cancelButtonLabel() }}\n </button>\n <button mat-flat-button color=\"primary\" [mat-dialog-close]=\"true\">\n {{ acceptButtonLabel() }}\n </button>\n</mat-dialog-actions>", dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "ngmodule", type: MatDialogModule }, { kind: "directive", type: i1$3.MatDialogClose, selector: "[mat-dialog-close], [matDialogClose]", inputs: ["aria-label", "type", "mat-dialog-close", "matDialogClose"], exportAs: ["matDialogClose"] }, { kind: "directive", type: i1$3.MatDialogTitle, selector: "[mat-dialog-title], [matDialogTitle]", inputs: ["id"], exportAs: ["matDialogTitle"] }, { kind: "directive", type: i1$3.MatDialogActions, selector: "[mat-dialog-actions], mat-dialog-actions, [matDialogActions]", inputs: ["align"] }, { kind: "directive", type: i1$3.MatDialogContent, selector: "[mat-dialog-content], mat-dialog-content, [matDialogContent]" }, { kind: "ngmodule", type: MatButtonModule }, { kind: "component", type: i1$4.MatButton, selector: " button[matButton], a[matButton], button[mat-button], button[mat-raised-button], button[mat-flat-button], button[mat-stroked-button], a[mat-button], a[mat-raised-button], a[mat-flat-button], a[mat-stroked-button] ", inputs: ["matButton"], exportAs: ["matButton", "matAnchor"] }] });
467
+ }
468
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: MatConfirmationComponent, decorators: [{
469
+ type: Component,
470
+ args: [{ selector: 'cl-mat-confirmation', standalone: true, imports: [CommonModule, MatDialogModule, MatButtonModule], template: "<h2 mat-dialog-title>{{ title() }}</h2>\n\n<mat-dialog-content>\n @if (message()) {\n <p>{{ message() }}</p>\n }\n <ng-template #contentHost />\n</mat-dialog-content>\n\n<mat-dialog-actions align=\"end\">\n <button mat-button [mat-dialog-close]=\"false\">\n {{ cancelButtonLabel() }}\n </button>\n <button mat-flat-button color=\"primary\" [mat-dialog-close]=\"true\">\n {{ acceptButtonLabel() }}\n </button>\n</mat-dialog-actions>" }]
471
+ }], propDecorators: { contentHost: [{ type: i0.ViewChild, args: ['contentHost', { ...{ read: ViewContainerRef }, isSignal: true }] }] } });
472
+
473
+ class MatConfirmationService {
474
+ dialog = inject(MatDialog);
475
+ confirm(data, width = '400px') {
476
+ const dialogRef = this.dialog.open(MatConfirmationComponent, {
477
+ data,
478
+ width,
479
+ disableClose: true,
480
+ });
481
+ return dialogRef.afterClosed().pipe(map((result) => result ?? false));
482
+ }
483
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: MatConfirmationService, deps: [], target: i0.ɵɵFactoryTarget.Service });
484
+ static ɵprov = i0.ɵɵngDeclareService({ minVersion: "22.0.0", version: "22.0.5", ngImport: i0, type: MatConfirmationService });
485
+ }
486
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: MatConfirmationService, decorators: [{
487
+ type: Service
488
+ }] });
489
+
490
+ // eslint-disable-next-line @angular-eslint/directive-class-suffix
491
+ class MatFormHostableComponent {
492
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: MatFormHostableComponent, deps: [], target: i0.ɵɵFactoryTarget.Directive });
493
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.0.5", type: MatFormHostableComponent, isStandalone: true, ngImport: i0 });
494
+ }
495
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: MatFormHostableComponent, decorators: [{
496
+ type: Directive
497
+ }] });
498
+ class MatFormDialogComponent {
499
+ data = inject(MAT_DIALOG_DATA);
500
+ dialogRef = inject((MatDialogRef));
501
+ formHost = viewChild.required('formHost', { read: ViewContainerRef });
502
+ actionsAlign = signal('end', /* @ts-ignore */
503
+ ...(ngDevMode ? [{ debugName: "actionsAlign" }] : /* istanbul ignore next */ []));
504
+ cancelButtonLabel = signal('Cancel', /* @ts-ignore */
505
+ ...(ngDevMode ? [{ debugName: "cancelButtonLabel" }] : /* istanbul ignore next */ []));
506
+ submitButtonLabel = signal('Submit', /* @ts-ignore */
507
+ ...(ngDevMode ? [{ debugName: "submitButtonLabel" }] : /* istanbul ignore next */ []));
508
+ isFormValid = signal(false, /* @ts-ignore */
509
+ ...(ngDevMode ? [{ debugName: "isFormValid" }] : /* istanbul ignore next */ []));
510
+ hostedComponentRef;
511
+ destroy$ = new Subject();
512
+ title = signal('', /* @ts-ignore */
513
+ ...(ngDevMode ? [{ debugName: "title" }] : /* istanbul ignore next */ []));
514
+ ngAfterViewInit() {
515
+ const { component, dialogTitle, formDialogConfig, formValue } = this.data;
516
+ this.formHost().clear();
517
+ const componentRef = this.formHost().createComponent(component);
518
+ this.hostedComponentRef = componentRef.instance;
519
+ this.title.set(dialogTitle);
520
+ if (formDialogConfig) {
521
+ this.actionsAlign.set(formDialogConfig.actionsAlign || 'end');
522
+ this.cancelButtonLabel.set(formDialogConfig.cancelButtonLabel || 'Cancel');
523
+ this.submitButtonLabel.set(formDialogConfig.submitButtonLabel || 'Submit');
524
+ }
525
+ if (formValue) {
526
+ this.hostedComponentRef.form.patchValue(formValue);
527
+ }
528
+ this.hostedComponentRef?.form.statusChanges.pipe(takeUntil(this.destroy$)).subscribe(status => {
529
+ this.isFormValid.set(status === 'VALID');
530
+ });
531
+ }
532
+ ngOnDestroy() {
533
+ this.destroy$.next();
534
+ this.destroy$.complete();
535
+ }
536
+ onSubmit() {
537
+ this.dialogRef.close(this.hostedComponentRef?.form.value);
538
+ }
539
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: MatFormDialogComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
540
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "22.0.5", type: MatFormDialogComponent, isStandalone: true, selector: "cl-mat-form-dialog", viewQueries: [{ propertyName: "formHost", first: true, predicate: ["formHost"], descendants: true, read: ViewContainerRef, isSignal: true }], ngImport: i0, template: "<h2 mat-dialog-title>\n {{ title() }}\n</h2>\n\n<mat-dialog-content>\n <ng-template #formHost />\n</mat-dialog-content>\n\n<mat-dialog-actions align=\"end\">\n <button mat-button [mat-dialog-close]=\"undefined\" type=\"button\">\n {{ cancelButtonLabel() }}\n </button>\n <button mat-flat-button color=\"primary\" [disabled]=\"!isFormValid()\" (click)=\"onSubmit()\" type=\"button\">\n {{ submitButtonLabel() }}\n </button>\n</mat-dialog-actions>\n", styles: [":host{display:block}\n"], dependencies: [{ kind: "ngmodule", type: MatButtonModule }, { kind: "component", type: i1$4.MatButton, selector: " button[matButton], a[matButton], button[mat-button], button[mat-raised-button], button[mat-flat-button], button[mat-stroked-button], a[mat-button], a[mat-raised-button], a[mat-flat-button], a[mat-stroked-button] ", inputs: ["matButton"], exportAs: ["matButton", "matAnchor"] }, { kind: "ngmodule", type: MatDialogModule }, { kind: "directive", type: i1$3.MatDialogClose, selector: "[mat-dialog-close], [matDialogClose]", inputs: ["aria-label", "type", "mat-dialog-close", "matDialogClose"], exportAs: ["matDialogClose"] }, { kind: "directive", type: i1$3.MatDialogTitle, selector: "[mat-dialog-title], [matDialogTitle]", inputs: ["id"], exportAs: ["matDialogTitle"] }, { kind: "directive", type: i1$3.MatDialogActions, selector: "[mat-dialog-actions], mat-dialog-actions, [matDialogActions]", inputs: ["align"] }, { kind: "directive", type: i1$3.MatDialogContent, selector: "[mat-dialog-content], mat-dialog-content, [matDialogContent]" }] });
541
+ }
542
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: MatFormDialogComponent, decorators: [{
543
+ type: Component,
544
+ args: [{ selector: 'cl-mat-form-dialog', imports: [
545
+ MatButtonModule,
546
+ MatDialogModule,
547
+ ], template: "<h2 mat-dialog-title>\n {{ title() }}\n</h2>\n\n<mat-dialog-content>\n <ng-template #formHost />\n</mat-dialog-content>\n\n<mat-dialog-actions align=\"end\">\n <button mat-button [mat-dialog-close]=\"undefined\" type=\"button\">\n {{ cancelButtonLabel() }}\n </button>\n <button mat-flat-button color=\"primary\" [disabled]=\"!isFormValid()\" (click)=\"onSubmit()\" type=\"button\">\n {{ submitButtonLabel() }}\n </button>\n</mat-dialog-actions>\n", styles: [":host{display:block}\n"] }]
548
+ }], propDecorators: { formHost: [{ type: i0.ViewChild, args: ['formHost', { ...{ read: ViewContainerRef }, isSignal: true }] }] } });
549
+
550
+ class MatFormDialogService {
551
+ dialog = inject(MatDialog);
552
+ open(component, dialogTitle, data) {
553
+ const dialogRef = this.dialog.open(MatFormDialogComponent, {
554
+ ...data?.matDialogConfig,
555
+ data: {
556
+ component,
557
+ dialogTitle,
558
+ formValue: data?.formValue,
559
+ formDialogConfig: data?.formDialogConfig
560
+ }
561
+ });
562
+ return dialogRef.afterClosed();
563
+ }
564
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: MatFormDialogService, deps: [], target: i0.ɵɵFactoryTarget.Service });
565
+ static ɵprov = i0.ɵɵngDeclareService({ minVersion: "22.0.0", version: "22.0.5", ngImport: i0, type: MatFormDialogService });
566
+ }
567
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: MatFormDialogService, decorators: [{
568
+ type: Service
569
+ }] });
570
+
434
571
  class ProgressBarDialogComponent {
435
572
  cdRef = inject(ChangeDetectorRef);
436
573
  clStateService = inject(ClStateService);
@@ -450,7 +587,7 @@ class ProgressBarDialogComponent {
450
587
  });
451
588
  }
452
589
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: ProgressBarDialogComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
453
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "22.0.5", type: ProgressBarDialogComponent, isStandalone: true, selector: "cl-progress-bar-dialog", ngImport: i0, template: "<p-dialog [closable]=\"false\" [closeOnEscape]=\"false\" [draggable]=\"false\" [modal]=\"true\" [resizable]=\"false\"\n [showHeader]=\"true\" styleClass=\"w-4\" [(visible)]=\"visible\">\n <p-progressBar mode=\"indeterminate\" />\n</p-dialog>\n", styles: [":host ::ng-deep p-dialog .p-dialog-header{padding:1rem}\n"], dependencies: [{ kind: "ngmodule", type: DialogModule }, { kind: "component", type: i1$3.Dialog, selector: "p-dialog", inputs: ["hostName", "header", "draggable", "resizable", "contentStyle", "contentStyleClass", "modal", "closeOnEscape", "dismissableMask", "rtl", "closable", "breakpoints", "styleClass", "maskStyleClass", "maskStyle", "showHeader", "blockScroll", "autoZIndex", "baseZIndex", "minX", "minY", "focusOnShow", "maximizable", "keepInViewport", "focusTrap", "transitionOptions", "maskMotionOptions", "motionOptions", "closeIcon", "closeAriaLabel", "closeTabindex", "minimizeIcon", "maximizeIcon", "closeButtonProps", "maximizeButtonProps", "visible", "style", "position", "role", "appendTo", "content", "contentTemplate", "footerTemplate", "closeIconTemplate", "maximizeIconTemplate", "minimizeIconTemplate", "headlessTemplate"], outputs: ["onShow", "onHide", "visibleChange", "onResizeInit", "onResizeEnd", "onDragEnd", "onMaximize"] }, { kind: "ngmodule", type: ProgressBarModule }, { kind: "component", type: i2$1.ProgressBar, selector: "p-progressBar, p-progressbar, p-progress-bar", inputs: ["value", "showValue", "styleClass", "valueStyleClass", "unit", "mode", "color"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
590
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "22.0.5", type: ProgressBarDialogComponent, isStandalone: true, selector: "cl-progress-bar-dialog", ngImport: i0, template: "<p-dialog [closable]=\"false\" [closeOnEscape]=\"false\" [draggable]=\"false\" [modal]=\"true\" [resizable]=\"false\"\n [showHeader]=\"true\" styleClass=\"w-4\" [(visible)]=\"visible\">\n <p-progressBar mode=\"indeterminate\" />\n</p-dialog>\n", styles: [":host ::ng-deep p-dialog .p-dialog-header{padding:1rem}\n"], dependencies: [{ kind: "ngmodule", type: DialogModule }, { kind: "component", type: i1$5.Dialog, selector: "p-dialog", inputs: ["hostName", "header", "draggable", "resizable", "contentStyle", "contentStyleClass", "modal", "closeOnEscape", "dismissableMask", "rtl", "closable", "breakpoints", "styleClass", "maskStyleClass", "maskStyle", "showHeader", "blockScroll", "autoZIndex", "baseZIndex", "minX", "minY", "focusOnShow", "maximizable", "keepInViewport", "focusTrap", "transitionOptions", "maskMotionOptions", "motionOptions", "closeIcon", "closeAriaLabel", "closeTabindex", "minimizeIcon", "maximizeIcon", "closeButtonProps", "maximizeButtonProps", "visible", "style", "position", "role", "appendTo", "content", "contentTemplate", "footerTemplate", "closeIconTemplate", "maximizeIconTemplate", "minimizeIconTemplate", "headlessTemplate"], outputs: ["onShow", "onHide", "visibleChange", "onResizeInit", "onResizeEnd", "onDragEnd", "onMaximize"] }, { kind: "ngmodule", type: ProgressBarModule }, { kind: "component", type: i2$1.ProgressBar, selector: "p-progressBar, p-progressbar, p-progress-bar", inputs: ["value", "showValue", "styleClass", "valueStyleClass", "unit", "mode", "color"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
454
591
  }
455
592
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: ProgressBarDialogComponent, decorators: [{
456
593
  type: Component,
@@ -517,7 +654,7 @@ class ToastsComponent {
517
654
  });
518
655
  }
519
656
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: ToastsComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
520
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "22.0.5", type: ToastsComponent, isStandalone: true, selector: "cl-toasts", ngImport: i0, template: "<p-toast key=\"general\" position=\"bottom-center\" />\n", styles: [""], dependencies: [{ kind: "ngmodule", type: ToastModule }, { kind: "component", type: i1$4.Toast, selector: "p-toast", inputs: ["key", "autoZIndex", "baseZIndex", "life", "styleClass", "position", "preventOpenDuplicates", "preventDuplicates", "showTransformOptions", "hideTransformOptions", "showTransitionOptions", "hideTransitionOptions", "motionOptions", "breakpoints"], outputs: ["onClose"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
657
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "22.0.5", type: ToastsComponent, isStandalone: true, selector: "cl-toasts", ngImport: i0, template: "<p-toast key=\"general\" position=\"bottom-center\" />\n", styles: [""], dependencies: [{ kind: "ngmodule", type: ToastModule }, { kind: "component", type: i1$6.Toast, selector: "p-toast", inputs: ["key", "autoZIndex", "baseZIndex", "life", "styleClass", "position", "preventOpenDuplicates", "preventDuplicates", "showTransformOptions", "hideTransformOptions", "showTransitionOptions", "hideTransitionOptions", "motionOptions", "breakpoints"], outputs: ["onClose"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
521
658
  }
522
659
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: ToastsComponent, decorators: [{
523
660
  type: Component,
@@ -969,6 +1106,260 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.5", ngImpor
969
1106
  }]
970
1107
  }] });
971
1108
 
1109
+ class MatFileInputComponent {
1110
+ directory = input('', /* @ts-ignore */
1111
+ ...(ngDevMode ? [{ debugName: "directory" }] : /* istanbul ignore next */ []));
1112
+ icon = input('add', /* @ts-ignore */
1113
+ ...(ngDevMode ? [{ debugName: "icon" }] : /* istanbul ignore next */ []));
1114
+ label = input('Browse', /* @ts-ignore */
1115
+ ...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
1116
+ readonly = input(false, /* @ts-ignore */
1117
+ ...(ngDevMode ? [{ debugName: "readonly" }] : /* istanbul ignore next */ []));
1118
+ onDownloadEmitter = output({ alias: 'onDownload' });
1119
+ fileInput = viewChild('fileInput', /* @ts-ignore */
1120
+ ...(ngDevMode ? [{ debugName: "fileInput" }] : /* istanbul ignore next */ []));
1121
+ fileName = signal('', /* @ts-ignore */
1122
+ ...(ngDevMode ? [{ debugName: "fileName" }] : /* istanbul ignore next */ []));
1123
+ isDisabled = signal(false, /* @ts-ignore */
1124
+ ...(ngDevMode ? [{ debugName: "isDisabled" }] : /* istanbul ignore next */ []));
1125
+ isFileSelected = signal(false, /* @ts-ignore */
1126
+ ...(ngDevMode ? [{ debugName: "isFileSelected" }] : /* istanbul ignore next */ []));
1127
+ value = signal(null, /* @ts-ignore */
1128
+ ...(ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []));
1129
+ // ControlValueAccessor interface methods
1130
+ registerOnChange(fn) {
1131
+ this.onChange = fn;
1132
+ }
1133
+ registerOnTouched(fn) {
1134
+ this.onTouched = fn;
1135
+ }
1136
+ setDisabledState(isDisabled) {
1137
+ setTimeout(() => {
1138
+ this.isDisabled.set(isDisabled);
1139
+ });
1140
+ }
1141
+ writeValue(value = null) {
1142
+ let newValue = [];
1143
+ if (Array.isArray(value)) {
1144
+ newValue = cloneDeep(value);
1145
+ this.selectFile(newValue[0]);
1146
+ }
1147
+ else if (typeof value === 'string') {
1148
+ const hash = this.getHashFromFileName(value);
1149
+ const file = {
1150
+ isNew: !value,
1151
+ hash,
1152
+ name: value,
1153
+ path: this.directory(),
1154
+ toDelete: false,
1155
+ };
1156
+ newValue.push(file);
1157
+ this.selectFile(file);
1158
+ }
1159
+ this.setValue(newValue);
1160
+ }
1161
+ // Custom public methods
1162
+ onClick() {
1163
+ this.fileInput()?.nativeElement.click();
1164
+ this.onTouched();
1165
+ }
1166
+ onFileSelected(event) {
1167
+ const file = event.target.files[0];
1168
+ if (file) {
1169
+ const { extension, name } = this.getFileNameParts(file.name);
1170
+ const hash = v4().split('-')[0];
1171
+ const newFile = {
1172
+ file,
1173
+ hash,
1174
+ isNew: true,
1175
+ name: `${name}.${hash}.${extension}`,
1176
+ path: this.directory(),
1177
+ toDelete: false,
1178
+ };
1179
+ const newValue = [...(this.value() ?? [])];
1180
+ newValue.push(newFile);
1181
+ this.selectFile(newFile);
1182
+ this.setValue(newValue);
1183
+ }
1184
+ }
1185
+ onDelete() {
1186
+ const newValue = [...(this.value() ?? [])];
1187
+ const file = this.getLastFile(newValue);
1188
+ if (file) {
1189
+ if (file.isNew) {
1190
+ newValue.pop();
1191
+ }
1192
+ else {
1193
+ file.toDelete = true;
1194
+ }
1195
+ this.fileName.set('');
1196
+ this.isFileSelected.set(false);
1197
+ this.setValue(newValue);
1198
+ }
1199
+ }
1200
+ onDownload() {
1201
+ this.onDownloadEmitter.emit(this.value());
1202
+ }
1203
+ // Custom private methods
1204
+ getFileNameParts(fileName) {
1205
+ const lastDotIndex = fileName.lastIndexOf('.');
1206
+ if (lastDotIndex === -1) {
1207
+ return { name: fileName, extension: '' };
1208
+ }
1209
+ return {
1210
+ name: fileName.substring(0, lastDotIndex),
1211
+ extension: fileName.substring(lastDotIndex + 1),
1212
+ };
1213
+ }
1214
+ getHashFromFileName(fileName) {
1215
+ const parts = fileName.split('.');
1216
+ // Assumes format is name.hash.extension
1217
+ return parts.length > 2 ? parts[parts.length - 2] : '';
1218
+ }
1219
+ getLastFile(value) {
1220
+ return value.length > 0 ? value[value.length - 1] : undefined;
1221
+ }
1222
+ getSafeFileName(file) {
1223
+ const { name, extension } = this.getFileNameParts(file.name);
1224
+ const hash = this.getHashFromFileName(file.name);
1225
+ const fileName = name.replace(`.${hash}`, '');
1226
+ return `${decodeURIComponent(fileName)}.${extension}`;
1227
+ }
1228
+ onChange = (value) => { };
1229
+ onTouched = () => { };
1230
+ selectFile(file) {
1231
+ const safeFileName = this.getSafeFileName(file);
1232
+ this.fileName.set(safeFileName);
1233
+ this.isFileSelected.set(true);
1234
+ }
1235
+ setValue(value) {
1236
+ this.value.set(value);
1237
+ this.onChange(value);
1238
+ this.onTouched();
1239
+ }
1240
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: MatFileInputComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
1241
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.5", type: MatFileInputComponent, isStandalone: true, selector: "cl-mat-file-input", inputs: { directory: { classPropertyName: "directory", publicName: "directory", isSignal: true, isRequired: false, transformFunction: null }, icon: { classPropertyName: "icon", publicName: "icon", isSignal: true, isRequired: false, transformFunction: null }, label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, readonly: { classPropertyName: "readonly", publicName: "readonly", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { onDownloadEmitter: "onDownload" }, providers: [
1242
+ {
1243
+ multi: true,
1244
+ provide: NG_VALUE_ACCESSOR,
1245
+ useExisting: MatFileInputComponent,
1246
+ },
1247
+ ], viewQueries: [{ propertyName: "fileInput", first: true, predicate: ["fileInput"], descendants: true, isSignal: true }], ngImport: i0, template: "<div class=\"file-input-container\">\n <input\n #fileInput\n (change)=\"onFileSelected($event)\"\n [disabled]=\"isDisabled()\"\n class=\"file-input\"\n hidden\n type=\"file\"\n />\n\n @if (isFileSelected()) {\n <div class=\"file-details\">\n <span class=\"file-name\" (click)=\"onDownload()\">{{ fileName() }}</span>\n <button mat-icon-button (click)=\"onDelete()\" [disabled]=\"isDisabled() || readonly()\">\n <mat-icon>delete</mat-icon>\n </button>\n </div>\n } @else {\n <button mat-raised-button (click)=\"onClick()\" [disabled]=\"isDisabled() || readonly()\">\n <mat-icon>{{ icon() }}</mat-icon>\n <span>{{ label() }}</span>\n </button>\n }\n</div>", styles: [":host .file-input-container{display:flex;align-items:center}:host .file-details{display:flex;align-items:center;gap:8px}:host .file-name{cursor:pointer;text-decoration:underline;color:#00f}\n"], dependencies: [{ kind: "ngmodule", type: FormsModule }, { kind: "ngmodule", type: MatButtonModule }, { kind: "component", type: i1$4.MatButton, selector: " button[matButton], a[matButton], button[mat-button], button[mat-raised-button], button[mat-flat-button], button[mat-stroked-button], a[mat-button], a[mat-raised-button], a[mat-flat-button], a[mat-stroked-button] ", inputs: ["matButton"], exportAs: ["matButton", "matAnchor"] }, { kind: "component", type: i1$4.MatIconButton, selector: "button[mat-icon-button], a[mat-icon-button], button[matIconButton], a[matIconButton]", exportAs: ["matButton", "matAnchor"] }, { kind: "ngmodule", type: MatIconModule }, { kind: "component", type: i2$3.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }] });
1248
+ }
1249
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: MatFileInputComponent, decorators: [{
1250
+ type: Component,
1251
+ args: [{ selector: 'cl-mat-file-input', standalone: true, imports: [FormsModule, MatButtonModule, MatIconModule], providers: [
1252
+ {
1253
+ multi: true,
1254
+ provide: NG_VALUE_ACCESSOR,
1255
+ useExisting: MatFileInputComponent,
1256
+ },
1257
+ ], template: "<div class=\"file-input-container\">\n <input\n #fileInput\n (change)=\"onFileSelected($event)\"\n [disabled]=\"isDisabled()\"\n class=\"file-input\"\n hidden\n type=\"file\"\n />\n\n @if (isFileSelected()) {\n <div class=\"file-details\">\n <span class=\"file-name\" (click)=\"onDownload()\">{{ fileName() }}</span>\n <button mat-icon-button (click)=\"onDelete()\" [disabled]=\"isDisabled() || readonly()\">\n <mat-icon>delete</mat-icon>\n </button>\n </div>\n } @else {\n <button mat-raised-button (click)=\"onClick()\" [disabled]=\"isDisabled() || readonly()\">\n <mat-icon>{{ icon() }}</mat-icon>\n <span>{{ label() }}</span>\n </button>\n }\n</div>", styles: [":host .file-input-container{display:flex;align-items:center}:host .file-details{display:flex;align-items:center;gap:8px}:host .file-name{cursor:pointer;text-decoration:underline;color:#00f}\n"] }]
1258
+ }], propDecorators: { directory: [{ type: i0.Input, args: [{ isSignal: true, alias: "directory", required: false }] }], icon: [{ type: i0.Input, args: [{ isSignal: true, alias: "icon", required: false }] }], label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }], readonly: [{ type: i0.Input, args: [{ isSignal: true, alias: "readonly", required: false }] }], onDownloadEmitter: [{ type: i0.Output, args: ["onDownload"] }], fileInput: [{ type: i0.ViewChild, args: ['fileInput', { isSignal: true }] }] } });
1259
+
1260
+ class MatFileInputsComponent extends BaseFormComponent {
1261
+ cdRef = inject(ChangeDetectorRef);
1262
+ directory = input('', /* @ts-ignore */
1263
+ ...(ngDevMode ? [{ debugName: "directory" }] : /* istanbul ignore next */ []));
1264
+ icon = input('add', /* @ts-ignore */
1265
+ ...(ngDevMode ? [{ debugName: "icon" }] : /* istanbul ignore next */ []));
1266
+ label = input('Browse', /* @ts-ignore */
1267
+ ...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
1268
+ max = input(5, /* @ts-ignore */
1269
+ ...(ngDevMode ? [{ debugName: "max" }] : /* istanbul ignore next */ []));
1270
+ readonly = input(false, /* @ts-ignore */
1271
+ ...(ngDevMode ? [{ debugName: "readonly" }] : /* istanbul ignore next */ []));
1272
+ onDownloadEmitter = output({ alias: 'onDownload' });
1273
+ onAdd() {
1274
+ this.formArray.push(new FormControl());
1275
+ this.cdRef.markForCheck();
1276
+ }
1277
+ onDelete(index) {
1278
+ this.formArray.removeAt(index);
1279
+ this.cdRef.markForCheck();
1280
+ }
1281
+ onDownload(file) {
1282
+ this.onDownloadEmitter.emit(file);
1283
+ }
1284
+ setDisabledState(isDisabled) {
1285
+ for (const control of this.formArray.controls) {
1286
+ if (isDisabled) {
1287
+ control.disable();
1288
+ }
1289
+ else {
1290
+ control.enable();
1291
+ }
1292
+ }
1293
+ }
1294
+ validate(control) {
1295
+ if (control?.hasValidator(Validators.required) && Array.isArray(control?.value)) {
1296
+ const first = control.value[0];
1297
+ if (!(typeof first === 'string' ||
1298
+ (Array.isArray(first) && first.some(({ toDelete }) => toDelete === false)))) {
1299
+ return {
1300
+ required: true
1301
+ };
1302
+ }
1303
+ }
1304
+ return null;
1305
+ }
1306
+ writeValue(value) {
1307
+ if (Array.isArray(value)) {
1308
+ setTimeout(() => {
1309
+ if (value.length === 0) {
1310
+ this.onAdd();
1311
+ }
1312
+ else {
1313
+ for (let i = 0, j = value.length; i < j; i++) {
1314
+ this.onAdd();
1315
+ }
1316
+ this.setValue(value);
1317
+ }
1318
+ });
1319
+ }
1320
+ else if (!this.readonly()) {
1321
+ this.onAdd();
1322
+ }
1323
+ }
1324
+ getForm() {
1325
+ return new FormArray([]);
1326
+ }
1327
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: MatFileInputsComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
1328
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.5", type: MatFileInputsComponent, isStandalone: true, selector: "cl-mat-file-inputs", inputs: { directory: { classPropertyName: "directory", publicName: "directory", isSignal: true, isRequired: false, transformFunction: null }, icon: { classPropertyName: "icon", publicName: "icon", isSignal: true, isRequired: false, transformFunction: null }, label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, max: { classPropertyName: "max", publicName: "max", isSignal: true, isRequired: false, transformFunction: null }, readonly: { classPropertyName: "readonly", publicName: "readonly", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { onDownloadEmitter: "onDownload" }, providers: [
1329
+ {
1330
+ multi: true,
1331
+ provide: NG_VALIDATORS,
1332
+ useExisting: MatFileInputsComponent
1333
+ },
1334
+ {
1335
+ multi: true,
1336
+ provide: NG_VALUE_ACCESSOR,
1337
+ useExisting: MatFileInputsComponent
1338
+ }
1339
+ ], usesInheritance: true, ngImport: i0, template: "<ng-container [formGroup]=\"formGroup\">\n @for (item of formArray.value; track index; let index = $index) {\n <div class=\"flex mb-3\">\n <cl-mat-file-input [formControlName]=\"index\" [directory]=\"directory()\" [icon]=\"icon()\" [label]=\"label()\"\n (onDownload)=\"onDownload($event)\" [readonly]=\"readonly()\" />\n @if (!readonly()) {\n @if (index === 0) {\n <button (click)=\"onAdd()\" [disabled]=\"formArray.length >= max()\" mat-icon-button type=\"button\">\n <mat-icon>{{ icon() }}</mat-icon>\n </button>\n } @else if (index > 0) {\n <button (click)=\"onDelete(index)\" mat-icon-button type=\"button\">\n <mat-icon>remove</mat-icon>\n </button>\n }\n }\n </div>\n }\n</ng-container>\n", styles: [""], dependencies: [{ kind: "ngmodule", type: MatButtonModule }, { kind: "component", type: i1$4.MatIconButton, selector: "button[mat-icon-button], a[mat-icon-button], button[matIconButton], a[matIconButton]", exportAs: ["matButton", "matAnchor"] }, { kind: "component", type: MatFileInputComponent, selector: "cl-mat-file-input", inputs: ["directory", "icon", "label", "readonly"], outputs: ["onDownload"] }, { kind: "ngmodule", type: MatIconModule }, { kind: "component", type: i2$3.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i2$2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2$2.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],[formArray],form:not([ngNoForm]),[ngForm]" }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i2$2.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i2$2.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }] });
1340
+ }
1341
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: MatFileInputsComponent, decorators: [{
1342
+ type: Component,
1343
+ args: [{ selector: 'cl-mat-file-inputs', imports: [
1344
+ MatButtonModule,
1345
+ MatFileInputComponent,
1346
+ MatIconModule,
1347
+ FormsModule,
1348
+ ReactiveFormsModule,
1349
+ ], providers: [
1350
+ {
1351
+ multi: true,
1352
+ provide: NG_VALIDATORS,
1353
+ useExisting: MatFileInputsComponent
1354
+ },
1355
+ {
1356
+ multi: true,
1357
+ provide: NG_VALUE_ACCESSOR,
1358
+ useExisting: MatFileInputsComponent
1359
+ }
1360
+ ], template: "<ng-container [formGroup]=\"formGroup\">\n @for (item of formArray.value; track index; let index = $index) {\n <div class=\"flex mb-3\">\n <cl-mat-file-input [formControlName]=\"index\" [directory]=\"directory()\" [icon]=\"icon()\" [label]=\"label()\"\n (onDownload)=\"onDownload($event)\" [readonly]=\"readonly()\" />\n @if (!readonly()) {\n @if (index === 0) {\n <button (click)=\"onAdd()\" [disabled]=\"formArray.length >= max()\" mat-icon-button type=\"button\">\n <mat-icon>{{ icon() }}</mat-icon>\n </button>\n } @else if (index > 0) {\n <button (click)=\"onDelete(index)\" mat-icon-button type=\"button\">\n <mat-icon>remove</mat-icon>\n </button>\n }\n }\n </div>\n }\n</ng-container>\n" }]
1361
+ }], propDecorators: { directory: [{ type: i0.Input, args: [{ isSignal: true, alias: "directory", required: false }] }], icon: [{ type: i0.Input, args: [{ isSignal: true, alias: "icon", required: false }] }], label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }], max: [{ type: i0.Input, args: [{ isSignal: true, alias: "max", required: false }] }], readonly: [{ type: i0.Input, args: [{ isSignal: true, alias: "readonly", required: false }] }], onDownloadEmitter: [{ type: i0.Output, args: ["onDownload"] }] } });
1362
+
972
1363
  ;
973
1364
 
974
1365
  class CommonLibModule {
@@ -1006,5 +1397,5 @@ function concatWithToArray(values) {
1006
1397
  * Generated bundle index. Do not edit.
1007
1398
  */
1008
1399
 
1009
- export { BaseFormComponent, ButtonComponent, ClStateService, CommonLibModule, ConfirmationComponent, ConfirmationService, ContentDialogComponent, ContentDialogService, ERROR_DIRECTIVE, ErrorDirective, FORM_FIELD, FileInputComponent, FileInputsComponent, FormDialogComponent, FormDialogService, FormFieldComponent, FormFieldModule, IconButtonComponent, LABEL_DIRECTIVE, LabelDirective, ProgressBarDialogComponent, ProgressBarDialogService, ReadonlyValueComponent, ToastsComponent, ToastsService, concatWithToArray };
1400
+ export { BaseFormComponent, ButtonComponent, ClStateService, CommonLibModule, ConfirmationComponent, ConfirmationService, ContentDialogComponent, ContentDialogService, ERROR_DIRECTIVE, ErrorDirective, FORM_FIELD, FileInputComponent, FileInputsComponent, FormDialogComponent, FormDialogService, FormFieldComponent, FormFieldModule, IconButtonComponent, LABEL_DIRECTIVE, LabelDirective, MatConfirmationComponent, MatConfirmationService, MatFileInputComponent, MatFileInputsComponent, MatFormDialogComponent, MatFormDialogService, MatFormHostableComponent, ProgressBarDialogComponent, ProgressBarDialogService, ReadonlyValueComponent, ToastsComponent, ToastsService, concatWithToArray };
1010
1401
  //# sourceMappingURL=jm-7c3-common-lib.mjs.map